@pellux/goodvibes-sdk 0.34.0 → 0.34.2

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 (195) hide show
  1. package/dist/contracts/artifacts/operator-contract.json +1 -1
  2. package/dist/events/workflows.d.ts +4 -0
  3. package/dist/events/workflows.d.ts.map +1 -1
  4. package/dist/platform/agents/message-bus-core.d.ts +11 -0
  5. package/dist/platform/agents/message-bus-core.d.ts.map +1 -1
  6. package/dist/platform/agents/message-bus-core.js +28 -21
  7. package/dist/platform/agents/orchestrator-runner.d.ts.map +1 -1
  8. package/dist/platform/agents/orchestrator-runner.js +6 -4
  9. package/dist/platform/agents/wrfc-config.d.ts.map +1 -1
  10. package/dist/platform/agents/wrfc-config.js +16 -10
  11. package/dist/platform/agents/wrfc-controller.d.ts +26 -0
  12. package/dist/platform/agents/wrfc-controller.d.ts.map +1 -1
  13. package/dist/platform/agents/wrfc-controller.js +134 -138
  14. package/dist/platform/agents/wrfc-runtime-events.d.ts +1 -0
  15. package/dist/platform/agents/wrfc-runtime-events.d.ts.map +1 -1
  16. package/dist/platform/agents/wrfc-runtime-events.js +4 -1
  17. package/dist/platform/automation/delivery-manager.d.ts.map +1 -1
  18. package/dist/platform/automation/delivery-manager.js +1 -6
  19. package/dist/platform/batch/manager.d.ts.map +1 -1
  20. package/dist/platform/batch/manager.js +1 -3
  21. package/dist/platform/channels/policy-manager.d.ts.map +1 -1
  22. package/dist/platform/channels/policy-manager.js +1 -3
  23. package/dist/platform/channels/reply-pipeline.d.ts.map +1 -1
  24. package/dist/platform/channels/reply-pipeline.js +4 -0
  25. package/dist/platform/config/schema-domain-core.d.ts +1 -1
  26. package/dist/platform/config/schema-domain-core.d.ts.map +1 -1
  27. package/dist/platform/config/schema-domain-core.js +12 -12
  28. package/dist/platform/config/schema-domain-runtime.d.ts +1 -1
  29. package/dist/platform/config/schema-domain-runtime.d.ts.map +1 -1
  30. package/dist/platform/config/schema-domain-runtime.js +19 -18
  31. package/dist/platform/config/schema-domain-surfaces.d.ts +1 -1
  32. package/dist/platform/config/schema-domain-surfaces.d.ts.map +1 -1
  33. package/dist/platform/config/schema-domain-surfaces.js +4 -3
  34. package/dist/platform/config/schema-shared.d.ts +6 -0
  35. package/dist/platform/config/schema-shared.d.ts.map +1 -1
  36. package/dist/platform/config/schema-shared.js +21 -1
  37. package/dist/platform/control-plane/approval-broker.d.ts.map +1 -1
  38. package/dist/platform/control-plane/approval-broker.js +1 -3
  39. package/dist/platform/control-plane/session-broker-state.d.ts.map +1 -1
  40. package/dist/platform/control-plane/session-broker-state.js +1 -3
  41. package/dist/platform/core/compaction-sections.d.ts +3 -1
  42. package/dist/platform/core/compaction-sections.d.ts.map +1 -1
  43. package/dist/platform/core/compaction-sections.js +70 -66
  44. package/dist/platform/core/context-compaction.d.ts.map +1 -1
  45. package/dist/platform/core/context-compaction.js +10 -16
  46. package/dist/platform/core/orchestrator-context-runtime.d.ts +2 -2
  47. package/dist/platform/core/orchestrator-context-runtime.d.ts.map +1 -1
  48. package/dist/platform/core/orchestrator-context-runtime.js +24 -21
  49. package/dist/platform/core/orchestrator-tool-runtime.d.ts.map +1 -1
  50. package/dist/platform/core/orchestrator-tool-runtime.js +2 -1
  51. package/dist/platform/core/session-lineage.d.ts +2 -5
  52. package/dist/platform/core/session-lineage.d.ts.map +1 -1
  53. package/dist/platform/core/session-lineage.js +4 -16
  54. package/dist/platform/core/wrfc-routing.d.ts.map +1 -1
  55. package/dist/platform/core/wrfc-routing.js +1 -3
  56. package/dist/platform/daemon/http/mcp-routes.d.ts.map +1 -1
  57. package/dist/platform/daemon/http/mcp-routes.js +1 -3
  58. package/dist/platform/daemon/http/openai-compatible-routes.d.ts.map +1 -1
  59. package/dist/platform/daemon/http/openai-compatible-routes.js +1 -3
  60. package/dist/platform/daemon/http/runtime-routes.d.ts.map +1 -1
  61. package/dist/platform/daemon/http/runtime-routes.js +1 -3
  62. package/dist/platform/hooks/runners/http.d.ts.map +1 -1
  63. package/dist/platform/hooks/runners/http.js +9 -19
  64. package/dist/platform/integrations/webhooks.js +2 -11
  65. package/dist/platform/knowledge/semantic/self-improvement.d.ts.map +1 -1
  66. package/dist/platform/knowledge/semantic/self-improvement.js +2 -21
  67. package/dist/platform/mcp/client.d.ts.map +1 -1
  68. package/dist/platform/mcp/client.js +1 -3
  69. package/dist/platform/mcp/config.d.ts.map +1 -1
  70. package/dist/platform/mcp/config.js +1 -3
  71. package/dist/platform/media/builtin-generation-providers.d.ts.map +1 -1
  72. package/dist/platform/media/builtin-generation-providers.js +1 -6
  73. package/dist/platform/providers/anthropic-compat.d.ts.map +1 -1
  74. package/dist/platform/providers/anthropic-compat.js +11 -131
  75. package/dist/platform/providers/anthropic-sdk-provider.d.ts.map +1 -1
  76. package/dist/platform/providers/anthropic-sdk-provider.js +8 -42
  77. package/dist/platform/providers/anthropic-sse-assembler.d.ts +80 -0
  78. package/dist/platform/providers/anthropic-sse-assembler.d.ts.map +1 -0
  79. package/dist/platform/providers/anthropic-sse-assembler.js +146 -0
  80. package/dist/platform/providers/anthropic-stream.d.ts +30 -0
  81. package/dist/platform/providers/anthropic-stream.d.ts.map +1 -0
  82. package/dist/platform/providers/anthropic-stream.js +44 -0
  83. package/dist/platform/providers/anthropic-vertex.d.ts.map +1 -1
  84. package/dist/platform/providers/anthropic-vertex.js +1 -3
  85. package/dist/platform/providers/anthropic.d.ts.map +1 -1
  86. package/dist/platform/providers/anthropic.js +15 -151
  87. package/dist/platform/providers/capabilities.d.ts.map +1 -1
  88. package/dist/platform/providers/capabilities.js +11 -7
  89. package/dist/platform/providers/context-discovery.d.ts.map +1 -1
  90. package/dist/platform/providers/context-discovery.js +9 -16
  91. package/dist/platform/providers/context-window-fallback.d.ts +24 -0
  92. package/dist/platform/providers/context-window-fallback.d.ts.map +1 -0
  93. package/dist/platform/providers/context-window-fallback.js +48 -0
  94. package/dist/platform/providers/gemini.d.ts.map +1 -1
  95. package/dist/platform/providers/gemini.js +3 -6
  96. package/dist/platform/providers/json-ttl-cache.d.ts +35 -0
  97. package/dist/platform/providers/json-ttl-cache.d.ts.map +1 -0
  98. package/dist/platform/providers/json-ttl-cache.js +52 -0
  99. package/dist/platform/providers/llama-cpp.d.ts.map +1 -1
  100. package/dist/platform/providers/llama-cpp.js +2 -23
  101. package/dist/platform/providers/lm-studio-helpers.d.ts +1 -1
  102. package/dist/platform/providers/lm-studio-helpers.d.ts.map +1 -1
  103. package/dist/platform/providers/lm-studio-helpers.js +5 -25
  104. package/dist/platform/providers/model-benchmarks.d.ts.map +1 -1
  105. package/dist/platform/providers/model-benchmarks.js +11 -34
  106. package/dist/platform/providers/model-catalog-cache.d.ts.map +1 -1
  107. package/dist/platform/providers/model-catalog-cache.js +15 -38
  108. package/dist/platform/providers/model-catalog-synthetic.d.ts.map +1 -1
  109. package/dist/platform/providers/model-catalog-synthetic.js +3 -2
  110. package/dist/platform/providers/model-catalog.d.ts.map +1 -1
  111. package/dist/platform/providers/model-catalog.js +3 -2
  112. package/dist/platform/providers/model-limits.d.ts.map +1 -1
  113. package/dist/platform/providers/model-limits.js +18 -42
  114. package/dist/platform/providers/ollama.d.ts.map +1 -1
  115. package/dist/platform/providers/ollama.js +3 -24
  116. package/dist/platform/providers/openai-codex.d.ts.map +1 -1
  117. package/dist/platform/providers/openai-codex.js +8 -9
  118. package/dist/platform/providers/openai-compat.d.ts.map +1 -1
  119. package/dist/platform/providers/openai-compat.js +13 -40
  120. package/dist/platform/providers/openai-stream-helpers.d.ts +62 -0
  121. package/dist/platform/providers/openai-stream-helpers.d.ts.map +1 -0
  122. package/dist/platform/providers/openai-stream-helpers.js +73 -0
  123. package/dist/platform/providers/openai.d.ts.map +1 -1
  124. package/dist/platform/providers/openai.js +13 -41
  125. package/dist/platform/providers/provider-error.d.ts +17 -0
  126. package/dist/platform/providers/provider-error.d.ts.map +1 -0
  127. package/dist/platform/providers/provider-error.js +33 -0
  128. package/dist/platform/providers/provider-stop-reason.d.ts +15 -0
  129. package/dist/platform/providers/provider-stop-reason.d.ts.map +1 -0
  130. package/dist/platform/providers/provider-stop-reason.js +15 -0
  131. package/dist/platform/providers/sse-line-buffer.d.ts +13 -0
  132. package/dist/platform/providers/sse-line-buffer.d.ts.map +1 -0
  133. package/dist/platform/providers/sse-line-buffer.js +23 -0
  134. package/dist/platform/providers/tool-formats.d.ts +5 -0
  135. package/dist/platform/providers/tool-formats.d.ts.map +1 -1
  136. package/dist/platform/providers/tool-formats.js +14 -0
  137. package/dist/platform/runtime/bootstrap-runtime-events.d.ts.map +1 -1
  138. package/dist/platform/runtime/bootstrap-runtime-events.js +6 -0
  139. package/dist/platform/runtime/bootstrap-services.d.ts.map +1 -1
  140. package/dist/platform/runtime/bootstrap-services.js +4 -5
  141. package/dist/platform/runtime/emitters/workflows.d.ts +4 -0
  142. package/dist/platform/runtime/emitters/workflows.d.ts.map +1 -1
  143. package/dist/platform/runtime/emitters/workflows.js +3 -0
  144. package/dist/platform/runtime/remote/distributed-runtime-store.d.ts.map +1 -1
  145. package/dist/platform/runtime/remote/distributed-runtime-store.js +1 -3
  146. package/dist/platform/runtime/retention/pruner.js +2 -5
  147. package/dist/platform/runtime/store/helpers/reducers/lifecycle.d.ts.map +1 -1
  148. package/dist/platform/runtime/store/helpers/reducers/lifecycle.js +15 -14
  149. package/dist/platform/runtime/store/helpers/reducers/shared.d.ts +6 -0
  150. package/dist/platform/runtime/store/helpers/reducers/shared.d.ts.map +1 -1
  151. package/dist/platform/runtime/store/helpers/reducers/shared.js +8 -1
  152. package/dist/platform/runtime/telemetry/exporters/queue.d.ts.map +1 -1
  153. package/dist/platform/runtime/telemetry/exporters/queue.js +1 -7
  154. package/dist/platform/runtime/transports/http-helpers.d.ts +0 -1
  155. package/dist/platform/runtime/transports/http-helpers.d.ts.map +1 -1
  156. package/dist/platform/runtime/transports/http-helpers.js +1 -3
  157. package/dist/platform/runtime/ui-read-model-helpers.d.ts +2 -0
  158. package/dist/platform/runtime/ui-read-model-helpers.d.ts.map +1 -1
  159. package/dist/platform/runtime/ui-read-model-helpers.js +8 -0
  160. package/dist/platform/runtime/ui-read-models-core.d.ts.map +1 -1
  161. package/dist/platform/runtime/ui-read-models-core.js +3 -5
  162. package/dist/platform/runtime/ui-read-models-observability-remote.d.ts.map +1 -1
  163. package/dist/platform/runtime/ui-read-models-observability-remote.js +2 -4
  164. package/dist/platform/runtime/ui-read-models-operations.d.ts.map +1 -1
  165. package/dist/platform/runtime/ui-read-models-operations.js +8 -26
  166. package/dist/platform/scheduler/scheduler.d.ts.map +1 -1
  167. package/dist/platform/scheduler/scheduler.js +1 -3
  168. package/dist/platform/tools/agent/index.d.ts +1 -0
  169. package/dist/platform/tools/agent/index.d.ts.map +1 -1
  170. package/dist/platform/tools/agent/index.js +1 -0
  171. package/dist/platform/tools/agent/predicates.d.ts +15 -0
  172. package/dist/platform/tools/agent/predicates.d.ts.map +1 -0
  173. package/dist/platform/tools/agent/predicates.js +15 -0
  174. package/dist/platform/tools/exec/runtime.d.ts.map +1 -1
  175. package/dist/platform/tools/exec/runtime.js +1 -7
  176. package/dist/platform/tools/fetch/runtime.d.ts.map +1 -1
  177. package/dist/platform/tools/fetch/runtime.js +9 -20
  178. package/dist/platform/tools/shared/process-manager.d.ts.map +1 -1
  179. package/dist/platform/tools/shared/process-manager.js +1 -6
  180. package/dist/platform/utils/concurrency.d.ts +1 -0
  181. package/dist/platform/utils/concurrency.d.ts.map +1 -1
  182. package/dist/platform/utils/concurrency.js +1 -0
  183. package/dist/platform/utils/error-display.d.ts +9 -0
  184. package/dist/platform/utils/error-display.d.ts.map +1 -1
  185. package/dist/platform/utils/error-display.js +11 -0
  186. package/dist/platform/utils/fetch-with-timeout.d.ts +22 -2
  187. package/dist/platform/utils/fetch-with-timeout.d.ts.map +1 -1
  188. package/dist/platform/utils/fetch-with-timeout.js +33 -15
  189. package/dist/platform/utils/record-coerce.d.ts +5 -0
  190. package/dist/platform/utils/record-coerce.d.ts.map +1 -1
  191. package/dist/platform/utils/record-coerce.js +7 -0
  192. package/dist/platform/utils/retry.d.ts.map +1 -1
  193. package/dist/platform/utils/retry.js +2 -4
  194. package/dist/platform/version.js +1 -1
  195. package/package.json +9 -9
@@ -9,9 +9,10 @@
9
9
  *
10
10
  * Empty sections return null — the orchestrator omits them entirely (no header).
11
11
  */
12
+ import { isActiveAgent } from '../tools/agent/predicates.js';
12
13
  import { estimateTokens } from './compaction-types.js';
13
14
  /** Extract plain text from a ProviderMessage content field. */
14
- function extractText(content) {
15
+ export function extractText(content) {
15
16
  if (typeof content === 'string')
16
17
  return content;
17
18
  return content
@@ -83,7 +84,7 @@ export function buildCurrentTask(planTitle, lastUserMessage) {
83
84
  * Returns null if no agents are running.
84
85
  */
85
86
  export function buildRunningAgents(agents, chains) {
86
- const active = agents.filter((a) => a.status === 'running' || a.status === 'pending');
87
+ const active = agents.filter(isActiveAgent);
87
88
  if (active.length === 0)
88
89
  return null;
89
90
  // Build a map from agent ID to chain ID for quick lookup
@@ -129,35 +130,52 @@ export function gatherRecentConversation(messages, maxTokens = 3000) {
129
130
  // ---------------------------------------------------------------------------
130
131
  // LLM substance filter prompt
131
132
  // ---------------------------------------------------------------------------
132
- /**
133
- * buildToolResultsPrompt — build the prompt for LLM-assisted tool relevance extraction.
134
- *
135
- * The caller sends this to the LLM and uses the response as the section content.
136
- */
137
- export function buildToolResultsPrompt(toolMessages) {
138
- if (toolMessages.length === 0)
133
+ // ---------------------------------------------------------------------------
134
+ // Shared delimited-message prompt scaffold
135
+ // ---------------------------------------------------------------------------
136
+ function buildDelimitedMessagePrompt(opts) {
137
+ if (opts.messages.length === 0)
139
138
  return '';
140
139
  const parts = [
141
- 'From these tool call results, select the ones that are still relevant for ongoing work.',
142
- 'Include: file paths touched with what was done (created/edited/deleted), any error outputs',
143
- 'that have not been resolved, any build/test results.',
144
- 'Max 1,500 tokens. Use relative paths and short descriptions.',
140
+ ...opts.intro,
145
141
  '',
146
- '--- TOOL RESULTS ---',
142
+ `--- ${opts.delimiter} ---`,
147
143
  '',
148
144
  ];
149
- for (const msg of toolMessages) {
150
- const text = extractText(msg.content);
151
- if (text.trim()) {
152
- parts.push(`[tool]: ${text.trim().slice(0, 2000)}`);
145
+ for (const msg of opts.messages) {
146
+ const line = opts.render(msg);
147
+ if (line != null) {
148
+ parts.push(line);
153
149
  parts.push('');
154
150
  }
155
151
  }
156
- parts.push('--- END TOOL RESULTS ---');
152
+ parts.push(`--- END ${opts.delimiter} ---`);
157
153
  parts.push('');
158
- parts.push('Provide a concise summary of relevant tool results now:');
154
+ parts.push(opts.outro);
159
155
  return parts.join('\n');
160
156
  }
157
+ /**
158
+ * buildToolResultsPrompt — build the prompt for LLM-assisted tool relevance extraction.
159
+ *
160
+ * The caller sends this to the LLM and uses the response as the section content.
161
+ */
162
+ export function buildToolResultsPrompt(toolMessages) {
163
+ return buildDelimitedMessagePrompt({
164
+ intro: [
165
+ 'From these tool call results, select the ones that are still relevant for ongoing work.',
166
+ 'Include: file paths touched with what was done (created/edited/deleted), any error outputs',
167
+ 'that have not been resolved, any build/test results.',
168
+ 'Max 1,500 tokens. Use relative paths and short descriptions.',
169
+ ],
170
+ delimiter: 'TOOL RESULTS',
171
+ messages: toolMessages,
172
+ render: (msg) => {
173
+ const text = extractText(msg.content);
174
+ return text.trim() ? `[tool]: ${text.trim().slice(0, 2000)}` : null;
175
+ },
176
+ outro: 'Provide a concise summary of relevant tool results now:',
177
+ });
178
+ }
161
179
  // ---------------------------------------------------------------------------
162
180
  // Recent conversation substance filter prompt
163
181
  // ---------------------------------------------------------------------------
@@ -169,30 +187,23 @@ export function buildToolResultsPrompt(toolMessages) {
169
187
  * Multi-turn coherence rule: keep user-assistant PAIRS.
170
188
  */
171
189
  export function buildConversationFilterPrompt(gatheredMessages) {
172
- if (gatheredMessages.length === 0)
173
- return '';
174
- const parts = [
175
- 'From these recent messages, remove anything that does not advance the work:',
176
- 'short acknowledgments, agent count updates, repetitive system nudges, status confirmations.',
177
- 'Keep: instructions, planning, decisions, task assignments, requirement changes.',
178
- 'ALL user messages are high-priority bias toward keeping them even if short.',
179
- 'Keep user-assistant pairs together: if you keep an assistant message, keep the user message that prompted it.',
180
- 'Return only the messages worth preserving, in original order.',
181
- '',
182
- '--- RECENT MESSAGES ---',
183
- '',
184
- ];
185
- for (const msg of gatheredMessages) {
186
- const text = extractText(msg.content);
187
- if (text.trim()) {
188
- parts.push(`[${msg.role}]: ${text.trim()}`);
189
- parts.push('');
190
- }
191
- }
192
- parts.push('--- END RECENT MESSAGES ---');
193
- parts.push('');
194
- parts.push('Return the filtered messages in the same [role]: content format:');
195
- return parts.join('\n');
190
+ return buildDelimitedMessagePrompt({
191
+ intro: [
192
+ 'From these recent messages, remove anything that does not advance the work:',
193
+ 'short acknowledgments, agent count updates, repetitive system nudges, status confirmations.',
194
+ 'Keep: instructions, planning, decisions, task assignments, requirement changes.',
195
+ 'ALL user messages are high-priority bias toward keeping them even if short.',
196
+ 'Keep user-assistant pairs together: if you keep an assistant message, keep the user message that prompted it.',
197
+ 'Return only the messages worth preserving, in original order.',
198
+ ],
199
+ delimiter: 'RECENT MESSAGES',
200
+ messages: gatheredMessages,
201
+ render: (msg) => {
202
+ const text = extractText(msg.content);
203
+ return text.trim() ? `[${msg.role}]: ${text.trim()}` : null;
204
+ },
205
+ outro: 'Return the filtered messages in the same [role]: content format:',
206
+ });
196
207
  }
197
208
  // ---------------------------------------------------------------------------
198
209
  // Agent activity table
@@ -302,28 +313,21 @@ export function buildOlderAgentSummaryPrompt(olderChains) {
302
313
  * Returns empty string if no messages.
303
314
  */
304
315
  export function buildResolvedProblemsPrompt(messages) {
305
- if (messages.length === 0)
306
- return '';
307
- const parts = [
308
- 'Extract problem resolution pairs from this conversation.',
309
- 'Only include problems that were actually resolved. One line each.',
310
- 'Format: problem resolution.',
311
- 'Highlight the resolution, not the debugging journey.',
312
- '',
313
- '--- CONVERSATION ---',
314
- '',
315
- ];
316
- for (const msg of messages) {
317
- const text = extractText(msg.content);
318
- if (text.trim()) {
319
- parts.push(`[${msg.role}]: ${text.trim().slice(0, 1000)}`);
320
- parts.push('');
321
- }
322
- }
323
- parts.push('--- END CONVERSATION ---');
324
- parts.push('');
325
- parts.push('List resolved problems now (or return empty if none):');
326
- return parts.join('\n');
316
+ return buildDelimitedMessagePrompt({
317
+ intro: [
318
+ 'Extract problem resolution pairs from this conversation.',
319
+ 'Only include problems that were actually resolved. One line each.',
320
+ 'Format: problem resolution.',
321
+ 'Highlight the resolution, not the debugging journey.',
322
+ ],
323
+ delimiter: 'CONVERSATION',
324
+ messages,
325
+ render: (msg) => {
326
+ const text = extractText(msg.content);
327
+ return text.trim() ? `[${msg.role}]: ${text.trim().slice(0, 1000)}` : null;
328
+ },
329
+ outro: 'List resolved problems now (or return empty if none):',
330
+ });
327
331
  }
328
332
  // ---------------------------------------------------------------------------
329
333
  // Plan progress
@@ -1 +1 @@
1
- {"version":3,"file":"context-compaction.d.ts","sourceRoot":"","sources":["../../../src/platform/core/context-compaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAA4B,MAAM,2BAA2B,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAkB/B,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAElG,MAAM,WAAW,kBAAkB;IACjC,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,EAAE,OAAO,CAAC;IACtB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,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Q,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAMD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,sCAAsC,KAAK,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAQ7C,wBAAgB,mBAAmB,IAAI,SAAS,eAAe,EAAE,CAEhE;AAED,wBAAgB,sBAAsB,IAAI,eAAe,GAAG,IAAI,CAI/D;AAMD,0EAA0E;AAC1E,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM,CAc9E;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAYvD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,mBAAmB,CA6BpF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAEnE;AAMD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,eAAe,EAAE,EAC3B,UAAU,SAAK,GACd,eAAe,EAAE,CAanB;AAqHD;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAE3B;AA0OD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAOlC"}
@@ -25,7 +25,8 @@
25
25
  import { logger } from '../utils/logger.js';
26
26
  import { DEFAULT_COMPACTION_CONFIG, estimateTokens } from './compaction-types.js';
27
27
  import { summarizeError } from '../utils/error-display.js';
28
- import { buildHandoffHeader, buildSessionMemories, buildCurrentTask, buildRunningAgents, gatherRecentConversation, buildConversationFilterPrompt, buildToolResultsPrompt, buildAgentActivityTable, buildOlderAgentSummaryPrompt, buildResolvedProblemsPrompt, buildPlanProgress, buildSessionLineage, } from './compaction-sections.js';
28
+ import { buildHandoffHeader, buildSessionMemories, buildCurrentTask, buildRunningAgents, gatherRecentConversation, buildConversationFilterPrompt, buildToolResultsPrompt, buildAgentActivityTable, buildOlderAgentSummaryPrompt, buildResolvedProblemsPrompt, buildPlanProgress, buildSessionLineage, extractText, } from './compaction-sections.js';
29
+ import { isActiveAgent } from '../tools/agent/predicates.js';
29
30
  // ---------------------------------------------------------------------------
30
31
  // Compaction trigger constants
31
32
  // ---------------------------------------------------------------------------
@@ -208,7 +209,7 @@ function validateCompaction(sections, ctx, totalTokens, config) {
208
209
  if (!sectionIds.has('current-task')) {
209
210
  warnings.push('WARNING: current-task section is missing');
210
211
  }
211
- const hasRunningAgents = ctx.agents.some((a) => a.status === 'running' || a.status === 'pending');
212
+ const hasRunningAgents = ctx.agents.some(isActiveAgent);
212
213
  if (hasRunningAgents && !sectionIds.has('running-agents')) {
213
214
  warnings.push('WARNING: running agents exist but running-agents section is missing');
214
215
  }
@@ -272,9 +273,7 @@ async function runCompaction(ctx, registry) {
272
273
  for (let i = ctx.messages.length - 1; i >= 0; i--) {
273
274
  const msg = ctx.messages[i];
274
275
  if (msg?.role === 'user') {
275
- const text = typeof msg.content === 'string'
276
- ? msg.content
277
- : msg.content.filter((p) => p.type === 'text').map((p) => p.text).join('');
276
+ const text = extractText(msg.content);
278
277
  if (text.trim())
279
278
  return text.trim();
280
279
  }
@@ -333,18 +332,13 @@ async function runCompaction(ctx, registry) {
333
332
  id: 'recent-conversation',
334
333
  header: '## Recent Conversation',
335
334
  content: filteredText,
336
- tokens: estimateTokens(filteredText),
335
+ tokens: estimateTokens('## Recent Conversation\n' + filteredText),
337
336
  });
338
337
  }
339
338
  else {
340
339
  // Include raw gathered messages if the LLM filter fails.
341
340
  const fallbackLines = gatheredMessages.map((m) => {
342
- const text = typeof m.content === 'string'
343
- ? m.content
344
- : m.content
345
- .filter((p) => p.type === 'text')
346
- .map((p) => p.text)
347
- .join('');
341
+ const text = extractText(m.content);
348
342
  return `[${m.role}]: ${text.trim()}`;
349
343
  });
350
344
  const fallbackContent = fallbackLines.join('\n\n');
@@ -352,7 +346,7 @@ async function runCompaction(ctx, registry) {
352
346
  id: 'recent-conversation',
353
347
  header: '## Recent Conversation',
354
348
  content: fallbackContent,
355
- tokens: estimateTokens(fallbackContent),
349
+ tokens: estimateTokens('## Recent Conversation\n' + fallbackContent),
356
350
  });
357
351
  }
358
352
  }
@@ -362,7 +356,7 @@ async function runCompaction(ctx, registry) {
362
356
  id: 'tool-results',
363
357
  header: '## Tool Results & Files Modified',
364
358
  content: toolSummary,
365
- tokens: estimateTokens(toolSummary),
359
+ tokens: estimateTokens('## Tool Results & Files Modified\n' + toolSummary),
366
360
  });
367
361
  }
368
362
  // Older agent summary
@@ -371,7 +365,7 @@ async function runCompaction(ctx, registry) {
371
365
  id: 'older-agent-summary',
372
366
  header: '## Older Work Summary',
373
367
  content: olderSummary,
374
- tokens: estimateTokens(olderSummary),
368
+ tokens: estimateTokens('## Older Work Summary\n' + olderSummary),
375
369
  });
376
370
  }
377
371
  // Resolved problems
@@ -381,7 +375,7 @@ async function runCompaction(ctx, registry) {
381
375
  id: 'resolved-problems',
382
376
  header: '## Resolved Problems',
383
377
  content: problemsText,
384
- tokens: estimateTokens(problemsText),
378
+ tokens: estimateTokens('## Resolved Problems\n' + problemsText),
385
379
  });
386
380
  }
387
381
  // Plan progress (rule-based)
@@ -19,7 +19,7 @@ export type PreflightDeps = {
19
19
  hookDispatcher: HookDispatcherLike | null;
20
20
  configManager: Pick<ConfigManager, 'get'>;
21
21
  providerRegistry: ProviderRegistry;
22
- sessionLineageTracker: Pick<SessionLineageTracker, 'getEntries' | 'getCompactionCount'>;
22
+ sessionLineageTracker: Pick<SessionLineageTracker, 'getEntries' | 'getCompactionCount' | 'getOriginalTask'>;
23
23
  sessionId: string;
24
24
  agentManager: Pick<AgentManager, 'list'>;
25
25
  wrfcController: Pick<WrfcController, 'listChains'>;
@@ -45,7 +45,7 @@ export type PostTurnContextDeps = {
45
45
  hookDispatcher: HookDispatcherLike | null;
46
46
  configManager: Pick<ConfigManager, 'get'>;
47
47
  providerRegistry: ProviderRegistry;
48
- sessionLineageTracker: Pick<SessionLineageTracker, 'getEntries' | 'getCompactionCount'>;
48
+ sessionLineageTracker: Pick<SessionLineageTracker, 'getEntries' | 'getCompactionCount' | 'getOriginalTask'>;
49
49
  sessionId: string;
50
50
  requestRender: () => void;
51
51
  isCompacting: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator-context-runtime.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator-context-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAIlF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/D,KAAK,kBAAkB,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OA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AClC,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACzC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACnD,WAAW,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;IAC5D,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC5D,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,cAAc,EAAE,qBAAqB,CAAC;IACtC,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC1C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EAAE,YAAY,GAAG,oBAAoB,GAAG,iBAAiB,CAAC,CAAC;IAC5G,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,wBAAsB,gCAAgC,CACpD,IAAI,EAAE,mBAAmB,EACzB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAuMf"}
@@ -1,5 +1,6 @@
1
1
  import { logger } from '../utils/logger.js';
2
2
  import { estimateConversationTokens, COMPACTION_BUFFER_TOKENS, SMALL_WINDOW_THRESHOLD, compactSmallWindow, getAutoCompactDecision } from './context-compaction.js';
3
+ import { isActiveAgent } from '../tools/agent/predicates.js';
3
4
  import { emitOpsContextWarning } from '../runtime/emitters/index.js';
4
5
  import { summarizeError } from '../utils/error-display.js';
5
6
  function normalizeCatalogTier(tier) {
@@ -36,6 +37,22 @@ function formatAutoCompactTrigger(decision) {
36
37
  }
37
38
  return `crossing the ${decision.thresholdPercent}% auto-compact threshold`;
38
39
  }
40
+ function buildAutoCompactionContext(deps, params) {
41
+ return {
42
+ messages: params.messages,
43
+ sessionMemories: deps.sessionMemoryStore?.list() ?? [],
44
+ lineageEntries: deps.sessionLineageTracker.getEntries(),
45
+ agents: deps.agentManager.list().filter(isActiveAgent),
46
+ wrfcChains: deps.wrfcController.listChains(),
47
+ activePlan: deps.planManager?.getActive(deps.sessionId) ?? null,
48
+ compactionCount: deps.sessionLineageTracker.getCompactionCount(),
49
+ originalTask: deps.sessionLineageTracker.getOriginalTask() ?? undefined,
50
+ contextWindow: params.contextWindow,
51
+ trigger: 'auto',
52
+ extractionModelId: params.extractionModelId,
53
+ extractionProvider: params.extractionProvider,
54
+ };
55
+ }
39
56
  export async function checkContextWindowPreflight(deps, turnId, model) {
40
57
  const contextWindow = deps.providerRegistry.getContextWindowForModel(model);
41
58
  const tier = normalizeCatalogTier(model.tier);
@@ -98,19 +115,12 @@ export async function checkContextWindowPreflight(deps, turnId, model) {
98
115
  }
99
116
  }
100
117
  try {
101
- const preflightCtx = {
118
+ const preflightCtx = buildAutoCompactionContext(deps, {
102
119
  messages,
103
- sessionMemories: deps.sessionMemoryStore?.list() ?? [],
104
- lineageEntries: deps.sessionLineageTracker.getEntries(),
105
- agents: deps.agentManager.list().filter(a => a.status === 'running' || a.status === 'pending'),
106
- wrfcChains: deps.wrfcController.listChains(),
107
- activePlan: deps.planManager?.getActive(deps.sessionId) ?? null,
108
- compactionCount: deps.sessionLineageTracker.getCompactionCount(),
109
120
  contextWindow,
110
- trigger: 'auto',
111
121
  extractionModelId: model.registryKey,
112
122
  extractionProvider: model.provider,
113
- };
123
+ });
114
124
  await deps.conversation.compact(deps.providerRegistry, model.registryKey, 'auto', model.provider, preflightCtx);
115
125
  deps.conversation.addSystemMessage('Context compacted. Retrying request...');
116
126
  if (deps.hookDispatcher) {
@@ -278,19 +288,12 @@ export async function handlePostTurnContextMaintenance(deps, turnId, totalTokens
278
288
  }
279
289
  }
280
290
  else if (!skipAutoCompact) {
281
- const compactionCtx = {
291
+ const compactionCtx = buildAutoCompactionContext(deps, {
282
292
  messages: currentMsgs,
283
- sessionMemories: deps.sessionMemoryStore?.list() ?? [],
284
- lineageEntries: deps.sessionLineageTracker.getEntries(),
285
- agents: deps.agentManager.list().filter(a => a.status === 'running' || a.status === 'pending'),
286
- wrfcChains: deps.wrfcController.listChains(),
287
- activePlan: deps.planManager?.getActive(deps.sessionId) ?? null,
288
- compactionCount: deps.sessionLineageTracker.getCompactionCount(),
289
293
  contextWindow: maxTokens,
290
- trigger: 'auto',
291
294
  extractionModelId: currentModel.registryKey,
292
295
  extractionProvider: currentModel.provider,
293
- };
296
+ });
294
297
  void deps.conversation.compact(deps.providerRegistry, currentModel.registryKey, 'auto', currentModel.provider, compactionCtx).then(() => {
295
298
  deps.setIsCompacting(false);
296
299
  deps.setLastWarningBracket(0);
@@ -378,9 +381,9 @@ export async function handlePostTurnContextMaintenance(deps, turnId, totalTokens
378
381
  threshold: configuredThreshold,
379
382
  currentTokens: totalTokens,
380
383
  contextWindow: maxTokens,
381
- thresholdTokens: Math.floor((maxTokens * configuredThreshold) / 100),
382
- remainingTokens: Math.max(0, maxTokens - totalTokens),
383
- safetyBufferTokens: COMPACTION_BUFFER_TOKENS,
384
+ thresholdTokens: autoDecision.thresholdTokens,
385
+ remainingTokens: autoDecision.remainingTokens,
386
+ safetyBufferTokens: autoDecision.safetyBufferTokens,
384
387
  reason: 'threshold',
385
388
  });
386
389
  }
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator-tool-runtime.d.ts","sourceRoot":"","sources":["../../../src/platform/core/orchestrator-tool-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAiB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO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AAE;QAAE,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;QAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CAAC;IAC/G,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,cAAc,EAAE,qBAAqB,CAAC;IACtC,uBAAuB,EAAE,MAAM,OAAO,CAAC;IACvC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,gBAAgB,EAAE,QAAQ,EAAE,CAAC;IAC7B,mBAAmB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,kBAAkB,EACxB,eAAe,EAAE,UAAU,EAAE,EAC7B,MAAM,EAAE,oBAAoB,GAC3B,IAAI,CA8DN;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE;IAAE,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,EAC7D,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,EAClD,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,EAC3D,UAAU,GAAE,eAAe,GAAG,IAAW,EACzC,cAAc,GAAE,OAAO,8BAA8B,EAAE,cAAc,GAAG,IAAW,EACnF,WAAW,GAAE,IAAI,CAAC,oBAAoB,EAAE,YAAY,CAAC,GAAG,IAAW,GAClE,MAAM,EAAE,CA4GV"}
@@ -4,6 +4,7 @@ import { buildSyntheticResult, detectUnresolvedToolCalls } from './tool-reconcil
4
4
  import { logger } from '../utils/logger.js';
5
5
  import { evaluateOrchestrationSpawn } from '../runtime/orchestration/spawn-policy.js';
6
6
  import { summarizeError } from '../utils/error-display.js';
7
+ import { isActiveAgent } from '../tools/agent/predicates.js';
7
8
  export async function executeToolCalls(deps, turnId, calls) {
8
9
  const results = [];
9
10
  for (const call of calls) {
@@ -287,7 +288,7 @@ export function autoSpawnPendingItems(conversation, plan, items, agentManager, c
287
288
  mode: 'graph-execute',
288
289
  });
289
290
  }
290
- let running = agentManager.list().filter(a => a.status === 'running' || a.status === 'pending').length;
291
+ let running = agentManager.list().filter(a => isActiveAgent(a)).length;
291
292
  const spawnDecision = evaluateOrchestrationSpawn({
292
293
  configManager,
293
294
  mode: 'plan-auto',
@@ -31,12 +31,9 @@ export declare class SessionLineageTracker {
31
31
  reset(): void;
32
32
  /** Get the number of compactions performed. */
33
33
  getCompactionCount(): number;
34
+ /** Get the original task for this session, or null if never set. */
35
+ getOriginalTask(): string | null;
34
36
  /** Get a copy of the lineage entries (read-only snapshot). */
35
37
  getEntries(): string[];
36
- /**
37
- * Format the lineage for compaction output.
38
- * Returns null if originalTask was never set (section is omitted).
39
- */
40
- format(): string | null;
41
38
  }
42
39
  //# sourceMappingURL=session-lineage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-lineage.d.ts","sourceRoot":"","sources":["../../../src/platform/core/session-lineage.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKnC;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMzC,+DAA+D;IAC/D,KAAK,IAAI,IAAI;IAKb,+CAA+C;IAC/C,kBAAkB,IAAI,MAAM;IAI5B,8DAA8D;IAC9D,UAAU,IAAI,MAAM,EAAE;IAItB;;;OAGG;IACH,MAAM,IAAI,MAAM,GAAG,IAAI;CAcxB"}
1
+ {"version":3,"file":"session-lineage.d.ts","sourceRoot":"","sources":["../../../src/platform/core/session-lineage.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKnC;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMzC,+DAA+D;IAC/D,KAAK,IAAI,IAAI;IAKb,+CAA+C;IAC/C,kBAAkB,IAAI,MAAM;IAI5B,oEAAoE;IACpE,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC,8DAA8D;IAC9D,UAAU,IAAI,MAAM,EAAE;CAGvB"}
@@ -45,24 +45,12 @@ export class SessionLineageTracker {
45
45
  getCompactionCount() {
46
46
  return this.entries.length;
47
47
  }
48
+ /** Get the original task for this session, or null if never set. */
49
+ getOriginalTask() {
50
+ return this.originalTask;
51
+ }
48
52
  /** Get a copy of the lineage entries (read-only snapshot). */
49
53
  getEntries() {
50
54
  return [...this.entries];
51
55
  }
52
- /**
53
- * Format the lineage for compaction output.
54
- * Returns null if originalTask was never set (section is omitted).
55
- */
56
- format() {
57
- if (this.originalTask === null) {
58
- return null;
59
- }
60
- const lines = [
61
- `## Session Lineage`,
62
- `Original task: "${this.originalTask}"`,
63
- `Compactions: ${this.entries.length}`,
64
- ...this.entries,
65
- ];
66
- return lines.join('\n');
67
- }
68
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wrfc-routing.d.ts","sourceRoot":"","sources":["../../../src/platform/core/wrfc-routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3D;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1E;AAyBD,wBAAgB,yCAAyC,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAQrF"}
1
+ {"version":3,"file":"wrfc-routing.d.ts","sourceRoot":"","sources":["../../../src/platform/core/wrfc-routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3D;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1E;AAsBD,wBAAgB,yCAAyC,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAQrF"}
@@ -1,3 +1,4 @@
1
+ import { isRecord } from '../utils/record-coerce.js';
1
2
  export function isWrfcWorkflowRequest(text) {
2
3
  const normalized = text.trim().toLowerCase();
3
4
  if (!/\bwrfc\b/.test(normalized))
@@ -12,9 +13,6 @@ export function buildWrfcWorkflowRoutingPrompt(text) {
12
13
  return null;
13
14
  return '[WRFC routing] The user is asking for WRFC-owned work. Use the agent tool to start exactly one WRFC owner chain with mode=spawn, template=engineer, reviewMode=wrfc. Do not answer by describing WRFC, and do not spawn reviewer/tester/verifier roots.';
14
15
  }
15
- function isRecord(value) {
16
- return typeof value === 'object' && value !== null && !Array.isArray(value);
17
- }
18
16
  function parseToolOutput(output) {
19
17
  if (!output)
20
18
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-routes.d.ts","sourceRoot":"","sources":["../../../../src/platform/daemon/http/mcp-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,UAAU,eAAe;IACvB,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AC,CAAC;IACzE,QAAQ,CAAC,qBAAqB,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;IACxF,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,IAAI,CAAC;CAC1D;AAiED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAkExG"}
@@ -1,7 +1,5 @@
1
1
  import { jsonErrorResponse } from './error-response.js';
2
- function isRecord(value) {
3
- return typeof value === 'object' && value !== null && !Array.isArray(value);
4
- }
2
+ import { isRecord } from '../../utils/record-coerce.js';
5
3
  function stringArray(value) {
6
4
  return Array.isArray(value) && value.every((entry) => typeof entry === 'string')
7
5
  ? [...value]
@@ -1 +1 @@
1
- {"version":3,"file":"openai-compatible-routes.d.ts","sourceRoot":"","sources":["../../../../src/platform/daemon/http/openai-compatible-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAKpE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,iBAAiB,GAAG,aAAa,CAAC,CAAC;IACpG,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,QAAQ,CAAC;CAC9F;AAoBD,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,4BAA4B,EACrC,UAAU,SAA4B,GACrC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAgB1B"}
1
+ {"version":3,"file":"openai-compatible-routes.d.ts","sourceRoot":"","sources":["../../../../src/platform/daemon/http/openai-compatible-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAMpE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,iBAAiB,GAAG,aAAa,CAAC,CAAC;IACpG,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;IAC7E,QAAQ,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,QAAQ,CAAC;CAC9F;AAoBD,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,4BAA4B,EACrC,UAAU,SAA4B,GACrC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAgB1B"}
@@ -1,4 +1,5 @@
1
1
  import { summarizeError } from '../../utils/error-display.js';
2
+ import { isRecord } from '../../utils/record-coerce.js';
2
3
  const OPENAI_COMPAT_PATH_PREFIX = '/v1';
3
4
  export async function dispatchOpenAICompatibleRoutes(request, context, pathPrefix = OPENAI_COMPAT_PATH_PREFIX) {
4
5
  const url = new URL(request.url);
@@ -418,9 +419,6 @@ function parseDataUrl(value) {
418
419
  return null;
419
420
  return { mediaType: match[1], data: match[2] };
420
421
  }
421
- function isRecord(value) {
422
- return typeof value === 'object' && value !== null && !Array.isArray(value);
423
- }
424
422
  function readString(value) {
425
423
  return typeof value === 'string' ? value : undefined;
426
424
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-routes.d.ts","sourceRoot":"","sources":["../../../../src/platform/daemon/http/runtime-routes.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAExG,YAAY,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAqQ1E,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,yBAAyB,GACjC,4BAA4B,CAgB9B"}
1
+ {"version":3,"file":"runtime-routes.d.ts","sourceRoot":"","sources":["../../../../src/platform/daemon/http/runtime-routes.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAGxG,YAAY,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAkQ1E,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,yBAAyB,GACjC,4BAA4B,CAgB9B"}
@@ -1,5 +1,6 @@
1
1
  import { createDaemonRuntimeRouteHandlers as createSdkDaemonRuntimeRouteHandlers } from '@pellux/goodvibes-daemon-sdk';
2
2
  import { EXECUTION_FILESYSTEM_POLICIES, EXECUTION_NETWORK_POLICIES, EXECUTION_RISK_CLASSES, } from '../../runtime/execution-intents.js';
3
+ import { isRecord } from '../../utils/record-coerce.js';
3
4
  const providerSelections = new Set(['inherit-current', 'concrete', 'synthetic']);
4
5
  const providerFailurePolicies = new Set(['ordered-fallbacks', 'fail']);
5
6
  const executionTargetKinds = new Set(['isolated', 'current', 'pinned', 'background', 'main', 'session', 'route']);
@@ -47,9 +48,6 @@ const communicationLanes = new Set(['parent-only', 'parent-and-children', 'cohor
47
48
  const executionRiskClasses = new Set(EXECUTION_RISK_CLASSES);
48
49
  const executionNetworkPolicies = new Set(EXECUTION_NETWORK_POLICIES);
49
50
  const executionFilesystemPolicies = new Set(EXECUTION_FILESYSTEM_POLICIES);
50
- function isRecord(value) {
51
- return typeof value === 'object' && value !== null && !Array.isArray(value);
52
- }
53
51
  function isFiniteNumber(value) {
54
52
  return typeof value === 'number' && Number.isFinite(value);
55
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/platform/hooks/runners/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMzE;;;GAGG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAgErF"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/platform/hooks/runners/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMzE;;;GAGG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAsDrF"}
@@ -1,7 +1,7 @@
1
1
  import { logger } from '../../utils/logger.js';
2
2
  import { summarizeError } from '../../utils/error-display.js';
3
3
  import { classifyHostTrustTier, extractHostname, emitSsrfDeny } from '../../tools/fetch/trust-tiers.js';
4
- import { instrumentedFetch } from '../../utils/fetch-with-timeout.js';
4
+ import { instrumentedFetch, fetchWithTimeout } from '../../utils/fetch-with-timeout.js';
5
5
  /**
6
6
  * HTTP hook runner.
7
7
  * POSTs the event JSON to the configured URL and parses the response as HookResult.
@@ -25,24 +25,14 @@ export async function run(hook, event) {
25
25
  }
26
26
  const timeoutMs = (hook.timeout ?? 30) * 1000;
27
27
  try {
28
- const controller = new AbortController();
29
- const timer = setTimeout(() => controller.abort(), timeoutMs);
30
- timer.unref?.();
31
- let response;
32
- try {
33
- response = await instrumentedFetch(url, {
34
- method: 'POST',
35
- headers: {
36
- 'Content-Type': 'application/json',
37
- ...hook.headers,
38
- },
39
- body: JSON.stringify(event),
40
- signal: controller.signal,
41
- });
42
- }
43
- finally {
44
- clearTimeout(timer);
45
- }
28
+ const response = await fetchWithTimeout(url, {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ ...hook.headers,
33
+ },
34
+ body: JSON.stringify(event),
35
+ }, timeoutMs, instrumentedFetch);
46
36
  if (!response.ok) {
47
37
  return {
48
38
  ok: false,