stratagate-dsh 0.2.70 → 0.2.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/client.js +15 -5
- package/dist/plugin.js +129 -38
- package/dist/plugin.js.map +1 -1
- package/package.json +3 -3
package/dist/plugin.js
CHANGED
|
@@ -1314,7 +1314,7 @@ function normalizeRetrievalAssessment(input, batchEvidenceRefs) {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
|
|
1316
1316
|
// packages/core/src/storage.ts
|
|
1317
|
-
var STRATAGATE_STORAGE_SCHEMA_VERSION =
|
|
1317
|
+
var STRATAGATE_STORAGE_SCHEMA_VERSION = 11;
|
|
1318
1318
|
var KNOWLEDGE_GRAPH_PROJECTOR_VERSION = 1;
|
|
1319
1319
|
var DERIVATION_MAX_ATTEMPTS = 3;
|
|
1320
1320
|
var StorageConflictError = class extends Error {
|
|
@@ -1449,6 +1449,11 @@ function normalizeSnapshot(value) {
|
|
|
1449
1449
|
schemaVersion: STRATAGATE_STORAGE_SCHEMA_VERSION,
|
|
1450
1450
|
externalMemoryImportJobs: []
|
|
1451
1451
|
};
|
|
1452
|
+
} else if (schemaVersion === 10) {
|
|
1453
|
+
snapshot = {
|
|
1454
|
+
...structuredClone(value),
|
|
1455
|
+
schemaVersion: STRATAGATE_STORAGE_SCHEMA_VERSION
|
|
1456
|
+
};
|
|
1452
1457
|
} else if (schemaVersion === STRATAGATE_STORAGE_SCHEMA_VERSION) {
|
|
1453
1458
|
snapshot = structuredClone(value);
|
|
1454
1459
|
} else {
|
|
@@ -1471,8 +1476,16 @@ function normalizeSnapshot(value) {
|
|
|
1471
1476
|
for (const job of snapshot.graphProjectionJobs) {
|
|
1472
1477
|
if (job.nextRetryAt === void 0) job.nextRetryAt = null;
|
|
1473
1478
|
}
|
|
1479
|
+
const sourceBlockMap = new Map(snapshot.blocks.map((block) => [block.id, block]));
|
|
1474
1480
|
for (const event of snapshot.events) {
|
|
1475
1481
|
event.temporal = { ...event.temporal, eventType: normalizeStandardEventType(event.temporal.eventType) };
|
|
1482
|
+
if (event.formedTurn === void 0) {
|
|
1483
|
+
const sourceBlock = sourceBlockMap.get(event.sourceBlockId);
|
|
1484
|
+
const reliableSource = sourceBlock && !sourceBlock.threadId?.startsWith("external-import:") && Number.isSafeInteger(sourceBlock.endTurn) && sourceBlock.endTurn >= 0;
|
|
1485
|
+
if (reliableSource) event.formedTurn = sourceBlock.endTurn;
|
|
1486
|
+
} else if (!Number.isSafeInteger(event.formedTurn) || event.formedTurn < 0) {
|
|
1487
|
+
throw new TypeError("Invalid StrataGate snapshot: Event formedTurn must be a non-negative integer");
|
|
1488
|
+
}
|
|
1476
1489
|
}
|
|
1477
1490
|
for (const block of snapshot.blocks) {
|
|
1478
1491
|
if (block.processingStatus !== "pending" && block.processingStatus !== "ready") {
|
|
@@ -1719,6 +1732,7 @@ CREATE TABLE IF NOT EXISTS events (
|
|
|
1719
1732
|
tags_json TEXT NOT NULL,
|
|
1720
1733
|
quotes_json TEXT NOT NULL,
|
|
1721
1734
|
source_block_id TEXT NOT NULL,
|
|
1735
|
+
formed_turn INTEGER,
|
|
1722
1736
|
temporal_json TEXT NOT NULL,
|
|
1723
1737
|
scope TEXT NOT NULL,
|
|
1724
1738
|
criticality TEXT NOT NULL,
|
|
@@ -2024,6 +2038,7 @@ var SqliteStorage = class {
|
|
|
2024
2038
|
quotes: parseJson(row.quotes_json, "events.quotes_json"),
|
|
2025
2039
|
sourceMessageIds: sourcesByEvent.get(row.id) ?? [],
|
|
2026
2040
|
sourceBlockId: row.source_block_id,
|
|
2041
|
+
...row.formed_turn === null ? {} : { formedTurn: row.formed_turn },
|
|
2027
2042
|
temporal: (() => {
|
|
2028
2043
|
const temporal = parseJson(row.temporal_json, "events.temporal_json");
|
|
2029
2044
|
return { ...temporal, eventType: normalizeStandardEventType(temporal.eventType) };
|
|
@@ -2334,10 +2349,10 @@ var SqliteStorage = class {
|
|
|
2334
2349
|
const insertEvent = this.database.prepare(`
|
|
2335
2350
|
INSERT INTO events (
|
|
2336
2351
|
namespace, id, position, title, summary, narrative, tags_json, quotes_json, source_block_id,
|
|
2337
|
-
temporal_json, scope, criticality, confidence, status, superseded_by,
|
|
2352
|
+
formed_turn, temporal_json, scope, criticality, confidence, status, superseded_by,
|
|
2338
2353
|
mention_count, last_adopted_turn, last_retrieved_at, pinned, floor_weight, forced_cap,
|
|
2339
2354
|
created_at, updated_at
|
|
2340
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
2355
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
2341
2356
|
ON CONFLICT (namespace, id) DO UPDATE SET
|
|
2342
2357
|
position = excluded.position,
|
|
2343
2358
|
title = excluded.title,
|
|
@@ -2346,6 +2361,7 @@ var SqliteStorage = class {
|
|
|
2346
2361
|
tags_json = excluded.tags_json,
|
|
2347
2362
|
quotes_json = excluded.quotes_json,
|
|
2348
2363
|
source_block_id = excluded.source_block_id,
|
|
2364
|
+
formed_turn = excluded.formed_turn,
|
|
2349
2365
|
temporal_json = excluded.temporal_json,
|
|
2350
2366
|
scope = excluded.scope,
|
|
2351
2367
|
criticality = excluded.criticality,
|
|
@@ -2376,6 +2392,7 @@ var SqliteStorage = class {
|
|
|
2376
2392
|
JSON.stringify(event.tags),
|
|
2377
2393
|
JSON.stringify(event.quotes),
|
|
2378
2394
|
event.sourceBlockId,
|
|
2395
|
+
event.formedTurn ?? null,
|
|
2379
2396
|
JSON.stringify(event.temporal),
|
|
2380
2397
|
event.scope,
|
|
2381
2398
|
event.criticality,
|
|
@@ -2644,6 +2661,23 @@ var SqliteStorage = class {
|
|
|
2644
2661
|
if (!blockColumns.some(({ name: name2 }) => name2 === "processing_status")) {
|
|
2645
2662
|
this.database.exec("ALTER TABLE blocks ADD COLUMN processing_status TEXT NOT NULL DEFAULT 'ready' CHECK (processing_status IN ('pending', 'ready'))");
|
|
2646
2663
|
}
|
|
2664
|
+
const eventColumns = this.database.prepare("PRAGMA table_info('events')").all();
|
|
2665
|
+
if (!eventColumns.some(({ name: name2 }) => name2 === "formed_turn")) {
|
|
2666
|
+
this.database.exec("ALTER TABLE events ADD COLUMN formed_turn INTEGER");
|
|
2667
|
+
}
|
|
2668
|
+
this.database.exec(`
|
|
2669
|
+
UPDATE events
|
|
2670
|
+
SET formed_turn = (
|
|
2671
|
+
SELECT blocks.end_turn FROM blocks
|
|
2672
|
+
WHERE blocks.namespace = events.namespace AND blocks.id = events.source_block_id
|
|
2673
|
+
)
|
|
2674
|
+
WHERE formed_turn IS NULL AND EXISTS (
|
|
2675
|
+
SELECT 1 FROM blocks
|
|
2676
|
+
WHERE blocks.namespace = events.namespace
|
|
2677
|
+
AND blocks.id = events.source_block_id
|
|
2678
|
+
AND (blocks.thread_id IS NULL OR blocks.thread_id NOT LIKE 'external-import:%')
|
|
2679
|
+
)
|
|
2680
|
+
`);
|
|
2647
2681
|
const extractionColumns = this.database.prepare("PRAGMA table_info('extraction_jobs')").all();
|
|
2648
2682
|
if (!extractionColumns.some(({ name: name2 }) => name2 === "next_retry_at")) {
|
|
2649
2683
|
this.database.exec("ALTER TABLE extraction_jobs ADD COLUMN next_retry_at TEXT");
|
|
@@ -4059,8 +4093,10 @@ var StrataGate = class _StrataGate {
|
|
|
4059
4093
|
const sourceMessageIds = requestedRefs.length > 0 ? requestedRefs : sourceBlock.l5Raw.map((message) => message.id);
|
|
4060
4094
|
const now = toUtc8Iso(this.now());
|
|
4061
4095
|
const criticality = input.criticality ?? "routine";
|
|
4096
|
+
const formedTurn = sourceBlock.threadId?.startsWith("external-import:") ? this.currentTurn : sourceBlock.endTurn;
|
|
4062
4097
|
const event = {
|
|
4063
4098
|
id: input.id ?? this.idFactory("evt"),
|
|
4099
|
+
formedTurn,
|
|
4064
4100
|
title: input.title.trim(),
|
|
4065
4101
|
summary: input.summary.trim(),
|
|
4066
4102
|
narrative: input.narrative?.trim() || input.summary.trim(),
|
|
@@ -4079,7 +4115,7 @@ var StrataGate = class _StrataGate {
|
|
|
4079
4115
|
supersededBy: null,
|
|
4080
4116
|
weight: {
|
|
4081
4117
|
mentionCount: 1,
|
|
4082
|
-
lastAdoptedTurn:
|
|
4118
|
+
lastAdoptedTurn: formedTurn,
|
|
4083
4119
|
lastRetrievedAt: null,
|
|
4084
4120
|
pinned: false,
|
|
4085
4121
|
floorWeight: criticalityFloor(criticality),
|
|
@@ -7983,7 +8019,8 @@ function appendWeightSegment(points, event, fromTurn, toTurn, mentionCount) {
|
|
|
7983
8019
|
if (toTurn < fromTurn) return;
|
|
7984
8020
|
if (toTurn === fromTurn) return;
|
|
7985
8021
|
const span = toTurn - fromTurn;
|
|
7986
|
-
const
|
|
8022
|
+
const samples = Math.min(256, Math.max(12, Math.ceil(span * 12)));
|
|
8023
|
+
const step = span / samples;
|
|
7987
8024
|
for (let turn = fromTurn; turn < toTurn; turn += step) {
|
|
7988
8025
|
points.push({ turn, weight: sampledEventWeight(event, turn, fromTurn, mentionCount), kind: "sample" });
|
|
7989
8026
|
}
|
|
@@ -7991,65 +8028,116 @@ function appendWeightSegment(points, event, fromTurn, toTurn, mentionCount) {
|
|
|
7991
8028
|
}
|
|
7992
8029
|
function eventWeightTrajectory(snapshot, event) {
|
|
7993
8030
|
const currentTurn = snapshot.currentTurn;
|
|
8031
|
+
const formedTurn = Number.isSafeInteger(event.formedTurn) && event.formedTurn >= 0 ? event.formedTurn : null;
|
|
8032
|
+
const sourceBlock = snapshot.blocks.find(({ id }) => id === event.sourceBlockId);
|
|
8033
|
+
const sourceBlockEndTurn = Number.isSafeInteger(sourceBlock?.endTurn) && sourceBlock.endTurn >= 0 ? sourceBlock.endTurn : null;
|
|
7994
8034
|
const effectiveAdoptions = Math.max(0, event.weight.mentionCount - 1);
|
|
7995
8035
|
const adoptionReceipts = snapshot.usageReceipts.filter(({ eventIds }) => eventIds.includes(event.id));
|
|
7996
8036
|
const adoptionTurns = adoptionReceipts.map(({ audit: audit2 }) => audit2?.turn).filter((turn) => Number.isSafeInteger(turn) && turn >= 0).sort((left, right) => left - right);
|
|
7997
|
-
const
|
|
8037
|
+
const confirmedAdoptionTurns = [...adoptionTurns];
|
|
8038
|
+
if (effectiveAdoptions > 0 && Number.isSafeInteger(event.weight.lastAdoptedTurn) && event.weight.lastAdoptedTurn >= 0) {
|
|
8039
|
+
confirmedAdoptionTurns.push(event.weight.lastAdoptedTurn);
|
|
8040
|
+
}
|
|
8041
|
+
confirmedAdoptionTurns.sort((left, right) => left - right);
|
|
8042
|
+
const groupedAdoptions = [...new Set(confirmedAdoptionTurns)].map((turn) => ({
|
|
8043
|
+
turn,
|
|
8044
|
+
adoptionCount: Math.max(1, adoptionTurns.filter((value) => value === turn).length)
|
|
8045
|
+
}));
|
|
8046
|
+
const earliestKnownAdoptionTurn = groupedAdoptions[0]?.turn ?? null;
|
|
8047
|
+
const trajectoryStartTurn = formedTurn ?? sourceBlockEndTurn ?? earliestKnownAdoptionTurn ?? currentTurn;
|
|
8048
|
+
const formationTurnSource = formedTurn !== null ? "formedTurn" : sourceBlockEndTurn !== null ? "sourceBlock" : null;
|
|
8049
|
+
const historyComplete = adoptionReceipts.length === effectiveAdoptions && adoptionTurns.length === adoptionReceipts.length && (effectiveAdoptions === 0 || adoptionTurns.at(-1) === event.weight.lastAdoptedTurn) && adoptionTurns.every((turn) => turn >= trajectoryStartTurn) && (effectiveAdoptions > 0 || event.weight.lastAdoptedTurn === trajectoryStartTurn);
|
|
8050
|
+
const adoptionHistoryComplete = adoptionReceipts.length === effectiveAdoptions && adoptionReceipts.every((receipt) => Boolean(receipt.createdAt) && Number.isFinite(Date.parse(receipt.createdAt)) && Boolean(receipt.audit?.sessionId?.trim()) && Number.isSafeInteger(receipt.audit?.turn) && receipt.audit.turn >= 0) && (formedTurn === null || adoptionReceipts.every((receipt) => receipt.audit.turn >= formedTurn));
|
|
8051
|
+
const adoptionHistory = adoptionReceipts.filter((receipt) => Boolean(receipt.createdAt) && Number.isFinite(Date.parse(receipt.createdAt)) && Boolean(receipt.audit?.sessionId?.trim()) && Number.isSafeInteger(receipt.audit?.turn) && receipt.audit.turn >= 0 && (formedTurn === null || receipt.audit.turn >= formedTurn)).map((receipt) => ({
|
|
8052
|
+
receiptId: receipt.id,
|
|
8053
|
+
createdAt: receipt.createdAt,
|
|
8054
|
+
sessionId: receipt.audit.sessionId,
|
|
8055
|
+
turn: receipt.audit.turn,
|
|
8056
|
+
...formedTurn === null ? {} : { relativeTurn: receipt.audit.turn - formedTurn },
|
|
8057
|
+
evidenceRefs: receipt.audit?.evidenceRefs ?? []
|
|
8058
|
+
})).sort((left, right) => left.turn - right.turn || left.createdAt.localeCompare(right.createdAt));
|
|
7998
8059
|
const canInterpolate = event.status !== "forgotten" && event.status !== "archived" && event.weight.forcedCap === null && !event.weight.pinned;
|
|
7999
|
-
const
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
}
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
points.push({ turn: anchorTurn, weight: 1, kind: "adoption", label: "\u91C7\u7528" });
|
|
8010
|
-
for (const [index, turn] of adoptionTurns.slice(1).entries()) {
|
|
8011
|
-
appendWeightSegment(points, event, anchorTurn, turn, mentionCount);
|
|
8012
|
-
points.push({ turn, weight: 1, kind: "adoption", label: index === adoptionTurns.length - 2 ? "\u518D\u6B21\u91C7\u7528" : "\u91C7\u7528" });
|
|
8060
|
+
const segments = [];
|
|
8061
|
+
const originPoint = formationTurnSource ? { turn: trajectoryStartTurn, weight: 1, kind: "creation", label: formationTurnSource === "formedTurn" ? "\u5F62\u6210" : "\u6765\u6E90" } : null;
|
|
8062
|
+
if (canInterpolate && historyComplete && originPoint) {
|
|
8063
|
+
const lifecycle = [originPoint];
|
|
8064
|
+
let anchorTurn = trajectoryStartTurn;
|
|
8065
|
+
let mentionCount = 1;
|
|
8066
|
+
for (const { turn, adoptionCount } of groupedAdoptions) {
|
|
8067
|
+
if (turn < trajectoryStartTurn || turn > currentTurn) continue;
|
|
8068
|
+
appendWeightSegment(lifecycle, event, anchorTurn, turn, mentionCount);
|
|
8069
|
+
lifecycle.push({ turn, weight: 1, kind: "adoption", adoptionCount, label: adoptionCount > 1 ? `\u91C7\u7EB3 \xD7${adoptionCount}` : "\u91C7\u7EB3" });
|
|
8013
8070
|
anchorTurn = turn;
|
|
8014
|
-
mentionCount +=
|
|
8071
|
+
mentionCount += adoptionCount;
|
|
8015
8072
|
}
|
|
8016
|
-
appendWeightSegment(
|
|
8073
|
+
appendWeightSegment(lifecycle, event, anchorTurn, currentTurn, mentionCount);
|
|
8074
|
+
segments.push({ certainty: "known", points: lifecycle });
|
|
8017
8075
|
} else if (canInterpolate) {
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8076
|
+
let anchorPoint = originPoint;
|
|
8077
|
+
let mentionCount = 1;
|
|
8078
|
+
const visibleAdoptions = groupedAdoptions.filter(({ turn }) => turn >= trajectoryStartTurn && turn <= currentTurn);
|
|
8079
|
+
for (const { turn, adoptionCount } of visibleAdoptions) {
|
|
8080
|
+
if (anchorPoint && turn > anchorPoint.turn) {
|
|
8081
|
+
const incomplete = [anchorPoint];
|
|
8082
|
+
appendWeightSegment(incomplete, event, anchorPoint.turn, turn, mentionCount);
|
|
8083
|
+
incomplete.push({ turn, weight: 1, kind: "adoption", adoptionCount, label: adoptionCount > 1 ? `\u91C7\u7EB3 \xD7${adoptionCount}` : "\u91C7\u7EB3" });
|
|
8084
|
+
segments.push({ certainty: "incomplete", points: incomplete });
|
|
8085
|
+
} else {
|
|
8086
|
+
segments.push({ certainty: "known", points: [{ turn, weight: 1, kind: "adoption", adoptionCount, label: adoptionCount > 1 ? `\u91C7\u7EB3 \xD7${adoptionCount}` : "\u91C7\u7EB3" }] });
|
|
8087
|
+
}
|
|
8088
|
+
anchorPoint = { turn, weight: 1, kind: "adoption", adoptionCount, label: adoptionCount > 1 ? `\u91C7\u7EB3 \xD7${adoptionCount}` : "\u91C7\u7EB3" };
|
|
8089
|
+
mentionCount += adoptionCount;
|
|
8090
|
+
}
|
|
8091
|
+
if (anchorPoint && anchorPoint.turn <= currentTurn) {
|
|
8092
|
+
const latestIsReliable = effectiveAdoptions > 0 && anchorPoint.turn === event.weight.lastAdoptedTurn && visibleAdoptions.at(-1)?.turn === event.weight.lastAdoptedTurn;
|
|
8093
|
+
const tail = [anchorPoint];
|
|
8094
|
+
appendWeightSegment(tail, event, anchorPoint.turn, currentTurn, latestIsReliable ? event.weight.mentionCount : mentionCount);
|
|
8095
|
+
if (tail.length > 1) segments.push({ certainty: latestIsReliable ? "known" : "incomplete", points: tail });
|
|
8096
|
+
} else if (originPoint && originPoint.turn <= currentTurn) {
|
|
8097
|
+
const tail = [originPoint];
|
|
8098
|
+
appendWeightSegment(tail, event, originPoint.turn, currentTurn, 1);
|
|
8099
|
+
if (tail.length > 1) segments.push({ certainty: historyComplete ? "known" : "incomplete", points: tail });
|
|
8100
|
+
else segments.push({ certainty: "known", points: [originPoint] });
|
|
8101
|
+
}
|
|
8102
|
+
} else if (originPoint) {
|
|
8103
|
+
segments.push({ certainty: "known", points: [originPoint] });
|
|
8023
8104
|
}
|
|
8024
8105
|
const currentWeight = memoryWeightAt(event, currentTurn);
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
weight: currentWeight,
|
|
8031
|
-
label: `${points[points.length - 1].label} \xB7 \u5F53\u524D`
|
|
8032
|
-
};
|
|
8106
|
+
const lastSegment = segments.at(-1);
|
|
8107
|
+
if (!lastSegment || lastSegment.points.at(-1)?.turn !== currentTurn) {
|
|
8108
|
+
segments.push({ certainty: "known", points: [{ turn: currentTurn, weight: currentWeight, kind: "current", label: "\u5F53\u524D" }] });
|
|
8109
|
+
} else if (lastSegment.points.at(-1)?.kind === "sample") {
|
|
8110
|
+
lastSegment.points[lastSegment.points.length - 1] = { ...lastSegment.points[lastSegment.points.length - 1], weight: currentWeight, kind: "current", label: "\u5F53\u524D" };
|
|
8033
8111
|
} else {
|
|
8034
|
-
|
|
8112
|
+
segments.push({ certainty: "known", points: [{ turn: currentTurn, weight: currentWeight, kind: "current", label: "\u5F53\u524D" }] });
|
|
8035
8113
|
}
|
|
8114
|
+
const points = segments.flatMap(({ points: segmentPoints }) => segmentPoints);
|
|
8036
8115
|
return {
|
|
8037
8116
|
scale: "conversation_turn",
|
|
8117
|
+
formedTurn,
|
|
8118
|
+
trajectoryStartTurn,
|
|
8119
|
+
formationTurnSource,
|
|
8038
8120
|
currentTurn,
|
|
8039
8121
|
currentWeight,
|
|
8040
8122
|
effectiveAdoptions,
|
|
8123
|
+
floorWeight: event.weight.floorWeight,
|
|
8124
|
+
criticality: event.criticality,
|
|
8041
8125
|
latestAdoptionTurn: effectiveAdoptions > 0 ? event.weight.lastAdoptedTurn : null,
|
|
8042
8126
|
turnsSinceLatestAdoption: effectiveAdoptions > 0 ? Math.max(0, currentTurn - event.weight.lastAdoptedTurn) : null,
|
|
8043
8127
|
lastRetrievedAt: event.weight.lastRetrievedAt,
|
|
8044
8128
|
recordedAdoptionTurns: adoptionTurns,
|
|
8045
8129
|
historyComplete,
|
|
8130
|
+
adoptionHistoryComplete,
|
|
8131
|
+
adoptionHistory,
|
|
8132
|
+
segments,
|
|
8046
8133
|
points,
|
|
8047
|
-
note: !canInterpolate ? "\u56FA\u5B9A\u3001\u5C01\u5B58\u6216\u72B6\u6001\u4E0A\u9650\u7684\u53D8\u66F4\u8F6E\u6B21\u6CA1\u6709\u5386\u53F2\u8BB0\u5F55\uFF0C\u56E0\u6B64\u4EC5\u663E\u793A\u5F53\u524D\u771F\u5B9E\u6743\u91CD\u3002" :
|
|
8134
|
+
note: !canInterpolate ? "\u56FA\u5B9A\u3001\u5C01\u5B58\u6216\u72B6\u6001\u4E0A\u9650\u7684\u53D8\u66F4\u8F6E\u6B21\u6CA1\u6709\u5386\u53F2\u8BB0\u5F55\uFF0C\u56E0\u6B64\u4EC5\u663E\u793A\u5F53\u524D\u771F\u5B9E\u6743\u91CD\u3002" : !historyComplete ? "\u65E7\u7248\u672C\u672A\u8BB0\u5F55\u90E8\u5206\u91C7\u7EB3\u7684\u5177\u4F53\u8F6E\u6B21\uFF1B\u786E\u5B9A\u8282\u70B9\u4E0E\u533A\u95F4\u7167\u5E38\u663E\u793A\uFF0C\u7F3A\u5931\u533A\u95F4\u4EC5\u4F5C\u8D8B\u52BF\u8FDE\u63A5\u3002" : effectiveAdoptions > 0 ? "\u91C7\u7EB3\u8F6E\u6B21\u6765\u81EA\u771F\u5B9E\u4F7F\u7528\u56DE\u6267\u3002" : "\u5C1A\u672A\u88AB Agent \u91C7\u7EB3\u3002"
|
|
8048
8135
|
};
|
|
8049
8136
|
}
|
|
8050
8137
|
function eventSummary(event, snapshot) {
|
|
8051
8138
|
return {
|
|
8052
8139
|
id: event.id,
|
|
8140
|
+
formedTurn: event.formedTurn,
|
|
8053
8141
|
title: event.title,
|
|
8054
8142
|
summary: event.summary,
|
|
8055
8143
|
narrative: event.narrative,
|
|
@@ -8514,7 +8602,7 @@ async function memories(runtime, url) {
|
|
|
8514
8602
|
return time(right).localeCompare(time(left));
|
|
8515
8603
|
}).map((event) => ({
|
|
8516
8604
|
...eventSummary(event, snapshot),
|
|
8517
|
-
relatedNodes: snapshot.graphNodes.filter(({ id
|
|
8605
|
+
relatedNodes: snapshot.graphNodes.filter(({ id }) => (event.temporal.participantNodeIds ?? []).includes(id)).map(({ id, name: name2, type, aliases }) => ({ id, name: name2, type, aliases })),
|
|
8518
8606
|
relatedElements: snapshot.elements.filter(({ sourceEventIds }) => sourceEventIds.includes(event.id)).map(({ id, name: name2 }) => ({ id, name: name2 }))
|
|
8519
8607
|
}));
|
|
8520
8608
|
else if (kind === "graph") {
|
|
@@ -8705,6 +8793,9 @@ async function sources(runtime, url) {
|
|
|
8705
8793
|
return {
|
|
8706
8794
|
namespace,
|
|
8707
8795
|
events: events.map((event) => eventSummary(event, eventId ? snapshot : void 0)),
|
|
8796
|
+
...eventId ? {
|
|
8797
|
+
relatedNodes: snapshot.graphNodes.filter(({ id }) => events[0]?.temporal.participantNodeIds?.includes(id)).map(({ id, name: name2, type, aliases }) => ({ id, name: name2, type, aliases }))
|
|
8798
|
+
} : {},
|
|
8708
8799
|
elements: elements.map(elementSummary),
|
|
8709
8800
|
blocks: events.map((event) => snapshot.blocks.find(({ id }) => id === event.sourceBlockId)).filter((block) => Boolean(block)).map((block) => ({ id: block.id, title: block.l0Title, createdAt: block.createdAt })),
|
|
8710
8801
|
messages: sourceMessages(snapshot, ids)
|