@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.
Files changed (165) hide show
  1. package/dist/contracts/artifacts/operator-contract.json +1 -1
  2. package/dist/events/communication.d.ts +21 -1
  3. package/dist/events/communication.d.ts.map +1 -1
  4. package/dist/platform/agents/message-bus-core.d.ts +7 -0
  5. package/dist/platform/agents/message-bus-core.d.ts.map +1 -1
  6. package/dist/platform/agents/message-bus-core.js +2 -1
  7. package/dist/platform/agents/orchestrator-runner.d.ts +37 -1
  8. package/dist/platform/agents/orchestrator-runner.d.ts.map +1 -1
  9. package/dist/platform/agents/orchestrator-runner.js +158 -7
  10. package/dist/platform/agents/orchestrator.d.ts +40 -0
  11. package/dist/platform/agents/orchestrator.d.ts.map +1 -1
  12. package/dist/platform/agents/orchestrator.js +29 -0
  13. package/dist/platform/agents/turn-knowledge-injection.d.ts +107 -0
  14. package/dist/platform/agents/turn-knowledge-injection.d.ts.map +1 -0
  15. package/dist/platform/agents/turn-knowledge-injection.js +152 -0
  16. package/dist/platform/agents/wrfc-controller.d.ts +23 -0
  17. package/dist/platform/agents/wrfc-controller.d.ts.map +1 -1
  18. package/dist/platform/agents/wrfc-controller.js +55 -0
  19. package/dist/platform/config/manager.d.ts +9 -0
  20. package/dist/platform/config/manager.d.ts.map +1 -1
  21. package/dist/platform/config/manager.js +15 -0
  22. package/dist/platform/control-plane/approval-broker.d.ts +1 -0
  23. package/dist/platform/control-plane/approval-broker.d.ts.map +1 -1
  24. package/dist/platform/control-plane/approval-broker.js +2 -0
  25. package/dist/platform/core/adaptive-planner.d.ts +50 -0
  26. package/dist/platform/core/adaptive-planner.d.ts.map +1 -1
  27. package/dist/platform/core/adaptive-planner.js +49 -0
  28. package/dist/platform/core/index.d.ts +1 -0
  29. package/dist/platform/core/index.d.ts.map +1 -1
  30. package/dist/platform/core/index.js +1 -0
  31. package/dist/platform/core/orchestrator-runtime.d.ts +11 -0
  32. package/dist/platform/core/orchestrator-runtime.d.ts.map +1 -1
  33. package/dist/platform/core/orchestrator-turn-loop.d.ts +28 -1
  34. package/dist/platform/core/orchestrator-turn-loop.d.ts.map +1 -1
  35. package/dist/platform/core/orchestrator-turn-loop.js +115 -3
  36. package/dist/platform/core/orchestrator.d.ts +61 -0
  37. package/dist/platform/core/orchestrator.d.ts.map +1 -1
  38. package/dist/platform/core/orchestrator.js +74 -1
  39. package/dist/platform/core/plan-proposal.d.ts +165 -0
  40. package/dist/platform/core/plan-proposal.d.ts.map +1 -0
  41. package/dist/platform/core/plan-proposal.js +296 -0
  42. package/dist/platform/knowledge/knowledge-api.d.ts +26 -0
  43. package/dist/platform/knowledge/knowledge-api.d.ts.map +1 -1
  44. package/dist/platform/knowledge/knowledge-api.js +11 -0
  45. package/dist/platform/orchestration/budget.d.ts +22 -0
  46. package/dist/platform/orchestration/budget.d.ts.map +1 -0
  47. package/dist/platform/orchestration/budget.js +35 -0
  48. package/dist/platform/orchestration/cancellation.d.ts +31 -0
  49. package/dist/platform/orchestration/cancellation.d.ts.map +1 -0
  50. package/dist/platform/orchestration/cancellation.js +25 -0
  51. package/dist/platform/orchestration/controller-compat.d.ts +32 -0
  52. package/dist/platform/orchestration/controller-compat.d.ts.map +1 -0
  53. package/dist/platform/orchestration/controller-compat.js +13 -0
  54. package/dist/platform/orchestration/dirty-guard.d.ts +32 -0
  55. package/dist/platform/orchestration/dirty-guard.d.ts.map +1 -0
  56. package/dist/platform/orchestration/dirty-guard.js +147 -0
  57. package/dist/platform/orchestration/engine.d.ts +57 -0
  58. package/dist/platform/orchestration/engine.d.ts.map +1 -0
  59. package/dist/platform/orchestration/engine.js +418 -0
  60. package/dist/platform/orchestration/index.d.ts +18 -0
  61. package/dist/platform/orchestration/index.d.ts.map +1 -0
  62. package/dist/platform/orchestration/index.js +10 -0
  63. package/dist/platform/orchestration/persistence.d.ts +24 -0
  64. package/dist/platform/orchestration/persistence.d.ts.map +1 -0
  65. package/dist/platform/orchestration/persistence.js +176 -0
  66. package/dist/platform/orchestration/phase-runner.d.ts +87 -0
  67. package/dist/platform/orchestration/phase-runner.d.ts.map +1 -0
  68. package/dist/platform/orchestration/phase-runner.js +274 -0
  69. package/dist/platform/orchestration/scheduler.d.ts +45 -0
  70. package/dist/platform/orchestration/scheduler.d.ts.map +1 -0
  71. package/dist/platform/orchestration/scheduler.js +57 -0
  72. package/dist/platform/orchestration/types.d.ts +250 -0
  73. package/dist/platform/orchestration/types.d.ts.map +1 -0
  74. package/dist/platform/orchestration/types.js +15 -0
  75. package/dist/platform/runtime/emitters/communication.d.ts +11 -0
  76. package/dist/platform/runtime/emitters/communication.d.ts.map +1 -1
  77. package/dist/platform/runtime/emitters/communication.js +9 -0
  78. package/dist/platform/runtime/feature-flags/flags.d.ts.map +1 -1
  79. package/dist/platform/runtime/feature-flags/flags.js +17 -0
  80. package/dist/platform/runtime/fleet/adapters/agent.d.ts +56 -0
  81. package/dist/platform/runtime/fleet/adapters/agent.d.ts.map +1 -0
  82. package/dist/platform/runtime/fleet/adapters/agent.js +143 -0
  83. package/dist/platform/runtime/fleet/adapters/automation.d.ts +30 -0
  84. package/dist/platform/runtime/fleet/adapters/automation.d.ts.map +1 -0
  85. package/dist/platform/runtime/fleet/adapters/automation.js +41 -0
  86. package/dist/platform/runtime/fleet/adapters/background-process.d.ts +12 -0
  87. package/dist/platform/runtime/fleet/adapters/background-process.d.ts.map +1 -0
  88. package/dist/platform/runtime/fleet/adapters/background-process.js +46 -0
  89. package/dist/platform/runtime/fleet/adapters/code-index.d.ts +21 -0
  90. package/dist/platform/runtime/fleet/adapters/code-index.d.ts.map +1 -0
  91. package/dist/platform/runtime/fleet/adapters/code-index.js +44 -0
  92. package/dist/platform/runtime/fleet/adapters/orchestration.d.ts +47 -0
  93. package/dist/platform/runtime/fleet/adapters/orchestration.d.ts.map +1 -0
  94. package/dist/platform/runtime/fleet/adapters/orchestration.js +225 -0
  95. package/dist/platform/runtime/fleet/adapters/schedule.d.ts +14 -0
  96. package/dist/platform/runtime/fleet/adapters/schedule.d.ts.map +1 -0
  97. package/dist/platform/runtime/fleet/adapters/schedule.js +28 -0
  98. package/dist/platform/runtime/fleet/adapters/trigger.d.ts +12 -0
  99. package/dist/platform/runtime/fleet/adapters/trigger.d.ts.map +1 -0
  100. package/dist/platform/runtime/fleet/adapters/trigger.js +22 -0
  101. package/dist/platform/runtime/fleet/adapters/watcher.d.ts +13 -0
  102. package/dist/platform/runtime/fleet/adapters/watcher.d.ts.map +1 -0
  103. package/dist/platform/runtime/fleet/adapters/watcher.js +47 -0
  104. package/dist/platform/runtime/fleet/adapters/workflow.d.ts +11 -0
  105. package/dist/platform/runtime/fleet/adapters/workflow.d.ts.map +1 -0
  106. package/dist/platform/runtime/fleet/adapters/workflow.js +34 -0
  107. package/dist/platform/runtime/fleet/adapters/wrfc.d.ts +22 -0
  108. package/dist/platform/runtime/fleet/adapters/wrfc.d.ts.map +1 -0
  109. package/dist/platform/runtime/fleet/adapters/wrfc.js +228 -0
  110. package/dist/platform/runtime/fleet/index.d.ts +10 -0
  111. package/dist/platform/runtime/fleet/index.d.ts.map +1 -0
  112. package/dist/platform/runtime/fleet/index.js +6 -0
  113. package/dist/platform/runtime/fleet/registry.d.ts +113 -0
  114. package/dist/platform/runtime/fleet/registry.d.ts.map +1 -0
  115. package/dist/platform/runtime/fleet/registry.js +630 -0
  116. package/dist/platform/runtime/fleet/types.d.ts +199 -0
  117. package/dist/platform/runtime/fleet/types.d.ts.map +1 -0
  118. package/dist/platform/runtime/fleet/types.js +2 -0
  119. package/dist/platform/runtime/runtime-knowledge-api.d.ts +1 -1
  120. package/dist/platform/runtime/runtime-knowledge-api.d.ts.map +1 -1
  121. package/dist/platform/runtime/runtime-knowledge-api.js +1 -0
  122. package/dist/platform/runtime/services.d.ts +46 -0
  123. package/dist/platform/runtime/services.d.ts.map +1 -1
  124. package/dist/platform/runtime/services.js +78 -0
  125. package/dist/platform/state/code-index-chunking.d.ts +49 -0
  126. package/dist/platform/state/code-index-chunking.d.ts.map +1 -0
  127. package/dist/platform/state/code-index-chunking.js +111 -0
  128. package/dist/platform/state/code-index-db.d.ts +53 -0
  129. package/dist/platform/state/code-index-db.d.ts.map +1 -0
  130. package/dist/platform/state/code-index-db.js +101 -0
  131. package/dist/platform/state/code-index-store.d.ts +175 -0
  132. package/dist/platform/state/code-index-store.d.ts.map +1 -0
  133. package/dist/platform/state/code-index-store.js +612 -0
  134. package/dist/platform/state/index.d.ts +4 -2
  135. package/dist/platform/state/index.d.ts.map +1 -1
  136. package/dist/platform/state/index.js +2 -1
  137. package/dist/platform/state/knowledge-injection.d.ts +23 -0
  138. package/dist/platform/state/knowledge-injection.d.ts.map +1 -1
  139. package/dist/platform/state/knowledge-injection.js +34 -19
  140. package/dist/platform/state/memory-vector-store.d.ts +1 -13
  141. package/dist/platform/state/memory-vector-store.d.ts.map +1 -1
  142. package/dist/platform/state/memory-vector-store.js +6 -38
  143. package/dist/platform/state/sqlite-vec-loader.d.ts +25 -0
  144. package/dist/platform/state/sqlite-vec-loader.d.ts.map +1 -0
  145. package/dist/platform/state/sqlite-vec-loader.js +43 -0
  146. package/dist/platform/tools/agent/manager.d.ts +128 -1
  147. package/dist/platform/tools/agent/manager.d.ts.map +1 -1
  148. package/dist/platform/tools/agent/manager.js +137 -1
  149. package/dist/platform/tools/exec/runtime.d.ts.map +1 -1
  150. package/dist/platform/tools/exec/runtime.js +139 -44
  151. package/dist/platform/tools/exec/schema.d.ts +2 -0
  152. package/dist/platform/tools/exec/schema.d.ts.map +1 -1
  153. package/dist/platform/tools/fetch/runtime.d.ts +7 -0
  154. package/dist/platform/tools/fetch/runtime.d.ts.map +1 -1
  155. package/dist/platform/tools/fetch/runtime.js +8 -6
  156. package/dist/platform/tools/registry.d.ts +9 -3
  157. package/dist/platform/tools/registry.d.ts.map +1 -1
  158. package/dist/platform/tools/registry.js +9 -3
  159. package/dist/platform/types/tools.d.ts +14 -1
  160. package/dist/platform/types/tools.d.ts.map +1 -1
  161. package/dist/platform/version.js +1 -1
  162. package/dist/platform/workspace/checkpoint/side-git.d.ts +20 -8
  163. package/dist/platform/workspace/checkpoint/side-git.d.ts.map +1 -1
  164. package/dist/platform/workspace/checkpoint/side-git.js +21 -11
  165. package/package.json +17 -9
@@ -0,0 +1,107 @@
1
+ import type { ProviderMessage } from '../providers/interface.js';
2
+ import type { MemoryRecord, MemoryRegistry, MemorySemanticSearchResult, MemoryVectorStats } from '../state/index.js';
3
+ /**
4
+ * Default per-turn injection budget: min(800 tokens, 3% of the model's context window).
5
+ * 800 is the static floor for models with an unknown/zero context window (0 short-circuits
6
+ * the percentage term); the percentage term keeps the block a small, bounded slice of the
7
+ * turn's own budget for large-context models rather than a fixed absolute cost.
8
+ */
9
+ export declare const DEFAULT_TURN_KNOWLEDGE_BUDGET_TOKENS = 800;
10
+ /**
11
+ * Default relevance floor: the minimum `scoreKnowledge` score required to survive stage 2
12
+ * filtering (stage 1 is the existing confidence>=55 gate inside selectKnowledgeForTaskScored).
13
+ * Derived directly from the scoreKnowledge weights (knowledge-injection.ts) rather than
14
+ * picked arbitrarily: a record sitting exactly at the confidence floor (55) with the
15
+ * weakest positive reviewState bonus ('fresh', +20) that matches at least one task token
16
+ * (+20) scores 55 + 20 + 20 = 95. Below that, a record is either under-confidence, has no
17
+ * reviewState credit, or matched nothing about the current turn — filler, not relevance.
18
+ */
19
+ export declare const DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR = 95;
20
+ /** Default candidate breadth passed through to selectKnowledgeForTaskScored. */
21
+ export declare const DEFAULT_TURN_KNOWLEDGE_LIMIT = 3;
22
+ /** Bounded ring size for AgentRecord.turnInjections (see recordTurnInjection). */
23
+ export declare const DEFAULT_TURN_INJECTION_RING_SIZE = 20;
24
+ export declare function defaultTurnKnowledgeBudgetTokens(contextWindow: number): number;
25
+ /**
26
+ * Per-turn honesty record for one agent turn's passive-injection attempt. Stored on
27
+ * `AgentRecord.turnInjections` (bounded ring) and appended verbatim to the agent's
28
+ * session transcript (`{type:'knowledge_injection', turn, ...record}`) — no new
29
+ * event-contract member, per the brief's "prefer existing-event reuse" constraint.
30
+ */
31
+ export interface TurnInjectionRecord {
32
+ /** The agent turn number this retrieval ran on. */
33
+ readonly turn: number;
34
+ /** The derived query actually sent through the ranking pipeline (task + conversation tail). */
35
+ readonly query: string;
36
+ /** Count of scored, confidence-gated, not-already-injected candidates considered this turn. */
37
+ readonly candidatesConsidered: number;
38
+ /** Record ids actually injected into the prompt this turn (empty when block===null). */
39
+ readonly injectedIds: readonly string[];
40
+ /** Record ids that cleared the relevance floor but were dropped to fit the token budget. */
41
+ readonly droppedForBudget: readonly string[];
42
+ /** Estimated token cost of the rendered block (0 when block===null). */
43
+ readonly tokenCost: number;
44
+ /** The token budget this turn was evaluated against. */
45
+ readonly budgetTokens: number;
46
+ /** The relevance floor this turn was evaluated against. */
47
+ readonly relevanceFloor: number;
48
+ /** Ingest mode (keyword/semantic/hybrid) of each injected record, same order as injectedIds. */
49
+ readonly ingestModes: readonly string[];
50
+ /** Honest embeddings signal: 'available' when the registry's vector index is enabled and
51
+ * usable, 'fallback-lexical' when memory-store.ts's searchSemantic() degraded to keyword
52
+ * ranking (no vector index, or the registry does not expose vectorStats at all). */
53
+ readonly embeddingBackend: 'available' | 'fallback-lexical';
54
+ /** Present exactly when block===null: why nothing was injected. */
55
+ readonly reason?: string | undefined;
56
+ }
57
+ /**
58
+ * Structural registry surface, mirroring knowledge-injection.ts's private
59
+ * `KnowledgeRegistrySource` plus one addition: optional `vectorStats`, the sole signal this
60
+ * module uses to tell a real semantic search apart from memory-store.ts's silent lexical
61
+ * fallback (searchSemantic() never throws on a missing/disabled vector index — it just
62
+ * degrades to keyword ranking). Kept structural (not `Pick<MemoryRegistry, ...>`) so tests
63
+ * can supply a minimal fake without constructing a real MemoryStore/SQLite.
64
+ */
65
+ export type TurnKnowledgeRegistrySource = {
66
+ getAll(): readonly MemoryRecord[];
67
+ searchSemantic?(input: Parameters<MemoryRegistry['searchSemantic']>[0]): readonly MemorySemanticSearchResult[];
68
+ vectorStats?(): MemoryVectorStats;
69
+ };
70
+ export interface BuildPerTurnKnowledgeInjectionInput {
71
+ readonly memoryRegistry: TurnKnowledgeRegistrySource;
72
+ /** The agent's (possibly frozen) task text — always included in the derived query. */
73
+ readonly task: string;
74
+ readonly writeScope?: readonly string[] | undefined;
75
+ /** The current conversation, formatted for the LLM — the source of "what changed this turn". */
76
+ readonly conversationTail: readonly ProviderMessage[];
77
+ /** Hard token budget for the rendered block. budgetTokens<=0 is the caller's job to no-op on;
78
+ * this function still honors it correctly (an empty/null block, honest record). */
79
+ readonly budgetTokens: number;
80
+ readonly relevanceFloor: number;
81
+ readonly limit?: number | undefined;
82
+ /** Ids never to re-list (the spawn-time baseline plus every id injected on prior turns). */
83
+ readonly alreadyInjectedIds: readonly string[];
84
+ readonly turn: number;
85
+ }
86
+ export interface BuildPerTurnKnowledgeInjectionResult {
87
+ readonly block: string | null;
88
+ readonly record: TurnInjectionRecord;
89
+ }
90
+ /**
91
+ * The one behavioral difference from spawn-time selection: derive the query from the
92
+ * LATEST user-role message in the conversation tail (a steer, a drained directive, or —
93
+ * on turn 1, before any steer exists — the initial task itself) concatenated with the
94
+ * task, instead of the task alone. On turn 1 the latest user message IS the task (the
95
+ * runner seeds it via `conversation.addUserMessage(record.task)` before the turn loop),
96
+ * so this collapses to the task with no duplication.
97
+ */
98
+ export declare function deriveTurnKnowledgeQuery(task: string, conversationTail: readonly ProviderMessage[]): string;
99
+ export declare function buildPerTurnKnowledgeInjection(input: BuildPerTurnKnowledgeInjectionInput): BuildPerTurnKnowledgeInjectionResult;
100
+ /**
101
+ * Push one entry onto a bounded ring, evicting the oldest entry once
102
+ * `retention` is exceeded. Pure and exported so it is independently
103
+ * unit-testable (and so orchestrator-runner.ts never has to hand-roll ring
104
+ * eviction inline).
105
+ */
106
+ export declare function recordTurnInjection(existing: readonly TurnInjectionRecord[] | undefined, entry: TurnInjectionRecord, retention?: number): TurnInjectionRecord[];
107
+ //# sourceMappingURL=turn-knowledge-injection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-knowledge-injection.d.ts","sourceRoot":"","sources":["../../../src/platform/agents/turn-knowledge-injection.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG9E,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAErH;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,KAAK,CAAC;AAEzD,gFAAgF;AAChF,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,kFAAkF;AAClF,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAK9E;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+FAA+F;IAC/F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+FAA+F;IAC/F,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,4FAA4F;IAC5F,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,gGAAgG;IAChG,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,C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AAE,GAAG,MAAM,CAc3G;AAQD,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,mCAAmC,GACzC,oCAAoC,CA0FtC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,mBAAmB,EAAE,GAAG,SAAS,EACpD,KAAK,EAAE,mBAAmB,EAC1B,SAAS,GAAE,MAAyC,GACnD,mBAAmB,EAAE,CAGvB"}
@@ -0,0 +1,152 @@
1
+ import { estimateTokens } from '../core/context-compaction.js';
2
+ import { buildKnowledgeInjectionPrompt, selectKnowledgeForTaskScored } from '../state/index.js';
3
+ /**
4
+ * Default per-turn injection budget: min(800 tokens, 3% of the model's context window).
5
+ * 800 is the static floor for models with an unknown/zero context window (0 short-circuits
6
+ * the percentage term); the percentage term keeps the block a small, bounded slice of the
7
+ * turn's own budget for large-context models rather than a fixed absolute cost.
8
+ */
9
+ export const DEFAULT_TURN_KNOWLEDGE_BUDGET_TOKENS = 800;
10
+ /**
11
+ * Default relevance floor: the minimum `scoreKnowledge` score required to survive stage 2
12
+ * filtering (stage 1 is the existing confidence>=55 gate inside selectKnowledgeForTaskScored).
13
+ * Derived directly from the scoreKnowledge weights (knowledge-injection.ts) rather than
14
+ * picked arbitrarily: a record sitting exactly at the confidence floor (55) with the
15
+ * weakest positive reviewState bonus ('fresh', +20) that matches at least one task token
16
+ * (+20) scores 55 + 20 + 20 = 95. Below that, a record is either under-confidence, has no
17
+ * reviewState credit, or matched nothing about the current turn — filler, not relevance.
18
+ */
19
+ export const DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR = 95;
20
+ /** Default candidate breadth passed through to selectKnowledgeForTaskScored. */
21
+ export const DEFAULT_TURN_KNOWLEDGE_LIMIT = 3;
22
+ /** Bounded ring size for AgentRecord.turnInjections (see recordTurnInjection). */
23
+ export const DEFAULT_TURN_INJECTION_RING_SIZE = 20;
24
+ export function defaultTurnKnowledgeBudgetTokens(contextWindow) {
25
+ if (!Number.isFinite(contextWindow) || contextWindow <= 0) {
26
+ return DEFAULT_TURN_KNOWLEDGE_BUDGET_TOKENS;
27
+ }
28
+ return Math.min(DEFAULT_TURN_KNOWLEDGE_BUDGET_TOKENS, Math.floor(contextWindow * 0.03));
29
+ }
30
+ function extractTextContent(content) {
31
+ if (typeof content === 'string')
32
+ return content;
33
+ return content
34
+ .filter((part) => part.type === 'text')
35
+ .map((part) => part.text)
36
+ .join(' ');
37
+ }
38
+ /**
39
+ * The one behavioral difference from spawn-time selection: derive the query from the
40
+ * LATEST user-role message in the conversation tail (a steer, a drained directive, or —
41
+ * on turn 1, before any steer exists — the initial task itself) concatenated with the
42
+ * task, instead of the task alone. On turn 1 the latest user message IS the task (the
43
+ * runner seeds it via `conversation.addUserMessage(record.task)` before the turn loop),
44
+ * so this collapses to the task with no duplication.
45
+ */
46
+ export function deriveTurnKnowledgeQuery(task, conversationTail) {
47
+ let latestUserContent = '';
48
+ for (let i = conversationTail.length - 1; i >= 0; i--) {
49
+ const message = conversationTail[i];
50
+ if (message?.role === 'user') {
51
+ latestUserContent = extractTextContent(message.content).trim();
52
+ break;
53
+ }
54
+ }
55
+ const trimmedTask = task.trim();
56
+ if (!latestUserContent || latestUserContent === trimmedTask) {
57
+ return trimmedTask;
58
+ }
59
+ return `${trimmedTask} ${latestUserContent}`.trim();
60
+ }
61
+ function resolveEmbeddingBackend(registry) {
62
+ const stats = registry.vectorStats?.();
63
+ if (!stats)
64
+ return 'fallback-lexical';
65
+ return stats.enabled && stats.available ? 'available' : 'fallback-lexical';
66
+ }
67
+ export function buildPerTurnKnowledgeInjection(input) {
68
+ const { memoryRegistry, task, writeScope = [], conversationTail, budgetTokens, relevanceFloor, limit = DEFAULT_TURN_KNOWLEDGE_LIMIT, alreadyInjectedIds, turn, } = input;
69
+ const query = deriveTurnKnowledgeQuery(task, conversationTail);
70
+ const alreadyInjectedIdSet = new Set(alreadyInjectedIds);
71
+ const embeddingBackend = resolveEmbeddingBackend(memoryRegistry);
72
+ const scored = selectKnowledgeForTaskScored(memoryRegistry, query, writeScope, limit)
73
+ .filter((entry) => !alreadyInjectedIdSet.has(entry.injection.id));
74
+ const candidatesConsidered = scored.length;
75
+ const clearedFloor = scored.filter((entry) => entry.score >= relevanceFloor).slice(0, limit);
76
+ if (clearedFloor.length === 0) {
77
+ return {
78
+ block: null,
79
+ record: {
80
+ turn,
81
+ query,
82
+ candidatesConsidered,
83
+ injectedIds: [],
84
+ droppedForBudget: [],
85
+ tokenCost: 0,
86
+ budgetTokens,
87
+ relevanceFloor,
88
+ ingestModes: [],
89
+ embeddingBackend,
90
+ reason: 'no records cleared relevance floor',
91
+ },
92
+ };
93
+ }
94
+ // Greedy budget trim: clearedFloor is already sorted best-first (selectKnowledgeForTaskScored's
95
+ // contract), so dropping from the tail always drops the lowest-scored surviving entry.
96
+ const kept = [...clearedFloor];
97
+ const droppedForBudget = [];
98
+ let tokenCost = estimateTokens(buildKnowledgeInjectionPrompt(kept.map((entry) => entry.injection)) ?? '');
99
+ while (kept.length > 0 && tokenCost > budgetTokens) {
100
+ const removed = kept.pop();
101
+ if (!removed)
102
+ break;
103
+ droppedForBudget.push(removed.injection.id);
104
+ tokenCost = kept.length > 0
105
+ ? estimateTokens(buildKnowledgeInjectionPrompt(kept.map((entry) => entry.injection)) ?? '')
106
+ : 0;
107
+ }
108
+ if (kept.length === 0) {
109
+ return {
110
+ block: null,
111
+ record: {
112
+ turn,
113
+ query,
114
+ candidatesConsidered,
115
+ injectedIds: [],
116
+ droppedForBudget,
117
+ tokenCost: 0,
118
+ budgetTokens,
119
+ relevanceFloor,
120
+ ingestModes: [],
121
+ embeddingBackend,
122
+ reason: 'single highest-scoring record exceeds budget',
123
+ },
124
+ };
125
+ }
126
+ const block = buildKnowledgeInjectionPrompt(kept.map((entry) => entry.injection));
127
+ return {
128
+ block,
129
+ record: {
130
+ turn,
131
+ query,
132
+ candidatesConsidered,
133
+ injectedIds: kept.map((entry) => entry.injection.id),
134
+ droppedForBudget,
135
+ tokenCost,
136
+ budgetTokens,
137
+ relevanceFloor,
138
+ ingestModes: kept.map((entry) => entry.injection.ingestMode),
139
+ embeddingBackend,
140
+ },
141
+ };
142
+ }
143
+ /**
144
+ * Push one entry onto a bounded ring, evicting the oldest entry once
145
+ * `retention` is exceeded. Pure and exported so it is independently
146
+ * unit-testable (and so orchestrator-runner.ts never has to hand-roll ring
147
+ * eviction inline).
148
+ */
149
+ export function recordTurnInjection(existing, entry, retention = DEFAULT_TURN_INJECTION_RING_SIZE) {
150
+ const next = existing ? [...existing, entry] : [entry];
151
+ return next.length > retention ? next.slice(next.length - retention) : next;
152
+ }
@@ -96,6 +96,29 @@ export declare class WrfcController {
96
96
  * Returns true if the chain was imported, false if refused.
97
97
  */
98
98
  importChain(chain: WrfcChain, force?: boolean): boolean;
99
+ /**
100
+ * Item d5 (Wave 6, wo-F): resurrection-safe zombie check for a chain about
101
+ * to be imported at rehydrate. A non-terminal chain whose ENTIRE roster
102
+ * (allAgentIds) is absent from THIS process's live AgentManager never
103
+ * survived the restart — no in-process execution is coming back to finish
104
+ * it, so it would otherwise show as "running" forever. If even ONE roster
105
+ * agent id IS live (e.g. re-imported mid-session, not at a real process
106
+ * restart), this returns false and the chain is left exactly as imported —
107
+ * reaping only ever fires when NOTHING could possibly still be driving it.
108
+ */
109
+ private isZombieChain;
110
+ /**
111
+ * Item d5: mark a reimported zombie chain terminal at import time so it
112
+ * presents as failed + prunable instead of stuck non-terminal forever.
113
+ * Deliberately does NOT call failChain()/cancelChain(): those assume a
114
+ * live in-memory execution (cancel running children, complete the owner
115
+ * agent record, re-check gates for siblings) that makes no sense for a
116
+ * chain whose entire roster is already confirmed dead — this is a direct,
117
+ * minimal field mutation plus the same state-changed/chain-failed events
118
+ * every other terminal transition emits, so consumers see one consistent
119
+ * "chain failed" signal regardless of which path produced it.
120
+ */
121
+ private reapZombieChain;
99
122
  dispose(): void;
100
123
  private transition;
101
124
  private applyWrfcAgentMetadata;
@@ -1 +1 @@
1
- {"version":3,"file":"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9B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,0BAA0B;IAMlC,OAAO,CAAC,eAAe;CAKxB"}
@@ -296,7 +296,17 @@ export class WrfcController {
296
296
  });
297
297
  return false;
298
298
  }
299
+ // Insert into the chain map BEFORE reapZombieChain runs. reapZombieChain
300
+ // emits state-changed + chain-failed for a terminal transition, and every
301
+ // other terminal transition in this controller operates on a chain already
302
+ // present in this.chains — so a consumer that resolves the chain via
303
+ // getChain(id) in response to those events finds it, consistent with the
304
+ // rest of the lifecycle. (chain is a reference already held here, so
305
+ // setting first and then mutating it in reapZombieChain is equivalent.)
299
306
  this.chains.set(chain.id, chain);
307
+ if (!isChainTerminal(chain.state) && this.isZombieChain(chain)) {
308
+ this.reapZombieChain(chain);
309
+ }
300
310
  logger.info('WrfcController.importChain: chain imported', {
301
311
  chainId: chain.id,
302
312
  state: chain.state,
@@ -304,6 +314,51 @@ export class WrfcController {
304
314
  });
305
315
  return true;
306
316
  }
317
+ /**
318
+ * Item d5 (Wave 6, wo-F): resurrection-safe zombie check for a chain about
319
+ * to be imported at rehydrate. A non-terminal chain whose ENTIRE roster
320
+ * (allAgentIds) is absent from THIS process's live AgentManager never
321
+ * survived the restart — no in-process execution is coming back to finish
322
+ * it, so it would otherwise show as "running" forever. If even ONE roster
323
+ * agent id IS live (e.g. re-imported mid-session, not at a real process
324
+ * restart), this returns false and the chain is left exactly as imported —
325
+ * reaping only ever fires when NOTHING could possibly still be driving it.
326
+ */
327
+ isZombieChain(chain) {
328
+ if (chain.allAgentIds.length === 0)
329
+ return false;
330
+ return chain.allAgentIds.every((agentId) => this.agentManager.getStatus(agentId) === null);
331
+ }
332
+ /**
333
+ * Item d5: mark a reimported zombie chain terminal at import time so it
334
+ * presents as failed + prunable instead of stuck non-terminal forever.
335
+ * Deliberately does NOT call failChain()/cancelChain(): those assume a
336
+ * live in-memory execution (cancel running children, complete the owner
337
+ * agent record, re-check gates for siblings) that makes no sense for a
338
+ * chain whose entire roster is already confirmed dead — this is a direct,
339
+ * minimal field mutation plus the same state-changed/chain-failed events
340
+ * every other terminal transition emits, so consumers see one consistent
341
+ * "chain failed" signal regardless of which path produced it.
342
+ */
343
+ reapZombieChain(chain) {
344
+ const from = chain.state;
345
+ const reason = 'zombie chain reaped at rehydrate: no member agent survived the restart';
346
+ chain.state = 'failed';
347
+ chain.error = reason;
348
+ chain.failureKind = 'other';
349
+ chain.completedAt = Date.now();
350
+ emitWrfcStateChanged(this.runtimeBus, this.sessionId, chain.id, from, 'failed');
351
+ emitWorkflowChainFailed(this.runtimeBus, createWrfcWorkflowContext(this.sessionId, chain.id), {
352
+ chainId: chain.id,
353
+ reason,
354
+ failureKind: 'other',
355
+ });
356
+ logger.warn('WrfcController.importChain: reaped zombie chain — no member agent survived restart', {
357
+ chainId: chain.id,
358
+ priorState: from,
359
+ agentIds: chain.allAgentIds,
360
+ });
361
+ }
307
362
  dispose() {
308
363
  for (const unsub of this.unsubscribers)
309
364
  unsub();
@@ -103,6 +103,15 @@ export declare class ConfigManager {
103
103
  * The patch is shallow-merged into the existing category value.
104
104
  */
105
105
  mergeCategory<C extends keyof GoodVibesConfig>(category: C, patch: Partial<GoodVibesConfig[C]>): void;
106
+ /**
107
+ * Remove a key from an object-shaped category and auto-save.
108
+ *
109
+ * mergeCategory can only set keys (undefined patch values are skipped, and
110
+ * getCategory returns a clone, so delete-then-merge is a silent no-op) —
111
+ * clearing an override, e.g. a feature-flag entry back to its default,
112
+ * requires this explicit removal.
113
+ */
114
+ removeCategoryKey<C extends keyof GoodVibesConfig>(category: C, key: string): void;
106
115
  /**
107
116
  * Reset a specific key to its default, or reset all config.
108
117
  * Saves to disk after reset.
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/platform/config/manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI1F,OAAO,KAAK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9B,SAAS,IAAI,aAAa,EAAE;IAI5B,0DAA0D;IAC1D,IAAI,IAAI,IAAI;IAKZ,yEAAyE;IACzE,WAAW,IAAI,IAAI;IAQnB,4FAA4F;IAC5F,IAAI,IAAI,IAAI;IAyBZ;;;;;;OAMG;IACH,aAAa,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAWrG;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAOlF;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,IAAI;CAY7B"}
@@ -314,6 +314,21 @@ export class ConfigManager {
314
314
  }
315
315
  this.save();
316
316
  }
317
+ /**
318
+ * Remove a key from an object-shaped category and auto-save.
319
+ *
320
+ * mergeCategory can only set keys (undefined patch values are skipped, and
321
+ * getCategory returns a clone, so delete-then-merge is a silent no-op) —
322
+ * clearing an override, e.g. a feature-flag entry back to its default,
323
+ * requires this explicit removal.
324
+ */
325
+ removeCategoryKey(category, key) {
326
+ const current = this.config[category];
327
+ if (!(key in current))
328
+ return;
329
+ delete current[key];
330
+ this.save();
331
+ }
317
332
  /**
318
333
  * Reset a specific key to its default, or reset all config.
319
334
  * Saves to disk after reset.
@@ -64,6 +64,7 @@ export declare class ApprovalBroker {
64
64
  resolveApproval(approvalId: string, input: {
65
65
  readonly approved: boolean;
66
66
  readonly remember?: boolean | undefined;
67
+ readonly modifiedArgs?: Record<string, unknown> | undefined;
67
68
  readonly actor: string;
68
69
  readonly actorSurface?: string | undefined;
69
70
  readonly note?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"approval-broker.d.ts","sourceRoot":"","sources":["../../../src/platform/control-plane/approval-broker.ts"],"names":[],"mappings":"AACA,OAAO,EAA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BjC,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,SAAQ,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;YA4BpH,cAAc;IAwB5B;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;YAYhB,OAAO;IAOrB,OAAO,CAAC,OAAO;CA8BhB"}
@@ -220,6 +220,7 @@ export class ApprovalBroker {
220
220
  .then((decision) => this.resolveApproval(approval.id, {
221
221
  approved: decision.approved,
222
222
  remember: decision.remember,
223
+ modifiedArgs: decision.modifiedArgs,
223
224
  actor: 'tui-local',
224
225
  actorSurface: 'tui',
225
226
  }))
@@ -267,6 +268,7 @@ export class ApprovalBroker {
267
268
  decision: {
268
269
  approved: input.approved,
269
270
  ...(input.remember !== undefined ? { remember: input.remember } : {}),
271
+ ...(input.modifiedArgs !== undefined ? { modifiedArgs: input.modifiedArgs } : {}),
270
272
  },
271
273
  audit: [
272
274
  ...approval.audit,
@@ -9,6 +9,7 @@
9
9
  * /plan explain
10
10
  * /plan override <strategy>
11
11
  */
12
+ import { type PlanProposal, type PlanProposalIssue, type RawDecomposition } from './plan-proposal.js';
12
13
  /**
13
14
  * The five supported execution strategies.
14
15
  *
@@ -52,6 +53,18 @@ export interface StrategyCandidate {
52
53
  score: number;
53
54
  reasonCode: StrategyReasonCode;
54
55
  }
56
+ /**
57
+ * The outcome of the deterministic "does this task warrant decomposition?"
58
+ * gate. This is a semantic projection of the existing strategy selection —
59
+ * `decompose` is simply `selected !== 'single'` — so every existing reason
60
+ * code and the `/plan explain` output stay authoritative. No new scoring
61
+ * logic lives here.
62
+ */
63
+ export interface DecompositionGate {
64
+ decompose: boolean;
65
+ strategy: ExecutionStrategy;
66
+ reasonCode: StrategyReasonCode;
67
+ }
55
68
  /** The outcome of a planner selection pass. */
56
69
  export interface PlannerDecision {
57
70
  /** The strategy that was ultimately selected. */
@@ -86,6 +99,43 @@ export declare class AdaptivePlanner {
86
99
  * The decision is appended to the history log.
87
100
  */
88
101
  select(inputs: PlannerInputs): PlannerDecision;
102
+ /**
103
+ * Deterministic gate: does this task warrant decomposition into a
104
+ * multi-phase workstream, or is a single-item workstream the honest
105
+ * answer?
106
+ *
107
+ * This calls the existing `select()` pipeline — no new scoring logic — and
108
+ * projects the result: `decompose` is `selected !== 'single'`. Because it
109
+ * goes through `select()`, the decision is appended to the same audit
110
+ * history as every other planner call, and `/plan explain` / `/plan
111
+ * status` remain authoritative for it.
112
+ */
113
+ shouldDecompose(inputs: PlannerInputs): DecompositionGate;
114
+ /**
115
+ * Produce a typed `PlanProposal` for the given inputs.
116
+ *
117
+ * `AdaptivePlanner` never spawns a planning agent and never performs LLM
118
+ * decomposition itself — it only gates (via `shouldDecompose`) and
119
+ * validates/assembles (via `assemblePlanProposal`, in `plan-proposal.ts`).
120
+ * The raw decomposition, if any, is expected to come from a planning
121
+ * agent that the ORCHESTRATION ENGINE spawns and hands back here.
122
+ *
123
+ * - If the gate says decomposition is not warranted, or no raw
124
+ * decomposition is available yet, this returns the honest single-item
125
+ * fallback (`singleItemProposal`) — never a partially-assembled guess.
126
+ * - Otherwise it validates `raw` via `assemblePlanProposal`, which never
127
+ * throws: malformed decompositions degrade to an honest partial result
128
+ * plus a list of `issues`.
129
+ *
130
+ * Returns the `gate` alongside the proposal so callers (the engine, or the
131
+ * TUI) can show WHY a proposal was or wasn't decomposed, reusing
132
+ * `AdaptivePlanner.explainReasonCode`.
133
+ */
134
+ proposeWorkstream(inputs: PlannerInputs, raw?: RawDecomposition): {
135
+ proposal: PlanProposal;
136
+ gate: DecompositionGate;
137
+ issues: PlanProposalIssue[];
138
+ };
89
139
  /**
90
140
  * Set the operating mode for future calls to `select()`.
91
141
  *
@@ -1 +1 @@
1
- {"version":3,"file":"adaptive-planner.d.ts","sourceRoot":"","sources":["../../../src/platform/core/adaptive-planner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH;;;;;;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M;IAShD,4DAA4D;IAC5D,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAI1D,wDAAwD;IACxD,UAAU,CAAC,KAAK,SAAK,GAAG,eAAe,EAAE;IAIzC,gDAAgD;IAChD,SAAS,IAAI,eAAe,GAAG,IAAI;IAQnC;;;OAGG;IACH,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,0BAA0B;CA6BnC"}
@@ -10,6 +10,7 @@
10
10
  * /plan override <strategy>
11
11
  */
12
12
  import { logger } from '../utils/logger.js';
13
+ import { assemblePlanProposal, singleItemProposal, } from './plan-proposal.js';
13
14
  /** All valid strategy names (including 'auto'). Exported for use in command handlers. */
14
15
  export const VALID_STRATEGIES = ['auto', 'single', 'cohort', 'background', 'remote'];
15
16
  // ---------------------------------------------------------------------------
@@ -172,6 +173,54 @@ export class AdaptivePlanner {
172
173
  });
173
174
  return decision;
174
175
  }
176
+ /**
177
+ * Deterministic gate: does this task warrant decomposition into a
178
+ * multi-phase workstream, or is a single-item workstream the honest
179
+ * answer?
180
+ *
181
+ * This calls the existing `select()` pipeline — no new scoring logic — and
182
+ * projects the result: `decompose` is `selected !== 'single'`. Because it
183
+ * goes through `select()`, the decision is appended to the same audit
184
+ * history as every other planner call, and `/plan explain` / `/plan
185
+ * status` remain authoritative for it.
186
+ */
187
+ shouldDecompose(inputs) {
188
+ const decision = this.select(inputs);
189
+ return {
190
+ decompose: decision.selected !== 'single',
191
+ strategy: decision.selected,
192
+ reasonCode: decision.reasonCode,
193
+ };
194
+ }
195
+ /**
196
+ * Produce a typed `PlanProposal` for the given inputs.
197
+ *
198
+ * `AdaptivePlanner` never spawns a planning agent and never performs LLM
199
+ * decomposition itself — it only gates (via `shouldDecompose`) and
200
+ * validates/assembles (via `assemblePlanProposal`, in `plan-proposal.ts`).
201
+ * The raw decomposition, if any, is expected to come from a planning
202
+ * agent that the ORCHESTRATION ENGINE spawns and hands back here.
203
+ *
204
+ * - If the gate says decomposition is not warranted, or no raw
205
+ * decomposition is available yet, this returns the honest single-item
206
+ * fallback (`singleItemProposal`) — never a partially-assembled guess.
207
+ * - Otherwise it validates `raw` via `assemblePlanProposal`, which never
208
+ * throws: malformed decompositions degrade to an honest partial result
209
+ * plus a list of `issues`.
210
+ *
211
+ * Returns the `gate` alongside the proposal so callers (the engine, or the
212
+ * TUI) can show WHY a proposal was or wasn't decomposed, reusing
213
+ * `AdaptivePlanner.explainReasonCode`.
214
+ */
215
+ proposeWorkstream(inputs, raw) {
216
+ const gate = this.shouldDecompose(inputs);
217
+ const task = inputs.taskDescription ?? '';
218
+ if (gate.decompose && raw) {
219
+ const { proposal, issues } = assemblePlanProposal(task, gate.strategy, raw);
220
+ return { proposal, gate, issues };
221
+ }
222
+ return { proposal: singleItemProposal(task), gate, issues: [] };
223
+ }
175
224
  /**
176
225
  * Set the operating mode for future calls to `select()`.
177
226
  *