@aexol/spectral 0.9.220 → 0.9.222

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 (153) hide show
  1. package/dist/agent/index.d.ts +7 -3
  2. package/dist/agent/index.d.ts.map +1 -1
  3. package/dist/agent/index.js +35 -8
  4. package/dist/extensions/aexol-backend-client.d.ts +85 -0
  5. package/dist/extensions/aexol-backend-client.d.ts.map +1 -0
  6. package/dist/extensions/aexol-backend-client.js +159 -0
  7. package/dist/extensions/aexol-mcp.d.ts +10 -6
  8. package/dist/extensions/aexol-mcp.d.ts.map +1 -1
  9. package/dist/extensions/aexol-mcp.js +21 -106
  10. package/dist/extensions/logic-trace-backend-draft.d.ts +68 -0
  11. package/dist/extensions/logic-trace-backend-draft.d.ts.map +1 -0
  12. package/dist/extensions/logic-trace-backend-draft.js +171 -0
  13. package/dist/extensions/logic-trace-validate.d.ts +33 -0
  14. package/dist/extensions/logic-trace-validate.d.ts.map +1 -0
  15. package/dist/extensions/logic-trace-validate.js +73 -0
  16. package/dist/extensions/logic-trace.d.ts +213 -0
  17. package/dist/extensions/logic-trace.d.ts.map +1 -0
  18. package/dist/extensions/logic-trace.js +1098 -0
  19. package/dist/generated/parser/lexer.d.ts +148 -0
  20. package/dist/generated/parser/lexer.d.ts.map +1 -0
  21. package/dist/generated/parser/lexer.js +877 -0
  22. package/dist/generated/parser/mod.d.ts +26 -0
  23. package/dist/generated/parser/mod.d.ts.map +1 -0
  24. package/dist/generated/parser/mod.js +30 -0
  25. package/dist/generated/parser/parser.d.ts +161 -0
  26. package/dist/generated/parser/parser.d.ts.map +1 -0
  27. package/dist/generated/parser/parser.js +754 -0
  28. package/dist/generated/parser/tokenizer.d.ts +107 -0
  29. package/dist/generated/parser/tokenizer.d.ts.map +1 -0
  30. package/dist/generated/parser/tokenizer.js +202 -0
  31. package/dist/generated/parser/validator.d.ts +45 -0
  32. package/dist/generated/parser/validator.d.ts.map +1 -0
  33. package/dist/generated/parser/validator.js +202 -0
  34. package/dist/generated/zeus/const.d.ts.map +1 -1
  35. package/dist/generated/zeus/const.js +4 -170
  36. package/dist/generated/zeus/index.d.ts +8 -873
  37. package/dist/generated/zeus/index.d.ts.map +1 -1
  38. package/dist/generated/zeus/index.js +0 -7
  39. package/dist/mcp/ui-stream-types.d.ts +2 -2
  40. package/dist/memory/tools/share-project-observation.js +1 -1
  41. package/dist/memory/tools/write-project-observation.d.ts.map +1 -1
  42. package/dist/memory/tools/write-project-observation.js +4 -3
  43. package/dist/sdk/agent-core/harness/types.d.ts +0 -1
  44. package/dist/sdk/agent-core/harness/types.d.ts.map +1 -1
  45. package/dist/sdk/agent-core/index.d.ts +0 -8
  46. package/dist/sdk/agent-core/index.d.ts.map +1 -1
  47. package/dist/sdk/agent-core/index.js +0 -9
  48. package/dist/sdk/coding-agent/core/extensions/index.d.ts +1 -1
  49. package/dist/sdk/coding-agent/core/extensions/index.d.ts.map +1 -1
  50. package/dist/sdk/coding-agent/core/extensions/native-extensions.js +2 -2
  51. package/dist/sdk/coding-agent/core/extensions/types.d.ts +20 -1
  52. package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
  53. package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.d.ts +9 -4
  54. package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  55. package/dist/sdk/coding-agent/core/tools/tool-definition-wrapper.js +15 -2
  56. package/dist/sdk/coding-agent/index.d.ts +1 -1
  57. package/dist/sdk/coding-agent/index.d.ts.map +1 -1
  58. package/dist/server/agent-bridge/headless-ui.d.ts +20 -0
  59. package/dist/server/agent-bridge/headless-ui.d.ts.map +1 -0
  60. package/dist/server/agent-bridge/headless-ui.js +85 -0
  61. package/dist/server/agent-bridge/pricing.d.ts +37 -0
  62. package/dist/server/agent-bridge/pricing.d.ts.map +1 -0
  63. package/dist/server/agent-bridge/pricing.js +202 -0
  64. package/dist/server/agent-bridge/rehydrate.d.ts +35 -0
  65. package/dist/server/agent-bridge/rehydrate.d.ts.map +1 -0
  66. package/dist/server/agent-bridge/rehydrate.js +122 -0
  67. package/dist/server/agent-bridge/synthetic-model.d.ts +27 -0
  68. package/dist/server/agent-bridge/synthetic-model.d.ts.map +1 -0
  69. package/dist/server/agent-bridge/synthetic-model.js +92 -0
  70. package/dist/server/agent-bridge.d.ts +11 -1
  71. package/dist/server/agent-bridge.d.ts.map +1 -1
  72. package/dist/server/agent-bridge.js +42 -481
  73. package/dist/server/session-stream/compaction-events.d.ts +13 -0
  74. package/dist/server/session-stream/compaction-events.d.ts.map +1 -0
  75. package/dist/server/session-stream/compaction-events.js +32 -0
  76. package/dist/server/session-stream/history-prune.d.ts +35 -0
  77. package/dist/server/session-stream/history-prune.d.ts.map +1 -0
  78. package/dist/server/session-stream/history-prune.js +182 -0
  79. package/dist/server/session-stream/memory.d.ts +48 -0
  80. package/dist/server/session-stream/memory.d.ts.map +1 -0
  81. package/dist/server/session-stream/memory.js +136 -0
  82. package/dist/server/session-stream/replay-tail.d.ts +4 -0
  83. package/dist/server/session-stream/replay-tail.d.ts.map +1 -0
  84. package/dist/server/session-stream/replay-tail.js +39 -0
  85. package/dist/server/session-stream/turn-events.d.ts +33 -0
  86. package/dist/server/session-stream/turn-events.d.ts.map +1 -0
  87. package/dist/server/session-stream/turn-events.js +65 -0
  88. package/dist/server/session-stream/turn-silence.d.ts +8 -0
  89. package/dist/server/session-stream/turn-silence.d.ts.map +1 -0
  90. package/dist/server/session-stream/turn-silence.js +72 -0
  91. package/dist/server/session-stream.d.ts +137 -36
  92. package/dist/server/session-stream.d.ts.map +1 -1
  93. package/dist/server/session-stream.js +18 -509
  94. package/dist/server/storage/observation-ranking.d.ts +14 -0
  95. package/dist/server/storage/observation-ranking.d.ts.map +1 -0
  96. package/dist/server/storage/observation-ranking.js +37 -0
  97. package/dist/server/storage/preflight.d.ts +20 -0
  98. package/dist/server/storage/preflight.d.ts.map +1 -0
  99. package/dist/server/storage/preflight.js +22 -0
  100. package/dist/server/storage/project-binding.d.ts +5 -0
  101. package/dist/server/storage/project-binding.d.ts.map +1 -0
  102. package/dist/server/storage/project-binding.js +32 -0
  103. package/dist/server/storage/rows.d.ts +104 -0
  104. package/dist/server/storage/rows.d.ts.map +1 -0
  105. package/dist/server/storage/rows.js +2 -0
  106. package/dist/server/storage/schema.d.ts +20 -0
  107. package/dist/server/storage/schema.d.ts.map +1 -0
  108. package/dist/server/storage/schema.js +134 -0
  109. package/dist/server/storage/types.d.ts +66 -0
  110. package/dist/server/storage/types.d.ts.map +1 -0
  111. package/dist/server/storage/types.js +1 -0
  112. package/dist/server/storage.d.ts +7 -94
  113. package/dist/server/storage.d.ts.map +1 -1
  114. package/dist/server/storage.js +6 -224
  115. package/dist/server/wire.d.ts +6 -0
  116. package/dist/server/wire.d.ts.map +1 -1
  117. package/package.json +2 -1
  118. package/dist/sdk/agent-core/harness/agent-harness.d.ts +0 -92
  119. package/dist/sdk/agent-core/harness/agent-harness.d.ts.map +0 -1
  120. package/dist/sdk/agent-core/harness/agent-harness.js +0 -899
  121. package/dist/sdk/agent-core/harness/env/nodejs.d.ts +0 -51
  122. package/dist/sdk/agent-core/harness/env/nodejs.d.ts.map +0 -1
  123. package/dist/sdk/agent-core/harness/env/nodejs.js +0 -485
  124. package/dist/sdk/agent-core/harness/prompt-templates.d.ts +0 -48
  125. package/dist/sdk/agent-core/harness/prompt-templates.d.ts.map +0 -1
  126. package/dist/sdk/agent-core/harness/prompt-templates.js +0 -229
  127. package/dist/sdk/agent-core/harness/session/jsonl-repo.d.ts +0 -26
  128. package/dist/sdk/agent-core/harness/session/jsonl-repo.d.ts.map +0 -1
  129. package/dist/sdk/agent-core/harness/session/jsonl-repo.js +0 -100
  130. package/dist/sdk/agent-core/harness/session/jsonl-storage.d.ts +0 -33
  131. package/dist/sdk/agent-core/harness/session/jsonl-storage.d.ts.map +0 -1
  132. package/dist/sdk/agent-core/harness/session/jsonl-storage.js +0 -230
  133. package/dist/sdk/agent-core/harness/session/memory-repo.d.ts +0 -18
  134. package/dist/sdk/agent-core/harness/session/memory-repo.d.ts.map +0 -1
  135. package/dist/sdk/agent-core/harness/session/memory-repo.js +0 -41
  136. package/dist/sdk/agent-core/harness/session/memory-storage.d.ts +0 -25
  137. package/dist/sdk/agent-core/harness/session/memory-storage.d.ts.map +0 -1
  138. package/dist/sdk/agent-core/harness/session/memory-storage.js +0 -113
  139. package/dist/sdk/agent-core/harness/session/repo-utils.d.ts +0 -11
  140. package/dist/sdk/agent-core/harness/session/repo-utils.d.ts.map +0 -1
  141. package/dist/sdk/agent-core/harness/session/repo-utils.js +0 -38
  142. package/dist/sdk/agent-core/harness/skills.d.ts +0 -44
  143. package/dist/sdk/agent-core/harness/skills.d.ts.map +0 -1
  144. package/dist/sdk/agent-core/harness/skills.js +0 -310
  145. package/dist/sdk/agent-core/harness/utils/shell-output.d.ts +0 -14
  146. package/dist/sdk/agent-core/harness/utils/shell-output.d.ts.map +0 -1
  147. package/dist/sdk/agent-core/harness/utils/shell-output.js +0 -125
  148. package/dist/sdk/agent-core/node.d.ts +0 -3
  149. package/dist/sdk/agent-core/node.d.ts.map +0 -1
  150. package/dist/sdk/agent-core/node.js +0 -2
  151. package/dist/sdk/agent-core/proxy.d.ts +0 -69
  152. package/dist/sdk/agent-core/proxy.d.ts.map +0 -1
  153. package/dist/sdk/agent-core/proxy.js +0 -297
@@ -1 +1 @@
1
- {"version":3,"file":"agent-bridge.d.ts","sourceRoot":"","sources":["../../src/server/agent-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAaH,OAAO,EAQL,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAEtB,MAAM,8BAA8B,CAAC;AAatC,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AActC,OAAO,EACL,kBAAkB,IAAI,yBAAyB,EAEhD,MAAM,0BAA0B,CAAC;AAClC,OAA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ACH,OAAO,CAAC,8BAA8B;IAQtC,yEAAyE;IACzE,OAAO,CAAC,iCAAiC;IAOzC,OAAO,CAAC,iBAAiB;IAazB;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,uBAAuB;IAMzB,OAAO,CACX,OAAO,CAAC,EAAE,MAAM,GAAG,4BAA4B,GAC9C,OAAO,CAAC,gBAAgB,CAAC;IAY5B,OAAO,IAAI,IAAI;IAiDf;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;;;;;;OAQG;IACH,OAAO,CAAC,6BAA6B;IAiCrC;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B,uEAAuE;IACvE,OAAO,CAAC,wBAAwB;IAMhC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,sBAAsB;IAwD9B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,EAAE,iBAAiB,GAAG,IAAI;CAqlBzC"}
@@ -62,26 +62,23 @@ import codeOrderExtension from "../extensions/code-order/index.js";
62
62
  import { BrowserService } from "../extensions/browser/browser-service.js";
63
63
  import subagentExt from "../agent/index.js";
64
64
  import designerExtension from "../designer/index.js";
65
+ import logicTraceExtension from "../extensions/logic-trace.js";
65
66
  import observationalMemory from "../memory/index.js";
66
67
  import { OBSERVATIONAL_MEMORY_CONTEXT_CUSTOM_TYPE, OBSERVATIONAL_MEMORY_SNAPSHOT_CUSTOM_TYPE, } from "../memory/types.js";
67
68
  import { fetchAllowedModels as defaultFetchAllowedModels, } from "../relay/models-fetch.js";
68
69
  import { humanizeProviderError } from "./error-humanizer.js";
69
- import { createBridgeConfirm, createStdinConfirmIO, } from "./ui/terminal-confirm.js";
70
70
  import { readStudioBinding, getBindingFilePath } from "../studio-binding.js";
71
- /**
72
- * Synthetic provider names registered with spectral's `ModelRegistry`. They route
73
- * 100% of inference traffic through the backend (`${backendUrl}/v1`), which
74
- * authenticates with the machine JWT and forwards to the upstream provider
75
- * with centrally-managed API keys.
76
- *
77
- * Two providers (rather than one): `spectral-proxy-openai` for upstream catalog
78
- * models (OpenRouter, DeepSeek, OpenAI, etc.), and
79
- * `spectral-proxy-user-model` for team-registered built-in UserModel entries.
80
- * Both use the OpenAI-compatible `/chat/completions` request shape.
81
- */
82
- const SPECTRAL_PROXY_OPENAI = "spectral-proxy-openai";
83
- const SPECTRAL_PROXY_USER_MODEL = "spectral-proxy-user-model";
84
- const KIMI_K2_7_CODE_CONTEXT_WINDOW = 262_144;
71
+ // Facade imports: cohesive helpers extracted verbatim to `./agent-bridge/` modules.
72
+ import { calculateCredits, getModelCost } from "./agent-bridge/pricing.js";
73
+ import { SPECTRAL_PROXY_OPENAI, SPECTRAL_PROXY_USER_MODEL, inferSyntheticContextWindow, inferSyntheticOpenAICompat, inferSyntheticThinkingLevelMap, } from "./agent-bridge/synthetic-model.js";
74
+ import { parseWireToolEvents, sanitizeRehydratedBlock, toRestoredMemorySnapshot, } from "./agent-bridge/rehydrate.js";
75
+ import { createHeadlessUIContext } from "./agent-bridge/headless-ui.js";
76
+ // Facade re-exports: moved helpers remain importable from this module so
77
+ // existing (and future) importers of `agent-bridge.js` are unaffected.
78
+ export { bareModelId, calculateCredits, getModelCost, lookupPricing, } from "./agent-bridge/pricing.js";
79
+ export { SPECTRAL_PROXY_OPENAI, SPECTRAL_PROXY_USER_MODEL, inferSyntheticContextWindow, inferSyntheticOpenAICompat, inferSyntheticThinkingLevelMap, } from "./agent-bridge/synthetic-model.js";
80
+ export { parseWireToolEvents, sanitizeRehydratedBlock, toRestoredMemorySnapshot, } from "./agent-bridge/rehydrate.js";
81
+ export { createHeadlessUIContext } from "./agent-bridge/headless-ui.js";
85
82
  /**
86
83
  * Walk ancestor directories from `cwd` up to the filesystem root, collecting
87
84
  * any existing skill directories at the given relative paths (e.g.
@@ -133,280 +130,7 @@ function extractTextFromContent(content) {
133
130
  }
134
131
  return out;
135
132
  }
136
- /**
137
- * Token pricing per model (USD per 1M tokens). Matches provider list
138
- * prices as of May 2026. Used to compute token cost server-side when
139
- * spectral's own cost field is unavailable (synthetic proxy models are
140
- * registered with zero cost to avoid agent-side billing).
141
- *
142
- * Keys are matched as prefix substrings against modelId, so
143
- * `"gpt-5"` covers both `gpt-5` and any
144
- * future point-release.
145
- */
146
- const MODEL_PRICING = [
147
- // OpenAI models
148
- {
149
- prefix: "gpt-5.5",
150
- input: 1.75,
151
- output: 14,
152
- cacheWrite: 14,
153
- cacheRead: 0.35,
154
- },
155
- {
156
- prefix: "gpt-5.4",
157
- input: 1.75,
158
- output: 14,
159
- cacheWrite: 14,
160
- cacheRead: 0.35,
161
- },
162
- {
163
- prefix: "gpt-5.3",
164
- input: 1.75,
165
- output: 14,
166
- cacheWrite: 14,
167
- cacheRead: 0.35,
168
- },
169
- {
170
- prefix: "gpt-5.2",
171
- input: 1.75,
172
- output: 14,
173
- cacheWrite: 14,
174
- cacheRead: 0.35,
175
- },
176
- { prefix: "gpt-5.1", input: 2, output: 8, cacheWrite: 8, cacheRead: 0.5 },
177
- { prefix: "gpt-5", input: 1.25, output: 10, cacheWrite: 10, cacheRead: 0.25 },
178
- { prefix: "gpt-4.1", input: 2, output: 8, cacheWrite: 8, cacheRead: 0.5 },
179
- { prefix: "gpt-4o", input: 2.5, output: 10, cacheWrite: 10, cacheRead: 1.25 },
180
- { prefix: "gpt-4-turbo", input: 10, output: 30, cacheWrite: 0, cacheRead: 0 },
181
- { prefix: "gpt-4", input: 30, output: 60, cacheWrite: 0, cacheRead: 0 },
182
- {
183
- prefix: "gpt-3.5-turbo",
184
- input: 0.5,
185
- output: 1.5,
186
- cacheWrite: 0,
187
- cacheRead: 0,
188
- },
189
- { prefix: "o1", input: 15, output: 60, cacheWrite: 0, cacheRead: 0 },
190
- { prefix: "o3-mini", input: 1.1, output: 4.4, cacheWrite: 0, cacheRead: 0 },
191
- { prefix: "o4-mini", input: 1.1, output: 4.4, cacheWrite: 0, cacheRead: 0 },
192
- // Google Gemini models
193
- {
194
- prefix: "gemini-2.5-pro",
195
- input: 1.25,
196
- output: 10,
197
- cacheWrite: 0,
198
- cacheRead: 0,
199
- },
200
- {
201
- prefix: "gemini-2.5-flash",
202
- input: 0.15,
203
- output: 0.6,
204
- cacheWrite: 0,
205
- cacheRead: 0,
206
- },
207
- // DeepSeek models
208
- {
209
- prefix: "deepseek-v3",
210
- input: 0.27,
211
- output: 1.1,
212
- cacheWrite: 0,
213
- cacheRead: 0,
214
- },
215
- {
216
- prefix: "deepseek-r1",
217
- input: 0.55,
218
- output: 2.19,
219
- cacheWrite: 0,
220
- cacheRead: 0,
221
- },
222
- {
223
- prefix: "deepseek/deepseek-v3",
224
- input: 0.27,
225
- output: 1.1,
226
- cacheWrite: 0,
227
- cacheRead: 0,
228
- },
229
- {
230
- prefix: "deepseek/deepseek-r1",
231
- input: 0.55,
232
- output: 2.19,
233
- cacheWrite: 0,
234
- cacheRead: 0,
235
- },
236
- // Meta Llama models (common via OpenRouter-compatible endpoints)
237
- {
238
- prefix: "meta-llama/llama-4",
239
- input: 0.2,
240
- output: 0.8,
241
- cacheWrite: 0,
242
- cacheRead: 0,
243
- },
244
- {
245
- prefix: "meta-llama/llama-3.3",
246
- input: 0.2,
247
- output: 0.5,
248
- cacheWrite: 0,
249
- cacheRead: 0,
250
- },
251
- ];
252
- /**
253
- * Strip vendor prefix to extract the bare model name.
254
- * e.g. "openai/gpt-5.3-codex" → "gpt-5.3-codex".
255
- * Returns the original string when no separator is present.
256
- */
257
- function bareModelId(modelId) {
258
- const idx = modelId.lastIndexOf("/");
259
- return idx === -1 ? modelId : modelId.slice(idx + 1);
260
- }
261
- function inferSyntheticContextWindow(model) {
262
- if (typeof model.contextWindow === "number" &&
263
- Number.isFinite(model.contextWindow)) {
264
- return model.contextWindow;
265
- }
266
- const modelId = model.modelId.toLowerCase();
267
- const bare = bareModelId(modelId);
268
- if (modelId === "moonshotai/kimi-k2.7-code" ||
269
- bare === "kimi-k2.7-code" ||
270
- bare === "local-openrouter-kimi") {
271
- return KIMI_K2_7_CODE_CONTEXT_WINDOW;
272
- }
273
- return 0;
274
- }
275
133
  /** Get model cost from backend credit rates, falling back to hardcoded pricing table. */
276
- function getModelCost(m) {
277
- // Prefer backend credit rates when configured
278
- const hasCredits = m.creditInputPer1M != null ||
279
- m.creditOutputPer1M != null ||
280
- m.creditCacheReadPer1M != null ||
281
- m.creditCacheWritePer1M != null;
282
- if (hasCredits) {
283
- return {
284
- input: m.creditInputPer1M ?? 0,
285
- output: m.creditOutputPer1M ?? 0,
286
- cacheRead: m.creditCacheReadPer1M ?? 0,
287
- cacheWrite: m.creditCacheWritePer1M ?? 0,
288
- };
289
- }
290
- // Fall back to hardcoded pricing table when credits aren't configured
291
- const pricing = lookupPricing(m.modelId);
292
- return pricing
293
- ? {
294
- input: pricing.input,
295
- output: pricing.output,
296
- cacheRead: pricing.cacheRead,
297
- cacheWrite: pricing.cacheWrite,
298
- }
299
- : { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
300
- }
301
- /** Look up pricing for a modelId. Returns null when unknown. */
302
- function lookupPricing(modelId) {
303
- const bare = bareModelId(modelId);
304
- for (const entry of MODEL_PRICING) {
305
- if (modelId.startsWith(entry.prefix) || bare.startsWith(entry.prefix)) {
306
- return {
307
- input: entry.input,
308
- output: entry.output,
309
- cacheWrite: entry.cacheWrite,
310
- cacheRead: entry.cacheRead,
311
- };
312
- }
313
- }
314
- return null;
315
- }
316
- function inferSyntheticThinkingLevelMap(model) {
317
- if (!model.supportsReasoning)
318
- return undefined;
319
- const modelId = model.modelId.toLowerCase();
320
- const bare = bareModelId(modelId);
321
- if (model.provider === "built-in" &&
322
- (modelId.includes("gpt-5") || bare.includes("gpt-5"))) {
323
- return {
324
- off: "none",
325
- minimal: "minimal",
326
- low: "low",
327
- medium: "medium",
328
- high: "high",
329
- xhigh: "xhigh",
330
- };
331
- }
332
- return undefined;
333
- }
334
- function inferSyntheticOpenAICompat(model) {
335
- const bare = bareModelId(model.modelId);
336
- const isDeepSeek = model.provider === "deepseek" ||
337
- model.modelId.startsWith("deepseek/") ||
338
- bare.startsWith("deepseek");
339
- if (isDeepSeek) {
340
- return {
341
- thinkingFormat: "deepseek",
342
- requiresReasoningContentOnAssistantMessages: true,
343
- supportsDeveloperRole: false,
344
- };
345
- }
346
- if (model.provider === "built-in") {
347
- const compat = {
348
- // Built-in models are proxied through the backend, which forwards a
349
- // session-affinity key to OpenRouter for prompt-cache sticky routing.
350
- // Sending the real per-session id from the CLI lets the backend use it
351
- // instead of a coarser machine/team fallback, maximizing cache hits on
352
- // large multi-turn agentic prompts.
353
- sendSessionAffinityHeaders: true,
354
- };
355
- if (model.modelId.toLowerCase().includes("gpt-5") ||
356
- bare.toLowerCase().includes("gpt-5")) {
357
- compat.thinkingFormat = "openai";
358
- compat.supportsReasoningEffort = true;
359
- compat.supportsStore = false;
360
- }
361
- return compat;
362
- }
363
- if (model.provider === "openrouter") {
364
- const compat = {
365
- thinkingFormat: "openrouter",
366
- };
367
- return compat;
368
- }
369
- return undefined;
370
- }
371
- /**
372
- * Calculate credits from token usage using per-model credit rates.
373
- *
374
- * NOTE: We intentionally keep higher precision here (no 2-decimal rounding)
375
- * so small turns don't collapse to 0.00 in live UI aggregation. Rendering
376
- * layers decide final display precision.
377
- */
378
- function calculateCredits(inputTokens, outputTokens, cacheReadTokens = 0, cacheWriteTokens = 0, creditInputPer1M, creditOutputPer1M, creditCachedInputPer1M, creditCacheReadPer1M, creditCacheWritePer1M) {
379
- const inputRate = creditInputPer1M ?? 0;
380
- const outputRate = creditOutputPer1M ?? 0;
381
- const cachedInputRate = creditCachedInputPer1M ?? 0;
382
- const cacheReadRate = creditCacheReadPer1M ?? 0;
383
- const cacheWriteRate = creditCacheWritePer1M ?? 0;
384
- const credits = (inputTokens / 1_000_000) * inputRate +
385
- (outputTokens / 1_000_000) * outputRate +
386
- (cacheReadTokens / 1_000_000) * cacheReadRate +
387
- (cacheWriteTokens / 1_000_000) * cacheWriteRate;
388
- if (inputRate === 0 &&
389
- outputRate === 0 &&
390
- cacheReadRate === 0 &&
391
- cacheWriteRate === 0) {
392
- if (cachedInputRate > 0) {
393
- return (((inputTokens + cacheReadTokens + cacheWriteTokens) / 1_000_000) *
394
- cachedInputRate);
395
- }
396
- return 0;
397
- }
398
- return credits;
399
- }
400
- /**
401
- * Parse the newline-delimited JSON of wire events persisted alongside an
402
- * assistant message and extract all tool_call / tool_result events.
403
- *
404
- * These are used during session rehydration to reconstruct the full tool
405
- * interaction history (call → result) so the LLM context is complete —
406
- * without this, reconnected sessions would see only the assistant text
407
- * and never the tool results, causing the model to get confused about
408
- * the conversation state.
409
- */
410
134
  /**
411
135
  * Map a wire `ImageAttachment` onto a spectral `ImageContent` block.
412
136
  *
@@ -434,115 +158,6 @@ function toImageContent(image) {
434
158
  }
435
159
  return null;
436
160
  }
437
- function parseWireToolEvents(eventsJsonl) {
438
- const toolCalls = [];
439
- const toolResults = [];
440
- if (!eventsJsonl)
441
- return { toolCalls, toolResults };
442
- for (const line of eventsJsonl.split("\n")) {
443
- const trimmed = line.trim();
444
- if (!trimmed)
445
- continue;
446
- try {
447
- const ev = JSON.parse(trimmed);
448
- if (ev.type === "tool_call") {
449
- toolCalls.push({
450
- id: ev.id,
451
- name: ev.name,
452
- arguments: ev.args,
453
- });
454
- }
455
- else if (ev.type === "tool_result") {
456
- toolResults.push({
457
- id: ev.id,
458
- result: ev.result,
459
- isError: ev.isError ?? false,
460
- });
461
- }
462
- }
463
- catch {
464
- // Skip malformed JSON lines — they won't be meaningful for
465
- // rehydration and we'd rather keep the session alive than fail.
466
- }
467
- }
468
- return { toolCalls, toolResults };
469
- }
470
- /**
471
- * Safety clean-up for content blocks rehydrated from persisted wire events.
472
- *
473
- * Rehydrated tool-result content is bounded for the model-facing context,
474
- * while the original wire event remains available to the UI for rendering
475
- * images and other rich results.
476
- */
477
- const MAX_REHYDRATED_TEXT = 100_000;
478
- /**
479
- * Ceiling for blocks that already carry an offload footer (`Full output:`).
480
- * These blocks are a bounded preview + a re-readable path, so cutting them
481
- * with the generic limit would destroy the footer. Keep them whole up to
482
- * this size; larger ones lose their middle but keep head + footer.
483
- */
484
- const MAX_REHYDRATED_OFFLOAD_TEXT = 200_000;
485
- function sanitizeRehydratedBlock(block) {
486
- // Tool-result image blocks are not accepted by every provider; the raw
487
- // result remains in events_jsonl for the UI, while the model gets a compact reference.
488
- if (block.type === "image") {
489
- // Hosted images carry a url instead of inline bytes — print that rather
490
- // than a meaningless "0 bytes base64".
491
- const hostedUrl = typeof block.url === "string" && block.url ? block.url : undefined;
492
- const descriptor = hostedUrl
493
- ? `[Image: ${block.mimeType ?? "image/png"}, url: ${hostedUrl}]`
494
- : `[Image: ${block.mimeType ?? "image/png"}, ${(typeof block.data === "string" ? block.data.length : 0).toLocaleString()} bytes base64]`;
495
- return {
496
- type: "text",
497
- text: descriptor +
498
- `\n(Image data is available in the raw MCP result.)`,
499
- };
500
- }
501
- // Truncate oversized text blocks to prevent context overflow.
502
- if (block.type !== "text")
503
- return block;
504
- if (block.text.includes("Full output:")) {
505
- if (block.text.length <= MAX_REHYDRATED_OFFLOAD_TEXT)
506
- return block;
507
- // Keep the head (preview) and the tail (offload footer), drop the middle.
508
- const keepHead = Math.floor(MAX_REHYDRATED_OFFLOAD_TEXT * 0.7);
509
- const keepTail = MAX_REHYDRATED_OFFLOAD_TEXT - keepHead;
510
- const omitted = block.text.length - keepHead - keepTail;
511
- return {
512
- ...block,
513
- text: block.text.slice(0, keepHead) +
514
- `\n\n[... ${omitted.toLocaleString()} bytes omitted from rehydrated offload preview ...]\n\n` +
515
- block.text.slice(block.text.length - keepTail),
516
- };
517
- }
518
- if (block.text.length <= MAX_REHYDRATED_TEXT)
519
- return block;
520
- const omitted = block.text.length - MAX_REHYDRATED_TEXT;
521
- return {
522
- ...block,
523
- text: block.text.slice(0, MAX_REHYDRATED_TEXT) +
524
- `\n\n[truncated — ${omitted.toLocaleString()} bytes omitted]`,
525
- };
526
- }
527
- function normalizeSnapshotDetails(details) {
528
- if (details.version === 4)
529
- return details;
530
- return {
531
- type: "observational-memory",
532
- version: 4,
533
- observations: details.observations,
534
- reflections: details.reflections,
535
- };
536
- }
537
- function toRestoredMemorySnapshot(snapshot) {
538
- return {
539
- type: "observational-memory-snapshot",
540
- version: 1,
541
- coveredSourceCount: snapshot.coveredSourceCount,
542
- summary: snapshot.summary,
543
- details: normalizeSnapshotDetails(snapshot.details),
544
- };
545
- }
546
161
  /**
547
162
  * Inactivity-based prompt hang watchdog. Unlike a fixed wall-clock deadline,
548
163
  * this only fires when the agent session has emitted NO *meaningful* progress
@@ -655,6 +270,13 @@ export class AgentBridge {
655
270
  * timer flushes it once the minimum interval has elapsed.
656
271
  */
657
272
  subagentProgressThrottle = new Map();
273
+ /**
274
+ * toolCallId → startedAt captured at `tool_execution_start` so the
275
+ * terminal `tool_result` can carry the real start time (durations
276
+ * end-to-end). Entries with no end event are bounded: more than 2000
277
+ * orphans means ids are never resolving, so the oldest are cleared.
278
+ */
279
+ toolStartedAt = new Map();
658
280
  constructor(opts) {
659
281
  this.opts = opts;
660
282
  }
@@ -708,6 +330,14 @@ export class AgentBridge {
708
330
  async (ext) => {
709
331
  designerExtension(ext);
710
332
  },
333
+ // Logic trace: keeps the ONE logic.aexol file in the bound Studio
334
+ // project refreshed the same way observations are (turn_end +
335
+ // threshold + singleton + passive). Registered BEFORE
336
+ // observationalMemory so its forced session_before_compact flush runs
337
+ // before the memory compaction hook produces the summary.
338
+ async (ext) => {
339
+ logicTraceExtension(ext);
340
+ },
711
341
  async (ext) => {
712
342
  observationalMemory(ext);
713
343
  },
@@ -1957,13 +1587,25 @@ export class AgentBridge {
1957
1587
  };
1958
1588
  this.emitAndBuffer(se);
1959
1589
  }
1590
+ // pi agent events carry no timestamps; Date.now() at emit time is
1591
+ // the same source the subagent tool-progress path uses.
1592
+ const startedAt = Date.now();
1960
1593
  this.emitAndBuffer({
1961
1594
  type: "tool_call",
1962
1595
  messageId: this.pending?.messageId ?? "",
1963
1596
  id: ev.toolCallId,
1964
1597
  name: ev.toolName,
1965
1598
  args: ev.args,
1599
+ startedAt,
1966
1600
  });
1601
+ // Persist the same start stamp so the terminal `tool_result` below
1602
+ // can echo it (the wire schema declares `tool_result.startedAt`).
1603
+ this.toolStartedAt.set(ev.toolCallId, startedAt);
1604
+ if (this.toolStartedAt.size > 2000) {
1605
+ const oldest = this.toolStartedAt.keys().next().value;
1606
+ if (oldest !== undefined)
1607
+ this.toolStartedAt.delete(oldest);
1608
+ }
1967
1609
  return;
1968
1610
  }
1969
1611
  case "tool_execution_update": {
@@ -2127,7 +1769,10 @@ export class AgentBridge {
2127
1769
  id: ev.toolCallId,
2128
1770
  result: ev.result,
2129
1771
  isError: ev.isError,
1772
+ startedAt: this.toolStartedAt.get(ev.toolCallId) ?? Date.now(),
1773
+ finishedAt: Date.now(),
2130
1774
  });
1775
+ this.toolStartedAt.delete(ev.toolCallId);
2131
1776
  return;
2132
1777
  }
2133
1778
  case "message_end": {
@@ -2327,87 +1972,3 @@ export class AgentBridge {
2327
1972
  }
2328
1973
  }
2329
1974
  }
2330
- // ---------------------------------------------------------------------------
2331
- // Headless UI context
2332
- // ---------------------------------------------------------------------------
2333
- /**
2334
- * Detect the memory subsystem from a notification message text.
2335
- * The memory extension prefixes all messages with "Observational memory:".
2336
- */
2337
- function detectMemorySystem(message) {
2338
- if (!message.startsWith("Observational memory:"))
2339
- return undefined;
2340
- const lower = message.toLowerCase();
2341
- if (lower.includes("observer"))
2342
- return "memory_observer";
2343
- if (lower.includes("compaction") || lower.includes("compact"))
2344
- return "memory_compaction";
2345
- if (lower.includes("reflection") || lower.includes("reflect"))
2346
- return "memory_reflection";
2347
- if (lower.includes("pruner") || lower.includes("prune"))
2348
- return "memory_pruner";
2349
- // Keep generic observational-memory messages visible in the landing badge.
2350
- return "memory_observer";
2351
- }
2352
- /**
2353
- * Detect subsystem from notification messages by known prefix.
2354
- * Returns undefined for generic extension messages without a matching prefix.
2355
- */
2356
- function detectNotifSystem(message) {
2357
- if (message.startsWith("[spectral-vision]"))
2358
- return "vision";
2359
- return detectMemorySystem(message);
2360
- }
2361
- /**
2362
- * Create a minimal ExtensionUIContext that forwards `notify()` calls as
2363
- * `agent_notification` wire events, and renders `confirm()` as a terminal-
2364
- * native permission prompt on serve's stdout (the terminal `spectral serve`
2365
- * runs in) so extensions like desktop-control can request real user approval
2366
- * while the user chats via the web UI. A prompt also emits an
2367
- * `agent_notification` ("Approval required in terminal: …") so web users know
2368
- * to look at the terminal. Confirmations are serialized across sessions and
2369
- * auto-deny on timeout (SPECTRAL_CONFIRM_TIMEOUT_MS, default 5 min) or when
2370
- * stdin is not a TTY. All other interactive UI methods (select/input/custom/
2371
- * editor) remain no-ops resolving `undefined`.
2372
- */
2373
- function createHeadlessUIContext(emit) {
2374
- const terminalIO = createStdinConfirmIO();
2375
- // Defer to a Proxy so we don't need to stub every method.
2376
- // `notify` and `confirm` are the methods called by extensions in serve mode
2377
- // (observational memory, MCP status bar updates, spectral-vision,
2378
- // desktop-control).
2379
- const handler = {
2380
- get(_target, prop) {
2381
- if (prop === "notify") {
2382
- return (message, type, metadata) => {
2383
- const level = type ?? "info";
2384
- const system = detectNotifSystem(message);
2385
- if (system?.startsWith("memory_")) {
2386
- console.info(`[AgentBridge][memory][${level}] ${message}`);
2387
- }
2388
- else if (system === "vision") {
2389
- console.info(`[AgentBridge][vision][${level}] ${message}`);
2390
- }
2391
- emit({
2392
- type: "agent_notification",
2393
- message,
2394
- level,
2395
- system,
2396
- dcpLiteTelemetry: metadata?.dcpLiteTelemetry,
2397
- });
2398
- };
2399
- }
2400
- // All other methods: return a no-op function or undefined.
2401
- // Methods that return Promises (select, confirm, input, custom, editor)
2402
- if (prop === "confirm") {
2403
- return createBridgeConfirm(emit, terminalIO);
2404
- }
2405
- // resolve to `undefined`. `confirm` above is the one interactive method
2406
- // with a real terminal-native implementation.
2407
- // Methods that set state (setStatus, setWorkingMessage, setWidget, etc.)
2408
- // are safe to no-op.
2409
- return () => undefined;
2410
- },
2411
- };
2412
- return new Proxy({}, handler);
2413
- }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Pure helpers for compaction_end events and CompactionResult handling.
3
+ * Bodies moved verbatim from `session-stream.ts`.
4
+ */
5
+ import type { CompactionResult } from "../../sdk/coding-agent/index.js";
6
+ import type { ServerEvent } from "../wire.js";
7
+ export declare function formatCompactionTokenStats(event: Extract<ServerEvent, {
8
+ type: "compaction_end";
9
+ }>): string;
10
+ export declare function isSkippedCompactionResult(result: CompactionResult | void): result is CompactionResult & {
11
+ skipped: true;
12
+ };
13
+ //# sourceMappingURL=compaction-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compaction-events.d.ts","sourceRoot":"","sources":["../../../src/server/session-stream/compaction-events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,GACtD,MAAM,CAiCR;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,MAAM,IAAI,gBAAgB,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAIhD"}
@@ -0,0 +1,32 @@
1
+ export function formatCompactionTokenStats(event) {
2
+ const parts = [];
3
+ if (typeof event.compactionNumber === "number") {
4
+ parts.push(`compaction #${event.compactionNumber.toLocaleString()}`);
5
+ }
6
+ if (typeof event.tokensBefore === "number") {
7
+ parts.push(`from ~${event.tokensBefore.toLocaleString()} tokens`);
8
+ }
9
+ if (typeof event.tokensCompacted === "number") {
10
+ parts.push(`compacted ~${event.tokensCompacted.toLocaleString()} tokens`);
11
+ }
12
+ if (typeof event.tokensRemoved === "number") {
13
+ parts.push(`removed ~${event.tokensRemoved.toLocaleString()} tokens`);
14
+ }
15
+ if (typeof event.summaryTokens === "number") {
16
+ parts.push(`summary +~${event.summaryTokens.toLocaleString()} tokens`);
17
+ }
18
+ if (typeof event.reductionPercent === "number") {
19
+ parts.push(`reduction ~${event.reductionPercent.toLocaleString(undefined, { maximumFractionDigits: 2 })}%`);
20
+ }
21
+ if (event.largestTokenSources?.length) {
22
+ const sources = event.largestTokenSources
23
+ .slice(0, 3)
24
+ .map((bucket) => `${bucket.type}:${bucket.name} ~${bucket.tokens.toLocaleString()}`)
25
+ .join("; ");
26
+ parts.push(`largest sources ${sources}`);
27
+ }
28
+ return parts.length > 0 ? ` (${parts.join(", ")})` : "";
29
+ }
30
+ export function isSkippedCompactionResult(result) {
31
+ return Boolean(result && typeof result === "object" && result.skipped === true);
32
+ }