@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
|
@@ -20,6 +20,7 @@ export * from './orchestrator-turn-helpers.js';
|
|
|
20
20
|
export * from './orchestrator-turn-loop.js';
|
|
21
21
|
export * from './orchestrator.js';
|
|
22
22
|
export * from './plan-command-handler.js';
|
|
23
|
+
export * from './plan-proposal.js';
|
|
23
24
|
export * from './replay-command-handler.js';
|
|
24
25
|
export * from './session-lineage.js';
|
|
25
26
|
export * from './session-memory.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC"}
|
|
@@ -20,6 +20,7 @@ export * from './orchestrator-turn-helpers.js';
|
|
|
20
20
|
export * from './orchestrator-turn-loop.js';
|
|
21
21
|
export * from './orchestrator.js';
|
|
22
22
|
export * from './plan-command-handler.js';
|
|
23
|
+
export * from './plan-proposal.js';
|
|
23
24
|
export * from './replay-command-handler.js';
|
|
24
25
|
export * from './session-lineage.js';
|
|
25
26
|
export * from './session-memory.js';
|
|
@@ -8,6 +8,7 @@ import type { AdaptivePlanner } from './adaptive-planner.js';
|
|
|
8
8
|
import type { ExecutionPlanManager } from './execution-plan.js';
|
|
9
9
|
import type { SessionMemoryStore } from './session-memory.js';
|
|
10
10
|
import type { FavoritesStore } from '../providers/favorites.js';
|
|
11
|
+
import type { TurnKnowledgeRegistrySource } from '../agents/turn-knowledge-injection.js';
|
|
11
12
|
export type OrchestratorCoreServices = {
|
|
12
13
|
configManager?: Pick<ConfigManager, 'get' | 'getCategory' | 'getWorkingDirectory'> | undefined;
|
|
13
14
|
providerRegistry?: ProviderRegistry | undefined;
|
|
@@ -18,6 +19,16 @@ export type OrchestratorCoreServices = {
|
|
|
18
19
|
adaptivePlanner?: Pick<AdaptivePlanner, 'select' | 'getMode' | 'setMode' | 'explain' | 'override' | 'clearOverride' | 'getOverride' | 'getLatest'>;
|
|
19
20
|
sessionMemoryStore?: Pick<SessionMemoryStore, 'list'> | undefined;
|
|
20
21
|
favoritesStore?: Pick<FavoritesStore, 'recordUsage'> | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Wave-5 (wo805) narrow injection seam for the MAIN interactive session's per-turn
|
|
24
|
+
* passive knowledge injection (see core/orchestrator-turn-loop.ts). Optional/undefined
|
|
25
|
+
* is a hard no-op — the feature never runs and the base system prompt is
|
|
26
|
+
* byte-identical, matching the agent path's (wo801) `memoryRegistry` semantics. Wired
|
|
27
|
+
* in post-construction via `Orchestrator.setCoreServices({ memoryRegistry })` since,
|
|
28
|
+
* like `sessionMemoryStore`/`planManager` above, it is not required at construction
|
|
29
|
+
* time.
|
|
30
|
+
*/
|
|
31
|
+
memoryRegistry?: TurnKnowledgeRegistrySource | undefined;
|
|
21
32
|
};
|
|
22
33
|
export declare function normalizeUsage(usage: Awaited<ReturnType<LLMProvider['chat']>>['usage']): Awaited<ReturnType<LLMProvider['chat']>>['usage'];
|
|
23
34
|
export declare function estimateFreshTurnInputTokens(lastInputTokens: number, currentEstimatedTokens: number, text: string, content?: ContentPart[]): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-runtime.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,E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AQ,EAAE,wBAAwB,EAClC,qBAAqB,EAAE,gBAAgB,GACtC,gBAAgB,CAElB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,wBAAwB,GACjC,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,aAAa,GAAG,qBAAqB,CAAC,CAKpE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,gBAAgB,CAK5F;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,wBAAwB,EAClC,oBAAoB,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,GACxD,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,CAErC;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,8BAA8B,EAAE,cAAc,CAMvD"}
|
|
@@ -13,6 +13,7 @@ import type { ModelDefinition } from '../providers/registry.js';
|
|
|
13
13
|
import type { FavoritesStore } from '../providers/favorites.js';
|
|
14
14
|
import type { AgentManager } from '../tools/agent/index.js';
|
|
15
15
|
import type { ExecutionPlanManager } from './execution-plan.js';
|
|
16
|
+
import { type TurnInjectionRecord, type TurnKnowledgeRegistrySource } from '../agents/turn-knowledge-injection.js';
|
|
16
17
|
interface HookDispatcherLike {
|
|
17
18
|
fire(event: HookEvent): Promise<HookResult>;
|
|
18
19
|
}
|
|
@@ -27,7 +28,7 @@ export interface OrchestratorTurnLoopContext {
|
|
|
27
28
|
readonly runtimeBus: RuntimeEventBus | null;
|
|
28
29
|
readonly agentManager: Pick<AgentManager, 'list' | 'spawn'>;
|
|
29
30
|
readonly configManager: Pick<ConfigManager, 'get'>;
|
|
30
|
-
readonly providerRegistry: Pick<ProviderRegistry, 'require' | 'getCurrentModel' | 'getForModel' | 'getTokenLimitsForModel'>;
|
|
31
|
+
readonly providerRegistry: Pick<ProviderRegistry, 'require' | 'getCurrentModel' | 'getForModel' | 'getTokenLimitsForModel' | 'getContextWindowForModel'>;
|
|
31
32
|
readonly favoritesStore?: Pick<FavoritesStore, 'recordUsage'> | undefined;
|
|
32
33
|
readonly cacheHitTracker: Pick<CacheHitTracker, 'getMetrics'>;
|
|
33
34
|
readonly helperModel: HelperModel;
|
|
@@ -58,6 +59,32 @@ export interface OrchestratorTurnLoopContext {
|
|
|
58
59
|
cacheRead: number;
|
|
59
60
|
cacheWrite: number;
|
|
60
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Wave-5 (wo805) per-turn passive-injection wiring for the MAIN interactive session —
|
|
64
|
+
* the sibling of wo801's agents/orchestrator-runner.ts runAgentTask wiring, gated on the
|
|
65
|
+
* SAME `agent-passive-knowledge-injection` feature flag (its description already
|
|
66
|
+
* promised "the EVOLVING main-session conversation" coverage; see
|
|
67
|
+
* runtime/feature-flags/flags.ts). `memoryRegistry` undefined is a hard no-op, matching
|
|
68
|
+
* the agent path. Budget/floor default to the same derived defaults
|
|
69
|
+
* (defaultTurnKnowledgeBudgetTokens / DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR) when
|
|
70
|
+
* omitted.
|
|
71
|
+
*/
|
|
72
|
+
readonly memoryRegistry?: TurnKnowledgeRegistrySource | undefined;
|
|
73
|
+
readonly isPassiveKnowledgeInjectionEnabled: () => boolean;
|
|
74
|
+
readonly passiveKnowledgeInjectionBudgetTokens?: number | undefined;
|
|
75
|
+
readonly passiveKnowledgeInjectionRelevanceFloor?: number | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The main session has no spawn-time `AgentRecord.knowledgeInjections` baseline, so this
|
|
78
|
+
* starts empty and grows monotonically for the life of the Orchestrator — no record is
|
|
79
|
+
* ever surfaced twice across the whole interactive session (mirrors wo801's
|
|
80
|
+
* knowledgeIdsAlreadySurfaced, but session-lifetime instead of one-agent-run-lifetime).
|
|
81
|
+
*/
|
|
82
|
+
readonly getAlreadyInjectedKnowledgeIds: () => readonly string[];
|
|
83
|
+
readonly addInjectedKnowledgeIds: (ids: readonly string[]) => void;
|
|
84
|
+
/** Bounded ring (see recordTurnInjection) backing Orchestrator.getTurnInjections(). */
|
|
85
|
+
readonly recordTurnKnowledgeInjection: (record: TurnInjectionRecord) => void;
|
|
86
|
+
/** Monotonic per-Orchestrator-lifetime sequence number for TurnInjectionRecord.turn. */
|
|
87
|
+
readonly nextTurnKnowledgeSequence: () => number;
|
|
61
88
|
}
|
|
62
89
|
export declare function executeOrchestratorTurnLoop(context: OrchestratorTurnLoopContext): Promise<void>;
|
|
63
90
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator-turn-loop.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator-turn-loop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAe,MAAM,2BAA2B,CAAC;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAc/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,KAAK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AA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CA+drG"}
|
|
@@ -8,7 +8,18 @@ import { logger } from '../utils/logger.js';
|
|
|
8
8
|
import { emitMalformedToolUseWarning, handleFinalResponseOutcome, handleToolResponseOutcome, } from './orchestrator-turn-helpers.js';
|
|
9
9
|
import { appendGoodVibesRuntimeAwarenessPrompt } from '../tools/goodvibes-runtime/index.js';
|
|
10
10
|
import { buildWrfcWorkflowRoutingPrompt } from './wrfc-routing.js';
|
|
11
|
+
import { buildPerTurnKnowledgeInjection, defaultTurnKnowledgeBudgetTokens, DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR, } from '../agents/turn-knowledge-injection.js';
|
|
11
12
|
const AUTO_SPAWN_FALLBACK_DELAY_MS = 5_000;
|
|
13
|
+
/**
|
|
14
|
+
* Wave-5 (wo805) per-turn passive-injection headroom clamp for the MAIN interactive
|
|
15
|
+
* session. Mirrors agents/orchestrator-runner.ts's CONTEXT_COMPACT_THRESHOLD (0.85) —
|
|
16
|
+
* deliberately NOT derived from this loop's own configurable `behavior.autoCompactThreshold`
|
|
17
|
+
* (default 80, see config/schema-domain-core.ts), which governs CONVERSATION compaction and
|
|
18
|
+
* can be user-tuned or disabled (0) independently of this feature. Keeping this fixed keeps
|
|
19
|
+
* the injection block's safety margin identical to wo801's regardless of what the operator
|
|
20
|
+
* has configured for compaction.
|
|
21
|
+
*/
|
|
22
|
+
const PASSIVE_KNOWLEDGE_INJECTION_CONTEXT_THRESHOLD = 0.85;
|
|
12
23
|
export async function executeOrchestratorTurnLoop(context) {
|
|
13
24
|
const helperModel = context.helperModel;
|
|
14
25
|
const model = context.providerRegistry.getCurrentModel();
|
|
@@ -17,6 +28,20 @@ export async function executeOrchestratorTurnLoop(context) {
|
|
|
17
28
|
const streamEnabled = context.configManager.get('display.stream');
|
|
18
29
|
let continueLoop = true;
|
|
19
30
|
const circuitBreaker = new ConsecutiveErrorBreaker();
|
|
31
|
+
// Wave-5 (wo805): true only for the FIRST LLM call this executeOrchestratorTurnLoop()
|
|
32
|
+
// invocation makes (see the per-iteration gate below for why this is the main loop's
|
|
33
|
+
// analog of wo801's "new user input this turn").
|
|
34
|
+
let isFirstIterationOfThisCall = true;
|
|
35
|
+
// Wave-5 (wo805): the last successfully-built per-turn knowledge block, reused verbatim
|
|
36
|
+
// on tool-continuation iterations of THIS call where nothing new arrived (mirrors
|
|
37
|
+
// wo801's priorTurnKnowledgeBlock) — declared OUTSIDE the while loop so a block built on
|
|
38
|
+
// iteration 1 (the human message that started this runTurn()) stays available to every
|
|
39
|
+
// later tool round of the SAME call, not just the first LLM call. It is composed onto
|
|
40
|
+
// the CURRENT `composedBaseSystemPrompt` fresh every iteration (see
|
|
41
|
+
// composeTurnSystemPrompt below), never written back into any cached base string, so it
|
|
42
|
+
// cannot compound. Reset implicitly to null on every NEW executeOrchestratorTurnLoop()
|
|
43
|
+
// call (a fresh runTurn() always recomputes from scratch on its own iteration 1).
|
|
44
|
+
let turnKnowledgeBlock = null;
|
|
20
45
|
while (continueLoop) {
|
|
21
46
|
let streamAccumulated = '';
|
|
22
47
|
let reasoningAccumulated = '';
|
|
@@ -99,6 +124,95 @@ export async function executeOrchestratorTurnLoop(context) {
|
|
|
99
124
|
break;
|
|
100
125
|
}
|
|
101
126
|
}
|
|
127
|
+
// Wave-5 (wo805): per-turn passive knowledge injection for the MAIN interactive
|
|
128
|
+
// session — the missing counterpart to wo801's agents/orchestrator-runner.ts wiring.
|
|
129
|
+
// `newUserInputThisTurn` mirrors wo801's turn-1/steer-drain gate: it is true exactly
|
|
130
|
+
// on the FIRST LLM call this executeOrchestratorTurnLoop() invocation makes (the fresh
|
|
131
|
+
// human message this runTurn() call was invoked with) and false on every subsequent
|
|
132
|
+
// tool-continuation iteration of the SAME call, since the main session never drains
|
|
133
|
+
// new human input mid-call (handleUserInput queues a second message until the current
|
|
134
|
+
// runTurn() completes — see orchestrator.ts). Retrieval reruns only when
|
|
135
|
+
// newUserInputThisTurn is true; tool-continuation iterations reuse `turnKnowledgeBlock`
|
|
136
|
+
// as-is (declared before the while loop) — exactly wo801's reuse behavior for
|
|
137
|
+
// no-new-input turns, just with a different trigger for what counts as "new".
|
|
138
|
+
const newUserInputThisTurn = isFirstIterationOfThisCall;
|
|
139
|
+
isFirstIterationOfThisCall = false;
|
|
140
|
+
const passiveKnowledgeInjectionEnabled = context.isPassiveKnowledgeInjectionEnabled();
|
|
141
|
+
let knowledgeContextWindow = 0;
|
|
142
|
+
if (passiveKnowledgeInjectionEnabled && context.memoryRegistry) {
|
|
143
|
+
knowledgeContextWindow = context.providerRegistry.getContextWindowForModel(model);
|
|
144
|
+
}
|
|
145
|
+
const baseSystemPromptForCall = appendGoodVibesRuntimeAwarenessPrompt(context.getSystemPrompt());
|
|
146
|
+
const wrfcRoutingPromptForCall = buildWrfcWorkflowRoutingPrompt(context.text);
|
|
147
|
+
const composedBaseSystemPrompt = wrfcRoutingPromptForCall
|
|
148
|
+
? `${baseSystemPromptForCall}\n\n${wrfcRoutingPromptForCall}`
|
|
149
|
+
: baseSystemPromptForCall;
|
|
150
|
+
if (passiveKnowledgeInjectionEnabled && newUserInputThisTurn && context.memoryRegistry) {
|
|
151
|
+
const configuredBudget = context.passiveKnowledgeInjectionBudgetTokens
|
|
152
|
+
?? defaultTurnKnowledgeBudgetTokens(knowledgeContextWindow);
|
|
153
|
+
let turnBudgetTokens = configuredBudget;
|
|
154
|
+
if (knowledgeContextWindow > 0) {
|
|
155
|
+
// Clamp to whatever headroom remains under the same fixed safety threshold this
|
|
156
|
+
// block always uses (PASSIVE_KNOWLEDGE_INJECTION_CONTEXT_THRESHOLD) so base+block
|
|
157
|
+
// can never silently exceed it, using LIVE token counts from the
|
|
158
|
+
// post-preflight-compaction conversation state (checkContextWindowPreflight above
|
|
159
|
+
// already ran this iteration) rather than turn-start estimates.
|
|
160
|
+
const msgTokensForBudget = estimateConversationTokens(context.conversation.getMessagesForLLM());
|
|
161
|
+
const sysTokensForBudget = estimateTokens(composedBaseSystemPrompt);
|
|
162
|
+
const threshold = Math.floor(knowledgeContextWindow * PASSIVE_KNOWLEDGE_INJECTION_CONTEXT_THRESHOLD);
|
|
163
|
+
const headroomTokens = threshold - msgTokensForBudget - sysTokensForBudget;
|
|
164
|
+
turnBudgetTokens = Math.max(0, Math.min(configuredBudget, headroomTokens));
|
|
165
|
+
}
|
|
166
|
+
if (turnBudgetTokens > 0) {
|
|
167
|
+
const relevanceFloor = context.passiveKnowledgeInjectionRelevanceFloor ?? DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR;
|
|
168
|
+
const { block, record: turnInjectionRecord } = buildPerTurnKnowledgeInjection({
|
|
169
|
+
memoryRegistry: context.memoryRegistry,
|
|
170
|
+
// The main session has no frozen "task" distinct from the live conversation —
|
|
171
|
+
// context.text (this call's originating human message) IS this turn's task, and
|
|
172
|
+
// is also the latest user-role message already appended to the conversation
|
|
173
|
+
// before the loop started (see prepareConversationForTurn), so
|
|
174
|
+
// deriveTurnKnowledgeQuery collapses to it with no duplication — the same
|
|
175
|
+
// turn-1 behavior wo801 documents for the agent path.
|
|
176
|
+
task: context.text,
|
|
177
|
+
conversationTail: context.conversation.getMessagesForLLM(),
|
|
178
|
+
budgetTokens: turnBudgetTokens,
|
|
179
|
+
relevanceFloor,
|
|
180
|
+
alreadyInjectedIds: context.getAlreadyInjectedKnowledgeIds(),
|
|
181
|
+
turn: context.nextTurnKnowledgeSequence(),
|
|
182
|
+
});
|
|
183
|
+
turnKnowledgeBlock = block;
|
|
184
|
+
if (turnInjectionRecord.injectedIds.length > 0) {
|
|
185
|
+
context.addInjectedKnowledgeIds(turnInjectionRecord.injectedIds);
|
|
186
|
+
}
|
|
187
|
+
context.recordTurnKnowledgeInjection(turnInjectionRecord);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// Hard no-op: no budget headroom this call. Never call into retrieval for a
|
|
191
|
+
// budget already known to be zero, and never keep claiming a stale block from an
|
|
192
|
+
// earlier iteration that no longer fits — clear it so composeTurnSystemPrompt
|
|
193
|
+
// falls back to the base prompt exactly (mirrors wo801's identical branch).
|
|
194
|
+
turnKnowledgeBlock = null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Composed fresh at the call site (never a hoisted `const` reused across calls) so the
|
|
198
|
+
// block is re-validated against LIVE tokens at the instant it is actually sent — the
|
|
199
|
+
// same "never mutate the cached base, recompute at the call site" discipline wo801's
|
|
200
|
+
// composeTurnSystemPrompt established, even though this loop has no in-call
|
|
201
|
+
// context-exceeded retry path to go stale across (compaction here is the PROACTIVE
|
|
202
|
+
// checkContextWindowPreflight above, not a reactive mid-call retry-and-shrink).
|
|
203
|
+
const composeTurnSystemPrompt = (base) => {
|
|
204
|
+
if (!turnKnowledgeBlock)
|
|
205
|
+
return base;
|
|
206
|
+
if (knowledgeContextWindow > 0) {
|
|
207
|
+
const liveMsgTokens = estimateConversationTokens(context.conversation.getMessagesForLLM());
|
|
208
|
+
const liveSysTokens = estimateTokens(base);
|
|
209
|
+
const liveBlockTokens = estimateTokens(turnKnowledgeBlock);
|
|
210
|
+
const threshold = Math.floor(knowledgeContextWindow * PASSIVE_KNOWLEDGE_INJECTION_CONTEXT_THRESHOLD);
|
|
211
|
+
if (liveMsgTokens + liveSysTokens + liveBlockTokens > threshold)
|
|
212
|
+
return base;
|
|
213
|
+
}
|
|
214
|
+
return `${base}\n\n${turnKnowledgeBlock}`;
|
|
215
|
+
};
|
|
102
216
|
let response;
|
|
103
217
|
if (context.runtimeBus) {
|
|
104
218
|
emitLlmRequestStarted(context.runtimeBus, context.emitterContext(context.turnId), {
|
|
@@ -111,13 +225,11 @@ export async function executeOrchestratorTurnLoop(context) {
|
|
|
111
225
|
const chatStartedAt = Date.now();
|
|
112
226
|
let chatRetries = 0;
|
|
113
227
|
try {
|
|
114
|
-
const baseSystemPrompt = appendGoodVibesRuntimeAwarenessPrompt(context.getSystemPrompt());
|
|
115
|
-
const wrfcRoutingPrompt = buildWrfcWorkflowRoutingPrompt(context.text);
|
|
116
228
|
response = await provider.chat({
|
|
117
229
|
model: model.id,
|
|
118
230
|
messages: context.conversation.getMessagesForLLM(),
|
|
119
231
|
tools: toolDefinitions.length > 0 ? toolDefinitions : undefined,
|
|
120
|
-
systemPrompt:
|
|
232
|
+
systemPrompt: composeTurnSystemPrompt(composedBaseSystemPrompt),
|
|
121
233
|
maxTokens: tokenLimits.maxOutputTokens,
|
|
122
234
|
reasoningEffort: (() => {
|
|
123
235
|
const configured = context.configManager.get('provider.reasoningEffort');
|
|
@@ -10,6 +10,7 @@ import { WrfcController } from '../agents/wrfc-controller.js';
|
|
|
10
10
|
import type { FeatureFlagManager } from '../runtime/feature-flags/manager.js';
|
|
11
11
|
import type { RuntimeEventBus, TurnInputOrigin } from '../runtime/events/index.js';
|
|
12
12
|
import { type OrchestratorCoreServices } from './orchestrator-runtime.js';
|
|
13
|
+
import { type TurnInjectionRecord } from '../agents/turn-knowledge-injection.js';
|
|
13
14
|
/** Minimal interface for hook dispatch — allows any hook dispatcher implementation */
|
|
14
15
|
interface HookDispatcherLike {
|
|
15
16
|
fire(event: HookEvent): Promise<HookResult>;
|
|
@@ -66,6 +67,19 @@ export interface OrchestratorOptions {
|
|
|
66
67
|
* plans, and reply correlation. Defaults to a generated private id.
|
|
67
68
|
*/
|
|
68
69
|
sessionId?: string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Wave-5 (wo805) per-turn passive-injection budget override for the main session,
|
|
72
|
+
* mirroring agents/orchestrator-runner.ts's `passiveKnowledgeInjectionBudgetTokens`.
|
|
73
|
+
* Omitted uses the derived default (defaultTurnKnowledgeBudgetTokens). `0` is a hard
|
|
74
|
+
* no-op, independent of the feature flag's own state.
|
|
75
|
+
*/
|
|
76
|
+
passiveKnowledgeInjectionBudgetTokens?: number | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Wave-5 (wo805) per-turn passive-injection relevance-floor override for the main
|
|
79
|
+
* session, mirroring agents/orchestrator-runner.ts's
|
|
80
|
+
* `passiveKnowledgeInjectionRelevanceFloor`. Omitted uses DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR.
|
|
81
|
+
*/
|
|
82
|
+
passiveKnowledgeInjectionRelevanceFloor?: number | undefined;
|
|
69
83
|
/** Required runtime service dependencies. */
|
|
70
84
|
services: {
|
|
71
85
|
readonly agentManager: Pick<AgentManager, 'list' | 'spawn'>;
|
|
@@ -169,6 +183,19 @@ export declare class Orchestrator {
|
|
|
169
183
|
private permissionManager;
|
|
170
184
|
private getSystemPrompt;
|
|
171
185
|
private hookDispatcher;
|
|
186
|
+
/**
|
|
187
|
+
* Wave-5 (wo805) per-turn passive-injection state for the MAIN interactive session —
|
|
188
|
+
* see core/orchestrator-turn-loop.ts for the retrieval/budget wiring that reads and
|
|
189
|
+
* mutates these. `turnKnowledgeIdsAlreadySurfaced` has no spawn-time baseline (unlike
|
|
190
|
+
* an AgentRecord's `knowledgeInjections`) so it starts empty and grows monotonically
|
|
191
|
+
* for the life of this Orchestrator. `turnInjectionRing` backs the public
|
|
192
|
+
* `getTurnInjections()` accessor.
|
|
193
|
+
*/
|
|
194
|
+
private readonly turnKnowledgeIdsAlreadySurfaced;
|
|
195
|
+
private turnInjectionRing;
|
|
196
|
+
private turnKnowledgeSequence;
|
|
197
|
+
private readonly passiveKnowledgeInjectionBudgetTokens;
|
|
198
|
+
private readonly passiveKnowledgeInjectionRelevanceFloor;
|
|
172
199
|
/**
|
|
173
200
|
* Construct an Orchestrator using a named-options object.
|
|
174
201
|
*
|
|
@@ -197,6 +224,15 @@ export declare class Orchestrator {
|
|
|
197
224
|
*/
|
|
198
225
|
registerDelegateTool(manager: AcpManager): void;
|
|
199
226
|
getSpinner(): string;
|
|
227
|
+
/**
|
|
228
|
+
* Wave-5 (wo805): bounded ring of per-turn passive-injection honesty records for the
|
|
229
|
+
* MAIN interactive session — the main-session counterpart to `AgentRecord.turnInjections`
|
|
230
|
+
* (wo801). There is no AgentRecord for the primary conversation, so this is the exact
|
|
231
|
+
* accessor a `/recall`-style renderer should read as the main-session default when no
|
|
232
|
+
* agent id is given. See agents/turn-knowledge-injection.ts for the record shape and
|
|
233
|
+
* recordTurnInjection for the ring-eviction policy (same bounded size as the agent path).
|
|
234
|
+
*/
|
|
235
|
+
getTurnInjections(): readonly TurnInjectionRecord[];
|
|
200
236
|
setSystemMessageRouter(router: LowPrioritySystemMessageSink | null): void;
|
|
201
237
|
enqueueConversationFollowUp(item: ConversationFollowUpItem): void;
|
|
202
238
|
/** Abort the current in-flight LLM request, if any. */
|
|
@@ -267,6 +303,31 @@ export declare class Orchestrator {
|
|
|
267
303
|
* has been wired in — safe for tests that omit the optional constructor arg.
|
|
268
304
|
*/
|
|
269
305
|
private isReconciliationEnabled;
|
|
306
|
+
/**
|
|
307
|
+
* Returns `true` when Wave-5 (wo801/wo805) per-turn passive knowledge injection is
|
|
308
|
+
* active for this session. Shares the SAME `agent-passive-knowledge-injection` flag as
|
|
309
|
+
* the agent path (agents/orchestrator-runner.ts) rather than a sibling main-session
|
|
310
|
+
* flag — the flag's own description already promises "the EVOLVING main-session
|
|
311
|
+
* conversation" coverage (see runtime/feature-flags/flags.ts), so wiring the main loop
|
|
312
|
+
* under the same id completes that promise instead of duplicating a second toggle for
|
|
313
|
+
* what is, from an operator's perspective, one feature.
|
|
314
|
+
*
|
|
315
|
+
* Defaults to `true` (flag `defaultState: 'enabled'`) when no flag manager has been
|
|
316
|
+
* wired in, matching {@link isReconciliationEnabled}'s convention.
|
|
317
|
+
*/
|
|
318
|
+
private isPassiveKnowledgeInjectionEnabled;
|
|
319
|
+
/**
|
|
320
|
+
* Wave-5 (wo805): ids never to re-surface in a later per-turn knowledge block. The main
|
|
321
|
+
* session has no spawn-time `AgentRecord.knowledgeInjections` baseline, so this starts
|
|
322
|
+
* empty and grows monotonically for the life of the Orchestrator.
|
|
323
|
+
*/
|
|
324
|
+
private getAlreadyInjectedKnowledgeIds;
|
|
325
|
+
/** Wave-5 (wo805): mark ids as surfaced so they are never listed twice this session. */
|
|
326
|
+
private addInjectedKnowledgeIds;
|
|
327
|
+
/** Wave-5 (wo805): append one honesty record to the bounded ring behind {@link getTurnInjections}. */
|
|
328
|
+
private recordTurnKnowledgeInjection;
|
|
329
|
+
/** Wave-5 (wo805): monotonic per-Orchestrator-lifetime sequence number for TurnInjectionRecord.turn. */
|
|
330
|
+
private nextTurnKnowledgeSequence;
|
|
270
331
|
/**
|
|
271
332
|
* Reconcile unresolved tool calls at turn end.
|
|
272
333
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAMpD,OAAO,EACL,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAmBnF,OAAO,EASL,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO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AAC,YAAY;YAWN,OAAO;IA2BrB;kGAC8F;IAC9F,OAAO,CAAC,gBAAgB;IAwFxB,iEAAiE;YACnD,aAAa;IA2D3B,iFAAiF;YACnE,gBAAgB;IA0B9B,wDAAwD;IACxD,OAAO,CAAC,eAAe;IAwDvB,2GAA2G;IAC3G,OAAO,CAAC,YAAY;IAoDpB;;;;;;;;;;;;OAYG;YACW,2BAA2B;IAyBzC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAK/B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,kCAAkC;IAK1C;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;IAItC,wFAAwF;IACxF,OAAO,CAAC,uBAAuB;IAI/B,sGAAsG;IACtG,OAAO,CAAC,4BAA4B;IAIpC,wGAAwG;IACxG,OAAO,CAAC,yBAAyB;IAIjC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,4BAA4B;YAetB,gBAAgB;CAU/B"}
|
|
@@ -20,6 +20,7 @@ import { checkContextWindowPreflight, emitContextOverflowError, handlePostTurnCo
|
|
|
20
20
|
import { createEmitterContext, estimateFreshTurnInputTokens, getCacheHitTracker, getIdempotencyStore, getSessionLineageTracker, normalizeUsage, requireConfigManager, requireProviderRegistry, } from './orchestrator-runtime.js';
|
|
21
21
|
import { maybeEmitAdaptivePlannerDecision, prepareConversationForTurn, } from './orchestrator-turn-helpers.js';
|
|
22
22
|
import { executeOrchestratorTurnLoop } from './orchestrator-turn-loop.js';
|
|
23
|
+
import { recordTurnInjection, } from '../agents/turn-knowledge-injection.js';
|
|
23
24
|
/** Delay (ms) before auto-spawning plan items if the model ends its turn without spawning them. */
|
|
24
25
|
const AUTO_SPAWN_FALLBACK_DELAY_MS = 5_000;
|
|
25
26
|
const THINKING_SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
@@ -111,6 +112,19 @@ export class Orchestrator {
|
|
|
111
112
|
permissionManager;
|
|
112
113
|
getSystemPrompt;
|
|
113
114
|
hookDispatcher;
|
|
115
|
+
/**
|
|
116
|
+
* Wave-5 (wo805) per-turn passive-injection state for the MAIN interactive session —
|
|
117
|
+
* see core/orchestrator-turn-loop.ts for the retrieval/budget wiring that reads and
|
|
118
|
+
* mutates these. `turnKnowledgeIdsAlreadySurfaced` has no spawn-time baseline (unlike
|
|
119
|
+
* an AgentRecord's `knowledgeInjections`) so it starts empty and grows monotonically
|
|
120
|
+
* for the life of this Orchestrator. `turnInjectionRing` backs the public
|
|
121
|
+
* `getTurnInjections()` accessor.
|
|
122
|
+
*/
|
|
123
|
+
turnKnowledgeIdsAlreadySurfaced = new Set();
|
|
124
|
+
turnInjectionRing = [];
|
|
125
|
+
turnKnowledgeSequence = 0;
|
|
126
|
+
passiveKnowledgeInjectionBudgetTokens;
|
|
127
|
+
passiveKnowledgeInjectionRelevanceFloor;
|
|
114
128
|
/**
|
|
115
129
|
* Construct an Orchestrator using a named-options object.
|
|
116
130
|
*
|
|
@@ -132,7 +146,9 @@ export class Orchestrator {
|
|
|
132
146
|
* ```
|
|
133
147
|
*/
|
|
134
148
|
constructor(options) {
|
|
135
|
-
const { conversation, getViewportHeight, scrollToEnd, toolRegistry, permissionManager, getSystemPrompt = () => '', hookDispatcher = null, flagManager = null, requestRender = null, runtimeBus = null, sessionId, services, } = options;
|
|
149
|
+
const { conversation, getViewportHeight, scrollToEnd, toolRegistry, permissionManager, getSystemPrompt = () => '', hookDispatcher = null, flagManager = null, requestRender = null, runtimeBus = null, sessionId, passiveKnowledgeInjectionBudgetTokens, passiveKnowledgeInjectionRelevanceFloor, services, } = options;
|
|
150
|
+
this.passiveKnowledgeInjectionBudgetTokens = passiveKnowledgeInjectionBudgetTokens;
|
|
151
|
+
this.passiveKnowledgeInjectionRelevanceFloor = passiveKnowledgeInjectionRelevanceFloor;
|
|
136
152
|
this.sessionId = sessionId?.trim() || randomUUID();
|
|
137
153
|
this.conversation = conversation;
|
|
138
154
|
this.getViewportHeight = getViewportHeight;
|
|
@@ -250,6 +266,17 @@ export class Orchestrator {
|
|
|
250
266
|
getSpinner() {
|
|
251
267
|
return THINKING_SPINNER_FRAMES[this.thinkingFrame % THINKING_SPINNER_FRAMES.length];
|
|
252
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Wave-5 (wo805): bounded ring of per-turn passive-injection honesty records for the
|
|
271
|
+
* MAIN interactive session — the main-session counterpart to `AgentRecord.turnInjections`
|
|
272
|
+
* (wo801). There is no AgentRecord for the primary conversation, so this is the exact
|
|
273
|
+
* accessor a `/recall`-style renderer should read as the main-session default when no
|
|
274
|
+
* agent id is given. See agents/turn-knowledge-injection.ts for the record shape and
|
|
275
|
+
* recordTurnInjection for the ring-eviction policy (same bounded size as the agent path).
|
|
276
|
+
*/
|
|
277
|
+
getTurnInjections() {
|
|
278
|
+
return this.turnInjectionRing;
|
|
279
|
+
}
|
|
253
280
|
setSystemMessageRouter(router) {
|
|
254
281
|
this.systemMessageRouter = router;
|
|
255
282
|
}
|
|
@@ -505,6 +532,14 @@ export class Orchestrator {
|
|
|
505
532
|
setLastInputTokens: (value) => { this.lastInputTokens = value; },
|
|
506
533
|
markTurnFailed: () => { this._turnFailed = true; },
|
|
507
534
|
usage: this.usage,
|
|
535
|
+
memoryRegistry: this.coreServices.memoryRegistry,
|
|
536
|
+
isPassiveKnowledgeInjectionEnabled: () => this.isPassiveKnowledgeInjectionEnabled(),
|
|
537
|
+
passiveKnowledgeInjectionBudgetTokens: this.passiveKnowledgeInjectionBudgetTokens,
|
|
538
|
+
passiveKnowledgeInjectionRelevanceFloor: this.passiveKnowledgeInjectionRelevanceFloor,
|
|
539
|
+
getAlreadyInjectedKnowledgeIds: () => this.getAlreadyInjectedKnowledgeIds(),
|
|
540
|
+
addInjectedKnowledgeIds: (ids) => { this.addInjectedKnowledgeIds(ids); },
|
|
541
|
+
recordTurnKnowledgeInjection: (record) => { this.recordTurnKnowledgeInjection(record); },
|
|
542
|
+
nextTurnKnowledgeSequence: () => this.nextTurnKnowledgeSequence(),
|
|
508
543
|
});
|
|
509
544
|
}
|
|
510
545
|
/** Phase 3: Post-turn context maintenance (compaction, memory, plan updates). */
|
|
@@ -679,6 +714,44 @@ export class Orchestrator {
|
|
|
679
714
|
return true;
|
|
680
715
|
return this.flagManager.isEnabled('tool-result-reconciliation');
|
|
681
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Returns `true` when Wave-5 (wo801/wo805) per-turn passive knowledge injection is
|
|
719
|
+
* active for this session. Shares the SAME `agent-passive-knowledge-injection` flag as
|
|
720
|
+
* the agent path (agents/orchestrator-runner.ts) rather than a sibling main-session
|
|
721
|
+
* flag — the flag's own description already promises "the EVOLVING main-session
|
|
722
|
+
* conversation" coverage (see runtime/feature-flags/flags.ts), so wiring the main loop
|
|
723
|
+
* under the same id completes that promise instead of duplicating a second toggle for
|
|
724
|
+
* what is, from an operator's perspective, one feature.
|
|
725
|
+
*
|
|
726
|
+
* Defaults to `true` (flag `defaultState: 'enabled'`) when no flag manager has been
|
|
727
|
+
* wired in, matching {@link isReconciliationEnabled}'s convention.
|
|
728
|
+
*/
|
|
729
|
+
isPassiveKnowledgeInjectionEnabled() {
|
|
730
|
+
if (this.flagManager === null)
|
|
731
|
+
return true;
|
|
732
|
+
return this.flagManager.isEnabled('agent-passive-knowledge-injection');
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Wave-5 (wo805): ids never to re-surface in a later per-turn knowledge block. The main
|
|
736
|
+
* session has no spawn-time `AgentRecord.knowledgeInjections` baseline, so this starts
|
|
737
|
+
* empty and grows monotonically for the life of the Orchestrator.
|
|
738
|
+
*/
|
|
739
|
+
getAlreadyInjectedKnowledgeIds() {
|
|
740
|
+
return [...this.turnKnowledgeIdsAlreadySurfaced];
|
|
741
|
+
}
|
|
742
|
+
/** Wave-5 (wo805): mark ids as surfaced so they are never listed twice this session. */
|
|
743
|
+
addInjectedKnowledgeIds(ids) {
|
|
744
|
+
for (const id of ids)
|
|
745
|
+
this.turnKnowledgeIdsAlreadySurfaced.add(id);
|
|
746
|
+
}
|
|
747
|
+
/** Wave-5 (wo805): append one honesty record to the bounded ring behind {@link getTurnInjections}. */
|
|
748
|
+
recordTurnKnowledgeInjection(record) {
|
|
749
|
+
this.turnInjectionRing = recordTurnInjection(this.turnInjectionRing, record);
|
|
750
|
+
}
|
|
751
|
+
/** Wave-5 (wo805): monotonic per-Orchestrator-lifetime sequence number for TurnInjectionRecord.turn. */
|
|
752
|
+
nextTurnKnowledgeSequence() {
|
|
753
|
+
return ++this.turnKnowledgeSequence;
|
|
754
|
+
}
|
|
682
755
|
/**
|
|
683
756
|
* Reconcile unresolved tool calls at turn end.
|
|
684
757
|
*
|