openfox 2.0.143 → 2.0.144

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 (69) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/CHANGELOG.md +11 -0
  3. package/dist/auto-continue-M3RPFGFI.js +111 -0
  4. package/dist/{chat-handler-VDB4CSXK.js → chat-handler-QOOQOHHR.js} +26 -25
  5. package/dist/{chunk-EX6ROYYS.js → chunk-2DBWCXAQ.js} +3 -3
  6. package/dist/chunk-2DVAF6HY.js +447 -0
  7. package/dist/{chunk-CYTC2E3O.js → chunk-3IVJ65IG.js} +12 -10
  8. package/dist/{chunk-IMQDO5EJ.js → chunk-5ONERSDK.js} +124 -107
  9. package/dist/{chunk-QZV3M6V5.js → chunk-5XKWYLBX.js} +18 -16
  10. package/dist/{chunk-KVDOPLXJ.js → chunk-AWBV2VXO.js} +2 -2
  11. package/dist/{chunk-Z4CTMGFH.js → chunk-C4LI5U6L.js} +36 -34
  12. package/dist/{chunk-F3R4YS3F.js → chunk-CCIG3YLG.js} +2 -2
  13. package/dist/{chunk-2CEZQAGQ.js → chunk-DJH6LMBT.js} +2 -2
  14. package/dist/{chunk-EFEHIJXF.js → chunk-E4F32L4Q.js} +2 -2
  15. package/dist/{chunk-CTAYPMB2.js → chunk-FAN4P45J.js} +2 -2
  16. package/dist/{chunk-5KA3L46F.js → chunk-FLTNKZNQ.js} +9 -9
  17. package/dist/{chunk-DNL2NUDB.js → chunk-GZ4EK4LZ.js} +2 -2
  18. package/dist/{chunk-FHBLF2QR.js → chunk-L2RESXUF.js} +2 -2
  19. package/dist/{chunk-VKZBCC75.js → chunk-MBDYJ35W.js} +13 -11
  20. package/dist/{chunk-DQEANXXF.js → chunk-ODETQHMI.js} +3 -3
  21. package/dist/{chunk-H3QN2J4X.js → chunk-OSUEWIVU.js} +10 -8
  22. package/dist/{chunk-HZOL7UEC.js → chunk-QURYQA4D.js} +4 -4
  23. package/dist/{chunk-N5AJHJG5.js → chunk-STVJA7IX.js} +3 -3
  24. package/dist/{chunk-WSDR27YV.js → chunk-UO4X2ENE.js} +2 -2
  25. package/dist/{chunk-SJTBOREW.js → chunk-VFHGN3IS.js} +4 -4
  26. package/dist/{chunk-SKNPOZYP.js → chunk-X6SWZEK7.js} +3 -1
  27. package/dist/{chunk-TIIWXMGE.js → chunk-X7ZAP6YW.js} +2 -2
  28. package/dist/{chunk-MEPTCUYN.js → chunk-YEFZ5HBD.js} +2 -2
  29. package/dist/{chunk-DRIR2IZR.js → chunk-YEW4YEJU.js} +2 -2
  30. package/dist/{chunk-NJFXYSXP.js → chunk-YRSZJ7IZ.js} +11 -441
  31. package/dist/{chunk-7XA3MEX2.js → chunk-Z3C3D4IR.js} +24 -22
  32. package/dist/{chunk-Z7IT3V22.js → chunk-ZONLEX2F.js} +8 -4
  33. package/dist/chunk-ZSGELOTW.js +7 -0
  34. package/dist/cli/dev.js +1 -1
  35. package/dist/cli/index.js +1 -1
  36. package/dist/{client-ZEGIB3MF.js → client-L4PANCG4.js} +4 -4
  37. package/dist/{compactor-2MSRXHVA.js → compactor-53WDNC2S.js} +11 -10
  38. package/dist/{describe-image-QSEMMRV7.js → describe-image-IGLGVEOJ.js} +12 -11
  39. package/dist/{dynamic-context-3THEBFBI.js → dynamic-context-CR4RUXOX.js} +11 -10
  40. package/dist/{events-UAUOGRSV.js → events-ODZ4SSBW.js} +11 -9
  41. package/dist/{export-import-SYYISNTZ.js → export-import-3WOHC7PI.js} +10 -8
  42. package/dist/{folding-IHD244OU.js → folding-V2R2MZ6Y.js} +4 -4
  43. package/dist/{http-client-RA7XFYPO.js → http-client-SZZBSL4U.js} +3 -3
  44. package/dist/{launch-MF2VT7SU.js → launch-4COI5RGL.js} +26 -25
  45. package/dist/{manager-4SMHCFXY.js → manager-PDG7RKPA.js} +4 -4
  46. package/dist/{orchestrator-BU4RJHPZ.js → orchestrator-AMTWA6JO.js} +25 -24
  47. package/dist/package.json +1 -1
  48. package/dist/{path-security-WOA6MTWQ.js → path-security-3YFS3GJQ.js} +9 -8
  49. package/dist/{platform-EAZNZDAE.js → platform-WCXMN4NM.js} +3 -3
  50. package/dist/{processor-IZ4EAHPD.js → processor-UZ7OBCAK.js} +25 -24
  51. package/dist/{provider-YNTH5YG5.js → provider-QE7XSGYA.js} +5 -5
  52. package/dist/{provider-manager-2UENHAAA.js → provider-manager-WW2EF76W.js} +5 -5
  53. package/dist/{registry-C7RKKHZB.js → registry-24U5BZAJ.js} +3 -3
  54. package/dist/{serve-KKAOO7YM.js → serve-NLQ6IB2V.js} +31 -30
  55. package/dist/server/index.js +30 -29
  56. package/dist/{server-PVO4USPN.js → server-YXKUQ3DD.js} +29 -28
  57. package/dist/{service-OQZWTW34.js → service-KMOSB6SU.js} +7 -7
  58. package/dist/{session-overrides-CKS2AVE5.js → session-overrides-GQKE7WGE.js} +5 -5
  59. package/dist/{sessions-DAHLRQE2.js → sessions-A3IZYL6X.js} +4 -4
  60. package/dist/{settings-TR4BF2C4.js → settings-FQUDSGZF.js} +2 -2
  61. package/dist/store-AOZ46PBS.js +23 -0
  62. package/dist/{tasks-WC23TK6I.js → tasks-X5DM553T.js} +7 -7
  63. package/dist/{tools-CECV6XQ6.js → tools-7L63ZMNU.js} +30 -29
  64. package/dist/{update-6MBRWJAV.js → update-IBN2GJUI.js} +2 -2
  65. package/dist/web/assets/{index-CxuR2kCS.js → index-DL26wmhi.js} +74 -74
  66. package/dist/web/index.html +1 -1
  67. package/dist/web/sw.js +1 -1
  68. package/package.json +1 -1
  69. package/dist/chunk-6DLQ2AV4.js +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.144 - 2026-09-11
4
+
5
+ ### Features
6
+
7
+ - **New criteria stream live in the feed** — criteria additions appear in the feed's criteria group as they are generated, no refresh needed.
8
+ - **Opt-in boot auto-continuation** — sessions interrupted by a restart resume automatically on the next launch.
9
+
10
+ ### Bug Fixes
11
+
12
+ - **Installed version detected on localized CLIs** — the version is now parsed correctly even when the CLI outputs French or another language.
13
+
3
14
  ## 2.0.143 - 2026-09-10
4
15
 
5
16
  ### Features
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.144 - 2026-09-11
4
+
5
+ ### Features
6
+
7
+ - **New criteria stream live in the feed** — criteria additions appear in the feed's criteria group as they are generated, no refresh needed.
8
+ - **Opt-in boot auto-continuation** — sessions interrupted by a restart resume automatically on the next launch.
9
+
10
+ ### Bug Fixes
11
+
12
+ - **Installed version detected on localized CLIs** — the version is now parsed correctly even when the CLI outputs French or another language.
13
+
3
14
  ## 2.0.143 - 2026-09-10
4
15
 
5
16
  ### Features
@@ -0,0 +1,111 @@
1
+ import "./chunk-C4LI5U6L.js";
2
+ import "./chunk-OAN4BXEW.js";
3
+ import "./chunk-DJH6LMBT.js";
4
+ import "./chunk-PHR64A6U.js";
5
+ import "./chunk-J7GAZGZT.js";
6
+ import "./chunk-2DBWCXAQ.js";
7
+ import "./chunk-UO4X2ENE.js";
8
+ import "./chunk-FLTNKZNQ.js";
9
+ import "./chunk-X7ZAP6YW.js";
10
+ import "./chunk-STVJA7IX.js";
11
+ import {
12
+ createMessageDoneEvent
13
+ } from "./chunk-FAN4P45J.js";
14
+ import {
15
+ CONTINUE_AFTER_STREAM_ERROR_PROMPT,
16
+ CONTINUE_PROMPT
17
+ } from "./chunk-ZONLEX2F.js";
18
+ import "./chunk-VGE6UYND.js";
19
+ import "./chunk-ODETQHMI.js";
20
+ import "./chunk-I72ACQ6R.js";
21
+ import "./chunk-VIJVLLPT.js";
22
+ import "./chunk-2DVAF6HY.js";
23
+ import "./chunk-YRSZJ7IZ.js";
24
+ import "./chunk-E4F32L4Q.js";
25
+ import "./chunk-CCIG3YLG.js";
26
+ import "./chunk-YEW4YEJU.js";
27
+ import "./chunk-OSXPQSLW.js";
28
+ import "./chunk-V5AC2TV7.js";
29
+ import "./chunk-OVAHNEFG.js";
30
+ import "./chunk-LCLH6ZUL.js";
31
+ import "./chunk-YEFZ5HBD.js";
32
+ import "./chunk-AWBV2VXO.js";
33
+ import "./chunk-OA2FURC3.js";
34
+ import "./chunk-J2GP3J3X.js";
35
+ import "./chunk-JYYBSODN.js";
36
+ import "./chunk-L2RESXUF.js";
37
+ import "./chunk-TS5WKTFB.js";
38
+ import "./chunk-FTPQI5TA.js";
39
+ import "./chunk-HNCM3D7Y.js";
40
+ import "./chunk-QMU3ZY2C.js";
41
+ import "./chunk-FSSUPWYO.js";
42
+ import "./chunk-XG3AUMPI.js";
43
+ import "./chunk-GZ4EK4LZ.js";
44
+ import "./chunk-X6SWZEK7.js";
45
+ import "./chunk-WOVWVB5J.js";
46
+ import "./chunk-VKMPR25F.js";
47
+ import {
48
+ logger
49
+ } from "./chunk-K44MW7JJ.js";
50
+ import "./chunk-PW5L4WBG.js";
51
+ import "./chunk-24YKXKCG.js";
52
+ import "./chunk-73BO5OT3.js";
53
+ import "./chunk-CQGTEGKL.js";
54
+ import "./chunk-YLJ4XMA6.js";
55
+
56
+ // src/server/session/auto-continue.ts
57
+ function planBootContinuation(events, hasActiveWorkflow) {
58
+ if (hasActiveWorkflow) return null;
59
+ const finalizeMessageId = findUnfinalizedAssistantMessage(events);
60
+ return finalizeMessageId ? { finalizeMessageId, content: CONTINUE_AFTER_STREAM_ERROR_PROMPT } : { content: CONTINUE_PROMPT };
61
+ }
62
+ function findUnfinalizedAssistantMessage(events) {
63
+ let lastAssistantId;
64
+ const finalized = /* @__PURE__ */ new Set();
65
+ for (const event of events) {
66
+ switch (event.type) {
67
+ case "message.start": {
68
+ const data = event.data;
69
+ if (data.role === "assistant") {
70
+ lastAssistantId = data.messageId;
71
+ }
72
+ break;
73
+ }
74
+ case "message.done":
75
+ case "chat.done": {
76
+ const data = event.data;
77
+ if (data.messageId) {
78
+ finalized.add(data.messageId);
79
+ }
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ if (lastAssistantId && !finalized.has(lastAssistantId)) {
85
+ return lastAssistantId;
86
+ }
87
+ return void 0;
88
+ }
89
+ function runBootAutoContinuations(sessionIds, deps) {
90
+ let continued = 0;
91
+ for (const sessionId of sessionIds) {
92
+ const plan = planBootContinuation(deps.getEvents(sessionId), deps.hasActiveWorkflow(sessionId));
93
+ if (!plan) {
94
+ logger.debug("Skipping boot auto-continuation", { sessionId });
95
+ continue;
96
+ }
97
+ if (plan.finalizeMessageId) {
98
+ deps.appendEvent(sessionId, createMessageDoneEvent(plan.finalizeMessageId, { partial: true }));
99
+ }
100
+ deps.queueMessage(sessionId, plan.content);
101
+ continued++;
102
+ }
103
+ return continued;
104
+ }
105
+ export {
106
+ CONTINUE_AFTER_STREAM_ERROR_PROMPT,
107
+ CONTINUE_PROMPT,
108
+ planBootContinuation,
109
+ runBootAutoContinuations
110
+ };
111
+ //# sourceMappingURL=auto-continue-M3RPFGFI.js.map
@@ -2,55 +2,56 @@ import {
2
2
  buildRunChatTurnParams,
3
3
  finalizeTurnCompletion,
4
4
  generateSessionNameForSession
5
- } from "./chunk-CYTC2E3O.js";
5
+ } from "./chunk-3IVJ65IG.js";
6
6
  import {
7
7
  runChatTurn
8
- } from "./chunk-QZV3M6V5.js";
9
- import "./chunk-H3QN2J4X.js";
10
- import "./chunk-Z4CTMGFH.js";
11
- import "./chunk-2CEZQAGQ.js";
8
+ } from "./chunk-5XKWYLBX.js";
9
+ import "./chunk-OSUEWIVU.js";
10
+ import "./chunk-C4LI5U6L.js";
11
+ import "./chunk-OAN4BXEW.js";
12
+ import "./chunk-DJH6LMBT.js";
12
13
  import "./chunk-PHR64A6U.js";
13
14
  import "./chunk-J7GAZGZT.js";
14
- import "./chunk-EX6ROYYS.js";
15
- import "./chunk-WSDR27YV.js";
16
- import "./chunk-5KA3L46F.js";
17
- import "./chunk-TIIWXMGE.js";
18
- import "./chunk-CTAYPMB2.js";
19
- import "./chunk-Z7IT3V22.js";
15
+ import "./chunk-2DBWCXAQ.js";
16
+ import "./chunk-UO4X2ENE.js";
17
+ import "./chunk-FLTNKZNQ.js";
18
+ import "./chunk-X7ZAP6YW.js";
19
+ import "./chunk-STVJA7IX.js";
20
+ import "./chunk-FAN4P45J.js";
21
+ import "./chunk-ZONLEX2F.js";
20
22
  import "./chunk-VGE6UYND.js";
21
- import "./chunk-DQEANXXF.js";
23
+ import "./chunk-ODETQHMI.js";
22
24
  import "./chunk-I72ACQ6R.js";
23
25
  import "./chunk-VIJVLLPT.js";
24
- import "./chunk-OAN4BXEW.js";
25
- import "./chunk-V5AC2TV7.js";
26
- import "./chunk-N5AJHJG5.js";
26
+ import "./chunk-2DVAF6HY.js";
27
27
  import {
28
28
  getEventStore
29
- } from "./chunk-NJFXYSXP.js";
30
- import "./chunk-EFEHIJXF.js";
31
- import "./chunk-F3R4YS3F.js";
32
- import "./chunk-DRIR2IZR.js";
29
+ } from "./chunk-YRSZJ7IZ.js";
30
+ import "./chunk-E4F32L4Q.js";
31
+ import "./chunk-CCIG3YLG.js";
32
+ import "./chunk-YEW4YEJU.js";
33
33
  import "./chunk-OSXPQSLW.js";
34
+ import "./chunk-V5AC2TV7.js";
34
35
  import {
35
36
  createChatMessageMessage,
36
37
  createPhaseChangedMessage,
37
38
  createSessionRunningMessage
38
39
  } from "./chunk-OVAHNEFG.js";
39
40
  import "./chunk-LCLH6ZUL.js";
40
- import "./chunk-MEPTCUYN.js";
41
- import "./chunk-KVDOPLXJ.js";
41
+ import "./chunk-YEFZ5HBD.js";
42
+ import "./chunk-AWBV2VXO.js";
42
43
  import "./chunk-OA2FURC3.js";
43
44
  import "./chunk-J2GP3J3X.js";
44
45
  import "./chunk-JYYBSODN.js";
45
- import "./chunk-FHBLF2QR.js";
46
+ import "./chunk-L2RESXUF.js";
46
47
  import "./chunk-TS5WKTFB.js";
47
48
  import "./chunk-FTPQI5TA.js";
48
49
  import "./chunk-HNCM3D7Y.js";
49
50
  import "./chunk-QMU3ZY2C.js";
50
51
  import "./chunk-FSSUPWYO.js";
51
52
  import "./chunk-XG3AUMPI.js";
52
- import "./chunk-DNL2NUDB.js";
53
- import "./chunk-SKNPOZYP.js";
53
+ import "./chunk-GZ4EK4LZ.js";
54
+ import "./chunk-X6SWZEK7.js";
54
55
  import "./chunk-WOVWVB5J.js";
55
56
  import "./chunk-VKMPR25F.js";
56
57
  import "./chunk-K44MW7JJ.js";
@@ -180,4 +181,4 @@ export {
180
181
  startChatSession,
181
182
  stopSessionExecution
182
183
  };
183
- //# sourceMappingURL=chat-handler-VDB4CSXK.js.map
184
+ //# sourceMappingURL=chat-handler-QOOQOHHR.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serverT
3
- } from "./chunk-TIIWXMGE.js";
3
+ } from "./chunk-X7ZAP6YW.js";
4
4
  import {
5
5
  deleteItemFromDir,
6
6
  getDefaultIds,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-OSXPQSLW.js";
12
12
  import {
13
13
  parseDefaultModelSelection
14
- } from "./chunk-KVDOPLXJ.js";
14
+ } from "./chunk-AWBV2VXO.js";
15
15
  import {
16
16
  getProject
17
17
  } from "./chunk-JYYBSODN.js";
@@ -1462,4 +1462,4 @@ export {
1462
1462
  isTaskGateError,
1463
1463
  createTasksService
1464
1464
  };
1465
- //# sourceMappingURL=chunk-EX6ROYYS.js.map
1465
+ //# sourceMappingURL=chunk-2DBWCXAQ.js.map
@@ -0,0 +1,447 @@
1
+ import {
2
+ getEventStore
3
+ } from "./chunk-YRSZJ7IZ.js";
4
+ import {
5
+ buildContextMessagesFromEventHistory,
6
+ buildMessagesFromStoredEvents,
7
+ foldContextState,
8
+ foldSessionState,
9
+ spreadOptionalMessageFields
10
+ } from "./chunk-E4F32L4Q.js";
11
+ import {
12
+ updateSessionMessageCount
13
+ } from "./chunk-CCIG3YLG.js";
14
+ import {
15
+ getRuntimeConfig
16
+ } from "./chunk-YEW4YEJU.js";
17
+
18
+ // src/server/events/types.ts
19
+ function isTurnEvent(event) {
20
+ return typeof event === "object" && event !== null && "type" in event && "data" in event && typeof event.type === "string";
21
+ }
22
+ function isStoredEvent(event) {
23
+ return typeof event === "object" && event !== null && "seq" in event && "timestamp" in event && "sessionId" in event && "type" in event && "data" in event;
24
+ }
25
+ function createEvent(type, data) {
26
+ return { type, data };
27
+ }
28
+
29
+ // src/server/events/session.ts
30
+ function combineEventsWithSnapshot(sessionId, snapshot, events) {
31
+ if (!snapshot) return events;
32
+ const snapshotEvent = {
33
+ seq: 0,
34
+ timestamp: snapshot.snapshotAt,
35
+ sessionId,
36
+ type: "turn.snapshot",
37
+ data: snapshot
38
+ };
39
+ return [snapshotEvent, ...events];
40
+ }
41
+ function toSnapshotMessage(message) {
42
+ return {
43
+ id: message.id,
44
+ role: message.role,
45
+ content: message.content,
46
+ timestamp: new Date(message.timestamp).getTime(),
47
+ ...spreadOptionalMessageFields(message)
48
+ };
49
+ }
50
+ function getSessionState(sessionId, maxTokens, defaultMode) {
51
+ const eventStore = getEventStore();
52
+ const { snapshot: latestSnapshot, events: rawEvents } = eventStore.getEventsSinceSnapshot(sessionId);
53
+ const events = combineEventsWithSnapshot(sessionId, latestSnapshot, rawEvents);
54
+ if (events.length === 0) {
55
+ return void 0;
56
+ }
57
+ let initialWindowId;
58
+ for (const event of events) {
59
+ if (event.type === "session.initialized") {
60
+ const data = event.data;
61
+ initialWindowId = data.contextWindowId;
62
+ break;
63
+ }
64
+ }
65
+ if (!initialWindowId) {
66
+ for (const event of events) {
67
+ if (event.type === "turn.snapshot") {
68
+ const snapshotData = event.data;
69
+ if (snapshotData.sessionInit?.contextWindowId) {
70
+ initialWindowId = snapshotData.sessionInit.contextWindowId;
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ }
76
+ if (!initialWindowId) {
77
+ for (const event of events) {
78
+ if (event.type === "turn.snapshot") {
79
+ const snapshotData = event.data;
80
+ if (snapshotData.currentContextWindowId) {
81
+ initialWindowId = snapshotData.currentContextWindowId;
82
+ break;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ if (!initialWindowId) {
88
+ return void 0;
89
+ }
90
+ const config = getRuntimeConfig();
91
+ const effectiveMaxTokens = maxTokens ?? config.context.maxTokens;
92
+ if (latestSnapshot) {
93
+ const state = foldSessionState(events, initialWindowId, effectiveMaxTokens, void 0, defaultMode);
94
+ return {
95
+ ...state,
96
+ messages: buildMessagesFromStoredEvents(events).messages.map(toSnapshotMessage)
97
+ };
98
+ }
99
+ return foldSessionState(events, initialWindowId, effectiveMaxTokens, void 0, defaultMode);
100
+ }
101
+ function getCurrentWindowMessages(sessionId) {
102
+ const currentWindowId = getCurrentContextWindowId(sessionId);
103
+ if (!currentWindowId) return [];
104
+ const state = getSessionState(sessionId);
105
+ if (!state) return [];
106
+ return state.messages.filter((m) => m.contextWindowId === currentWindowId);
107
+ }
108
+ function getContextMessages(sessionId) {
109
+ const eventStore = getEventStore();
110
+ const currentWindowId = getCurrentContextWindowId(sessionId);
111
+ if (!currentWindowId) return [];
112
+ const { snapshot: ctxSnapshot, events: ctxRawEvents } = eventStore.getEventsSinceSnapshot(sessionId);
113
+ const events = combineEventsWithSnapshot(sessionId, ctxSnapshot, ctxRawEvents);
114
+ if (events.length === 0) return [];
115
+ return buildContextMessagesFromEventHistory(events, currentWindowId, { includeVerifier: false });
116
+ }
117
+ function getCurrentContextWindowId(sessionId) {
118
+ const eventStore = getEventStore();
119
+ const events = eventStore.getEvents(sessionId);
120
+ const contextResult = foldContextState(events, "");
121
+ return contextResult.currentContextWindowId || void 0;
122
+ }
123
+ function getCurrentWindowMessageOptions(sessionId) {
124
+ const contextWindowId = getCurrentContextWindowId(sessionId);
125
+ return contextWindowId ? { contextWindowId } : void 0;
126
+ }
127
+ function getReadFilesCache(sessionId) {
128
+ const state = getSessionState(sessionId);
129
+ return state?.readFiles ?? [];
130
+ }
131
+ function isFileInCache(sessionId, path) {
132
+ const cache = getReadFilesCache(sessionId);
133
+ return cache.some((f) => f.path === path);
134
+ }
135
+ function emitSessionInitialized(sessionId, projectId, workdir, contextWindowId, title) {
136
+ const eventStore = getEventStore();
137
+ eventStore.append(sessionId, {
138
+ type: "session.initialized",
139
+ data: {
140
+ projectId,
141
+ workdir,
142
+ contextWindowId,
143
+ ...title !== void 0 && { title }
144
+ }
145
+ });
146
+ }
147
+ function emitUserMessage(sessionId, content, options) {
148
+ const eventStore = getEventStore();
149
+ const messageId = crypto.randomUUID();
150
+ eventStore.append(sessionId, {
151
+ type: "message.start",
152
+ data: {
153
+ messageId,
154
+ role: "user",
155
+ content,
156
+ ...options?.contextWindowId !== void 0 && { contextWindowId: options.contextWindowId },
157
+ ...options?.isSystemGenerated !== void 0 && { isSystemGenerated: options.isSystemGenerated },
158
+ ...options?.messageKind !== void 0 && { messageKind: options.messageKind },
159
+ ...options?.isCompactionSummary !== void 0 && { isCompactionSummary: options.isCompactionSummary },
160
+ ...options?.tokenCount !== void 0 && { tokenCount: options.tokenCount },
161
+ ...options?.attachments !== void 0 && { attachments: options.attachments },
162
+ ...options?.subAgentId !== void 0 && { subAgentId: options.subAgentId },
163
+ ...options?.subAgentType !== void 0 && { subAgentType: options.subAgentType },
164
+ ...options?.metadata !== void 0 && { metadata: options.metadata }
165
+ }
166
+ });
167
+ eventStore.append(sessionId, {
168
+ type: "message.done",
169
+ data: { messageId }
170
+ });
171
+ updateSessionMessageCount(sessionId, 1);
172
+ return messageId;
173
+ }
174
+ function emitAssistantMessageStart(sessionId, options) {
175
+ const eventStore = getEventStore();
176
+ const messageId = crypto.randomUUID();
177
+ eventStore.append(sessionId, {
178
+ type: "message.start",
179
+ data: {
180
+ messageId,
181
+ role: "assistant",
182
+ ...options?.contextWindowId !== void 0 && { contextWindowId: options.contextWindowId },
183
+ ...options?.subAgentId !== void 0 && { subAgentId: options.subAgentId },
184
+ ...options?.subAgentType !== void 0 && { subAgentType: options.subAgentType }
185
+ }
186
+ });
187
+ updateSessionMessageCount(sessionId, 1);
188
+ return messageId;
189
+ }
190
+ function emitMessageDelta(sessionId, messageId, content) {
191
+ const eventStore = getEventStore();
192
+ eventStore.append(sessionId, {
193
+ type: "message.delta",
194
+ data: { messageId, content }
195
+ });
196
+ }
197
+ function emitMessageThinking(sessionId, messageId, content) {
198
+ const eventStore = getEventStore();
199
+ eventStore.append(sessionId, {
200
+ type: "message.thinking",
201
+ data: { messageId, content }
202
+ });
203
+ }
204
+ function emitMessageDone(sessionId, messageId, options) {
205
+ const eventStore = getEventStore();
206
+ eventStore.append(sessionId, {
207
+ type: "message.done",
208
+ data: {
209
+ messageId,
210
+ ...options?.stats !== void 0 && { stats: options.stats },
211
+ ...options?.segments !== void 0 && { segments: options.segments },
212
+ ...options?.partial !== void 0 && { partial: options.partial },
213
+ ...options?.tokenCount !== void 0 && { tokenCount: options.tokenCount }
214
+ }
215
+ });
216
+ }
217
+ function emitToolPreparing(sessionId, messageId, index, name) {
218
+ const eventStore = getEventStore();
219
+ eventStore.append(sessionId, {
220
+ type: "tool.preparing",
221
+ data: { messageId, index, name }
222
+ });
223
+ }
224
+ function emitToolCall(sessionId, messageId, toolCall) {
225
+ const eventStore = getEventStore();
226
+ eventStore.append(sessionId, {
227
+ type: "tool.call",
228
+ data: { messageId, toolCall }
229
+ });
230
+ }
231
+ function emitToolOutput(sessionId, messageId, toolCallId, stream, content) {
232
+ const eventStore = getEventStore();
233
+ eventStore.append(sessionId, {
234
+ type: "tool.output",
235
+ data: { messageId, toolCallId, stream, content }
236
+ });
237
+ }
238
+ function emitToolResult(sessionId, messageId, toolCallId, result) {
239
+ const eventStore = getEventStore();
240
+ eventStore.append(sessionId, {
241
+ type: "tool.result",
242
+ data: { messageId, toolCallId, result }
243
+ });
244
+ }
245
+ function emitModeChanged(sessionId, mode, auto, reason) {
246
+ const eventStore = getEventStore();
247
+ eventStore.append(sessionId, {
248
+ type: "mode.changed",
249
+ data: {
250
+ mode,
251
+ auto,
252
+ ...reason !== void 0 && { reason }
253
+ }
254
+ });
255
+ }
256
+ function emitPhaseChanged(sessionId, phase) {
257
+ const eventStore = getEventStore();
258
+ eventStore.append(sessionId, {
259
+ type: "phase.changed",
260
+ data: { phase }
261
+ });
262
+ }
263
+ function emitRunningChanged(sessionId, isRunning) {
264
+ const eventStore = getEventStore();
265
+ eventStore.append(sessionId, {
266
+ type: "running.changed",
267
+ data: { isRunning }
268
+ });
269
+ }
270
+ function emitWorkflowExecutionChanged(sessionId, executionId, workflowId, workflowName, workflowColor, status, currentStepId, currentStepName, pendingChoices) {
271
+ const eventStore = getEventStore();
272
+ eventStore.append(sessionId, {
273
+ type: "workflow.execution_changed",
274
+ data: {
275
+ executionId,
276
+ workflowId,
277
+ workflowName,
278
+ ...workflowColor ? { workflowColor } : {},
279
+ status,
280
+ ...currentStepId ? { currentStepId } : {},
281
+ ...currentStepName ? { currentStepName } : {},
282
+ ...pendingChoices !== void 0 ? { pendingChoices } : {}
283
+ }
284
+ });
285
+ }
286
+ function emitCriteriaSet(sessionId, criteria) {
287
+ const eventStore = getEventStore();
288
+ eventStore.append(sessionId, {
289
+ type: "criteria.set",
290
+ data: { criteria }
291
+ });
292
+ }
293
+ function emitCriterionUpdated(sessionId, criterionId, status) {
294
+ const eventStore = getEventStore();
295
+ eventStore.append(sessionId, {
296
+ type: "criterion.updated",
297
+ data: { criterionId, status }
298
+ });
299
+ }
300
+ function emitTodosUpdated(sessionId, todos) {
301
+ const eventStore = getEventStore();
302
+ eventStore.append(sessionId, {
303
+ type: "todo.updated",
304
+ data: { todos }
305
+ });
306
+ }
307
+ function emitMetadataSet(sessionId, key, entries) {
308
+ const eventStore = getEventStore();
309
+ eventStore.append(sessionId, {
310
+ type: "metadata.set",
311
+ data: { key, entries }
312
+ });
313
+ }
314
+ function emitFileRead(sessionId, path, tokenCount, contextWindowId) {
315
+ const eventStore = getEventStore();
316
+ eventStore.append(sessionId, {
317
+ type: "file.read",
318
+ data: { path, tokenCount, contextWindowId }
319
+ });
320
+ }
321
+ function emitContextCompacted(sessionId, closedWindowId, newWindowId, beforeTokens, afterTokens, summary) {
322
+ const eventStore = getEventStore();
323
+ eventStore.append(sessionId, {
324
+ type: "context.compacted",
325
+ data: {
326
+ closedWindowId,
327
+ newWindowId,
328
+ beforeTokens,
329
+ afterTokens,
330
+ summary
331
+ }
332
+ });
333
+ }
334
+ function emitContextState(sessionId, currentTokens, maxTokens, compactionCount, dangerZone, canCompact, subAgentId, dynamicContextChanged) {
335
+ const eventStore = getEventStore();
336
+ eventStore.append(sessionId, {
337
+ type: "context.state",
338
+ data: {
339
+ currentTokens,
340
+ maxTokens,
341
+ compactionCount,
342
+ dangerZone,
343
+ canCompact,
344
+ dynamicContextChanged: dynamicContextChanged ?? false,
345
+ ...subAgentId !== void 0 && { subAgentId }
346
+ }
347
+ });
348
+ }
349
+ function emitChatDone(sessionId, messageId, reason, stats) {
350
+ const eventStore = getEventStore();
351
+ eventStore.append(sessionId, {
352
+ type: "chat.done",
353
+ data: {
354
+ messageId,
355
+ reason,
356
+ ...stats !== void 0 && { stats }
357
+ }
358
+ });
359
+ }
360
+ function emitChatError(sessionId, error, recoverable) {
361
+ const eventStore = getEventStore();
362
+ eventStore.append(sessionId, {
363
+ type: "chat.error",
364
+ data: { error, recoverable }
365
+ });
366
+ }
367
+ function emitPatternRetry(sessionId, messageId, pattern, field, attempt, maxAttempts, matchedContent) {
368
+ const eventStore = getEventStore();
369
+ eventStore.append(sessionId, {
370
+ type: "pattern.retry",
371
+ data: { messageId, pattern, field, attempt, maxAttempts, matchedContent }
372
+ });
373
+ }
374
+ function emitTurnSnapshot(sessionId, snapshot) {
375
+ const eventStore = getEventStore();
376
+ eventStore.append(sessionId, {
377
+ type: "turn.snapshot",
378
+ data: snapshot
379
+ });
380
+ }
381
+ function truncateSessionMessages(sessionId, messageIndex) {
382
+ const eventStore = getEventStore();
383
+ const snapshotEvent = eventStore.getLatestSnapshot(sessionId);
384
+ if (!snapshotEvent) return;
385
+ const snapshot = snapshotEvent.data;
386
+ const messages = snapshot.messages;
387
+ const lastKept = messageIndex + 1;
388
+ if (lastKept < 0 || lastKept >= messages.length) return;
389
+ const truncatedSnapshot = { ...snapshot, messages: messages.slice(0, lastKept) };
390
+ eventStore.deleteEventsAfterSeq(sessionId, snapshotEvent.seq);
391
+ eventStore.append(sessionId, {
392
+ type: "turn.snapshot",
393
+ data: truncatedSnapshot
394
+ });
395
+ const removed = messages.length - lastKept;
396
+ updateSessionMessageCount(sessionId, -removed);
397
+ }
398
+ function getRecentUserPromptsForSession(sessionId, limit = 10) {
399
+ try {
400
+ const eventStore = getEventStore();
401
+ return eventStore.getRecentUserPrompts(sessionId, limit);
402
+ } catch {
403
+ return [];
404
+ }
405
+ }
406
+
407
+ export {
408
+ isTurnEvent,
409
+ isStoredEvent,
410
+ createEvent,
411
+ combineEventsWithSnapshot,
412
+ getSessionState,
413
+ getCurrentWindowMessages,
414
+ getContextMessages,
415
+ getCurrentContextWindowId,
416
+ getCurrentWindowMessageOptions,
417
+ getReadFilesCache,
418
+ isFileInCache,
419
+ emitSessionInitialized,
420
+ emitUserMessage,
421
+ emitAssistantMessageStart,
422
+ emitMessageDelta,
423
+ emitMessageThinking,
424
+ emitMessageDone,
425
+ emitToolPreparing,
426
+ emitToolCall,
427
+ emitToolOutput,
428
+ emitToolResult,
429
+ emitModeChanged,
430
+ emitPhaseChanged,
431
+ emitRunningChanged,
432
+ emitWorkflowExecutionChanged,
433
+ emitCriteriaSet,
434
+ emitCriterionUpdated,
435
+ emitTodosUpdated,
436
+ emitMetadataSet,
437
+ emitFileRead,
438
+ emitContextCompacted,
439
+ emitContextState,
440
+ emitChatDone,
441
+ emitChatError,
442
+ emitPatternRetry,
443
+ emitTurnSnapshot,
444
+ truncateSessionMessages,
445
+ getRecentUserPromptsForSession
446
+ };
447
+ //# sourceMappingURL=chunk-2DVAF6HY.js.map