openfox 2.0.76 → 2.0.78
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/dist/{chat-handler-3BZ4PDL2.js → chat-handler-5ZHPYU24.js} +21 -20
- package/dist/{chunk-MF3UW36X.js → chunk-37WF2Z3T.js} +84 -17
- package/dist/{chunk-OBQPXUXI.js → chunk-5CQRB7AD.js} +2 -2
- package/dist/chunk-64TKWWNF.js +7 -0
- package/dist/{chunk-LXFLRM7M.js → chunk-6AE3JPDJ.js} +2 -2
- package/dist/chunk-AANVMTYU.js +327 -0
- package/dist/{chunk-YMFCFMMB.js → chunk-AFJLY43Z.js} +8 -3
- package/dist/{chunk-OCVRIPQP.js → chunk-CJDYSUU5.js} +3 -3
- package/dist/{chunk-OMWVB2XC.js → chunk-DI4SIPFT.js} +46 -27
- package/dist/{chunk-7772ENZN.js → chunk-EHVDAVYG.js} +4 -3
- package/dist/{chunk-DH3SSBZN.js → chunk-EYIWUONA.js} +2 -2
- package/dist/{chunk-NGJ5XJ7D.js → chunk-M7EFXRDS.js} +57 -290
- package/dist/{chunk-4QHDQP2N.js → chunk-MTUYDBSL.js} +2 -2
- package/dist/{chunk-HHUIXHHX.js → chunk-NUR2B4RU.js} +7 -7
- package/dist/{chunk-46RORSKU.js → chunk-NZIYELSQ.js} +9 -7
- package/dist/{chunk-7QXRQ5ZL.js → chunk-RGUUZD5B.js} +5 -1
- package/dist/{chunk-EZK7CGJ7.js → chunk-RMXPVQP4.js} +315 -45
- package/dist/{chunk-D6CI2B7B.js → chunk-SGBXBP3S.js} +253 -110
- package/dist/{chunk-O3NUNU4H.js → chunk-SJTG56CH.js} +5 -4
- package/dist/{chunk-DJASQ2ZB.js → chunk-TSVFRWSG.js} +24 -5
- package/dist/{chunk-XTK6E2QR.js → chunk-UIU7OGHP.js} +26 -10
- package/dist/{chunk-J7VCI5EX.js → chunk-UMX7MMNW.js} +652 -248
- package/dist/{chunk-HLHGNHMV.js → chunk-VGWJFXPR.js} +23 -11
- package/dist/{chunk-KVRSAC4Z.js → chunk-VPFUXGMM.js} +6 -1
- package/dist/{chunk-W4ZEG3LX.js → chunk-WL2WEJAK.js} +2 -2
- package/dist/{chunk-HAQV6AJP.js → chunk-WUSWNLTV.js} +3 -3
- package/dist/{chunk-5GOOSZX7.js → chunk-X6BXZFO7.js} +1 -1
- package/dist/{chunk-WGAAQASA.js → chunk-YFVSSMA3.js} +3 -2
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{client-TDPQVBQ7.js → client-V5DZRO2D.js} +3 -3
- package/dist/{client-pure-NMLDKRDN.js → client-pure-5YE5WFJP.js} +2 -2
- package/dist/compactor-G7B3V24F.js +24 -0
- package/dist/{config-EUMVEFHU.js → config-MD74ETY5.js} +2 -2
- package/dist/{events-FLWRLM6V.js → events-KNOZX7YG.js} +7 -4
- package/dist/{folding-ONH3D4OK.js → folding-OPP2BVUB.js} +2 -2
- package/dist/{inspect-proxy-JHZV34QR.js → inspect-proxy-DRYIIH4O.js} +4 -4
- package/dist/{manager-OPMCSYN2.js → manager-ATWZUL3O.js} +5 -5
- package/dist/{orchestrator-5IMCWX5P.js → orchestrator-L6LX5BV7.js} +20 -19
- package/dist/package.json +6 -1
- package/dist/{path-security-ZROWNL22.js → path-security-HUXQHEQ5.js} +10 -7
- package/dist/{platform-QGXO3CNR.js → platform-VBNNMTR5.js} +4 -4
- package/dist/{processor-3R4GS6VB.js → processor-UQX5KL56.js} +21 -20
- package/dist/{project-creator-C22J43BC.js → project-creator-NNUITNUI.js} +3 -3
- package/dist/{projects-WSVINK2C.js → projects-ZGJGICGT.js} +3 -3
- package/dist/{protocol-Sr6Jr4ZS.d.ts → protocol-BXxJmsOW.d.ts} +2 -1
- package/dist/{protocol-EWEVW65B.js → protocol-Q7X4NEME.js} +3 -3
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-G2YC2IC4.js → provider-PI3RDDE4.js} +6 -6
- package/dist/{provider-manager-SQIELYLK.js → provider-manager-PD3BXUHY.js} +4 -4
- package/dist/{serve-MXKMKZYY.js → serve-QWC3U5MB.js} +26 -25
- package/dist/server/index.d.ts +27 -4
- package/dist/server/index.js +25 -24
- package/dist/server-3XUD2NB7.js +40 -0
- package/dist/sessions-SFG42M4W.js +42 -0
- package/dist/{settings-7XDMSPIC.js → settings-6M55N4Q2.js} +5 -3
- package/dist/shared/index.d.ts +3 -3
- package/dist/shared/index.js +1 -1
- package/dist/{tools-JRCUWPJO.js → tools-HGKUD327.js} +26 -23
- package/dist/{types-C4cG9CtC.d.ts → types-C308SU4B.d.ts} +3 -0
- package/dist/{types-DSZhFA8O.d.ts → types-o07LJcLI.d.ts} +1 -1
- package/dist/{update-OXDQ75M7.js → update-NWZALB5M.js} +2 -2
- package/dist/{update-server-4MTM7M5P.js → update-server-V6GJ43WH.js} +2 -2
- package/dist/web/assets/index-7_xKqeJc.js +305 -0
- package/dist/web/assets/index-DRkTjPo3.css +32 -0
- package/dist/web/index.html +4 -4
- package/dist/web/manifest.webmanifest +1 -1
- package/dist/web/registerSW.js +1 -1
- package/dist/web/sw.js +1 -1
- package/dist/{workspace-6QTTUMMW.js → workspace-J74ZMSOJ.js} +14 -2
- package/package.json +6 -1
- package/dist/chunk-KQEVAO2Q.js +0 -7
- package/dist/compactor-BB3YYVRP.js +0 -23
- package/dist/server-SPYFMFQE.js +0 -39
- package/dist/web/assets/index-BNVBxKnB.css +0 -32
- package/dist/web/assets/index-ghDkIdlf.js +0 -305
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
computeSessionHash,
|
|
4
4
|
runAgentTurn,
|
|
5
5
|
runChatTurn
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VGWJFXPR.js";
|
|
7
7
|
import {
|
|
8
8
|
deleteItemFromDir,
|
|
9
9
|
devServerManager,
|
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
jsonSerializer,
|
|
14
14
|
loadAllAgentsDefault,
|
|
15
15
|
saveItemToDir
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-SGBXBP3S.js";
|
|
17
|
+
import {
|
|
18
|
+
checkAborted,
|
|
19
|
+
onProcessEvent,
|
|
20
|
+
spawnShellProcess
|
|
21
|
+
} from "./chunk-5CQRB7AD.js";
|
|
17
22
|
import {
|
|
18
23
|
gitSpawnEnv
|
|
19
24
|
} from "./chunk-WGMJCFCE.js";
|
|
@@ -23,32 +28,31 @@ import {
|
|
|
23
28
|
} from "./chunk-EU3WWTFH.js";
|
|
24
29
|
import {
|
|
25
30
|
appendCompactionPrompt
|
|
26
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-WUSWNLTV.js";
|
|
27
32
|
import {
|
|
28
33
|
TurnMetrics,
|
|
29
34
|
createMessageStartEvent
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
checkAborted,
|
|
33
|
-
onProcessEvent,
|
|
34
|
-
spawnShellProcess
|
|
35
|
-
} from "./chunk-OBQPXUXI.js";
|
|
35
|
+
} from "./chunk-EHVDAVYG.js";
|
|
36
36
|
import {
|
|
37
37
|
getPlatformShell
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-MTUYDBSL.js";
|
|
39
|
+
import {
|
|
40
|
+
getMaxVisibleItems
|
|
41
|
+
} from "./chunk-AFJLY43Z.js";
|
|
39
42
|
import {
|
|
40
43
|
killProcessTree,
|
|
41
44
|
terminateProcessTree
|
|
42
45
|
} from "./chunk-I72ACQ6R.js";
|
|
43
46
|
import {
|
|
47
|
+
combineEventsWithSnapshot,
|
|
44
48
|
getCurrentContextWindowId,
|
|
45
49
|
getEventStore,
|
|
46
50
|
getRuntimeConfig
|
|
47
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-M7EFXRDS.js";
|
|
48
52
|
import {
|
|
49
53
|
buildMessagesFromStoredEvents,
|
|
50
54
|
foldPendingConfirmations
|
|
51
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-TSVFRWSG.js";
|
|
52
56
|
import {
|
|
53
57
|
createChatErrorMessage,
|
|
54
58
|
createChatMessageMessage,
|
|
@@ -63,7 +67,7 @@ import {
|
|
|
63
67
|
parseClientMessage,
|
|
64
68
|
serializeServerMessage,
|
|
65
69
|
storedEventToServerMessage
|
|
66
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-SJTG56CH.js";
|
|
67
71
|
import {
|
|
68
72
|
logger
|
|
69
73
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -72,7 +76,7 @@ import {
|
|
|
72
76
|
} from "./chunk-VUQCQXXJ.js";
|
|
73
77
|
import {
|
|
74
78
|
createServerMessage
|
|
75
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-X6BXZFO7.js";
|
|
76
80
|
import {
|
|
77
81
|
getGlobalConfigDir
|
|
78
82
|
} from "./chunk-CQGTEGKL.js";
|
|
@@ -1600,21 +1604,27 @@ function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvi
|
|
|
1600
1604
|
const seq = client.lastSentSeq + 1;
|
|
1601
1605
|
enqueueSend(client, serializeServerMessage({ ...msg, sessionId }), seq);
|
|
1602
1606
|
}
|
|
1603
|
-
if (msg.type === "chat.path_confirmation" && projectId) {
|
|
1607
|
+
if ((msg.type === "chat.path_confirmation" || msg.type === "session.confirmation_resolved") && projectId) {
|
|
1604
1608
|
for (const [clientWs, client] of clients) {
|
|
1605
1609
|
if (clientWs.readyState !== WebSocket2.OPEN) continue;
|
|
1606
1610
|
if (isSubscribedToSession(client, sessionId)) continue;
|
|
1607
1611
|
const clientProjectId = client.activeSessionId ? sessionManager.getSession(client.activeSessionId)?.projectId : void 0;
|
|
1608
1612
|
if (clientProjectId !== projectId) continue;
|
|
1609
1613
|
const seq = client.lastSentSeq + 1;
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
serializeServerMessage({ type: "session.confirmation_pending", sessionId, payload: msg.payload }),
|
|
1613
|
-
seq
|
|
1614
|
-
);
|
|
1614
|
+
const crossSessionType = msg.type === "chat.path_confirmation" ? "session.confirmation_pending" : "session.confirmation_resolved";
|
|
1615
|
+
enqueueSend(client, serializeServerMessage({ type: crossSessionType, sessionId, payload: msg.payload }), seq);
|
|
1615
1616
|
}
|
|
1616
1617
|
}
|
|
1617
1618
|
};
|
|
1619
|
+
const broadcastForProject = (projectId, sessionId, msg) => {
|
|
1620
|
+
for (const [clientWs, client] of clients) {
|
|
1621
|
+
if (clientWs.readyState !== WebSocket2.OPEN) continue;
|
|
1622
|
+
const clientProjectId = client.activeSessionId ? sessionManager.getSession(client.activeSessionId)?.projectId : void 0;
|
|
1623
|
+
if (clientProjectId !== projectId) continue;
|
|
1624
|
+
const seq = client.lastSentSeq + 1;
|
|
1625
|
+
enqueueSend(client, serializeServerMessage({ ...msg, sessionId }), seq);
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1618
1628
|
devServerManager.onOutput((workdir, chunk) => {
|
|
1619
1629
|
broadcastAll(
|
|
1620
1630
|
createServerMessage("devServer.output", {
|
|
@@ -1637,15 +1647,15 @@ function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvi
|
|
|
1637
1647
|
if (event.type === "session_updated") {
|
|
1638
1648
|
const updatedSession = event.session;
|
|
1639
1649
|
const eventStore = getEventStore();
|
|
1640
|
-
const events = eventStore.
|
|
1641
|
-
const
|
|
1650
|
+
const { snapshot, events: eventsSinceSnapshot } = eventStore.getEventsSinceSnapshot(updatedSession.id);
|
|
1651
|
+
const events = combineEventsWithSnapshot(updatedSession.id, snapshot, eventsSinceSnapshot);
|
|
1652
|
+
const maxVisible = getMaxVisibleItems();
|
|
1653
|
+
const { messages, hiddenCount } = buildMessagesFromStoredEvents(events, maxVisible || void 0);
|
|
1642
1654
|
const pendingConfirmations = foldPendingConfirmations(events);
|
|
1643
1655
|
const pendingQuestions = getPendingQuestionsForSession(updatedSession.id);
|
|
1644
1656
|
const effectiveWorkdir = updatedSession.workspace ?? updatedSession.workdir;
|
|
1645
|
-
let workspaceChanged = false;
|
|
1646
1657
|
for (const [, client] of clients) {
|
|
1647
1658
|
if (client.activeSessionId === updatedSession.id && client.activeWorkdir !== effectiveWorkdir) {
|
|
1648
|
-
workspaceChanged = true;
|
|
1649
1659
|
const prevWorkdir = client.activeWorkdir;
|
|
1650
1660
|
client.activeWorkdir = effectiveWorkdir;
|
|
1651
1661
|
if (prevWorkdir) {
|
|
@@ -1659,9 +1669,17 @@ function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvi
|
|
|
1659
1669
|
if (effectiveWorkdir) moduleStartGitPolling(effectiveWorkdir);
|
|
1660
1670
|
broadcastForSession(
|
|
1661
1671
|
updatedSession.id,
|
|
1662
|
-
createSessionStateMessage(
|
|
1672
|
+
createSessionStateMessage(
|
|
1673
|
+
updatedSession,
|
|
1674
|
+
messages,
|
|
1675
|
+
pendingConfirmations,
|
|
1676
|
+
pendingQuestions,
|
|
1677
|
+
void 0,
|
|
1678
|
+
void 0,
|
|
1679
|
+
hiddenCount
|
|
1680
|
+
)
|
|
1663
1681
|
);
|
|
1664
|
-
if (
|
|
1682
|
+
if (effectiveWorkdir) {
|
|
1665
1683
|
;
|
|
1666
1684
|
(async () => {
|
|
1667
1685
|
const branch = await moduleGitBranch(effectiveWorkdir);
|
|
@@ -1809,6 +1827,7 @@ function createWebSocketServer(httpServer, _config, getLLMClient, getActiveProvi
|
|
|
1809
1827
|
},
|
|
1810
1828
|
close: (cb) => wss.close(cb),
|
|
1811
1829
|
broadcastForSession,
|
|
1830
|
+
broadcastForProject,
|
|
1812
1831
|
broadcastAll
|
|
1813
1832
|
};
|
|
1814
1833
|
}
|
|
@@ -2194,4 +2213,4 @@ export {
|
|
|
2194
2213
|
signalMcpReady,
|
|
2195
2214
|
createWebSocketServer
|
|
2196
2215
|
};
|
|
2197
|
-
//# sourceMappingURL=chunk-
|
|
2216
|
+
//# sourceMappingURL=chunk-DI4SIPFT.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPlatformShell
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MTUYDBSL.js";
|
|
4
4
|
import {
|
|
5
5
|
streamWithSegments
|
|
6
6
|
} from "./chunk-J2GP3J3X.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-YHEQTVFV.js";
|
|
13
13
|
import {
|
|
14
14
|
buildModelParams
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-RMXPVQP4.js";
|
|
16
16
|
import {
|
|
17
17
|
logger
|
|
18
18
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -62,6 +62,7 @@ Prefer precise, minimal changes.
|
|
|
62
62
|
Use available tools when needed.
|
|
63
63
|
Explain tradeoffs clearly when requirements are ambiguous.
|
|
64
64
|
Follow repository and project instructions exactly.
|
|
65
|
+
Commands run from your working directory \u2014 do not prepend "cd /path/" to change to a directory you are already in.
|
|
65
66
|
|
|
66
67
|
## MODE CONTROL
|
|
67
68
|
OpenFox appends runtime control as USER-role messages wrapped in <system-reminder>...</system-reminder>.
|
|
@@ -679,4 +680,4 @@ export {
|
|
|
679
680
|
createChatDoneEvent,
|
|
680
681
|
consumeStreamGenerator
|
|
681
682
|
};
|
|
682
|
-
//# sourceMappingURL=chunk-
|
|
683
|
+
//# sourceMappingURL=chunk-EHVDAVYG.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectByWorkdir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6AE3JPDJ.js";
|
|
4
4
|
import {
|
|
5
5
|
logger
|
|
6
6
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -343,4 +343,4 @@ export {
|
|
|
343
343
|
startInspectProxy,
|
|
344
344
|
stopAllInspectProxies
|
|
345
345
|
};
|
|
346
|
-
//# sourceMappingURL=chunk-
|
|
346
|
+
//# sourceMappingURL=chunk-EYIWUONA.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDatabase
|
|
3
|
-
} from "./chunk-7QXRQ5ZL.js";
|
|
4
1
|
import {
|
|
5
2
|
buildContextMessagesFromEventHistory,
|
|
6
3
|
buildMessagesFromStoredEvents,
|
|
@@ -8,7 +5,10 @@ import {
|
|
|
8
5
|
foldContextState,
|
|
9
6
|
foldSessionState,
|
|
10
7
|
spreadOptionalMessageFields
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TSVFRWSG.js";
|
|
9
|
+
import {
|
|
10
|
+
updateSessionMessageCount
|
|
11
|
+
} from "./chunk-AANVMTYU.js";
|
|
12
12
|
import {
|
|
13
13
|
logger
|
|
14
14
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -599,6 +599,7 @@ function initEventStore(db) {
|
|
|
599
599
|
} catch {
|
|
600
600
|
}
|
|
601
601
|
resetStaleRunningSessions(eventStoreInstance, db);
|
|
602
|
+
rejectStaleConfirmations(eventStoreInstance, db);
|
|
602
603
|
const result = eventStoreInstance.optimizeStorage();
|
|
603
604
|
if (result.deletedSnapshots > 0) {
|
|
604
605
|
logger.info("Storage optimized", result);
|
|
@@ -652,6 +653,39 @@ function resetStaleRunningSessions(eventStore, db) {
|
|
|
652
653
|
logger.info("EventStore reset stale running sessions", { count: resetCount });
|
|
653
654
|
}
|
|
654
655
|
}
|
|
656
|
+
function rejectStaleConfirmations(eventStore, db) {
|
|
657
|
+
const sessions = db.prepare(`SELECT id FROM sessions`).all();
|
|
658
|
+
let rejectedCount = 0;
|
|
659
|
+
for (const { id: sessionId } of sessions) {
|
|
660
|
+
const pendingRows = db.prepare(
|
|
661
|
+
`
|
|
662
|
+
SELECT e1.seq, e1.payload FROM events e1
|
|
663
|
+
WHERE e1.session_id = ?
|
|
664
|
+
AND e1.event_type = 'path.confirmation_pending'
|
|
665
|
+
AND NOT EXISTS (
|
|
666
|
+
SELECT 1 FROM events e2
|
|
667
|
+
WHERE e2.session_id = e1.session_id
|
|
668
|
+
AND e2.event_type = 'path.confirmation_responded'
|
|
669
|
+
AND json_extract(e2.payload, '$.callId') = json_extract(e1.payload, '$.callId')
|
|
670
|
+
)
|
|
671
|
+
`
|
|
672
|
+
).all(sessionId);
|
|
673
|
+
for (const row of pendingRows) {
|
|
674
|
+
try {
|
|
675
|
+
const data = JSON.parse(row.payload);
|
|
676
|
+
eventStore.append(sessionId, {
|
|
677
|
+
type: "path.confirmation_responded",
|
|
678
|
+
data: { callId: data.callId, approved: false, alwaysAllow: false }
|
|
679
|
+
});
|
|
680
|
+
rejectedCount++;
|
|
681
|
+
} catch {
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (rejectedCount > 0) {
|
|
686
|
+
logger.info("Rejected stale path confirmations from previous server run", { count: rejectedCount });
|
|
687
|
+
}
|
|
688
|
+
}
|
|
655
689
|
function getEventStore() {
|
|
656
690
|
if (!eventStoreInstance) {
|
|
657
691
|
throw new Error("EventStore not initialized. Call initEventStore first.");
|
|
@@ -670,274 +704,6 @@ function createEvent(type, data) {
|
|
|
670
704
|
return { type, data };
|
|
671
705
|
}
|
|
672
706
|
|
|
673
|
-
// src/server/db/sessions.ts
|
|
674
|
-
function getProjectDangerLevel(projectId) {
|
|
675
|
-
try {
|
|
676
|
-
const db = getDatabase();
|
|
677
|
-
const row = db.prepare("SELECT danger_level FROM projects WHERE id = ?").get(projectId);
|
|
678
|
-
return row?.danger_level ?? "normal";
|
|
679
|
-
} catch {
|
|
680
|
-
return "normal";
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
function createSession(projectId, workdir, title, providerId, providerModel, workspace) {
|
|
684
|
-
const db = getDatabase();
|
|
685
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
686
|
-
const id = crypto.randomUUID();
|
|
687
|
-
const dangerLevel = getProjectDangerLevel(projectId);
|
|
688
|
-
db.prepare(
|
|
689
|
-
`
|
|
690
|
-
INSERT INTO sessions (id, project_id, workdir, workspace, phase, mode, workflow_phase, is_running, created_at, updated_at, title, provider_id, provider_model, danger_level)
|
|
691
|
-
VALUES (?, ?, ?, ?, 'idle', 'planner', 'plan', 0, ?, ?, ?, ?, ?, ?)
|
|
692
|
-
`
|
|
693
|
-
).run(
|
|
694
|
-
id,
|
|
695
|
-
projectId,
|
|
696
|
-
workdir,
|
|
697
|
-
workspace ?? null,
|
|
698
|
-
now,
|
|
699
|
-
now,
|
|
700
|
-
title ?? null,
|
|
701
|
-
providerId ?? null,
|
|
702
|
-
providerModel ?? null,
|
|
703
|
-
dangerLevel
|
|
704
|
-
);
|
|
705
|
-
return {
|
|
706
|
-
id,
|
|
707
|
-
projectId,
|
|
708
|
-
workdir,
|
|
709
|
-
...workspace ? { workspace } : {},
|
|
710
|
-
mode: "planner",
|
|
711
|
-
phase: "plan",
|
|
712
|
-
isRunning: false,
|
|
713
|
-
providerId: providerId ?? null,
|
|
714
|
-
providerModel: providerModel ?? null,
|
|
715
|
-
createdAt: now,
|
|
716
|
-
updatedAt: now,
|
|
717
|
-
messages: [],
|
|
718
|
-
criteria: [],
|
|
719
|
-
contextWindows: [],
|
|
720
|
-
executionState: null,
|
|
721
|
-
metadata: {
|
|
722
|
-
...title ? { title } : {},
|
|
723
|
-
totalTokensUsed: 0,
|
|
724
|
-
totalToolCalls: 0,
|
|
725
|
-
iterationCount: 0
|
|
726
|
-
},
|
|
727
|
-
metadataEntries: {},
|
|
728
|
-
dangerLevel
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
function getSession(id) {
|
|
732
|
-
const db = getDatabase();
|
|
733
|
-
const row = db.prepare(
|
|
734
|
-
`
|
|
735
|
-
SELECT * FROM sessions WHERE id = ?
|
|
736
|
-
`
|
|
737
|
-
).get(id);
|
|
738
|
-
if (!row) {
|
|
739
|
-
return null;
|
|
740
|
-
}
|
|
741
|
-
return {
|
|
742
|
-
...mapSessionBase(row),
|
|
743
|
-
messages: [],
|
|
744
|
-
criteria: [],
|
|
745
|
-
contextWindows: [],
|
|
746
|
-
executionState: null,
|
|
747
|
-
metadata: {
|
|
748
|
-
...row.title ? { title: row.title } : {},
|
|
749
|
-
totalTokensUsed: row.total_tokens_used,
|
|
750
|
-
totalToolCalls: row.total_tool_calls,
|
|
751
|
-
iterationCount: row.iteration_count
|
|
752
|
-
},
|
|
753
|
-
metadataEntries: {},
|
|
754
|
-
dangerLevel: row.danger_level ?? "normal"
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
function updateSessionProvider(id, providerId, providerModel) {
|
|
758
|
-
const db = getDatabase();
|
|
759
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
760
|
-
db.prepare(
|
|
761
|
-
`
|
|
762
|
-
UPDATE sessions SET provider_id = ?, provider_model = ?, updated_at = ? WHERE id = ?
|
|
763
|
-
`
|
|
764
|
-
).run(providerId, providerModel, now, id);
|
|
765
|
-
}
|
|
766
|
-
function updateSessionDangerLevel(id, dangerLevel) {
|
|
767
|
-
const db = getDatabase();
|
|
768
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
769
|
-
db.prepare(
|
|
770
|
-
`
|
|
771
|
-
UPDATE sessions SET danger_level = ?, updated_at = ? WHERE id = ?
|
|
772
|
-
`
|
|
773
|
-
).run(dangerLevel, now, id);
|
|
774
|
-
}
|
|
775
|
-
function updateSessionRunning(id, isRunning) {
|
|
776
|
-
const db = getDatabase();
|
|
777
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
778
|
-
db.prepare(
|
|
779
|
-
`
|
|
780
|
-
UPDATE sessions SET is_running = ?, updated_at = ? WHERE id = ?
|
|
781
|
-
`
|
|
782
|
-
).run(isRunning ? 1 : 0, now, id);
|
|
783
|
-
}
|
|
784
|
-
function updateSessionMetadata(id, metadata) {
|
|
785
|
-
const db = getDatabase();
|
|
786
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
787
|
-
const updates = ["updated_at = ?"];
|
|
788
|
-
const values = [now];
|
|
789
|
-
if (metadata.title !== void 0) {
|
|
790
|
-
updates.push("title = ?");
|
|
791
|
-
values.push(metadata.title ?? "");
|
|
792
|
-
}
|
|
793
|
-
if (metadata.totalTokensUsed !== void 0) {
|
|
794
|
-
updates.push("total_tokens_used = ?");
|
|
795
|
-
values.push(metadata.totalTokensUsed);
|
|
796
|
-
}
|
|
797
|
-
if (metadata.totalToolCalls !== void 0) {
|
|
798
|
-
updates.push("total_tool_calls = ?");
|
|
799
|
-
values.push(metadata.totalToolCalls);
|
|
800
|
-
}
|
|
801
|
-
if (metadata.iterationCount !== void 0) {
|
|
802
|
-
updates.push("iteration_count = ?");
|
|
803
|
-
values.push(metadata.iterationCount);
|
|
804
|
-
}
|
|
805
|
-
values.push(id);
|
|
806
|
-
db.prepare(
|
|
807
|
-
`
|
|
808
|
-
UPDATE sessions SET ${updates.join(", ")} WHERE id = ?
|
|
809
|
-
`
|
|
810
|
-
).run(...values);
|
|
811
|
-
}
|
|
812
|
-
function updateSessionCachedPrompt(id, systemPrompt, tools, hash) {
|
|
813
|
-
const db = getDatabase();
|
|
814
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
815
|
-
db.prepare(
|
|
816
|
-
`
|
|
817
|
-
UPDATE sessions SET cached_system_prompt = ?, cached_tools = ?, cached_hash = ?, updated_at = ? WHERE id = ?
|
|
818
|
-
`
|
|
819
|
-
).run(systemPrompt, JSON.stringify(tools), hash, now, id);
|
|
820
|
-
}
|
|
821
|
-
function getSessionCachedPrompt(id) {
|
|
822
|
-
const db = getDatabase();
|
|
823
|
-
const row = db.prepare(
|
|
824
|
-
`
|
|
825
|
-
SELECT cached_system_prompt, cached_tools, cached_hash FROM sessions WHERE id = ?
|
|
826
|
-
`
|
|
827
|
-
).get(id);
|
|
828
|
-
if (!row || !row.cached_system_prompt || !row.cached_tools || !row.cached_hash) {
|
|
829
|
-
return null;
|
|
830
|
-
}
|
|
831
|
-
try {
|
|
832
|
-
const tools = JSON.parse(row.cached_tools);
|
|
833
|
-
return { systemPrompt: row.cached_system_prompt, tools, hash: row.cached_hash };
|
|
834
|
-
} catch {
|
|
835
|
-
return null;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
function updateSessionMessageCount(id, delta) {
|
|
839
|
-
try {
|
|
840
|
-
const db = getDatabase();
|
|
841
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
842
|
-
db.prepare(
|
|
843
|
-
`
|
|
844
|
-
UPDATE sessions SET message_count = message_count + ?, updated_at = ? WHERE id = ?
|
|
845
|
-
`
|
|
846
|
-
).run(delta, now, id);
|
|
847
|
-
} catch {
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
function listSessions() {
|
|
851
|
-
const db = getDatabase();
|
|
852
|
-
const rows = db.prepare(
|
|
853
|
-
`
|
|
854
|
-
SELECT
|
|
855
|
-
s.id,
|
|
856
|
-
s.project_id,
|
|
857
|
-
s.workdir,
|
|
858
|
-
s.workspace,
|
|
859
|
-
s.mode,
|
|
860
|
-
s.workflow_phase,
|
|
861
|
-
s.is_running,
|
|
862
|
-
s.created_at,
|
|
863
|
-
s.updated_at,
|
|
864
|
-
s.title,
|
|
865
|
-
s.provider_id,
|
|
866
|
-
s.provider_model,
|
|
867
|
-
s.message_count
|
|
868
|
-
FROM sessions s
|
|
869
|
-
ORDER BY s.updated_at DESC
|
|
870
|
-
`
|
|
871
|
-
).all();
|
|
872
|
-
return rows.map(mapSessionSummaryRow);
|
|
873
|
-
}
|
|
874
|
-
function listSessionsByProject(projectId, limit = 20, offset = 0) {
|
|
875
|
-
const db = getDatabase();
|
|
876
|
-
const rows = db.prepare(
|
|
877
|
-
`
|
|
878
|
-
SELECT
|
|
879
|
-
s.id,
|
|
880
|
-
s.project_id,
|
|
881
|
-
s.workdir,
|
|
882
|
-
s.workspace,
|
|
883
|
-
s.mode,
|
|
884
|
-
s.workflow_phase,
|
|
885
|
-
s.is_running,
|
|
886
|
-
s.created_at,
|
|
887
|
-
s.updated_at,
|
|
888
|
-
s.title,
|
|
889
|
-
s.provider_id,
|
|
890
|
-
s.provider_model,
|
|
891
|
-
s.message_count
|
|
892
|
-
FROM sessions s
|
|
893
|
-
WHERE s.project_id = ?
|
|
894
|
-
ORDER BY s.updated_at DESC
|
|
895
|
-
LIMIT ? OFFSET ?
|
|
896
|
-
`
|
|
897
|
-
).all(projectId, limit + 1, offset);
|
|
898
|
-
const hasMore = rows.length > limit;
|
|
899
|
-
const sessions = rows.slice(0, limit).map(mapSessionSummaryRow);
|
|
900
|
-
return { sessions, hasMore };
|
|
901
|
-
}
|
|
902
|
-
function updateSessionWorkdir(id, workdir, workspace) {
|
|
903
|
-
const db = getDatabase();
|
|
904
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
905
|
-
db.prepare("UPDATE sessions SET workdir = ?, workspace = ?, updated_at = ? WHERE id = ?").run(
|
|
906
|
-
workdir,
|
|
907
|
-
workspace,
|
|
908
|
-
now,
|
|
909
|
-
id
|
|
910
|
-
);
|
|
911
|
-
}
|
|
912
|
-
function deleteSession(id) {
|
|
913
|
-
const db = getDatabase();
|
|
914
|
-
db.prepare("DELETE FROM sessions WHERE id = ?").run(id);
|
|
915
|
-
}
|
|
916
|
-
function mapSessionBase(row) {
|
|
917
|
-
return {
|
|
918
|
-
id: row.id,
|
|
919
|
-
projectId: row.project_id,
|
|
920
|
-
workdir: row.workdir,
|
|
921
|
-
...row.workspace ? { workspace: row.workspace } : {},
|
|
922
|
-
mode: row.mode ?? "planner",
|
|
923
|
-
phase: row.workflow_phase ?? "plan",
|
|
924
|
-
isRunning: Boolean(row.is_running),
|
|
925
|
-
providerId: row.provider_id ?? null,
|
|
926
|
-
providerModel: row.provider_model ?? null,
|
|
927
|
-
createdAt: row.created_at,
|
|
928
|
-
updatedAt: row.updated_at
|
|
929
|
-
};
|
|
930
|
-
}
|
|
931
|
-
function mapSessionSummaryRow(row) {
|
|
932
|
-
return {
|
|
933
|
-
...mapSessionBase(row),
|
|
934
|
-
...row.title ? { title: row.title } : {},
|
|
935
|
-
criteriaCount: 0,
|
|
936
|
-
criteriaCompleted: 0,
|
|
937
|
-
messageCount: row.message_count
|
|
938
|
-
};
|
|
939
|
-
}
|
|
940
|
-
|
|
941
707
|
// src/server/config.ts
|
|
942
708
|
import { z } from "zod";
|
|
943
709
|
var backendSchema = z.enum(["vllm", "sglang", "ollama", "llamacpp", "unknown"]).default("unknown");
|
|
@@ -1007,6 +773,17 @@ function getRuntimeConfig() {
|
|
|
1007
773
|
}
|
|
1008
774
|
|
|
1009
775
|
// src/server/events/session.ts
|
|
776
|
+
function combineEventsWithSnapshot(sessionId, snapshot, events) {
|
|
777
|
+
if (!snapshot) return events;
|
|
778
|
+
const snapshotEvent = {
|
|
779
|
+
seq: 0,
|
|
780
|
+
timestamp: snapshot.snapshotAt,
|
|
781
|
+
sessionId,
|
|
782
|
+
type: "turn.snapshot",
|
|
783
|
+
data: snapshot
|
|
784
|
+
};
|
|
785
|
+
return [snapshotEvent, ...events];
|
|
786
|
+
}
|
|
1010
787
|
function toSnapshotMessage(message) {
|
|
1011
788
|
return {
|
|
1012
789
|
id: message.id,
|
|
@@ -1018,8 +795,8 @@ function toSnapshotMessage(message) {
|
|
|
1018
795
|
}
|
|
1019
796
|
function getSessionState(sessionId, maxTokens) {
|
|
1020
797
|
const eventStore = getEventStore();
|
|
1021
|
-
const
|
|
1022
|
-
const events =
|
|
798
|
+
const { snapshot: latestSnapshot, events: rawEvents } = eventStore.getEventsSinceSnapshot(sessionId);
|
|
799
|
+
const events = combineEventsWithSnapshot(sessionId, latestSnapshot, rawEvents);
|
|
1023
800
|
if (events.length === 0) {
|
|
1024
801
|
return void 0;
|
|
1025
802
|
}
|
|
@@ -1058,11 +835,11 @@ function getSessionState(sessionId, maxTokens) {
|
|
|
1058
835
|
}
|
|
1059
836
|
const config = getRuntimeConfig();
|
|
1060
837
|
const effectiveMaxTokens = maxTokens ?? config.context.maxTokens;
|
|
1061
|
-
if (
|
|
838
|
+
if (latestSnapshot) {
|
|
1062
839
|
const state = foldSessionState(events, initialWindowId, effectiveMaxTokens);
|
|
1063
840
|
return {
|
|
1064
841
|
...state,
|
|
1065
|
-
messages: buildMessagesFromStoredEvents(events).map(toSnapshotMessage)
|
|
842
|
+
messages: buildMessagesFromStoredEvents(events).messages.map(toSnapshotMessage)
|
|
1066
843
|
};
|
|
1067
844
|
}
|
|
1068
845
|
return foldSessionState(events, initialWindowId, effectiveMaxTokens);
|
|
@@ -1078,7 +855,8 @@ function getContextMessages(sessionId) {
|
|
|
1078
855
|
const eventStore = getEventStore();
|
|
1079
856
|
const currentWindowId = getCurrentContextWindowId(sessionId);
|
|
1080
857
|
if (!currentWindowId) return [];
|
|
1081
|
-
const events = eventStore.
|
|
858
|
+
const { snapshot: ctxSnapshot, events: ctxRawEvents } = eventStore.getEventsSinceSnapshot(sessionId);
|
|
859
|
+
const events = combineEventsWithSnapshot(sessionId, ctxSnapshot, ctxRawEvents);
|
|
1082
860
|
if (events.length === 0) return [];
|
|
1083
861
|
return buildContextMessagesFromEventHistory(events, currentWindowId, { includeVerifier: false });
|
|
1084
862
|
}
|
|
@@ -1411,21 +1189,10 @@ export {
|
|
|
1411
1189
|
isTurnEvent,
|
|
1412
1190
|
isStoredEvent,
|
|
1413
1191
|
createEvent,
|
|
1414
|
-
createSession,
|
|
1415
|
-
getSession,
|
|
1416
|
-
updateSessionProvider,
|
|
1417
|
-
updateSessionDangerLevel,
|
|
1418
|
-
updateSessionRunning,
|
|
1419
|
-
updateSessionMetadata,
|
|
1420
|
-
updateSessionCachedPrompt,
|
|
1421
|
-
getSessionCachedPrompt,
|
|
1422
|
-
listSessions,
|
|
1423
|
-
listSessionsByProject,
|
|
1424
|
-
updateSessionWorkdir,
|
|
1425
|
-
deleteSession,
|
|
1426
1192
|
loadConfig,
|
|
1427
1193
|
setRuntimeConfig,
|
|
1428
1194
|
getRuntimeConfig,
|
|
1195
|
+
combineEventsWithSnapshot,
|
|
1429
1196
|
getSessionState,
|
|
1430
1197
|
getCurrentWindowMessages,
|
|
1431
1198
|
getContextMessages,
|
|
@@ -1460,4 +1227,4 @@ export {
|
|
|
1460
1227
|
truncateSessionMessages,
|
|
1461
1228
|
getRecentUserPromptsForSession
|
|
1462
1229
|
};
|
|
1463
|
-
//# sourceMappingURL=chunk-
|
|
1230
|
+
//# sourceMappingURL=chunk-M7EFXRDS.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AFJLY43Z.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-MTUYDBSL.js.map
|
|
@@ -37,7 +37,7 @@ Options:
|
|
|
37
37
|
}
|
|
38
38
|
async function runNetworkSetup(mode) {
|
|
39
39
|
const { loadAuthConfig, saveAuthConfig, encryptPassword } = await import("./auth-YY5PJYSC.js");
|
|
40
|
-
const { saveGlobalConfig } = await import("./config-
|
|
40
|
+
const { saveGlobalConfig } = await import("./config-MD74ETY5.js");
|
|
41
41
|
const { getAuthKeyPath } = await import("./paths-F27V3S4I.js");
|
|
42
42
|
const existingAuth = await loadAuthConfig(mode);
|
|
43
43
|
if (existingAuth) {
|
|
@@ -104,7 +104,7 @@ async function runNetworkSetup(mode) {
|
|
|
104
104
|
console.log("\u2713 Configuration saved!\n");
|
|
105
105
|
}
|
|
106
106
|
async function runConfig(mode) {
|
|
107
|
-
const { loadGlobalConfig, getActiveProvider, getDefaultModel } = await import("./config-
|
|
107
|
+
const { loadGlobalConfig, getActiveProvider, getDefaultModel } = await import("./config-MD74ETY5.js");
|
|
108
108
|
const { getGlobalConfigPath } = await import("./paths-F27V3S4I.js");
|
|
109
109
|
const config = await loadGlobalConfig(mode);
|
|
110
110
|
const configPath = getGlobalConfigPath(mode);
|
|
@@ -163,7 +163,7 @@ async function runCli(options) {
|
|
|
163
163
|
break;
|
|
164
164
|
}
|
|
165
165
|
case "provider": {
|
|
166
|
-
const { runProviderCommand } = await import("./provider-
|
|
166
|
+
const { runProviderCommand } = await import("./provider-PI3RDDE4.js");
|
|
167
167
|
const [, subcommand] = positionals;
|
|
168
168
|
await runProviderCommand(mode, subcommand);
|
|
169
169
|
break;
|
|
@@ -200,7 +200,7 @@ async function runCli(options) {
|
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
202
|
case "update": {
|
|
203
|
-
const { runUpdate } = await import("./update-
|
|
203
|
+
const { runUpdate } = await import("./update-NWZALB5M.js");
|
|
204
204
|
const code = await runUpdate();
|
|
205
205
|
if (code !== 0) {
|
|
206
206
|
process.exit(code);
|
|
@@ -208,12 +208,12 @@ async function runCli(options) {
|
|
|
208
208
|
break;
|
|
209
209
|
}
|
|
210
210
|
default: {
|
|
211
|
-
const { configFileExists } = await import("./config-
|
|
211
|
+
const { configFileExists } = await import("./config-MD74ETY5.js");
|
|
212
212
|
const configExists = await configFileExists(mode);
|
|
213
213
|
if (!configExists) {
|
|
214
214
|
await runNetworkSetup(mode);
|
|
215
215
|
}
|
|
216
|
-
const { runServe } = await import("./serve-
|
|
216
|
+
const { runServe } = await import("./serve-QWC3U5MB.js");
|
|
217
217
|
const serveOptions = { mode };
|
|
218
218
|
if (values.port) serveOptions.port = parseInt(values.port);
|
|
219
219
|
if (values["no-browser"] === true) serveOptions.openBrowser = false;
|
|
@@ -225,4 +225,4 @@ async function runCli(options) {
|
|
|
225
225
|
export {
|
|
226
226
|
runCli
|
|
227
227
|
};
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
228
|
+
//# sourceMappingURL=chunk-NUR2B4RU.js.map
|