@aexol/spectral 0.9.183 → 0.9.185
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/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +8 -7
- package/dist/memory/branch.d.ts +13 -0
- package/dist/memory/branch.d.ts.map +1 -1
- package/dist/memory/branch.js +100 -0
- package/dist/memory/config.d.ts +2 -12
- package/dist/memory/config.d.ts.map +1 -1
- package/dist/memory/config.js +2 -20
- package/dist/memory/hooks/compaction-hook.d.ts.map +1 -1
- package/dist/memory/hooks/compaction-hook.js +43 -1
- package/dist/memory/hooks/observer-trigger.d.ts.map +1 -1
- package/dist/memory/hooks/observer-trigger.js +9 -3
- package/dist/memory/index.d.ts +13 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +17 -26
- package/dist/memory/project-observation-memory.d.ts +16 -0
- package/dist/memory/project-observation-memory.d.ts.map +1 -0
- package/dist/memory/project-observation-memory.js +27 -0
- package/dist/memory/project-observations-store.d.ts +8 -0
- package/dist/memory/project-observations-store.d.ts.map +1 -1
- package/dist/memory/project-observations-store.js +5 -0
- package/dist/memory/prompts.d.ts +2 -2
- package/dist/memory/prompts.d.ts.map +1 -1
- package/dist/memory/prompts.js +1 -1
- package/dist/memory/session-memory.d.ts +21 -0
- package/dist/memory/session-memory.d.ts.map +1 -0
- package/dist/memory/session-memory.js +33 -0
- package/dist/memory/tool-output-compressor.d.ts +0 -1
- package/dist/memory/tool-output-compressor.d.ts.map +1 -1
- package/dist/memory/tool-output-compressor.js +0 -1
- package/dist/memory/tools/compact-context.d.ts +31 -10
- package/dist/memory/tools/compact-context.d.ts.map +1 -1
- package/dist/memory/tools/compact-context.js +193 -246
- package/dist/memory/tools/read-project-observations.d.ts.map +1 -1
- package/dist/memory/tools/read-project-observations.js +6 -3
- package/dist/memory/tools/recall-observation.d.ts.map +1 -1
- package/dist/memory/tools/recall-observation.js +18 -4
- package/dist/memory/tools/receive-agent-observations.d.ts.map +1 -1
- package/dist/memory/tools/receive-agent-observations.js +4 -2
- package/dist/memory/tools/share-project-observation.d.ts.map +1 -1
- package/dist/memory/tools/share-project-observation.js +5 -3
- package/dist/memory/tools/write-project-observation.d.ts.map +1 -1
- package/dist/memory/tools/write-project-observation.js +16 -3
- package/dist/sdk/coding-agent/core/compaction/compaction.d.ts +11 -0
- package/dist/sdk/coding-agent/core/compaction/compaction.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/compaction/compaction.js +13 -0
- package/dist/server/handlers/settings.d.ts +0 -6
- package/dist/server/handlers/settings.d.ts.map +1 -1
- package/dist/server/handlers/settings.js +0 -21
- package/dist/server/inter-agent-broker.d.ts +12 -7
- package/dist/server/inter-agent-broker.d.ts.map +1 -1
- package/dist/server/inter-agent-broker.js +12 -7
- package/dist/server/session-stream.d.ts +1 -3
- package/dist/server/session-stream.d.ts.map +1 -1
- package/dist/server/session-stream.js +2 -5
- package/dist/server/storage.d.ts +14 -0
- package/dist/server/storage.d.ts.map +1 -1
- package/dist/server/storage.js +43 -0
- package/dist/server/wire.d.ts +0 -4
- package/dist/server/wire.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAIX,SAAS,EAET,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAIX,SAAS,EAET,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACN,KAAK,WAAW,EAKhB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAuG7G;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACxC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC,GACpF,MAAM,CAYR;AA0JD;;;GAGG;AACH,wBAAgB,oCAAoC,CACnD,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAChD,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,CAK3D;AAoBD,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,gBAAgB,GACnB,SAAS,EAAE,CAoCb;AAwcD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,GAAG,EAAE,YAAY,EACjB,IAAI,CAAC,EAAE;IACN,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,GACC,IAAI,CAgaN"}
|
package/dist/agent/index.js
CHANGED
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
* - Access to observational memory via the recall tool
|
|
26
26
|
*/
|
|
27
27
|
import { agentLoop } from "../sdk/agent-core/index.js";
|
|
28
|
-
import {
|
|
29
|
-
import { loadConfig } from "../memory/config.js";
|
|
28
|
+
import { buildIsolatedRequestTimePrunedMessagesResult, COMPACT_CONTEXT_TOOL_NAME, } from "../memory/tools/compact-context.js";
|
|
30
29
|
import { StringEnum } from "../sdk/ai/index.js";
|
|
31
30
|
import { mutateSystemPrompt } from "../sdk/coding-agent/core/system-prompt-mutator.js";
|
|
32
31
|
import { Type } from "typebox";
|
|
@@ -446,6 +445,10 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
|
|
|
446
445
|
// Accumulated thinking deltas for the live subagent sheet. This stays outside
|
|
447
446
|
// final `SingleResult` so the public subagent tool_result contract is unchanged.
|
|
448
447
|
let thinkingText = "";
|
|
448
|
+
// Per-run frozen DCP-lite cut for the isolated subagent loop. Reusing the
|
|
449
|
+
// same summary + anchor across provider requests keeps the subagent prompt
|
|
450
|
+
// prefix byte-stable within a single run.
|
|
451
|
+
let isolatedPruneFrozen = null;
|
|
449
452
|
// Responses API reasoning metadata that lets the UI classify accumulated
|
|
450
453
|
// subagent thinking as activity (mirrors the main-session thinking metadata).
|
|
451
454
|
let thinkingMetadata;
|
|
@@ -468,10 +471,6 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
|
|
|
468
471
|
const config = {
|
|
469
472
|
model,
|
|
470
473
|
apiKey: auth.apiKey,
|
|
471
|
-
onPayload: createIsolatedDcpNudgePayloadHook({
|
|
472
|
-
config: loadConfig(effectiveCwd),
|
|
473
|
-
policy: ctx.settingsManager?.getCompactionPolicy?.(),
|
|
474
|
-
}),
|
|
475
474
|
headers: auth.headers,
|
|
476
475
|
convertToLlm: (msgs) => msgs.filter((m) => m.role === "user" || m.role === "assistant" || m.role === "toolResult"),
|
|
477
476
|
toolExecution: "parallel",
|
|
@@ -479,7 +478,9 @@ async function runSingleAgent(defaultCwd, agents, agentName, task, cwd, step, si
|
|
|
479
478
|
// Pure request-time DCP adapter: policy-derived, invocation-local, and
|
|
480
479
|
// never connected to the parent Runtime or SessionManager.
|
|
481
480
|
try {
|
|
482
|
-
|
|
481
|
+
const pruned = buildIsolatedRequestTimePrunedMessagesResult(messages, undefined, undefined, isolatedPruneFrozen);
|
|
482
|
+
isolatedPruneFrozen = pruned.frozen;
|
|
483
|
+
return pruned.messages;
|
|
483
484
|
}
|
|
484
485
|
catch {
|
|
485
486
|
return messages;
|
package/dist/memory/branch.d.ts
CHANGED
|
@@ -121,4 +121,17 @@ export interface MemoryState {
|
|
|
121
121
|
pendingObs: ObservationRecord[];
|
|
122
122
|
}
|
|
123
123
|
export declare function getMemoryState(entries: Entry[]): MemoryState;
|
|
124
|
+
/**
|
|
125
|
+
* Build a synthetic branch entry array that is sufficient for
|
|
126
|
+
* `recallMemorySources` to recover the same memory id outside of its original
|
|
127
|
+
* session/branch.
|
|
128
|
+
*
|
|
129
|
+
* This is the cross-session recall archive unit: it contains only the source
|
|
130
|
+
* entries referenced by the requested observation/reflection, the observation
|
|
131
|
+
* entries needed to resolve direct and supporting observations, and (for
|
|
132
|
+
* reflections) a restored-memory snapshot entry carrying the reflection
|
|
133
|
+
* provenance. It is deliberately keyed by memory id so it can be persisted in
|
|
134
|
+
* the project-scoped store without dragging the whole branch along.
|
|
135
|
+
*/
|
|
136
|
+
export declare function buildRecallSourceArchiveEntries(entries: Entry[], memoryState: Pick<MemoryState, "reflections" | "committedObs" | "pendingObs">, memoryId: string): Entry[] | undefined;
|
|
124
137
|
//# sourceMappingURL=branch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/memory/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAGrB,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;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WAAW;IAC3B,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,UAAU,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,WAAW,CAQ5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,KAAK,EAAE,EAChB,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,cAAc,GAAG,YAAY,CAAC,EAC7E,QAAQ,EAAE,MAAM,GACd,KAAK,EAAE,GAAG,SAAS,CA4FrB"}
|
package/dist/memory/branch.js
CHANGED
|
@@ -468,3 +468,103 @@ export function getMemoryState(entries) {
|
|
|
468
468
|
pendingObs: pendingData.flatMap((d) => d.records),
|
|
469
469
|
};
|
|
470
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Build a synthetic branch entry array that is sufficient for
|
|
473
|
+
* `recallMemorySources` to recover the same memory id outside of its original
|
|
474
|
+
* session/branch.
|
|
475
|
+
*
|
|
476
|
+
* This is the cross-session recall archive unit: it contains only the source
|
|
477
|
+
* entries referenced by the requested observation/reflection, the observation
|
|
478
|
+
* entries needed to resolve direct and supporting observations, and (for
|
|
479
|
+
* reflections) a restored-memory snapshot entry carrying the reflection
|
|
480
|
+
* provenance. It is deliberately keyed by memory id so it can be persisted in
|
|
481
|
+
* the project-scoped store without dragging the whole branch along.
|
|
482
|
+
*/
|
|
483
|
+
export function buildRecallSourceArchiveEntries(entries, memoryState, memoryId) {
|
|
484
|
+
const allObservations = [...memoryState.committedObs, ...memoryState.pendingObs];
|
|
485
|
+
const selectedObservationRecords = [];
|
|
486
|
+
const seenObservationKeys = new Set();
|
|
487
|
+
const recordKey = (observation) => [
|
|
488
|
+
observation.id,
|
|
489
|
+
observation.content,
|
|
490
|
+
observation.timestamp,
|
|
491
|
+
observation.relevance,
|
|
492
|
+
JSON.stringify(observation.sourceEntryIds ?? null),
|
|
493
|
+
].join("\u0000");
|
|
494
|
+
const addObservation = (observation) => {
|
|
495
|
+
const key = recordKey(observation);
|
|
496
|
+
if (seenObservationKeys.has(key))
|
|
497
|
+
return;
|
|
498
|
+
seenObservationKeys.add(key);
|
|
499
|
+
selectedObservationRecords.push(observation);
|
|
500
|
+
};
|
|
501
|
+
for (const observation of allObservations) {
|
|
502
|
+
if (observation.id === memoryId)
|
|
503
|
+
addObservation(observation);
|
|
504
|
+
}
|
|
505
|
+
const reflections = [];
|
|
506
|
+
for (const reflection of memoryState.reflections) {
|
|
507
|
+
if (!isReflectionRecord(reflection) || reflection.id !== memoryId)
|
|
508
|
+
continue;
|
|
509
|
+
reflections.push(reflection);
|
|
510
|
+
for (const observationId of reflection.supportingObservationIds) {
|
|
511
|
+
for (const observation of allObservations) {
|
|
512
|
+
if (observation.id === observationId)
|
|
513
|
+
addObservation(observation);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (reflections.length === 0 && selectedObservationRecords.length === 0) {
|
|
518
|
+
return undefined;
|
|
519
|
+
}
|
|
520
|
+
const sourceEntryIds = new Set();
|
|
521
|
+
for (const observation of selectedObservationRecords) {
|
|
522
|
+
for (const sourceEntryId of observation.sourceEntryIds ?? []) {
|
|
523
|
+
sourceEntryIds.add(sourceEntryId);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const sourceEntries = entries.filter((entry) => {
|
|
527
|
+
if (!isSourceEntry(entry))
|
|
528
|
+
return false;
|
|
529
|
+
for (const requestedId of sourceEntryIds) {
|
|
530
|
+
if (sourceEntryMatchesRequestedId(entry, requestedId))
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
return false;
|
|
534
|
+
});
|
|
535
|
+
const archiveEntries = [...sourceEntries];
|
|
536
|
+
let observationEntryIndex = 0;
|
|
537
|
+
for (const observation of selectedObservationRecords) {
|
|
538
|
+
archiveEntries.push({
|
|
539
|
+
type: "custom",
|
|
540
|
+
id: `recall-archive-observation:${memoryId}:${observationEntryIndex++}`,
|
|
541
|
+
customType: OBSERVATION_CUSTOM_TYPE,
|
|
542
|
+
data: {
|
|
543
|
+
records: [observation],
|
|
544
|
+
coversFromId: "",
|
|
545
|
+
coversUpToId: "",
|
|
546
|
+
tokenCount: 0,
|
|
547
|
+
},
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
if (reflections.length > 0) {
|
|
551
|
+
archiveEntries.push({
|
|
552
|
+
type: "custom",
|
|
553
|
+
id: `recall-archive-snapshot:${memoryId}`,
|
|
554
|
+
customType: OBSERVATIONAL_MEMORY_SNAPSHOT_CUSTOM_TYPE,
|
|
555
|
+
data: {
|
|
556
|
+
type: "observational-memory-snapshot",
|
|
557
|
+
version: 1,
|
|
558
|
+
coveredSourceCount: sourceEntries.length,
|
|
559
|
+
summary: "",
|
|
560
|
+
details: {
|
|
561
|
+
type: "observational-memory",
|
|
562
|
+
version: 4,
|
|
563
|
+
observations: selectedObservationRecords,
|
|
564
|
+
reflections,
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
return archiveEntries;
|
|
570
|
+
}
|
package/dist/memory/config.d.ts
CHANGED
|
@@ -23,18 +23,8 @@ export interface Config {
|
|
|
23
23
|
observerMaxChunkTokens?: number;
|
|
24
24
|
reflectorMaxTurnsPerPass?: number;
|
|
25
25
|
prunerMaxTurnsPerPass?: number;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/** Absolute context tokens before adding DCP-lite nudges. Mirrors DCP compress.minContextLimit. */
|
|
29
|
-
dcpNudgeMinContextTokens: number;
|
|
30
|
-
/** Context-window percent before adding DCP-lite nudges. */
|
|
31
|
-
dcpNudgeContextPercent: number;
|
|
32
|
-
/** Minimum turns between repeated DCP-lite nudges. */
|
|
33
|
-
dcpNudgeTurnInterval: number;
|
|
34
|
-
/** Provider requests after a user prompt before adding an in-run DCP-lite nudge. */
|
|
35
|
-
dcpInRunNudgeIterationThreshold: number;
|
|
36
|
-
/** Minimum provider requests between repeated in-run DCP-lite nudges. */
|
|
37
|
-
dcpInRunNudgeFrequency: number;
|
|
26
|
+
/** Absolute context tokens at which DCP-lite auto older-history compaction triggers. Default: 50_000. */
|
|
27
|
+
autoCompactionContextTokens: number;
|
|
38
28
|
/** @deprecated Use reflectorMaxTurnsPerPass and prunerMaxTurnsPerPass. */
|
|
39
29
|
compactionMaxToolCalls?: number;
|
|
40
30
|
interAgent?: InterAgentConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/memory/config.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAChC,yFAAyF;IACzF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4DAA4D;IAC5D,qBAAqB,CAAC,EAAE,SAAS,CAAC;IAClC,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACtB,0BAA0B,EAAE,MAAM,CAAC;IACnC,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot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AAC,UAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnF;AAyBD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAUpF;AAED,gEAAgE;AAChE,wBAAsB,eAAe,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,OAAO,CAAC,MAAM,CAAC,CAUjB"}
|
package/dist/memory/config.js
CHANGED
|
@@ -9,12 +9,7 @@ export const DEFAULTS = {
|
|
|
9
9
|
passive: false,
|
|
10
10
|
debugLog: false,
|
|
11
11
|
observerMaxChunkTokens: 30_000,
|
|
12
|
-
|
|
13
|
-
dcpNudgeMinContextTokens: 50_000,
|
|
14
|
-
dcpNudgeContextPercent: 35,
|
|
15
|
-
dcpNudgeTurnInterval: 5,
|
|
16
|
-
dcpInRunNudgeIterationThreshold: 15,
|
|
17
|
-
dcpInRunNudgeFrequency: 5,
|
|
12
|
+
autoCompactionContextTokens: 50_000,
|
|
18
13
|
};
|
|
19
14
|
const SETTINGS_KEY = "observational-memory";
|
|
20
15
|
const PASSIVE_ENV = "PI_OBSERVATIONAL_MEMORY_PASSIVE";
|
|
@@ -33,14 +28,6 @@ function normalizeTurnLimit(normalized, key) {
|
|
|
33
28
|
normalized[key] = value;
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
|
-
function normalizePercent(normalized, key) {
|
|
37
|
-
if (!(key in normalized))
|
|
38
|
-
return;
|
|
39
|
-
const value = normalized[key];
|
|
40
|
-
if (typeof value === "number" && Number.isFinite(value) && value > 0 && value <= 100)
|
|
41
|
-
return;
|
|
42
|
-
delete normalized[key];
|
|
43
|
-
}
|
|
44
31
|
const RELEVANCE_VALUES = ["low", "medium", "high", "critical"];
|
|
45
32
|
function normalizeInterAgentConfig(value) {
|
|
46
33
|
if (!value || typeof value !== "object")
|
|
@@ -69,12 +56,7 @@ function normalizeSettingsConfig(value) {
|
|
|
69
56
|
normalizeTurnLimit(normalized, "observerMaxChunkTokens");
|
|
70
57
|
normalizeTurnLimit(normalized, "reflectorMaxTurnsPerPass");
|
|
71
58
|
normalizeTurnLimit(normalized, "prunerMaxTurnsPerPass");
|
|
72
|
-
normalizeTurnLimit(normalized, "
|
|
73
|
-
normalizeTurnLimit(normalized, "dcpNudgeMinContextTokens");
|
|
74
|
-
normalizeTurnLimit(normalized, "dcpNudgeTurnInterval");
|
|
75
|
-
normalizeTurnLimit(normalized, "dcpInRunNudgeIterationThreshold");
|
|
76
|
-
normalizeTurnLimit(normalized, "dcpInRunNudgeFrequency");
|
|
77
|
-
normalizePercent(normalized, "dcpNudgeContextPercent");
|
|
59
|
+
normalizeTurnLimit(normalized, "autoCompactionContextTokens");
|
|
78
60
|
normalizeTurnLimit(normalized, "compactionMaxToolCalls");
|
|
79
61
|
if ("interAgent" in normalized) {
|
|
80
62
|
const normalizedInterAgent = normalizeInterAgentConfig(normalized.interAgent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-hook.d.ts","sourceRoot":"","sources":["../../../src/memory/hooks/compaction-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA+C,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"compaction-hook.d.ts","sourceRoot":"","sources":["../../../src/memory/hooks/compaction-hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAA+C,MAAM,iCAAiC,CAAC;AAejH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAkB7C,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAkPhF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { debugLog, withDebugLogContext } from "../debug-log.js";
|
|
2
2
|
import { getProjectObsStore } from "../project-observations-store.js";
|
|
3
3
|
import { relayProjectObservations } from "../inter-agent-relay.js";
|
|
4
|
-
import { collectObservationsByCoverage, findLastCompactionIndex, getMemoryState, } from "../branch.js";
|
|
4
|
+
import { buildRecallSourceArchiveEntries, collectObservationsByCoverage, findLastCompactionIndex, getMemoryState, } from "../branch.js";
|
|
5
5
|
import { migrateLegacyReflections, renderSummary, } from "../compaction.js";
|
|
6
|
+
import { reflectionId, } from "../types.js";
|
|
6
7
|
import { deterministicPrune } from "../deterministic-pruner.js";
|
|
7
8
|
function plural(count, singular, pluralForm = `${singular}s`) {
|
|
8
9
|
return `${count.toLocaleString()} ${count === 1 ? singular : pluralForm}`;
|
|
@@ -89,6 +90,7 @@ export function registerCompactionHook(ext, runtime) {
|
|
|
89
90
|
if (hasUI)
|
|
90
91
|
ui?.notify(`Observational memory: no new observations — carrying forward ${memoryState.committedObs.length} observation${memoryState.committedObs.length === 1 ? "" : "s"}, ${workingReflections.length} reflection${workingReflections.length === 1 ? "" : "s"}`, "info");
|
|
91
92
|
persistProjectObservations(ctx, workingReflections);
|
|
93
|
+
persistProjectRecallSources(ctx, entries, memoryState.committedObs, workingReflections);
|
|
92
94
|
return {
|
|
93
95
|
compaction: {
|
|
94
96
|
summary,
|
|
@@ -158,6 +160,7 @@ export function registerCompactionHook(ext, runtime) {
|
|
|
158
160
|
if (hasUI)
|
|
159
161
|
ui?.notify(`Observational memory: compaction assembled — ${finalObservations.length} observation${finalObservations.length === 1 ? "" : "s"}, ${finalReflections.length} reflection${finalReflections.length === 1 ? "" : "s"}`, "info");
|
|
160
162
|
persistProjectObservations(ctx, finalReflections);
|
|
163
|
+
persistProjectRecallSources(ctx, entries, finalObservations, finalReflections);
|
|
161
164
|
return {
|
|
162
165
|
compaction: {
|
|
163
166
|
summary,
|
|
@@ -197,4 +200,43 @@ export function registerCompactionHook(ext, runtime) {
|
|
|
197
200
|
});
|
|
198
201
|
relayProjectObservations(ctx.cwd, projectId, sessionId, projectObs, "reflection");
|
|
199
202
|
}
|
|
203
|
+
function persistProjectRecallSources(ctx, entries, observations, reflections) {
|
|
204
|
+
const store = getProjectObsStore();
|
|
205
|
+
if (!store)
|
|
206
|
+
return;
|
|
207
|
+
const projectId = store.getProjectByCwd(ctx.cwd);
|
|
208
|
+
if (!projectId)
|
|
209
|
+
return;
|
|
210
|
+
const sessionId = ctx.sessionManager.getSessionId?.();
|
|
211
|
+
if (!sessionId)
|
|
212
|
+
return;
|
|
213
|
+
const memoryIds = new Set();
|
|
214
|
+
for (const observation of observations)
|
|
215
|
+
memoryIds.add(observation.id);
|
|
216
|
+
for (const reflection of reflections) {
|
|
217
|
+
const id = reflectionId(reflection);
|
|
218
|
+
if (id)
|
|
219
|
+
memoryIds.add(id);
|
|
220
|
+
}
|
|
221
|
+
if (memoryIds.size === 0)
|
|
222
|
+
return;
|
|
223
|
+
const memoryState = { reflections, committedObs: observations, pendingObs: [] };
|
|
224
|
+
let persisted = 0;
|
|
225
|
+
for (const memoryId of memoryIds) {
|
|
226
|
+
const existing = store.getProjectRecallSource?.(projectId, memoryId);
|
|
227
|
+
if (existing && existing.length > 0)
|
|
228
|
+
continue;
|
|
229
|
+
const archiveEntries = buildRecallSourceArchiveEntries(entries, memoryState, memoryId);
|
|
230
|
+
if (!archiveEntries || archiveEntries.length === 0)
|
|
231
|
+
continue;
|
|
232
|
+
store.upsertProjectRecallSource?.(projectId, memoryId, archiveEntries);
|
|
233
|
+
persisted += 1;
|
|
234
|
+
}
|
|
235
|
+
debugLog("compaction.project_recall_sources", {
|
|
236
|
+
projectId,
|
|
237
|
+
sessionId,
|
|
238
|
+
candidates: memoryIds.size,
|
|
239
|
+
persisted,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
200
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observer-trigger.d.ts","sourceRoot":"","sources":["../../../src/memory/hooks/observer-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"observer-trigger.d.ts","sourceRoot":"","sources":["../../../src/memory/hooks/observer-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAapE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAY7C,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAmLjF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { debugLog, withDebugLogContext } from "../debug-log.js";
|
|
2
2
|
import { resolveTurnLimits } from "../config.js";
|
|
3
|
-
import { firstRawIdAfter, getMemoryState, lastObservationCoverEndIdx, rawTailEntriesBetween, rawTokensSinceLastBound, } from "../branch.js";
|
|
3
|
+
import { buildRecallSourceArchiveEntries, firstRawIdAfter, getMemoryState, lastObservationCoverEndIdx, rawTailEntriesBetween, rawTokensSinceLastBound, } from "../branch.js";
|
|
4
4
|
import { observationsToPromptLines, runObserver } from "../observer.js";
|
|
5
5
|
import { serializeSourceAddressedBranchEntries } from "../serialize.js";
|
|
6
6
|
import { estimateEntryTokens, estimateStringTokens } from "../tokens.js";
|
|
@@ -153,7 +153,7 @@ export function registerObserverTrigger(ext, runtime) {
|
|
|
153
153
|
records,
|
|
154
154
|
});
|
|
155
155
|
ext.appendEntry(OBSERVATION_CUSTOM_TYPE, data);
|
|
156
|
-
relayObservationRecords(cwd, ctx.sessionManager.getSessionId?.(), records);
|
|
156
|
+
relayObservationRecords(cwd, ctx.sessionManager.getSessionId?.(), records, chunkEntries);
|
|
157
157
|
debugLog("observer.appended", { count: records.length, tokenCount: observationTokens, coversFromId, coversUpToId: effectiveCoversUpToId });
|
|
158
158
|
if (hasUI && ui)
|
|
159
159
|
ui.notify(`Observational memory: ${records.length} observation${records.length === 1 ? "" : "s"} recorded (~${observationTokens.toLocaleString()} tokens)`, "info");
|
|
@@ -165,7 +165,7 @@ export function registerObserverTrigger(ext, runtime) {
|
|
|
165
165
|
}));
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
function relayObservationRecords(cwd, sessionId, records) {
|
|
168
|
+
function relayObservationRecords(cwd, sessionId, records, sourceEntries) {
|
|
169
169
|
if (!sessionId || records.length === 0)
|
|
170
170
|
return;
|
|
171
171
|
const store = getProjectObsStore();
|
|
@@ -174,5 +174,11 @@ function relayObservationRecords(cwd, sessionId, records) {
|
|
|
174
174
|
const projectId = store.getProjectByCwd(cwd);
|
|
175
175
|
if (!projectId)
|
|
176
176
|
return;
|
|
177
|
+
for (const record of records) {
|
|
178
|
+
const archiveEntries = buildRecallSourceArchiveEntries(sourceEntries, { reflections: [], committedObs: [record], pendingObs: [] }, record.id);
|
|
179
|
+
if (!archiveEntries || archiveEntries.length === 0)
|
|
180
|
+
continue;
|
|
181
|
+
store.upsertProjectRecallSource?.(projectId, record.id, archiveEntries);
|
|
182
|
+
}
|
|
177
183
|
relayProjectObservations(cwd, projectId, sessionId, records, "observation");
|
|
178
184
|
}
|
package/dist/memory/index.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "../sdk/coding-agent/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Observational memory extension entry point.
|
|
4
|
+
*
|
|
5
|
+
* The extension is composed of two independent layers:
|
|
6
|
+
* - `session-memory.ts`: session/branch-scoped memory (observer,
|
|
7
|
+
* deterministic prune, summary render, session snapshot persistence).
|
|
8
|
+
* - `project-observation-memory.ts`: per-machine + per-cwd, cross-session
|
|
9
|
+
* project observations (write/read/recall/share/receive tools plus
|
|
10
|
+
* inter-agent broker wiring).
|
|
11
|
+
*
|
|
12
|
+
* This default export keeps the original registration contract so it is still
|
|
13
|
+
* registered exactly once as `observationalMemory(ext)`.
|
|
14
|
+
*/
|
|
2
15
|
export default function observationalMemory(ext: ExtensionAPI): void;
|
|
3
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAKjE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,GAAG,EAAE,YAAY,QAQ5D"}
|
package/dist/memory/index.js
CHANGED
|
@@ -1,32 +1,23 @@
|
|
|
1
|
-
import { registerStatusCommand } from "./commands/status.js";
|
|
2
|
-
import { registerViewCommand } from "./commands/view.js";
|
|
3
|
-
import { registerCompactionHook } from "./hooks/compaction-hook.js";
|
|
4
|
-
import { registerCompactionTrigger } from "./hooks/compaction-trigger.js";
|
|
5
|
-
import { registerInterAgentReceiver } from "./hooks/inter-agent-receiver.js";
|
|
6
|
-
import { registerObserverTrigger } from "./hooks/observer-trigger.js";
|
|
7
1
|
import { Runtime } from "./runtime.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
import { registerProjectObservationMemory } from "./project-observation-memory.js";
|
|
3
|
+
import { registerSessionMemory } from "./session-memory.js";
|
|
4
|
+
/**
|
|
5
|
+
* Observational memory extension entry point.
|
|
6
|
+
*
|
|
7
|
+
* The extension is composed of two independent layers:
|
|
8
|
+
* - `session-memory.ts`: session/branch-scoped memory (observer,
|
|
9
|
+
* deterministic prune, summary render, session snapshot persistence).
|
|
10
|
+
* - `project-observation-memory.ts`: per-machine + per-cwd, cross-session
|
|
11
|
+
* project observations (write/read/recall/share/receive tools plus
|
|
12
|
+
* inter-agent broker wiring).
|
|
13
|
+
*
|
|
14
|
+
* This default export keeps the original registration contract so it is still
|
|
15
|
+
* registered exactly once as `observationalMemory(ext)`.
|
|
16
|
+
*/
|
|
15
17
|
export default function observationalMemory(ext) {
|
|
16
18
|
const runtime = new Runtime();
|
|
17
19
|
// Log extension load so we can confirm it's running in serve mode.
|
|
18
20
|
process.stderr.write("[obs-mem] extension loaded\n");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
registerCompactionTrigger(ext, runtime);
|
|
22
|
-
registerCompactionHook(ext, runtime);
|
|
23
|
-
registerToolOutputCompressor(ext, runtime);
|
|
24
|
-
registerStatusCommand(ext, runtime);
|
|
25
|
-
registerViewCommand(ext, runtime);
|
|
26
|
-
registerRecallTool(ext);
|
|
27
|
-
registerReadProjectObservationsTool(ext);
|
|
28
|
-
registerWriteProjectObservationTool(ext);
|
|
29
|
-
registerShareProjectObservationTool(ext);
|
|
30
|
-
registerReceiveAgentObservationsTool(ext);
|
|
31
|
-
registerInterAgentReceiver(ext);
|
|
21
|
+
registerSessionMemory(ext, runtime);
|
|
22
|
+
registerProjectObservationMemory(ext);
|
|
32
23
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "../sdk/coding-agent/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Project-observation memory layer.
|
|
4
|
+
*
|
|
5
|
+
* This layer owns the five project-observation tools
|
|
6
|
+
* (`write_project_observation`, `read_project_observations`, `recall`,
|
|
7
|
+
* `share_project_observation`, `receive_agent_observations`) plus the
|
|
8
|
+
* `project-observations-store.ts` shim and the inter-agent broker wiring.
|
|
9
|
+
*
|
|
10
|
+
* Storage is per-machine + per-cwd + cross-session: observations are keyed by
|
|
11
|
+
* the local project resolved from the absolute working directory and persisted
|
|
12
|
+
* in the same-machine SQLite store. There is no cloud/team sync and no
|
|
13
|
+
* cross-machine fan-out.
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerProjectObservationMemory(ext: ExtensionAPI): void;
|
|
16
|
+
//# sourceMappingURL=project-observation-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-observation-memory.d.ts","sourceRoot":"","sources":["../../src/memory/project-observation-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAQjE;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAQxE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { registerInterAgentReceiver } from "./hooks/inter-agent-receiver.js";
|
|
2
|
+
import { registerRecallTool } from "./tools/recall-observation.js";
|
|
3
|
+
import { registerReadProjectObservationsTool } from "./tools/read-project-observations.js";
|
|
4
|
+
import { registerReceiveAgentObservationsTool } from "./tools/receive-agent-observations.js";
|
|
5
|
+
import { registerShareProjectObservationTool } from "./tools/share-project-observation.js";
|
|
6
|
+
import { registerWriteProjectObservationTool } from "./tools/write-project-observation.js";
|
|
7
|
+
/**
|
|
8
|
+
* Project-observation memory layer.
|
|
9
|
+
*
|
|
10
|
+
* This layer owns the five project-observation tools
|
|
11
|
+
* (`write_project_observation`, `read_project_observations`, `recall`,
|
|
12
|
+
* `share_project_observation`, `receive_agent_observations`) plus the
|
|
13
|
+
* `project-observations-store.ts` shim and the inter-agent broker wiring.
|
|
14
|
+
*
|
|
15
|
+
* Storage is per-machine + per-cwd + cross-session: observations are keyed by
|
|
16
|
+
* the local project resolved from the absolute working directory and persisted
|
|
17
|
+
* in the same-machine SQLite store. There is no cloud/team sync and no
|
|
18
|
+
* cross-machine fan-out.
|
|
19
|
+
*/
|
|
20
|
+
export function registerProjectObservationMemory(ext) {
|
|
21
|
+
registerRecallTool(ext);
|
|
22
|
+
registerReadProjectObservationsTool(ext);
|
|
23
|
+
registerWriteProjectObservationTool(ext);
|
|
24
|
+
registerShareProjectObservationTool(ext);
|
|
25
|
+
registerReceiveAgentObservationsTool(ext);
|
|
26
|
+
registerInterAgentReceiver(ext);
|
|
27
|
+
}
|
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
* memory extension so the `read_project_observations` tool can query
|
|
4
4
|
* cross-session observations.
|
|
5
5
|
*
|
|
6
|
+
* Storage is per-machine + per-cwd: observations are keyed by the local
|
|
7
|
+
* project resolved from the absolute working directory and persisted in the
|
|
8
|
+
* same-machine SQLite store. They are shared across sessions on this machine
|
|
9
|
+
* but are NOT synced across machines or teams.
|
|
10
|
+
*
|
|
6
11
|
* Set once by the SessionStreamManager at startup. Read by tools at runtime.
|
|
7
12
|
*/
|
|
13
|
+
import type { Entry } from "./branch.js";
|
|
8
14
|
export interface ProjectObservationsStore {
|
|
9
15
|
insertProjectObservations(projectId: string, sessionId: string, observations: Array<{
|
|
10
16
|
id: string;
|
|
@@ -25,6 +31,8 @@ export interface ProjectObservationsStore {
|
|
|
25
31
|
sessionId: string;
|
|
26
32
|
} | null;
|
|
27
33
|
getProjectByCwd(cwd: string): string | null;
|
|
34
|
+
upsertProjectRecallSource?(projectId: string, memoryId: string, entries: Entry[]): void;
|
|
35
|
+
getProjectRecallSource?(projectId: string, memoryId: string): Entry[] | null;
|
|
28
36
|
}
|
|
29
37
|
export declare function setProjectObsStore(store: ProjectObservationsStore): void;
|
|
30
38
|
export declare function getProjectObsStore(): ProjectObservationsStore | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-observations-store.d.ts","sourceRoot":"","sources":["../../src/memory/project-observations-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"project-observations-store.d.ts","sourceRoot":"","sources":["../../src/memory/project-observations-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,wBAAwB;IACxC,yBAAyB,CACxB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,EACvE,SAAS,EAAE,MAAM,GACf,IAAI,CAAC;IACR,yBAAyB,CACxB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACZ,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvF,yBAAyB,CACxB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACnB;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnG,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5C,yBAAyB,CAAC,CACzB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,KAAK,EAAE,GACd,IAAI,CAAC;IACR,sBAAsB,CAAC,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACd,KAAK,EAAE,GAAG,IAAI,CAAC;CAClB;AAID,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAExE;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,GAAG,IAAI,CAEpE"}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* memory extension so the `read_project_observations` tool can query
|
|
4
4
|
* cross-session observations.
|
|
5
5
|
*
|
|
6
|
+
* Storage is per-machine + per-cwd: observations are keyed by the local
|
|
7
|
+
* project resolved from the absolute working directory and persisted in the
|
|
8
|
+
* same-machine SQLite store. They are shared across sessions on this machine
|
|
9
|
+
* but are NOT synced across machines or teams.
|
|
10
|
+
*
|
|
6
11
|
* Set once by the SessionStreamManager at startup. Read by tools at runtime.
|
|
7
12
|
*/
|
|
8
13
|
let _store = null;
|