@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,228 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ import { chainNodeId, subtaskNodeId } from './agent.js';
3
+ // 'interrupted' is included: it is only ever produced on an AGENT node
4
+ // (deriveAgentState), never on a chain/subtask's own `state`, but a chain
5
+ // member agent that was individually interrupted (not via chain cascade,
6
+ // which always hard-kills — see registry.ts cancelAgents) must still count
7
+ // as terminal here, or it would be misread as "live" below.
8
+ const TERMINAL_STATES = new Set(['done', 'failed', 'killed', 'interrupted']);
9
+ function chainState(chain, memberNodes) {
10
+ switch (chain.state) {
11
+ case 'passed':
12
+ return { state: 'done' };
13
+ case 'failed':
14
+ return { state: 'failed' };
15
+ case 'pending':
16
+ return { state: 'queued' };
17
+ case 'awaiting_gates':
18
+ return { state: 'idle', phase: chain.state };
19
+ default:
20
+ break;
21
+ }
22
+ // Active phase (engineering/integrating/reviewing/fixing/gating/committing).
23
+ // Retrying is DERIVED: a transport retry has been recorded and no member
24
+ // agent is currently live — i.e. the respawn window. Once the replacement
25
+ // agent runs, the chain shows its active phase again.
26
+ const retryCount = chain.transportRetryCount ?? 0;
27
+ const anyMemberLive = memberNodes.some((node) => !TERMINAL_STATES.has(node.state));
28
+ if (retryCount > 0 && !anyMemberLive) {
29
+ return { state: 'retrying', phase: chain.state };
30
+ }
31
+ // CONTROLLER-DRIVEN PHASES: 'gating' (running gate checks) and 'committing'
32
+ // (git commit/merge) are performed by WrfcController itself, never by a
33
+ // member agent — every phase-worker member has already finished its own
34
+ // work by the time the chain advances to either state. "Zero live members"
35
+ // is therefore the NORMAL condition here, not a symptom of a cascade kill,
36
+ // so these two states are excluded from the CHAIN TERMINAL TRUTH check
37
+ // below (enumerated from the WrfcState union in wrfc-types.ts — do not
38
+ // widen this to other active states, where a live member IS expected and
39
+ // its absence legitimately signals a kill).
40
+ const controllerDrivenWithNoLiveMembersByDesign = chain.state === 'gating' || chain.state === 'committing';
41
+ // CHAIN TERMINAL TRUTH: WrfcController has no cancel/abort of its own, so a
42
+ // cascade kill (registry.ts kill('chain:<id>')) only cancels the member
43
+ // agents — chain.state never leaves whatever active phase it was in when
44
+ // killed. Once every known member has reached a terminal state and it's
45
+ // NOT the transport-retry respawn window handled above, NOR one of the
46
+ // controller-driven phases handled above, the chain was terminated out
47
+ // from under its owner: report it terminal instead of a perpetually-running
48
+ // phase (the replay-found "climbing elapsed" leak). `phase` is preserved
49
+ // for display ("killed while engineering").
50
+ if (memberNodes.length > 0 && !anyMemberLive && !controllerDrivenWithNoLiveMembersByDesign) {
51
+ return { state: 'killed', phase: chain.state };
52
+ }
53
+ return { state: 'executing-tool', phase: chain.state };
54
+ }
55
+ /**
56
+ * Synthetic completedAt for a chain whose terminal state was DERIVED (see
57
+ * chainState above) rather than reported by WrfcController — cascade kill
58
+ * never sets `chain.completedAt`. Freezing to the latest member completedAt
59
+ * (rather than `now`) is what stops elapsedMs from climbing after a kill;
60
+ * every member here is terminal (chainState's caller only reaches this when
61
+ * `state === 'killed'`), and every terminal agent node has a completedAt
62
+ * (set atomically with its terminal status — see agent.ts / manager.ts
63
+ * cancel()), so the max is always defined when memberNodes is non-empty.
64
+ */
65
+ function syntheticChainCompletedAt(memberNodes) {
66
+ let latest;
67
+ for (const node of memberNodes) {
68
+ if (node.completedAt === undefined)
69
+ continue;
70
+ if (latest === undefined || node.completedAt > latest)
71
+ latest = node.completedAt;
72
+ }
73
+ return latest;
74
+ }
75
+ function subtaskState(subtask) {
76
+ switch (subtask.state) {
77
+ case 'pending':
78
+ return { state: 'queued' };
79
+ case 'passed':
80
+ return { state: 'done' };
81
+ case 'failed':
82
+ return { state: 'failed' };
83
+ default:
84
+ return { state: 'executing-tool', phase: subtask.state };
85
+ }
86
+ }
87
+ function sumUsage(nodes) {
88
+ const contributors = nodes.filter((node) => node.usage !== undefined);
89
+ if (contributors.length === 0)
90
+ return undefined;
91
+ const total = {
92
+ inputTokens: 0,
93
+ outputTokens: 0,
94
+ cacheReadTokens: 0,
95
+ cacheWriteTokens: 0,
96
+ reasoningTokens: 0,
97
+ llmCallCount: 0,
98
+ turnCount: 0,
99
+ toolCallCount: 0,
100
+ };
101
+ let sawReasoning = false;
102
+ for (const node of contributors) {
103
+ const usage = node.usage;
104
+ total.inputTokens += usage.inputTokens;
105
+ total.outputTokens += usage.outputTokens;
106
+ total.cacheReadTokens += usage.cacheReadTokens;
107
+ total.cacheWriteTokens += usage.cacheWriteTokens;
108
+ if (usage.reasoningTokens !== undefined) {
109
+ sawReasoning = true;
110
+ total.reasoningTokens += usage.reasoningTokens;
111
+ }
112
+ total.llmCallCount += usage.llmCallCount;
113
+ total.turnCount += usage.turnCount;
114
+ total.toolCallCount += usage.toolCallCount;
115
+ }
116
+ return {
117
+ inputTokens: total.inputTokens,
118
+ outputTokens: total.outputTokens,
119
+ cacheReadTokens: total.cacheReadTokens,
120
+ cacheWriteTokens: total.cacheWriteTokens,
121
+ reasoningTokens: sawReasoning ? total.reasoningTokens : undefined,
122
+ llmCallCount: total.llmCallCount,
123
+ turnCount: total.turnCount,
124
+ toolCallCount: total.toolCallCount,
125
+ };
126
+ }
127
+ /**
128
+ * Aggregate member-agent cost onto the chain, honestly:
129
+ * all contributors priced → 'priced'; none priced → null/'unpriced';
130
+ * mixed → sum of the priced subset, flagged 'estimated'.
131
+ *
132
+ * The owner agent is EXCLUDED from aggregation: it runs no LLM turns itself —
133
+ * its AgentRecord.usage is populated FROM the phase children at completion
134
+ * time (Wave-0/1), so including it would double-count.
135
+ */
136
+ function aggregateCost(members) {
137
+ const withUsage = members.filter((node) => node.usage !== undefined);
138
+ if (withUsage.length === 0)
139
+ return { costUsd: null, costState: 'unpriced' };
140
+ const priced = withUsage.filter((node) => node.costState === 'priced' && typeof node.costUsd === 'number');
141
+ if (priced.length === 0)
142
+ return { costUsd: null, costState: 'unpriced' };
143
+ const total = priced.reduce((sum, node) => sum + node.costUsd, 0);
144
+ return { costUsd: total, costState: priced.length === withUsage.length ? 'priced' : 'estimated' };
145
+ }
146
+ /**
147
+ * The subtask's currently-active member agent, i.e. whichever role is
148
+ * driving its current phase. Undefined when the subtask has no phase
149
+ * currently in flight (pending/passed/failed) — matches subtaskState()'s
150
+ * own phase mapping above.
151
+ */
152
+ export function activeSubtaskMemberAgentId(subtask) {
153
+ switch (subtask.state) {
154
+ case 'engineering':
155
+ return subtask.engineerAgentId;
156
+ case 'reviewing':
157
+ return subtask.reviewerAgentId;
158
+ case 'fixing':
159
+ return subtask.fixerAgentId;
160
+ default:
161
+ return undefined;
162
+ }
163
+ }
164
+ /** WrfcSubtask → ProcessNode (child of its chain node). */
165
+ export function adaptSubtask(subtask, chain, opts) {
166
+ const { state, phase } = subtaskState(subtask);
167
+ const killable = state !== 'done' && state !== 'failed' && state !== 'killed';
168
+ return {
169
+ id: subtaskNodeId(subtask.id),
170
+ kind: 'wrfc-subtask',
171
+ parentId: chainNodeId(chain.id),
172
+ label: subtask.title,
173
+ task: subtask.task,
174
+ state,
175
+ startedAt: undefined,
176
+ completedAt: undefined,
177
+ elapsedMs: 0,
178
+ usage: undefined,
179
+ costUsd: null,
180
+ costState: 'unpriced',
181
+ // Silent source: no phase-transition timestamp exists, so anchor to the
182
+ // chain's creation time to keep the activity stable across queries.
183
+ currentActivity: phase ? { kind: 'phase', text: phase, at: chain.createdAt } : undefined,
184
+ // Steer targets the live member agent driving this subtask's current
185
+ // phase, NOT the subtask node itself (which has no conversation loop).
186
+ capabilities: { interruptible: false, killable, pausable: false, resumable: false, steerable: opts.steerable },
187
+ raw: subtask,
188
+ };
189
+ }
190
+ /**
191
+ * WrfcChain → ProcessNode. `memberNodes` are the already-adapted agent nodes
192
+ * whose ids appear in chain.allAgentIds, EXCLUDING the owner agent (see
193
+ * aggregateCost). Chain nodes are roots (the owner agent hangs under the
194
+ * chain via its wrfcId edge, not the other way around).
195
+ */
196
+ export function adaptChain(chain, memberNodes, now) {
197
+ const { state, phase } = chainState(chain, memberNodes);
198
+ const { costUsd, costState } = aggregateCost(memberNodes);
199
+ const killable = state !== 'done' && state !== 'failed' && state !== 'killed';
200
+ // chain.completedAt is authoritative when WrfcController set it (the
201
+ // 'passed'/'failed' clean-terminal cases). `state === 'killed'` is only
202
+ // ever reached via chainState's DERIVED branch (WrfcController never
203
+ // literally sets chain.state to 'killed'), so falling back to the
204
+ // synthetic max(member.completedAt) there — instead of `now` — is what
205
+ // freezes elapsedMs once the chain is recognized as killed.
206
+ const completedAt = chain.completedAt ?? (state === 'killed' ? syntheticChainCompletedAt(memberNodes) : undefined);
207
+ return {
208
+ id: chainNodeId(chain.id),
209
+ kind: 'wrfc-chain',
210
+ parentId: undefined,
211
+ label: `wrfc ${chain.id}`,
212
+ task: chain.task,
213
+ state,
214
+ startedAt: chain.createdAt,
215
+ completedAt,
216
+ elapsedMs: Math.max(0, (completedAt ?? now) - chain.createdAt),
217
+ usage: sumUsage(memberNodes),
218
+ costUsd,
219
+ costState,
220
+ // Silent source: anchored to createdAt (no phase-transition timestamp).
221
+ currentActivity: phase ? { kind: 'phase', text: phase, at: chain.createdAt } : undefined,
222
+ // A wrfc-chain is an FSM coordinating member agents; it has no
223
+ // conversation loop of its own, so it is NEVER steerable — steer the
224
+ // member subtask instead (adaptSubtask, above).
225
+ capabilities: { interruptible: false, killable, pausable: false, resumable: false, steerable: false },
226
+ raw: chain,
227
+ };
228
+ }
@@ -0,0 +1,10 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ export type { ProcessKind, ProcessState, ProcessUsage, ProcessActivity, ProcessCapabilities, ProcessSessionRef, ProcessCostState, ProcessNode, FleetSnapshot, FleetQueryFilter, ProcessKillOptions, ProcessRegistry, SteerResult, } from './types.js';
3
+ export type { ProcessRegistryDeps, RegistryTimers } from './registry.js';
4
+ export { createProcessRegistry, DEFAULT_STALLED_THRESHOLD_MS, DEFAULT_TICK_INTERVAL_MS, STEER_TTL_MS, } from './registry.js';
5
+ export { chainNodeId, subtaskNodeId, workItemNodeId } from './adapters/agent.js';
6
+ export { scheduleNodeId } from './adapters/schedule.js';
7
+ export { workstreamNodeId, phaseNodeId } from './adapters/orchestration.js';
8
+ export { codeIndexNodeId } from './adapters/code-index.js';
9
+ export type { CodeIndexProcessSource } from './adapters/code-index.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/platform/runtime/fleet/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAKrF,YAAY,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,EACxB,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ export { createProcessRegistry, DEFAULT_STALLED_THRESHOLD_MS, DEFAULT_TICK_INTERVAL_MS, STEER_TTL_MS, } from './registry.js';
3
+ export { chainNodeId, subtaskNodeId, workItemNodeId } from './adapters/agent.js';
4
+ export { scheduleNodeId } from './adapters/schedule.js';
5
+ export { workstreamNodeId, phaseNodeId } from './adapters/orchestration.js';
6
+ export { codeIndexNodeId } from './adapters/code-index.js';
@@ -0,0 +1,113 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ /**
3
+ * Live process registry (W2.1) — one queryable + subscribable aggregation
4
+ * surface over the already-composed runtime managers. ZERO new store state:
5
+ * every query is an aggregate-on-read over the managers' in-memory maps, and
6
+ * the only registry-owned mutable state is the agent activity side-table fed
7
+ * by EXISTING runtime-bus 'agents' events (no new event contract).
8
+ *
9
+ * Pattern precedent: platform/core/orchestrator-context-runtime.ts already
10
+ * aggregates agentManager.list() + wrfcController.listChains() into a
11
+ * read-only context; this module generalizes that into a durable registry.
12
+ */
13
+ import type { AgentManager } from '../../tools/agent/manager.js';
14
+ import type { WrfcController } from '../../agents/wrfc-controller.js';
15
+ import type { ProcessManager } from '../../tools/shared/process-manager.js';
16
+ import type { WatcherRegistry } from '../../watchers/registry.js';
17
+ import type { ScheduleManager, TriggerManager, WorkflowManager } from '../../tools/workflow/index.js';
18
+ import type { AutomationManager } from '../../automation/index.js';
19
+ import type { ApprovalBroker } from '../../control-plane/approval-broker.js';
20
+ import type { SharedSessionBroker } from '../../control-plane/session-broker.js';
21
+ import type { AgentMessageBus } from '../../agents/message-bus.js';
22
+ import type { RuntimeEventBus } from '../events/index.js';
23
+ import type { ProcessRegistry, ProcessUsage } from './types.js';
24
+ import type { CodeIndexProcessSource } from './adapters/code-index.js';
25
+ import type { OrchestrationEngine } from '../../orchestration/engine.js';
26
+ /** Default stalled threshold: running agent with no bus activity for this long → 'stalled'. */
27
+ export declare const DEFAULT_STALLED_THRESHOLD_MS = 20000;
28
+ /** Default coalesced tick interval for subscriber notification. */
29
+ export declare const DEFAULT_TICK_INTERVAL_MS = 750;
30
+ /**
31
+ * TTL for a steer message, deliberately much larger than
32
+ * AgentMessageBus's own DEFAULT_TTL_MS (5 min, message-bus-core.ts). A
33
+ * steer queued against an agent mid long-running tool call (build, test
34
+ * suite) must survive the wait for that tool to return rather than
35
+ * silently expiring before the agent reaches its next turn boundary.
36
+ */
37
+ export declare const STEER_TTL_MS: number;
38
+ /** Injectable timer seam so tests can drive/observe the coalesced tick. */
39
+ export interface RegistryTimers {
40
+ setInterval(callback: () => void, intervalMs: number): unknown;
41
+ clearInterval(handle: unknown): void;
42
+ }
43
+ /**
44
+ * Narrow structural deps — a pick of each manager's read/control surface, NOT
45
+ * the whole RuntimeServices, so the registry stays testable with stubs and
46
+ * cannot participate in a construction cycle.
47
+ */
48
+ export interface ProcessRegistryDeps {
49
+ readonly agentManager: Pick<AgentManager, 'list' | 'cancel'>;
50
+ readonly wrfcController: Pick<WrfcController, 'listChains'>;
51
+ /**
52
+ * Optional (Wave 4, wo701): folds workstream/phase/work-item nodes into
53
+ * the fleet, nested workstream -> phase -> work-item, mirroring the
54
+ * wrfc-chain/subtask nesting. Without this dep the registry degrades to
55
+ * exactly today's behavior — no orchestration nodes, no new capability.
56
+ *
57
+ * `kill` is used (not a raw AgentManager.cancel cascade like the wrfc-chain
58
+ * path) so a fleet-initiated kill goes through the SAME
59
+ * engine.kill(itemId) path as an engine-internal caller: it aborts the
60
+ * item's registered AbortController (reaching an in-flight exec/fetch
61
+ * tool's child process, not just the agent's next turn-boundary poll) AND
62
+ * updates the engine's own WorkItem.state bookkeeping. Bypassing it would
63
+ * silently reopen the orphaned-child-process gap for this one kill path.
64
+ */
65
+ readonly orchestrationEngine?: Pick<OrchestrationEngine, 'listWorkstreams' | 'kill'> | undefined;
66
+ readonly processManager: Pick<ProcessManager, 'list' | 'stop' | 'getStatus'>;
67
+ readonly watcherRegistry: Pick<WatcherRegistry, 'list' | 'stopWatcher'>;
68
+ readonly workflow: {
69
+ readonly workflowManager: Pick<WorkflowManager, 'list' | 'cancel'>;
70
+ /** `enable` (Wave 6, wo-F item d2) backs ProcessRegistry.resume() — the inverse of `disable`'s interrupt/pause. */
71
+ readonly triggerManager: Pick<TriggerManager, 'list' | 'remove' | 'disable' | 'enable'>;
72
+ readonly scheduleManager: Pick<ScheduleManager, 'list' | 'remove' | 'disable' | 'enable'>;
73
+ };
74
+ /** Optional: awaiting-approval derivation. Non-control-plane runtimes still build a fleet. */
75
+ readonly approvalBroker?: Pick<ApprovalBroker, 'listApprovals'> | undefined;
76
+ /** Optional: populates ProcessNode.sessionRef.sessionId (Wave-3 tab attach point). */
77
+ readonly sessionBroker?: Pick<SharedSessionBroker, 'listSessions'> | undefined;
78
+ /**
79
+ * Optional: the repo source-tree code index (Wave-5 wo802, W5.3 Stage A).
80
+ * When present, its build/idle state surfaces as a single 'code-index'
81
+ * ProcessNode. Without this dep the fleet degrades to exactly today's
82
+ * behavior — zero code-index nodes, no new capability.
83
+ */
84
+ readonly codeIndexService?: CodeIndexProcessSource | undefined;
85
+ /**
86
+ * Optional (Wave 6, wo-F item d4): folds `/schedule` automation jobs
87
+ * (platform/automation, a SEPARATE subsystem from the workflow-tool's
88
+ * ScheduleManager above) into the fleet as 'schedule'-kind nodes — see
89
+ * adapters/automation.ts. Without this dep the fleet degrades to exactly
90
+ * today's behavior — zero automation-job nodes, no new capability.
91
+ */
92
+ readonly automationManager?: Pick<AutomationManager, 'listJobs' | 'setEnabled' | 'removeJob'> | undefined;
93
+ /**
94
+ * Optional: backs `steer()` and the `steerable` capability (Wave-3). The
95
+ * bus already exists in the composed runtime and already feeds every
96
+ * in-process agent's per-turn inbox drain (orchestrator-runner.ts) — this
97
+ * just hands the registry a narrow `send`-only pick of it. Without this
98
+ * dep, steer() always refuses and steerable is false everywhere
99
+ * (graceful degrade, matches the approvalBroker/sessionBroker pattern).
100
+ */
101
+ readonly messageBus?: Pick<AgentMessageBus, 'send'> | undefined;
102
+ /** Optional: feeds the fine-grained agent activity side-table. Without it the registry degrades to coarse states. */
103
+ readonly runtimeBus?: RuntimeEventBus | undefined;
104
+ /** Optional: honest cost pricing. Return null when the model is unknown — NEVER fabricate. */
105
+ readonly priceUsage?: ((model: string | undefined, usage: ProcessUsage) => number | null) | undefined;
106
+ readonly now?: (() => number) | undefined;
107
+ readonly stalledThresholdMs?: number | undefined;
108
+ readonly tickIntervalMs?: number | undefined;
109
+ readonly timers?: RegistryTimers | undefined;
110
+ }
111
+ /** Create the live process registry over the already-composed managers. */
112
+ export declare function createProcessRegistry(deps: ProcessRegistryDeps): ProcessRegistry;
113
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/platform/runtime/fleet/registry.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAEV,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,oBAAoB,CAAC;AAEhF,OAAO,KAAK,EAKV,eAAe,EACf,YAAY,EAEb,MAAM,YAAY,CAAC;AAmBpB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGvE,OAAO,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