openfox 2.0.110 → 2.0.112
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 +25 -0
- package/README.md +1 -0
- package/dist/CHANGELOG.md +25 -0
- package/dist/{ask-CJMU6EW7.js → ask-ZYPCJKZD.js} +3 -2
- package/dist/{chat-handler-UZ7WTT6D.js → chat-handler-BYXZIIV3.js} +23 -22
- package/dist/{chunk-VJWWJEBX.js → chunk-3UILDGOO.js} +9 -9
- package/dist/{chunk-GNFDD6LN.js → chunk-BOSKQI62.js} +3 -3
- package/dist/{chunk-D6ODGTSZ.js → chunk-C372UH7N.js} +2 -1
- package/dist/{chunk-4ZXRERIW.js → chunk-C5NQF2K4.js} +46 -4
- package/dist/{chunk-3HS72YIE.js → chunk-ERYUSG5C.js} +2 -2
- package/dist/{chunk-PU3IPUSW.js → chunk-FFPCVN5M.js} +45 -8
- package/dist/{chunk-KDQJOI2I.js → chunk-FSYRANYR.js} +2 -2
- package/dist/chunk-IJ53Y77N.js +142 -0
- package/dist/{chunk-ZJW3KOII.js → chunk-IYTDCPEQ.js} +293 -98
- package/dist/{chunk-WCQOHRUX.js → chunk-JDT63SSP.js} +2 -2
- package/dist/{chunk-VT2X3DMC.js → chunk-JNHKKUGJ.js} +2 -2
- package/dist/{chunk-JAX5OEMM.js → chunk-JURM3RPZ.js} +21 -4
- package/dist/chunk-LCLH6ZUL.js +43 -0
- package/dist/{chunk-6EV7X5MP.js → chunk-N4RTAGFY.js} +2 -2
- package/dist/{chunk-LXYNP7LL.js → chunk-NB2D6I64.js} +221 -5
- package/dist/{chunk-VKWVPQJ5.js → chunk-OAN4BXEW.js} +3 -1
- package/dist/{chunk-4R7G5JB6.js → chunk-P45RJGOT.js} +1 -1
- package/dist/chunk-P5AA7OYJ.js +7 -0
- package/dist/{chunk-E5HZKNTY.js → chunk-PCC4DBPF.js} +2 -2
- package/dist/{chunk-ACJNRPTO.js → chunk-QGXLZZBS.js} +29 -21
- package/dist/{chunk-UCYPPLVR.js → chunk-RAKPI4OE.js} +81 -70
- package/dist/{chunk-MM46DJJL.js → chunk-RISQXU32.js} +2 -2
- package/dist/{chunk-CQKRZ4WV.js → chunk-RKMP74BB.js} +4 -4
- package/dist/chunk-RSB4AR2A.js +108 -0
- package/dist/{chunk-VXKPZUCT.js → chunk-RT2A2RRL.js} +4 -2
- package/dist/{chunk-HK75Q3EA.js → chunk-SDGNV45R.js} +10 -10
- package/dist/{chunk-C5JJM72V.js → chunk-SVJFMZ2Q.js} +49 -5
- package/dist/{chunk-B5MH4HQ6.js → chunk-SYJMUIRC.js} +7 -3
- package/dist/{chunk-QRASX3HC.js → chunk-UAF2FOI5.js} +7 -7
- package/dist/{chunk-4HIFB7F5.js → chunk-XCK5IBO4.js} +37 -26
- package/dist/{chunk-5HMKLHTT.js → chunk-XWNCKIPO.js} +2 -2
- package/dist/{chunk-NORNB6IJ.js → chunk-Z56SEG4Z.js} +6 -6
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-LPNFUOPV.js → client-QNQTX5EA.js} +4 -4
- package/dist/{compactor-OSDLCGRC.js → compactor-X2KZ3XFU.js} +10 -9
- package/dist/{config-HX7FDKGJ.js → config-TW5FHQEM.js} +2 -2
- package/dist/{dynamic-context-WVA7HTEP.js → dynamic-context-ZRQO2FJN.js} +7 -7
- package/dist/{events-26J7BUSY.js → events-Y6XXQYFG.js} +7 -6
- package/dist/{folding-ZD4AMFNR.js → folding-Z4GNWRC3.js} +9 -6
- package/dist/{http-client-MQARNFY3.js → http-client-2GDKHZIG.js} +3 -3
- package/dist/{manager-RJH7EYIG.js → manager-HCMDFEQH.js} +4 -4
- package/dist/{model-overrides-BXMFIT47.js → model-overrides-O3ZYKFP7.js} +3 -3
- package/dist/oauth-provider-52YILVUJ.js +15 -0
- package/dist/oauth-store-XCFXV2VM.js +32 -0
- package/dist/{orchestrator-BW27C4K4.js → orchestrator-P5EUMC7E.js} +22 -21
- package/dist/package.json +13 -10
- package/dist/{path-security-AAZMH33K.js → path-security-525YLND3.js} +11 -9
- package/dist/{platform-EZJABX5J.js → platform-MEQUWG6U.js} +3 -3
- package/dist/{processor-FTCPHWBM.js → processor-UN4H4V7F.js} +22 -21
- package/dist/{protocol-_Gphic7p.d.ts → protocol-D6MISQyz.d.ts} +8 -3
- package/dist/{protocol-SPIJPOEN.js → protocol-FTHAR2YL.js} +4 -3
- package/dist/{provider-JS5P3HQ2.js → provider-3R4X62LW.js} +7 -7
- package/dist/{provider-manager-MWAIOX2A.js → provider-manager-W5N4XRE5.js} +5 -5
- package/dist/{registry-JJB5GXOM.js → registry-74KPZ5NV.js} +3 -3
- package/dist/{serve-XDZB4EJN.js → serve-WHFUNQ6Z.js} +32 -29
- package/dist/server/index.d.ts +15 -1
- package/dist/server/index.js +31 -28
- package/dist/server-7MOOJR2N.js +48 -0
- package/dist/{session-overrides-T47KXDDS.js → session-overrides-XH6I3COP.js} +5 -5
- package/dist/{sessions-YTWCOHI3.js → sessions-D772YTWL.js} +8 -4
- package/dist/{settings-2RZBMX5Y.js → settings-KO6DSJLD.js} +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/{tools-KPIYFL5A.js → tools-HTUTYMKI.js} +20 -19
- package/dist/{update-75QZJYKD.js → update-BRUFGGTW.js} +2 -2
- package/dist/{update-server-4I6LXE5K.js → update-server-LOOXIXDW.js} +2 -2
- package/dist/web/assets/{index-BmjVoqQT.js → index-Dukvfqm-.js} +83 -83
- package/dist/web/assets/{index-CyWbbpRP.css → index-nS1p0g8O.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +13 -10
- package/scripts/postinstall.mjs +8 -0
- package/dist/chunk-64374FPB.js +0 -7
- package/dist/server-R6DDJNF3.js +0 -47
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
updateSessionMcpDisabledServers
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-C5NQF2K4.js";
|
|
4
4
|
import {
|
|
5
5
|
getDatabase
|
|
6
6
|
} from "./chunk-LCQ5AN6Y.js";
|
|
@@ -62,4 +62,4 @@ export {
|
|
|
62
62
|
clearSessionOverrides,
|
|
63
63
|
getAllSessionOverrides
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-JDT63SSP.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RT2A2RRL.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
7
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -455,4 +455,4 @@ export {
|
|
|
455
455
|
getOverrideAgentIds,
|
|
456
456
|
resolveDefaultAgentId
|
|
457
457
|
};
|
|
458
|
-
//# sourceMappingURL=chunk-
|
|
458
|
+
//# sourceMappingURL=chunk-JNHKKUGJ.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeAskOptions
|
|
3
|
+
} from "./chunk-LCLH6ZUL.js";
|
|
4
|
+
|
|
1
5
|
// src/server/utils/async.ts
|
|
2
6
|
function createDeferred() {
|
|
3
7
|
let resolve;
|
|
@@ -56,8 +60,21 @@ var askUserTool = {
|
|
|
56
60
|
},
|
|
57
61
|
options: {
|
|
58
62
|
type: "array",
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
description: "Options for choice-type questions. Each entry may be a plain string or an object {value, label, description?} (or legacy {label, description?}). The server normalizes everything to {value, label, description?}.",
|
|
64
|
+
items: {
|
|
65
|
+
oneOf: [
|
|
66
|
+
{ type: "string" },
|
|
67
|
+
{
|
|
68
|
+
type: "object",
|
|
69
|
+
properties: {
|
|
70
|
+
value: { type: "string" },
|
|
71
|
+
label: { type: "string" },
|
|
72
|
+
description: { type: "string" }
|
|
73
|
+
},
|
|
74
|
+
required: ["label"]
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
61
78
|
}
|
|
62
79
|
},
|
|
63
80
|
required: ["question"]
|
|
@@ -67,7 +84,7 @@ var askUserTool = {
|
|
|
67
84
|
async execute(args, context) {
|
|
68
85
|
const question = args["question"];
|
|
69
86
|
const type = args["type"] ?? "text";
|
|
70
|
-
const options = args["options"];
|
|
87
|
+
const options = normalizeAskOptions(args["options"]);
|
|
71
88
|
const callId = context.toolCallId ?? crypto.randomUUID();
|
|
72
89
|
const deferred = createDeferred();
|
|
73
90
|
void deferred.promise.catch(() => {
|
|
@@ -156,4 +173,4 @@ export {
|
|
|
156
173
|
awaitAnswer,
|
|
157
174
|
getPendingQuestionsForSession
|
|
158
175
|
};
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
176
|
+
//# sourceMappingURL=chunk-JURM3RPZ.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/shared/ask-options.ts
|
|
2
|
+
function normalizeAskOptions(raw) {
|
|
3
|
+
if (raw == null) return void 0;
|
|
4
|
+
if (typeof raw === "string") {
|
|
5
|
+
const parts = raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
6
|
+
return parts.length > 0 ? parts.map((label) => ({ value: label, label })) : void 0;
|
|
7
|
+
}
|
|
8
|
+
if (!Array.isArray(raw)) return void 0;
|
|
9
|
+
const out = [];
|
|
10
|
+
for (const item of raw) {
|
|
11
|
+
if (typeof item === "string") {
|
|
12
|
+
const trimmed = item.trim();
|
|
13
|
+
if (trimmed.length > 0) {
|
|
14
|
+
out.push({ value: trimmed, label: trimmed });
|
|
15
|
+
}
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (item != null && typeof item === "object") {
|
|
19
|
+
const obj = item;
|
|
20
|
+
const labelRaw = obj["label"];
|
|
21
|
+
const valueRaw = obj["value"];
|
|
22
|
+
if (typeof labelRaw === "string" && labelRaw.trim().length > 0) {
|
|
23
|
+
const label = labelRaw.trim();
|
|
24
|
+
const value = typeof valueRaw === "string" && valueRaw.length > 0 ? valueRaw : label;
|
|
25
|
+
const descRaw = obj["description"];
|
|
26
|
+
const opt = {
|
|
27
|
+
value,
|
|
28
|
+
label
|
|
29
|
+
};
|
|
30
|
+
if (typeof descRaw === "string" && descRaw.length > 0) {
|
|
31
|
+
opt.description = descRaw;
|
|
32
|
+
}
|
|
33
|
+
out.push(opt);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return out.length > 0 ? out : void 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
normalizeAskOptions
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=chunk-LCLH6ZUL.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RT2A2RRL.js";
|
|
5
5
|
|
|
6
6
|
// src/server/utils/platform.ts
|
|
7
7
|
import os from "os";
|
|
@@ -63,4 +63,4 @@ export {
|
|
|
63
63
|
isWindowsPath,
|
|
64
64
|
isAbsolutePath
|
|
65
65
|
};
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
66
|
+
//# sourceMappingURL=chunk-N4RTAGFY.js.map
|
|
@@ -4,19 +4,25 @@ import {
|
|
|
4
4
|
buildSnapshot,
|
|
5
5
|
foldContextState,
|
|
6
6
|
foldSessionState,
|
|
7
|
-
spreadOptionalMessageFields
|
|
8
|
-
|
|
7
|
+
spreadOptionalMessageFields,
|
|
8
|
+
trimSnapshotStreamingOutput
|
|
9
|
+
} from "./chunk-QGXLZZBS.js";
|
|
9
10
|
import {
|
|
10
11
|
updateSessionMessageCount
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-C5NQF2K4.js";
|
|
12
13
|
import {
|
|
13
14
|
getRuntimeConfig
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JNHKKUGJ.js";
|
|
16
|
+
import {
|
|
17
|
+
SETTINGS_KEYS
|
|
18
|
+
} from "./chunk-RT2A2RRL.js";
|
|
15
19
|
import {
|
|
16
20
|
logger
|
|
17
21
|
} from "./chunk-K44MW7JJ.js";
|
|
18
22
|
|
|
19
23
|
// src/server/events/store.ts
|
|
24
|
+
import { existsSync, statSync, unlinkSync } from "fs";
|
|
25
|
+
var SNAPSHOT_BACKUP_RETENTION_MS = 10 * 24 * 60 * 60 * 1e3;
|
|
20
26
|
function createEventIterator(state, subscriber) {
|
|
21
27
|
return {
|
|
22
28
|
[Symbol.asyncIterator]() {
|
|
@@ -714,6 +720,188 @@ var EventStore = class _EventStore {
|
|
|
714
720
|
logger.info("Orphaned sessions found", { count: orphaned.length, ids: orphaned });
|
|
715
721
|
return orphaned;
|
|
716
722
|
}
|
|
723
|
+
/**
|
|
724
|
+
* Remove an expired rollback backup (`<db>.pre-de-dup.bak`) once it has aged
|
|
725
|
+
* past the retention window. Best-effort: failures are logged at debug level
|
|
726
|
+
* and never abort the caller (startup or manual migration).
|
|
727
|
+
*/
|
|
728
|
+
pruneExpiredRollbackBackup() {
|
|
729
|
+
const dbName = this.db.name;
|
|
730
|
+
if (!dbName || dbName === ":memory:") return;
|
|
731
|
+
const backupPath = `${dbName}.pre-de-dup.bak`;
|
|
732
|
+
try {
|
|
733
|
+
if (!existsSync(backupPath)) return;
|
|
734
|
+
const ageMs = Date.now() - statSync(backupPath).mtimeMs;
|
|
735
|
+
if (ageMs <= SNAPSHOT_BACKUP_RETENTION_MS) return;
|
|
736
|
+
unlinkSync(backupPath);
|
|
737
|
+
logger.info("Pruned expired rollback backup", {
|
|
738
|
+
backupPath,
|
|
739
|
+
ageDays: Math.round(ageMs / (24 * 60 * 60 * 1e3))
|
|
740
|
+
});
|
|
741
|
+
} catch (error) {
|
|
742
|
+
logger.debug("Could not prune expired rollback backup", {
|
|
743
|
+
backupPath,
|
|
744
|
+
error: error instanceof Error ? error.message : String(error)
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Rewrite every persisted snapshot with the snapshot streaming
|
|
750
|
+
* de-duplication applied (see trimSnapshotStreamingOutput). Every finished
|
|
751
|
+
* tool call's streaming output is dropped — it is never read again once the
|
|
752
|
+
* call has a result; only pending (in-flight) calls keep their stream.
|
|
753
|
+
*
|
|
754
|
+
* Safe by construction: before the first rewrite it creates a rollback copy
|
|
755
|
+
* of the database (`<db>.pre-de-dup.bak`, only once) — the migration refuses
|
|
756
|
+
* to rewrite if that backup cannot be created. Expired rollback backups are
|
|
757
|
+
* auto-pruned (10-day retention) at the start of every invocation. Idempotent:
|
|
758
|
+
* after a successful run the maintenance flag is set and subsequent runs are
|
|
759
|
+
* a no-op. Returns a report used for the audit trail.
|
|
760
|
+
*/
|
|
761
|
+
async migrateSnapshotStreams() {
|
|
762
|
+
this.pruneExpiredRollbackBackup();
|
|
763
|
+
const flag = this.getMaintenanceFlag();
|
|
764
|
+
if (flag === "true") {
|
|
765
|
+
return {
|
|
766
|
+
skipped: true,
|
|
767
|
+
backupPath: null,
|
|
768
|
+
scanned: 0,
|
|
769
|
+
rewritten: 0,
|
|
770
|
+
droppedStreams: 0,
|
|
771
|
+
bytesBefore: 0,
|
|
772
|
+
bytesAfter: 0,
|
|
773
|
+
kept: { pending: 0, samples: [] }
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
const dbName = this.db.name;
|
|
777
|
+
let backupPath = null;
|
|
778
|
+
if (dbName && dbName !== ":memory:") {
|
|
779
|
+
backupPath = `${dbName}.pre-de-dup.bak`;
|
|
780
|
+
try {
|
|
781
|
+
if (!existsSync(backupPath)) {
|
|
782
|
+
logger.info("Creating rollback backup before snapshot stream de-dup", { backupPath });
|
|
783
|
+
await this.db.backup(backupPath);
|
|
784
|
+
}
|
|
785
|
+
} catch (error) {
|
|
786
|
+
logger.error("Aborting snapshot stream de-dup: could not create rollback backup", {
|
|
787
|
+
backupPath,
|
|
788
|
+
error: error instanceof Error ? error.message : String(error)
|
|
789
|
+
});
|
|
790
|
+
return {
|
|
791
|
+
skipped: true,
|
|
792
|
+
backupPath: null,
|
|
793
|
+
scanned: 0,
|
|
794
|
+
rewritten: 0,
|
|
795
|
+
droppedStreams: 0,
|
|
796
|
+
bytesBefore: 0,
|
|
797
|
+
bytesAfter: 0,
|
|
798
|
+
kept: { pending: 0, samples: [] }
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
const rows = this.db.prepare(`SELECT id, session_id, payload FROM events WHERE event_type = 'turn.snapshot'`).all();
|
|
803
|
+
const update = this.db.prepare(`UPDATE events SET payload = ? WHERE id = ?`);
|
|
804
|
+
const kept = { pending: 0, samples: [] };
|
|
805
|
+
let rewritten = 0;
|
|
806
|
+
let droppedStreams = 0;
|
|
807
|
+
let bytesBefore = 0;
|
|
808
|
+
let bytesAfter = 0;
|
|
809
|
+
this.db.transaction(() => {
|
|
810
|
+
for (const row of rows) {
|
|
811
|
+
bytesBefore += Buffer.byteLength(row.payload);
|
|
812
|
+
let parsed;
|
|
813
|
+
try {
|
|
814
|
+
parsed = JSON.parse(row.payload);
|
|
815
|
+
} catch {
|
|
816
|
+
bytesAfter += Buffer.byteLength(row.payload);
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
let snapshotDropped = 0;
|
|
820
|
+
for (const message of parsed.messages ?? []) {
|
|
821
|
+
for (const tc of message.toolCalls ?? []) {
|
|
822
|
+
if (!tc.streamingOutput || tc.streamingOutput.length === 0) continue;
|
|
823
|
+
if (tc.result === void 0) {
|
|
824
|
+
kept.pending++;
|
|
825
|
+
if (kept.samples.length < 20) {
|
|
826
|
+
kept.samples.push({ sessionId: row.session_id, tool: tc.name });
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
snapshotDropped++;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
if (snapshotDropped === 0) {
|
|
834
|
+
bytesAfter += Buffer.byteLength(row.payload);
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
const { messages, droppedStreams: dropped } = trimSnapshotStreamingOutput(parsed.messages ?? []);
|
|
838
|
+
if (dropped === 0) {
|
|
839
|
+
bytesAfter += Buffer.byteLength(row.payload);
|
|
840
|
+
continue;
|
|
841
|
+
}
|
|
842
|
+
const next = { ...parsed, messages };
|
|
843
|
+
const nextPayload = JSON.stringify(next);
|
|
844
|
+
update.run(nextPayload, row.id);
|
|
845
|
+
rewritten++;
|
|
846
|
+
droppedStreams += dropped;
|
|
847
|
+
bytesAfter += Buffer.byteLength(nextPayload);
|
|
848
|
+
}
|
|
849
|
+
})();
|
|
850
|
+
this.setSettingViaDb(SETTINGS_KEYS.MAINTENANCE_SNAPSHOT_STREAMS_MIGRATED, "true");
|
|
851
|
+
logger.info("Snapshot stream migration complete", {
|
|
852
|
+
scanned: rows.length,
|
|
853
|
+
rewritten,
|
|
854
|
+
droppedStreams,
|
|
855
|
+
keptPending: kept.pending,
|
|
856
|
+
bytesSaved: bytesBefore - bytesAfter
|
|
857
|
+
});
|
|
858
|
+
return {
|
|
859
|
+
skipped: false,
|
|
860
|
+
backupPath,
|
|
861
|
+
scanned: rows.length,
|
|
862
|
+
rewritten,
|
|
863
|
+
droppedStreams,
|
|
864
|
+
bytesBefore,
|
|
865
|
+
bytesAfter,
|
|
866
|
+
kept
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* Read a maintenance flag from the settings table, tolerating databases
|
|
871
|
+
* without that table (e.g. minimal test fixtures).
|
|
872
|
+
*/
|
|
873
|
+
getMaintenanceFlag() {
|
|
874
|
+
try {
|
|
875
|
+
const row = this.db.prepare(`SELECT value FROM settings WHERE key = ?`).get(SETTINGS_KEYS.MAINTENANCE_SNAPSHOT_STREAMS_MIGRATED);
|
|
876
|
+
return row?.value ?? null;
|
|
877
|
+
} catch {
|
|
878
|
+
return null;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Upsert a maintenance flag, tolerating databases without the settings table.
|
|
883
|
+
*/
|
|
884
|
+
setSettingViaDb(key, value) {
|
|
885
|
+
try {
|
|
886
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
887
|
+
this.db.prepare(
|
|
888
|
+
`INSERT INTO settings (key, value, updated_at)
|
|
889
|
+
VALUES (?, ?, ?)
|
|
890
|
+
ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`
|
|
891
|
+
).run(key, value, now);
|
|
892
|
+
} catch {
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Collapse the WAL into the main database and truncate the file. Safe to
|
|
897
|
+
* call anytime; a no-op when the WAL is empty.
|
|
898
|
+
*/
|
|
899
|
+
checkpointWal() {
|
|
900
|
+
const result = this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
901
|
+
const summary = result[0] ?? { busy: 0, log: 0, checkpointed: 0 };
|
|
902
|
+
logger.debug("WAL checkpoint", summary);
|
|
903
|
+
return summary;
|
|
904
|
+
}
|
|
717
905
|
};
|
|
718
906
|
var eventStoreInstance = null;
|
|
719
907
|
function initEventStore(db) {
|
|
@@ -728,6 +916,25 @@ function initEventStore(db) {
|
|
|
728
916
|
if (result.deletedSnapshots > 0) {
|
|
729
917
|
logger.info("Storage optimized", result);
|
|
730
918
|
}
|
|
919
|
+
setImmediate(() => {
|
|
920
|
+
void (async () => {
|
|
921
|
+
try {
|
|
922
|
+
const report = await eventStoreInstance.migrateSnapshotStreams();
|
|
923
|
+
if (!report.skipped) {
|
|
924
|
+
logger.info("Snapshot stream de-dup (auto)", {
|
|
925
|
+
rewritten: report.rewritten,
|
|
926
|
+
droppedStreams: report.droppedStreams,
|
|
927
|
+
bytesSaved: report.bytesBefore - report.bytesAfter,
|
|
928
|
+
backupPath: report.backupPath
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
} catch (error) {
|
|
932
|
+
logger.warn("Snapshot stream de-dup failed at startup", {
|
|
933
|
+
error: error instanceof Error ? error.message : String(error)
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
})();
|
|
937
|
+
});
|
|
731
938
|
setImmediate(() => {
|
|
732
939
|
try {
|
|
733
940
|
logger.info("Starting orphaned session consolidation");
|
|
@@ -749,6 +956,15 @@ function initEventStore(db) {
|
|
|
749
956
|
} catch {
|
|
750
957
|
}
|
|
751
958
|
});
|
|
959
|
+
setImmediate(() => {
|
|
960
|
+
try {
|
|
961
|
+
eventStoreInstance.checkpointWal();
|
|
962
|
+
} catch (error) {
|
|
963
|
+
logger.debug("WAL checkpoint failed at startup", {
|
|
964
|
+
error: error instanceof Error ? error.message : String(error)
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
});
|
|
752
968
|
return eventStoreInstance;
|
|
753
969
|
}
|
|
754
970
|
function resetStaleRunningSessions(eventStore, db) {
|
|
@@ -1249,4 +1465,4 @@ export {
|
|
|
1249
1465
|
truncateSessionMessages,
|
|
1250
1466
|
getRecentUserPromptsForSession
|
|
1251
1467
|
};
|
|
1252
|
-
//# sourceMappingURL=chunk-
|
|
1468
|
+
//# sourceMappingURL=chunk-NB2D6I64.js.map
|
|
@@ -8,6 +8,7 @@ function buildUpdatedServerConfig(patch, existing, persistedCfg) {
|
|
|
8
8
|
const mergedEnv = patch.env !== void 0 ? patch.env : transportChanged ? void 0 : existing.config.env;
|
|
9
9
|
const mergedUrl = patch.url !== void 0 ? patch.url : transportChanged ? void 0 : existing.config.url;
|
|
10
10
|
const mergedHeaders = patch.headers !== void 0 ? patch.headers : transportChanged ? void 0 : existing.config.headers;
|
|
11
|
+
const mergedOauth = patch.oauth !== void 0 ? patch.oauth : transportChanged ? void 0 : existing.config.oauth;
|
|
11
12
|
const mergedTimeout = patch.timeout !== void 0 ? patch.timeout : existing.config.timeout;
|
|
12
13
|
const mergedDisabled = patch.disabled !== void 0 ? patch.disabled : existing.config.disabled;
|
|
13
14
|
if (patch.timeout !== void 0 && (typeof patch.timeout !== "number" || patch.timeout <= 0)) {
|
|
@@ -26,6 +27,7 @@ function buildUpdatedServerConfig(patch, existing, persistedCfg) {
|
|
|
26
27
|
...mergedEnv && Object.keys(mergedEnv).length > 0 ? { env: mergedEnv } : {},
|
|
27
28
|
...mergedUrl ? { url: mergedUrl } : {},
|
|
28
29
|
...mergedHeaders && Object.keys(mergedHeaders).length > 0 ? { headers: mergedHeaders } : {},
|
|
30
|
+
...mergedOauth ? { oauth: mergedOauth } : {},
|
|
29
31
|
...mergedTimeout !== void 0 ? { timeout: mergedTimeout } : {},
|
|
30
32
|
...mergedDisabled !== void 0 ? { disabled: mergedDisabled } : {},
|
|
31
33
|
...persistedCfg?.disabledTools && persistedCfg.disabledTools.length > 0 ? { disabledTools: persistedCfg.disabledTools } : {},
|
|
@@ -58,4 +60,4 @@ export {
|
|
|
58
60
|
buildUpdatedServerConfig,
|
|
59
61
|
applyMcpServerUpdate
|
|
60
62
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-OAN4BXEW.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-RT2A2RRL.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
7
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -164,4 +164,4 @@ export {
|
|
|
164
164
|
WorkspaceInUseError,
|
|
165
165
|
OpenAIHttpClient
|
|
166
166
|
};
|
|
167
|
-
//# sourceMappingURL=chunk-
|
|
167
|
+
//# sourceMappingURL=chunk-PCC4DBPF.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeAskOptions
|
|
3
|
+
} from "./chunk-LCLH6ZUL.js";
|
|
1
4
|
import {
|
|
2
5
|
resolveDefaultAgentId
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JNHKKUGJ.js";
|
|
4
7
|
|
|
5
8
|
// src/server/events/apply-events.ts
|
|
6
9
|
function markComplete(msg, reason) {
|
|
@@ -763,7 +766,12 @@ function foldSessionState(events, initialWindowId, maxTokens, initialMessages, d
|
|
|
763
766
|
}
|
|
764
767
|
case "chat.ask_user": {
|
|
765
768
|
const data = event.data;
|
|
766
|
-
pendingUserInput = {
|
|
769
|
+
pendingUserInput = {
|
|
770
|
+
callId: data.callId,
|
|
771
|
+
question: data.question,
|
|
772
|
+
type: data.type,
|
|
773
|
+
options: normalizeAskOptions(data.options)
|
|
774
|
+
};
|
|
767
775
|
break;
|
|
768
776
|
}
|
|
769
777
|
case "task.completed": {
|
|
@@ -828,34 +836,33 @@ function foldWaitingWorkflow(events) {
|
|
|
828
836
|
}
|
|
829
837
|
return waitingWorkflow;
|
|
830
838
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
839
|
+
function trimSnapshotStreamingOutput(messages) {
|
|
840
|
+
let droppedStreams = 0;
|
|
841
|
+
let keptStreams = 0;
|
|
842
|
+
const trimmedMessages = messages.map((message) => {
|
|
834
843
|
const toolCalls = message.toolCalls;
|
|
835
844
|
if (!toolCalls) return message;
|
|
836
845
|
let changed = false;
|
|
837
846
|
const newToolCalls = toolCalls.map((tc) => {
|
|
838
847
|
if (!tc.streamingOutput || tc.streamingOutput.length === 0) return tc;
|
|
839
|
-
if (tc.result
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
}
|
|
850
|
-
changed = true;
|
|
851
|
-
return { ...tc, streamingOutput: kept, streamingOutputTruncated: true };
|
|
848
|
+
if (tc.result !== void 0) {
|
|
849
|
+
droppedStreams++;
|
|
850
|
+
changed = true;
|
|
851
|
+
const { streamingOutput: _omitted, streamingOutputTruncated: _omittedFlag, ...rest } = tc;
|
|
852
|
+
void _omitted;
|
|
853
|
+
void _omittedFlag;
|
|
854
|
+
return rest;
|
|
855
|
+
}
|
|
856
|
+
keptStreams++;
|
|
857
|
+
return tc;
|
|
852
858
|
});
|
|
853
859
|
if (!changed) return message;
|
|
854
860
|
return { ...message, toolCalls: newToolCalls };
|
|
855
861
|
});
|
|
862
|
+
return { messages: trimmedMessages, droppedStreams, keptStreams };
|
|
856
863
|
}
|
|
857
864
|
function buildSnapshot(foldedState, latestSeq, snapshotAt = Date.now()) {
|
|
858
|
-
const messages =
|
|
865
|
+
const { messages } = trimSnapshotStreamingOutput(foldedState.messages);
|
|
859
866
|
return {
|
|
860
867
|
mode: foldedState.mode,
|
|
861
868
|
phase: foldedState.phase,
|
|
@@ -901,7 +908,7 @@ function buildSnapshotFromSessionState(input) {
|
|
|
901
908
|
latestSnapshotEvent.data.messages,
|
|
902
909
|
events.slice(latestSnapshotIndex + 1)
|
|
903
910
|
) : foldedState.messages;
|
|
904
|
-
const trimmedMessages =
|
|
911
|
+
const { messages: trimmedMessages } = trimSnapshotStreamingOutput(messages);
|
|
905
912
|
return {
|
|
906
913
|
mode: session.mode,
|
|
907
914
|
phase: session.phase,
|
|
@@ -954,7 +961,8 @@ export {
|
|
|
954
961
|
foldPendingConfirmations,
|
|
955
962
|
foldSessionState,
|
|
956
963
|
foldWaitingWorkflow,
|
|
964
|
+
trimSnapshotStreamingOutput,
|
|
957
965
|
buildSnapshot,
|
|
958
966
|
buildSnapshotFromSessionState
|
|
959
967
|
};
|
|
960
|
-
//# sourceMappingURL=chunk-
|
|
968
|
+
//# sourceMappingURL=chunk-QGXLZZBS.js.map
|