@pellux/goodvibes-sdk 0.37.1 → 0.38.0
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/contracts/artifacts/operator-contract.json +1 -1
- package/dist/events/communication.d.ts +21 -1
- package/dist/events/communication.d.ts.map +1 -1
- package/dist/platform/agents/message-bus-core.d.ts +7 -0
- package/dist/platform/agents/message-bus-core.d.ts.map +1 -1
- package/dist/platform/agents/message-bus-core.js +2 -1
- package/dist/platform/agents/orchestrator-runner.d.ts +37 -1
- package/dist/platform/agents/orchestrator-runner.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator-runner.js +158 -7
- package/dist/platform/agents/orchestrator.d.ts +40 -0
- package/dist/platform/agents/orchestrator.d.ts.map +1 -1
- package/dist/platform/agents/orchestrator.js +29 -0
- package/dist/platform/agents/turn-knowledge-injection.d.ts +107 -0
- package/dist/platform/agents/turn-knowledge-injection.d.ts.map +1 -0
- package/dist/platform/agents/turn-knowledge-injection.js +152 -0
- package/dist/platform/agents/wrfc-controller.d.ts +23 -0
- package/dist/platform/agents/wrfc-controller.d.ts.map +1 -1
- package/dist/platform/agents/wrfc-controller.js +55 -0
- package/dist/platform/config/manager.d.ts +9 -0
- package/dist/platform/config/manager.d.ts.map +1 -1
- package/dist/platform/config/manager.js +15 -0
- package/dist/platform/control-plane/approval-broker.d.ts +1 -0
- package/dist/platform/control-plane/approval-broker.d.ts.map +1 -1
- package/dist/platform/control-plane/approval-broker.js +2 -0
- package/dist/platform/core/adaptive-planner.d.ts +50 -0
- package/dist/platform/core/adaptive-planner.d.ts.map +1 -1
- package/dist/platform/core/adaptive-planner.js +49 -0
- package/dist/platform/core/index.d.ts +1 -0
- package/dist/platform/core/index.d.ts.map +1 -1
- package/dist/platform/core/index.js +1 -0
- package/dist/platform/core/orchestrator-runtime.d.ts +11 -0
- package/dist/platform/core/orchestrator-runtime.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-turn-loop.d.ts +28 -1
- package/dist/platform/core/orchestrator-turn-loop.d.ts.map +1 -1
- package/dist/platform/core/orchestrator-turn-loop.js +115 -3
- package/dist/platform/core/orchestrator.d.ts +61 -0
- package/dist/platform/core/orchestrator.d.ts.map +1 -1
- package/dist/platform/core/orchestrator.js +74 -1
- package/dist/platform/core/plan-proposal.d.ts +165 -0
- package/dist/platform/core/plan-proposal.d.ts.map +1 -0
- package/dist/platform/core/plan-proposal.js +296 -0
- package/dist/platform/knowledge/knowledge-api.d.ts +26 -0
- package/dist/platform/knowledge/knowledge-api.d.ts.map +1 -1
- package/dist/platform/knowledge/knowledge-api.js +11 -0
- package/dist/platform/orchestration/budget.d.ts +22 -0
- package/dist/platform/orchestration/budget.d.ts.map +1 -0
- package/dist/platform/orchestration/budget.js +35 -0
- package/dist/platform/orchestration/cancellation.d.ts +31 -0
- package/dist/platform/orchestration/cancellation.d.ts.map +1 -0
- package/dist/platform/orchestration/cancellation.js +25 -0
- package/dist/platform/orchestration/controller-compat.d.ts +32 -0
- package/dist/platform/orchestration/controller-compat.d.ts.map +1 -0
- package/dist/platform/orchestration/controller-compat.js +13 -0
- package/dist/platform/orchestration/dirty-guard.d.ts +32 -0
- package/dist/platform/orchestration/dirty-guard.d.ts.map +1 -0
- package/dist/platform/orchestration/dirty-guard.js +147 -0
- package/dist/platform/orchestration/engine.d.ts +57 -0
- package/dist/platform/orchestration/engine.d.ts.map +1 -0
- package/dist/platform/orchestration/engine.js +418 -0
- package/dist/platform/orchestration/index.d.ts +18 -0
- package/dist/platform/orchestration/index.d.ts.map +1 -0
- package/dist/platform/orchestration/index.js +10 -0
- package/dist/platform/orchestration/persistence.d.ts +24 -0
- package/dist/platform/orchestration/persistence.d.ts.map +1 -0
- package/dist/platform/orchestration/persistence.js +176 -0
- package/dist/platform/orchestration/phase-runner.d.ts +87 -0
- package/dist/platform/orchestration/phase-runner.d.ts.map +1 -0
- package/dist/platform/orchestration/phase-runner.js +274 -0
- package/dist/platform/orchestration/scheduler.d.ts +45 -0
- package/dist/platform/orchestration/scheduler.d.ts.map +1 -0
- package/dist/platform/orchestration/scheduler.js +57 -0
- package/dist/platform/orchestration/types.d.ts +250 -0
- package/dist/platform/orchestration/types.d.ts.map +1 -0
- package/dist/platform/orchestration/types.js +15 -0
- package/dist/platform/runtime/emitters/communication.d.ts +11 -0
- package/dist/platform/runtime/emitters/communication.d.ts.map +1 -1
- package/dist/platform/runtime/emitters/communication.js +9 -0
- package/dist/platform/runtime/feature-flags/flags.d.ts.map +1 -1
- package/dist/platform/runtime/feature-flags/flags.js +17 -0
- package/dist/platform/runtime/fleet/adapters/agent.d.ts +56 -0
- package/dist/platform/runtime/fleet/adapters/agent.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/agent.js +143 -0
- package/dist/platform/runtime/fleet/adapters/automation.d.ts +30 -0
- package/dist/platform/runtime/fleet/adapters/automation.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/automation.js +41 -0
- package/dist/platform/runtime/fleet/adapters/background-process.d.ts +12 -0
- package/dist/platform/runtime/fleet/adapters/background-process.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/background-process.js +46 -0
- package/dist/platform/runtime/fleet/adapters/code-index.d.ts +21 -0
- package/dist/platform/runtime/fleet/adapters/code-index.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/code-index.js +44 -0
- package/dist/platform/runtime/fleet/adapters/orchestration.d.ts +47 -0
- package/dist/platform/runtime/fleet/adapters/orchestration.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/orchestration.js +225 -0
- package/dist/platform/runtime/fleet/adapters/schedule.d.ts +14 -0
- package/dist/platform/runtime/fleet/adapters/schedule.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/schedule.js +28 -0
- package/dist/platform/runtime/fleet/adapters/trigger.d.ts +12 -0
- package/dist/platform/runtime/fleet/adapters/trigger.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/trigger.js +22 -0
- package/dist/platform/runtime/fleet/adapters/watcher.d.ts +13 -0
- package/dist/platform/runtime/fleet/adapters/watcher.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/watcher.js +47 -0
- package/dist/platform/runtime/fleet/adapters/workflow.d.ts +11 -0
- package/dist/platform/runtime/fleet/adapters/workflow.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/workflow.js +34 -0
- package/dist/platform/runtime/fleet/adapters/wrfc.d.ts +22 -0
- package/dist/platform/runtime/fleet/adapters/wrfc.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/adapters/wrfc.js +228 -0
- package/dist/platform/runtime/fleet/index.d.ts +10 -0
- package/dist/platform/runtime/fleet/index.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/index.js +6 -0
- package/dist/platform/runtime/fleet/registry.d.ts +113 -0
- package/dist/platform/runtime/fleet/registry.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/registry.js +630 -0
- package/dist/platform/runtime/fleet/types.d.ts +199 -0
- package/dist/platform/runtime/fleet/types.d.ts.map +1 -0
- package/dist/platform/runtime/fleet/types.js +2 -0
- package/dist/platform/runtime/runtime-knowledge-api.d.ts +1 -1
- package/dist/platform/runtime/runtime-knowledge-api.d.ts.map +1 -1
- package/dist/platform/runtime/runtime-knowledge-api.js +1 -0
- package/dist/platform/runtime/services.d.ts +46 -0
- package/dist/platform/runtime/services.d.ts.map +1 -1
- package/dist/platform/runtime/services.js +78 -0
- package/dist/platform/state/code-index-chunking.d.ts +49 -0
- package/dist/platform/state/code-index-chunking.d.ts.map +1 -0
- package/dist/platform/state/code-index-chunking.js +111 -0
- package/dist/platform/state/code-index-db.d.ts +53 -0
- package/dist/platform/state/code-index-db.d.ts.map +1 -0
- package/dist/platform/state/code-index-db.js +101 -0
- package/dist/platform/state/code-index-store.d.ts +175 -0
- package/dist/platform/state/code-index-store.d.ts.map +1 -0
- package/dist/platform/state/code-index-store.js +612 -0
- package/dist/platform/state/index.d.ts +4 -2
- package/dist/platform/state/index.d.ts.map +1 -1
- package/dist/platform/state/index.js +2 -1
- package/dist/platform/state/knowledge-injection.d.ts +23 -0
- package/dist/platform/state/knowledge-injection.d.ts.map +1 -1
- package/dist/platform/state/knowledge-injection.js +34 -19
- package/dist/platform/state/memory-vector-store.d.ts +1 -13
- package/dist/platform/state/memory-vector-store.d.ts.map +1 -1
- package/dist/platform/state/memory-vector-store.js +6 -38
- package/dist/platform/state/sqlite-vec-loader.d.ts +25 -0
- package/dist/platform/state/sqlite-vec-loader.d.ts.map +1 -0
- package/dist/platform/state/sqlite-vec-loader.js +43 -0
- package/dist/platform/tools/agent/manager.d.ts +128 -1
- package/dist/platform/tools/agent/manager.d.ts.map +1 -1
- package/dist/platform/tools/agent/manager.js +137 -1
- package/dist/platform/tools/exec/runtime.d.ts.map +1 -1
- package/dist/platform/tools/exec/runtime.js +139 -44
- package/dist/platform/tools/exec/schema.d.ts +2 -0
- package/dist/platform/tools/exec/schema.d.ts.map +1 -1
- package/dist/platform/tools/fetch/runtime.d.ts +7 -0
- package/dist/platform/tools/fetch/runtime.d.ts.map +1 -1
- package/dist/platform/tools/fetch/runtime.js +8 -6
- package/dist/platform/tools/registry.d.ts +9 -3
- package/dist/platform/tools/registry.d.ts.map +1 -1
- package/dist/platform/tools/registry.js +9 -3
- package/dist/platform/types/tools.d.ts +14 -1
- package/dist/platform/types/tools.d.ts.map +1 -1
- package/dist/platform/version.js +1 -1
- package/dist/platform/workspace/checkpoint/side-git.d.ts +20 -8
- package/dist/platform/workspace/checkpoint/side-git.d.ts.map +1 -1
- package/dist/platform/workspace/checkpoint/side-git.js +21 -11
- package/package.json +17 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-injection.d.ts","sourceRoot":"","sources":["../../../src/platform/state/knowledge-injection.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,u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Y,EAAE,CAAC;IAClC,cAAc,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,0BAA0B,EAAE,CAAC;CAChH,CAAC;AA4FF;;;;;;;GAOG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,uBAAuB,EACjC,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,SAAS,MAAM,EAAO,EAClC,KAAK,SAAI,GACR,wBAAwB,EAAE,CA+C5B;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,uBAAuB,EACjC,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,SAAS,MAAM,EAAO,EAClC,KAAK,SAAI,GACR,kBAAkB,EAAE,CAItB;AAgBD,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,SAAS,6BAA6B,EAAE,GAAG,MAAM,GAAG,IAAI,CAgBjH"}
|
|
@@ -69,7 +69,17 @@ function scoreKnowledge(record, taskTokens, scopeTokens) {
|
|
|
69
69
|
}
|
|
70
70
|
return score;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Full ranking pipeline, unsliced: scores every registry record that clears
|
|
74
|
+
* the confidence>=55 gate against `task`/`writeScope`, folds in semantic
|
|
75
|
+
* similarity when the registry supports it, and returns every candidate with
|
|
76
|
+
* score>0 sorted best-first. `limit` only widens the semantic-search
|
|
77
|
+
* candidate pool (`Math.max(limit*4,12)`, mirroring the historical
|
|
78
|
+
* behavior) — it does NOT slice the returned array. Callers that want the
|
|
79
|
+
* spawn-time top-N behavior should slice the result themselves; see
|
|
80
|
+
* `selectKnowledgeForTask` below.
|
|
81
|
+
*/
|
|
82
|
+
export function selectKnowledgeForTaskScored(registry, task, writeScope = [], limit = 3) {
|
|
73
83
|
const taskTokens = tokenize(task);
|
|
74
84
|
const scopeTokens = writeScope.flatMap((entry) => tokenize(entry));
|
|
75
85
|
const semanticResults = registry.searchSemantic?.({
|
|
@@ -85,7 +95,7 @@ export function selectKnowledgeForTask(registry, task, writeScope = [], limit =
|
|
|
85
95
|
for (const entry of semanticResults) {
|
|
86
96
|
recordsById.set(entry.record.id, entry.record);
|
|
87
97
|
}
|
|
88
|
-
|
|
98
|
+
return [...recordsById.values()]
|
|
89
99
|
.filter((record) => record.confidence >= 55)
|
|
90
100
|
.map((record) => {
|
|
91
101
|
const semantic = semanticById.get(record.id);
|
|
@@ -96,26 +106,31 @@ export function selectKnowledgeForTask(registry, task, writeScope = [], limit =
|
|
|
96
106
|
})
|
|
97
107
|
.filter((entry) => entry.score > 0)
|
|
98
108
|
.sort((a, b) => b.score - a.score || b.record.updatedAt - a.record.updatedAt)
|
|
99
|
-
.map((
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
.map(({ record, score }) => ({
|
|
110
|
+
score,
|
|
111
|
+
injection: {
|
|
112
|
+
id: record.id,
|
|
113
|
+
cls: record.cls,
|
|
114
|
+
summary: record.summary,
|
|
115
|
+
reason: determineReason(record, taskTokens, scopeTokens, semanticById.get(record.id)?.similarity),
|
|
116
|
+
confidence: record.confidence,
|
|
117
|
+
reviewState: record.reviewState,
|
|
118
|
+
trustTier: inferKnowledgeInjectionTrustTier(record.reviewState),
|
|
119
|
+
useAs: 'reference-material',
|
|
120
|
+
retention: 'task-only',
|
|
121
|
+
provenance: {
|
|
122
|
+
source: 'project-memory',
|
|
123
|
+
links: record.provenance,
|
|
124
|
+
},
|
|
125
|
+
ingestMode: determineIngestMode(record, taskTokens, scopeTokens, semanticById.get(record.id)?.similarity),
|
|
115
126
|
},
|
|
116
|
-
ingestMode: determineIngestMode(record, taskTokens, scopeTokens, semanticById.get(record.id)?.similarity),
|
|
117
127
|
}));
|
|
118
128
|
}
|
|
129
|
+
export function selectKnowledgeForTask(registry, task, writeScope = [], limit = 3) {
|
|
130
|
+
return selectKnowledgeForTaskScored(registry, task, writeScope, limit)
|
|
131
|
+
.map((entry) => entry.injection)
|
|
132
|
+
.slice(0, limit);
|
|
133
|
+
}
|
|
119
134
|
function normalizeKnowledgeInjectionPromptInput(injection) {
|
|
120
135
|
return {
|
|
121
136
|
...injection,
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { MemoryClass, MemoryRecord, MemoryReviewState, MemoryScope } from './memory-store.js';
|
|
2
2
|
import { MemoryEmbeddingProviderRegistry } from './memory-embeddings.js';
|
|
3
|
-
|
|
4
|
-
* Resolves the path to the sqlite-vec native extension.
|
|
5
|
-
*
|
|
6
|
-
* When running inside a Bun bundled executable (import.meta.url path contains
|
|
7
|
-
* "$bunfs"), the npm package's import.meta.resolve() cannot find the extension
|
|
8
|
-
* because the virtual filesystem does not contain node_modules. In that case,
|
|
9
|
-
* the extension must be co-located with the binary under
|
|
10
|
-
* `<execDir>/lib/sqlite-vec-<os>-<arch>/vec0.<suffix>`.
|
|
11
|
-
*
|
|
12
|
-
* In development (bun run / node), the package's own getLoadablePath() is used
|
|
13
|
-
* via the re-exported `load()` function.
|
|
14
|
-
*/
|
|
15
|
-
export declare function resolveSqliteVecPath(): string;
|
|
3
|
+
export { resolveSqliteVecPath } from './sqlite-vec-loader.js';
|
|
16
4
|
export declare const MEMORY_VECTOR_DIMS = 384;
|
|
17
5
|
export { embedMemoryText } from './memory-embeddings.js';
|
|
18
6
|
export interface MemoryVectorSearchFilter {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-vector-store.d.ts","sourceRoot":"","sources":["../../../src/platform/state/memory-vector-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory-vector-store.d.ts","sourceRoot":"","sources":["../../../src/platform/state/memory-vector-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EACL,+BAA+B,EAGhC,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,GAAG,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAClE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAA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,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,wBAAwB;IAUhC,OAAO,CAAC,WAAW;CA4BpB"}
|
|
@@ -1,47 +1,15 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { dirname
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
3
|
import { mkdirSync } from 'node:fs';
|
|
4
4
|
import { Database } from 'bun:sqlite';
|
|
5
|
-
import { load as loadSqliteVec } from 'sqlite-vec';
|
|
6
5
|
import { MemoryEmbeddingProviderRegistry, embedMemoryText, normalizeMemoryEmbeddingVector, } from './memory-embeddings.js';
|
|
6
|
+
import { loadSqliteVecExtension } from './sqlite-vec-loader.js';
|
|
7
7
|
import { logger } from '../utils/logger.js';
|
|
8
8
|
import { summarizeError } from '../utils/error-display.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* "$bunfs"), the npm package's import.meta.resolve() cannot find the extension
|
|
14
|
-
* because the virtual filesystem does not contain node_modules. In that case,
|
|
15
|
-
* the extension must be co-located with the binary under
|
|
16
|
-
* `<execDir>/lib/sqlite-vec-<os>-<arch>/vec0.<suffix>`.
|
|
17
|
-
*
|
|
18
|
-
* In development (bun run / node), the package's own getLoadablePath() is used
|
|
19
|
-
* via the re-exported `load()` function.
|
|
20
|
-
*/
|
|
21
|
-
export function resolveSqliteVecPath() {
|
|
22
|
-
const isBundled = import.meta.url.includes('$bunfs');
|
|
23
|
-
if (isBundled) {
|
|
24
|
-
const os = process.platform === 'win32' ? 'windows' : process.platform;
|
|
25
|
-
const arch = process.arch;
|
|
26
|
-
const suffix = process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so';
|
|
27
|
-
return join(dirname(process.execPath), 'lib', `sqlite-vec-${os}-${arch}`, `vec0.${suffix}`);
|
|
28
|
-
}
|
|
29
|
-
// In dev mode, delegate to sqlite-vec's own resolver.
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Loads the sqlite-vec extension into a Bun SQLite database.
|
|
34
|
-
* Handles both bundled-binary and development execution contexts.
|
|
35
|
-
*/
|
|
36
|
-
function loadSqliteVecExtension(db) {
|
|
37
|
-
const bundledPath = resolveSqliteVecPath();
|
|
38
|
-
if (bundledPath) {
|
|
39
|
-
db.loadExtension(bundledPath);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
loadSqliteVec(db);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
9
|
+
// Lifted to sqlite-vec-loader.ts (Wave-5 W5.3) so code-index-store.ts can load
|
|
10
|
+
// the exact same native extension the exact same way. Re-exported here so
|
|
11
|
+
// existing callers that import resolveSqliteVecPath from this module keep working.
|
|
12
|
+
export { resolveSqliteVecPath } from './sqlite-vec-loader.js';
|
|
45
13
|
// Keep this in sync with DEFAULT_MEMORY_EMBEDDING_DIMS in memory-embeddings.ts.
|
|
46
14
|
// Duplicating the literal here avoids an initialization cycle when state/index.ts
|
|
47
15
|
// re-exports both modules during targeted test imports.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
|
|
2
|
+
import type { Database } from 'bun:sqlite';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the path to the sqlite-vec native extension.
|
|
5
|
+
*
|
|
6
|
+
* When running inside a Bun bundled executable (import.meta.url path contains
|
|
7
|
+
* "$bunfs"), the npm package's import.meta.resolve() cannot find the extension
|
|
8
|
+
* because the virtual filesystem does not contain node_modules. In that case,
|
|
9
|
+
* the extension must be co-located with the binary under
|
|
10
|
+
* `<execDir>/lib/sqlite-vec-<os>-<arch>/vec0.<suffix>`.
|
|
11
|
+
*
|
|
12
|
+
* In development (bun run / node), the package's own getLoadablePath() is used
|
|
13
|
+
* via the re-exported `load()` function.
|
|
14
|
+
*
|
|
15
|
+
* Shared by memory-vector-store.ts (MemoryStore's vector index) and
|
|
16
|
+
* code-index-store.ts (the repo source-tree code index, Wave-5 W5.3) so both
|
|
17
|
+
* indexes load the exact same native extension the exact same way.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveSqliteVecPath(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Loads the sqlite-vec extension into a Bun SQLite database.
|
|
22
|
+
* Handles both bundled-binary and development execution contexts.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadSqliteVecExtension(db: Database): void;
|
|
25
|
+
//# sourceMappingURL=sqlite-vec-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-vec-loader.d.ts","sourceRoot":"","sources":["../../../src/platform/state/sqlite-vec-loader.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAGrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAU7C;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAOzD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { load as loadSqliteVec } from 'sqlite-vec';
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the path to the sqlite-vec native extension.
|
|
6
|
+
*
|
|
7
|
+
* When running inside a Bun bundled executable (import.meta.url path contains
|
|
8
|
+
* "$bunfs"), the npm package's import.meta.resolve() cannot find the extension
|
|
9
|
+
* because the virtual filesystem does not contain node_modules. In that case,
|
|
10
|
+
* the extension must be co-located with the binary under
|
|
11
|
+
* `<execDir>/lib/sqlite-vec-<os>-<arch>/vec0.<suffix>`.
|
|
12
|
+
*
|
|
13
|
+
* In development (bun run / node), the package's own getLoadablePath() is used
|
|
14
|
+
* via the re-exported `load()` function.
|
|
15
|
+
*
|
|
16
|
+
* Shared by memory-vector-store.ts (MemoryStore's vector index) and
|
|
17
|
+
* code-index-store.ts (the repo source-tree code index, Wave-5 W5.3) so both
|
|
18
|
+
* indexes load the exact same native extension the exact same way.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveSqliteVecPath() {
|
|
21
|
+
const isBundled = import.meta.url.includes('$bunfs');
|
|
22
|
+
if (isBundled) {
|
|
23
|
+
const os = process.platform === 'win32' ? 'windows' : process.platform;
|
|
24
|
+
const arch = process.arch;
|
|
25
|
+
const suffix = process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so';
|
|
26
|
+
return join(dirname(process.execPath), 'lib', `sqlite-vec-${os}-${arch}`, `vec0.${suffix}`);
|
|
27
|
+
}
|
|
28
|
+
// In dev mode, delegate to sqlite-vec's own resolver.
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Loads the sqlite-vec extension into a Bun SQLite database.
|
|
33
|
+
* Handles both bundled-binary and development execution contexts.
|
|
34
|
+
*/
|
|
35
|
+
export function loadSqliteVecExtension(db) {
|
|
36
|
+
const bundledPath = resolveSqliteVecPath();
|
|
37
|
+
if (bundledPath) {
|
|
38
|
+
db.loadExtension(bundledPath);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
loadSqliteVec(db);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -2,10 +2,12 @@ import { ArchetypeLoader } from '../../agents/archetypes.js';
|
|
|
2
2
|
import { AgentMessageBus } from '../../agents/message-bus.js';
|
|
3
3
|
import { WrfcController } from '../../agents/wrfc-controller.js';
|
|
4
4
|
import type { ConfigManager } from '../../config/manager.js';
|
|
5
|
+
import type { ConversationMessageSnapshot } from '../../core/conversation.js';
|
|
5
6
|
import type { RuntimeEventBus } from '../../runtime/events/index.js';
|
|
6
7
|
import type { ExecutionIntent } from '../../runtime/execution-intents.js';
|
|
7
8
|
import type { AgentInput } from './schema.js';
|
|
8
9
|
import type { WrfcAgentRole } from '../../agents/wrfc-types.js';
|
|
10
|
+
import type { TurnInjectionRecord } from '../../agents/turn-knowledge-injection.js';
|
|
9
11
|
export type AgentExecutor = {
|
|
10
12
|
runAgent(record: AgentRecord): Promise<void>;
|
|
11
13
|
};
|
|
@@ -15,7 +17,25 @@ export interface AgentManagerDependencies {
|
|
|
15
17
|
readonly wrfcController?: Pick<WrfcController, 'createChain'> | null | undefined;
|
|
16
18
|
readonly executor?: AgentExecutor | null | undefined;
|
|
17
19
|
readonly configManager?: Pick<ConfigManager, 'get'> | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Bound on how many finished agents' final conversation snapshot are kept
|
|
22
|
+
* in the retention ring (see getConversationSnapshot). Defaults to
|
|
23
|
+
* DEFAULT_CONVERSATION_SNAPSHOT_RETENTION. Test-only knob in practice.
|
|
24
|
+
*/
|
|
25
|
+
readonly conversationSnapshotRetention?: number | undefined;
|
|
18
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Wave-3 tab attach point (Part C6): default bound on how many recently
|
|
29
|
+
* finished agents' final conversation snapshot AgentManager keeps around
|
|
30
|
+
* after their live source is released. Without a bound, a long-lived process
|
|
31
|
+
* that spawns many short-lived agents would retain every finished agent's
|
|
32
|
+
* full message history forever — this is the "leaking unbounded memory" the
|
|
33
|
+
* brief calls out. RUNNING agents are unaffected by this bound: their
|
|
34
|
+
* snapshot is read live from the still-open ConversationManager, whose size
|
|
35
|
+
* is already governed by the existing context-window compaction machinery
|
|
36
|
+
* (core/context-compaction.ts), not by this retention ring.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_CONVERSATION_SNAPSHOT_RETENTION = 20;
|
|
19
39
|
export declare const AGENT_TEMPLATES: Record<string, {
|
|
20
40
|
description: string;
|
|
21
41
|
defaultTools: string[];
|
|
@@ -33,6 +53,16 @@ export interface AgentRecord {
|
|
|
33
53
|
context?: string | undefined;
|
|
34
54
|
tools: string[];
|
|
35
55
|
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
56
|
+
/**
|
|
57
|
+
* Set by cancel(id, kind) when status transitions to 'cancelled'. Distinguishes
|
|
58
|
+
* a graceful interrupt request from a hard kill for display purposes
|
|
59
|
+
* (Wave-3 verb formalization) without overloading `status`, which is
|
|
60
|
+
* consumed widely (ledger parse, orchestrator finalize, exportState/
|
|
61
|
+
* importState). Absent on records cancelled before this field existed, and
|
|
62
|
+
* on any record cancelled via the single-arg cancel(id) call — both default
|
|
63
|
+
* to 'kill' at the read site (fleet/adapters/agent.ts deriveAgentState).
|
|
64
|
+
*/
|
|
65
|
+
terminationKind?: 'interrupt' | 'kill' | undefined;
|
|
36
66
|
startedAt: number;
|
|
37
67
|
completedAt?: number | undefined;
|
|
38
68
|
progress?: string | undefined;
|
|
@@ -57,6 +87,15 @@ export interface AgentRecord {
|
|
|
57
87
|
wrfcRouteReason?: string | undefined;
|
|
58
88
|
wrfcSubtasks?: AgentInput['wrfcSubtasks'] | undefined;
|
|
59
89
|
dangerously_disable_wrfc?: boolean | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Wave-4 orchestration engine tag (wo701): set by phase-runner.ts when it
|
|
92
|
+
* spawns an agent to run one WorkItem through one Phase. Mirrors
|
|
93
|
+
* wrfcId/wrfcSubtaskId — the fleet's agent adapter uses it to parent this
|
|
94
|
+
* agent node under its work-item ProcessNode (adapters/agent.ts
|
|
95
|
+
* resolveParentId), separate from the WRFC parenting track so the two
|
|
96
|
+
* systems' agents are never conflated.
|
|
97
|
+
*/
|
|
98
|
+
workItemId?: string | undefined;
|
|
60
99
|
cohort?: string | undefined;
|
|
61
100
|
orchestrationGraphId?: string | undefined;
|
|
62
101
|
orchestrationNodeId?: string | undefined;
|
|
@@ -80,6 +119,17 @@ export interface AgentRecord {
|
|
|
80
119
|
confidence: number;
|
|
81
120
|
reviewState: 'fresh' | 'reviewed' | 'stale' | 'contradicted';
|
|
82
121
|
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Wave-5 (wo801, W5.1) bounded ring of per-turn passive-injection honesty
|
|
124
|
+
* records — one entry per turn that actually ran retrieval (turns that
|
|
125
|
+
* reused the prior turn's cached block, or that ran with the feature
|
|
126
|
+
* flag/budget off, append nothing). See turn-knowledge-injection.ts for
|
|
127
|
+
* the record shape and recordTurnInjection for the ring-eviction policy.
|
|
128
|
+
* Deliberately a plain field (no new KnowledgeEvent contract member) —
|
|
129
|
+
* the same entries are also appended to the agent's session transcript
|
|
130
|
+
* via `session.appendMessage({type:'knowledge_injection', ...})`.
|
|
131
|
+
*/
|
|
132
|
+
turnInjections?: TurnInjectionRecord[] | undefined;
|
|
83
133
|
}
|
|
84
134
|
export declare class AgentManager {
|
|
85
135
|
private agents;
|
|
@@ -90,12 +140,89 @@ export declare class AgentManager {
|
|
|
90
140
|
private wrfcController;
|
|
91
141
|
private executor;
|
|
92
142
|
private readonly configManager;
|
|
143
|
+
/**
|
|
144
|
+
* Live snapshot accessors for RUNNING agents (Wave-3 Part C6 bridge).
|
|
145
|
+
* Registered by the executor (orchestrator-runner.ts) right after it
|
|
146
|
+
* creates the agent's ConversationManager; the manager never stores
|
|
147
|
+
* messages itself while an agent is running — it just holds a callback.
|
|
148
|
+
*/
|
|
149
|
+
private readonly conversationSources;
|
|
150
|
+
/**
|
|
151
|
+
* Wave-4 cooperative cancellation bridge (wo701): per-agent AbortSignal
|
|
152
|
+
* registered by an orchestration-engine work item for the duration of one
|
|
153
|
+
* phase run. AgentOrchestrator reads this via
|
|
154
|
+
* setCancellationSource/getCancellationSignal and threads it into
|
|
155
|
+
* toolRegistry.execute opts so opted-in tools (exec, fetch) can abort an
|
|
156
|
+
* in-flight child process/request immediately, instead of only at the next
|
|
157
|
+
* turn boundary's status poll. Purely additive — no caller is required to
|
|
158
|
+
* register anything, and an agent with no registered signal behaves
|
|
159
|
+
* exactly as before this change.
|
|
160
|
+
*/
|
|
161
|
+
private readonly cancellationSignals;
|
|
162
|
+
/**
|
|
163
|
+
* Frozen final snapshots for agents whose live source was released (their
|
|
164
|
+
* run ended). Map insertion order doubles as the bounded ring's age order:
|
|
165
|
+
* oldest entry (first key) is evicted once conversationSnapshotRetention is
|
|
166
|
+
* exceeded. See getConversationSnapshot for the read-side contract.
|
|
167
|
+
*/
|
|
168
|
+
private readonly frozenConversationSnapshots;
|
|
169
|
+
private readonly conversationSnapshotRetention;
|
|
93
170
|
constructor(deps?: AgentManagerDependencies);
|
|
94
171
|
setRuntimeBus(runtimeBus: RuntimeEventBus | null): void;
|
|
95
172
|
private deriveEffectiveTools;
|
|
96
173
|
spawn(input: AgentInput): AgentRecord;
|
|
97
174
|
getStatus(id: string): AgentRecord | null;
|
|
98
|
-
cancel(id: string): boolean;
|
|
175
|
+
cancel(id: string, kind?: 'interrupt' | 'kill'): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Register the live conversation-snapshot source for a running agent
|
|
178
|
+
* (Wave-3 Part C6 bridge). Called by the executor (orchestrator-runner.ts)
|
|
179
|
+
* once its ConversationManager exists — `source` is invoked on demand by
|
|
180
|
+
* getConversationSnapshot(); the manager never copies or stores the
|
|
181
|
+
* messages itself while the agent is running.
|
|
182
|
+
*/
|
|
183
|
+
registerConversationSource(agentId: string, source: () => ConversationMessageSnapshot[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* Wave-4 cooperative cancellation bridge (wo701): register the AbortSignal
|
|
186
|
+
* an orchestration engine's cancellation registry created for a work
|
|
187
|
+
* item's current agent. Called by the engine right after
|
|
188
|
+
* AgentManager.spawn() so the signal is in place before the agent's first
|
|
189
|
+
* turn/tool call.
|
|
190
|
+
*/
|
|
191
|
+
registerCancellationSignal(agentId: string, signal: AbortSignal): void;
|
|
192
|
+
/** Drop the registered signal once the run ends (success, failure, or cancel). Safe to call unconditionally. */
|
|
193
|
+
releaseCancellationSignal(agentId: string): void;
|
|
194
|
+
/** Read back the registered signal for AgentOrchestrator's per-tool-call opts. */
|
|
195
|
+
getCancellationSignal(agentId: string): AbortSignal | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Release the live source for an agent whose run has ended, freezing one
|
|
198
|
+
* final snapshot into the bounded retention ring (see
|
|
199
|
+
* DEFAULT_CONVERSATION_SNAPSHOT_RETENTION) so a transcript tab that was
|
|
200
|
+
* open at the moment of completion keeps showing content instead of going
|
|
201
|
+
* blank. Once evicted (oldest-first, beyond the retention bound),
|
|
202
|
+
* getConversationSnapshot falls back to an empty array — callers past that
|
|
203
|
+
* point are expected to degrade to the on-disk event ledger (Wave-3 TUI
|
|
204
|
+
* Part C6's documented fallback for completed/detached agents).
|
|
205
|
+
*
|
|
206
|
+
* Safe to call even when no source was ever registered for this agentId
|
|
207
|
+
* (e.g. a WRFC owner agent, which never runs its own turn loop).
|
|
208
|
+
*/
|
|
209
|
+
releaseConversationSource(agentId: string): void;
|
|
210
|
+
/**
|
|
211
|
+
* The Wave-3 tab attach point: a full-fidelity conversation history for a
|
|
212
|
+
* fleet agent (ConversationMessageSnapshot[] — the same shape the main
|
|
213
|
+
* session surface renders via MessageLineCache/conversation.ts).
|
|
214
|
+
*
|
|
215
|
+
* - RUNNING agent with a registered source → the current live snapshot.
|
|
216
|
+
* - Agent whose run just ended → the frozen final snapshot, until evicted
|
|
217
|
+
* from the bounded retention ring (oldest-first beyond
|
|
218
|
+
* conversationSnapshotRetention completed agents).
|
|
219
|
+
* - Unknown agent, or one long since evicted → empty array. The disk
|
|
220
|
+
* ledger (<agentId>.jsonl, written by AgentSession) is NOT a substitute
|
|
221
|
+
* for this array — it is a truncated event log (tool args/results
|
|
222
|
+
* sliced to 500 chars, no assistant message text), so callers past
|
|
223
|
+
* eviction get a degraded activity view, never a fabricated replay.
|
|
224
|
+
*/
|
|
225
|
+
getConversationSnapshot(agentId: string): ConversationMessageSnapshot[];
|
|
99
226
|
listByGraph(graphId: string): AgentRecord[];
|
|
100
227
|
cancelSubtree(rootAgentId: string): string[];
|
|
101
228
|
cancelGraph(graphId: string): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAcrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/agent/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAcrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAQpF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI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AG,IAAI;IAsBhD;;;;;;;;;;;;;;OAcG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,2BAA2B,EAAE;IAavE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE;IAI3C,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAkB5C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAQtC,IAAI,IAAI,WAAW,EAAE;IAIrB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE;IAI3C,KAAK,IAAI,IAAI;IAOb,WAAW,IAAI,WAAW,EAAE;IAU5B,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI;IAOzC,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI;IAIjD,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG,IAAI,GAAG,IAAI;CAGpF"}
|
|
@@ -8,6 +8,18 @@ import { logger } from '../../utils/logger.js';
|
|
|
8
8
|
import { summarizeError } from '../../utils/error-display.js';
|
|
9
9
|
import { splitModelRegistryKey } from '../../providers/registry-helpers.js';
|
|
10
10
|
import { isRootReviewRoleTask, resolveAuthoritativeWrfcScope, resolveImplementationToolContract, resolveNarrowedRootSpawnScope, } from './wrfc-batch-policy.js';
|
|
11
|
+
/**
|
|
12
|
+
* Wave-3 tab attach point (Part C6): default bound on how many recently
|
|
13
|
+
* finished agents' final conversation snapshot AgentManager keeps around
|
|
14
|
+
* after their live source is released. Without a bound, a long-lived process
|
|
15
|
+
* that spawns many short-lived agents would retain every finished agent's
|
|
16
|
+
* full message history forever — this is the "leaking unbounded memory" the
|
|
17
|
+
* brief calls out. RUNNING agents are unaffected by this bound: their
|
|
18
|
+
* snapshot is read live from the still-open ConversationManager, whose size
|
|
19
|
+
* is already governed by the existing context-window compaction machinery
|
|
20
|
+
* (core/context-compaction.ts), not by this retention ring.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_CONVERSATION_SNAPSHOT_RETENTION = 20;
|
|
11
23
|
export const AGENT_TEMPLATES = {
|
|
12
24
|
orchestrator: {
|
|
13
25
|
description: 'WRFC coordination and decomposition agent',
|
|
@@ -65,12 +77,40 @@ export class AgentManager {
|
|
|
65
77
|
wrfcController;
|
|
66
78
|
executor;
|
|
67
79
|
configManager;
|
|
80
|
+
/**
|
|
81
|
+
* Live snapshot accessors for RUNNING agents (Wave-3 Part C6 bridge).
|
|
82
|
+
* Registered by the executor (orchestrator-runner.ts) right after it
|
|
83
|
+
* creates the agent's ConversationManager; the manager never stores
|
|
84
|
+
* messages itself while an agent is running — it just holds a callback.
|
|
85
|
+
*/
|
|
86
|
+
conversationSources = new Map();
|
|
87
|
+
/**
|
|
88
|
+
* Wave-4 cooperative cancellation bridge (wo701): per-agent AbortSignal
|
|
89
|
+
* registered by an orchestration-engine work item for the duration of one
|
|
90
|
+
* phase run. AgentOrchestrator reads this via
|
|
91
|
+
* setCancellationSource/getCancellationSignal and threads it into
|
|
92
|
+
* toolRegistry.execute opts so opted-in tools (exec, fetch) can abort an
|
|
93
|
+
* in-flight child process/request immediately, instead of only at the next
|
|
94
|
+
* turn boundary's status poll. Purely additive — no caller is required to
|
|
95
|
+
* register anything, and an agent with no registered signal behaves
|
|
96
|
+
* exactly as before this change.
|
|
97
|
+
*/
|
|
98
|
+
cancellationSignals = new Map();
|
|
99
|
+
/**
|
|
100
|
+
* Frozen final snapshots for agents whose live source was released (their
|
|
101
|
+
* run ended). Map insertion order doubles as the bounded ring's age order:
|
|
102
|
+
* oldest entry (first key) is evicted once conversationSnapshotRetention is
|
|
103
|
+
* exceeded. See getConversationSnapshot for the read-side contract.
|
|
104
|
+
*/
|
|
105
|
+
frozenConversationSnapshots = new Map();
|
|
106
|
+
conversationSnapshotRetention;
|
|
68
107
|
constructor(deps = {}) {
|
|
69
108
|
this.archetypeLoader = deps.archetypeLoader ?? new ArchetypeLoader();
|
|
70
109
|
this.messageBus = deps.messageBus ?? new AgentMessageBus();
|
|
71
110
|
this.wrfcController = deps.wrfcController ?? null;
|
|
72
111
|
this.executor = deps.executor ?? null;
|
|
73
112
|
this.configManager = deps.configManager ?? null;
|
|
113
|
+
this.conversationSnapshotRetention = deps.conversationSnapshotRetention ?? DEFAULT_CONVERSATION_SNAPSHOT_RETENTION;
|
|
74
114
|
}
|
|
75
115
|
setRuntimeBus(runtimeBus) {
|
|
76
116
|
this.runtimeBus = runtimeBus;
|
|
@@ -446,12 +486,13 @@ export class AgentManager {
|
|
|
446
486
|
getStatus(id) {
|
|
447
487
|
return this.agents.get(id) ?? null;
|
|
448
488
|
}
|
|
449
|
-
cancel(id) {
|
|
489
|
+
cancel(id, kind = 'kill') {
|
|
450
490
|
const record = this.agents.get(id);
|
|
451
491
|
if (!record)
|
|
452
492
|
return false;
|
|
453
493
|
if (record.status === 'pending' || record.status === 'running') {
|
|
454
494
|
record.status = 'cancelled';
|
|
495
|
+
record.terminationKind = kind;
|
|
455
496
|
record.completedAt = Date.now();
|
|
456
497
|
if (this.runtimeBus) {
|
|
457
498
|
emitAgentCancelled(this.runtimeBus, {
|
|
@@ -480,6 +521,99 @@ export class AgentManager {
|
|
|
480
521
|
this.agents.set(id, record);
|
|
481
522
|
return true;
|
|
482
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Register the live conversation-snapshot source for a running agent
|
|
526
|
+
* (Wave-3 Part C6 bridge). Called by the executor (orchestrator-runner.ts)
|
|
527
|
+
* once its ConversationManager exists — `source` is invoked on demand by
|
|
528
|
+
* getConversationSnapshot(); the manager never copies or stores the
|
|
529
|
+
* messages itself while the agent is running.
|
|
530
|
+
*/
|
|
531
|
+
registerConversationSource(agentId, source) {
|
|
532
|
+
this.conversationSources.set(agentId, source);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Wave-4 cooperative cancellation bridge (wo701): register the AbortSignal
|
|
536
|
+
* an orchestration engine's cancellation registry created for a work
|
|
537
|
+
* item's current agent. Called by the engine right after
|
|
538
|
+
* AgentManager.spawn() so the signal is in place before the agent's first
|
|
539
|
+
* turn/tool call.
|
|
540
|
+
*/
|
|
541
|
+
registerCancellationSignal(agentId, signal) {
|
|
542
|
+
this.cancellationSignals.set(agentId, signal);
|
|
543
|
+
}
|
|
544
|
+
/** Drop the registered signal once the run ends (success, failure, or cancel). Safe to call unconditionally. */
|
|
545
|
+
releaseCancellationSignal(agentId) {
|
|
546
|
+
this.cancellationSignals.delete(agentId);
|
|
547
|
+
}
|
|
548
|
+
/** Read back the registered signal for AgentOrchestrator's per-tool-call opts. */
|
|
549
|
+
getCancellationSignal(agentId) {
|
|
550
|
+
return this.cancellationSignals.get(agentId);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Release the live source for an agent whose run has ended, freezing one
|
|
554
|
+
* final snapshot into the bounded retention ring (see
|
|
555
|
+
* DEFAULT_CONVERSATION_SNAPSHOT_RETENTION) so a transcript tab that was
|
|
556
|
+
* open at the moment of completion keeps showing content instead of going
|
|
557
|
+
* blank. Once evicted (oldest-first, beyond the retention bound),
|
|
558
|
+
* getConversationSnapshot falls back to an empty array — callers past that
|
|
559
|
+
* point are expected to degrade to the on-disk event ledger (Wave-3 TUI
|
|
560
|
+
* Part C6's documented fallback for completed/detached agents).
|
|
561
|
+
*
|
|
562
|
+
* Safe to call even when no source was ever registered for this agentId
|
|
563
|
+
* (e.g. a WRFC owner agent, which never runs its own turn loop).
|
|
564
|
+
*/
|
|
565
|
+
releaseConversationSource(agentId) {
|
|
566
|
+
const source = this.conversationSources.get(agentId);
|
|
567
|
+
if (!source)
|
|
568
|
+
return;
|
|
569
|
+
this.conversationSources.delete(agentId);
|
|
570
|
+
let finalSnapshot;
|
|
571
|
+
try {
|
|
572
|
+
finalSnapshot = source();
|
|
573
|
+
}
|
|
574
|
+
catch (error) {
|
|
575
|
+
logger.warn('AgentManager: conversation source threw on release', { agentId, error: summarizeError(error) });
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
// Re-insert at the end (freshest) even if already present, so the ring's
|
|
579
|
+
// insertion order tracks recency of completion, not first appearance.
|
|
580
|
+
this.frozenConversationSnapshots.delete(agentId);
|
|
581
|
+
this.frozenConversationSnapshots.set(agentId, finalSnapshot);
|
|
582
|
+
while (this.frozenConversationSnapshots.size > this.conversationSnapshotRetention) {
|
|
583
|
+
const oldestKey = this.frozenConversationSnapshots.keys().next().value;
|
|
584
|
+
if (oldestKey === undefined)
|
|
585
|
+
break;
|
|
586
|
+
this.frozenConversationSnapshots.delete(oldestKey);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* The Wave-3 tab attach point: a full-fidelity conversation history for a
|
|
591
|
+
* fleet agent (ConversationMessageSnapshot[] — the same shape the main
|
|
592
|
+
* session surface renders via MessageLineCache/conversation.ts).
|
|
593
|
+
*
|
|
594
|
+
* - RUNNING agent with a registered source → the current live snapshot.
|
|
595
|
+
* - Agent whose run just ended → the frozen final snapshot, until evicted
|
|
596
|
+
* from the bounded retention ring (oldest-first beyond
|
|
597
|
+
* conversationSnapshotRetention completed agents).
|
|
598
|
+
* - Unknown agent, or one long since evicted → empty array. The disk
|
|
599
|
+
* ledger (<agentId>.jsonl, written by AgentSession) is NOT a substitute
|
|
600
|
+
* for this array — it is a truncated event log (tool args/results
|
|
601
|
+
* sliced to 500 chars, no assistant message text), so callers past
|
|
602
|
+
* eviction get a degraded activity view, never a fabricated replay.
|
|
603
|
+
*/
|
|
604
|
+
getConversationSnapshot(agentId) {
|
|
605
|
+
const liveSource = this.conversationSources.get(agentId);
|
|
606
|
+
if (liveSource) {
|
|
607
|
+
try {
|
|
608
|
+
return liveSource();
|
|
609
|
+
}
|
|
610
|
+
catch (error) {
|
|
611
|
+
logger.warn('AgentManager: conversation source threw', { agentId, error: summarizeError(error) });
|
|
612
|
+
return [];
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return this.frozenConversationSnapshots.get(agentId) ?? [];
|
|
616
|
+
}
|
|
483
617
|
listByGraph(graphId) {
|
|
484
618
|
return this.list().filter((agent) => agent.orchestrationGraphId === graphId);
|
|
485
619
|
}
|
|
@@ -521,6 +655,8 @@ export class AgentManager {
|
|
|
521
655
|
clear() {
|
|
522
656
|
this.agents.clear();
|
|
523
657
|
this.orchestrationGraphs.clear();
|
|
658
|
+
this.conversationSources.clear();
|
|
659
|
+
this.frozenConversationSnapshots.clear();
|
|
524
660
|
}
|
|
525
661
|
exportState() {
|
|
526
662
|
return [...this.agents.values()].map((agent) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/exec/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAqB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAA+B,iBAAiB,EAAiB,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/platform/tools/exec/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAqB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAA+B,iBAAiB,EAAiB,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAyjB/E;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,GAC3D,OAAO,CA8CT;AAsJD,wBAAgB,cAAc,CAC5B,cAAc,EAAE,cAAc,EAC9B,OAAO,GAAE;IACP,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACjF,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CACnD,GACL,IAAI,CA8FN"}
|