openfox 2.0.4 → 2.0.5

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 (32) hide show
  1. package/dist/{ask-5SSOA6SZ.js → ask-4GZ334CO.js} +4 -2
  2. package/dist/{chat-handler-WHE75FCD.js → chat-handler-RQXMBCKX.js} +9 -9
  3. package/dist/{chunk-DTJJZZOC.js → chunk-3QB2RMX2.js} +13 -7
  4. package/dist/{chunk-LVS5YGTX.js → chunk-5BDVM6YI.js} +1 -1
  5. package/dist/{chunk-RVXAYREQ.js → chunk-734M5CG5.js} +2 -2
  6. package/dist/{chunk-STJJDIXV.js → chunk-7EHJPONC.js} +4 -4
  7. package/dist/{chunk-N374WCXC.js → chunk-7S6FKODI.js} +10 -10
  8. package/dist/{chunk-O2MR653P.js → chunk-DXV74LCI.js} +68 -36
  9. package/dist/{chunk-BJYPTN5S.js → chunk-EU3WWTFH.js} +35 -8
  10. package/dist/{chunk-4HBWSC6K.js → chunk-LX66KJPL.js} +2 -2
  11. package/dist/{chunk-FRJQC77Y.js → chunk-SYG2ENUQ.js} +2 -2
  12. package/dist/{chunk-KXJWTSOS.js → chunk-TIKQWNYK.js} +12 -5
  13. package/dist/cli/dev.js +1 -1
  14. package/dist/cli/index.js +1 -1
  15. package/dist/{events-5SWEG62X.js → events-4K52FKPR.js} +3 -3
  16. package/dist/{folding-NUBDA4HS.js → folding-QIBNKYA6.js} +2 -2
  17. package/dist/{orchestrator-X2ECL42Y.js → orchestrator-JPDTRWQE.js} +8 -8
  18. package/dist/package.json +1 -1
  19. package/dist/{processor-7TYZNS4I.js → processor-KRBBTKRS.js} +20 -7
  20. package/dist/{protocol-BljtHZrx.d.ts → protocol-CaLuIetw.d.ts} +11 -1
  21. package/dist/{protocol-X53W2J73.js → protocol-YYWMFR35.js} +3 -3
  22. package/dist/{serve-XPCJSKXX.js → serve-YJIMBTIX.js} +9 -9
  23. package/dist/server/index.d.ts +1 -1
  24. package/dist/server/index.js +8 -8
  25. package/dist/shared/index.d.ts +2 -2
  26. package/dist/shared/index.js +1 -1
  27. package/dist/{tools-22OPY2O7.js → tools-Z6KF35SO.js} +9 -7
  28. package/dist/web/assets/{index-Sdax8ayU.css → index-B6xft9Co.css} +1 -1
  29. package/dist/web/assets/{index-Di3909TT.js → index-Cwshb4LW.js} +43 -43
  30. package/dist/web/index.html +2 -2
  31. package/dist/web/sw.js +1 -1
  32. package/package.json +1 -1
@@ -4,16 +4,18 @@ import {
4
4
  awaitAnswer,
5
5
  cancelQuestion,
6
6
  cancelQuestionsForSession,
7
+ getPendingQuestionsForSession,
7
8
  hasPendingQuestion,
8
9
  provideAnswer
9
- } from "./chunk-BJYPTN5S.js";
10
+ } from "./chunk-EU3WWTFH.js";
10
11
  export {
11
12
  AskUserInterrupt,
12
13
  askUserTool,
13
14
  awaitAnswer,
14
15
  cancelQuestion,
15
16
  cancelQuestionsForSession,
17
+ getPendingQuestionsForSession,
16
18
  hasPendingQuestion,
17
19
  provideAnswer
18
20
  };
19
- //# sourceMappingURL=ask-5SSOA6SZ.js.map
21
+ //# sourceMappingURL=ask-4GZ334CO.js.map
@@ -5,28 +5,28 @@ import {
5
5
  generateSessionName,
6
6
  getSessionMessageCount,
7
7
  needsNameGenerationCheck
8
- } from "./chunk-KXJWTSOS.js";
8
+ } from "./chunk-TIKQWNYK.js";
9
9
  import {
10
10
  runChatTurn
11
- } from "./chunk-STJJDIXV.js";
12
- import "./chunk-N374WCXC.js";
11
+ } from "./chunk-7EHJPONC.js";
12
+ import "./chunk-7S6FKODI.js";
13
13
  import "./chunk-DL6ZILAF.js";
14
14
  import "./chunk-PBGOZMVY.js";
15
15
  import "./chunk-VRGRAQDG.js";
16
16
  import "./chunk-XAMAYRDA.js";
17
17
  import {
18
18
  getEventStore
19
- } from "./chunk-FRJQC77Y.js";
20
- import "./chunk-4HBWSC6K.js";
19
+ } from "./chunk-SYG2ENUQ.js";
20
+ import "./chunk-LX66KJPL.js";
21
21
  import {
22
22
  createChatMessageMessage,
23
23
  createPhaseChangedMessage,
24
24
  createSessionRunningMessage
25
- } from "./chunk-DTJJZZOC.js";
26
- import "./chunk-BJYPTN5S.js";
25
+ } from "./chunk-3QB2RMX2.js";
26
+ import "./chunk-EU3WWTFH.js";
27
27
  import "./chunk-RFNEDBVO.js";
28
28
  import "./chunk-FBGWG4N6.js";
29
- import "./chunk-LVS5YGTX.js";
29
+ import "./chunk-5BDVM6YI.js";
30
30
  import "./chunk-CQGTEGKL.js";
31
31
  import "./chunk-Z4SWOUWC.js";
32
32
  import {
@@ -161,4 +161,4 @@ export {
161
161
  startChatSession,
162
162
  stopSessionExecution
163
163
  };
164
- //# sourceMappingURL=chat-handler-WHE75FCD.js.map
164
+ //# sourceMappingURL=chat-handler-RQXMBCKX.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createServerMessage,
3
3
  isClientMessage
4
- } from "./chunk-LVS5YGTX.js";
4
+ } from "./chunk-5BDVM6YI.js";
5
5
 
6
6
  // src/server/ws/protocol.ts
7
7
  function enrichMessagesWithToolResults(messages) {
@@ -43,11 +43,17 @@ function serializeServerMessage(message) {
43
43
  function createErrorMessage(code, message, correlationId) {
44
44
  return createServerMessage("error", { code, message }, correlationId);
45
45
  }
46
- function createSessionStateMessage(session, messages, pendingConfirmations = [], gitStatus, correlationId) {
46
+ function createSessionStateMessage(session, messages, pendingConfirmations = [], pendingQuestions, gitStatus, correlationId) {
47
47
  const enrichedMessages = enrichMessagesWithToolResults(messages);
48
48
  return createServerMessage(
49
49
  "session.state",
50
- { session, messages: enrichedMessages, pendingConfirmations, ...gitStatus ? { gitStatus } : {} },
50
+ {
51
+ session,
52
+ messages: enrichedMessages,
53
+ pendingConfirmations,
54
+ ...pendingQuestions ? { pendingQuestions } : {},
55
+ ...gitStatus ? { gitStatus } : {}
56
+ },
51
57
  correlationId
52
58
  );
53
59
  }
@@ -123,8 +129,8 @@ function createChatErrorMessage(error, recoverable) {
123
129
  function createChatPathConfirmationMessage(callId, tool, paths, workdir, reason) {
124
130
  return createServerMessage("chat.path_confirmation", { callId, tool, paths, workdir, reason });
125
131
  }
126
- function createChatAskUserMessage(callId, question) {
127
- return createServerMessage("chat.ask_user", { callId, question });
132
+ function createChatAskUserMessage(callId, question, type, options) {
133
+ return createServerMessage("chat.ask_user", { callId, question, type, options });
128
134
  }
129
135
  function createModeChangedMessage(mode, auto, reason) {
130
136
  return createServerMessage("mode.changed", { mode, auto, ...reason ? { reason } : {} });
@@ -281,7 +287,7 @@ function storedEventToServerMessage(event) {
281
287
  }
282
288
  case "chat.ask_user": {
283
289
  const data = event.data;
284
- return createChatAskUserMessage(data.callId, data.question);
290
+ return createChatAskUserMessage(data.callId, data.question, data.type, data.options);
285
291
  }
286
292
  case "pattern.retry": {
287
293
  const data = event.data;
@@ -333,4 +339,4 @@ export {
333
339
  createQueueStateMessage,
334
340
  storedEventToServerMessage
335
341
  };
336
- //# sourceMappingURL=chunk-DTJJZZOC.js.map
342
+ //# sourceMappingURL=chunk-3QB2RMX2.js.map
@@ -26,4 +26,4 @@ export {
26
26
  isClientMessage,
27
27
  isServerMessage
28
28
  };
29
- //# sourceMappingURL=chunk-LVS5YGTX.js.map
29
+ //# sourceMappingURL=chunk-5BDVM6YI.js.map
@@ -193,7 +193,7 @@ async function runCli(options) {
193
193
  if (!configExists) {
194
194
  await runNetworkSetup(mode);
195
195
  }
196
- const { runServe } = await import("./serve-XPCJSKXX.js");
196
+ const { runServe } = await import("./serve-YJIMBTIX.js");
197
197
  const serveOptions = { mode };
198
198
  if (values.port) serveOptions.port = parseInt(values.port);
199
199
  if (values["no-browser"] === true) serveOptions.openBrowser = false;
@@ -205,4 +205,4 @@ async function runCli(options) {
205
205
  export {
206
206
  runCli
207
207
  };
208
- //# sourceMappingURL=chunk-RVXAYREQ.js.map
208
+ //# sourceMappingURL=chunk-734M5CG5.js.map
@@ -17,16 +17,16 @@ import {
17
17
  loadAllAgentsDefault,
18
18
  processEventsForConversation,
19
19
  runTopLevelAgentLoop
20
- } from "./chunk-N374WCXC.js";
20
+ } from "./chunk-7S6FKODI.js";
21
21
  import {
22
22
  getCurrentContextWindowId,
23
23
  getCurrentWindowMessageOptions,
24
24
  getEventStore,
25
25
  getRuntimeConfig
26
- } from "./chunk-FRJQC77Y.js";
26
+ } from "./chunk-SYG2ENUQ.js";
27
27
  import {
28
28
  buildSnapshotFromSessionState
29
- } from "./chunk-4HBWSC6K.js";
29
+ } from "./chunk-LX66KJPL.js";
30
30
  import {
31
31
  getGlobalConfigDir
32
32
  } from "./chunk-CQGTEGKL.js";
@@ -311,4 +311,4 @@ export {
311
311
  runAgentTurn,
312
312
  injectWorkflowKickoffIfNeeded
313
313
  };
314
- //# sourceMappingURL=chunk-STJJDIXV.js.map
314
+ //# sourceMappingURL=chunk-7EHJPONC.js.map
@@ -22,7 +22,7 @@ import {
22
22
  getCurrentWindowMessageOptions,
23
23
  getEventStore,
24
24
  getRuntimeConfig
25
- } from "./chunk-FRJQC77Y.js";
25
+ } from "./chunk-SYG2ENUQ.js";
26
26
  import {
27
27
  buildContextMessagesFromEventHistory,
28
28
  foldContextState,
@@ -31,18 +31,18 @@ import {
31
31
  handleToolCall,
32
32
  handleToolResult,
33
33
  stripOrphanedToolCalls
34
- } from "./chunk-4HBWSC6K.js";
34
+ } from "./chunk-LX66KJPL.js";
35
35
  import {
36
36
  createChatDoneMessage,
37
37
  createChatMessageMessage,
38
38
  createChatMessageUpdatedMessage,
39
39
  createChatPathConfirmationMessage,
40
40
  createQueueStateMessage
41
- } from "./chunk-DTJJZZOC.js";
41
+ } from "./chunk-3QB2RMX2.js";
42
42
  import {
43
43
  AskUserInterrupt,
44
44
  askUserTool
45
- } from "./chunk-BJYPTN5S.js";
45
+ } from "./chunk-EU3WWTFH.js";
46
46
  import {
47
47
  SETTINGS_KEYS,
48
48
  deleteSetting,
@@ -2647,9 +2647,9 @@ async function executeTools(assistantMsgId, toolCalls, ctx, append) {
2647
2647
  } else if (error instanceof AskUserInterrupt) {
2648
2648
  append({
2649
2649
  type: "chat.ask_user",
2650
- data: { callId: error.callId, question: error.question }
2650
+ data: { callId: error.callId, question: error.question, type: error.type, options: error.options }
2651
2651
  });
2652
- const { awaitAnswer } = await import("./ask-5SSOA6SZ.js");
2652
+ const { awaitAnswer } = await import("./ask-4GZ334CO.js");
2653
2653
  const answerPromise = awaitAnswer(error.callId);
2654
2654
  if (!answerPromise) {
2655
2655
  throw new Error(`No pending question found for callId: ${error.callId}`);
@@ -2676,7 +2676,6 @@ async function executeTools(assistantMsgId, toolCalls, ctx, append) {
2676
2676
  durationMs: 0,
2677
2677
  truncated: false
2678
2678
  };
2679
- ctx.turnMetrics.addToolTime(toolResult2.durationMs);
2680
2679
  append(createToolResultEvent(assistantMsgId, toolCall.id, toolResult2));
2681
2680
  return {
2682
2681
  toolCall,
@@ -2708,7 +2707,6 @@ async function executeTools(assistantMsgId, toolCalls, ctx, append) {
2708
2707
  } catch (error) {
2709
2708
  toolResult = await handleToolExecutionError(error, ctx.sessionId, startTime);
2710
2709
  }
2711
- ctx.turnMetrics.addToolTime(toolResult.durationMs);
2712
2710
  ctx.onToolExecuted?.(toolCall, toolResult);
2713
2711
  if (toolCall.name === "return_value" && !toolCall.parseError) {
2714
2712
  returnValueContent = toolCall.arguments["content"];
@@ -2730,8 +2728,10 @@ Error: ${toolResult.error}` : `Error: ${toolResult.error}`
2730
2728
  index
2731
2729
  };
2732
2730
  };
2731
+ const batchStart = Date.now();
2733
2732
  const executionPromises = toolCalls.map((toolCall, index) => executeTool(toolCall, index));
2734
2733
  const results = await Promise.all(executionPromises);
2734
+ ctx.turnMetrics.addToolTime(Date.now() - batchStart);
2735
2735
  results.sort((a, b) => a.index - b.index);
2736
2736
  for (const result of results) {
2737
2737
  toolMessages.push({
@@ -3761,7 +3761,7 @@ var callSubAgentTool = {
3761
3761
  };
3762
3762
  }
3763
3763
  try {
3764
- const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-22OPY2O7.js");
3764
+ const { getToolRegistryForAgent: getToolRegistryForAgent2 } = await import("./tools-Z6KF35SO.js");
3765
3765
  const toolRegistry = getToolRegistryForAgent2(agentDef);
3766
3766
  const turnMetrics = new TurnMetrics();
3767
3767
  const result = await executeSubAgent({
@@ -4811,4 +4811,4 @@ export {
4811
4811
  getToolRegistryForAgent,
4812
4812
  createToolRegistry
4813
4813
  };
4814
- //# sourceMappingURL=chunk-N374WCXC.js.map
4814
+ //# sourceMappingURL=chunk-7S6FKODI.js.map
@@ -3,7 +3,7 @@ import {
3
3
  injectWorkflowKickoffIfNeeded,
4
4
  runAgentTurn,
5
5
  runChatTurn
6
- } from "./chunk-STJJDIXV.js";
6
+ } from "./chunk-7EHJPONC.js";
7
7
  import {
8
8
  COMPACTION_PROMPT,
9
9
  TurnMetrics,
@@ -58,7 +58,7 @@ import {
58
58
  skillExists,
59
59
  spawnShellProcess,
60
60
  streamLLMPure
61
- } from "./chunk-N374WCXC.js";
61
+ } from "./chunk-7S6FKODI.js";
62
62
  import {
63
63
  getPathSeparator,
64
64
  getPlatformShell,
@@ -95,11 +95,11 @@ import {
95
95
  updateSessionMetadata,
96
96
  updateSessionProvider,
97
97
  updateSessionRunning
98
- } from "./chunk-FRJQC77Y.js";
98
+ } from "./chunk-SYG2ENUQ.js";
99
99
  import {
100
100
  buildMessagesFromStoredEvents,
101
101
  foldPendingConfirmations
102
- } from "./chunk-4HBWSC6K.js";
102
+ } from "./chunk-LX66KJPL.js";
103
103
  import {
104
104
  createChatErrorMessage,
105
105
  createChatMessageMessage,
@@ -114,11 +114,11 @@ import {
114
114
  parseClientMessage,
115
115
  serializeServerMessage,
116
116
  storedEventToServerMessage
117
- } from "./chunk-DTJJZZOC.js";
117
+ } from "./chunk-3QB2RMX2.js";
118
118
  import {
119
119
  EventEmitter,
120
120
  provideAnswer
121
- } from "./chunk-BJYPTN5S.js";
121
+ } from "./chunk-EU3WWTFH.js";
122
122
  import {
123
123
  initDatabase
124
124
  } from "./chunk-FBGWG4N6.js";
@@ -127,7 +127,7 @@ import {
127
127
  } from "./chunk-VUQCQXXJ.js";
128
128
  import {
129
129
  createServerMessage
130
- } from "./chunk-LVS5YGTX.js";
130
+ } from "./chunk-5BDVM6YI.js";
131
131
  import {
132
132
  getGlobalConfigDir
133
133
  } from "./chunk-CQGTEGKL.js";
@@ -690,6 +690,26 @@ var RULES = [
690
690
  // -------------------------------------------------------------------------
691
691
  // Ask User Tool
692
692
  // -------------------------------------------------------------------------
693
+ // Specific type rules must come before generic ask rules
694
+ {
695
+ match: /confirm.*question/i,
696
+ tools: [{ name: "ask_user", arguments: { question: "Do you approve?", type: "confirm" } }],
697
+ response: "I asked a confirm question."
698
+ },
699
+ {
700
+ match: /choose.*option/i,
701
+ tools: [
702
+ {
703
+ name: "ask_user",
704
+ arguments: {
705
+ question: "Which option do you prefer?",
706
+ type: "choice",
707
+ options: ["Option A", "Option B", "Option C"]
708
+ }
709
+ }
710
+ ],
711
+ response: "I asked a choice question."
712
+ },
693
713
  {
694
714
  match: /ask.*user|ask.*question|clarif/i,
695
715
  tools: [{ name: "ask_user", arguments: { question: "What would you like me to do?" } }],
@@ -3263,7 +3283,12 @@ async function handleClientMessage(ws, client, message, _getLLMClient, _getActiv
3263
3283
  const compactEvents = compactEventStore.getEvents(sessionId);
3264
3284
  const compactMessages = buildMessagesFromStoredEvents(compactEvents);
3265
3285
  const pendingConfirmations = foldPendingConfirmations(compactEvents);
3266
- sendForSession(sessionId, createSessionStateMessage(updatedSession, compactMessages, pendingConfirmations));
3286
+ const { getPendingQuestionsForSession } = await import("./tools-Z6KF35SO.js");
3287
+ const pendingQuestions = getPendingQuestionsForSession(sessionId);
3288
+ sendForSession(
3289
+ sessionId,
3290
+ createSessionStateMessage(updatedSession, compactMessages, pendingConfirmations, pendingQuestions)
3291
+ );
3267
3292
  } catch (error) {
3268
3293
  logger.error("Compaction failed", { error, sessionId });
3269
3294
  sendForSession(
@@ -3471,8 +3496,8 @@ ${content}` : workflowInfo;
3471
3496
  send(createErrorMessage("INVALID_PAYLOAD", "Invalid ask.answer payload", message.id));
3472
3497
  return;
3473
3498
  }
3474
- const { callId, answer } = message.payload;
3475
- const found = provideAnswer(callId, answer);
3499
+ const { callId, answer, skip } = message.payload;
3500
+ const found = provideAnswer(callId, answer, skip);
3476
3501
  if (!found) {
3477
3502
  send(createErrorMessage("NOT_FOUND", "No pending question with that ID", message.id));
3478
3503
  return;
@@ -5793,7 +5818,7 @@ import { Router as Router6 } from "express";
5793
5818
  import { spawn as spawn5 } from "child_process";
5794
5819
 
5795
5820
  // src/constants.ts
5796
- var VERSION = "2.0.4";
5821
+ var VERSION = "2.0.5";
5797
5822
 
5798
5823
  // src/server/routes/auto-update.ts
5799
5824
  var updateInProgress = false;
@@ -6086,7 +6111,7 @@ async function createServerHandle(config4) {
6086
6111
  res.json({ project });
6087
6112
  });
6088
6113
  app.get("/api/sessions", async (req, res) => {
6089
- const { getRecentUserPromptsForSession } = await import("./events-5SWEG62X.js");
6114
+ const { getRecentUserPromptsForSession } = await import("./events-4K52FKPR.js");
6090
6115
  const projectId = req.query["projectId"];
6091
6116
  const limit = Math.min(parseInt(req.query["limit"]) || 20, 100);
6092
6117
  const offset = parseInt(req.query["offset"]) || 0;
@@ -6119,8 +6144,9 @@ async function createServerHandle(config4) {
6119
6144
  res.status(201).json({ session });
6120
6145
  });
6121
6146
  app.get("/api/sessions/:id", async (req, res) => {
6122
- const { getEventStore: getEventStore2 } = await import("./events-5SWEG62X.js");
6123
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-NUBDA4HS.js");
6147
+ const { getEventStore: getEventStore2 } = await import("./events-4K52FKPR.js");
6148
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-QIBNKYA6.js");
6149
+ const { getPendingQuestionsForSession } = await import("./tools-Z6KF35SO.js");
6124
6150
  const session = sessionManager.getSession(req.params.id);
6125
6151
  if (!session) {
6126
6152
  return res.status(404).json({ error: "Session not found" });
@@ -6130,7 +6156,8 @@ async function createServerHandle(config4) {
6130
6156
  const messages = buildMessagesFromStoredEvents2(events);
6131
6157
  const contextState = sessionManager.getContextState(req.params.id);
6132
6158
  const queueState = sessionManager.getQueueState(req.params.id);
6133
- res.json({ session, messages, contextState, queueState });
6159
+ const pendingQuestions = getPendingQuestionsForSession(req.params.id);
6160
+ res.json({ session, messages, contextState, queueState, pendingQuestions });
6134
6161
  });
6135
6162
  app.delete("/api/sessions/:id", (req, res) => {
6136
6163
  const session = sessionManager.getSession(req.params["id"]);
@@ -6150,8 +6177,8 @@ async function createServerHandle(config4) {
6150
6177
  res.json({ success: true });
6151
6178
  });
6152
6179
  app.post("/api/sessions/:id/provider", async (req, res) => {
6153
- const { getEventStore: getEventStore2 } = await import("./events-5SWEG62X.js");
6154
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-NUBDA4HS.js");
6180
+ const { getEventStore: getEventStore2 } = await import("./events-4K52FKPR.js");
6181
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-QIBNKYA6.js");
6155
6182
  const sessionId = req.params.id;
6156
6183
  const session = sessionManager.getSession(sessionId);
6157
6184
  if (!session) {
@@ -6193,8 +6220,8 @@ async function createServerHandle(config4) {
6193
6220
  res.json({ success: true });
6194
6221
  });
6195
6222
  app.put("/api/sessions/:id/mode", async (req, res) => {
6196
- const { getEventStore: getEventStore2 } = await import("./events-5SWEG62X.js");
6197
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-NUBDA4HS.js");
6223
+ const { getEventStore: getEventStore2 } = await import("./events-4K52FKPR.js");
6224
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2 } = await import("./folding-QIBNKYA6.js");
6198
6225
  const sessionId = req.params.id;
6199
6226
  const session = sessionManager.getSession(sessionId);
6200
6227
  if (!session) {
@@ -6250,32 +6277,37 @@ async function createServerHandle(config4) {
6250
6277
  if (!callId || approved === void 0) {
6251
6278
  return res.status(400).json({ error: "callId and approved are required" });
6252
6279
  }
6253
- const { providePathConfirmation } = await import("./tools-22OPY2O7.js");
6280
+ const { providePathConfirmation } = await import("./tools-Z6KF35SO.js");
6254
6281
  const result = providePathConfirmation(callId, approved, alwaysAllow);
6255
6282
  if (!result.found) {
6256
6283
  return res.status(404).json({ error: "No pending path confirmation with that ID" });
6257
6284
  }
6258
- const { getEventStore: getEventStore2 } = await import("./events-5SWEG62X.js");
6259
- const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-NUBDA4HS.js");
6260
- const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-X53W2J73.js");
6285
+ const { getEventStore: getEventStore2 } = await import("./events-4K52FKPR.js");
6286
+ const { buildMessagesFromStoredEvents: buildMessagesFromStoredEvents2, foldPendingConfirmations: foldPendingConfirmations2 } = await import("./folding-QIBNKYA6.js");
6287
+ const { createSessionStateMessage: createSessionStateMessage2 } = await import("./protocol-YYWMFR35.js");
6288
+ const { getPendingQuestionsForSession } = await import("./tools-Z6KF35SO.js");
6261
6289
  const eventStore = getEventStore2();
6262
6290
  const events = eventStore.getEvents(sessionId);
6263
6291
  const messages = buildMessagesFromStoredEvents2(events);
6264
6292
  const pendingConfirmations = foldPendingConfirmations2(events);
6293
+ const pendingQuestions = getPendingQuestionsForSession(sessionId);
6265
6294
  const session = sessionManager.getSession(sessionId);
6266
6295
  if (session) {
6267
- const stateMsg = createSessionStateMessage2(session, messages, pendingConfirmations);
6296
+ const stateMsg = createSessionStateMessage2(session, messages, pendingConfirmations, pendingQuestions);
6268
6297
  wssExports.broadcastForSession(sessionId, { ...stateMsg, sessionId });
6269
6298
  }
6270
6299
  res.json({ success: true });
6271
6300
  });
6272
6301
  app.post("/api/sessions/:id/answer", async (req, res) => {
6273
- const { callId, answer } = req.body;
6274
- if (!callId || !answer) {
6275
- return res.status(400).json({ error: "callId and answer are required" });
6302
+ const { callId, answer, skip } = req.body;
6303
+ if (!callId) {
6304
+ return res.status(400).json({ error: "callId is required" });
6305
+ }
6306
+ if (!skip && typeof answer !== "string") {
6307
+ return res.status(400).json({ error: "answer is required when not skipping" });
6276
6308
  }
6277
- const { provideAnswer: provideAnswer2 } = await import("./tools-22OPY2O7.js");
6278
- const found = provideAnswer2(callId, answer);
6309
+ const { provideAnswer: provideAnswer2 } = await import("./tools-Z6KF35SO.js");
6310
+ const found = provideAnswer2(callId, answer ?? "", skip ?? false);
6279
6311
  if (!found) {
6280
6312
  return res.status(404).json({ error: "No pending question with that ID" });
6281
6313
  }
@@ -6310,15 +6342,15 @@ async function createServerHandle(config4) {
6310
6342
  if (!session) {
6311
6343
  return res.status(404).json({ error: "Session not found" });
6312
6344
  }
6313
- const { stopSessionExecution } = await import("./chat-handler-WHE75FCD.js");
6314
- const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-22OPY2O7.js");
6345
+ const { stopSessionExecution } = await import("./chat-handler-RQXMBCKX.js");
6346
+ const { cancelQuestionsForSession, cancelPathConfirmationsForSession } = await import("./tools-Z6KF35SO.js");
6315
6347
  const queuedMessages = sessionManager.getQueueState(sessionId);
6316
6348
  sessionManager.clearMessageQueue(sessionId);
6317
6349
  stopSessionExecution(sessionId, sessionManager);
6318
6350
  abortSession(sessionId);
6319
6351
  cancelQuestionsForSession(sessionId, "Session stopped by user");
6320
6352
  cancelPathConfirmationsForSession(sessionId, "Session stopped by user");
6321
- const eventStore = (await import("./events-5SWEG62X.js")).getEventStore();
6353
+ const eventStore = (await import("./events-4K52FKPR.js")).getEventStore();
6322
6354
  eventStore.append(sessionId, { type: "running.changed", data: { isRunning: false } });
6323
6355
  res.json({ success: true, queuedMessages });
6324
6356
  });
@@ -6332,7 +6364,7 @@ async function createServerHandle(config4) {
6332
6364
  if (typeof messageIndex !== "number" || messageIndex < 0) {
6333
6365
  return res.status(400).json({ error: "messageIndex must be a non-negative number" });
6334
6366
  }
6335
- const { truncateSessionMessages } = await import("./events-5SWEG62X.js");
6367
+ const { truncateSessionMessages } = await import("./events-4K52FKPR.js");
6336
6368
  truncateSessionMessages(sessionId, messageIndex);
6337
6369
  res.json({ success: true });
6338
6370
  });
@@ -6350,7 +6382,7 @@ async function createServerHandle(config4) {
6350
6382
  if (!msg) {
6351
6383
  return res.status(400).json({ error: "Message not found at this index" });
6352
6384
  }
6353
- const { truncateSessionMessages } = await import("./events-5SWEG62X.js");
6385
+ const { truncateSessionMessages } = await import("./events-4K52FKPR.js");
6354
6386
  truncateSessionMessages(sessionId, messageIndex - 1);
6355
6387
  sessionManager.queueMessage(sessionId, "asap", msg.content, msg.attachments, msg.messageKind);
6356
6388
  res.json({ success: true });
@@ -6921,7 +6953,7 @@ async function createServerHandle(config4) {
6921
6953
  providerManager
6922
6954
  );
6923
6955
  const wss = wssExports.wss;
6924
- const { QueueProcessor } = await import("./processor-7TYZNS4I.js");
6956
+ const { QueueProcessor } = await import("./processor-KRBBTKRS.js");
6925
6957
  const queueProcessor = new QueueProcessor({
6926
6958
  sessionManager,
6927
6959
  providerManager,
@@ -6995,4 +7027,4 @@ export {
6995
7027
  createServerHandle,
6996
7028
  createServer
6997
7029
  };
6998
- //# sourceMappingURL=chunk-O2MR653P.js.map
7030
+ //# sourceMappingURL=chunk-DXV74LCI.js.map
@@ -48,6 +48,16 @@ var askUserTool = {
48
48
  question: {
49
49
  type: "string",
50
50
  description: "The question to ask the user"
51
+ },
52
+ type: {
53
+ type: "string",
54
+ enum: ["text", "confirm", "choice"],
55
+ description: "Type of question (text, confirm, or choice)"
56
+ },
57
+ options: {
58
+ type: "array",
59
+ items: { type: "string" },
60
+ description: "Options for choice-type questions"
51
61
  }
52
62
  },
53
63
  required: ["question"]
@@ -56,7 +66,9 @@ var askUserTool = {
56
66
  },
57
67
  async execute(args, context) {
58
68
  const question = args["question"];
59
- const callId = crypto.randomUUID();
69
+ const type = args["type"] ?? "text";
70
+ const options = args["options"];
71
+ const callId = context.toolCallId ?? crypto.randomUUID();
60
72
  const deferred = createDeferred();
61
73
  void deferred.promise.catch(() => {
62
74
  });
@@ -64,25 +76,30 @@ var askUserTool = {
64
76
  promise: deferred.promise,
65
77
  resolve: deferred.resolve,
66
78
  reject: deferred.reject,
67
- sessionId: context.sessionId
79
+ sessionId: context.sessionId,
80
+ question,
81
+ type,
82
+ options
68
83
  });
69
- throw new AskUserInterrupt(callId, question);
84
+ throw new AskUserInterrupt(callId, question, type, options);
70
85
  }
71
86
  };
72
87
  var AskUserInterrupt = class extends Error {
73
- constructor(callId, question) {
88
+ constructor(callId, question, type = "text", options) {
74
89
  super("Ask user interrupt");
75
90
  this.callId = callId;
76
91
  this.question = question;
92
+ this.type = type;
93
+ this.options = options;
77
94
  this.name = "AskUserInterrupt";
78
95
  }
79
96
  };
80
- function provideAnswer(callId, answer) {
97
+ function provideAnswer(callId, answer, skip) {
81
98
  const pending = pendingQuestions.get(callId);
82
99
  if (!pending) {
83
100
  return false;
84
101
  }
85
- pending.resolve(answer);
102
+ pending.resolve(skip ? "[user skipped]" : answer);
86
103
  pendingQuestions.delete(callId);
87
104
  return true;
88
105
  }
@@ -114,6 +131,15 @@ function awaitAnswer(callId) {
114
131
  const pending = pendingQuestions.get(callId);
115
132
  return pending?.promise ?? null;
116
133
  }
134
+ function getPendingQuestionsForSession(sessionId) {
135
+ const result = [];
136
+ for (const [callId, pending] of pendingQuestions.entries()) {
137
+ if (pending.sessionId === sessionId) {
138
+ result.push({ callId, question: pending.question, type: pending.type, options: pending.options });
139
+ }
140
+ }
141
+ return result;
142
+ }
117
143
 
118
144
  export {
119
145
  EventEmitter,
@@ -123,6 +149,7 @@ export {
123
149
  cancelQuestion,
124
150
  cancelQuestionsForSession,
125
151
  hasPendingQuestion,
126
- awaitAnswer
152
+ awaitAnswer,
153
+ getPendingQuestionsForSession
127
154
  };
128
- //# sourceMappingURL=chunk-BJYPTN5S.js.map
155
+ //# sourceMappingURL=chunk-EU3WWTFH.js.map
@@ -694,7 +694,7 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages) {
694
694
  }
695
695
  case "chat.ask_user": {
696
696
  const data = event.data;
697
- pendingUserInput = { callId: data.callId, question: data.question };
697
+ pendingUserInput = { callId: data.callId, question: data.question, type: data.type, options: data.options };
698
698
  break;
699
699
  }
700
700
  case "task.completed": {
@@ -856,4 +856,4 @@ export {
856
856
  getMessagesForWindow,
857
857
  buildContextMessagesFromMessages
858
858
  };
859
- //# sourceMappingURL=chunk-4HBWSC6K.js.map
859
+ //# sourceMappingURL=chunk-LX66KJPL.js.map
@@ -5,7 +5,7 @@ import {
5
5
  foldContextState,
6
6
  foldSessionState,
7
7
  spreadOptionalMessageFields
8
- } from "./chunk-4HBWSC6K.js";
8
+ } from "./chunk-LX66KJPL.js";
9
9
  import {
10
10
  getDatabase
11
11
  } from "./chunk-FBGWG4N6.js";
@@ -1397,4 +1397,4 @@ export {
1397
1397
  truncateSessionMessages,
1398
1398
  getRecentUserPromptsForSession
1399
1399
  };
1400
- //# sourceMappingURL=chunk-FRJQC77Y.js.map
1400
+ //# sourceMappingURL=chunk-SYG2ENUQ.js.map