新增调用前端分区渲染功能,节点通过 ref 文件传输,并增加简单认证

This commit is contained in:
2026-05-18 16:21:23 +08:00
parent 3e3deaa724
commit 69a90de9a1
4 changed files with 89 additions and 4 deletions
+25 -3
View File
@@ -45,6 +45,7 @@ export type StoreResultInput = {
export type RetrievalContext = {
actorKey: string;
clientSessionId?: string;
maxItems?: number;
projectId?: string;
};
@@ -105,18 +106,33 @@ export class ResultReferenceStore {
return record;
}
async getAuthorized(resultRef: string, context: RetrievalContext) {
async getAuthorized(resultRef: string, context: RetrievalContext) {
const record = await this.readAuthorizedRecord(resultRef, context);
if (!record) {
return null;
}
const data = projectData(record.data, context.maxItems ?? config.RESULT_REF_MAX_RETRIEVAL_ITEMS);
return {
ok: true,
result_ref: record.resultRef,
result_size_bytes: record.sizeBytes,
stored_at: record.createdAt,
data,
preview: record.preview,
};
}
async getFullAuthorized(resultRef: string, context: RetrievalContext) {
const record = await this.readAuthorizedRecord(resultRef, context);
if (!record) {
return null;
}
const data = projectData(record.data, context.maxItems ?? config.RESULT_REF_MAX_RETRIEVAL_ITEMS);
return {
ok: true,
result_ref: record.resultRef,
result_size_bytes: record.sizeBytes,
stored_at: record.createdAt,
data,
data: record.data,
preview: record.preview,
};
}
@@ -173,6 +189,12 @@ export class ResultReferenceStore {
if ((record.projectId ?? "") !== (context.projectId ?? "")) {
return null;
}
if (
context.clientSessionId &&
record.clientSessionId !== context.clientSessionId
) {
return null;
}
return record;
}
}