refactor(agent): 移除旧工具桥
This commit is contained in:
+20
-65
@@ -26,83 +26,50 @@ describe("ResultReferenceResolver", () => {
|
||||
await rm(tempDir, { force: true, recursive: true });
|
||||
});
|
||||
|
||||
it("stores metadata for new referenced results and resolves them", async () => {
|
||||
it("stores metadata for render refs and resolves them", async () => {
|
||||
const record = await resolver.register({
|
||||
actorKey: "actor-1",
|
||||
clientSessionId: "client-1",
|
||||
data: [{ id: "J1" }, { id: "J2" }],
|
||||
kind: RESULT_REFERENCE_KIND.dynamicHttpResult,
|
||||
data: {
|
||||
node_area_map: {
|
||||
J1: "DMA-1",
|
||||
J2: "DMA-2",
|
||||
},
|
||||
},
|
||||
kind: RESULT_REFERENCE_KIND.renderJunctionsPayload,
|
||||
projectId: "project-1",
|
||||
projectKey: "project-key-1",
|
||||
schemaVersion: 1,
|
||||
sessionId: "session-1",
|
||||
source: RESULT_REFERENCE_SOURCE.dynamicHttp,
|
||||
source: RESULT_REFERENCE_SOURCE.agentGenerated,
|
||||
traceId: "trace-1",
|
||||
});
|
||||
|
||||
expect(record.kind).toBe(RESULT_REFERENCE_KIND.dynamicHttpResult);
|
||||
expect(record.kind).toBe(RESULT_REFERENCE_KIND.renderJunctionsPayload);
|
||||
expect(record.schemaVersion).toBe(1);
|
||||
expect(record.source).toBe(RESULT_REFERENCE_SOURCE.dynamicHttp);
|
||||
expect(record.source).toBe(RESULT_REFERENCE_SOURCE.agentGenerated);
|
||||
|
||||
const result = await resolver.getAuthorized(
|
||||
const result = await resolver.getFullAuthorized(
|
||||
record.resultRef,
|
||||
{
|
||||
actorKey: "actor-1",
|
||||
projectId: "project-1",
|
||||
},
|
||||
{
|
||||
maxItems: 1,
|
||||
},
|
||||
);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.kind).toBe(RESULT_REFERENCE_KIND.dynamicHttpResult);
|
||||
expect(result?.kind).toBe(RESULT_REFERENCE_KIND.renderJunctionsPayload);
|
||||
expect(result?.schema_version).toBe(1);
|
||||
expect(result?.source).toBe(RESULT_REFERENCE_SOURCE.dynamicHttp);
|
||||
expect(result?.data).toEqual([{ id: "J1" }]);
|
||||
});
|
||||
|
||||
it("keeps legacy result refs readable while defaulting metadata", async () => {
|
||||
const legacyRef = "res-aaaaaaaaaaaaaaaa";
|
||||
await writeFile(
|
||||
join(tempDir, `${legacyRef}.json`),
|
||||
JSON.stringify(
|
||||
{
|
||||
resultRef: legacyRef,
|
||||
actorKey: "actor-legacy",
|
||||
clientSessionId: "client-legacy",
|
||||
createdAt: "2026-05-21T00:00:00.000Z",
|
||||
data: { nodes: ["J1"] },
|
||||
preview: {
|
||||
count: 1,
|
||||
fields: ["nodes"],
|
||||
sample: { nodes: ["J1"] },
|
||||
summary: "object<1 fields>",
|
||||
},
|
||||
projectId: "project-legacy",
|
||||
projectKey: "project-key-legacy",
|
||||
sessionId: "session-legacy",
|
||||
sizeBytes: 16,
|
||||
traceId: "trace-legacy",
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const record = await store.getAuthorizedRecord(legacyRef, {
|
||||
actorKey: "actor-legacy",
|
||||
projectId: "project-legacy",
|
||||
expect(result?.source).toBe(RESULT_REFERENCE_SOURCE.agentGenerated);
|
||||
expect(result?.data).toEqual({
|
||||
node_area_map: {
|
||||
J1: "DMA-1",
|
||||
J2: "DMA-2",
|
||||
},
|
||||
});
|
||||
|
||||
expect(record).not.toBeNull();
|
||||
expect(record?.kind).toBe(RESULT_REFERENCE_KIND.dynamicHttpResult);
|
||||
expect(record?.schemaVersion).toBe(1);
|
||||
expect(record?.source).toBe(RESULT_REFERENCE_SOURCE.legacy);
|
||||
});
|
||||
|
||||
it("rejects malformed refs, mismatched kinds, and auth mismatches", async () => {
|
||||
it("rejects malformed refs and auth mismatches", async () => {
|
||||
const malformedRef = "res-bbbbbbbbbbbbbbbb";
|
||||
await writeFile(
|
||||
join(tempDir, `${malformedRef}.json`),
|
||||
@@ -152,18 +119,6 @@ describe("ResultReferenceResolver", () => {
|
||||
traceId: "trace-2",
|
||||
});
|
||||
|
||||
const wrongKind = await resolver.getFullAuthorized(
|
||||
renderRecord.resultRef,
|
||||
{
|
||||
actorKey: "actor-2",
|
||||
projectId: "project-2",
|
||||
},
|
||||
{
|
||||
expectedKind: RESULT_REFERENCE_KIND.dynamicHttpResult,
|
||||
},
|
||||
);
|
||||
expect(wrongKind).toBeNull();
|
||||
|
||||
const wrongActor = await resolver.getFullAuthorized(renderRecord.resultRef, {
|
||||
actorKey: "actor-other",
|
||||
projectId: "project-2",
|
||||
|
||||
Reference in New Issue
Block a user