openfox 0.2.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/agent-defaults/builder.agent.md +3 -7
  2. package/dist/agent-defaults/code-reviewer.agent.md +1 -2
  3. package/dist/agent-defaults/debugger.agent.md +1 -2
  4. package/dist/agent-defaults/planner.agent.md +2 -9
  5. package/dist/agent-defaults/test-generator.agent.md +1 -1
  6. package/dist/agent-defaults/verifier.agent.md +4 -5
  7. package/dist/ask-3RK5YJZE.js +19 -0
  8. package/dist/auto-compaction-7LNZ5J3W.js +23 -0
  9. package/dist/{branch.api-WDHKZJS6.js → branch.api-XADFZZAA.js} +2 -2
  10. package/dist/chat-handler-T7SLWZ4E.js +201 -0
  11. package/dist/chunk-22CTURMH.js +128 -0
  12. package/dist/chunk-2KSCZSXQ.js +680 -0
  13. package/dist/{chunk-S5NRIWEU.js → chunk-2TBNG7CS.js} +12 -12
  14. package/dist/{chunk-4Z2OZ6NX.js → chunk-3EHGGBWE.js} +29 -2
  15. package/dist/{chunk-GZ7ZVJIW.js → chunk-3UQACISJ.js} +159 -49
  16. package/dist/{chunk-AF7XS4OI.js → chunk-5YQAXUKO.js} +4 -1
  17. package/dist/{chunk-MTX5Y3V3.js → chunk-7IOZFJBW.js} +2 -2
  18. package/dist/chunk-BU2ZYOEA.js +1067 -0
  19. package/dist/chunk-M2C5GEQR.js +137 -0
  20. package/dist/{chunk-U62ZECSQ.js → chunk-PNBH3RAX.js} +2 -2
  21. package/dist/chunk-QDEKU5RL.js +75 -0
  22. package/dist/chunk-QYP5HQV4.js +438 -0
  23. package/dist/{chunk-O4W4555H.js → chunk-RAZQTQK2.js} +1353 -1134
  24. package/dist/chunk-S4QKTRGJ.js +343 -0
  25. package/dist/{chunk-ARFK3RZW.js → chunk-TPT6HP4H.js} +1 -1
  26. package/dist/chunk-TVQOONDR.js +75 -0
  27. package/dist/{chunk-5ZUU23XF.js → chunk-U6BUT37A.js} +286 -33
  28. package/dist/chunk-VZXXJKSQ.js +314 -0
  29. package/dist/{chunk-26NRL3HX.js → chunk-XFXOSPYH.js} +3 -2
  30. package/dist/{chunk-N2XYX4ZA.js → chunk-XKFPU2FA.js} +13 -2
  31. package/dist/{chunk-FUUYYDVG.js → chunk-YB2574C6.js} +2841 -4507
  32. package/dist/cli/dev.js +4 -3
  33. package/dist/cli/index.js +4 -3
  34. package/dist/{config-GIXXE4VK.js → config-GIFCEJDU.js} +11 -6
  35. package/dist/events-G6CKHDNZ.js +114 -0
  36. package/dist/folding-O52L65VN.js +37 -0
  37. package/dist/{init-2EJ5AC7Z.js → init-MKTUIGZU.js} +46 -13
  38. package/dist/orchestrator-UGXX7JRQ.js +39 -0
  39. package/dist/package.json +9 -2
  40. package/dist/{paths-4BPXWB2W.js → paths-MM76AWYB.js} +2 -2
  41. package/dist/processor-KLHKDILM.js +236 -0
  42. package/dist/{project-creator-CWPKRIKI.js → project-creator-KAQXMZCT.js} +9 -8
  43. package/dist/projects-GSMMEVSO.js +19 -0
  44. package/dist/{protocol-BFFz3WM0.d.ts → protocol-BZ6OIASP.d.ts} +71 -50
  45. package/dist/protocol-WQENDK72.js +88 -0
  46. package/dist/{provider-QEVVNYOX.js → provider-4KTWU6IV.js} +41 -9
  47. package/dist/runtime-config-2XJJIMSC.js +9 -0
  48. package/dist/{serve-RYEBLJVN.js → serve-UK6B6G2O.js} +38 -18
  49. package/dist/server/index.d.ts +81 -27
  50. package/dist/server/index.js +19 -11
  51. package/dist/{settings-D5O3TMLD.js → settings-NCLN4JDZ.js} +4 -4
  52. package/dist/shared/index.d.ts +2 -2
  53. package/dist/shared/index.js +1 -1
  54. package/dist/tools-SGBQE736.js +48 -0
  55. package/dist/vision-fallback-63VPBSEN.js +22 -0
  56. package/dist/web/assets/{index-DHmZmhnR.css → index-BsaaC0X0.css} +32 -1
  57. package/dist/web/assets/index-CvO7QkGh.js +141 -0
  58. package/dist/web/index.html +2 -2
  59. package/dist/web/sounds/typing.mp3 +0 -0
  60. package/dist/workflow-defaults/default.workflow.json +1 -1
  61. package/package.json +9 -2
  62. package/dist/chunk-L4XDA3V7.js +0 -218
  63. package/dist/tools-QMIIDJTV.js +0 -48
  64. package/dist/web/assets/index-CAD7Iv_d.js +0 -122
@@ -0,0 +1,314 @@
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-YB2574C6.js";
17
+ import {
18
+ getCurrentContextWindowId,
19
+ getEventStore
20
+ } from "./chunk-BU2ZYOEA.js";
21
+ import {
22
+ buildSnapshotFromSessionState
23
+ } from "./chunk-2KSCZSXQ.js";
24
+ import {
25
+ createChatMessageMessage
26
+ } from "./chunk-S4QKTRGJ.js";
27
+ import {
28
+ logger
29
+ } from "./chunk-PNBH3RAX.js";
30
+
31
+ // src/server/sub-agents/verifier-helpers.ts
32
+ var MAX_CONSECUTIVE_VERIFIER_NUDGES = 10;
33
+ var VERIFIER_STALL_REASON = "Verifier stopped repeatedly before terminalizing verification after repeated nudges.";
34
+ function getCriteriaAwaitingVerification(criteria) {
35
+ return criteria.filter((criterion) => criterion.status.type === "completed");
36
+ }
37
+ function buildVerifierNudgeContent(criteria) {
38
+ const ids = criteria.map((criterion) => criterion.id).join(", ");
39
+ 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}.`;
40
+ }
41
+ function buildVerifierRestartContent(criteria) {
42
+ const ids = criteria.map((criterion) => criterion.id).join(", ");
43
+ return `${VERIFIER_STALL_REASON} Leaving remaining criteria unchanged so verification can restart in a fresh window: ${ids}.`;
44
+ }
45
+ function createVerifierNudgeConfig() {
46
+ return {
47
+ maxConsecutiveNudges: MAX_CONSECUTIVE_VERIFIER_NUDGES,
48
+ getCriteriaAwaiting: getCriteriaAwaitingVerification,
49
+ buildNudgeContent: buildVerifierNudgeContent,
50
+ buildRestartContent: buildVerifierRestartContent
51
+ };
52
+ }
53
+
54
+ // src/server/chat/orchestrator.ts
55
+ function getCurrentWindowMessageOptions(sessionId) {
56
+ const contextWindowId = getCurrentContextWindowId(sessionId);
57
+ return contextWindowId ? { contextWindowId } : void 0;
58
+ }
59
+ function resolveStatsIdentity(options) {
60
+ const model = options.llmClient.getModel();
61
+ if (options.statsIdentity) {
62
+ return {
63
+ ...options.statsIdentity,
64
+ model
65
+ };
66
+ }
67
+ return {
68
+ providerId: `provider:${model}`,
69
+ providerName: "Unknown Provider",
70
+ backend: "unknown",
71
+ model
72
+ };
73
+ }
74
+ async function runChatTurn(options) {
75
+ const { sessionManager, sessionId } = options;
76
+ const eventStore = getEventStore();
77
+ const statsIdentity = resolveStatsIdentity(options);
78
+ const session = sessionManager.requireSession(sessionId);
79
+ const mode = session.mode;
80
+ logger.debug("Starting chat turn", { sessionId, mode });
81
+ const turnMetrics = new TurnMetrics();
82
+ try {
83
+ if (mode === "builder") {
84
+ await runBuilderTurn(options, turnMetrics);
85
+ } else {
86
+ await runGenericAgentTurn(options, turnMetrics, mode);
87
+ }
88
+ const snapshot = buildSnapshot(sessionManager, sessionId, turnMetrics.buildStats(statsIdentity, mode));
89
+ const snapshotEvent = eventStore.append(sessionId, { type: "turn.snapshot", data: snapshot });
90
+ const deletedCount = eventStore.cleanupOldEvents(sessionId);
91
+ if (deletedCount > 0) {
92
+ logger.debug("Cleaned up old events after snapshot", { sessionId, deletedCount, snapshotSeq: snapshotEvent.seq });
93
+ }
94
+ } catch (error) {
95
+ if (error instanceof PathAccessDeniedError) {
96
+ const errorMsgId2 = crypto.randomUUID();
97
+ 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";
98
+ eventStore.append(sessionId, {
99
+ type: "chat.error",
100
+ data: {
101
+ error: `User denied access to ${reasonText}.`,
102
+ recoverable: false
103
+ }
104
+ });
105
+ eventStore.append(sessionId, createMessageStartEvent(errorMsgId2, "user", `Access denied: ${error.paths.join(", ")}. If you need this file, explain why and ask the user for permission.`, {
106
+ ...getCurrentWindowMessageOptions(sessionId) ?? {},
107
+ isSystemGenerated: true,
108
+ messageKind: "correction"
109
+ }));
110
+ eventStore.append(sessionId, createChatDoneEvent(errorMsgId2, "error"));
111
+ return;
112
+ }
113
+ if (error instanceof Error && error.message === "Aborted") {
114
+ return;
115
+ }
116
+ logger.error("Chat turn error", { sessionId, mode, error });
117
+ const errorMsgId = crypto.randomUUID();
118
+ eventStore.append(sessionId, {
119
+ type: "chat.error",
120
+ data: {
121
+ error: error instanceof Error ? error.message : "Unknown error",
122
+ recoverable: false
123
+ }
124
+ });
125
+ eventStore.append(sessionId, createMessageStartEvent(errorMsgId, "user", `Error: ${error instanceof Error ? error.message : "Unknown error"}`, {
126
+ ...getCurrentWindowMessageOptions(sessionId) ?? {},
127
+ isSystemGenerated: true,
128
+ messageKind: "correction"
129
+ }));
130
+ eventStore.append(sessionId, createChatDoneEvent(errorMsgId, "error"));
131
+ } finally {
132
+ eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
133
+ }
134
+ }
135
+ function injectModeReminderIfNeeded(sessionManager, sessionId, agentId, allAgents, onMessage) {
136
+ const eventStore = getEventStore();
137
+ const session = sessionManager.requireSession(sessionId);
138
+ const lastModeReminder = session.executionState?.lastModeWithReminder;
139
+ if (lastModeReminder === agentId) {
140
+ return;
141
+ }
142
+ const agentDef = findAgentById(agentId, allAgents);
143
+ if (!agentDef) return;
144
+ const reminderContent = buildAgentReminder(agentDef);
145
+ const reminderMsgId = crypto.randomUUID();
146
+ const currentWindowMessageOptions = getCurrentContextWindowId(sessionId) ? { contextWindowId: getCurrentContextWindowId(sessionId) } : void 0;
147
+ eventStore.append(sessionId, {
148
+ type: "message.start",
149
+ data: {
150
+ messageId: reminderMsgId,
151
+ role: "user",
152
+ content: reminderContent,
153
+ ...currentWindowMessageOptions ?? {},
154
+ isSystemGenerated: true,
155
+ messageKind: "auto-prompt",
156
+ metadata: {
157
+ type: "agent",
158
+ name: agentDef.metadata.name ?? agentDef.metadata.id,
159
+ color: agentDef.metadata.color ?? "#6b7280"
160
+ }
161
+ }
162
+ });
163
+ eventStore.append(sessionId, {
164
+ type: "message.done",
165
+ data: { messageId: reminderMsgId }
166
+ });
167
+ if (onMessage) {
168
+ onMessage(createChatMessageMessage({
169
+ id: reminderMsgId,
170
+ role: "user",
171
+ content: reminderContent,
172
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
173
+ isSystemGenerated: true,
174
+ messageKind: "auto-prompt",
175
+ metadata: {
176
+ type: "agent",
177
+ name: agentDef.metadata.name ?? agentDef.metadata.id,
178
+ color: agentDef.metadata.color ?? "#6b7280"
179
+ }
180
+ }));
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
+ mode: agentId,
194
+ sessionManager: options.sessionManager,
195
+ sessionId: options.sessionId,
196
+ llmClient: options.llmClient,
197
+ statsIdentity,
198
+ signal: options.signal,
199
+ onMessage: options.onMessage,
200
+ assembleRequest: (input) => assembleAgentRequest({ ...input, agentDef, subAgentDefs }),
201
+ getToolRegistry: () => getToolRegistryForAgent(agentDef)
202
+ }, turnMetrics);
203
+ }
204
+ function filterToolRegistryForStepDone(baseRegistry, _injectStepDone) {
205
+ return baseRegistry;
206
+ }
207
+ async function runBuilderTurn(options, turnMetrics) {
208
+ const { sessionManager, sessionId } = options;
209
+ const statsIdentity = resolveStatsIdentity(options);
210
+ const eventStore = getEventStore();
211
+ const allAgents = await loadAllAgentsDefault();
212
+ injectModeReminderIfNeeded(options.sessionManager, options.sessionId, "builder", allAgents, options.onMessage);
213
+ const builderDef = findAgentById("builder", allAgents);
214
+ const subAgentDefs = getSubAgents(allAgents);
215
+ let stepDoneCalled = false;
216
+ return {
217
+ ...await runTopLevelAgentLoop({
218
+ mode: "builder",
219
+ sessionManager,
220
+ sessionId,
221
+ llmClient: options.llmClient,
222
+ statsIdentity,
223
+ signal: options.signal,
224
+ onMessage: options.onMessage,
225
+ assembleRequest: (input) => assembleAgentRequest({ ...input, agentDef: builderDef, subAgentDefs }),
226
+ getToolRegistry: () => {
227
+ const baseRegistry = getToolRegistryForAgent(builderDef);
228
+ return filterToolRegistryForStepDone(baseRegistry, options.injectStepDone === true);
229
+ },
230
+ onToolExecuted: (toolCall, toolResult) => {
231
+ if (toolCall.name === "step_done" && toolResult.success) {
232
+ stepDoneCalled = true;
233
+ }
234
+ if (toolResult.success && ["write_file", "edit_file"].includes(toolCall.name)) {
235
+ const path = toolCall.arguments["path"];
236
+ sessionManager.addModifiedFile(sessionId, path);
237
+ }
238
+ },
239
+ injectKickoff: () => {
240
+ if (options.injectBuilderKickoff !== true) return;
241
+ const session = sessionManager.requireSession(sessionId);
242
+ const events = eventStore.getEvents(sessionId);
243
+ const hasBuilderKickoff = events.some((e) => {
244
+ if (e.type !== "message.start") return false;
245
+ const data = e.data;
246
+ return data.messageKind === "auto-prompt" && data.content?.includes("fulfil the");
247
+ });
248
+ if (!hasBuilderKickoff) {
249
+ const kickoffMsgId = crypto.randomUUID();
250
+ const kickoffContent = BUILDER_KICKOFF_PROMPT(session.criteria.length);
251
+ eventStore.append(sessionId, createMessageStartEvent(kickoffMsgId, "user", kickoffContent, {
252
+ ...getCurrentWindowMessageOptions(sessionId) ?? {},
253
+ isSystemGenerated: true,
254
+ messageKind: "auto-prompt",
255
+ metadata: { type: "agent", name: "Builder", color: "#22c55e" }
256
+ }));
257
+ eventStore.append(sessionId, { type: "message.done", data: { messageId: kickoffMsgId } });
258
+ }
259
+ }
260
+ }, turnMetrics),
261
+ stepDoneCalled
262
+ };
263
+ }
264
+ async function runVerifierTurn(options, turnMetrics) {
265
+ const { sessionManager, sessionId, llmClient, signal, onMessage } = options;
266
+ const statsIdentity = resolveStatsIdentity(options);
267
+ const session = sessionManager.requireSession(sessionId);
268
+ const toVerify = session.criteria.filter((c) => c.status.type === "completed");
269
+ if (toVerify.length === 0) {
270
+ logger.debug("Nothing to verify", { sessionId });
271
+ return { allPassed: true, failed: [] };
272
+ }
273
+ const allAgents = await loadAllAgentsDefault();
274
+ const verifierDef = findAgentById("verifier", allAgents);
275
+ const toolRegistry = getToolRegistryForAgent(verifierDef);
276
+ const result = await executeSubAgent({
277
+ subAgentType: "verifier",
278
+ prompt: VERIFIER_KICKOFF_PROMPT,
279
+ sessionManager,
280
+ sessionId,
281
+ llmClient,
282
+ toolRegistry,
283
+ turnMetrics,
284
+ statsIdentity,
285
+ signal,
286
+ onMessage,
287
+ nudgeConfig: createVerifierNudgeConfig()
288
+ });
289
+ return {
290
+ allPassed: result.allPassed ?? true,
291
+ failed: result.failed ?? [],
292
+ content: result.content
293
+ };
294
+ }
295
+ function buildSnapshot(sessionManager, sessionId, lastStats) {
296
+ const eventStore = getEventStore();
297
+ const session = sessionManager.requireSession(sessionId);
298
+ const events = eventStore.getEvents(sessionId);
299
+ const latestSeq = eventStore.getLatestSeq(sessionId) ?? 0;
300
+ return buildSnapshotFromSessionState({
301
+ session,
302
+ events,
303
+ latestSeq
304
+ });
305
+ }
306
+
307
+ export {
308
+ createVerifierNudgeConfig,
309
+ runChatTurn,
310
+ filterToolRegistryForStepDone,
311
+ runBuilderTurn,
312
+ runVerifierTurn
313
+ };
314
+ //# sourceMappingURL=chunk-VZXXJKSQ.js.map
@@ -95,9 +95,10 @@ async function* streamWithSegments(client, request) {
95
95
  const ttft = ((firstTokenTime ?? endTime) - startTime) / 1e3;
96
96
  const completionTime = (endTime - (firstTokenTime ?? startTime)) / 1e3;
97
97
  const { promptTokens, completionTokens } = response.usage;
98
+ const effectiveThinkingContent = thinkingContent || content === "" && response.reasoning_content || "";
98
99
  return {
99
100
  content,
100
- thinkingContent,
101
+ thinkingContent: effectiveThinkingContent,
101
102
  toolCalls,
102
103
  response,
103
104
  segments,
@@ -113,4 +114,4 @@ async function* streamWithSegments(client, request) {
113
114
  export {
114
115
  streamWithSegments
115
116
  };
116
- //# sourceMappingURL=chunk-26NRL3HX.js.map
117
+ //# sourceMappingURL=chunk-XFXOSPYH.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getDatabase
3
- } from "./chunk-4Z2OZ6NX.js";
3
+ } from "./chunk-3EHGGBWE.js";
4
4
 
5
5
  // src/server/db/projects.ts
6
6
  function createProject(name, workdir) {
@@ -29,6 +29,16 @@ function getProject(id) {
29
29
  }
30
30
  return rowToProject(row);
31
31
  }
32
+ function getProjectByWorkdir(workdir) {
33
+ const db = getDatabase();
34
+ const row = db.prepare(`
35
+ SELECT * FROM projects WHERE workdir = ?
36
+ `).get(workdir);
37
+ if (!row) {
38
+ return null;
39
+ }
40
+ return rowToProject(row);
41
+ }
32
42
  function listProjects() {
33
43
  const db = getDatabase();
34
44
  const rows = db.prepare(`
@@ -76,8 +86,9 @@ function rowToProject(row) {
76
86
  export {
77
87
  createProject,
78
88
  getProject,
89
+ getProjectByWorkdir,
79
90
  listProjects,
80
91
  updateProject,
81
92
  deleteProject
82
93
  };
83
- //# sourceMappingURL=chunk-N2XYX4ZA.js.map
94
+ //# sourceMappingURL=chunk-XKFPU2FA.js.map