stratagate-dsh 0.2.68 → 0.2.69
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 +5 -0
- package/dist/client.js +19 -13
- package/dist/plugin.js +88 -8
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -2
package/dist/plugin.js
CHANGED
|
@@ -6217,6 +6217,11 @@ var StrataGateRuntime = class {
|
|
|
6217
6217
|
retrievedMemories,
|
|
6218
6218
|
incremented: eventIds.size + elementIds.size,
|
|
6219
6219
|
evidenceRefs: selectedRefs,
|
|
6220
|
+
...assessment === void 0 ? {} : {
|
|
6221
|
+
verdict: assessment.verdict,
|
|
6222
|
+
missing: assessment.missing,
|
|
6223
|
+
nextStrategy: assessment.nextStrategy
|
|
6224
|
+
},
|
|
6220
6225
|
duplicateEvidenceRefs,
|
|
6221
6226
|
eventIds: [...eventIds],
|
|
6222
6227
|
elementIds: [...elementIds],
|
|
@@ -7908,7 +7913,81 @@ Tags: ${block.l0Tags.join(", ") || "none"}` },
|
|
|
7908
7913
|
{ level: 5, content: formatRawTranscript(block.l5Raw) }
|
|
7909
7914
|
]);
|
|
7910
7915
|
}
|
|
7911
|
-
function
|
|
7916
|
+
function sampledEventWeight(event, turn, lastAdoptedTurn, mentionCount) {
|
|
7917
|
+
return memoryWeightAt({
|
|
7918
|
+
status: event.status,
|
|
7919
|
+
weight: { ...event.weight, lastAdoptedTurn, mentionCount }
|
|
7920
|
+
}, turn);
|
|
7921
|
+
}
|
|
7922
|
+
function appendWeightSegment(points, event, fromTurn, toTurn, mentionCount) {
|
|
7923
|
+
if (toTurn < fromTurn) return;
|
|
7924
|
+
if (toTurn === fromTurn) return;
|
|
7925
|
+
const span = toTurn - fromTurn;
|
|
7926
|
+
const step = Math.max(1, Math.ceil(span / 32));
|
|
7927
|
+
for (let turn = fromTurn; turn < toTurn; turn += step) {
|
|
7928
|
+
points.push({ turn, weight: sampledEventWeight(event, turn, fromTurn, mentionCount), kind: "sample" });
|
|
7929
|
+
}
|
|
7930
|
+
points.push({ turn: toTurn, weight: sampledEventWeight(event, toTurn, fromTurn, mentionCount), kind: "sample" });
|
|
7931
|
+
}
|
|
7932
|
+
function eventWeightTrajectory(snapshot, event) {
|
|
7933
|
+
const currentTurn = snapshot.currentTurn;
|
|
7934
|
+
const effectiveAdoptions = Math.max(0, event.weight.mentionCount - 1);
|
|
7935
|
+
const adoptionReceipts = snapshot.usageReceipts.filter(({ eventIds }) => eventIds.includes(event.id));
|
|
7936
|
+
const adoptionTurns = adoptionReceipts.map(({ audit: audit2 }) => audit2?.turn).filter((turn) => Number.isSafeInteger(turn) && turn >= 0).sort((left, right) => left - right);
|
|
7937
|
+
const historyComplete = adoptionReceipts.length === effectiveAdoptions && adoptionTurns.length === adoptionReceipts.length && (effectiveAdoptions === 0 || adoptionTurns.at(-1) === event.weight.lastAdoptedTurn);
|
|
7938
|
+
const canInterpolate = event.status !== "forgotten" && event.status !== "archived" && event.weight.forcedCap === null && !event.weight.pinned;
|
|
7939
|
+
const points = [];
|
|
7940
|
+
if (canInterpolate && effectiveAdoptions === 0) {
|
|
7941
|
+
appendWeightSegment(points, event, event.weight.lastAdoptedTurn, currentTurn, 1);
|
|
7942
|
+
if (points.length > 0) {
|
|
7943
|
+
const first = points[0];
|
|
7944
|
+
points[0] = { turn: first.turn, weight: first.weight, kind: "creation", label: "\u521B\u5EFA" };
|
|
7945
|
+
}
|
|
7946
|
+
} else if (canInterpolate && historyComplete && adoptionTurns.length > 0) {
|
|
7947
|
+
let anchorTurn = adoptionTurns[0];
|
|
7948
|
+
let mentionCount = 2;
|
|
7949
|
+
points.push({ turn: anchorTurn, weight: 1, kind: "adoption", label: "\u91C7\u7528" });
|
|
7950
|
+
for (const [index, turn] of adoptionTurns.slice(1).entries()) {
|
|
7951
|
+
appendWeightSegment(points, event, anchorTurn, turn, mentionCount);
|
|
7952
|
+
points.push({ turn, weight: 1, kind: "adoption", label: index === adoptionTurns.length - 2 ? "\u518D\u6B21\u91C7\u7528" : "\u91C7\u7528" });
|
|
7953
|
+
anchorTurn = turn;
|
|
7954
|
+
mentionCount += 1;
|
|
7955
|
+
}
|
|
7956
|
+
appendWeightSegment(points, event, anchorTurn, currentTurn, mentionCount);
|
|
7957
|
+
} else if (canInterpolate) {
|
|
7958
|
+
appendWeightSegment(points, event, event.weight.lastAdoptedTurn, currentTurn, event.weight.mentionCount);
|
|
7959
|
+
if (effectiveAdoptions > 0 && points.length > 0) {
|
|
7960
|
+
const first = points[0];
|
|
7961
|
+
points[0] = { turn: first.turn, weight: first.weight, kind: "adoption", label: "\u6700\u8FD1\u91C7\u7528" };
|
|
7962
|
+
}
|
|
7963
|
+
}
|
|
7964
|
+
const currentWeight = memoryWeightAt(event, currentTurn);
|
|
7965
|
+
if (points.length === 0 || points.at(-1)?.turn !== currentTurn) {
|
|
7966
|
+
points.push({ turn: currentTurn, weight: currentWeight, kind: "current", label: "\u5F53\u524D" });
|
|
7967
|
+
} else if (points.at(-1)?.kind === "creation" || points.at(-1)?.kind === "adoption") {
|
|
7968
|
+
points[points.length - 1] = {
|
|
7969
|
+
...points[points.length - 1],
|
|
7970
|
+
weight: currentWeight,
|
|
7971
|
+
label: `${points[points.length - 1].label} \xB7 \u5F53\u524D`
|
|
7972
|
+
};
|
|
7973
|
+
} else {
|
|
7974
|
+
points[points.length - 1] = { ...points[points.length - 1], weight: currentWeight, kind: "current", label: "\u5F53\u524D" };
|
|
7975
|
+
}
|
|
7976
|
+
return {
|
|
7977
|
+
scale: "conversation_turn",
|
|
7978
|
+
currentTurn,
|
|
7979
|
+
currentWeight,
|
|
7980
|
+
effectiveAdoptions,
|
|
7981
|
+
latestAdoptionTurn: effectiveAdoptions > 0 ? event.weight.lastAdoptedTurn : null,
|
|
7982
|
+
turnsSinceLatestAdoption: effectiveAdoptions > 0 ? Math.max(0, currentTurn - event.weight.lastAdoptedTurn) : null,
|
|
7983
|
+
lastRetrievedAt: event.weight.lastRetrievedAt,
|
|
7984
|
+
recordedAdoptionTurns: adoptionTurns,
|
|
7985
|
+
historyComplete,
|
|
7986
|
+
points,
|
|
7987
|
+
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" : effectiveAdoptions > 0 && !historyComplete ? "\u90E8\u5206\u65E9\u671F\u91C7\u7528\u8BB0\u5F55\u7F3A\u5C11\u8F6E\u6B21\uFF1B\u66F2\u7EBF\u4EC5\u4ECE\u6700\u8FD1\u4E00\u6B21\u53EF\u786E\u8BA4\u7684\u5F3A\u5316\u5F00\u59CB\u3002" : effectiveAdoptions > 0 ? "\u91C7\u7528\u8F6E\u6B21\u6765\u81EA\u4F7F\u7528\u56DE\u6267\uFF1B\u521B\u5EFA\u8F6E\u6B21\u672A\u5355\u72EC\u4FDD\u5B58\uFF0C\u56E0\u6B64\u4E0D\u63A8\u6D4B\u521B\u5EFA\u8282\u70B9\u3002" : "\u5C1A\u672A\u53D1\u751F\u6709\u6548\u91C7\u7528\uFF1B\u521B\u5EFA\u951A\u70B9\u6765\u81EA Event \u5F53\u524D\u6743\u91CD\u72B6\u6001\u3002"
|
|
7988
|
+
};
|
|
7989
|
+
}
|
|
7990
|
+
function eventSummary(event, snapshot) {
|
|
7912
7991
|
return {
|
|
7913
7992
|
id: event.id,
|
|
7914
7993
|
title: event.title,
|
|
@@ -7924,6 +8003,7 @@ function eventSummary(event) {
|
|
|
7924
8003
|
status: event.status,
|
|
7925
8004
|
supersededBy: event.supersededBy,
|
|
7926
8005
|
weight: event.weight,
|
|
8006
|
+
...snapshot ? { weightTrajectory: eventWeightTrajectory(snapshot, event) } : {},
|
|
7927
8007
|
createdAt: event.createdAt,
|
|
7928
8008
|
updatedAt: event.updatedAt
|
|
7929
8009
|
};
|
|
@@ -8373,7 +8453,7 @@ async function memories(runtime, url) {
|
|
|
8373
8453
|
const time = (event) => event.temporal.happenedStart ?? event.temporal.happenedEnd ?? event.temporal.mentionedAt ?? event.createdAt;
|
|
8374
8454
|
return time(right).localeCompare(time(left));
|
|
8375
8455
|
}).map((event) => ({
|
|
8376
|
-
...eventSummary(event),
|
|
8456
|
+
...eventSummary(event, snapshot),
|
|
8377
8457
|
relatedNodes: snapshot.graphNodes.filter(({ id, sourceEventIds }) => sourceEventIds.includes(event.id) || (event.temporal.participantNodeIds ?? []).includes(id)).map(({ id, name: name2, type }) => ({ id, name: name2, type })),
|
|
8378
8458
|
relatedElements: snapshot.elements.filter(({ sourceEventIds }) => sourceEventIds.includes(event.id)).map(({ id, name: name2 }) => ({ id, name: name2 }))
|
|
8379
8459
|
}));
|
|
@@ -8385,7 +8465,7 @@ async function memories(runtime, url) {
|
|
|
8385
8465
|
projectorVersion: KNOWLEDGE_GRAPH_PROJECTOR_VERSION,
|
|
8386
8466
|
nodes: snapshot.graphNodes.map((node) => ({
|
|
8387
8467
|
...node,
|
|
8388
|
-
supportingEvents: node.sourceEventIds.flatMap((id) => eventMap.get(id) ?? []).map(eventSummary)
|
|
8468
|
+
supportingEvents: node.sourceEventIds.flatMap((id) => eventMap.get(id) ?? []).map((event) => eventSummary(event))
|
|
8389
8469
|
})),
|
|
8390
8470
|
edges: snapshot.graphEdges,
|
|
8391
8471
|
clusters: clusterKnowledgeGraph(snapshot.graphNodes, snapshot.graphEdges),
|
|
@@ -8474,7 +8554,7 @@ async function memories(runtime, url) {
|
|
|
8474
8554
|
jobs: projections.length,
|
|
8475
8555
|
lastError: failedProjection?.lastError ?? null
|
|
8476
8556
|
} : null,
|
|
8477
|
-
relatedEvents: relatedEvents.map(eventSummary),
|
|
8557
|
+
relatedEvents: relatedEvents.map((event) => eventSummary(event)),
|
|
8478
8558
|
relatedNodes
|
|
8479
8559
|
};
|
|
8480
8560
|
});
|
|
@@ -8533,7 +8613,7 @@ async function sources(runtime, url) {
|
|
|
8533
8613
|
node,
|
|
8534
8614
|
nodes: snapshot.graphNodes.filter(({ id }) => relatedNodeIds.has(id)),
|
|
8535
8615
|
edges,
|
|
8536
|
-
events: events.map(eventSummary),
|
|
8616
|
+
events: events.map((event) => eventSummary(event)),
|
|
8537
8617
|
messages: sourceMessages(snapshot, ids)
|
|
8538
8618
|
};
|
|
8539
8619
|
} else if (elementId) {
|
|
@@ -8553,7 +8633,7 @@ async function sources(runtime, url) {
|
|
|
8553
8633
|
elements = snapshot.elements.filter(({ sourceEventIds }) => sourceEventIds.some((id) => eventIds.has(id)));
|
|
8554
8634
|
return {
|
|
8555
8635
|
namespace,
|
|
8556
|
-
events: events.map(eventSummary),
|
|
8636
|
+
events: events.map((event) => eventSummary(event)),
|
|
8557
8637
|
elements: elements.map(elementSummary),
|
|
8558
8638
|
messages: sourceMessages(snapshot, ids),
|
|
8559
8639
|
layers: displayBlock ? virtualBlockLayers(displayBlock) : blockLayers(block),
|
|
@@ -8564,7 +8644,7 @@ async function sources(runtime, url) {
|
|
|
8564
8644
|
}
|
|
8565
8645
|
return {
|
|
8566
8646
|
namespace,
|
|
8567
|
-
events: events.map(eventSummary),
|
|
8647
|
+
events: events.map((event) => eventSummary(event, eventId ? snapshot : void 0)),
|
|
8568
8648
|
elements: elements.map(elementSummary),
|
|
8569
8649
|
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 })),
|
|
8570
8650
|
messages: sourceMessages(snapshot, ids)
|
|
@@ -8624,7 +8704,7 @@ function receiptSources(snapshot, receipt) {
|
|
|
8624
8704
|
const messageIds = new Set(supportingEvents.flatMap(({ sourceMessageIds }) => sourceMessageIds));
|
|
8625
8705
|
return {
|
|
8626
8706
|
...receipt,
|
|
8627
|
-
events: events.map(eventSummary),
|
|
8707
|
+
events: events.map((event) => eventSummary(event)),
|
|
8628
8708
|
elements: elements.map(elementSummary),
|
|
8629
8709
|
sourceMessages: sourceMessages(snapshot, messageIds)
|
|
8630
8710
|
};
|