@ashx-j/lunr-dev 0.2.16-dev.9.1 → 0.2.19-dev.10.1
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 +32 -1
- package/README.md +7 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +44 -19
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +1 -0
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-computer-use.d.ts +3 -0
- package/dist/builtin-extensions/lunr-computer-use.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-computer-use.js +157 -0
- package/dist/builtin-extensions/lunr-computer-use.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +10 -3
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts +5 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js +26 -4
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +37 -27
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +33 -8
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +52 -23
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +6 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +5 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js +38 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +3 -16
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +70 -30
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +103 -102
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/computer-use/adapter.d.ts +23 -0
- package/dist/core/computer-use/adapter.d.ts.map +1 -0
- package/dist/core/computer-use/adapter.js +116 -0
- package/dist/core/computer-use/adapter.js.map +1 -0
- package/dist/core/computer-use/lease.d.ts +18 -0
- package/dist/core/computer-use/lease.d.ts.map +1 -0
- package/dist/core/computer-use/lease.js +129 -0
- package/dist/core/computer-use/lease.js.map +1 -0
- package/dist/core/computer-use/macos-runtime.d.ts +14 -0
- package/dist/core/computer-use/macos-runtime.d.ts.map +1 -0
- package/dist/core/computer-use/macos-runtime.js +148 -0
- package/dist/core/computer-use/macos-runtime.js.map +1 -0
- package/dist/core/computer-use/policy.d.ts +19 -0
- package/dist/core/computer-use/policy.d.ts.map +1 -0
- package/dist/core/computer-use/policy.js +66 -0
- package/dist/core/computer-use/policy.js.map +1 -0
- package/dist/core/computer-use/release.generated.d.ts +31 -0
- package/dist/core/computer-use/release.generated.d.ts.map +1 -0
- package/dist/core/computer-use/release.generated.js +36 -0
- package/dist/core/computer-use/release.generated.js.map +1 -0
- package/dist/core/computer-use/runtime.d.ts +13 -0
- package/dist/core/computer-use/runtime.d.ts.map +1 -0
- package/dist/core/computer-use/runtime.js +158 -0
- package/dist/core/computer-use/runtime.js.map +1 -0
- package/dist/core/computer-use/schemas.d.ts +88 -0
- package/dist/core/computer-use/schemas.d.ts.map +1 -0
- package/dist/core/computer-use/schemas.js +80 -0
- package/dist/core/computer-use/schemas.js.map +1 -0
- package/dist/core/computer-use/windows-desktop.d.ts +3 -0
- package/dist/core/computer-use/windows-desktop.d.ts.map +1 -0
- package/dist/core/computer-use/windows-desktop.js +48 -0
- package/dist/core/computer-use/windows-desktop.js.map +1 -0
- package/dist/core/computer-use/workflow.d.ts +24 -0
- package/dist/core/computer-use/workflow.d.ts.map +1 -0
- package/dist/core/computer-use/workflow.js +330 -0
- package/dist/core/computer-use/workflow.js.map +1 -0
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-runtime.d.ts +0 -3
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +1 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permissions.d.ts +1 -1
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +23 -7
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +9 -0
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +13 -90
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/session-manager.d.ts +0 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +21 -79
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +19 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/dev-cli.js +0 -0
- package/dist/gateway/agent-bridge.d.ts +6 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +23 -6
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +23 -7
- package/dist/gateway/cron.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +23 -32
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/processes-selector.d.ts +2 -3
- package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/processes-selector.js +5 -10
- package/dist/modes/interactive/components/processes-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +18 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/thinking-level-slash.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-slash.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-slash.js +23 -0
- package/dist/modes/interactive/thinking-level-slash.js.map +1 -0
- package/dist/node-runtime/adapter-AZMY335J.js +279 -0
- package/dist/node-runtime/{agent-session-services-IFJMSX7Z.js → agent-session-services-RSGP5GDN.js} +15 -12
- package/dist/node-runtime/{builtin-extensions-LYZ3BFWQ.js → builtin-extensions-7STLFW3A.js} +4 -3
- package/dist/node-runtime/chunk-2IDTZAG5.js +1415 -0
- package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-4SJWFTUP.js} +1 -1
- package/dist/node-runtime/{chunk-AJX357CL.js → chunk-5NWQCSKR.js} +20 -1013
- package/dist/node-runtime/chunk-5OLJGVCB.js +68 -0
- package/dist/node-runtime/chunk-5Q45AVQG.js +108 -0
- package/dist/node-runtime/{chunk-TQNSPERU.js → chunk-5SQDLSZJ.js} +1 -1
- package/dist/node-runtime/{chunk-F4VQFJI2.js → chunk-6SPPH4FY.js} +4 -4
- package/dist/node-runtime/{chunk-PBC2Y6GS.js → chunk-6UB6NKA3.js} +29 -72
- package/dist/node-runtime/{chunk-A2KQXUJD.js → chunk-7AFOFSDY.js} +1 -1
- package/dist/node-runtime/chunk-BKAZ6BKX.js +2185 -0
- package/dist/node-runtime/{chunk-AHSTJBIB.js → chunk-EH2LJQPM.js} +4 -4
- package/dist/node-runtime/{chunk-N77MY65L.js → chunk-FLYMHKCS.js} +25 -25
- package/dist/node-runtime/{chunk-5P7PZMRU.js → chunk-HRS4HMDX.js} +1 -1
- package/dist/node-runtime/{chunk-IPA627GP.js → chunk-ISQDQIZN.js} +4 -4
- package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-J7QGQD45.js} +1 -1
- package/dist/node-runtime/{chunk-WOVTOV5P.js → chunk-JT6YCS5B.js} +29 -34
- package/dist/node-runtime/chunk-JZHEUQRL.js +180 -0
- package/dist/node-runtime/{chunk-ZKMFUD3Q.js → chunk-K72NVGUB.js} +3 -3
- package/dist/node-runtime/{chunk-ECD5L7YI.js → chunk-LCACDWHJ.js} +389 -15
- package/dist/node-runtime/{chunk-2QKLKMKC.js → chunk-LTXUQJI4.js} +1 -1
- package/dist/node-runtime/{chunk-MKKH27PH.js → chunk-LWJXTA6Z.js} +274 -2416
- package/dist/node-runtime/{chunk-EDBJNRSM.js → chunk-MGSB2C3M.js} +1 -1
- package/dist/node-runtime/{chunk-CDFZEWPU.js → chunk-MUMMMTW4.js} +6 -2
- package/dist/node-runtime/{chunk-YF63P5ZT.js → chunk-OTT6JMPU.js} +10 -67
- package/dist/node-runtime/{chunk-PGAJ5MO5.js → chunk-T5GM5BFH.js} +1 -1
- package/dist/node-runtime/{chunk-PCGNAY2O.js → chunk-TAP7QTUT.js} +38 -16
- package/dist/node-runtime/{chunk-4TLO4PO2.js → chunk-U6C7VTR5.js} +7 -1401
- package/dist/node-runtime/chunk-URD2SLIT.js +1019 -0
- package/dist/node-runtime/{chunk-QH42CDX3.js → chunk-W7S2REEG.js} +111 -84
- package/dist/node-runtime/{chunk-LZAW4ZX3.js → chunk-ZRDIMBEQ.js} +27 -9
- package/dist/node-runtime/{chunk-AD6VXAO7.js → chunk-ZSEZY3II.js} +5 -100
- package/dist/node-runtime/cli-runtime.js +1 -1
- package/dist/node-runtime/{command-L3LAHDIH.js → command-6UXQ6XZN.js} +1 -1
- package/dist/node-runtime/{commands-RL5YBW5I.js → commands-LGR5VT5X.js} +6 -4
- package/dist/node-runtime/{direct-tool-executor-JVDXTO7A.js → direct-tool-executor-TDJS7TBD.js} +9 -6
- package/dist/node-runtime/{export-html-KR26FOUZ.js → export-html-E4DT6ZJQ.js} +1 -1
- package/dist/node-runtime/{extract-XLQSJN4V.js → extract-IUCVZCWC.js} +2 -2
- package/dist/node-runtime/{gateway-X2TI5X7F.js → gateway-3OLC4GQN.js} +22 -367
- package/dist/node-runtime/{gemini-search-U7SUMPQA.js → gemini-search-NCIDF7NE.js} +1 -1
- package/dist/node-runtime/{gemini-url-context-PXWCBQHK.js → gemini-url-context-OKIN7AIP.js} +2 -2
- package/dist/node-runtime/image-resize-6ZPBFMWW.js +11 -0
- package/dist/node-runtime/index.js +53 -49
- package/dist/node-runtime/{init-NJV2T55N.js → init-EKE277AG.js} +6 -4
- package/dist/node-runtime/{interactive-mode-KOM35YF2.js → interactive-mode-S5M26CQ7.js} +20 -17
- package/dist/node-runtime/{interactive-view-U6OILKF3.js → interactive-view-N6F4KUIT.js} +3 -5
- package/dist/node-runtime/lunr-computer-use-4X3KUNF4.js +206 -0
- package/dist/node-runtime/{lunr-cron-YJ5UHYRD.js → lunr-cron-KKBOGAEF.js} +7 -1
- package/dist/node-runtime/main.js +24 -21
- package/dist/node-runtime/{mcp-auth-flow-QIXHW6QN.js → mcp-auth-flow-YL6RWPYG.js} +2 -1
- package/dist/node-runtime/{package-manager-cli-TZZHJCVI.js → package-manager-cli-C4EJOO5Q.js} +8 -6
- package/dist/node-runtime/{pi-mcp-adapter-QFB37AVN.js → pi-mcp-adapter-DPTJGAAL.js} +33 -27
- package/dist/node-runtime/{pi-subagents-7XJ4H53P.js → pi-subagents-VKCLYIBY.js} +103 -76
- package/dist/node-runtime/{pi-web-access-DPGAVKOA.js → pi-web-access-BV6DSZOP.js} +72 -69
- package/dist/node-runtime/{proxy-modes-HEEFK4KC.js → proxy-modes-R64LU6WZ.js} +12 -9
- package/dist/node-runtime/rpc-entry.js +24 -21
- package/dist/node-runtime/runtime-3SB5ATHQ.js +21 -0
- package/dist/node-runtime/{runtime-bridges-PPHNBFWL.js → runtime-bridges-UJ5WJJLN.js} +3 -3
- package/dist/node-runtime/{session-manager-MQNBYACL.js → session-manager-QEMZBMTM.js} +3 -5
- package/dist/node-runtime/{session-selector-5AZLJS6U.js → session-selector-URVJLOTK.js} +2 -2
- package/dist/node-runtime/{settings-manager-5LF2VQWC.js → settings-manager-K6IPIQTI.js} +3 -1
- package/dist/node-runtime/{src-Y7JSCK64.js → src-GPFAU3N6.js} +30 -10
- package/dist/node-runtime/{subagent-executor-5RNDEPIJ.js → subagent-executor-EFLTO32A.js} +39 -21
- package/dist/node-runtime/{update-cli-A253SZ7P.js → update-cli-I6OVDRPL.js} +3 -1
- package/dist/node-runtime/{video-extract-OYT5WKS5.js → video-extract-ETA5RA7U.js} +2 -2
- package/dist/node-runtime/workflow-SA34S4VX.js +325 -0
- package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-SRVGNN26.js} +2 -2
- package/dist/rpc.d.ts +3 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +18 -0
- package/dist/rpc.js.map +1 -0
- package/dist/startup/interactive-view.d.ts.map +1 -1
- package/dist/startup/interactive-view.js +1 -2
- package/dist/startup/interactive-view.js.map +1 -1
- package/docs/computer-use.md +277 -0
- package/docs/development.md +0 -32
- package/docs/features.md +2 -2
- package/docs/interactive-startup.md +10 -3
- package/docs/keybindings.md +2 -2
- package/docs/terminal-setup.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/install-lock/package-lock.json +3827 -0
- package/install-lock/package.json +18 -0
- package/native/computer-use/LICENSE.md +21 -0
- package/npm-shrinkwrap.json +3808 -0
- package/package.json +16 -10
- package/dist/startup/interactive-shell.d.ts +0 -55
- package/dist/startup/interactive-shell.d.ts.map +0 -1
- package/dist/startup/interactive-shell.js +0 -264
- package/dist/startup/interactive-shell.js.map +0 -1
- package/dist/node-runtime/{chunk-YSKSB3BJ.js → chunk-CH6OL6P2.js} +2 -2
- package/dist/node-runtime/{chunk-VSELYKWU.js → chunk-EHMBW7FA.js} +3 -3
|
@@ -9,6 +9,13 @@ import {
|
|
|
9
9
|
beginCronFire,
|
|
10
10
|
endCronFire
|
|
11
11
|
} from "./chunk-CJECDQKP.js";
|
|
12
|
+
import {
|
|
13
|
+
processImage
|
|
14
|
+
} from "./chunk-5Q45AVQG.js";
|
|
15
|
+
import {
|
|
16
|
+
createPermissionContext,
|
|
17
|
+
deletePermissionContext
|
|
18
|
+
} from "./chunk-ZRDIMBEQ.js";
|
|
12
19
|
import {
|
|
13
20
|
getAgentDir
|
|
14
21
|
} from "./chunk-PCIGF2XK.js";
|
|
@@ -1080,6 +1087,362 @@ function startScheduler(deps) {
|
|
|
1080
1087
|
};
|
|
1081
1088
|
}
|
|
1082
1089
|
|
|
1090
|
+
// packages/coding-agent/dist/gateway/store.js
|
|
1091
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1092
|
+
import { dirname, join as join2 } from "node:path";
|
|
1093
|
+
var storePathOverride;
|
|
1094
|
+
function storePath() {
|
|
1095
|
+
return storePathOverride ?? join2(getAgentDir(), "gateway-sessions.json");
|
|
1096
|
+
}
|
|
1097
|
+
function readStore() {
|
|
1098
|
+
let path = storePath();
|
|
1099
|
+
if (!existsSync2(path))
|
|
1100
|
+
return {};
|
|
1101
|
+
try {
|
|
1102
|
+
let parsed = JSON.parse(readFileSync2(path, "utf-8"));
|
|
1103
|
+
if (parsed == null || typeof parsed != "object" || Array.isArray(parsed))
|
|
1104
|
+
return {};
|
|
1105
|
+
let out = {};
|
|
1106
|
+
for (let [key, value] of Object.entries(parsed)) {
|
|
1107
|
+
if (value == null || typeof value != "object")
|
|
1108
|
+
continue;
|
|
1109
|
+
let v2 = value;
|
|
1110
|
+
typeof v2.sessionId != "string" || typeof v2.sessionFile != "string" || (out[key] = {
|
|
1111
|
+
sessionId: v2.sessionId,
|
|
1112
|
+
sessionFile: v2.sessionFile,
|
|
1113
|
+
createdAt: typeof v2.createdAt == "string" ? v2.createdAt : (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
1114
|
+
lastActiveAt: typeof v2.lastActiveAt == "string" ? v2.lastActiveAt : (/* @__PURE__ */ new Date(0)).toISOString()
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
return out;
|
|
1118
|
+
} catch {
|
|
1119
|
+
return {};
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
function writeStore(data) {
|
|
1123
|
+
let path = storePath(), dir = dirname(path);
|
|
1124
|
+
existsSync2(dir) || mkdirSync2(dir, { recursive: !0 });
|
|
1125
|
+
let tmp = `${path}.tmp-${process.pid}`;
|
|
1126
|
+
writeFileSync2(tmp, `${JSON.stringify(data, null, 2)}
|
|
1127
|
+
`, "utf-8"), renameSync2(tmp, path);
|
|
1128
|
+
}
|
|
1129
|
+
function getSession(key) {
|
|
1130
|
+
return readStore()[key];
|
|
1131
|
+
}
|
|
1132
|
+
function putSession(key, entry) {
|
|
1133
|
+
let data = readStore(), existing = data[key], stored = {
|
|
1134
|
+
sessionId: entry.sessionId,
|
|
1135
|
+
sessionFile: entry.sessionFile,
|
|
1136
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1137
|
+
lastActiveAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1138
|
+
};
|
|
1139
|
+
return data[key] = stored, writeStore(data), stored;
|
|
1140
|
+
}
|
|
1141
|
+
function touchSession(key) {
|
|
1142
|
+
let data = readStore(), existing = data[key];
|
|
1143
|
+
existing && (existing.lastActiveAt = (/* @__PURE__ */ new Date()).toISOString(), writeStore(data));
|
|
1144
|
+
}
|
|
1145
|
+
function removeSession(key) {
|
|
1146
|
+
let data = readStore();
|
|
1147
|
+
return key in data ? (delete data[key], writeStore(data), !0) : !1;
|
|
1148
|
+
}
|
|
1149
|
+
function listSessions() {
|
|
1150
|
+
return readStore();
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// packages/coding-agent/dist/gateway/agent-bridge.js
|
|
1154
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
1155
|
+
function isUserMessageEntry(entry) {
|
|
1156
|
+
return entry.type === "message";
|
|
1157
|
+
}
|
|
1158
|
+
var QUEUED = "__lunr_gateway_queued__", CACHE_CAP = 20, QUEUE_CAP = 5, runDepth = 0;
|
|
1159
|
+
async function shutdownBridgeSession(session, reason, targetSessionFile) {
|
|
1160
|
+
try {
|
|
1161
|
+
session.extensionRunner?.hasHandlers("session_shutdown") && await session.extensionRunner.emit({
|
|
1162
|
+
type: "session_shutdown",
|
|
1163
|
+
reason,
|
|
1164
|
+
...targetSessionFile ? { targetSessionFile } : {}
|
|
1165
|
+
});
|
|
1166
|
+
} catch (error) {
|
|
1167
|
+
console.error("[gateway] session shutdown handler failed", error);
|
|
1168
|
+
} finally {
|
|
1169
|
+
session.dispose?.();
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
async function defaultSessionFactory(key, reopen) {
|
|
1173
|
+
let [{ loadAllBuiltinExtensions }, { getAgentDir: getAgentDir2 }, { registerCustomizeBridge }, { registerMemoryCapBridge }, { registerModelTierBridge }, { createAgentSessionFromServices, createAgentSessionServices }, { SessionManager }, { SettingsManager }, { bindRuntimeBridges }] = await Promise.all([
|
|
1174
|
+
import("./builtin-extensions-7STLFW3A.js"),
|
|
1175
|
+
import("./config-FMEOZSWE.js"),
|
|
1176
|
+
import("./customize-XEXL2DGQ.js"),
|
|
1177
|
+
import("./memory-cap-3S4XRLNP.js"),
|
|
1178
|
+
import("./model-tiers-NJLHUEGK.js"),
|
|
1179
|
+
import("./agent-session-services-RSGP5GDN.js"),
|
|
1180
|
+
import("./session-manager-QEMZBMTM.js"),
|
|
1181
|
+
import("./settings-manager-K6IPIQTI.js"),
|
|
1182
|
+
import("./runtime-bridges-UJ5WJJLN.js")
|
|
1183
|
+
]), cwd = process.cwd(), agentDir = getAgentDir2(), settingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: !1 });
|
|
1184
|
+
registerModelTierBridge(settingsManager), registerMemoryCapBridge(settingsManager), registerCustomizeBridge(settingsManager);
|
|
1185
|
+
let sessionManager;
|
|
1186
|
+
reopen && existsSync3(reopen.sessionFile) ? sessionManager = SessionManager.open(reopen.sessionFile) : (reopen && console.warn(`[gateway] stored session file missing for ${key}; starting a fresh session`), sessionManager = SessionManager.create(cwd));
|
|
1187
|
+
let services = await createAgentSessionServices({
|
|
1188
|
+
cwd,
|
|
1189
|
+
agentDir,
|
|
1190
|
+
settingsManager,
|
|
1191
|
+
resourceLoaderOptions: { extensionFactories: await loadAllBuiltinExtensions() }
|
|
1192
|
+
}), { session } = await createAgentSessionFromServices({ services, sessionManager });
|
|
1193
|
+
return bindRuntimeBridges({ session, services }), await session.bindExtensions({
|
|
1194
|
+
mode: "print",
|
|
1195
|
+
onError: (err) => console.error(`[gateway] extension error (${err.extensionPath}): ${err.error}`)
|
|
1196
|
+
}), session;
|
|
1197
|
+
}
|
|
1198
|
+
function extractFinalText(session) {
|
|
1199
|
+
let messages = session.state.messages, last = messages[messages.length - 1];
|
|
1200
|
+
if (last?.role !== "assistant")
|
|
1201
|
+
return "";
|
|
1202
|
+
let assistant = last;
|
|
1203
|
+
if (assistant.stopReason === "error" || assistant.stopReason === "aborted")
|
|
1204
|
+
throw new Error(assistant.errorMessage || `Request ${assistant.stopReason}`);
|
|
1205
|
+
let text = "";
|
|
1206
|
+
for (let content of assistant.content)
|
|
1207
|
+
content.type === "text" && (text += content.text);
|
|
1208
|
+
return text;
|
|
1209
|
+
}
|
|
1210
|
+
var AgentBridge = class {
|
|
1211
|
+
cap;
|
|
1212
|
+
sessionFactory;
|
|
1213
|
+
cache = /* @__PURE__ */ new Map();
|
|
1214
|
+
redoStack = /* @__PURE__ */ new Map();
|
|
1215
|
+
creating = /* @__PURE__ */ new Map();
|
|
1216
|
+
constructor(options = {}) {
|
|
1217
|
+
this.cap = options.cacheCap ?? CACHE_CAP, this.sessionFactory = options.sessionFactory ?? defaultSessionFactory;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Run one conversational turn. Resolves with the final assistant text, or
|
|
1221
|
+
* the QUEUED sentinel when the session was busy (router must not reply).
|
|
1222
|
+
*/
|
|
1223
|
+
async runTurn(key, event, callbacks = {}) {
|
|
1224
|
+
let entry = await this.getOrCreate(key);
|
|
1225
|
+
if (entry.busy)
|
|
1226
|
+
return entry.queue.length >= QUEUE_CAP && (entry.queue.shift(), entry.dropped++), entry.queue.push(event), QUEUED;
|
|
1227
|
+
entry.busy = !0;
|
|
1228
|
+
let result;
|
|
1229
|
+
try {
|
|
1230
|
+
result = await this.runPrompt(entry, event.text, callbacks, event.source, event.attachments);
|
|
1231
|
+
} catch (err) {
|
|
1232
|
+
throw entry.busy = !1, err;
|
|
1233
|
+
}
|
|
1234
|
+
return touchSession(key), this.drainQueue(entry, callbacks).finally(() => {
|
|
1235
|
+
entry.busy = !1;
|
|
1236
|
+
}), result;
|
|
1237
|
+
}
|
|
1238
|
+
async abort(key) {
|
|
1239
|
+
await this.cache.get(key)?.session.abort();
|
|
1240
|
+
}
|
|
1241
|
+
/** Return the live session for a key, or null when none exists yet. */
|
|
1242
|
+
async getSession(key) {
|
|
1243
|
+
let cached = this.cache.get(key);
|
|
1244
|
+
return cached ? cached.session : getSession(key) ? (await this.getOrCreate(key)).session : null;
|
|
1245
|
+
}
|
|
1246
|
+
/** Switch the chat to a different persisted session file. */
|
|
1247
|
+
async switchSession(key, sessionFile) {
|
|
1248
|
+
let entry = this.cache.get(key);
|
|
1249
|
+
if (entry?.busy)
|
|
1250
|
+
throw new Error("Session is busy \u2014 /stop first or wait");
|
|
1251
|
+
if (entry) {
|
|
1252
|
+
let oldSessionId = entry.session.sessionManager?.getSessionId();
|
|
1253
|
+
entry.unsubscribe?.(), this.cache.delete(key), await shutdownBridgeSession(entry.session, "resume", sessionFile), oldSessionId && deletePermissionContext(oldSessionId);
|
|
1254
|
+
}
|
|
1255
|
+
removeSession(key), this.redoStack.delete(key);
|
|
1256
|
+
let session = await this.sessionFactory(key, { sessionFile }), newFile = session.sessionManager?.getSessionFile(), newSessionId = session.sessionManager?.getSessionId();
|
|
1257
|
+
newFile && putSession(key, { sessionId: newSessionId ?? key, sessionFile: newFile }), newSessionId && createPermissionContext(newSessionId);
|
|
1258
|
+
let newEntry = { session, busy: !1, queue: [], dropped: 0 };
|
|
1259
|
+
this.cache.set(key, newEntry), newEntry.unsubscribe = this._subscribeToSession(key, newEntry), await this._enforceCacheCap(key);
|
|
1260
|
+
}
|
|
1261
|
+
/** Undo the last user turn and push the previous leaf onto the redo stack. */
|
|
1262
|
+
async undo(key) {
|
|
1263
|
+
let session = await this.getSession(key);
|
|
1264
|
+
if (!session)
|
|
1265
|
+
throw new Error("No session");
|
|
1266
|
+
if (session.isStreaming)
|
|
1267
|
+
throw new Error("Wait for the current response to finish");
|
|
1268
|
+
let branch = session.sessionManager?.getBranch() ?? [], lastUserIndex = -1;
|
|
1269
|
+
for (let i = branch.length - 1; i >= 0; i--) {
|
|
1270
|
+
let entry = branch[i];
|
|
1271
|
+
if (isUserMessageEntry(entry) && entry.message.role === "user") {
|
|
1272
|
+
lastUserIndex = i;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
if (lastUserIndex === -1)
|
|
1277
|
+
throw new Error("Nothing to undo");
|
|
1278
|
+
let lastUser = branch[lastUserIndex];
|
|
1279
|
+
if (!isUserMessageEntry(lastUser))
|
|
1280
|
+
throw new Error("Nothing to undo");
|
|
1281
|
+
let leafId = session.sessionManager?.getLeafId() ?? null, targetId;
|
|
1282
|
+
if (lastUser.id === leafId) {
|
|
1283
|
+
if (!lastUser.parentId)
|
|
1284
|
+
throw new Error("Nothing to undo");
|
|
1285
|
+
targetId = lastUser.parentId;
|
|
1286
|
+
} else
|
|
1287
|
+
targetId = lastUser.id;
|
|
1288
|
+
if ((await session.navigateTree(targetId, {})).cancelled)
|
|
1289
|
+
throw new Error("Navigation cancelled");
|
|
1290
|
+
if (leafId) {
|
|
1291
|
+
let stack = this.redoStack.get(key) ?? [];
|
|
1292
|
+
stack.push(leafId), this.redoStack.set(key, stack);
|
|
1293
|
+
}
|
|
1294
|
+
return { userText: extractUserText(lastUser.message) };
|
|
1295
|
+
}
|
|
1296
|
+
/** Redo to the leaf saved by the most recent undo. */
|
|
1297
|
+
async redo(key) {
|
|
1298
|
+
let session = await this.getSession(key);
|
|
1299
|
+
if (!session)
|
|
1300
|
+
throw new Error("No session");
|
|
1301
|
+
if (session.isStreaming)
|
|
1302
|
+
throw new Error("Wait for the current response to finish");
|
|
1303
|
+
let stack = this.redoStack.get(key) ?? [], targetId = stack.pop();
|
|
1304
|
+
if (!targetId)
|
|
1305
|
+
throw new Error("Nothing to redo");
|
|
1306
|
+
if (this.redoStack.set(key, stack), (await session.navigateTree(targetId, {})).cancelled)
|
|
1307
|
+
throw stack.push(targetId), this.redoStack.set(key, stack), new Error("Navigation cancelled");
|
|
1308
|
+
}
|
|
1309
|
+
/** Test/debug hook: how many redo targets are saved for a key. */
|
|
1310
|
+
getRedoStackLength(key) {
|
|
1311
|
+
return this.redoStack.get(key)?.length ?? 0;
|
|
1312
|
+
}
|
|
1313
|
+
/** Drop the cached session (disposing it) and forget the store entry (/new, /reset). */
|
|
1314
|
+
async reset(key) {
|
|
1315
|
+
let entry = this.cache.get(key);
|
|
1316
|
+
if (entry) {
|
|
1317
|
+
entry.queue.length = 0, entry.dropped = 0;
|
|
1318
|
+
try {
|
|
1319
|
+
await entry.session.abort();
|
|
1320
|
+
} catch {
|
|
1321
|
+
}
|
|
1322
|
+
entry.unsubscribe?.(), this.cache.delete(key), await shutdownBridgeSession(entry.session, "new");
|
|
1323
|
+
}
|
|
1324
|
+
removeSession(key), this.redoStack.delete(key);
|
|
1325
|
+
}
|
|
1326
|
+
getStatus(key) {
|
|
1327
|
+
let entry = this.cache.get(key);
|
|
1328
|
+
return {
|
|
1329
|
+
busy: entry?.busy ?? !1,
|
|
1330
|
+
queueDepth: entry?.queue.length ?? 0,
|
|
1331
|
+
createdAt: getSession(key)?.createdAt
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
/** One prompt → final text. Increments runDepth; streams deltas when asked. */
|
|
1335
|
+
async runPrompt(entry, text, callbacks, source, attachments) {
|
|
1336
|
+
let { session } = entry, unsubscribe;
|
|
1337
|
+
if (callbacks.onDelta) {
|
|
1338
|
+
let onDelta = callbacks.onDelta, streamedLen = 0;
|
|
1339
|
+
unsubscribe = session.subscribe((event) => {
|
|
1340
|
+
if (event.type !== "message_update")
|
|
1341
|
+
return;
|
|
1342
|
+
let assistantEvent = event.assistantMessageEvent;
|
|
1343
|
+
if (assistantEvent.type !== "text_delta")
|
|
1344
|
+
return;
|
|
1345
|
+
let full = "";
|
|
1346
|
+
for (let content of assistantEvent.partial.content)
|
|
1347
|
+
content.type === "text" && (full += content.text);
|
|
1348
|
+
full.length < streamedLen && (streamedLen = 0), full.length > streamedLen && (onDelta(full.slice(streamedLen)), streamedLen = full.length);
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
runDepth++;
|
|
1352
|
+
try {
|
|
1353
|
+
let images = [], notes = [];
|
|
1354
|
+
for (let attachment of attachments ?? []) {
|
|
1355
|
+
let bytes = Buffer.from(attachment.data, "base64"), processed = await processImage(new Uint8Array(bytes), attachment.mimeType);
|
|
1356
|
+
if (processed.ok) {
|
|
1357
|
+
images.push({ type: "image", data: processed.data, mimeType: processed.mimeType });
|
|
1358
|
+
for (let hint of processed.hints)
|
|
1359
|
+
notes.push(hint);
|
|
1360
|
+
} else
|
|
1361
|
+
notes.push(processed.message);
|
|
1362
|
+
}
|
|
1363
|
+
let promptText = notes.length > 0 ? `${text}
|
|
1364
|
+
|
|
1365
|
+
${notes.join(" ")}` : text;
|
|
1366
|
+
await runWithOrigin({
|
|
1367
|
+
platform: source.platform,
|
|
1368
|
+
chatId: source.chatId,
|
|
1369
|
+
threadId: source.threadId,
|
|
1370
|
+
chatType: source.chatType
|
|
1371
|
+
}, () => session.prompt(promptText, { source: "extension", ...images.length ? { images } : {} }));
|
|
1372
|
+
} finally {
|
|
1373
|
+
runDepth--, unsubscribe?.();
|
|
1374
|
+
}
|
|
1375
|
+
return extractFinalText(session);
|
|
1376
|
+
}
|
|
1377
|
+
/** Drain the queue FIFO: all queued messages become one concatenated turn. */
|
|
1378
|
+
async drainQueue(entry, callbacks) {
|
|
1379
|
+
for (; entry.queue.length > 0; ) {
|
|
1380
|
+
let items = entry.queue.splice(0), parts = items.map((item) => item.text), attachments = items.flatMap((item) => item.attachments ?? []);
|
|
1381
|
+
entry.dropped > 0 && (parts.unshift(`[gateway: ${entry.dropped} earlier message(s) were dropped \u2014 the queue was full]`), entry.dropped = 0);
|
|
1382
|
+
try {
|
|
1383
|
+
let text = await this.runPrompt(entry, parts.join(`
|
|
1384
|
+
|
|
1385
|
+
`), {}, items[items.length - 1].source, attachments);
|
|
1386
|
+
callbacks.onFollowUpResult?.(text);
|
|
1387
|
+
} catch (err) {
|
|
1388
|
+
callbacks.onError?.(err instanceof Error ? err.message : String(err));
|
|
1389
|
+
return;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
async getOrCreate(key) {
|
|
1394
|
+
let cached = this.cache.get(key);
|
|
1395
|
+
if (cached)
|
|
1396
|
+
return this.cache.delete(key), this.cache.set(key, cached), cached;
|
|
1397
|
+
let pending = this.creating.get(key);
|
|
1398
|
+
if (!pending) {
|
|
1399
|
+
pending = this.createEntry(key), this.creating.set(key, pending);
|
|
1400
|
+
try {
|
|
1401
|
+
await pending;
|
|
1402
|
+
} finally {
|
|
1403
|
+
this.creating.delete(key);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
return pending;
|
|
1407
|
+
}
|
|
1408
|
+
async createEntry(key) {
|
|
1409
|
+
let stored = getSession(key), session = await this.sessionFactory(key, stored ? { sessionFile: stored.sessionFile } : void 0), sessionFile = session.sessionManager?.getSessionFile(), sessionId = session.sessionManager?.getSessionId();
|
|
1410
|
+
sessionFile && putSession(key, { sessionId: sessionId ?? key, sessionFile }), sessionId && createPermissionContext(sessionId);
|
|
1411
|
+
let entry = { session, busy: !1, queue: [], dropped: 0, unsubscribe: void 0 };
|
|
1412
|
+
return this.cache.set(key, entry), entry.unsubscribe = this._subscribeToSession(key, entry), await this._enforceCacheCap(key), entry;
|
|
1413
|
+
}
|
|
1414
|
+
async _enforceCacheCap(protectedKey) {
|
|
1415
|
+
for (; this.cache.size > this.cap; ) {
|
|
1416
|
+
let oldestKey, oldest;
|
|
1417
|
+
for (let [key, entry] of this.cache)
|
|
1418
|
+
if (key !== protectedKey && !entry.busy) {
|
|
1419
|
+
oldestKey = key, oldest = entry;
|
|
1420
|
+
break;
|
|
1421
|
+
}
|
|
1422
|
+
if (!oldest || !oldestKey) {
|
|
1423
|
+
this.cap = this.cache.size;
|
|
1424
|
+
break;
|
|
1425
|
+
}
|
|
1426
|
+
oldest.unsubscribe?.(), this.cache.delete(oldestKey), await shutdownBridgeSession(oldest.session, "quit");
|
|
1427
|
+
let evictedSessionId = oldest.session.sessionManager?.getSessionId();
|
|
1428
|
+
evictedSessionId && deletePermissionContext(evictedSessionId);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
_subscribeToSession(key, entry) {
|
|
1432
|
+
return entry.session.subscribe((event) => this._handleSessionEvent(key, event));
|
|
1433
|
+
}
|
|
1434
|
+
_handleSessionEvent(key, event) {
|
|
1435
|
+
event.type === "message_start" && event.message?.role === "user" && this.redoStack.delete(key);
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
function extractUserText(message) {
|
|
1439
|
+
let text = "";
|
|
1440
|
+
if ("content" in message && Array.isArray(message.content))
|
|
1441
|
+
for (let block of message.content)
|
|
1442
|
+
block && typeof block == "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text == "string" && (text += block.text);
|
|
1443
|
+
return text;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1083
1446
|
// packages/coding-agent/dist/gateway/text.js
|
|
1084
1447
|
function utf16Len(s2) {
|
|
1085
1448
|
return s2.length;
|
|
@@ -1158,15 +1521,15 @@ function splitMessage(text, max) {
|
|
|
1158
1521
|
var DELIVERY_BRIDGE_SYMBOL = /* @__PURE__ */ Symbol.for("@lunr/cron-delivery"), KNOWN_PLATFORMS = ["telegram", "discord"];
|
|
1159
1522
|
async function defaultCronSessionFactory(job, modelOverride) {
|
|
1160
1523
|
let [{ loadAllBuiltinExtensions }, { getAgentDir: getAgentDir2 }, { registerCustomizeBridge }, { registerMemoryCapBridge }, { registerModelTierBridge }, { createAgentSessionFromServices, createAgentSessionServices }, { SessionManager }, { SettingsManager }, { bindRuntimeBridges }] = await Promise.all([
|
|
1161
|
-
import("./builtin-extensions-
|
|
1524
|
+
import("./builtin-extensions-7STLFW3A.js"),
|
|
1162
1525
|
import("./config-FMEOZSWE.js"),
|
|
1163
1526
|
import("./customize-XEXL2DGQ.js"),
|
|
1164
1527
|
import("./memory-cap-3S4XRLNP.js"),
|
|
1165
1528
|
import("./model-tiers-NJLHUEGK.js"),
|
|
1166
|
-
import("./agent-session-services-
|
|
1167
|
-
import("./session-manager-
|
|
1168
|
-
import("./settings-manager-
|
|
1169
|
-
import("./runtime-bridges-
|
|
1529
|
+
import("./agent-session-services-RSGP5GDN.js"),
|
|
1530
|
+
import("./session-manager-QEMZBMTM.js"),
|
|
1531
|
+
import("./settings-manager-K6IPIQTI.js"),
|
|
1532
|
+
import("./runtime-bridges-UJ5WJJLN.js")
|
|
1170
1533
|
]), cwd = job.workdir ?? process.cwd(), agentDir = getAgentDir2(), settingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: !1 });
|
|
1171
1534
|
registerModelTierBridge(settingsManager), registerMemoryCapBridge(settingsManager), registerCustomizeBridge(settingsManager);
|
|
1172
1535
|
let sessionManager = SessionManager.inMemory(cwd), services = await createAgentSessionServices({
|
|
@@ -1183,13 +1546,22 @@ async function defaultCronSessionFactory(job, modelOverride) {
|
|
|
1183
1546
|
throw new Error(`no configured auth for provider: ${modelOverride.provider}`);
|
|
1184
1547
|
model = resolved;
|
|
1185
1548
|
}
|
|
1186
|
-
let { session } = await createAgentSessionFromServices({ services, sessionManager, model });
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1549
|
+
let { session } = await createAgentSessionFromServices({ services, sessionManager, model }), permissionId = sessionManager.getSessionId();
|
|
1550
|
+
createPermissionContext(permissionId, settingsManager.getDefaultPermissionMode(), !1);
|
|
1551
|
+
let dispose = session.dispose.bind(session);
|
|
1552
|
+
session.dispose = () => {
|
|
1553
|
+
deletePermissionContext(permissionId), dispose();
|
|
1554
|
+
};
|
|
1555
|
+
try {
|
|
1556
|
+
return bindRuntimeBridges({ session, services }), await session.bindExtensions({
|
|
1557
|
+
mode: "print",
|
|
1558
|
+
onError: (err) => console.error(`[gateway cron] extension error (${err.extensionPath}): ${err.error}`)
|
|
1559
|
+
}), session;
|
|
1560
|
+
} catch (error) {
|
|
1561
|
+
throw await shutdownBridgeSession(session, "quit"), error;
|
|
1562
|
+
}
|
|
1191
1563
|
}
|
|
1192
|
-
function
|
|
1564
|
+
function extractFinalText2(session) {
|
|
1193
1565
|
let messages = session.state.messages, last = messages[messages.length - 1];
|
|
1194
1566
|
if (last?.role !== "assistant")
|
|
1195
1567
|
return "";
|
|
@@ -1299,7 +1671,7 @@ async function readCronFallbackModels() {
|
|
|
1299
1671
|
try {
|
|
1300
1672
|
let [{ getAgentDir: getAgentDir2 }, { SettingsManager }] = await Promise.all([
|
|
1301
1673
|
import("./config-FMEOZSWE.js"),
|
|
1302
|
-
import("./settings-manager-
|
|
1674
|
+
import("./settings-manager-K6IPIQTI.js")
|
|
1303
1675
|
]), settingsManager = SettingsManager.create(process.cwd(), getAgentDir2(), { projectTrusted: !1 }), out = [];
|
|
1304
1676
|
for (let entry of settingsManager.getCronFallbackModels()) {
|
|
1305
1677
|
let idx = entry.indexOf("/");
|
|
@@ -1325,13 +1697,13 @@ function startGatewayCron(options) {
|
|
|
1325
1697
|
let label = candidate ? `${candidate.provider}/${candidate.modelId}` : "default model", session;
|
|
1326
1698
|
try {
|
|
1327
1699
|
session = await sessionFactory(job, candidate), globalThis[DELIVERY_BRIDGE_SYMBOL] = platformDeliverer, await withAttemptTimeout(session.prompt(prompt, { source: "extension" }), attemptTimeoutMs);
|
|
1328
|
-
let text =
|
|
1700
|
+
let text = extractFinalText2(session);
|
|
1329
1701
|
return candidate ? `[fell back to ${label}]
|
|
1330
1702
|
${text}` : text;
|
|
1331
1703
|
} catch (err) {
|
|
1332
1704
|
errors.push(`${label}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1333
1705
|
} finally {
|
|
1334
|
-
session
|
|
1706
|
+
session && await shutdownBridgeSession(session, "quit");
|
|
1335
1707
|
}
|
|
1336
1708
|
}
|
|
1337
1709
|
throw new Error(errors.join(" | ") || "no model candidates");
|
|
@@ -1359,10 +1731,12 @@ export {
|
|
|
1359
1731
|
pauseJob,
|
|
1360
1732
|
resumeJob,
|
|
1361
1733
|
removeJob,
|
|
1362
|
-
runWithOrigin,
|
|
1363
1734
|
currentOrigin,
|
|
1364
1735
|
executeJob,
|
|
1365
1736
|
startScheduler,
|
|
1737
|
+
listSessions,
|
|
1738
|
+
QUEUED,
|
|
1739
|
+
AgentBridge,
|
|
1366
1740
|
splitMessage,
|
|
1367
1741
|
createDeliverValidator,
|
|
1368
1742
|
startGatewayCron
|