openfox 2.0.0-beta.1 → 2.0.0-beta.11

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 (49) hide show
  1. package/dist/agent-defaults/code-reviewer.agent.md +2 -1
  2. package/dist/{chat-handler-IVIWOR3D.js → chat-handler-NMJCOCCB.js} +14 -27
  3. package/dist/{chunk-ZLUBZ4K4.js → chunk-4RLDN2LL.js} +222 -106
  4. package/dist/{chunk-CEZNMLOO.js → chunk-7TTEGAO6.js} +12 -13
  5. package/dist/chunk-BU56QFHW.js +315 -0
  6. package/dist/{chunk-FQLK5GL5.js → chunk-BVHFMAVN.js} +1 -1
  7. package/dist/{chunk-RF2JGDSS.js → chunk-DMH6JVPF.js} +13 -10
  8. package/dist/{chunk-ALH4KM2Y.js → chunk-EQQDA4D3.js} +2967 -3248
  9. package/dist/{chunk-QFSSKIQ3.js → chunk-EXYMWI7A.js} +4 -4
  10. package/dist/{chunk-NNEHZT3V.js → chunk-EZUR7OEP.js} +11 -3
  11. package/dist/{chunk-NONI4CRP.js → chunk-ITWVFGFV.js} +5 -61
  12. package/dist/{chunk-4U4CSRBE.js → chunk-LCRJWUW7.js} +6 -6
  13. package/dist/{chunk-XKR3HCAL.js → chunk-NSBYORD5.js} +177 -34
  14. package/dist/{chunk-PSJIT5LZ.js → chunk-RFNEDBVO.js} +4 -4
  15. package/dist/chunk-RI6GAMNP.js +13 -0
  16. package/dist/{chunk-HHAJ3QF6.js → chunk-UKTPL5ZG.js} +16 -28
  17. package/dist/{chunk-HGAMIPFO.js → chunk-VIIRNJDT.js} +39 -178
  18. package/dist/cli/dev.js +1 -1
  19. package/dist/cli/index.js +1 -1
  20. package/dist/compactor-TDNRM3A7.js +9 -0
  21. package/dist/{config-YU7NYZYG.js → config-TDVA7MQN.js} +9 -8
  22. package/dist/{events-OHJWCI3S.js → events-UGTGGFG3.js} +8 -7
  23. package/dist/{folding-U6UHQAS5.js → folding-YOCGTZYH.js} +2 -2
  24. package/dist/{orchestrator-7ZXM4J22.js → orchestrator-75L5UGDU.js} +18 -22
  25. package/dist/package.json +1 -1
  26. package/dist/{processor-TKBJLQ2N.js → processor-GHESQ2YV.js} +8 -9
  27. package/dist/{protocol-BQ12Aw5J.d.ts → protocol-B9R1CUvt.d.ts} +14 -39
  28. package/dist/{protocol-K62EPEGS.js → protocol-CN24IKQN.js} +3 -5
  29. package/dist/{provider-HTJEB3ON.js → provider-BGH4MBLH.js} +25 -10
  30. package/dist/{serve-5KA6SSSP.js → serve-I6T7V62Z.js} +25 -26
  31. package/dist/server/index.d.ts +1 -6
  32. package/dist/server/index.js +15 -16
  33. package/dist/{settings-VRAOAPLA.js → settings-6XX56F3F.js} +2 -2
  34. package/dist/shared/index.d.ts +2 -2
  35. package/dist/shared/index.js +1 -1
  36. package/dist/{tools-Z7X4HXZN.js → tools-D3WWIOQD.js} +11 -13
  37. package/dist/web/assets/{index-BY8EbT5Z.css → index-CSOB8dwI.css} +1 -1
  38. package/dist/web/assets/index-tJDr1ODC.js +299 -0
  39. package/dist/web/index.html +2 -2
  40. package/dist/web/sw.js +1 -1
  41. package/dist/workflow-defaults/default.workflow.json +9 -4
  42. package/package.json +1 -1
  43. package/dist/auto-compaction-UIWTO3H5.js +0 -27
  44. package/dist/chunk-CGZHLM3K.js +0 -70
  45. package/dist/chunk-SZKEGZIB.js +0 -140
  46. package/dist/chunk-UFY4I643.js +0 -332
  47. package/dist/runtime-config-NPSPMRDA.js +0 -9
  48. package/dist/vision-fallback-3MIZZ6NQ.js +0 -22
  49. package/dist/web/assets/index-CqOJgw7l.js +0 -299
@@ -1,332 +0,0 @@
1
- import {
2
- BUILDER_KICKOFF_PROMPT,
3
- PathAccessDeniedError,
4
- TurnMetrics,
5
- VERIFIER_KICKOFF_PROMPT,
6
- assembleAgentRequest,
7
- buildAgentReminder,
8
- createChatDoneEvent,
9
- createMessageStartEvent,
10
- executeSubAgent,
11
- findAgentById,
12
- getSubAgents,
13
- getToolRegistryForAgent,
14
- loadAllAgentsDefault,
15
- runTopLevelAgentLoop
16
- } from "./chunk-ALH4KM2Y.js";
17
- import {
18
- getCurrentContextWindowId,
19
- getEventStore
20
- } from "./chunk-XKR3HCAL.js";
21
- import {
22
- buildSnapshotFromSessionState
23
- } from "./chunk-NONI4CRP.js";
24
- import {
25
- logger
26
- } from "./chunk-K44MW7JJ.js";
27
-
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
- };
49
- }
50
-
51
- // src/server/chat/orchestrator.ts
52
- function getCurrentWindowMessageOptions(sessionId) {
53
- const contextWindowId = getCurrentContextWindowId(sessionId);
54
- return contextWindowId ? { contextWindowId } : void 0;
55
- }
56
- function resolveStatsIdentity(options) {
57
- const model = options.llmClient.getModel();
58
- if (options.statsIdentity) {
59
- return {
60
- ...options.statsIdentity,
61
- model
62
- };
63
- }
64
- return {
65
- providerId: `provider:${model}`,
66
- providerName: "Unknown Provider",
67
- backend: "unknown",
68
- model
69
- };
70
- }
71
- async function runChatTurn(options) {
72
- const { sessionManager, sessionId } = options;
73
- const eventStore = getEventStore();
74
- const statsIdentity = resolveStatsIdentity(options);
75
- const session = sessionManager.requireSession(sessionId);
76
- const mode = session.mode;
77
- logger.debug("Starting chat turn", { sessionId, mode });
78
- const turnMetrics = new TurnMetrics();
79
- try {
80
- if (mode === "builder") {
81
- await runBuilderTurn(options, turnMetrics);
82
- } else {
83
- await runGenericAgentTurn(options, turnMetrics, mode);
84
- }
85
- const snapshot = buildSnapshot(sessionManager, sessionId, turnMetrics.buildStats(statsIdentity, mode));
86
- const snapshotEvent = eventStore.append(sessionId, { type: "turn.snapshot", data: snapshot });
87
- const deletedCount = eventStore.cleanupOldEvents(sessionId);
88
- if (deletedCount > 0) {
89
- logger.debug("Cleaned up old events after snapshot", { sessionId, deletedCount, snapshotSeq: snapshotEvent.seq });
90
- }
91
- } catch (error) {
92
- if (error instanceof PathAccessDeniedError) {
93
- const errorMsgId2 = crypto.randomUUID();
94
- const reasonText = error.reason === "sensitive_file" ? "sensitive files that may contain secrets" : error.reason === "both" ? "files outside the project and sensitive files" : "files outside the project directory";
95
- eventStore.append(sessionId, {
96
- type: "chat.error",
97
- data: {
98
- error: `User denied access to ${reasonText}.`,
99
- recoverable: false
100
- }
101
- });
102
- eventStore.append(
103
- sessionId,
104
- createMessageStartEvent(
105
- errorMsgId2,
106
- "user",
107
- `Access denied: ${error.paths.join(", ")}. If you need this file, explain why and ask the user for permission.`,
108
- {
109
- ...getCurrentWindowMessageOptions(sessionId) ?? {},
110
- isSystemGenerated: true,
111
- messageKind: "correction"
112
- }
113
- )
114
- );
115
- eventStore.append(sessionId, createChatDoneEvent(errorMsgId2, "error"));
116
- return;
117
- }
118
- if (error instanceof Error && error.message === "Aborted") {
119
- const snapshot = buildSnapshot(sessionManager, sessionId, turnMetrics.buildStats(statsIdentity, mode));
120
- eventStore.append(sessionId, { type: "turn.snapshot", data: snapshot });
121
- return;
122
- }
123
- logger.error("Chat turn error", { sessionId, mode, error });
124
- const errorMsgId = crypto.randomUUID();
125
- eventStore.append(sessionId, {
126
- type: "chat.error",
127
- data: {
128
- error: error instanceof Error ? error.message : "Unknown error",
129
- recoverable: false
130
- }
131
- });
132
- eventStore.append(
133
- sessionId,
134
- createMessageStartEvent(
135
- errorMsgId,
136
- "user",
137
- `Error: ${error instanceof Error ? error.message : "Unknown error"}`,
138
- {
139
- ...getCurrentWindowMessageOptions(sessionId) ?? {},
140
- isSystemGenerated: true,
141
- messageKind: "correction"
142
- }
143
- )
144
- );
145
- eventStore.append(sessionId, createChatDoneEvent(errorMsgId, "error"));
146
- } finally {
147
- eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
148
- }
149
- }
150
- function injectModeReminderIfNeeded(sessionManager, sessionId, agentId, allAgents, _onMessage) {
151
- const eventStore = getEventStore();
152
- const session = sessionManager.requireSession(sessionId);
153
- const lastModeReminder = session.executionState?.lastModeWithReminder;
154
- if (lastModeReminder === agentId) {
155
- return;
156
- }
157
- const agentDef = findAgentById(agentId, allAgents);
158
- if (!agentDef) return;
159
- const reminderContent = buildAgentReminder(agentDef);
160
- const reminderMsgId = crypto.randomUUID();
161
- const currentWindowMessageOptions = getCurrentContextWindowId(sessionId) ? { contextWindowId: getCurrentContextWindowId(sessionId) } : void 0;
162
- eventStore.append(sessionId, {
163
- type: "message.start",
164
- data: {
165
- messageId: reminderMsgId,
166
- role: "user",
167
- content: reminderContent,
168
- ...currentWindowMessageOptions ?? {},
169
- isSystemGenerated: true,
170
- messageKind: "auto-prompt",
171
- metadata: {
172
- type: "agent",
173
- name: agentDef.metadata.name ?? agentDef.metadata.id,
174
- color: agentDef.metadata.color ?? "#6b7280"
175
- }
176
- }
177
- });
178
- eventStore.append(sessionId, {
179
- type: "message.done",
180
- data: { messageId: reminderMsgId }
181
- });
182
- sessionManager.updateExecutionState(sessionId, {
183
- lastModeWithReminder: agentId
184
- });
185
- }
186
- async function runGenericAgentTurn(options, turnMetrics, agentId) {
187
- const statsIdentity = resolveStatsIdentity(options);
188
- const allAgents = await loadAllAgentsDefault();
189
- injectModeReminderIfNeeded(options.sessionManager, options.sessionId, agentId, allAgents, options.onMessage);
190
- const agentDef = findAgentById(agentId, allAgents) ?? findAgentById("planner", allAgents);
191
- const subAgentDefs = getSubAgents(allAgents);
192
- await runTopLevelAgentLoop(
193
- {
194
- mode: agentId,
195
- sessionManager: options.sessionManager,
196
- sessionId: options.sessionId,
197
- llmClient: options.llmClient,
198
- statsIdentity,
199
- signal: options.signal,
200
- 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);
246
- }
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");
257
- });
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
- }
274
- },
275
- turnMetrics
276
- ),
277
- stepDoneCalled
278
- };
279
- }
280
- async function runVerifierTurn(options, turnMetrics) {
281
- const { sessionManager, sessionId, llmClient, signal, onMessage } = options;
282
- const statsIdentity = resolveStatsIdentity(options);
283
- 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()
304
- });
305
- return {
306
- allPassed: result.allPassed ?? true,
307
- failed: result.failed ?? [],
308
- content: result.content
309
- };
310
- }
311
- function buildSnapshot(sessionManager, sessionId, _lastStats) {
312
- const eventStore = getEventStore();
313
- const session = sessionManager.requireSession(sessionId);
314
- const events = eventStore.getEvents(sessionId);
315
- const latestSeq = eventStore.getLatestSeq(sessionId) ?? 0;
316
- const cachedPrompt = sessionManager.getCachedPrompt(sessionId);
317
- return buildSnapshotFromSessionState({
318
- session,
319
- events,
320
- latestSeq,
321
- ...cachedPrompt ? { cachedSystemPrompt: cachedPrompt.systemPrompt, dynamicContextHash: cachedPrompt.hash } : {}
322
- });
323
- }
324
-
325
- export {
326
- createVerifierNudgeConfig,
327
- runChatTurn,
328
- filterToolRegistryForStepDone,
329
- runBuilderTurn,
330
- runVerifierTurn
331
- };
332
- //# sourceMappingURL=chunk-UFY4I643.js.map
@@ -1,9 +0,0 @@
1
- import {
2
- getRuntimeConfig,
3
- setRuntimeConfig
4
- } from "./chunk-CGZHLM3K.js";
5
- export {
6
- getRuntimeConfig,
7
- setRuntimeConfig
8
- };
9
- //# sourceMappingURL=runtime-config-NPSPMRDA.js.map
@@ -1,22 +0,0 @@
1
- import {
2
- clearDescriptionCache,
3
- describeImage,
4
- describeImageFromDataUrl,
5
- descriptionCache,
6
- ensureVisionFallbackConfigLoaded,
7
- getVisionFallbackConfig,
8
- isVisionFallbackEnabled,
9
- setVisionFallbackConfig
10
- } from "./chunk-SZKEGZIB.js";
11
- import "./chunk-K44MW7JJ.js";
12
- export {
13
- clearDescriptionCache,
14
- describeImage,
15
- describeImageFromDataUrl,
16
- descriptionCache,
17
- ensureVisionFallbackConfigLoaded,
18
- getVisionFallbackConfig,
19
- isVisionFallbackEnabled,
20
- setVisionFallbackConfig
21
- };
22
- //# sourceMappingURL=vision-fallback-3MIZZ6NQ.js.map