openfox 2.0.107 → 2.0.109
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 +33 -0
- package/dist/CHANGELOG.md +33 -0
- package/dist/{chat-handler-A22X22VZ.js → chat-handler-UZ7WTT6D.js} +21 -21
- package/dist/{chunk-46KNPXY6.js → chunk-3HS72YIE.js} +3 -3
- package/dist/{chunk-P4APMCTX.js → chunk-4HIFB7F5.js} +16 -52
- package/dist/{chunk-IA4Y3CKA.js → chunk-4ZXRERIW.js} +2 -2
- package/dist/{chunk-SGJ3LSVA.js → chunk-5HMKLHTT.js} +2 -2
- package/dist/{chunk-UXQN7FGB.js → chunk-6EV7X5MP.js} +2 -2
- package/dist/{chunk-3C73IUUL.js → chunk-ACJNRPTO.js} +32 -4
- package/dist/{chunk-27SDWNKL.js → chunk-B5MH4HQ6.js} +12 -2
- package/dist/{chunk-6VNB4L4V.js → chunk-C5JJM72V.js} +3 -3
- package/dist/{chunk-26DEYDYV.js → chunk-CQKRZ4WV.js} +4 -4
- package/dist/{chunk-5LR4AMQH.js → chunk-DPDCOLL4.js} +4 -4
- package/dist/{chunk-TB7TTPYQ.js → chunk-E5HZKNTY.js} +2 -2
- package/dist/{chunk-RRTKVJMF.js → chunk-FR5LUTLQ.js} +12 -2
- package/dist/{chunk-LOHVZGCM.js → chunk-GNFDD6LN.js} +3 -3
- package/dist/{chunk-AYUUGKZU.js → chunk-HK75Q3EA.js} +11 -11
- package/dist/{chunk-5M45NHQ2.js → chunk-JR54MDZI.js} +2 -2
- package/dist/{chunk-UCIZV76E.js → chunk-KDQJOI2I.js} +3 -3
- package/dist/{chunk-WDJOSRIB.js → chunk-L737Y63F.js} +5 -2
- package/dist/{chunk-GXW4CRR5.js → chunk-LXYNP7LL.js} +130 -57
- package/dist/{chunk-V6Y6OLB4.js → chunk-MM46DJJL.js} +2 -2
- package/dist/{chunk-HU22EVEM.js → chunk-NORNB6IJ.js} +6 -6
- package/dist/{chunk-X3USQHHK.js → chunk-PU3IPUSW.js} +6 -6
- package/dist/{chunk-6M44ZHQA.js → chunk-UCYPPLVR.js} +40 -20
- package/dist/{chunk-SUTJJWUK.js → chunk-VJWWJEBX.js} +8 -8
- package/dist/{chunk-2GM6SUIQ.js → chunk-VT2X3DMC.js} +2 -2
- package/dist/{chunk-KIAKWUZ3.js → chunk-VXKPZUCT.js} +11 -1
- package/dist/{chunk-OEPRHAIO.js → chunk-WCQOHRUX.js} +2 -2
- package/dist/chunk-YM673D5U.js +7 -0
- package/dist/{chunk-SLFCV72V.js → chunk-Z5QAKEJH.js} +97 -146
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-MP3FSNN7.js → client-LPNFUOPV.js} +5 -5
- package/dist/{client-pure-USVHN4WG.js → client-pure-VFZIIK4S.js} +2 -2
- package/dist/{compactor-KK2BVJK5.js → compactor-OSDLCGRC.js} +11 -11
- package/dist/{dynamic-context-ZUXI5UTW.js → dynamic-context-WVA7HTEP.js} +7 -7
- package/dist/{events-OJ2R6OEM.js → events-26J7BUSY.js} +6 -6
- package/dist/{folding-DUZSKCZF.js → folding-ZD4AMFNR.js} +4 -4
- package/dist/{http-client-KJXFSK7A.js → http-client-MQARNFY3.js} +3 -3
- package/dist/{manager-N27WNW5B.js → manager-RJH7EYIG.js} +4 -4
- package/dist/{model-overrides-36SQR3JR.js → model-overrides-BXMFIT47.js} +3 -3
- package/dist/{orchestrator-VZORJ7KF.js → orchestrator-BW27C4K4.js} +20 -20
- package/dist/package.json +3 -1
- package/dist/{path-security-QCIA6YFV.js → path-security-AAZMH33K.js} +8 -8
- package/dist/{platform-Q6T3AUHA.js → platform-EZJABX5J.js} +3 -3
- package/dist/{processor-QYVHKRIV.js → processor-FTCPHWBM.js} +20 -20
- package/dist/{protocol-YDNGGADL.js → protocol-SPIJPOEN.js} +2 -2
- package/dist/{protocol-zRSsysOe.d.ts → protocol-_Gphic7p.d.ts} +1 -1
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-RQQ5JN34.js → provider-JS5P3HQ2.js} +6 -6
- package/dist/{provider-manager-RUC5QQ75.js → provider-manager-MWAIOX2A.js} +6 -6
- package/dist/{registry-BDSTPV65.js → registry-JJB5GXOM.js} +3 -3
- package/dist/{serve-4F7O6FL3.js → serve-TRDQ6A5H.js} +28 -28
- package/dist/server/index.d.ts +3 -39
- package/dist/server/index.js +27 -27
- package/dist/server-R6DDJNF3.js +47 -0
- package/dist/{session-overrides-SFWPS5CT.js → session-overrides-T47KXDDS.js} +5 -5
- package/dist/{sessions-TZNUQJ2I.js → sessions-YTWCOHI3.js} +4 -4
- package/dist/{settings-5LG7IB3K.js → settings-2RZBMX5Y.js} +2 -2
- package/dist/shared/index.d.ts +3 -3
- package/dist/{tools-Y4F4HJPO.js → tools-KPIYFL5A.js} +18 -18
- package/dist/{types-CTl70hba.d.ts → types-BMEOlLT0.d.ts} +1 -0
- package/dist/{types-_uF_PRaD.d.ts → types-D0TgGL3t.d.ts} +1 -1
- package/dist/{update-PG2YJEVU.js → update-WGZZ5Q37.js} +2 -2
- package/dist/web/assets/index-CaG1FEjz.js +323 -0
- package/dist/web/assets/{index-B7wjVPjL.css → index-CyWbbpRP.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/{workspace-2OG5VQG6.js → workspace-YDUQZ3HC.js} +4 -2
- package/package.json +3 -1
- package/dist/chunk-T5OFUWKZ.js +0 -7
- package/dist/server-CYE6XY7J.js +0 -47
- package/dist/web/assets/index-BxI3Y9C7.js +0 -323
|
@@ -2,44 +2,44 @@ import {
|
|
|
2
2
|
buildCachedPrompt,
|
|
3
3
|
computeDynamicContextHash,
|
|
4
4
|
getToolFingerprint
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NORNB6IJ.js";
|
|
6
6
|
import {
|
|
7
7
|
createAssemblyResult,
|
|
8
8
|
getConversationMessages,
|
|
9
9
|
getToolRegistryForAgent,
|
|
10
10
|
processEventsForConversation,
|
|
11
11
|
runTopLevelAgentLoop
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-UCYPPLVR.js";
|
|
13
13
|
import {
|
|
14
14
|
getAllInstructions,
|
|
15
15
|
getEnabledSkillMetadata
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GNFDD6LN.js";
|
|
17
17
|
import {
|
|
18
18
|
TurnMetrics,
|
|
19
19
|
createChatDoneEvent,
|
|
20
20
|
createMessageStartEvent
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JR54MDZI.js";
|
|
22
22
|
import {
|
|
23
23
|
buildAgentReminder,
|
|
24
24
|
buildAgentSmallReminder
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-5HMKLHTT.js";
|
|
26
26
|
import {
|
|
27
27
|
PathAccessDeniedError
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-PU3IPUSW.js";
|
|
29
29
|
import {
|
|
30
30
|
getCurrentContextWindowId,
|
|
31
31
|
getCurrentWindowMessageOptions,
|
|
32
32
|
getEventStore
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LXYNP7LL.js";
|
|
34
34
|
import {
|
|
35
35
|
buildSnapshotFromSessionState
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ACJNRPTO.js";
|
|
37
37
|
import {
|
|
38
38
|
findAgentById,
|
|
39
39
|
getRuntimeConfig,
|
|
40
40
|
loadAllAgentsDefault,
|
|
41
41
|
resolveDefaultAgentId
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-VT2X3DMC.js";
|
|
43
43
|
import {
|
|
44
44
|
logger
|
|
45
45
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
|
|
50
50
|
// src/server/chat/orchestrator.ts
|
|
51
51
|
async function buildRetryPatterns() {
|
|
52
|
-
const { getSetting, SETTINGS_KEYS } = await import("./settings-
|
|
52
|
+
const { getSetting, SETTINGS_KEYS } = await import("./settings-2RZBMX5Y.js");
|
|
53
53
|
const raw = getSetting(SETTINGS_KEYS.RETRY_PATTERNS);
|
|
54
54
|
if (!raw) {
|
|
55
55
|
const oldXmlProtection = getSetting("llm.disableXmlProtection");
|
|
@@ -319,4 +319,4 @@ export {
|
|
|
319
319
|
runChatTurn,
|
|
320
320
|
runAgentTurn
|
|
321
321
|
};
|
|
322
|
-
//# sourceMappingURL=chunk-
|
|
322
|
+
//# sourceMappingURL=chunk-HK75Q3EA.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-YHEQTVFV.js";
|
|
10
10
|
import {
|
|
11
11
|
buildModelParams
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-L737Y63F.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
15
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -438,4 +438,4 @@ export {
|
|
|
438
438
|
createChatDoneEvent,
|
|
439
439
|
consumeStreamGenerator
|
|
440
440
|
};
|
|
441
|
-
//# sourceMappingURL=chunk-
|
|
441
|
+
//# sourceMappingURL=chunk-JR54MDZI.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLLMClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3HS72YIE.js";
|
|
4
4
|
import {
|
|
5
5
|
getModelProfile
|
|
6
6
|
} from "./chunk-V4IE7HJY.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./chunk-HNCM3D7Y.js";
|
|
15
15
|
import {
|
|
16
16
|
resolveAttachmentsInMessages
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-L737Y63F.js";
|
|
18
18
|
import {
|
|
19
19
|
logger
|
|
20
20
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -804,4 +804,4 @@ export {
|
|
|
804
804
|
parseDefaultModelSelection,
|
|
805
805
|
createProviderManager
|
|
806
806
|
};
|
|
807
|
-
//# sourceMappingURL=chunk-
|
|
807
|
+
//# sourceMappingURL=chunk-KDQJOI2I.js.map
|
|
@@ -537,7 +537,10 @@ ${attachment.data}` }];
|
|
|
537
537
|
}
|
|
538
538
|
async function convertMessages(messages, modelSupportsVision, thinkingField, sendReasoningInMessages) {
|
|
539
539
|
const filtered = messages.filter((msg) => {
|
|
540
|
-
|
|
540
|
+
if (msg.role !== "assistant") return true;
|
|
541
|
+
const isEmpty = !msg.content?.trim() && (!msg.toolCalls || msg.toolCalls.length === 0);
|
|
542
|
+
if (!isEmpty) return true;
|
|
543
|
+
return Boolean(msg.thinkingContent && sendReasoningInMessages !== false);
|
|
541
544
|
});
|
|
542
545
|
const result = [];
|
|
543
546
|
for (const msg of filtered) {
|
|
@@ -694,4 +697,4 @@ export {
|
|
|
694
697
|
buildStreamingCreateParams,
|
|
695
698
|
mapFinishReason
|
|
696
699
|
};
|
|
697
|
-
//# sourceMappingURL=chunk-
|
|
700
|
+
//# sourceMappingURL=chunk-L737Y63F.js.map
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
foldContextState,
|
|
6
6
|
foldSessionState,
|
|
7
7
|
spreadOptionalMessageFields
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ACJNRPTO.js";
|
|
9
9
|
import {
|
|
10
10
|
updateSessionMessageCount
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4ZXRERIW.js";
|
|
12
12
|
import {
|
|
13
13
|
getRuntimeConfig
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VT2X3DMC.js";
|
|
15
15
|
import {
|
|
16
16
|
logger
|
|
17
17
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -72,11 +72,31 @@ function createSubscriber(state, id) {
|
|
|
72
72
|
closed: false
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
var EventStore = class {
|
|
75
|
+
var EventStore = class _EventStore {
|
|
76
76
|
db;
|
|
77
77
|
subscribers = /* @__PURE__ */ new Map();
|
|
78
78
|
globalSubscribers = /* @__PURE__ */ new Map();
|
|
79
79
|
globalSubscriberIdCounter = 0;
|
|
80
|
+
// Parsed latest-snapshot cache per session. Snapshots can be tens of MB of
|
|
81
|
+
// JSON; re-parsing them on every session load (REST, WS, sidebar list) costs
|
|
82
|
+
// hundreds of ms. Invalidated on every write path (append, delete, cleanup).
|
|
83
|
+
// This is a pragmatic stopgap: the real fix is shrinking the 47MB snapshots
|
|
84
|
+
// themselves (compaction refactor, out of scope) — the cache hides the cost
|
|
85
|
+
// without removing it.
|
|
86
|
+
snapshotCache = /* @__PURE__ */ new Map();
|
|
87
|
+
snapshotCacheBytes = 0;
|
|
88
|
+
static SNAPSHOT_CACHE_MAX_ENTRIES = 16;
|
|
89
|
+
static SNAPSHOT_CACHE_MAX_BYTES = 128 * 1024 * 1024;
|
|
90
|
+
// Recent user prompts per session (sidebar list). Computed once from the
|
|
91
|
+
// snapshot + message.start events, then served from memory. Bounded — small
|
|
92
|
+
// arrays, but a long-lived server must not accumulate one per listed
|
|
93
|
+
// session; entries are also dropped when their session is written to.
|
|
94
|
+
promptsCache = /* @__PURE__ */ new Map();
|
|
95
|
+
static PROMPTS_CACHE_MAX_ENTRIES = 64;
|
|
96
|
+
// Row cap for the message.start query feeding the prompts cache. Kept above
|
|
97
|
+
// any realistic caller limit so the cached result is not clipped to whatever
|
|
98
|
+
// limit the first caller happened to request.
|
|
99
|
+
static PROMPTS_QUERY_LIMIT = 100;
|
|
80
100
|
constructor(db) {
|
|
81
101
|
this.db = db;
|
|
82
102
|
this.initSchema();
|
|
@@ -140,6 +160,7 @@ var EventStore = class {
|
|
|
140
160
|
`INSERT INTO events (session_id, seq, timestamp, event_type, payload)
|
|
141
161
|
VALUES (?, ?, ?, ?, ?)`
|
|
142
162
|
).run(sessionId, seq, timestamp, event.type, payload);
|
|
163
|
+
this.invalidateSessionCache(sessionId);
|
|
143
164
|
const stored = {
|
|
144
165
|
seq,
|
|
145
166
|
timestamp,
|
|
@@ -178,6 +199,7 @@ var EventStore = class {
|
|
|
178
199
|
}
|
|
179
200
|
});
|
|
180
201
|
transaction();
|
|
202
|
+
this.invalidateSessionCache(sessionId);
|
|
181
203
|
for (const stored of results) {
|
|
182
204
|
this.notifySubscribers(sessionId, stored);
|
|
183
205
|
}
|
|
@@ -235,6 +257,7 @@ var EventStore = class {
|
|
|
235
257
|
*/
|
|
236
258
|
updateEventPayload(sessionId, seq, data) {
|
|
237
259
|
this.db.prepare(`UPDATE events SET payload = ? WHERE session_id = ? AND seq = ?`).run(JSON.stringify(data), sessionId, seq);
|
|
260
|
+
this.invalidateSessionCache(sessionId);
|
|
238
261
|
}
|
|
239
262
|
/**
|
|
240
263
|
* Get the latest sequence number for a session
|
|
@@ -247,13 +270,106 @@ var EventStore = class {
|
|
|
247
270
|
* Get the latest snapshot event for a session
|
|
248
271
|
*/
|
|
249
272
|
getLatestSnapshot(sessionId) {
|
|
273
|
+
const cached = this.snapshotCache.get(sessionId);
|
|
274
|
+
if (cached) {
|
|
275
|
+
return cached.stored;
|
|
276
|
+
}
|
|
250
277
|
const row = this.db.prepare(
|
|
251
278
|
`SELECT * FROM events
|
|
252
279
|
WHERE session_id = ? AND event_type = 'turn.snapshot'
|
|
253
280
|
ORDER BY seq DESC LIMIT 1`
|
|
254
281
|
).get(sessionId);
|
|
255
282
|
if (!row) return void 0;
|
|
256
|
-
|
|
283
|
+
const stored = this.rowToStoredEvent(row);
|
|
284
|
+
this.cacheSnapshot(sessionId, stored, row.payload.length);
|
|
285
|
+
return stored;
|
|
286
|
+
}
|
|
287
|
+
cacheSnapshot(sessionId, stored, bytes) {
|
|
288
|
+
const existing = this.snapshotCache.get(sessionId);
|
|
289
|
+
if (existing) {
|
|
290
|
+
this.snapshotCacheBytes -= existing.bytes;
|
|
291
|
+
}
|
|
292
|
+
this.snapshotCache.set(sessionId, { stored, bytes });
|
|
293
|
+
this.snapshotCacheBytes += bytes;
|
|
294
|
+
while (this.snapshotCache.size > _EventStore.SNAPSHOT_CACHE_MAX_ENTRIES || this.snapshotCacheBytes > _EventStore.SNAPSHOT_CACHE_MAX_BYTES) {
|
|
295
|
+
const oldestKey = this.snapshotCache.keys().next().value;
|
|
296
|
+
if (oldestKey === void 0 || oldestKey === sessionId) break;
|
|
297
|
+
const oldest = this.snapshotCache.get(oldestKey);
|
|
298
|
+
if (oldest) {
|
|
299
|
+
this.snapshotCacheBytes -= oldest.bytes;
|
|
300
|
+
}
|
|
301
|
+
this.snapshotCache.delete(oldestKey);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
invalidateSessionCache(sessionId) {
|
|
305
|
+
const entry = this.snapshotCache.get(sessionId);
|
|
306
|
+
if (entry) {
|
|
307
|
+
this.snapshotCacheBytes -= entry.bytes;
|
|
308
|
+
this.snapshotCache.delete(sessionId);
|
|
309
|
+
}
|
|
310
|
+
this.promptsCache.delete(sessionId);
|
|
311
|
+
}
|
|
312
|
+
clearSnapshotCache() {
|
|
313
|
+
this.snapshotCache.clear();
|
|
314
|
+
this.snapshotCacheBytes = 0;
|
|
315
|
+
this.promptsCache.clear();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get the most recent real user prompts for a session, cached in memory.
|
|
319
|
+
* Extracts them from the latest snapshot (when present) plus recent
|
|
320
|
+
* message.start events. Parsing a multi-MB snapshot on every sidebar list
|
|
321
|
+
* call dominated the list endpoint, so the result is memoized per session.
|
|
322
|
+
*/
|
|
323
|
+
getRecentUserPrompts(sessionId, limit) {
|
|
324
|
+
const cached = this.promptsCache.get(sessionId);
|
|
325
|
+
if (cached) {
|
|
326
|
+
return cached.slice(0, limit);
|
|
327
|
+
}
|
|
328
|
+
const isRealUserMessage = (msg) => msg.role === "user" && !msg.isSystemGenerated && !msg.messageKind && !msg.subAgentType;
|
|
329
|
+
const promptMap = /* @__PURE__ */ new Map();
|
|
330
|
+
const snapshotEvent = this.getLatestSnapshot(sessionId);
|
|
331
|
+
if (snapshotEvent) {
|
|
332
|
+
const snapshot = snapshotEvent.data;
|
|
333
|
+
for (const msg of snapshot.messages) {
|
|
334
|
+
if (isRealUserMessage(msg)) {
|
|
335
|
+
promptMap.set(msg.id, {
|
|
336
|
+
id: msg.id,
|
|
337
|
+
content: msg.content,
|
|
338
|
+
timestamp: new Date(msg.timestamp).toISOString()
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const rows = this.db.prepare(
|
|
344
|
+
`
|
|
345
|
+
SELECT payload, timestamp
|
|
346
|
+
FROM events
|
|
347
|
+
WHERE session_id = ? AND event_type = 'message.start'
|
|
348
|
+
AND json_extract(payload, '$.role') = 'user'
|
|
349
|
+
AND json_extract(payload, '$.isSystemGenerated') IS NULL
|
|
350
|
+
AND json_extract(payload, '$.messageKind') IS NULL
|
|
351
|
+
AND json_extract(payload, '$.subAgentType') IS NULL
|
|
352
|
+
ORDER BY timestamp DESC
|
|
353
|
+
LIMIT ?
|
|
354
|
+
`
|
|
355
|
+
).all(sessionId, _EventStore.PROMPTS_QUERY_LIMIT);
|
|
356
|
+
for (const row of rows) {
|
|
357
|
+
const message = JSON.parse(row.payload);
|
|
358
|
+
promptMap.set(message.messageId, {
|
|
359
|
+
id: message.messageId,
|
|
360
|
+
content: message.content,
|
|
361
|
+
timestamp: new Date(row.timestamp).toISOString()
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
const prompts = [...promptMap.values()].sort(
|
|
365
|
+
(a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
366
|
+
);
|
|
367
|
+
this.promptsCache.set(sessionId, prompts);
|
|
368
|
+
if (this.promptsCache.size > _EventStore.PROMPTS_CACHE_MAX_ENTRIES) {
|
|
369
|
+
const oldestKey = this.promptsCache.keys().next().value;
|
|
370
|
+
if (oldestKey !== void 0) this.promptsCache.delete(oldestKey);
|
|
371
|
+
}
|
|
372
|
+
return prompts.slice(0, limit);
|
|
257
373
|
}
|
|
258
374
|
/**
|
|
259
375
|
* Get the latest snapshot and all events since it
|
|
@@ -404,6 +520,7 @@ var EventStore = class {
|
|
|
404
520
|
*/
|
|
405
521
|
deleteSession(sessionId) {
|
|
406
522
|
this.db.prepare(`DELETE FROM events WHERE session_id = ?`).run(sessionId);
|
|
523
|
+
this.invalidateSessionCache(sessionId);
|
|
407
524
|
const sessionSubs = this.subscribers.get(sessionId);
|
|
408
525
|
if (sessionSubs) {
|
|
409
526
|
for (const subscriber of sessionSubs) {
|
|
@@ -423,6 +540,7 @@ var EventStore = class {
|
|
|
423
540
|
*/
|
|
424
541
|
deleteEventsUpToSeq(sessionId, upToSeq) {
|
|
425
542
|
const result = this.db.prepare(`DELETE FROM events WHERE session_id = ? AND seq <= ?`).run(sessionId, upToSeq);
|
|
543
|
+
this.invalidateSessionCache(sessionId);
|
|
426
544
|
return result.changes;
|
|
427
545
|
}
|
|
428
546
|
/**
|
|
@@ -436,6 +554,7 @@ var EventStore = class {
|
|
|
436
554
|
*/
|
|
437
555
|
deleteEventsAfterSeq(sessionId, fromSeq) {
|
|
438
556
|
const result = this.db.prepare(`DELETE FROM events WHERE session_id = ? AND seq > ?`).run(sessionId, fromSeq);
|
|
557
|
+
this.invalidateSessionCache(sessionId);
|
|
439
558
|
return result.changes;
|
|
440
559
|
}
|
|
441
560
|
/**
|
|
@@ -470,6 +589,7 @@ var EventStore = class {
|
|
|
470
589
|
)
|
|
471
590
|
`
|
|
472
591
|
).run(sessionId, latestSnapshotSeq);
|
|
592
|
+
this.invalidateSessionCache(sessionId);
|
|
473
593
|
return result.changes;
|
|
474
594
|
}
|
|
475
595
|
/**
|
|
@@ -492,6 +612,7 @@ var EventStore = class {
|
|
|
492
612
|
)
|
|
493
613
|
`
|
|
494
614
|
).run();
|
|
615
|
+
this.clearSnapshotCache();
|
|
495
616
|
return { deletedSnapshots: deleteResult.changes };
|
|
496
617
|
}
|
|
497
618
|
/**
|
|
@@ -1067,11 +1188,11 @@ function truncateSessionMessages(sessionId, messageIndex) {
|
|
|
1067
1188
|
const messages = snapshot.messages;
|
|
1068
1189
|
const lastKept = messageIndex + 1;
|
|
1069
1190
|
if (lastKept < 0 || lastKept >= messages.length) return;
|
|
1070
|
-
|
|
1191
|
+
const truncatedSnapshot = { ...snapshot, messages: messages.slice(0, lastKept) };
|
|
1071
1192
|
eventStore.deleteEventsAfterSeq(sessionId, snapshotEvent.seq);
|
|
1072
1193
|
eventStore.append(sessionId, {
|
|
1073
1194
|
type: "turn.snapshot",
|
|
1074
|
-
data:
|
|
1195
|
+
data: truncatedSnapshot
|
|
1075
1196
|
});
|
|
1076
1197
|
const removed = messages.length - lastKept;
|
|
1077
1198
|
updateSessionMessageCount(sessionId, -removed);
|
|
@@ -1079,55 +1200,7 @@ function truncateSessionMessages(sessionId, messageIndex) {
|
|
|
1079
1200
|
function getRecentUserPromptsForSession(sessionId, limit = 10) {
|
|
1080
1201
|
try {
|
|
1081
1202
|
const eventStore = getEventStore();
|
|
1082
|
-
|
|
1083
|
-
if (!db) {
|
|
1084
|
-
return [];
|
|
1085
|
-
}
|
|
1086
|
-
const isRealUserMessage = (msg) => msg.role === "user" && !msg.isSystemGenerated && !msg.messageKind && !msg.subAgentType;
|
|
1087
|
-
const promptMap = /* @__PURE__ */ new Map();
|
|
1088
|
-
const snapshotRow = db.prepare(
|
|
1089
|
-
`
|
|
1090
|
-
SELECT payload, timestamp
|
|
1091
|
-
FROM events
|
|
1092
|
-
WHERE session_id = ? AND event_type = 'turn.snapshot'
|
|
1093
|
-
ORDER BY timestamp DESC
|
|
1094
|
-
LIMIT 1
|
|
1095
|
-
`
|
|
1096
|
-
).get(sessionId);
|
|
1097
|
-
if (snapshotRow) {
|
|
1098
|
-
const snapshot = JSON.parse(snapshotRow.payload);
|
|
1099
|
-
for (const msg of snapshot.messages) {
|
|
1100
|
-
if (isRealUserMessage(msg)) {
|
|
1101
|
-
promptMap.set(msg.id, {
|
|
1102
|
-
id: msg.id,
|
|
1103
|
-
content: msg.content,
|
|
1104
|
-
timestamp: new Date(msg.timestamp).toISOString()
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
const rows = db.prepare(
|
|
1110
|
-
`
|
|
1111
|
-
SELECT payload, timestamp
|
|
1112
|
-
FROM events
|
|
1113
|
-
WHERE session_id = ? AND event_type = 'message.start'
|
|
1114
|
-
AND json_extract(payload, '$.role') = 'user'
|
|
1115
|
-
AND json_extract(payload, '$.isSystemGenerated') IS NULL
|
|
1116
|
-
AND json_extract(payload, '$.messageKind') IS NULL
|
|
1117
|
-
AND json_extract(payload, '$.subAgentType') IS NULL
|
|
1118
|
-
ORDER BY timestamp DESC
|
|
1119
|
-
LIMIT ?
|
|
1120
|
-
`
|
|
1121
|
-
).all(sessionId, limit);
|
|
1122
|
-
for (const row of rows) {
|
|
1123
|
-
const message = JSON.parse(row.payload);
|
|
1124
|
-
promptMap.set(message.messageId, {
|
|
1125
|
-
id: message.messageId,
|
|
1126
|
-
content: message.content,
|
|
1127
|
-
timestamp: new Date(row.timestamp).toISOString()
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
return [...promptMap.values()].sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()).slice(0, limit);
|
|
1203
|
+
return eventStore.getRecentUserPrompts(sessionId, limit);
|
|
1131
1204
|
} catch {
|
|
1132
1205
|
return [];
|
|
1133
1206
|
}
|
|
@@ -1176,4 +1249,4 @@ export {
|
|
|
1176
1249
|
truncateSessionMessages,
|
|
1177
1250
|
getRecentUserPromptsForSession
|
|
1178
1251
|
};
|
|
1179
|
-
//# sourceMappingURL=chunk-
|
|
1252
|
+
//# sourceMappingURL=chunk-LXYNP7LL.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting,
|
|
4
4
|
setSetting
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VXKPZUCT.js";
|
|
6
6
|
|
|
7
7
|
// src/server/agents/model-overrides.ts
|
|
8
8
|
import { z } from "zod";
|
|
@@ -69,4 +69,4 @@ export {
|
|
|
69
69
|
setAgentModelOverride,
|
|
70
70
|
resolveLLMClientForAgent
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-MM46DJJL.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAllInstructions,
|
|
3
3
|
getEnabledSkillMetadata
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GNFDD6LN.js";
|
|
5
5
|
import {
|
|
6
6
|
buildTopLevelSystemPrompt
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5HMKLHTT.js";
|
|
8
8
|
import {
|
|
9
9
|
findAgentById,
|
|
10
10
|
getRuntimeConfig,
|
|
11
11
|
getSubAgents,
|
|
12
12
|
loadAllAgentsDefault,
|
|
13
13
|
resolveDefaultAgentId
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VT2X3DMC.js";
|
|
15
15
|
import {
|
|
16
16
|
logger
|
|
17
17
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -105,7 +105,7 @@ function resolveAgentDef(sessionManager, sessionId) {
|
|
|
105
105
|
}
|
|
106
106
|
async function buildCachedPrompt(sessionManager, sessionId, agentDef, modelName) {
|
|
107
107
|
const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
|
|
108
|
-
const { getToolRegistryForAgent } = await import("./tools-
|
|
108
|
+
const { getToolRegistryForAgent } = await import("./tools-KPIYFL5A.js");
|
|
109
109
|
const tools = getToolRegistryForAgent(agentDef, sessionId).definitions;
|
|
110
110
|
const toolFingerprint = getToolFingerprint(tools);
|
|
111
111
|
const allAgents = await loadAllAgentsDefault();
|
|
@@ -124,7 +124,7 @@ async function buildCachedPrompt(sessionManager, sessionId, agentDef, modelName)
|
|
|
124
124
|
async function computeSessionHash(sessionManager, sessionId, modelName) {
|
|
125
125
|
const { instructionContent, skills } = await loadSessionContext(sessionManager, sessionId);
|
|
126
126
|
const agentDef = await resolveAgentDef(sessionManager, sessionId);
|
|
127
|
-
const { getToolRegistryForAgent } = await import("./tools-
|
|
127
|
+
const { getToolRegistryForAgent } = await import("./tools-KPIYFL5A.js");
|
|
128
128
|
const tools = getToolRegistryForAgent(agentDef, sessionId).definitions;
|
|
129
129
|
const toolFingerprint = getToolFingerprint(tools);
|
|
130
130
|
return computeDynamicContextHash(instructionContent, skills, toolFingerprint, modelName);
|
|
@@ -148,4 +148,4 @@ export {
|
|
|
148
148
|
computeSessionHash,
|
|
149
149
|
applyDynamicContext
|
|
150
150
|
};
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-NORNB6IJ.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getEventStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LXYNP7LL.js";
|
|
4
4
|
import {
|
|
5
5
|
createChatPathConfirmationMessage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-B5MH4HQ6.js";
|
|
7
7
|
|
|
8
8
|
// src/server/tools/path-security.ts
|
|
9
9
|
import { realpath } from "fs/promises";
|
|
@@ -283,6 +283,7 @@ function extractDangerousPatterns(command) {
|
|
|
283
283
|
}
|
|
284
284
|
return dangerous;
|
|
285
285
|
}
|
|
286
|
+
var GIT_N_NO_VERIFY_SUBCOMMANDS = /* @__PURE__ */ new Set(["commit", "am"]);
|
|
286
287
|
function extractGitNoVerify(command) {
|
|
287
288
|
const subCommands = command.split(/\s*(?:&&|\|\||\||;)\s*/);
|
|
288
289
|
for (const sub of subCommands) {
|
|
@@ -291,9 +292,8 @@ function extractGitNoVerify(command) {
|
|
|
291
292
|
const subCmd = parts[gitIndex + 1];
|
|
292
293
|
if (gitIndex >= 0 && subCmd && !subCmd.startsWith("-")) {
|
|
293
294
|
const gitArgs = parts.slice(gitIndex + 2);
|
|
294
|
-
if (gitArgs.
|
|
295
|
-
|
|
296
|
-
}
|
|
295
|
+
if (gitArgs.includes("--no-verify")) return true;
|
|
296
|
+
if (GIT_N_NO_VERIFY_SUBCOMMANDS.has(subCmd) && gitArgs.includes("-n")) return true;
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
return false;
|
|
@@ -498,4 +498,4 @@ export {
|
|
|
498
498
|
getConfirmationSessionId,
|
|
499
499
|
getPendingConfirmationsBySession
|
|
500
500
|
};
|
|
501
|
-
//# sourceMappingURL=chunk-
|
|
501
|
+
//# sourceMappingURL=chunk-PU3IPUSW.js.map
|