stratagate-dsh 0.2.34 → 0.2.36
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 +10 -0
- package/README.md +10 -3
- package/dist/client.js +2 -2
- package/dist/index.js +218 -26
- package/dist/index.js.map +1 -1
- package/docs/README.zh-CN.md +9 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2554,7 +2554,7 @@ function errorMessage(error) {
|
|
|
2554
2554
|
}
|
|
2555
2555
|
var STRATAGATE_CONSTRUCTOR_TOKEN = /* @__PURE__ */ Symbol("StrataGate constructor");
|
|
2556
2556
|
var StrataGate = class _StrataGate {
|
|
2557
|
-
|
|
2557
|
+
blockTurnSizeValue;
|
|
2558
2558
|
blockDecayLambdaValue;
|
|
2559
2559
|
summarizer;
|
|
2560
2560
|
extractor;
|
|
@@ -2586,7 +2586,7 @@ var StrataGate = class _StrataGate {
|
|
|
2586
2586
|
if (token !== STRATAGATE_CONSTRUCTOR_TOKEN) {
|
|
2587
2587
|
throw new TypeError("Use StrataGate.open() for SQLite or StrataGate.inMemory() for explicit ephemeral storage");
|
|
2588
2588
|
}
|
|
2589
|
-
this.
|
|
2589
|
+
this.blockTurnSizeValue = Math.max(1, Math.floor(options.blockTurnSize ?? DEFAULT_BLOCK_TURN_SIZE));
|
|
2590
2590
|
const blockDecayLambda = options.blockDecayLambda ?? BLOCK_DECAY_LAMBDA;
|
|
2591
2591
|
if (!Number.isFinite(blockDecayLambda) || blockDecayLambda < 0) {
|
|
2592
2592
|
throw new TypeError("blockDecayLambda must be a non-negative finite number");
|
|
@@ -2734,6 +2734,18 @@ var StrataGate = class _StrataGate {
|
|
|
2734
2734
|
get storageRevision() {
|
|
2735
2735
|
return this.revision;
|
|
2736
2736
|
}
|
|
2737
|
+
get blockTurnSize() {
|
|
2738
|
+
return this.blockTurnSizeValue;
|
|
2739
|
+
}
|
|
2740
|
+
async setBlockTurnSize(value) {
|
|
2741
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
2742
|
+
throw new TypeError("blockTurnSize must be a positive integer");
|
|
2743
|
+
}
|
|
2744
|
+
if (value === this.blockTurnSizeValue) return;
|
|
2745
|
+
await this.commitMutation(() => {
|
|
2746
|
+
this.blockTurnSizeValue = value;
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2737
2749
|
get blockDecayLambda() {
|
|
2738
2750
|
return this.blockDecayLambdaValue;
|
|
2739
2751
|
}
|
|
@@ -3479,6 +3491,16 @@ var StrataGate = class _StrataGate {
|
|
|
3479
3491
|
}
|
|
3480
3492
|
async searchGraphNodes(query, limit = 8) {
|
|
3481
3493
|
const candidates = this.graphNodes.filter((node) => node.status === "active" || node.status === "disputed");
|
|
3494
|
+
const queryTokens = [...new Set(searchTokens(query))];
|
|
3495
|
+
const fieldValues = (node) => [
|
|
3496
|
+
["name", node.name],
|
|
3497
|
+
["aliases", node.aliases.join(" ")],
|
|
3498
|
+
["tags", (node.tags ?? []).join(" ")],
|
|
3499
|
+
["type", node.type],
|
|
3500
|
+
["currentState", node.currentState],
|
|
3501
|
+
["facts", node.facts.map((fact) => `${fact.key} ${Array.isArray(fact.value) ? fact.value.join(" ") : fact.value}`).join(" ")],
|
|
3502
|
+
["relations", this.graphEdges.filter((edge) => edge.fromNodeId === node.id || edge.toNodeId === node.id).map(({ relation }) => relation).join(" ")]
|
|
3503
|
+
];
|
|
3482
3504
|
const ranked = bm25Rank(candidates, query, (node) => weightedSearchTokens([
|
|
3483
3505
|
[node.name, 6],
|
|
3484
3506
|
[node.aliases.join(" "), 5],
|
|
@@ -3487,9 +3509,28 @@ var StrataGate = class _StrataGate {
|
|
|
3487
3509
|
[node.currentState, 4],
|
|
3488
3510
|
[node.facts.map((fact) => `${fact.key} ${Array.isArray(fact.value) ? fact.value.join(" ") : fact.value}`).join(" "), 4],
|
|
3489
3511
|
[this.graphEdges.filter((edge) => edge.fromNodeId === node.id || edge.toNodeId === node.id).map(({ relation }) => relation).join(" "), 3]
|
|
3490
|
-
])).
|
|
3512
|
+
])).filter(({ item }) => {
|
|
3513
|
+
const fields = fieldValues(item);
|
|
3514
|
+
const matches = fields.filter(([, value]) => {
|
|
3515
|
+
const haystack = new Set(searchTokens(value));
|
|
3516
|
+
return queryTokens.some((token) => haystack.has(token));
|
|
3517
|
+
}).map(([field]) => field);
|
|
3518
|
+
if (!matches.some((field) => field !== "relations")) return false;
|
|
3519
|
+
return matches.some((field) => field !== "relations");
|
|
3520
|
+
}).slice(0, Math.max(1, Math.min(20, limit)));
|
|
3491
3521
|
if (searchTokens(query).length > 0 && ranked.length === 0) return [];
|
|
3492
|
-
return ranked.map(({ item: node, score }) =>
|
|
3522
|
+
return ranked.map(({ item: node, score }) => {
|
|
3523
|
+
const matchedFields = fieldValues(node).filter(([, value]) => {
|
|
3524
|
+
const haystack = new Set(searchTokens(value));
|
|
3525
|
+
return queryTokens.some((token) => haystack.has(token));
|
|
3526
|
+
}).map(([field]) => field);
|
|
3527
|
+
return {
|
|
3528
|
+
node,
|
|
3529
|
+
score,
|
|
3530
|
+
matchedFields,
|
|
3531
|
+
matchReason: `Lexical match in ${matchedFields.join(", ") || "indexed fields"}; score is ranking-only.`
|
|
3532
|
+
};
|
|
3533
|
+
});
|
|
3493
3534
|
}
|
|
3494
3535
|
requireGraphProjectionJob(id) {
|
|
3495
3536
|
const job = this.graphProjectionJobs.get(id);
|
|
@@ -4614,6 +4655,17 @@ var DshMetadataStore = class {
|
|
|
4614
4655
|
this.database = new DatabaseSync2(filename);
|
|
4615
4656
|
this.database.exec(METADATA_SCHEMA);
|
|
4616
4657
|
}
|
|
4658
|
+
blockTurnSize() {
|
|
4659
|
+
const row = this.database.prepare("SELECT value FROM stratagate_dsh_settings WHERE key = 'blockTurnSize'").get();
|
|
4660
|
+
const value = Number(row?.value);
|
|
4661
|
+
return Number.isSafeInteger(value) && value >= 1 ? value : null;
|
|
4662
|
+
}
|
|
4663
|
+
setBlockTurnSize(value) {
|
|
4664
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
4665
|
+
throw new TypeError("blockTurnSize must be a positive integer");
|
|
4666
|
+
}
|
|
4667
|
+
this.setSetting("blockTurnSize", value);
|
|
4668
|
+
}
|
|
4617
4669
|
blockDecayLambda() {
|
|
4618
4670
|
const row = this.database.prepare("SELECT value FROM stratagate_dsh_settings WHERE key = 'blockDecayLambda'").get();
|
|
4619
4671
|
const value = Number(row?.value);
|
|
@@ -4623,11 +4675,14 @@ var DshMetadataStore = class {
|
|
|
4623
4675
|
if (!Number.isFinite(value) || value < 0) {
|
|
4624
4676
|
throw new TypeError("blockDecayLambda must be a non-negative finite number");
|
|
4625
4677
|
}
|
|
4678
|
+
this.setSetting("blockDecayLambda", value);
|
|
4679
|
+
}
|
|
4680
|
+
setSetting(key, value) {
|
|
4626
4681
|
this.database.prepare(`
|
|
4627
4682
|
INSERT INTO stratagate_dsh_settings (key, value, updated_at)
|
|
4628
|
-
VALUES (
|
|
4683
|
+
VALUES (?, ?, ?)
|
|
4629
4684
|
ON CONFLICT (key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at
|
|
4630
|
-
`).run(String(value), (/* @__PURE__ */ new Date()).toISOString());
|
|
4685
|
+
`).run(key, String(value), (/* @__PURE__ */ new Date()).toISOString());
|
|
4631
4686
|
}
|
|
4632
4687
|
workspaceName(namespace) {
|
|
4633
4688
|
const row = this.database.prepare("SELECT display_name FROM stratagate_dsh_workspaces WHERE namespace = ?").get(namespace);
|
|
@@ -4668,6 +4723,7 @@ var StrataGateRuntime = class {
|
|
|
4668
4723
|
this.models = models;
|
|
4669
4724
|
this.onIngestError = onIngestError;
|
|
4670
4725
|
this.flushNativeSession = flushNativeSession;
|
|
4726
|
+
this.blockTurnSize = config.blockTurnSize;
|
|
4671
4727
|
this.blockDecayLambda = config.blockDecayLambda;
|
|
4672
4728
|
}
|
|
4673
4729
|
config;
|
|
@@ -4685,6 +4741,7 @@ var StrataGateRuntime = class {
|
|
|
4685
4741
|
batchSequence = 0;
|
|
4686
4742
|
closed = false;
|
|
4687
4743
|
ingestError;
|
|
4744
|
+
blockTurnSize;
|
|
4688
4745
|
blockDecayLambda;
|
|
4689
4746
|
acceptEvent(session, event) {
|
|
4690
4747
|
if (this.closed) return;
|
|
@@ -4718,7 +4775,7 @@ var StrataGateRuntime = class {
|
|
|
4718
4775
|
return this.batch(session, results.map(({ event }) => ({
|
|
4719
4776
|
ref: `event:${event.id}`,
|
|
4720
4777
|
target: { eventIds: [event.id], elementIds: [] }
|
|
4721
|
-
})), results);
|
|
4778
|
+
})), results.map(({ event, score }) => compactEvent(event, score)));
|
|
4722
4779
|
}
|
|
4723
4780
|
async searchElements(session, query, options = {}) {
|
|
4724
4781
|
await this.flush();
|
|
@@ -4726,7 +4783,18 @@ var StrataGateRuntime = class {
|
|
|
4726
4783
|
return this.batch(session, results.map((result) => ({
|
|
4727
4784
|
ref: `element:${result.elementId}:fact:${result.id}`,
|
|
4728
4785
|
target: { eventIds: [], elementIds: [result.elementId] }
|
|
4729
|
-
})), results)
|
|
4786
|
+
})), results.map((result) => ({
|
|
4787
|
+
id: result.id,
|
|
4788
|
+
elementId: result.elementId,
|
|
4789
|
+
name: result.name,
|
|
4790
|
+
type: result.type,
|
|
4791
|
+
factKey: result.fact.key,
|
|
4792
|
+
value: Array.isArray(result.fact.value) ? result.fact.value.join(", ") : result.fact.value,
|
|
4793
|
+
validFrom: result.fact.validFrom,
|
|
4794
|
+
validTo: result.fact.validTo,
|
|
4795
|
+
rankScore: result.score,
|
|
4796
|
+
scoreMeaning: "Ranking-only BM25/RRF score; not confidence or factual accuracy."
|
|
4797
|
+
})));
|
|
4730
4798
|
}
|
|
4731
4799
|
async searchRaw(session, query, limit, scope = "namespace") {
|
|
4732
4800
|
await this.flush();
|
|
@@ -4736,7 +4804,7 @@ var StrataGateRuntime = class {
|
|
|
4736
4804
|
return this.batch(session, results.map((result, index) => ({
|
|
4737
4805
|
ref: `raw:${result.blockId}:${result.message.id}:${index}`,
|
|
4738
4806
|
target: { eventIds: [], elementIds: [] }
|
|
4739
|
-
})), results, { scope, namespace: this.namespaceFor(session), threadId });
|
|
4807
|
+
})), results.map(compactRawHit), { scope, namespace: this.namespaceFor(session), threadId });
|
|
4740
4808
|
}
|
|
4741
4809
|
async blocks(session, scope = "session") {
|
|
4742
4810
|
await this.flush();
|
|
@@ -5035,6 +5103,7 @@ var StrataGateRuntime = class {
|
|
|
5035
5103
|
if (this.config.database === ":memory:" || !existsSync(this.config.database)) return;
|
|
5036
5104
|
const metadata = new DshMetadataStore(this.config.database);
|
|
5037
5105
|
try {
|
|
5106
|
+
this.blockTurnSize = metadata.blockTurnSize() ?? this.config.blockTurnSize;
|
|
5038
5107
|
this.blockDecayLambda = metadata.blockDecayLambda() ?? this.config.blockDecayLambda;
|
|
5039
5108
|
} finally {
|
|
5040
5109
|
metadata.close();
|
|
@@ -5043,10 +5112,10 @@ var StrataGateRuntime = class {
|
|
|
5043
5112
|
try {
|
|
5044
5113
|
for (const namespace of storage.listNamespaces()) {
|
|
5045
5114
|
const loaded = await storage.load(namespace);
|
|
5046
|
-
if (!loaded || loaded.snapshot.blockTurnSize === this.
|
|
5115
|
+
if (!loaded || loaded.snapshot.blockTurnSize === this.blockTurnSize && loaded.snapshot.blockDecayLambda === this.blockDecayLambda) continue;
|
|
5047
5116
|
await storage.save(namespace, {
|
|
5048
5117
|
...loaded.snapshot,
|
|
5049
|
-
blockTurnSize: this.
|
|
5118
|
+
blockTurnSize: this.blockTurnSize,
|
|
5050
5119
|
blockDecayLambda: this.blockDecayLambda
|
|
5051
5120
|
}, loaded.revision);
|
|
5052
5121
|
}
|
|
@@ -5082,7 +5151,7 @@ var StrataGateRuntime = class {
|
|
|
5082
5151
|
memory = await StrataGate.open({
|
|
5083
5152
|
database: this.config.database,
|
|
5084
5153
|
namespace: key,
|
|
5085
|
-
blockTurnSize: this.
|
|
5154
|
+
blockTurnSize: this.blockTurnSize,
|
|
5086
5155
|
blockDecayLambda: this.blockDecayLambda,
|
|
5087
5156
|
graphProjector: this.models.graphProjector,
|
|
5088
5157
|
disableElementProjection: true
|
|
@@ -5127,6 +5196,18 @@ var StrataGateRuntime = class {
|
|
|
5127
5196
|
await update;
|
|
5128
5197
|
return value;
|
|
5129
5198
|
}
|
|
5199
|
+
async adminSetBlockTurnSize(value) {
|
|
5200
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
5201
|
+
throw new TypeError("blockTurnSize must be a positive integer");
|
|
5202
|
+
}
|
|
5203
|
+
const update = this.settingsTail.catch(() => {
|
|
5204
|
+
}).then(() => this.applyBlockTurnSize(value));
|
|
5205
|
+
this.settingsTail = update.then(() => {
|
|
5206
|
+
}, () => {
|
|
5207
|
+
});
|
|
5208
|
+
await update;
|
|
5209
|
+
return value;
|
|
5210
|
+
}
|
|
5130
5211
|
async adminExpandBlock(namespace, id, target) {
|
|
5131
5212
|
const key = namespace.trim();
|
|
5132
5213
|
if (!key) throw new TypeError("StrataGate admin namespace must not be empty");
|
|
@@ -5141,7 +5222,7 @@ var StrataGateRuntime = class {
|
|
|
5141
5222
|
const memory = await StrataGate.open({
|
|
5142
5223
|
database: this.config.database,
|
|
5143
5224
|
namespace: key,
|
|
5144
|
-
blockTurnSize: this.
|
|
5225
|
+
blockTurnSize: this.blockTurnSize,
|
|
5145
5226
|
blockDecayLambda: this.blockDecayLambda,
|
|
5146
5227
|
summarizer: this.models.summarizer,
|
|
5147
5228
|
extractor: this.models.extractor,
|
|
@@ -5190,6 +5271,37 @@ var StrataGateRuntime = class {
|
|
|
5190
5271
|
}
|
|
5191
5272
|
}
|
|
5192
5273
|
}
|
|
5274
|
+
async applyBlockTurnSize(value) {
|
|
5275
|
+
await this.flush();
|
|
5276
|
+
this.blockTurnSize = value;
|
|
5277
|
+
if (this.config.database !== ":memory:") {
|
|
5278
|
+
const metadata = new DshMetadataStore(this.config.database);
|
|
5279
|
+
try {
|
|
5280
|
+
metadata.setBlockTurnSize(value);
|
|
5281
|
+
} finally {
|
|
5282
|
+
metadata.close();
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
const openNamespaces = /* @__PURE__ */ new Set();
|
|
5286
|
+
for (const [namespace, opening] of this.spaces) {
|
|
5287
|
+
const memory = await opening;
|
|
5288
|
+
await memory.setBlockTurnSize(value);
|
|
5289
|
+
openNamespaces.add(namespace);
|
|
5290
|
+
}
|
|
5291
|
+
if (this.config.database !== ":memory:" && existsSync(this.config.database)) {
|
|
5292
|
+
const storage = new SqliteStorage({ filename: this.config.database });
|
|
5293
|
+
try {
|
|
5294
|
+
for (const namespace of storage.listNamespaces()) {
|
|
5295
|
+
if (openNamespaces.has(namespace)) continue;
|
|
5296
|
+
const loaded = await storage.load(namespace);
|
|
5297
|
+
if (!loaded || loaded.snapshot.blockTurnSize === value) continue;
|
|
5298
|
+
await storage.save(namespace, { ...loaded.snapshot, blockTurnSize: value }, loaded.revision);
|
|
5299
|
+
}
|
|
5300
|
+
} finally {
|
|
5301
|
+
await storage.close();
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
}
|
|
5193
5305
|
space(session) {
|
|
5194
5306
|
const namespace = this.namespaceFor(session);
|
|
5195
5307
|
this.rememberWorkspace(namespace, session.header.cwd);
|
|
@@ -5198,7 +5310,7 @@ var StrataGateRuntime = class {
|
|
|
5198
5310
|
opening = StrataGate.open({
|
|
5199
5311
|
database: this.config.database,
|
|
5200
5312
|
namespace,
|
|
5201
|
-
blockTurnSize: this.
|
|
5313
|
+
blockTurnSize: this.blockTurnSize,
|
|
5202
5314
|
blockDecayLambda: this.blockDecayLambda,
|
|
5203
5315
|
summarizer: this.models.summarizer,
|
|
5204
5316
|
extractor: this.models.extractor,
|
|
@@ -5244,7 +5356,7 @@ var StrataGateRuntime = class {
|
|
|
5244
5356
|
return this.batch(session, results.map(({ node }) => ({
|
|
5245
5357
|
ref: `graph-node:${node.id}`,
|
|
5246
5358
|
target: { eventIds: node.sourceEventIds, elementIds: [] }
|
|
5247
|
-
})), results);
|
|
5359
|
+
})), results.map(({ node, score, matchedFields, matchReason }) => compactGraphNode(node, score, matchedFields, matchReason)));
|
|
5248
5360
|
}
|
|
5249
5361
|
async expandGraphNode(session, id) {
|
|
5250
5362
|
await this.flush();
|
|
@@ -5444,6 +5556,67 @@ function renderBlockSurfaceMessage(context) {
|
|
|
5444
5556
|
context.content
|
|
5445
5557
|
].join("\n");
|
|
5446
5558
|
}
|
|
5559
|
+
function compactTemporal(event) {
|
|
5560
|
+
const temporal = event.temporal;
|
|
5561
|
+
return Object.fromEntries(Object.entries({
|
|
5562
|
+
mentionedAt: temporal.mentionedAt,
|
|
5563
|
+
happenedStart: temporal.happenedStart,
|
|
5564
|
+
happenedEnd: temporal.happenedEnd,
|
|
5565
|
+
precision: temporal.precision,
|
|
5566
|
+
status: temporal.status,
|
|
5567
|
+
eventType: temporal.eventType
|
|
5568
|
+
}).filter(([, value]) => value !== void 0));
|
|
5569
|
+
}
|
|
5570
|
+
function compactText2(value, limit = 800) {
|
|
5571
|
+
return value.replace(/\s+/gu, " ").trim().slice(0, limit);
|
|
5572
|
+
}
|
|
5573
|
+
function compactEvent(event, score) {
|
|
5574
|
+
return {
|
|
5575
|
+
id: event.id,
|
|
5576
|
+
title: compactText2(event.title, 240),
|
|
5577
|
+
summary: compactText2(event.summary),
|
|
5578
|
+
sourceTime: event.temporal.happenedStart ?? event.temporal.mentionedAt ?? event.createdAt,
|
|
5579
|
+
temporal: compactTemporal(event),
|
|
5580
|
+
sourceBlockId: event.sourceBlockId,
|
|
5581
|
+
status: event.status,
|
|
5582
|
+
scope: event.scope,
|
|
5583
|
+
criticality: event.criticality,
|
|
5584
|
+
rankScore: score,
|
|
5585
|
+
scoreMeaning: "Ranking-only BM25/RRF score; not confidence, probability, or factual accuracy."
|
|
5586
|
+
};
|
|
5587
|
+
}
|
|
5588
|
+
function compactGraphNode(node, score, matchedFields, matchReason) {
|
|
5589
|
+
return {
|
|
5590
|
+
id: node.id,
|
|
5591
|
+
name: node.name,
|
|
5592
|
+
type: node.type,
|
|
5593
|
+
aliases: node.aliases.map((alias) => compactText2(alias, 160)),
|
|
5594
|
+
currentState: compactText2(node.currentState, 500),
|
|
5595
|
+
status: node.status,
|
|
5596
|
+
rankScore: score,
|
|
5597
|
+
...matchedFields ? { matchedFields } : {},
|
|
5598
|
+
...matchReason ? { matchReason } : {},
|
|
5599
|
+
scoreMeaning: "Ranking-only BM25/RRF score; not confidence, probability, or factual accuracy."
|
|
5600
|
+
};
|
|
5601
|
+
}
|
|
5602
|
+
function compactRawHit(result) {
|
|
5603
|
+
const message = {
|
|
5604
|
+
id: result.message.id,
|
|
5605
|
+
role: result.message.role,
|
|
5606
|
+
content: compactText2(result.message.content, 500),
|
|
5607
|
+
createdAt: result.message.createdAt,
|
|
5608
|
+
...result.message.threadId ? { threadId: result.message.threadId } : {}
|
|
5609
|
+
};
|
|
5610
|
+
return {
|
|
5611
|
+
id: result.message.id,
|
|
5612
|
+
blockId: result.blockId,
|
|
5613
|
+
turnRange: result.turnRange,
|
|
5614
|
+
message,
|
|
5615
|
+
sourceTime: result.message.createdAt,
|
|
5616
|
+
...result.message.threadId ? { threadId: result.message.threadId } : {},
|
|
5617
|
+
detailHint: "Use memory_expand_block with blockId for complete block/source details."
|
|
5618
|
+
};
|
|
5619
|
+
}
|
|
5447
5620
|
function currentBlockSurfaceMessages(session) {
|
|
5448
5621
|
const blocks = /* @__PURE__ */ new Map();
|
|
5449
5622
|
if (!session.surface?.nodes) return blocks;
|
|
@@ -5588,7 +5761,7 @@ function sessionOf(exec) {
|
|
|
5588
5761
|
function registerMemoryTools(ctx, runtime) {
|
|
5589
5762
|
ctx.tools.register(defineTool({
|
|
5590
5763
|
name: "memory_search_events",
|
|
5591
|
-
description: "Search durable StrataGate event memories. Returns a
|
|
5764
|
+
description: "Search durable StrataGate event memories. Returns a compact batch of event cards (id, title, summary, time, and evidence refs); call memory_expand_event for narrative/quotes/source messages. rankScore is BM25/RRF ordering only, never confidence or factual accuracy. Pass batchId to memory_assess before relying on evidence.",
|
|
5592
5765
|
parameters: {
|
|
5593
5766
|
query: { type: "string", required: true, description: "What historical decision, event, preference, or outcome to find." },
|
|
5594
5767
|
limit: { type: "integer", description: "Maximum results, 1-20." },
|
|
@@ -5606,7 +5779,7 @@ function registerMemoryTools(ctx, runtime) {
|
|
|
5606
5779
|
}));
|
|
5607
5780
|
ctx.tools.register(defineTool({
|
|
5608
5781
|
name: "memory_search_graph",
|
|
5609
|
-
description: "Search the current Event-backed Knowledge Graph for people, projects, organizations, tools, places, facts, and relations. Returns
|
|
5782
|
+
description: "Search the current Event-backed Knowledge Graph for people, projects, organizations, tools, places, facts, and relations. Returns compact node cards with matchedFields/matchReason; call memory_expand_graph_node for complete facts and edges. rankScore is BM25/RRF ordering only, never confidence or factual accuracy. Results are independently assessable.",
|
|
5610
5783
|
parameters: {
|
|
5611
5784
|
query: { type: "string", required: true },
|
|
5612
5785
|
limit: { type: "integer", description: "Maximum results, 1-20." }
|
|
@@ -5623,7 +5796,7 @@ function registerMemoryTools(ctx, runtime) {
|
|
|
5623
5796
|
}));
|
|
5624
5797
|
ctx.tools.register(defineTool({
|
|
5625
5798
|
name: "memory_search_elements",
|
|
5626
|
-
description: "Deprecated compatibility search for legacy Element-card data. Prefer memory_search_graph.",
|
|
5799
|
+
description: "Deprecated compatibility search for legacy Element-card data. Returns compact fact hits; rankScore is BM25/RRF ordering only, never confidence or factual accuracy. Prefer memory_search_graph.",
|
|
5627
5800
|
parameters: {
|
|
5628
5801
|
query: { type: "string", required: true },
|
|
5629
5802
|
limit: { type: "integer" },
|
|
@@ -5639,7 +5812,7 @@ function registerMemoryTools(ctx, runtime) {
|
|
|
5639
5812
|
}));
|
|
5640
5813
|
ctx.tools.register(defineTool({
|
|
5641
5814
|
name: "memory_search_raw",
|
|
5642
|
-
description: "Search
|
|
5815
|
+
description: "Search archived messages when summarized memories are insufficient. Returns compact raw hits (message id, blockId, excerpt, role, and time); use memory_expand_block with blockId for complete source details. By default searches the whole current namespace; use scope=session for the active thread. Returns evidence refs and batchId for assessment.",
|
|
5643
5816
|
parameters: {
|
|
5644
5817
|
query: { type: "string", required: true },
|
|
5645
5818
|
limit: { type: "integer" },
|
|
@@ -5835,7 +6008,7 @@ function clusterKnowledgeGraph(rawNodes, rawEdges) {
|
|
|
5835
6008
|
}
|
|
5836
6009
|
|
|
5837
6010
|
// src/web.ts
|
|
5838
|
-
var STRATAGATE_DSH_VERSION = "0.2.
|
|
6011
|
+
var STRATAGATE_DSH_VERSION = "0.2.36";
|
|
5839
6012
|
var LEGACY_THREAD_ID = "__legacy__";
|
|
5840
6013
|
var nodeRequire = createRequire(import.meta.url);
|
|
5841
6014
|
function installedPackageVersion(names) {
|
|
@@ -6024,12 +6197,31 @@ async function overview(runtime) {
|
|
|
6024
6197
|
};
|
|
6025
6198
|
}
|
|
6026
6199
|
async function updateSettings(runtime, url) {
|
|
6027
|
-
const
|
|
6028
|
-
const
|
|
6029
|
-
if (
|
|
6030
|
-
throw new AdminHttpError(400, "
|
|
6031
|
-
}
|
|
6032
|
-
|
|
6200
|
+
const rawTurnSize = url.searchParams.get("blockTurnSize")?.trim();
|
|
6201
|
+
const rawLambda = url.searchParams.get("blockDecayLambda")?.trim();
|
|
6202
|
+
if (rawTurnSize === void 0 && rawLambda === void 0) {
|
|
6203
|
+
throw new AdminHttpError(400, "blockTurnSize or blockDecayLambda is required");
|
|
6204
|
+
}
|
|
6205
|
+
let turnSize;
|
|
6206
|
+
let lambda;
|
|
6207
|
+
if (rawTurnSize !== void 0) {
|
|
6208
|
+
const value = Number(rawTurnSize);
|
|
6209
|
+
if (!rawTurnSize || !Number.isSafeInteger(value) || value < 1) {
|
|
6210
|
+
throw new AdminHttpError(400, "blockTurnSize must be a positive integer");
|
|
6211
|
+
}
|
|
6212
|
+
turnSize = value;
|
|
6213
|
+
}
|
|
6214
|
+
if (rawLambda !== void 0) {
|
|
6215
|
+
const value = Number(rawLambda);
|
|
6216
|
+
if (!rawLambda || !Number.isFinite(value) || value < 0) {
|
|
6217
|
+
throw new AdminHttpError(400, "blockDecayLambda must be a non-negative finite number");
|
|
6218
|
+
}
|
|
6219
|
+
lambda = value;
|
|
6220
|
+
}
|
|
6221
|
+
const result = {};
|
|
6222
|
+
if (turnSize !== void 0) result.blockTurnSize = await runtime.adminSetBlockTurnSize(turnSize);
|
|
6223
|
+
if (lambda !== void 0) result.blockDecayLambda = await runtime.adminSetBlockDecayLambda(lambda);
|
|
6224
|
+
return result;
|
|
6033
6225
|
}
|
|
6034
6226
|
async function importExternalMemory(runtime, req) {
|
|
6035
6227
|
let suppliedBody = req.body;
|