openfox 2.0.0-beta.4 → 2.0.0-beta.6

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 (50) hide show
  1. package/dist/{chat-handler-IUWEBZG7.js → chat-handler-27FY5TEH.js} +15 -29
  2. package/dist/{chunk-WBYS7AQN.js → chunk-3FFHHYWP.js} +178 -99
  3. package/dist/{chunk-HGAMIPFO.js → chunk-7FDY3EOH.js} +18 -176
  4. package/dist/{chunk-CEZNMLOO.js → chunk-7TTEGAO6.js} +12 -13
  5. package/dist/{chunk-FQLK5GL5.js → chunk-BVHFMAVN.js} +1 -1
  6. package/dist/{chunk-HW3U4XSZ.js → chunk-CDDMHSZF.js} +4 -4
  7. package/dist/{chunk-HHAJ3QF6.js → chunk-EMJGF3A7.js} +9 -24
  8. package/dist/{chunk-KEF4O3UM.js → chunk-FRCLNAE2.js} +2952 -3256
  9. package/dist/{chunk-RF2JGDSS.js → chunk-IGSZUXQP.js} +3 -3
  10. package/dist/{chunk-HLZV4S2I.js → chunk-NPHYEUYE.js} +127 -35
  11. package/dist/{chunk-NNEHZT3V.js → chunk-QUSUEN5R.js} +3 -3
  12. package/dist/{chunk-EYCCASW3.js → chunk-R3EK3ODJ.js} +6 -6
  13. package/dist/{chunk-7IKUIYFZ.js → chunk-RBJ25FIR.js} +135 -147
  14. package/dist/{chunk-PSJIT5LZ.js → chunk-RFNEDBVO.js} +4 -4
  15. package/dist/chunk-RI6GAMNP.js +13 -0
  16. package/dist/{chunk-26DZZZDC.js → chunk-XJEOP6XU.js} +5 -11
  17. package/dist/cli/dev.js +1 -1
  18. package/dist/cli/index.js +1 -1
  19. package/dist/compactor-TDNRM3A7.js +9 -0
  20. package/dist/{config-YU7NYZYG.js → config-VBBMTXJZ.js} +5 -6
  21. package/dist/{events-YO52472Q.js → events-PQ3KTI5H.js} +8 -8
  22. package/dist/{folding-K5L6M4WK.js → folding-CXORTBAU.js} +2 -3
  23. package/dist/{orchestrator-F75DNQKQ.js → orchestrator-QDCVUBCL.js} +18 -23
  24. package/dist/package.json +1 -1
  25. package/dist/{processor-FTEASNGS.js → processor-K4B7QRO2.js} +8 -10
  26. package/dist/{protocol-K62EPEGS.js → protocol-CN24IKQN.js} +3 -5
  27. package/dist/{protocol-BQ12Aw5J.d.ts → protocol-De-Pzgry.d.ts} +12 -38
  28. package/dist/{provider-HTJEB3ON.js → provider-NRWSSO55.js} +9 -10
  29. package/dist/{serve-CEQ2QMM5.js → serve-J6EM3G6N.js} +25 -27
  30. package/dist/server/index.d.ts +1 -6
  31. package/dist/server/index.js +15 -17
  32. package/dist/{settings-VRAOAPLA.js → settings-6XX56F3F.js} +2 -2
  33. package/dist/shared/index.d.ts +2 -2
  34. package/dist/shared/index.js +1 -1
  35. package/dist/{tools-OPEU2E5M.js → tools-GCANYSB7.js} +12 -15
  36. package/dist/web/assets/{index-bDyDeCAz.css → index-aa3jRAZ9.css} +2 -2
  37. package/dist/web/assets/index-ntDiC8b_.js +299 -0
  38. package/dist/web/index.html +2 -2
  39. package/dist/web/sw.js +1 -1
  40. package/dist/workflow-defaults/default.workflow.json +3 -3
  41. package/package.json +1 -1
  42. package/dist/auto-compaction-A3PIMGLF.js +0 -28
  43. package/dist/chunk-CGZHLM3K.js +0 -70
  44. package/dist/chunk-MCPID4EJ.js +0 -28
  45. package/dist/chunk-SZKEGZIB.js +0 -140
  46. package/dist/optimize-storage-2N6BY5KZ.js +0 -7
  47. package/dist/runtime-config-NPSPMRDA.js +0 -9
  48. package/dist/vision-fallback-3MIZZ6NQ.js +0 -22
  49. package/dist/web/assets/index-ZTEHxmVW.js +0 -317
  50. /package/dist/web/{workbox-7fc22fbe.js → workbox-8c29f6e4.js} +0 -0
@@ -1,57 +1,78 @@
1
1
  import {
2
- BUILDER_KICKOFF_PROMPT,
3
2
  PathAccessDeniedError,
4
3
  TurnMetrics,
5
- VERIFIER_KICKOFF_PROMPT,
4
+ WORKFLOW_KICKOFF_PROMPT,
6
5
  assembleAgentRequest,
7
6
  buildAgentReminder,
7
+ createAssemblyResult,
8
8
  createChatDoneEvent,
9
9
  createMessageStartEvent,
10
- executeSubAgent,
11
10
  findAgentById,
11
+ getAllInstructions,
12
+ getConversationMessages,
13
+ getEnabledSkillMetadata,
12
14
  getSubAgents,
13
15
  getToolRegistryForAgent,
14
16
  loadAllAgentsDefault,
17
+ processEventsForConversation,
15
18
  runTopLevelAgentLoop
16
- } from "./chunk-KEF4O3UM.js";
19
+ } from "./chunk-FRCLNAE2.js";
17
20
  import {
18
21
  getCurrentContextWindowId,
19
- getEventStore
20
- } from "./chunk-HLZV4S2I.js";
22
+ getCurrentWindowMessageOptions,
23
+ getEventStore,
24
+ getRuntimeConfig
25
+ } from "./chunk-NPHYEUYE.js";
21
26
  import {
22
27
  buildSnapshotFromSessionState
23
- } from "./chunk-26DZZZDC.js";
28
+ } from "./chunk-XJEOP6XU.js";
24
29
  import {
25
30
  logger
26
31
  } from "./chunk-K44MW7JJ.js";
32
+ import {
33
+ getGlobalConfigDir
34
+ } from "./chunk-CQGTEGKL.js";
27
35
 
28
- // src/server/sub-agents/verifier-helpers.ts
29
- var MAX_CONSECUTIVE_VERIFIER_NUDGES = 10;
30
- var VERIFIER_STALL_REASON = "Verifier stopped repeatedly before terminalizing verification after repeated nudges.";
31
- function getCriteriaAwaitingVerification(criteria) {
32
- return criteria.filter((criterion) => criterion.status.type === "completed");
33
- }
34
- function buildVerifierNudgeContent(criteria) {
35
- const ids = criteria.map((criterion) => criterion.id).join(", ");
36
- return `You stopped before finalizing verification. ${criteria.length} criteria still need a terminal verification result. Use criterion with action "pass" or "fail" for each remaining criterion: ${ids}.`;
37
- }
38
- function buildVerifierRestartContent(criteria) {
39
- const ids = criteria.map((criterion) => criterion.id).join(", ");
40
- return `${VERIFIER_STALL_REASON} Leaving remaining criteria unchanged so verification can restart in a fresh window: ${ids}.`;
41
- }
42
- function createVerifierNudgeConfig() {
43
- return {
44
- maxConsecutiveNudges: MAX_CONSECUTIVE_VERIFIER_NUDGES,
45
- getCriteriaAwaiting: getCriteriaAwaitingVerification,
46
- buildNudgeContent: buildVerifierNudgeContent,
47
- buildRestartContent: buildVerifierRestartContent
48
- };
36
+ // src/server/chat/dynamic-context.ts
37
+ import { createHash } from "crypto";
38
+ function computeDynamicContextHash(instructionContent, skills) {
39
+ const dynamicInputs = JSON.stringify({
40
+ instructions: instructionContent,
41
+ skills: skills.map((s) => s.id).sort()
42
+ });
43
+ return createHash("sha256").update(dynamicInputs).digest("hex");
49
44
  }
50
45
 
51
46
  // src/server/chat/orchestrator.ts
52
- function getCurrentWindowMessageOptions(sessionId) {
53
- const contextWindowId = getCurrentContextWindowId(sessionId);
54
- return contextWindowId ? { contextWindowId } : void 0;
47
+ async function buildRetryPatterns() {
48
+ const { getSetting, SETTINGS_KEYS } = await import("./settings-6XX56F3F.js");
49
+ const raw = getSetting(SETTINGS_KEYS.RETRY_PATTERNS);
50
+ if (!raw) {
51
+ const oldXmlProtection = getSetting("llm.disableXmlProtection");
52
+ if (oldXmlProtection !== null) {
53
+ const disabled = oldXmlProtection === "true";
54
+ return {
55
+ retryPatterns: disabled ? [] : [{ field: "both", pattern: "<(tool_call|function=|/tool_call|parameter=)", action: "retry", active: true }],
56
+ maxRetriesPerTurn: 10
57
+ };
58
+ }
59
+ return { retryPatterns: [], maxRetriesPerTurn: 10 };
60
+ }
61
+ try {
62
+ const parsed = JSON.parse(raw);
63
+ return {
64
+ retryPatterns: Array.isArray(parsed.patterns) ? parsed.patterns : [],
65
+ maxRetriesPerTurn: typeof parsed.maxRetriesPerTurn === "number" ? parsed.maxRetriesPerTurn : 10
66
+ };
67
+ } catch {
68
+ return { retryPatterns: [], maxRetriesPerTurn: 10 };
69
+ }
70
+ }
71
+ function buildGetConversationMessages(sessionId, llmClient, append) {
72
+ return async () => {
73
+ const processedEvents = await processEventsForConversation(sessionId, llmClient, (event) => append(event));
74
+ return getConversationMessages({ type: "toplevel", sessionId }, { events: processedEvents });
75
+ };
55
76
  }
56
77
  function resolveStatsIdentity(options) {
57
78
  const model = options.llmClient.getModel();
@@ -75,13 +96,11 @@ async function runChatTurn(options) {
75
96
  const session = sessionManager.requireSession(sessionId);
76
97
  const mode = session.mode;
77
98
  logger.debug("Starting chat turn", { sessionId, mode });
99
+ sessionManager.setRunning(sessionId, true);
100
+ const append = (event) => eventStore.append(sessionId, event);
78
101
  const turnMetrics = new TurnMetrics();
79
102
  try {
80
- if (mode === "builder") {
81
- await runBuilderTurn(options, turnMetrics);
82
- } else {
83
- await runGenericAgentTurn(options, turnMetrics, mode);
84
- }
103
+ await runAgentTurn(options, turnMetrics, mode, append);
85
104
  const snapshot = buildSnapshot(sessionManager, sessionId, turnMetrics.buildStats(statsIdentity, mode));
86
105
  const snapshotEvent = eventStore.append(sessionId, { type: "turn.snapshot", data: snapshot });
87
106
  const deletedCount = eventStore.cleanupOldEvents(sessionId);
@@ -147,18 +166,30 @@ async function runChatTurn(options) {
147
166
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
148
167
  }
149
168
  }
169
+ function windowHasReminder(sessionId, windowId) {
170
+ const eventStore = getEventStore();
171
+ const events = eventStore.getEvents(sessionId);
172
+ return events.some((event) => {
173
+ if (event.type !== "message.start") return false;
174
+ const data = event.data;
175
+ return data.contextWindowId === windowId && data.messageKind === "auto-prompt" && typeof data.content === "string" && data.content.includes("<system-reminder>");
176
+ });
177
+ }
150
178
  function injectModeReminderIfNeeded(sessionManager, sessionId, agentId, allAgents, _onMessage) {
151
179
  const eventStore = getEventStore();
152
180
  const session = sessionManager.requireSession(sessionId);
181
+ const currentWindowId = getCurrentContextWindowId(sessionId);
153
182
  const lastModeReminder = session.executionState?.lastModeWithReminder;
154
183
  if (lastModeReminder === agentId) {
155
- return;
184
+ if (!currentWindowId || windowHasReminder(sessionId, currentWindowId)) {
185
+ return;
186
+ }
156
187
  }
157
188
  const agentDef = findAgentById(agentId, allAgents);
158
189
  if (!agentDef) return;
159
190
  const reminderContent = buildAgentReminder(agentDef);
160
191
  const reminderMsgId = crypto.randomUUID();
161
- const currentWindowMessageOptions = getCurrentContextWindowId(sessionId) ? { contextWindowId: getCurrentContextWindowId(sessionId) } : void 0;
192
+ const currentWindowMessageOptions = currentWindowId ? { contextWindowId: currentWindowId } : void 0;
162
193
  eventStore.append(sessionId, {
163
194
  type: "message.start",
164
195
  data: {
@@ -183,130 +214,88 @@ function injectModeReminderIfNeeded(sessionManager, sessionId, agentId, allAgent
183
214
  lastModeWithReminder: agentId
184
215
  });
185
216
  }
186
- async function runGenericAgentTurn(options, turnMetrics, agentId) {
217
+ async function runAgentTurn(options, turnMetrics, agentId, append, callbacks) {
187
218
  const statsIdentity = resolveStatsIdentity(options);
188
219
  const allAgents = await loadAllAgentsDefault();
189
220
  injectModeReminderIfNeeded(options.sessionManager, options.sessionId, agentId, allAgents, options.onMessage);
190
221
  const agentDef = findAgentById(agentId, allAgents) ?? findAgentById("planner", allAgents);
191
222
  const subAgentDefs = getSubAgents(allAgents);
192
- await runTopLevelAgentLoop(
223
+ const { content: instructionContent } = await getAllInstructions(
224
+ options.sessionManager.requireSession(options.sessionId).workdir,
225
+ options.sessionManager.requireSession(options.sessionId).projectId
226
+ );
227
+ const runtimeConfig = getRuntimeConfig();
228
+ const configDir = getGlobalConfigDir(runtimeConfig.mode ?? "production");
229
+ const skills = await getEnabledSkillMetadata(configDir, runtimeConfig.workdir);
230
+ return runTopLevelAgentLoop(
193
231
  {
194
232
  mode: agentId,
233
+ append,
234
+ ...await buildRetryPatterns(),
195
235
  sessionManager: options.sessionManager,
196
236
  sessionId: options.sessionId,
197
237
  llmClient: options.llmClient,
198
238
  statsIdentity,
199
239
  signal: options.signal,
200
240
  onMessage: options.onMessage,
201
- assembleRequest: (input) => assembleAgentRequest({ ...input, agentDef, subAgentDefs, modelName: options.llmClient.getModel() }),
202
- getToolRegistry: () => getToolRegistryForAgent(agentDef)
203
- },
204
- turnMetrics
205
- );
206
- }
207
- function filterToolRegistryForStepDone(baseRegistry, _injectStepDone) {
208
- return baseRegistry;
209
- }
210
- async function runBuilderTurn(options, turnMetrics) {
211
- const { sessionManager, sessionId } = options;
212
- const statsIdentity = resolveStatsIdentity(options);
213
- const eventStore = getEventStore();
214
- const allAgents = await loadAllAgentsDefault();
215
- injectModeReminderIfNeeded(options.sessionManager, options.sessionId, "builder", allAgents, options.onMessage);
216
- const builderDef = findAgentById("builder", allAgents);
217
- const subAgentDefs = getSubAgents(allAgents);
218
- let stepDoneCalled = false;
219
- return {
220
- ...await runTopLevelAgentLoop(
221
- {
222
- mode: "builder",
223
- sessionManager,
224
- sessionId,
225
- llmClient: options.llmClient,
226
- statsIdentity,
227
- signal: options.signal,
228
- onMessage: options.onMessage,
229
- assembleRequest: (input) => assembleAgentRequest({
230
- ...input,
231
- agentDef: builderDef,
232
- subAgentDefs,
233
- modelName: options.llmClient.getModel()
234
- }),
235
- getToolRegistry: () => {
236
- const baseRegistry = getToolRegistryForAgent(builderDef);
237
- return filterToolRegistryForStepDone(baseRegistry, options.injectStepDone === true);
238
- },
239
- onToolExecuted: (toolCall, toolResult) => {
240
- if (toolCall.name === "step_done" && toolResult.success) {
241
- stepDoneCalled = true;
242
- }
243
- if (toolResult.success && ["write_file", "edit_file"].includes(toolCall.name)) {
244
- const path = toolCall.arguments["path"];
245
- sessionManager.addModifiedFile(sessionId, path);
241
+ assembleRequest: (input) => {
242
+ const cached = options.sessionManager.getCachedPrompt(options.sessionId);
243
+ if (cached) {
244
+ const currentHash = computeDynamicContextHash(instructionContent ?? "", skills);
245
+ if (cached.hash !== currentHash) {
246
+ options.sessionManager.setDynamicContextChanged(options.sessionId, true);
246
247
  }
247
- },
248
- injectKickoff: () => {
249
- if (options.injectBuilderKickoff !== true) return;
250
- const session = sessionManager.requireSession(sessionId);
251
- const currentWindowMessageOptions = getCurrentContextWindowId(sessionId) ? { contextWindowId: getCurrentContextWindowId(sessionId) } : void 0;
252
- const events = eventStore.getEvents(sessionId);
253
- const hasBuilderKickoff = events.some((e) => {
254
- if (e.type !== "message.start") return false;
255
- const data = e.data;
256
- return data.messageKind === "auto-prompt" && data.content?.includes("fulfil the");
248
+ return createAssemblyResult({
249
+ systemPrompt: cached.systemPrompt,
250
+ messages: input.messages,
251
+ injectedFiles: input.injectedFiles,
252
+ requestTools: input.promptTools,
253
+ toolChoice: input.toolChoice,
254
+ disableThinking: false
257
255
  });
258
- if (!hasBuilderKickoff) {
259
- const kickoffMsgId = crypto.randomUUID();
260
- const kickoffContent = BUILDER_KICKOFF_PROMPT(session.criteria.length);
261
- const msgMetadata = { type: "workflow", name: "Workflow", color: "#f59e0b" };
262
- eventStore.append(
263
- sessionId,
264
- createMessageStartEvent(kickoffMsgId, "user", kickoffContent, {
265
- ...currentWindowMessageOptions ?? {},
266
- isSystemGenerated: true,
267
- messageKind: "auto-prompt",
268
- metadata: msgMetadata
269
- })
270
- );
271
- eventStore.append(sessionId, { type: "message.done", data: { messageId: kickoffMsgId } });
272
- }
273
256
  }
257
+ const result = assembleAgentRequest({
258
+ ...input,
259
+ agentDef,
260
+ subAgentDefs,
261
+ modelName: options.llmClient.getModel()
262
+ });
263
+ const hash = computeDynamicContextHash(instructionContent ?? "", skills);
264
+ options.sessionManager.setCachedPrompt(options.sessionId, result.systemPrompt, hash);
265
+ return result;
274
266
  },
275
- turnMetrics
276
- ),
277
- stepDoneCalled
278
- };
267
+ getToolRegistry: () => getToolRegistryForAgent(agentDef),
268
+ getConversationMessages: buildGetConversationMessages(options.sessionId, options.llmClient, append),
269
+ injectModeReminder: () => injectModeReminderIfNeeded(options.sessionManager, options.sessionId, agentId, allAgents, options.onMessage),
270
+ ...callbacks?.injectKickoff ? { injectKickoff: callbacks.injectKickoff } : {},
271
+ ...callbacks?.onToolExecuted ? { onToolExecuted: callbacks.onToolExecuted } : {}
272
+ },
273
+ turnMetrics
274
+ );
279
275
  }
280
- async function runVerifierTurn(options, turnMetrics) {
281
- const { sessionManager, sessionId, llmClient, signal, onMessage } = options;
282
- const statsIdentity = resolveStatsIdentity(options);
276
+ function injectWorkflowKickoffIfNeeded(sessionManager, sessionId, eventStore) {
283
277
  const session = sessionManager.requireSession(sessionId);
284
- const toVerify = session.criteria.filter((c) => c.status.type === "completed");
285
- if (toVerify.length === 0) {
286
- logger.debug("Nothing to verify", { sessionId });
287
- return { allPassed: true, failed: [] };
288
- }
289
- const allAgents = await loadAllAgentsDefault();
290
- const verifierDef = findAgentById("verifier", allAgents);
291
- const toolRegistry = getToolRegistryForAgent(verifierDef);
292
- const result = await executeSubAgent({
293
- subAgentType: "verifier",
294
- prompt: VERIFIER_KICKOFF_PROMPT,
295
- sessionManager,
296
- sessionId,
297
- llmClient,
298
- toolRegistry,
299
- turnMetrics,
300
- statsIdentity,
301
- signal,
302
- onMessage,
303
- nudgeConfig: createVerifierNudgeConfig()
278
+ const currentWindowMessageOptions = getCurrentContextWindowId(sessionId) ? { contextWindowId: getCurrentContextWindowId(sessionId) } : void 0;
279
+ const events = eventStore.getEvents(sessionId);
280
+ const hasKickoff = events.some((e) => {
281
+ if (e.type !== "message.start") return false;
282
+ const data = e.data;
283
+ return data.messageKind === "auto-prompt" && data.content?.includes("fulfil the");
304
284
  });
305
- return {
306
- allPassed: result.allPassed ?? true,
307
- failed: result.failed ?? [],
308
- content: result.content
309
- };
285
+ if (!hasKickoff) {
286
+ const kickoffMsgId = crypto.randomUUID();
287
+ const kickoffContent = WORKFLOW_KICKOFF_PROMPT(session.criteria.length);
288
+ eventStore.append(
289
+ sessionId,
290
+ createMessageStartEvent(kickoffMsgId, "user", kickoffContent, {
291
+ ...currentWindowMessageOptions ?? {},
292
+ isSystemGenerated: true,
293
+ messageKind: "auto-prompt",
294
+ metadata: { type: "workflow", name: "Workflow", color: "#f59e0b" }
295
+ })
296
+ );
297
+ eventStore.append(sessionId, { type: "message.done", data: { messageId: kickoffMsgId } });
298
+ }
310
299
  }
311
300
  function buildSnapshot(sessionManager, sessionId, _lastStats) {
312
301
  const eventStore = getEventStore();
@@ -323,10 +312,9 @@ function buildSnapshot(sessionManager, sessionId, _lastStats) {
323
312
  }
324
313
 
325
314
  export {
326
- createVerifierNudgeConfig,
315
+ computeDynamicContextHash,
327
316
  runChatTurn,
328
- filterToolRegistryForStepDone,
329
- runBuilderTurn,
330
- runVerifierTurn
317
+ runAgentTurn,
318
+ injectWorkflowKickoffIfNeeded
331
319
  };
332
- //# sourceMappingURL=chunk-7IKUIYFZ.js.map
320
+ //# sourceMappingURL=chunk-RBJ25FIR.js.map
@@ -15,9 +15,9 @@ var SETTINGS_KEYS = {
15
15
  DISPLAY_USER_PRESETS: "display.userPresets",
16
16
  DISPLAY_FOLLOW_SYSTEM_THEME: "display.followSystemTheme",
17
17
  DISPLAY_SHOW_OPEN_IN_EDITOR: "display.showOpenInEditorLinks",
18
- LLM_DISABLE_XML_PROTECTION: "llm.disableXmlProtection",
19
18
  LLM_DYNAMIC_SYSTEM_PROMPT: "llm.dynamicSystemPrompt",
20
- KEYBINDINGS: "keybindings"
19
+ KEYBINDINGS: "keybindings",
20
+ RETRY_PATTERNS: "agent.retryPatterns"
21
21
  };
22
22
  var SETTINGS_DEFAULTS = {
23
23
  [SETTINGS_KEYS.DISPLAY_SHOW_THINKING]: "true",
@@ -29,8 +29,8 @@ var SETTINGS_DEFAULTS = {
29
29
  [SETTINGS_KEYS.DISPLAY_THEME]: JSON.stringify({ preset: "dark" }),
30
30
  [SETTINGS_KEYS.DISPLAY_FOLLOW_SYSTEM_THEME]: "true",
31
31
  [SETTINGS_KEYS.DISPLAY_SHOW_OPEN_IN_EDITOR]: "false",
32
- [SETTINGS_KEYS.LLM_DISABLE_XML_PROTECTION]: "false",
33
32
  [SETTINGS_KEYS.LLM_DYNAMIC_SYSTEM_PROMPT]: "false",
33
+ [SETTINGS_KEYS.RETRY_PATTERNS]: JSON.stringify({ patterns: [], maxRetriesPerTurn: 10 }),
34
34
  [SETTINGS_KEYS.KEYBINDINGS]: JSON.stringify({
35
35
  terminalToggle: { type: "double-press", key: "Control", threshold: 300 },
36
36
  quickAction: { type: "double-press", key: "Shift", threshold: 300 },
@@ -88,4 +88,4 @@ export {
88
88
  deleteSetting,
89
89
  getAllSettings
90
90
  };
91
- //# sourceMappingURL=chunk-PSJIT5LZ.js.map
91
+ //# sourceMappingURL=chunk-RFNEDBVO.js.map
@@ -0,0 +1,13 @@
1
+ // src/server/context/compactor.ts
2
+ function shouldCompact(currentTokens, maxTokens, threshold) {
3
+ return currentTokens > maxTokens * threshold;
4
+ }
5
+ function getCompactionTarget(maxTokens, targetRatio) {
6
+ return Math.floor(maxTokens * targetRatio);
7
+ }
8
+
9
+ export {
10
+ shouldCompact,
11
+ getCompactionTarget
12
+ };
13
+ //# sourceMappingURL=chunk-RI6GAMNP.js.map
@@ -1,7 +1,3 @@
1
- import {
2
- stripPromptContextMessages
3
- } from "./chunk-MCPID4EJ.js";
4
-
5
1
  // src/server/events/apply-events.ts
6
2
  function markComplete(msg, reason) {
7
3
  msg.isComplete = true;
@@ -44,7 +40,6 @@ function updateMessageDone(msg, data) {
44
40
  if (data.stats) msg.stats = data.stats;
45
41
  if (data.segments) msg.segments = data.segments;
46
42
  if (data.partial) msg.partial = true;
47
- if (data.promptContext) msg.promptContext = data.promptContext;
48
43
  if (data.tokenCount !== void 0) msg.tokenCount = data.tokenCount;
49
44
  if ("preparingToolCalls" in msg) {
50
45
  msg.preparingToolCalls = [];
@@ -139,9 +134,10 @@ function applyEvents(initialMessages, events, options) {
139
134
  }
140
135
  break;
141
136
  }
142
- case "format.retry": {
137
+ case "pattern.retry": {
143
138
  const data = event.data;
144
- for (const msg of messages.values()) {
139
+ const msg = messages.get(data.messageId);
140
+ if (msg) {
145
141
  const retries = msg.formatRetries ?? [];
146
142
  retries.push({ attempt: data.attempt, maxAttempts: data.maxAttempts, timestamp: event.timestamp });
147
143
  msg.formatRetries = retries;
@@ -246,7 +242,6 @@ function spreadOptionalMessageFields(message) {
246
242
  ...message.messageKind !== void 0 && { messageKind: message.messageKind },
247
243
  ...message.contextWindowId !== void 0 && { contextWindowId: message.contextWindowId },
248
244
  ...message.isCompactionSummary !== void 0 && { isCompactionSummary: message.isCompactionSummary },
249
- ...message.promptContext !== void 0 && { promptContext: message.promptContext },
250
245
  ...message.attachments !== void 0 && { attachments: message.attachments },
251
246
  ...message.preparingToolCalls !== void 0 && message.preparingToolCalls.length > 0 && { preparingToolCalls: message.preparingToolCalls },
252
247
  ...message.metadata !== void 0 && { metadata: message.metadata }
@@ -714,7 +709,7 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
714
709
  }
715
710
  break;
716
711
  }
717
- case "format.retry": {
712
+ case "pattern.retry": {
718
713
  const data = event.data;
719
714
  formatRetries.push({
720
715
  attempt: data.attempt,
@@ -825,7 +820,6 @@ function buildSnapshotFromSessionState(input) {
825
820
  latestSnapshotEvent.data.messages,
826
821
  events.slice(latestSnapshotIndex + 1)
827
822
  ) : foldedState.messages;
828
- stripPromptContextMessages(messages);
829
823
  return {
830
824
  mode: session.mode,
831
825
  phase: session.phase,
@@ -891,4 +885,4 @@ export {
891
885
  getMessagesForWindow,
892
886
  buildContextMessagesFromMessages
893
887
  };
894
- //# sourceMappingURL=chunk-26DZZZDC.js.map
888
+ //# sourceMappingURL=chunk-XJEOP6XU.js.map
package/dist/cli/dev.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-EYCCASW3.js";
4
+ } from "../chunk-R3EK3ODJ.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-K44MW7JJ.js";
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-EYCCASW3.js";
4
+ } from "../chunk-R3EK3ODJ.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-K44MW7JJ.js";
@@ -0,0 +1,9 @@
1
+ import {
2
+ getCompactionTarget,
3
+ shouldCompact
4
+ } from "./chunk-RI6GAMNP.js";
5
+ export {
6
+ getCompactionTarget,
7
+ shouldCompact
8
+ };
9
+ //# sourceMappingURL=compactor-TDNRM3A7.js.map
@@ -13,12 +13,11 @@ import {
13
13
  saveGlobalConfig,
14
14
  setDefaultModelSelection,
15
15
  trySmartDefaults
16
- } from "./chunk-NNEHZT3V.js";
17
- import "./chunk-HHAJ3QF6.js";
18
- import "./chunk-HGAMIPFO.js";
19
- import "./chunk-CQGTEGKL.js";
20
- import "./chunk-SZKEGZIB.js";
16
+ } from "./chunk-QUSUEN5R.js";
17
+ import "./chunk-EMJGF3A7.js";
18
+ import "./chunk-7FDY3EOH.js";
21
19
  import "./chunk-K44MW7JJ.js";
20
+ import "./chunk-CQGTEGKL.js";
22
21
  export {
23
22
  activateProvider,
24
23
  addProvider,
@@ -35,4 +34,4 @@ export {
35
34
  setDefaultModelSelection,
36
35
  trySmartDefaults
37
36
  };
38
- //# sourceMappingURL=config-YU7NYZYG.js.map
37
+ //# sourceMappingURL=config-VBBMTXJZ.js.map
@@ -10,12 +10,12 @@ import {
10
10
  emitCriteriaSet,
11
11
  emitCriterionUpdated,
12
12
  emitFileRead,
13
- emitFormatRetry,
14
13
  emitMessageDelta,
15
14
  emitMessageDone,
16
15
  emitMessageThinking,
17
16
  emitMetadataSet,
18
17
  emitModeChanged,
18
+ emitPatternRetry,
19
19
  emitPhaseChanged,
20
20
  emitRunningChanged,
21
21
  emitSessionInitialized,
@@ -28,6 +28,7 @@ import {
28
28
  emitUserMessage,
29
29
  getContextMessages,
30
30
  getCurrentContextWindowId,
31
+ getCurrentWindowMessageOptions,
31
32
  getCurrentWindowMessages,
32
33
  getEventStore,
33
34
  getReadFilesCache,
@@ -38,8 +39,7 @@ import {
38
39
  isStoredEvent,
39
40
  isTurnEvent,
40
41
  truncateSessionMessages
41
- } from "./chunk-HLZV4S2I.js";
42
- import "./chunk-FBGWG4N6.js";
42
+ } from "./chunk-NPHYEUYE.js";
43
43
  import {
44
44
  buildContextMessagesFromEventHistory,
45
45
  buildContextMessagesFromMessages,
@@ -56,9 +56,8 @@ import {
56
56
  foldTodos,
57
57
  foldTurnEventsToSnapshotMessages,
58
58
  getMessagesForWindow
59
- } from "./chunk-26DZZZDC.js";
60
- import "./chunk-MCPID4EJ.js";
61
- import "./chunk-CGZHLM3K.js";
59
+ } from "./chunk-XJEOP6XU.js";
60
+ import "./chunk-FBGWG4N6.js";
62
61
  import "./chunk-K44MW7JJ.js";
63
62
  export {
64
63
  EventStore,
@@ -78,12 +77,12 @@ export {
78
77
  emitCriteriaSet,
79
78
  emitCriterionUpdated,
80
79
  emitFileRead,
81
- emitFormatRetry,
82
80
  emitMessageDelta,
83
81
  emitMessageDone,
84
82
  emitMessageThinking,
85
83
  emitMetadataSet,
86
84
  emitModeChanged,
85
+ emitPatternRetry,
87
86
  emitPhaseChanged,
88
87
  emitRunningChanged,
89
88
  emitSessionInitialized,
@@ -104,6 +103,7 @@ export {
104
103
  foldTurnEventsToSnapshotMessages,
105
104
  getContextMessages,
106
105
  getCurrentContextWindowId,
106
+ getCurrentWindowMessageOptions,
107
107
  getCurrentWindowMessages,
108
108
  getEventStore,
109
109
  getMessagesForWindow,
@@ -116,4 +116,4 @@ export {
116
116
  isTurnEvent,
117
117
  truncateSessionMessages
118
118
  };
119
- //# sourceMappingURL=events-YO52472Q.js.map
119
+ //# sourceMappingURL=events-PQ3KTI5H.js.map
@@ -23,8 +23,7 @@ import {
23
23
  handleToolResult,
24
24
  spreadOptionalMessageFields,
25
25
  stripOrphanedToolCalls
26
- } from "./chunk-26DZZZDC.js";
27
- import "./chunk-MCPID4EJ.js";
26
+ } from "./chunk-XJEOP6XU.js";
28
27
  export {
29
28
  buildContextMessagesFromEventHistory,
30
29
  buildContextMessagesFromMessages,
@@ -51,4 +50,4 @@ export {
51
50
  spreadOptionalMessageFields,
52
51
  stripOrphanedToolCalls
53
52
  };
54
- //# sourceMappingURL=folding-K5L6M4WK.js.map
53
+ //# sourceMappingURL=folding-CXORTBAU.js.map
@@ -1,9 +1,8 @@
1
1
  import {
2
- filterToolRegistryForStepDone,
3
- runBuilderTurn,
4
- runChatTurn,
5
- runVerifierTurn
6
- } from "./chunk-7IKUIYFZ.js";
2
+ injectWorkflowKickoffIfNeeded,
3
+ runAgentTurn,
4
+ runChatTurn
5
+ } from "./chunk-RBJ25FIR.js";
7
6
  import {
8
7
  TurnMetrics,
9
8
  createChatDoneEvent,
@@ -11,24 +10,21 @@ import {
11
10
  createMessageStartEvent,
12
11
  createToolCallEvent,
13
12
  createToolResultEvent
14
- } from "./chunk-KEF4O3UM.js";
15
- import "./chunk-BJYPTN5S.js";
16
- import "./chunk-PSJIT5LZ.js";
17
- import "./chunk-XAMAYRDA.js";
13
+ } from "./chunk-FRCLNAE2.js";
18
14
  import "./chunk-DL6ZILAF.js";
19
15
  import "./chunk-PBGOZMVY.js";
20
16
  import "./chunk-VRGRAQDG.js";
21
- import "./chunk-HGAMIPFO.js";
22
- import "./chunk-HLZV4S2I.js";
17
+ import "./chunk-NPHYEUYE.js";
18
+ import "./chunk-XJEOP6XU.js";
19
+ import "./chunk-7TTEGAO6.js";
20
+ import "./chunk-BJYPTN5S.js";
21
+ import "./chunk-RFNEDBVO.js";
22
+ import "./chunk-XAMAYRDA.js";
23
23
  import "./chunk-FBGWG4N6.js";
24
- import "./chunk-26DZZZDC.js";
25
- import "./chunk-MCPID4EJ.js";
26
- import "./chunk-CEZNMLOO.js";
27
- import "./chunk-FQLK5GL5.js";
28
- import "./chunk-CQGTEGKL.js";
29
- import "./chunk-CGZHLM3K.js";
30
- import "./chunk-SZKEGZIB.js";
24
+ import "./chunk-BVHFMAVN.js";
25
+ import "./chunk-7FDY3EOH.js";
31
26
  import "./chunk-K44MW7JJ.js";
27
+ import "./chunk-CQGTEGKL.js";
32
28
  export {
33
29
  TurnMetrics,
34
30
  createChatDoneEvent,
@@ -36,9 +32,8 @@ export {
36
32
  createMessageStartEvent,
37
33
  createToolCallEvent,
38
34
  createToolResultEvent,
39
- filterToolRegistryForStepDone,
40
- runBuilderTurn,
41
- runChatTurn,
42
- runVerifierTurn
35
+ injectWorkflowKickoffIfNeeded,
36
+ runAgentTurn,
37
+ runChatTurn
43
38
  };
44
- //# sourceMappingURL=orchestrator-F75DNQKQ.js.map
39
+ //# sourceMappingURL=orchestrator-QDCVUBCL.js.map