openfox 2.0.142 → 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.
- package/CHANGELOG.md +27 -0
- package/dist/CHANGELOG.md +27 -0
- package/dist/auto-continue-M3RPFGFI.js +111 -0
- package/dist/{backend-EPISSWLB.js → backend-2VSDPCWS.js} +2 -2
- package/dist/{chat-handler-OFB4426F.js → chat-handler-QOOQOHHR.js} +28 -27
- package/dist/{chunk-CSUMZAYY.js → chunk-2DBWCXAQ.js} +3 -3
- package/dist/chunk-2DVAF6HY.js +447 -0
- package/dist/{chunk-ACILWRPU.js → chunk-3IVJ65IG.js} +12 -10
- package/dist/{chunk-VK2BSIJP.js → chunk-5ONERSDK.js} +146 -129
- package/dist/{chunk-5CZAKVGZ.js → chunk-5XKWYLBX.js} +18 -16
- package/dist/{chunk-R5FAEKXQ.js → chunk-73BO5OT3.js} +2 -1
- package/dist/{chunk-J556QIRD.js → chunk-AWBV2VXO.js} +3 -3
- package/dist/{chunk-RM4ZBI2B.js → chunk-C4LI5U6L.js} +45 -42
- package/dist/{chunk-F3R4YS3F.js → chunk-CCIG3YLG.js} +2 -2
- package/dist/{chunk-2CEZQAGQ.js → chunk-DJH6LMBT.js} +2 -2
- package/dist/{chunk-EFEHIJXF.js → chunk-E4F32L4Q.js} +2 -2
- package/dist/{chunk-OA7KBQ2O.js → chunk-FAN4P45J.js} +3 -3
- package/dist/{chunk-XADIBENX.js → chunk-FLTNKZNQ.js} +10 -10
- package/dist/{chunk-VLQ6BMU7.js → chunk-FTPQI5TA.js} +11 -1
- package/dist/{chunk-DNL2NUDB.js → chunk-GZ4EK4LZ.js} +2 -2
- package/dist/{chunk-5HDPFHHJ.js → chunk-L2RESXUF.js} +3 -3
- package/dist/{chunk-TRZZCMJ3.js → chunk-MBDYJ35W.js} +14 -11
- package/dist/{chunk-DQEANXXF.js → chunk-ODETQHMI.js} +3 -3
- package/dist/{chunk-HQDKHNWS.js → chunk-OSUEWIVU.js} +10 -8
- package/dist/{chunk-FFVIO6GL.js → chunk-QURYQA4D.js} +8 -8
- package/dist/{chunk-N5AJHJG5.js → chunk-STVJA7IX.js} +3 -3
- package/dist/{chunk-WSDR27YV.js → chunk-UO4X2ENE.js} +2 -2
- package/dist/{chunk-Q5JCBAQF.js → chunk-VFHGN3IS.js} +4 -4
- package/dist/{chunk-SKNPOZYP.js → chunk-X6SWZEK7.js} +3 -1
- package/dist/{chunk-TIIWXMGE.js → chunk-X7ZAP6YW.js} +2 -2
- package/dist/{chunk-MEPTCUYN.js → chunk-YEFZ5HBD.js} +2 -2
- package/dist/{chunk-DRIR2IZR.js → chunk-YEW4YEJU.js} +2 -2
- package/dist/{chunk-NJFXYSXP.js → chunk-YRSZJ7IZ.js} +11 -441
- package/dist/{chunk-TEUVZCPS.js → chunk-Z3C3D4IR.js} +24 -22
- package/dist/{chunk-Z7IT3V22.js → chunk-ZONLEX2F.js} +8 -4
- package/dist/chunk-ZSGELOTW.js +7 -0
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-2A766XZK.js → client-L4PANCG4.js} +5 -5
- package/dist/{compactor-3BVVHO4M.js → compactor-53WDNC2S.js} +12 -11
- package/dist/{config-LOK3LXFH.js → config-AJSENHBC.js} +2 -2
- package/dist/{describe-image-F22VNBWY.js → describe-image-IGLGVEOJ.js} +12 -11
- package/dist/{dynamic-context-5SFXTEAP.js → dynamic-context-CR4RUXOX.js} +11 -10
- package/dist/{events-UAUOGRSV.js → events-ODZ4SSBW.js} +11 -9
- package/dist/{export-import-PBEX3KWU.js → export-import-3WOHC7PI.js} +10 -8
- package/dist/{folding-IHD244OU.js → folding-V2R2MZ6Y.js} +4 -4
- package/dist/{http-client-RA7XFYPO.js → http-client-SZZBSL4U.js} +3 -3
- package/dist/{launch-L5NL75KK.js → launch-4COI5RGL.js} +28 -27
- package/dist/{manager-4SMHCFXY.js → manager-PDG7RKPA.js} +4 -4
- package/dist/{mcp-SQ4DOGPT.js → mcp-C7PNGP25.js} +2 -2
- package/dist/{orchestrator-53SS74LD.js → orchestrator-AMTWA6JO.js} +27 -26
- package/dist/package.json +1 -1
- package/dist/{path-security-WOA6MTWQ.js → path-security-3YFS3GJQ.js} +9 -8
- package/dist/{platform-EAZNZDAE.js → platform-WCXMN4NM.js} +3 -3
- package/dist/{processor-T4VWZMXT.js → processor-UZ7OBCAK.js} +27 -26
- package/dist/{protocol-Dpf4FBF2.d.ts → protocol-Ch2s26bR.d.ts} +1 -1
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-5XNJEDKW.js → provider-QE7XSGYA.js} +8 -8
- package/dist/{provider-manager-RHJYUU5W.js → provider-manager-WW2EF76W.js} +6 -6
- package/dist/{registry-C7RKKHZB.js → registry-24U5BZAJ.js} +3 -3
- package/dist/{serve-LP3ZX6CW.js → serve-NLQ6IB2V.js} +33 -32
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +32 -31
- package/dist/{server-IGZLCNZG.js → server-YXKUQ3DD.js} +31 -30
- package/dist/{service-AZU4YTS2.js → service-KMOSB6SU.js} +8 -8
- package/dist/{session-overrides-CKS2AVE5.js → session-overrides-GQKE7WGE.js} +5 -5
- package/dist/{sessions-DAHLRQE2.js → sessions-A3IZYL6X.js} +4 -4
- package/dist/{settings-TR4BF2C4.js → settings-FQUDSGZF.js} +2 -2
- package/dist/shared/index.d.ts +3 -3
- package/dist/store-AOZ46PBS.js +23 -0
- package/dist/{tasks-T5KZXKMD.js → tasks-X5DM553T.js} +8 -8
- package/dist/{tools-BL6XCTUV.js → tools-7L63ZMNU.js} +32 -31
- package/dist/{types-LO8296aY.d.ts → types-BajWwfkt.d.ts} +1 -1
- package/dist/{types-CZJf6Fnb.d.ts → types-BiHNYUUI.d.ts} +1 -1
- package/dist/{update-M5DMX3FC.js → update-IBN2GJUI.js} +2 -2
- package/dist/web/assets/{index-2WvLd7SC.css → index--zSmgMW5.css} +1 -1
- package/dist/web/assets/{index-BPhet33M.js → index-DL26wmhi.js} +78 -75
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-EPZO3MGM.js +0 -7
|
@@ -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
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
combineEventsWithSnapshot
|
|
3
|
+
} from "./chunk-2DVAF6HY.js";
|
|
4
4
|
import {
|
|
5
|
-
combineEventsWithSnapshot,
|
|
6
5
|
getEventStore
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YRSZJ7IZ.js";
|
|
8
7
|
import {
|
|
9
8
|
buildMessagesFromStoredEvents,
|
|
10
9
|
foldPendingConfirmations
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-E4F32L4Q.js";
|
|
12
11
|
import {
|
|
13
12
|
updateSessionMetadata
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-CCIG3YLG.js";
|
|
15
14
|
import {
|
|
16
15
|
getRuntimeConfig
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YEW4YEJU.js";
|
|
17
|
+
import {
|
|
18
|
+
getPendingQuestionsForSession
|
|
19
|
+
} from "./chunk-V5AC2TV7.js";
|
|
18
20
|
import {
|
|
19
21
|
createContextStateMessage,
|
|
20
22
|
createSessionStateMessage
|
|
21
23
|
} from "./chunk-OVAHNEFG.js";
|
|
22
24
|
import {
|
|
23
25
|
getMaxVisibleItems
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-X6SWZEK7.js";
|
|
25
27
|
import {
|
|
26
28
|
logger
|
|
27
29
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -162,7 +164,7 @@ async function generateSessionNameForSession(sessionId, userMessage, deps, signa
|
|
|
162
164
|
client = deps.getLLMClient();
|
|
163
165
|
client.setModel(providerConfig.model);
|
|
164
166
|
} else if (providerConfig) {
|
|
165
|
-
const { createLLMClient } = await import("./client-
|
|
167
|
+
const { createLLMClient } = await import("./client-L4PANCG4.js");
|
|
166
168
|
client = createLLMClient(
|
|
167
169
|
{
|
|
168
170
|
llm: {
|
|
@@ -217,4 +219,4 @@ export {
|
|
|
217
219
|
needsNameGeneration,
|
|
218
220
|
generateSessionNameForSession
|
|
219
221
|
};
|
|
220
|
-
//# sourceMappingURL=chunk-
|
|
222
|
+
//# sourceMappingURL=chunk-3IVJ65IG.js.map
|