@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,250 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ /**
3
+ * Orchestration engine — the model (W4.1, wo701).
4
+ *
5
+ * A phase/work-item pipeline layered OVER (not replacing) WrfcController. The
6
+ * hard departure from WrfcController is pipeline semantics: an item advances
7
+ * to its next phase the instant its gate passes, claimed by WHATEVER capacity
8
+ * slot is free — there is no pairwise binding of one reviewer to one
9
+ * engineer's history (see wrfc-controller.ts startReview:883/startFix:1042,
10
+ * which bind chain.reviewerAgentId/chain.fixerAgentId to a single chain).
11
+ *
12
+ * Float ordinals on Phase are load-bearing: inserting a phase mid-run assigns
13
+ * an ordinal strictly between its neighbors, so existing phase ids — and
14
+ * therefore existing PhaseResult resume-cache keys (itemId,phaseId) — never
15
+ * shift or invalidate.
16
+ */
17
+ import type { WrfcAgentRole, QualityGateResult } from '../agents/wrfc-types.js';
18
+ import type { WrfcCommitScope } from '../agents/wrfc-config.js';
19
+ import type { CompletionReport, ConstraintFinding } from '../agents/completion-report.js';
20
+ /** A named agent role, OR an archetype name loaded via ArchetypeLoader. */
21
+ export type PhaseRole = WrfcAgentRole | (string & {});
22
+ export type PhaseKind = 'plan' | 'engineer' | 'review' | 'fix' | 'gate' | 'integrate' | 'custom';
23
+ /** The gate policy a phase enforces before an item may advance past it. */
24
+ export interface PhaseGateSpec {
25
+ readonly scope: WrfcCommitScope;
26
+ readonly gates: readonly string[];
27
+ }
28
+ /**
29
+ * One pipeline stage. `ordinal` is a float specifically so
30
+ * `engine.insertPhase()` can slot a new phase strictly between two existing
31
+ * ordinals without renumbering anything — renumbering would invalidate every
32
+ * PhaseResult cache key already keyed off the old (itemId,phaseId) pairs.
33
+ */
34
+ export interface Phase {
35
+ readonly id: string;
36
+ readonly ordinal: number;
37
+ readonly role: PhaseRole;
38
+ readonly capacity: number;
39
+ readonly gate: PhaseGateSpec;
40
+ readonly kind: PhaseKind;
41
+ /** Epoch ms — set only for phases created via insertPhase() mid-run. */
42
+ readonly insertedAt?: number | undefined;
43
+ }
44
+ /** Caller-supplied shape for engine.insertPhase() / seeding. `id` is generated when omitted. */
45
+ export interface PhaseSpec {
46
+ readonly id?: string | undefined;
47
+ readonly role: PhaseRole;
48
+ readonly capacity: number;
49
+ readonly gate: PhaseGateSpec;
50
+ readonly kind: PhaseKind;
51
+ }
52
+ export type WorkItemState = 'pending' | 'awaiting-capacity'
53
+ /**
54
+ * Live only while a phase's agent is actually running. `importWorkstream`
55
+ * (engine.ts) reconciles any item persisted in this state back to
56
+ * 'pending' and clears `agentId` before the workstream is registered — a
57
+ * snapshot can only ever capture 'in-phase' as a crash artifact (the
58
+ * process died mid-run), never a resumable one, since no agent from a
59
+ * prior process is still alive to finish it. Without that reconciliation
60
+ * an imported 'in-phase' item counts as an OCCUPIED capacity slot forever
61
+ * (computeClaims, scheduler.ts) while never being in the re-claimable
62
+ * waiting set, permanently starving its workstream.
63
+ */
64
+ | 'in-phase' | 'passed' | 'failed'
65
+ /**
66
+ * Recoverable, not terminal. computeClaims (scheduler.ts) includes
67
+ * 'blocked-budget' items in its waiting set, so the item is automatically
68
+ * reconsidered on the next tick(). Because usage only grows, in practice
69
+ * that next tick only unblocks the item once the ceiling itself rises (or
70
+ * is removed) via `engine.updateBudget()` — which calls tick() after
71
+ * updating `workstream.budget` so the reconsideration happens immediately
72
+ * rather than waiting on some unrelated sibling to complete. `blockedReason`
73
+ * carries the human-readable reason for as long as the item stays blocked
74
+ * (cleared the moment it reclaims a slot).
75
+ */
76
+ | 'blocked-budget';
77
+ /** Token/cost usage rolled up across every agent this work-item has ever spawned. */
78
+ export interface WorkItemUsage {
79
+ readonly inputTokens: number;
80
+ readonly outputTokens: number;
81
+ readonly cacheReadTokens: number;
82
+ readonly cacheWriteTokens: number;
83
+ readonly reasoningTokens?: number | undefined;
84
+ readonly llmCallCount: number;
85
+ readonly turnCount: number;
86
+ readonly toolCallCount: number;
87
+ readonly costUsd: number | null;
88
+ readonly costState: 'priced' | 'unpriced' | 'estimated';
89
+ }
90
+ export declare function emptyWorkItemUsage(): WorkItemUsage;
91
+ /**
92
+ * One unit of pipeline work. `visits` bounds re-review cycles the same way
93
+ * WrfcController.retryTransportFailure/evaluateConstraints cap fix attempts —
94
+ * keyed by phaseId so a dynamically-inserted 'fix' phase gets its own counter.
95
+ */
96
+ export interface WorkItem {
97
+ readonly id: string;
98
+ title: string;
99
+ readonly task: string;
100
+ /** The phase this item is currently queued for or running in; null once terminal. */
101
+ currentPhaseId: string | null;
102
+ state: WorkItemState;
103
+ branch?: string | undefined;
104
+ /** The agent currently (or most recently) driving this item's active phase. */
105
+ agentId?: string | undefined;
106
+ /** Every agent ever spawned for this item, across all phases/retries — usage rollup roster. */
107
+ allAgentIds: string[];
108
+ /** phaseId -> number of times this item has been routed through that phase. */
109
+ readonly visits: Map<string, number>;
110
+ /** Deduped touched-path ledger for scoped commits, mirrors WrfcChain.touchedPaths. */
111
+ touchedPaths: string[];
112
+ usage: WorkItemUsage;
113
+ /** Separate from `visits` — a transport blip must never eat into the fix-cycle budget. */
114
+ transportRetryCount: number;
115
+ readonly createdAt: number;
116
+ completedAt?: number | undefined;
117
+ failureReason?: string | undefined;
118
+ /** Set only while state === 'blocked-budget'; cleared the instant the item reclaims a slot. See the 'blocked-budget' state doc for recovery semantics. */
119
+ blockedReason?: string | undefined;
120
+ }
121
+ export interface WorkItemSpec {
122
+ readonly id?: string | undefined;
123
+ readonly title: string;
124
+ readonly task: string;
125
+ }
126
+ export interface BudgetCeiling {
127
+ readonly maxTokens?: number | undefined;
128
+ readonly maxCostUsd?: number | undefined;
129
+ }
130
+ export interface Workstream {
131
+ readonly id: string;
132
+ title: string;
133
+ readonly schemaVersion: number;
134
+ phases: Phase[];
135
+ items: WorkItem[];
136
+ /**
137
+ * Mutable (not readonly) specifically so `engine.updateBudget()` can raise,
138
+ * lower, or clear (`undefined`) the ceiling on a live workstream. Every
139
+ * update calls tick() immediately afterward, so any item already sitting
140
+ * in 'blocked-budget' gets reconsidered right away rather than waiting on
141
+ * an unrelated sibling to complete first.
142
+ */
143
+ budget?: BudgetCeiling | undefined;
144
+ readonly createdAt: number;
145
+ }
146
+ /** Outcome of running a phase's configured gates for one item. */
147
+ export interface GateOutcome {
148
+ readonly passed: boolean;
149
+ readonly results: readonly QualityGateResult[];
150
+ readonly constraintFindings?: readonly ConstraintFinding[] | undefined;
151
+ readonly unsatisfiedConstraintIds?: readonly string[] | undefined;
152
+ }
153
+ /**
154
+ * Recorded on a PhaseResult when a scoped commit (Wave 6, wo-F item 4)
155
+ * excluded one or more candidate paths because they were already dirty
156
+ * before this engine run launched and this phase never actually touched
157
+ * them (see dirty-guard.ts's excludeUntouchedLaunchResidue). `skipped: true`
158
+ * means every candidate was excluded and no commit was attempted at all.
159
+ */
160
+ export interface CommitExclusion {
161
+ readonly excludedPaths: readonly string[];
162
+ readonly skipped: boolean;
163
+ }
164
+ /**
165
+ * The resume-cache unit, keyed (itemId,phaseId). On resume, every
166
+ * (itemId,phaseId) present in a snapshot's completedResults is hydrated
167
+ * without re-spawning — this is what makes prefix-replay possible.
168
+ */
169
+ export interface PhaseResult {
170
+ readonly itemId: string;
171
+ readonly phaseId: string;
172
+ readonly agentId: string;
173
+ readonly report: CompletionReport;
174
+ readonly gate: GateOutcome;
175
+ readonly startedAt: number;
176
+ readonly completedAt: number;
177
+ readonly usage: WorkItemUsage;
178
+ /** Present only when a scoped commit excluded launch-dirty residue (see CommitExclusion). */
179
+ readonly commitExclusion?: CommitExclusion | undefined;
180
+ }
181
+ /** Snapshot shape written to .goodvibes/orchestration/<workstreamId>.json. */
182
+ export interface WorkstreamSnapshot {
183
+ readonly schemaVersion: number;
184
+ readonly writtenAt: number;
185
+ readonly workstream: SerializedWorkstream;
186
+ readonly completedResults: readonly PhaseResult[];
187
+ }
188
+ /** JSON-safe mirror of Workstream (WorkItem.visits as an object, not a Map). */
189
+ export interface SerializedWorkstream extends Omit<Workstream, 'items'> {
190
+ readonly items: readonly SerializedWorkItem[];
191
+ }
192
+ export interface SerializedWorkItem extends Omit<WorkItem, 'visits'> {
193
+ readonly visits: Record<string, number>;
194
+ }
195
+ export declare const CURRENT_WORKSTREAM_SCHEMA_VERSION = 1;
196
+ /** Discriminated events the engine emits over its own lifecycle (persistence, budget, fleet). */
197
+ export type OrchestrationEvent = {
198
+ readonly type: 'phase-inserted';
199
+ readonly workstreamId: string;
200
+ readonly phase: Phase;
201
+ } | {
202
+ readonly type: 'item-advanced';
203
+ readonly workstreamId: string;
204
+ readonly itemId: string;
205
+ readonly fromPhaseId: string | null;
206
+ readonly toPhaseId: string | null;
207
+ } | {
208
+ readonly type: 'item-blocked-budget';
209
+ readonly workstreamId: string;
210
+ readonly itemId: string;
211
+ readonly phaseId: string;
212
+ readonly reason: string;
213
+ } | {
214
+ readonly type: 'item-cancelled';
215
+ readonly workstreamId: string;
216
+ readonly itemId: string;
217
+ readonly reason: string;
218
+ } | {
219
+ readonly type: 'item-passed';
220
+ readonly workstreamId: string;
221
+ readonly itemId: string;
222
+ } | {
223
+ readonly type: 'item-failed';
224
+ readonly workstreamId: string;
225
+ readonly itemId: string;
226
+ readonly reason: string;
227
+ }
228
+ /** Emitted once per item on `importWorkstream` for every item reconciled from a crash-artifact 'in-phase' snapshot back to 'pending' — see the 'in-phase' state doc. */
229
+ | {
230
+ readonly type: 'item-requeued';
231
+ readonly workstreamId: string;
232
+ readonly itemId: string;
233
+ readonly reason: string;
234
+ } | {
235
+ readonly type: 'workstream-persisted';
236
+ readonly workstreamId: string;
237
+ }
238
+ /**
239
+ * Emitted once per engine instance (Wave 6, wo-F item 4), right after the
240
+ * launch-time dirty-tree snapshot resolves, ONLY when it is non-empty.
241
+ * Engine-wide, not workstream-scoped — `workstreamId` is absent (unlike
242
+ * every other variant above) because it fires before any workstream is
243
+ * necessarily even created. See dirty-guard.ts.
244
+ */
245
+ | {
246
+ readonly type: 'dirty-tree-at-launch';
247
+ readonly paths: readonly string[];
248
+ };
249
+ export type OrchestrationEventListener = (event: OrchestrationEvent) => void;
250
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/platform/orchestration/types.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAE1F,2EAA2E;AAC3E,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEjG,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,wEAAwE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M,CAAA;CAAE,GACpH;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACxF;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACnH,wKAAwK;GACtK;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnH;IAAE,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE;AAC1E;;;;;;GAMG;GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC"}
@@ -0,0 +1,15 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ export function emptyWorkItemUsage() {
3
+ return {
4
+ inputTokens: 0,
5
+ outputTokens: 0,
6
+ cacheReadTokens: 0,
7
+ cacheWriteTokens: 0,
8
+ llmCallCount: 0,
9
+ turnCount: 0,
10
+ toolCallCount: 0,
11
+ costUsd: null,
12
+ costState: 'unpriced',
13
+ };
14
+ }
15
+ export const CURRENT_WORKSTREAM_SCHEMA_VERSION = 1;
@@ -17,6 +17,17 @@ export declare function emitCommunicationSent(bus: RuntimeEventBus, ctx: Emitter
17
17
  parentAgentId?: string | undefined;
18
18
  }): void;
19
19
  export declare function emitCommunicationDelivered(bus: RuntimeEventBus, ctx: EmitterContext, data: BaseCommunication): void;
20
+ /**
21
+ * The honest "consumed at boundary" signal — emitted once, at the drain
22
+ * site (orchestrator-runner.ts), the turn a queued message is actually
23
+ * injected into the target agent's conversation. Never repurpose
24
+ * `emitCommunicationDelivered` for this: it fires eagerly at send() time.
25
+ */
26
+ export declare function emitCommunicationConsumed(bus: RuntimeEventBus, ctx: EmitterContext, data: {
27
+ messageId: string;
28
+ agentId: string;
29
+ turn: number;
30
+ }): void;
20
31
  export declare function emitCommunicationBlocked(bus: RuntimeEventBus, ctx: EmitterContext, data: BaseCommunication & {
21
32
  reason: string;
22
33
  fromRole?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"communication.d.ts","sourceRoot":"","sources":["../../../../src/platform/runtime/emitters/communication.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAE9F,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,iBAAiB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,GACA,IAAI,CAEN;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,iBAAiB,GACtB,IAAI,CAEN;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,iBAAiB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,GACA,IAAI,CAEN"}
1
+ {"version":3,"file":"communication.d.ts","sourceRoot":"","sources":["../../../../src/platform/runtime/emitters/communication.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAE9F,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,iBAAiB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,GACA,IAAI,CAEN;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,iBAAiB,GACtB,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzD,IAAI,CAEN;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,iBAAiB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,GACA,IAAI,CAEN"}
@@ -8,6 +8,15 @@ export function emitCommunicationSent(bus, ctx, data) {
8
8
  export function emitCommunicationDelivered(bus, ctx, data) {
9
9
  bus.emit('communication', createEventEnvelope('COMMUNICATION_DELIVERED', { type: 'COMMUNICATION_DELIVERED', ...data }, ctx));
10
10
  }
11
+ /**
12
+ * The honest "consumed at boundary" signal — emitted once, at the drain
13
+ * site (orchestrator-runner.ts), the turn a queued message is actually
14
+ * injected into the target agent's conversation. Never repurpose
15
+ * `emitCommunicationDelivered` for this: it fires eagerly at send() time.
16
+ */
17
+ export function emitCommunicationConsumed(bus, ctx, data) {
18
+ bus.emit('communication', createEventEnvelope('COMMUNICATION_CONSUMED', { type: 'COMMUNICATION_CONSUMED', ...data }, ctx));
19
+ }
11
20
  export function emitCommunicationBlocked(bus, ctx, data) {
12
21
  bus.emit('communication', createEventEnvelope('COMMUNICATION_BLOCKED', { type: 'COMMUNICATION_BLOCKED', ...data }, ctx));
13
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../../src/platform/runtime/feature-flags/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,EAyctC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAE7D,CAAC"}
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../../src/platform/runtime/feature-flags/flags.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,EA4dtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAE7D,CAAC"}
@@ -190,6 +190,23 @@ export const FEATURE_FLAGS = [
190
190
  tier: 9,
191
191
  runtimeToggleable: true,
192
192
  },
193
+ {
194
+ id: 'agent-passive-knowledge-injection',
195
+ name: 'Agent Passive Knowledge Injection',
196
+ description: 'Enables per-turn re-retrieval of project-memory knowledge against the EVOLVING main-'
197
+ + 'session conversation (steers, new sub-topics), not just the frozen spawn-time task. '
198
+ + 'Re-runs retrieval only when a new user/steer message arrived this turn, applies a '
199
+ + 'relevance floor to filter filler, and holds the injected block to a hard token '
200
+ + 'budget (min ~800 tokens or 3% of the model context window) with a visible per-turn '
201
+ + 'record (candidates considered, ids injected, ids dropped for budget, token cost, '
202
+ + 'embeddings backend) stored on AgentRecord.turnInjections and the session transcript. '
203
+ + 'Default-on is safe specifically because the block is hard-budgeted and every turn '
204
+ + 'is honestly recorded, never silently eating context. Disable or set the budget to 0 '
205
+ + 'to revert to spawn-time-only injection (base system prompt byte-identical).',
206
+ defaultState: 'enabled',
207
+ tier: 9,
208
+ runtimeToggleable: true,
209
+ },
193
210
  {
194
211
  id: 'output-schema-fingerprint',
195
212
  name: 'Output Schema Fingerprints',
@@ -0,0 +1,56 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ import type { AgentRecord } from '../../../tools/agent/manager.js';
3
+ import type { ProcessActivity, ProcessNode, ProcessState, ProcessUsage } from '../types.js';
4
+ /** Chain node ids are namespaced to avoid colliding with agent/process ids. */
5
+ export declare function chainNodeId(chainId: string): string;
6
+ /** Subtask node ids are namespaced to avoid colliding with agent/process ids. */
7
+ export declare function subtaskNodeId(subtaskId: string): string;
8
+ /** Work-item node ids are namespaced to avoid colliding with agent/process ids (Wave 4, wo701). */
9
+ export declare function workItemNodeId(workItemId: string): string;
10
+ /**
11
+ * One activity side-table entry. Registry-owned; populated from the EXISTING
12
+ * runtime-bus 'agents' channel emitters (no new event contract).
13
+ */
14
+ export interface AgentActivityEntry {
15
+ readonly state: Extract<ProcessState, 'thinking' | 'executing-tool' | 'streaming' | 'retrying' | 'queued' | 'done' | 'failed'>;
16
+ readonly activity?: ProcessActivity | undefined;
17
+ /** Epoch ms of the last observed bus event for this agent. */
18
+ readonly at: number;
19
+ }
20
+ /** Assembly context the agent adapter needs to derive state and edges. */
21
+ export interface AgentAdapterContext {
22
+ readonly now: number;
23
+ readonly stalledThresholdMs: number;
24
+ /** Side-table entries keyed by agentId. Empty map when no runtimeBus was provided. */
25
+ readonly activity: ReadonlyMap<string, AgentActivityEntry>;
26
+ /** True when a runtimeBus feeds the side-table — gates the stalled derivation. */
27
+ readonly liveness: boolean;
28
+ /** Agent ids that have a pending shared approval (metadata.agentId match). */
29
+ readonly pendingApprovalAgentIds: ReadonlySet<string>;
30
+ /** Session ids that have a pending shared approval (sessionRef cross-match). */
31
+ readonly pendingApprovalSessionIds: ReadonlySet<string>;
32
+ /** agentId → bound sessionId (from the session broker, when available). */
33
+ readonly sessionIdByAgentId: ReadonlyMap<string, string>;
34
+ /** Raw WrfcChain ids present in this snapshot. */
35
+ readonly chainIds: ReadonlySet<string>;
36
+ /** Raw WrfcSubtask ids present in this snapshot. */
37
+ readonly subtaskIds: ReadonlySet<string>;
38
+ /** Raw orchestration-engine WorkItem ids present in this snapshot (Wave 4, wo701). */
39
+ readonly workItemIds: ReadonlySet<string>;
40
+ /** orchestrationNodeId → owning agentId, for parentNodeId edge resolution. */
41
+ readonly agentIdByOrchestrationNodeId: ReadonlyMap<string, string>;
42
+ /** All agent ids present in this snapshot. */
43
+ readonly agentIds: ReadonlySet<string>;
44
+ readonly priceUsage?: ((model: string | undefined, usage: ProcessUsage) => number | null) | undefined;
45
+ /**
46
+ * True when the registry was constructed with a `messageBus` dep — gates
47
+ * `steerable`. Without it, steering has no delivery mechanism, so every
48
+ * agent (even a live one) honestly reports steerable=false.
49
+ */
50
+ readonly messageBusPresent: boolean;
51
+ }
52
+ /** AgentRecord.usage + toolCallCount → ProcessUsage. */
53
+ export declare function usageFromAgentRecord(record: AgentRecord): ProcessUsage | undefined;
54
+ /** AgentRecord → ProcessNode. */
55
+ export declare function adaptAgent(record: AgentRecord, ctx: AgentAdapterContext): ProcessNode;
56
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../../../src/platform/runtime/fleet/adapters/agent.ts"],"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,MAAM,CAAC,CAAC;IACzD,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,sFAAsF;IACtF,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,8EAA8E;IAC9E,QAAQ,CAAC,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnE,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IACtG;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;AAED,wDAAwD;AACxD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAYlF;AA8ED,iCAAiC;AACjC,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,mBAAmB,GAAG,WAAW,CA6CrF"}
@@ -0,0 +1,143 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ /** Chain node ids are namespaced to avoid colliding with agent/process ids. */
3
+ export function chainNodeId(chainId) {
4
+ return `chain:${chainId}`;
5
+ }
6
+ /** Subtask node ids are namespaced to avoid colliding with agent/process ids. */
7
+ export function subtaskNodeId(subtaskId) {
8
+ return `subtask:${subtaskId}`;
9
+ }
10
+ /** Work-item node ids are namespaced to avoid colliding with agent/process ids (Wave 4, wo701). */
11
+ export function workItemNodeId(workItemId) {
12
+ return `work-item:${workItemId}`;
13
+ }
14
+ /** AgentRecord.usage + toolCallCount → ProcessUsage. */
15
+ export function usageFromAgentRecord(record) {
16
+ if (!record.usage)
17
+ return undefined;
18
+ return {
19
+ inputTokens: record.usage.inputTokens,
20
+ outputTokens: record.usage.outputTokens,
21
+ cacheReadTokens: record.usage.cacheReadTokens,
22
+ cacheWriteTokens: record.usage.cacheWriteTokens,
23
+ reasoningTokens: record.usage.reasoningTokens,
24
+ llmCallCount: record.usage.llmCallCount,
25
+ turnCount: record.usage.turnCount,
26
+ toolCallCount: record.toolCallCount,
27
+ };
28
+ }
29
+ /**
30
+ * parentId precedence (brief-mandated, Wave-4 stable):
31
+ * wrfcSubtaskId → `subtask:<id>` else wrfcId → `chain:<id>` else
32
+ * workItemId → `work-item:<id>` (Wave 4, wo701 — orchestration-engine phase
33
+ * agents, a separate track from WRFC so the two systems' agents are never
34
+ * conflated) else orchestrationNodeId/parentNodeId (resolved to the owning
35
+ * agent) else parentAgentId. Every step falls through when the referenced
36
+ * node is not present in this snapshot, so edges always resolve or the node
37
+ * is a root.
38
+ */
39
+ function resolveParentId(record, ctx) {
40
+ if (record.wrfcSubtaskId && ctx.subtaskIds.has(record.wrfcSubtaskId)) {
41
+ return subtaskNodeId(record.wrfcSubtaskId);
42
+ }
43
+ if (record.wrfcId && ctx.chainIds.has(record.wrfcId)) {
44
+ return chainNodeId(record.wrfcId);
45
+ }
46
+ if (record.workItemId && ctx.workItemIds.has(record.workItemId)) {
47
+ return workItemNodeId(record.workItemId);
48
+ }
49
+ if (record.parentNodeId) {
50
+ const owner = ctx.agentIdByOrchestrationNodeId.get(record.parentNodeId);
51
+ if (owner && owner !== record.id && ctx.agentIds.has(owner))
52
+ return owner;
53
+ }
54
+ if (record.parentAgentId && ctx.agentIds.has(record.parentAgentId)) {
55
+ return record.parentAgentId;
56
+ }
57
+ return undefined;
58
+ }
59
+ function deriveAgentState(record, entry, sessionId, ctx) {
60
+ switch (record.status) {
61
+ case 'completed':
62
+ return 'done';
63
+ case 'failed':
64
+ return 'failed';
65
+ case 'cancelled':
66
+ // terminationKind distinguishes a graceful interrupt request from a hard
67
+ // kill for display purposes (Wave-3 verb formalization). Records
68
+ // persisted before this field existed have no terminationKind and
69
+ // default to 'killed' — the historical behavior.
70
+ return record.terminationKind === 'interrupt' ? 'interrupted' : 'killed';
71
+ case 'pending':
72
+ return 'queued';
73
+ case 'running':
74
+ break;
75
+ }
76
+ // running — fine-grained derivation.
77
+ if (ctx.pendingApprovalAgentIds.has(record.id) ||
78
+ (sessionId !== undefined && ctx.pendingApprovalSessionIds.has(sessionId))) {
79
+ return 'awaiting-approval';
80
+ }
81
+ // Stalled: only derivable when a bus feeds the side-table (headless runtimes
82
+ // degrade to the coarse state, never crash). Baseline is the last observed
83
+ // event, or startedAt when the agent predates the registry.
84
+ //
85
+ // executing-tool is exempt: AGENT_AWAITING_TOOL stamps activity.at once at
86
+ // tool start and no further 'agents' event fires until the tool returns, so
87
+ // a long-running tool call (build, test suite, bash) would otherwise be
88
+ // misread as silence and falsely flip a working agent to 'stalled'. Only
89
+ // thinking/streaming (and other non-tool) silence may stall.
90
+ if (ctx.liveness && entry?.state !== 'executing-tool') {
91
+ const lastActivityAt = entry?.at ?? record.startedAt;
92
+ if (ctx.now - lastActivityAt > ctx.stalledThresholdMs)
93
+ return 'stalled';
94
+ }
95
+ if (entry && entry.state !== 'done' && entry.state !== 'failed')
96
+ return entry.state;
97
+ return 'executing-tool';
98
+ }
99
+ /** AgentRecord → ProcessNode. */
100
+ export function adaptAgent(record, ctx) {
101
+ const entry = ctx.activity.get(record.id);
102
+ const sessionId = ctx.sessionIdByAgentId.get(record.id);
103
+ const state = deriveAgentState(record, entry, sessionId, ctx);
104
+ const usage = usageFromAgentRecord(record);
105
+ const active = record.status === 'pending' || record.status === 'running';
106
+ let costUsd = null;
107
+ let costState = 'unpriced';
108
+ if (usage && ctx.priceUsage) {
109
+ let priced = null;
110
+ try {
111
+ priced = ctx.priceUsage(record.model, usage);
112
+ }
113
+ catch {
114
+ priced = null;
115
+ }
116
+ if (priced !== null) {
117
+ costUsd = priced;
118
+ costState = 'priced';
119
+ }
120
+ }
121
+ const label = record.wrfcRole ? `${record.template} (${record.wrfcRole})` : record.template;
122
+ const elapsedMs = Math.max(0, (record.completedAt ?? ctx.now) - record.startedAt);
123
+ return {
124
+ id: record.id,
125
+ kind: 'agent',
126
+ parentId: resolveParentId(record, ctx),
127
+ label,
128
+ task: record.task,
129
+ state,
130
+ startedAt: record.startedAt,
131
+ completedAt: record.completedAt,
132
+ elapsedMs,
133
+ usage,
134
+ model: record.model,
135
+ provider: record.provider,
136
+ costUsd,
137
+ costState,
138
+ currentActivity: entry?.activity,
139
+ capabilities: { interruptible: active, killable: active, pausable: false, resumable: false, steerable: active && ctx.messageBusPresent },
140
+ sessionRef: { sessionId, agentId: record.id },
141
+ raw: record,
142
+ };
143
+ }
@@ -0,0 +1,30 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ import type { AutomationJob } from '../../../automation/jobs.js';
3
+ import type { ProcessNode } from '../types.js';
4
+ /**
5
+ * Automation-job node ids are namespaced separately from workflow-tool
6
+ * ScheduleEntry ids (adapters/schedule.ts's scheduleNodeId) — same kind
7
+ * ('schedule'), completely different id space (AutomationJob.id vs
8
+ * ScheduleEntry.name), so the two can never collide even though a user
9
+ * could name a workflow-tool schedule and an automation job identically.
10
+ */
11
+ export declare function automationJobNodeId(jobId: string): string;
12
+ /** The `raw` shape for an automation-job-sourced 'schedule' node — the source marker registry.ts's control dispatch switches on to route kill/interrupt/resume to AutomationManager instead of ScheduleManager. */
13
+ export interface AutomationJobRaw {
14
+ readonly source: 'automation-manager';
15
+ readonly job: AutomationJob;
16
+ }
17
+ /** Type guard for AutomationJobRaw, used by registry.ts to distinguish an automation-job 'schedule' node's `raw` from a workflow-tool ScheduleEntry's `raw` — both share the 'schedule' kind. */
18
+ export declare function isAutomationJobRaw(raw: unknown): raw is AutomationJobRaw;
19
+ /**
20
+ * AutomationJob → ProcessNode (Wave 6, wo-F item d4). Reuses the 'schedule'
21
+ * kind rather than inventing a new one — a job created via `/schedule` IS a
22
+ * schedule from the user's viewpoint, even though it lives in a completely
23
+ * separate subsystem (platform/automation) from the workflow-tool's
24
+ * ScheduleManager (platform/tools/workflow) that adapters/schedule.ts
25
+ * already covers. `raw.source: 'automation-manager'` (AutomationJobRaw)
26
+ * distinguishes the origin so registry.ts's kill/interrupt/resume dispatch
27
+ * can route to the right manager.
28
+ */
29
+ export declare function adaptAutomationJob(job: AutomationJob): ProcessNode;
30
+ //# sourceMappingURL=automation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation.d.ts","sourceRoot":"","sources":["../../../../../src/platform/runtime/fleet/adapters/automation.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,mNAAmN;AACnN,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;CAC7B;AAED,iMAAiM;AACjM,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,gBAAgB,CAExE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,WAAW,CAelE"}
@@ -0,0 +1,41 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ /**
3
+ * Automation-job node ids are namespaced separately from workflow-tool
4
+ * ScheduleEntry ids (adapters/schedule.ts's scheduleNodeId) — same kind
5
+ * ('schedule'), completely different id space (AutomationJob.id vs
6
+ * ScheduleEntry.name), so the two can never collide even though a user
7
+ * could name a workflow-tool schedule and an automation job identically.
8
+ */
9
+ export function automationJobNodeId(jobId) {
10
+ return `automation-job:${jobId}`;
11
+ }
12
+ /** Type guard for AutomationJobRaw, used by registry.ts to distinguish an automation-job 'schedule' node's `raw` from a workflow-tool ScheduleEntry's `raw` — both share the 'schedule' kind. */
13
+ export function isAutomationJobRaw(raw) {
14
+ return raw !== null && typeof raw === 'object' && raw.source === 'automation-manager';
15
+ }
16
+ /**
17
+ * AutomationJob → ProcessNode (Wave 6, wo-F item d4). Reuses the 'schedule'
18
+ * kind rather than inventing a new one — a job created via `/schedule` IS a
19
+ * schedule from the user's viewpoint, even though it lives in a completely
20
+ * separate subsystem (platform/automation) from the workflow-tool's
21
+ * ScheduleManager (platform/tools/workflow) that adapters/schedule.ts
22
+ * already covers. `raw.source: 'automation-manager'` (AutomationJobRaw)
23
+ * distinguishes the origin so registry.ts's kill/interrupt/resume dispatch
24
+ * can route to the right manager.
25
+ */
26
+ export function adaptAutomationJob(job) {
27
+ return {
28
+ id: automationJobNodeId(job.id),
29
+ kind: 'schedule',
30
+ parentId: undefined,
31
+ label: job.name,
32
+ task: job.execution.prompt,
33
+ state: job.enabled ? 'idle' : 'paused',
34
+ startedAt: job.lastRunAt,
35
+ elapsedMs: 0,
36
+ costUsd: null,
37
+ costState: 'unpriced',
38
+ capabilities: { interruptible: false, killable: true, pausable: job.enabled, resumable: !job.enabled, steerable: false },
39
+ raw: { source: 'automation-manager', job },
40
+ };
41
+ }
@@ -0,0 +1,12 @@
1
+ /** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
2
+ import type { BackgroundProcess } from '../../../tools/shared/process-manager.js';
3
+ import type { ProcessNode } from '../types.js';
4
+ /** Last non-empty stdout line — already tracked on the record, no new emission needed. */
5
+ export declare function lastOutputLine(stdout: readonly string[]): string | undefined;
6
+ /**
7
+ * BackgroundProcess → ProcessNode. Silent source (no bus emission): liveness
8
+ * rides the registry tick; currentActivity is the last stdout line the
9
+ * ProcessManager already buffers.
10
+ */
11
+ export declare function adaptBackgroundProcess(record: BackgroundProcess, now: number): ProcessNode;
12
+ //# sourceMappingURL=background-process.d.ts.map