openfox 2.0.129 → 2.0.131
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 +44 -0
- package/README.md +2 -0
- package/dist/CHANGELOG.md +44 -0
- package/dist/auth-D3WLIBTG.js +19 -0
- package/dist/{auto-config-454YE6KC.js → auto-config-5VSNLVNI.js} +6 -5
- package/dist/{backend-4YPEC3J2.js → backend-NDBY3DAQ.js} +4 -2
- package/dist/{chat-handler-TH6JBO6G.js → chat-handler-RAIMQU7F.js} +35 -35
- package/dist/{chunk-ISE55FOR.js → chunk-2AI7VYPN.js} +11 -1
- package/dist/{chunk-HO7A7TMF.js → chunk-55DGZIZ6.js} +15 -5
- package/dist/{chunk-L24A6GZ7.js → chunk-5AI3LHRQ.js} +85 -57
- package/dist/{chunk-ZFNBATE3.js → chunk-6EZDW4JS.js} +3 -2
- package/dist/{chunk-ZXWJ6JTL.js → chunk-6MUSEPV7.js} +1197 -225
- package/dist/{chunk-OHTBWA7L.js → chunk-6SUBBT2M.js} +13 -13
- package/dist/{chunk-6LX43YRA.js → chunk-7ET46SNE.js} +4 -4
- package/dist/{chunk-GIJUWPRQ.js → chunk-7JVBDBXE.js} +2 -2
- package/dist/{chunk-MYNNMV75.js → chunk-7LGMQ5KS.js} +54 -36
- package/dist/{chunk-ZIL6VKLU.js → chunk-BKMWZTNO.js} +3 -3
- package/dist/chunk-BMBOSVRM.js +7 -0
- package/dist/{auth-GTGIGX5X.js → chunk-CQGJ5RWB.js} +4 -4
- package/dist/{chunk-3B232XG4.js → chunk-DPFET73G.js} +2 -2
- package/dist/chunk-DQTN4B33.js +235 -0
- package/dist/{chunk-KBESUA3W.js → chunk-ELYHHEYL.js} +3 -3
- package/dist/{chunk-DABWCAXS.js → chunk-EUOWCVU6.js} +19 -6
- package/dist/{chunk-YJD5A375.js → chunk-FGNJMKDV.js} +5 -5
- package/dist/{chunk-ATWOXI52.js → chunk-HCYSGLY2.js} +1 -1
- package/dist/{chunk-OYBUJIC3.js → chunk-JU757HVI.js} +5 -1
- package/dist/{chunk-AQBRI7TM.js → chunk-KWAHD2JA.js} +13 -8
- package/dist/{chunk-N2Q3KYWM.js → chunk-LQKXJPKP.js} +8 -3
- package/dist/{chunk-EHFIUXWZ.js → chunk-LW6MMSTD.js} +2 -2
- package/dist/{chunk-ZIYETXOW.js → chunk-M5T4RDPJ.js} +4 -4
- package/dist/{chunk-66MG44TF.js → chunk-MGEYAYGU.js} +2 -2
- package/dist/{chunk-RV5G7QQU.js → chunk-MQMPIXON.js} +3 -3
- package/dist/{chunk-K2QKX4ZJ.js → chunk-OA2FURC3.js} +8 -2
- package/dist/{chunk-567L5OJ6.js → chunk-P57IBMK4.js} +2 -2
- package/dist/{chunk-P6GTPKE5.js → chunk-QJG5K3X2.js} +278 -16
- package/dist/{chunk-2COZT3YI.js → chunk-RQPHGBWI.js} +24 -24
- package/dist/chunk-SVALN5KE.js +394 -0
- package/dist/{session-status-6Q5B5PEN.js → chunk-T3S5MTMD.js} +2 -3
- package/dist/{chunk-7YP4O4XE.js → chunk-TACWRDDC.js} +3 -3
- package/dist/{chunk-7ZMOP5LS.js → chunk-TS5WKTFB.js} +18 -1
- package/dist/{chunk-PBFGJFGC.js → chunk-UV6IH6HK.js} +32 -10
- package/dist/{chunk-7RIEI2TE.js → chunk-WCM5ZW5N.js} +52 -17
- package/dist/{chunk-Y3BSBKHY.js → chunk-XE6UC5Z3.js} +2 -2
- package/dist/{chunk-26WS7AH6.js → chunk-Y6ZGHOKM.js} +39 -7
- package/dist/chunk-YNMP647F.js +24 -0
- package/dist/{chunk-H6YIVK67.js → chunk-ZCFQOC3C.js} +26 -6
- package/dist/{chunk-IJFKJ5D6.js → chunk-ZL4IAFF3.js} +4 -4
- package/dist/{chunk-JQMQ4DGC.js → chunk-ZVHUISW7.js} +76 -32
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/client-E6QLHPHD.js +16 -0
- package/dist/{client-pure-GU2SV3DD.js → client-pure-FLKP6PTI.js} +2 -2
- package/dist/compactor-OEJAA2YP.js +32 -0
- package/dist/dynamic-context-Y555VDLA.js +52 -0
- package/dist/{events-GMHRX4LF.js → events-ZJPRGVL2.js} +9 -9
- package/dist/{folding-7K2GRPF4.js → folding-QRZOHY2I.js} +7 -7
- package/dist/http-client-P4XTKAZA.js +11 -0
- package/dist/{inspect-proxy-UKPU3Z64.js → inspect-proxy-A3OROWPG.js} +4 -4
- package/dist/launch-Y4H7FDU2.js +53 -0
- package/dist/{manager-NOKJQTTF.js → manager-TMBFBCQL.js} +5 -5
- package/dist/mcp-YU7AM3UV.js +120 -0
- package/dist/{model-catalog-ZLOWTQA7.js → model-catalog-2PCKTYGW.js} +2 -2
- package/dist/{oauth-provider-DGBC2YM6.js → oauth-provider-VHUS2KEG.js} +8 -2
- package/dist/orchestrator-SQN2SJ2A.js +64 -0
- package/dist/package.json +1 -1
- package/dist/{path-security-UDZ7UVWK.js → path-security-CBACXAMS.js} +13 -13
- package/dist/{platform-EMKWQTZX.js → platform-5LQXOZO3.js} +4 -4
- package/dist/plugins-registry.json +12 -0
- package/dist/{processor-7RDR675X.js → processor-MEHODYNE.js} +34 -34
- package/dist/{profiles-HXGJIPF2.js → profiles-EBCVFYG7.js} +2 -2
- package/dist/{project-creator-JF3YVQAH.js → project-creator-6AGQTNXB.js} +3 -3
- package/dist/{projects-TPSLCJP2.js → projects-5U37RUTL.js} +3 -3
- package/dist/{protocol-DMneA8mx.d.ts → protocol-BMUoqwYH.d.ts} +2 -1
- package/dist/{protocol-TS3GVTT3.js → protocol-Y7MRKRUO.js} +3 -3
- package/dist/provider/index.d.ts +4 -4
- package/dist/{provider-DXEICEIE.js → provider-6YRII4IV.js} +11 -11
- package/dist/{provider-manager-PU7RS2TK.js → provider-manager-URNJBK5Q.js} +11 -11
- package/dist/{registry-Z4GVYFTV.js → registry-CMSSZHDC.js} +5 -5
- package/dist/{serve-Z5ITDPCQ.js → serve-NPADSJG7.js} +45 -43
- package/dist/server/index.d.ts +28 -4
- package/dist/server/index.js +42 -40
- package/dist/server-5TY22HDN.js +56 -0
- package/dist/service-VPXGREXF.js +27 -0
- package/dist/{session-overrides-4WAD3X5Q.js → session-overrides-OECQYRDK.js} +7 -7
- package/dist/session-status-UFO5IFI7.js +10 -0
- package/dist/{sessions-D7VRCHQY.js → sessions-NMPX5ICI.js} +6 -6
- package/dist/{settings-VOWWO4VG.js → settings-MDCRNQBY.js} +3 -3
- package/dist/shared/index.d.ts +3 -3
- package/dist/shared/index.js +1 -1
- package/dist/skill-defaults/browser/SKILL.md +20 -1
- package/dist/{tasks-SE3DOPVP.js → tasks-MNPXK2S5.js} +14 -14
- package/dist/{tools-6XUSIJN2.js → tools-6BDT5YMT.js} +37 -37
- package/dist/{types-PAKlAzp9.d.ts → types-BIkpxjaj.d.ts} +11 -2
- package/dist/{types-BWuVnaBw.d.ts → types-CoY8Ka1C.d.ts} +1 -1
- package/dist/{update-EJUI6PSV.js → update-XKCOBE47.js} +2 -2
- package/dist/web/assets/{index-CGKd7WLQ.js → index-Bx5r3aJx.js} +88 -88
- package/dist/web/assets/{index-CbX8veVW.css → index-Y300llHY.css} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/dist/{workspace-6CUE26YA.js → workspace-LM646OHC.js} +4 -4
- package/package.json +1 -1
- package/plugins-registry.json +12 -0
- package/dist/chunk-HIRDDCPD.js +0 -7
- package/dist/chunk-PHP7PLFX.js +0 -151
- package/dist/chunk-RSB4AR2A.js +0 -108
- package/dist/client-RZGGDGUA.js +0 -16
- package/dist/compactor-WKFNTUXL.js +0 -32
- package/dist/dynamic-context-ZVE733UI.js +0 -28
- package/dist/http-client-ROVNSHF6.js +0 -11
- package/dist/launch-5ARSU7EM.js +0 -53
- package/dist/orchestrator-E6GIZGEN.js +0 -64
- package/dist/server-MUJ7EHEI.js +0 -56
- package/dist/service-INQWTYY2.js +0 -27
|
@@ -209,6 +209,10 @@ function runMigrations(db2) {
|
|
|
209
209
|
logger.info("Migrating sessions table: adding cached_hash column");
|
|
210
210
|
db2.exec(`ALTER TABLE sessions ADD COLUMN cached_hash TEXT`);
|
|
211
211
|
}
|
|
212
|
+
if (!columnNames.includes("cached_prompt_hash")) {
|
|
213
|
+
logger.info("Migrating sessions table: adding cached_prompt_hash column");
|
|
214
|
+
db2.exec(`ALTER TABLE sessions ADD COLUMN cached_prompt_hash TEXT`);
|
|
215
|
+
}
|
|
212
216
|
if (!columnNames.includes("workspace") && columnNames.includes("worktree")) {
|
|
213
217
|
logger.info("Migrating sessions table: renaming worktree to workspace");
|
|
214
218
|
db2.exec(`ALTER TABLE sessions RENAME COLUMN worktree TO workspace`);
|
|
@@ -340,4 +344,4 @@ export {
|
|
|
340
344
|
initDatabase,
|
|
341
345
|
getDatabase
|
|
342
346
|
};
|
|
343
|
-
//# sourceMappingURL=chunk-
|
|
347
|
+
//# sourceMappingURL=chunk-JU757HVI.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDefaultAgentId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ELYHHEYL.js";
|
|
4
4
|
import {
|
|
5
5
|
getDatabase
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JU757HVI.js";
|
|
7
7
|
|
|
8
8
|
// src/server/db/sessions.ts
|
|
9
9
|
function getProjectDangerLevel(projectId) {
|
|
@@ -197,20 +197,20 @@ function updateSessionMcpDisabledServers(id, disabledServers) {
|
|
|
197
197
|
const value = disabledServers.length > 0 ? JSON.stringify(disabledServers) : null;
|
|
198
198
|
db.prepare(`UPDATE sessions SET mcp_disabled_servers = ? WHERE id = ?`).run(value, id);
|
|
199
199
|
}
|
|
200
|
-
function updateSessionCachedPrompt(id, systemPrompt, tools, hash) {
|
|
200
|
+
function updateSessionCachedPrompt(id, systemPrompt, tools, hash, promptHash) {
|
|
201
201
|
const db = getDatabase();
|
|
202
202
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
203
203
|
db.prepare(
|
|
204
204
|
`
|
|
205
|
-
UPDATE sessions SET cached_system_prompt = ?, cached_tools = ?, cached_hash = ?, updated_at = ? WHERE id = ?
|
|
205
|
+
UPDATE sessions SET cached_system_prompt = ?, cached_tools = ?, cached_hash = ?, cached_prompt_hash = ?, updated_at = ? WHERE id = ?
|
|
206
206
|
`
|
|
207
|
-
).run(systemPrompt, JSON.stringify(tools), hash, now, id);
|
|
207
|
+
).run(systemPrompt, JSON.stringify(tools), hash, promptHash ?? null, now, id);
|
|
208
208
|
}
|
|
209
209
|
function getSessionCachedPrompt(id) {
|
|
210
210
|
const db = getDatabase();
|
|
211
211
|
const row = db.prepare(
|
|
212
212
|
`
|
|
213
|
-
SELECT cached_system_prompt, cached_tools, cached_hash FROM sessions WHERE id = ?
|
|
213
|
+
SELECT cached_system_prompt, cached_tools, cached_hash, cached_prompt_hash FROM sessions WHERE id = ?
|
|
214
214
|
`
|
|
215
215
|
).get(id);
|
|
216
216
|
if (!row || !row.cached_system_prompt || !row.cached_tools || !row.cached_hash) {
|
|
@@ -218,7 +218,12 @@ function getSessionCachedPrompt(id) {
|
|
|
218
218
|
}
|
|
219
219
|
try {
|
|
220
220
|
const tools = JSON.parse(row.cached_tools);
|
|
221
|
-
return {
|
|
221
|
+
return {
|
|
222
|
+
systemPrompt: row.cached_system_prompt,
|
|
223
|
+
tools,
|
|
224
|
+
hash: row.cached_hash,
|
|
225
|
+
...row.cached_prompt_hash ? { promptHash: row.cached_prompt_hash } : {}
|
|
226
|
+
};
|
|
222
227
|
} catch {
|
|
223
228
|
return null;
|
|
224
229
|
}
|
|
@@ -466,4 +471,4 @@ export {
|
|
|
466
471
|
getLatestWorkflowExecution,
|
|
467
472
|
clearWorkflowExecution
|
|
468
473
|
};
|
|
469
|
-
//# sourceMappingURL=chunk-
|
|
474
|
+
//# sourceMappingURL=chunk-KWAHD2JA.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDatabase
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JU757HVI.js";
|
|
4
4
|
|
|
5
5
|
// src/server/db/settings.ts
|
|
6
6
|
var SETTINGS_KEYS = {
|
|
@@ -119,7 +119,12 @@ function getAllSettings() {
|
|
|
119
119
|
}
|
|
120
120
|
function getMaxVisibleItems() {
|
|
121
121
|
const setting = getSetting(SETTINGS_KEYS.DISPLAY_MAX_VISIBLE_ITEMS);
|
|
122
|
-
|
|
122
|
+
const defaultValue = Number(SETTINGS_DEFAULTS[SETTINGS_KEYS.DISPLAY_MAX_VISIBLE_ITEMS]);
|
|
123
|
+
if (setting === null || setting.trim() === "") {
|
|
124
|
+
return defaultValue;
|
|
125
|
+
}
|
|
126
|
+
const value = Number(setting);
|
|
127
|
+
return Number.isInteger(value) && value >= 0 ? value : defaultValue;
|
|
123
128
|
}
|
|
124
129
|
|
|
125
130
|
export {
|
|
@@ -131,4 +136,4 @@ export {
|
|
|
131
136
|
getAllSettings,
|
|
132
137
|
getMaxVisibleItems
|
|
133
138
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-LQKXJPKP.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectByWorkdir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DPFET73G.js";
|
|
4
4
|
import {
|
|
5
5
|
logger
|
|
6
6
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -345,4 +345,4 @@ export {
|
|
|
345
345
|
startInspectProxy,
|
|
346
346
|
stopAllInspectProxies
|
|
347
347
|
};
|
|
348
|
-
//# sourceMappingURL=chunk-
|
|
348
|
+
//# sourceMappingURL=chunk-LW6MMSTD.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveDefaultAgentId
|
|
3
|
+
} from "./chunk-ELYHHEYL.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeAskOptions
|
|
3
6
|
} from "./chunk-LCLH6ZUL.js";
|
|
4
|
-
import {
|
|
5
|
-
resolveDefaultAgentId
|
|
6
|
-
} from "./chunk-KBESUA3W.js";
|
|
7
7
|
|
|
8
8
|
// src/server/events/apply-events.ts
|
|
9
9
|
function markComplete(msg, reason) {
|
|
@@ -965,4 +965,4 @@ export {
|
|
|
965
965
|
buildSnapshot,
|
|
966
966
|
buildSnapshotFromSessionState
|
|
967
967
|
};
|
|
968
|
-
//# sourceMappingURL=chunk-
|
|
968
|
+
//# sourceMappingURL=chunk-M5T4RDPJ.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SETTINGS_KEYS,
|
|
3
3
|
getSetting
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LQKXJPKP.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-MGEYAYGU.js.map
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
} from "./chunk-I72ACQ6R.js";
|
|
12
12
|
import {
|
|
13
13
|
getPlatformShell
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MGEYAYGU.js";
|
|
15
15
|
import {
|
|
16
16
|
SETTINGS_KEYS,
|
|
17
17
|
getSetting
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LQKXJPKP.js";
|
|
19
19
|
|
|
20
20
|
// src/server/utils/shell.ts
|
|
21
21
|
import { spawn } from "child_process";
|
|
@@ -214,4 +214,4 @@ export {
|
|
|
214
214
|
getSessionProcesses2 as getSessionProcesses,
|
|
215
215
|
getProcessLogs
|
|
216
216
|
};
|
|
217
|
-
//# sourceMappingURL=chunk-
|
|
217
|
+
//# sourceMappingURL=chunk-MQMPIXON.js.map
|
|
@@ -24,8 +24,14 @@ function findLmStudioModel(raw, modelId) {
|
|
|
24
24
|
return parseLmStudioModels(raw).find((model) => model.id === modelId);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// src/server/providers/vision.ts
|
|
28
|
+
function hasVisionEvidence(modelInfo) {
|
|
29
|
+
return !!modelInfo["vision_start_token_id"] || Object.keys(modelInfo).some((k) => k.includes(".vision") || k.includes("vision_"));
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
export {
|
|
28
33
|
parseLmStudioModels,
|
|
29
|
-
findLmStudioModel
|
|
34
|
+
findLmStudioModel,
|
|
35
|
+
hasVisionEvidence
|
|
30
36
|
};
|
|
31
|
-
//# sourceMappingURL=chunk-
|
|
37
|
+
//# sourceMappingURL=chunk-OA2FURC3.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
createServerMessage,
|
|
6
6
|
isClientMessage
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HCYSGLY2.js";
|
|
8
8
|
|
|
9
9
|
// src/server/session/client-session.ts
|
|
10
10
|
function toClientSession(session) {
|
|
@@ -378,4 +378,4 @@ export {
|
|
|
378
378
|
createQueueStateMessage,
|
|
379
379
|
storedEventToServerMessage
|
|
380
380
|
};
|
|
381
|
-
//# sourceMappingURL=chunk-
|
|
381
|
+
//# sourceMappingURL=chunk-P57IBMK4.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getModelProfile
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TS5WKTFB.js";
|
|
4
4
|
import {
|
|
5
5
|
getBackendCapabilities
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UV6IH6HK.js";
|
|
7
7
|
import {
|
|
8
8
|
ensureVersionPrefix,
|
|
9
9
|
stripVersionPrefix
|
|
@@ -14,16 +14,267 @@ import {
|
|
|
14
14
|
getThinking,
|
|
15
15
|
mapFinishReason,
|
|
16
16
|
parseToolArguments
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-EUOWCVU6.js";
|
|
18
18
|
import {
|
|
19
19
|
ChatHttpClient,
|
|
20
|
+
DONE,
|
|
20
21
|
LLMError,
|
|
21
22
|
OpenAIHttpClient
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6EZDW4JS.js";
|
|
23
24
|
import {
|
|
24
25
|
logger
|
|
25
26
|
} from "./chunk-K44MW7JJ.js";
|
|
26
27
|
|
|
28
|
+
// src/server/llm/responses-routing.ts
|
|
29
|
+
var OPENCODE_GO_RESPONSES_RULES = [
|
|
30
|
+
{
|
|
31
|
+
pattern: /^(gpt-5\.6-luna|grok-4\.6|muse-spark-1\.2-contributor)$/i,
|
|
32
|
+
protocol: "responses"
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
function basename(modelId) {
|
|
36
|
+
return modelId.split("/").pop() ?? modelId;
|
|
37
|
+
}
|
|
38
|
+
function matchesRules(modelId, rules) {
|
|
39
|
+
const name = basename(modelId);
|
|
40
|
+
for (const rule of rules) {
|
|
41
|
+
if (rule.pattern.test(modelId) || rule.pattern.test(name)) return rule.protocol;
|
|
42
|
+
}
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function resolveApiProtocol(input) {
|
|
46
|
+
const { model, backend, profileApiProtocol, explicitApiProtocol } = input;
|
|
47
|
+
if (explicitApiProtocol) return explicitApiProtocol;
|
|
48
|
+
if (backend === "openai" && profileApiProtocol) return profileApiProtocol;
|
|
49
|
+
if (backend === "opencode-go") {
|
|
50
|
+
const matched = matchesRules(model, OPENCODE_GO_RESPONSES_RULES);
|
|
51
|
+
if (matched) return matched;
|
|
52
|
+
}
|
|
53
|
+
return "chat-completions";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/server/llm/responses-native.ts
|
|
57
|
+
function messageToInputItem(message) {
|
|
58
|
+
if (message.role === "system" || message.role === "developer") return null;
|
|
59
|
+
if (message.role === "tool") {
|
|
60
|
+
return { type: "function_call_output", call_id: message.tool_call_id ?? "", output: message.content ?? "" };
|
|
61
|
+
}
|
|
62
|
+
if (message.role === "assistant" && message.tool_calls?.length) {
|
|
63
|
+
const items = [];
|
|
64
|
+
if (message.content) items.push({ role: "assistant", content: message.content });
|
|
65
|
+
for (const toolCall of message.tool_calls) {
|
|
66
|
+
items.push({
|
|
67
|
+
type: "function_call",
|
|
68
|
+
call_id: toolCall.id,
|
|
69
|
+
name: toolCall.function.name,
|
|
70
|
+
arguments: toolCall.function.arguments
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return items.length === 1 ? items[0] : { __multi: items };
|
|
74
|
+
}
|
|
75
|
+
return { role: message.role, content: message.content ?? "" };
|
|
76
|
+
}
|
|
77
|
+
function flattenInput(items) {
|
|
78
|
+
return items.flatMap(
|
|
79
|
+
(item) => item["__multi"] !== void 0 ? item["__multi"] : [item]
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function convertTools(tools) {
|
|
83
|
+
return tools.map((tool) => ({
|
|
84
|
+
type: "function",
|
|
85
|
+
name: tool.function.name,
|
|
86
|
+
description: tool.function.description,
|
|
87
|
+
parameters: tool.function.parameters
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
function buildResponsesRequest(params) {
|
|
91
|
+
const systemMessages = params.messages.filter((m) => m.role === "system" || m.role === "developer");
|
|
92
|
+
const instructions = systemMessages.map((m) => typeof m.content === "string" ? m.content : "").join("\n\n");
|
|
93
|
+
const body = {
|
|
94
|
+
model: params.model,
|
|
95
|
+
input: flattenInput(
|
|
96
|
+
params.messages.map(messageToInputItem).filter((item) => item !== null)
|
|
97
|
+
),
|
|
98
|
+
stream: Boolean(params.stream),
|
|
99
|
+
store: false
|
|
100
|
+
};
|
|
101
|
+
if (instructions) body.instructions = instructions;
|
|
102
|
+
if (params.tools?.length) body.tools = convertTools(params.tools);
|
|
103
|
+
if (params.tool_choice !== void 0) {
|
|
104
|
+
const choice = params.tool_choice;
|
|
105
|
+
body.tool_choice = choice === "auto" || choice === "none" ? choice : "auto";
|
|
106
|
+
}
|
|
107
|
+
const maxTokens = params.max_tokens ?? params.max_completion_tokens;
|
|
108
|
+
if (maxTokens !== void 0) body.max_output_tokens = maxTokens;
|
|
109
|
+
const effort = params.reasoning_effort;
|
|
110
|
+
if (effort && effort !== "none") {
|
|
111
|
+
body.reasoning = { effort };
|
|
112
|
+
}
|
|
113
|
+
return body;
|
|
114
|
+
}
|
|
115
|
+
function mapResponseStatus(status, incompleteReason) {
|
|
116
|
+
switch (status) {
|
|
117
|
+
case "incomplete":
|
|
118
|
+
return incompleteReason === "max_output_tokens" ? "length" : "stop";
|
|
119
|
+
case "failed":
|
|
120
|
+
case "cancelled":
|
|
121
|
+
return "content_filter";
|
|
122
|
+
default:
|
|
123
|
+
return "stop";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function parseResponsesResponse(data) {
|
|
127
|
+
let content = "";
|
|
128
|
+
let reasoning = "";
|
|
129
|
+
const toolCalls = [];
|
|
130
|
+
for (const item of data.output ?? []) {
|
|
131
|
+
if (item.type === "message") {
|
|
132
|
+
for (const block of item.content ?? []) {
|
|
133
|
+
if (block.type === "output_text" && block.text) content += block.text;
|
|
134
|
+
}
|
|
135
|
+
} else if (item.type === "reasoning") {
|
|
136
|
+
for (const block of item.summary ?? []) {
|
|
137
|
+
if (block.text) reasoning += block.text;
|
|
138
|
+
}
|
|
139
|
+
} else if (item.type === "function_call") {
|
|
140
|
+
toolCalls.push({
|
|
141
|
+
id: item.call_id ?? item.id ?? `call_${toolCalls.length}`,
|
|
142
|
+
type: "function",
|
|
143
|
+
function: { name: item.name ?? "", arguments: item.arguments ?? "{}" }
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const promptTokens = data.usage?.input_tokens ?? 0;
|
|
148
|
+
const completionTokens = data.usage?.output_tokens ?? 0;
|
|
149
|
+
const message = { content };
|
|
150
|
+
if (reasoning) message["reasoning_content"] = reasoning;
|
|
151
|
+
if (toolCalls.length > 0) message["tool_calls"] = toolCalls;
|
|
152
|
+
return {
|
|
153
|
+
id: data.id ?? `resp_${Date.now()}`,
|
|
154
|
+
choices: [
|
|
155
|
+
{
|
|
156
|
+
finish_reason: toolCalls.length > 0 ? "tool_calls" : mapResponseStatus(data.status, data.incomplete_details?.reason),
|
|
157
|
+
message
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
usage: {
|
|
161
|
+
prompt_tokens: promptTokens,
|
|
162
|
+
completion_tokens: completionTokens,
|
|
163
|
+
total_tokens: data.usage?.total_tokens ?? promptTokens + completionTokens
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function parseResponsesEvent(event) {
|
|
168
|
+
const type = event["type"];
|
|
169
|
+
const responseId = typeof event["response_id"] === "string" ? event["response_id"] : "resp";
|
|
170
|
+
switch (type) {
|
|
171
|
+
case "response.output_text.delta":
|
|
172
|
+
return chunk(responseId, { content: String(event["delta"] ?? "") });
|
|
173
|
+
case "response.reasoning_summary_text.delta":
|
|
174
|
+
return chunk(responseId, { reasoning_content: String(event["delta"] ?? "") });
|
|
175
|
+
case "response.reasoning_text.delta":
|
|
176
|
+
return chunk(responseId, { reasoning_content: String(event["delta"] ?? "") });
|
|
177
|
+
case "response.output_item.added": {
|
|
178
|
+
const item = event["item"];
|
|
179
|
+
if (item?.type === "function_call") {
|
|
180
|
+
const callId = item.call_id ?? item.id;
|
|
181
|
+
const toolCall = {
|
|
182
|
+
index: 0,
|
|
183
|
+
...callId ? { id: callId } : {},
|
|
184
|
+
function: { name: item.name ?? "", arguments: item.arguments ?? "" }
|
|
185
|
+
};
|
|
186
|
+
return chunk(responseId, { tool_calls: [toolCall] });
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
case "response.function_call_arguments.delta": {
|
|
191
|
+
const toolCall = { index: 0, function: { arguments: String(event["delta"] ?? "") } };
|
|
192
|
+
return chunk(responseId, { tool_calls: [toolCall] });
|
|
193
|
+
}
|
|
194
|
+
case "response.output_text.done":
|
|
195
|
+
case "response.reasoning_summary_text.done":
|
|
196
|
+
case "response.reasoning_text.done":
|
|
197
|
+
case "response.function_call_arguments.done":
|
|
198
|
+
case "response.output_item.done":
|
|
199
|
+
case "response.content_part.added":
|
|
200
|
+
case "response.content_part.done":
|
|
201
|
+
return null;
|
|
202
|
+
case "response.completed": {
|
|
203
|
+
const response = event["response"];
|
|
204
|
+
return finalChunk(responseId, response);
|
|
205
|
+
}
|
|
206
|
+
case "response.failed": {
|
|
207
|
+
const response = event["response"];
|
|
208
|
+
const message = response?.error?.message ?? "Responses API request failed";
|
|
209
|
+
logger.warn("Responses API stream failed", { message });
|
|
210
|
+
return finalChunk(responseId, response);
|
|
211
|
+
}
|
|
212
|
+
case "error": {
|
|
213
|
+
const message = event["message"] ?? "Responses API stream error";
|
|
214
|
+
logger.warn("Responses API stream error event", { message });
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
default:
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function chunk(id, delta) {
|
|
222
|
+
return { id, choices: [{ delta, finish_reason: null }] };
|
|
223
|
+
}
|
|
224
|
+
function finalChunk(id, response) {
|
|
225
|
+
const usage = response?.usage;
|
|
226
|
+
const c = {
|
|
227
|
+
id,
|
|
228
|
+
choices: [
|
|
229
|
+
{
|
|
230
|
+
delta: {},
|
|
231
|
+
finish_reason: mapResponseStatus(response?.status, response?.incomplete_details?.reason)
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
};
|
|
235
|
+
if (usage) {
|
|
236
|
+
c.usage = {
|
|
237
|
+
prompt_tokens: usage.input_tokens ?? 0,
|
|
238
|
+
completion_tokens: usage.output_tokens ?? 0,
|
|
239
|
+
total_tokens: usage.total_tokens ?? (usage.input_tokens ?? 0) + (usage.output_tokens ?? 0)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return c;
|
|
243
|
+
}
|
|
244
|
+
var OpenAIResponsesHttpClient = class extends ChatHttpClient {
|
|
245
|
+
baseURL;
|
|
246
|
+
apiKey;
|
|
247
|
+
constructor(options) {
|
|
248
|
+
super();
|
|
249
|
+
this.baseURL = options.baseURL;
|
|
250
|
+
this.apiKey = options.apiKey;
|
|
251
|
+
}
|
|
252
|
+
buildRequest(params) {
|
|
253
|
+
return {
|
|
254
|
+
url: `${this.baseURL}/responses`,
|
|
255
|
+
headers: {
|
|
256
|
+
"Content-Type": "application/json",
|
|
257
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
258
|
+
},
|
|
259
|
+
body: JSON.stringify(buildResponsesRequest(params))
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
parseNonStreaming(data) {
|
|
263
|
+
return parseResponsesResponse(data);
|
|
264
|
+
}
|
|
265
|
+
parseStreamLine(trimmed) {
|
|
266
|
+
if (!trimmed.startsWith("data: ")) return null;
|
|
267
|
+
const data = trimmed.slice(6);
|
|
268
|
+
if (data === "[DONE]") return DONE;
|
|
269
|
+
try {
|
|
270
|
+
return parseResponsesEvent(JSON.parse(data));
|
|
271
|
+
} catch (error) {
|
|
272
|
+
logger.warn("Failed to parse Responses SSE event", { data, error });
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
27
278
|
// src/server/llm/ollama-native.ts
|
|
28
279
|
function mapDoneReason(reason) {
|
|
29
280
|
switch (reason) {
|
|
@@ -233,7 +484,15 @@ function createLLMClient(config, initialBackend = config.llm.backend ?? "unknown
|
|
|
233
484
|
const ollamaHttpClient = new OllamaHttpClient({
|
|
234
485
|
baseURL: stripVersionPrefix(baseURL)
|
|
235
486
|
});
|
|
236
|
-
const
|
|
487
|
+
const responsesHttpClient = new OpenAIResponsesHttpClient({
|
|
488
|
+
baseURL,
|
|
489
|
+
apiKey: config.llm.apiKey ?? "not-needed"
|
|
490
|
+
});
|
|
491
|
+
const httpFor = (b) => {
|
|
492
|
+
if (b === "ollama") return ollamaHttpClient;
|
|
493
|
+
if (currentApiProtocol() === "responses") return responsesHttpClient;
|
|
494
|
+
return httpClient;
|
|
495
|
+
};
|
|
237
496
|
let model = config.llm.model;
|
|
238
497
|
let profile = getModelProfile(model);
|
|
239
498
|
let backend = initialBackend;
|
|
@@ -242,17 +501,20 @@ function createLLMClient(config, initialBackend = config.llm.backend ?? "unknown
|
|
|
242
501
|
const thinkingField = config.llm.thinkingField;
|
|
243
502
|
const sendReasoningInMessages = config.llm.sendReasoningInMessages;
|
|
244
503
|
const idleTimeout = config.llm.idleTimeout ?? 12e4;
|
|
504
|
+
const currentApiProtocol = () => resolveApiProtocol({ model, backend, profileApiProtocol: profile.apiProtocol });
|
|
245
505
|
function buildExtraParams(resolvedEffort) {
|
|
246
506
|
return {
|
|
247
507
|
...resolvedEffort ? { reasoningEffort: resolvedEffort } : {},
|
|
248
508
|
...thinkingField ? { thinkingField } : {},
|
|
249
|
-
...sendReasoningInMessages !== void 0 ? { sendReasoningInMessages } : {}
|
|
509
|
+
...sendReasoningInMessages !== void 0 ? { sendReasoningInMessages } : {},
|
|
510
|
+
apiProtocol: currentApiProtocol()
|
|
250
511
|
};
|
|
251
512
|
}
|
|
252
513
|
return {
|
|
253
514
|
getModel() {
|
|
254
515
|
return model;
|
|
255
516
|
},
|
|
517
|
+
usesResponsesApi: () => currentApiProtocol() === "responses",
|
|
256
518
|
getProfile() {
|
|
257
519
|
return profile;
|
|
258
520
|
},
|
|
@@ -381,25 +643,25 @@ function createLLMClient(config, initialBackend = config.llm.backend ?? "unknown
|
|
|
381
643
|
const onAbort = () => clearInterval(idleTimer);
|
|
382
644
|
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
383
645
|
try {
|
|
384
|
-
for await (const
|
|
646
|
+
for await (const chunk2 of stream) {
|
|
385
647
|
if (idleTimeoutController.signal.aborted) {
|
|
386
648
|
throw new Error(`LLM stream idle timeout: no chunks received for ${idleTimeout}ms`);
|
|
387
649
|
}
|
|
388
650
|
lastChunkTime = Date.now();
|
|
389
|
-
if (!Array.isArray(
|
|
390
|
-
const streamError =
|
|
651
|
+
if (!Array.isArray(chunk2?.choices)) {
|
|
652
|
+
const streamError = chunk2?.error;
|
|
391
653
|
const errorMessage = typeof streamError === "string" ? streamError : streamError && typeof streamError === "object" && "message" in streamError && typeof streamError.message === "string" ? streamError.message : "Invalid LLM stream chunk: missing choices";
|
|
392
654
|
throw new LLMError(errorMessage);
|
|
393
655
|
}
|
|
394
|
-
responseId =
|
|
395
|
-
if (
|
|
656
|
+
responseId = chunk2.id;
|
|
657
|
+
if (chunk2.usage) {
|
|
396
658
|
usage = {
|
|
397
|
-
promptTokens:
|
|
398
|
-
completionTokens:
|
|
399
|
-
totalTokens:
|
|
659
|
+
promptTokens: chunk2.usage.prompt_tokens ?? usage.promptTokens,
|
|
660
|
+
completionTokens: chunk2.usage.completion_tokens ?? usage.completionTokens,
|
|
661
|
+
totalTokens: chunk2.usage.total_tokens ?? usage.totalTokens
|
|
400
662
|
};
|
|
401
663
|
}
|
|
402
|
-
const choice =
|
|
664
|
+
const choice = chunk2.choices[0];
|
|
403
665
|
if (!choice) continue;
|
|
404
666
|
if (choice.finish_reason) {
|
|
405
667
|
finishReason = mapFinishReason(choice.finish_reason);
|
|
@@ -506,4 +768,4 @@ function createLLMClient(config, initialBackend = config.llm.backend ?? "unknown
|
|
|
506
768
|
export {
|
|
507
769
|
createLLMClient
|
|
508
770
|
};
|
|
509
|
-
//# sourceMappingURL=chunk-
|
|
771
|
+
//# sourceMappingURL=chunk-QJG5K3X2.js.map
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runAgentTurn
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WCM5ZW5N.js";
|
|
4
4
|
import {
|
|
5
5
|
executeSubAgent,
|
|
6
6
|
getToolRegistryForAgent
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
TurnMetrics,
|
|
10
|
-
createMessageStartEvent
|
|
11
|
-
} from "./chunk-6LX43YRA.js";
|
|
12
|
-
import {
|
|
13
|
-
checkAborted,
|
|
14
|
-
decodeUtf8,
|
|
15
|
-
spawnShellProcess
|
|
16
|
-
} from "./chunk-RV5G7QQU.js";
|
|
17
|
-
import {
|
|
18
|
-
terminateProcessTree
|
|
19
|
-
} from "./chunk-I72ACQ6R.js";
|
|
7
|
+
} from "./chunk-5AI3LHRQ.js";
|
|
20
8
|
import {
|
|
21
9
|
gitSpawnEnv
|
|
22
10
|
} from "./chunk-J7GAZGZT.js";
|
|
@@ -27,24 +15,36 @@ import {
|
|
|
27
15
|
loadProjectWorkflows,
|
|
28
16
|
loadUserWorkflows,
|
|
29
17
|
normalizeWorkflowScope
|
|
30
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-ZCFQOC3C.js";
|
|
19
|
+
import {
|
|
20
|
+
TurnMetrics,
|
|
21
|
+
createMessageStartEvent
|
|
22
|
+
} from "./chunk-7ET46SNE.js";
|
|
23
|
+
import {
|
|
24
|
+
checkAborted,
|
|
25
|
+
decodeUtf8,
|
|
26
|
+
spawnShellProcess
|
|
27
|
+
} from "./chunk-MQMPIXON.js";
|
|
28
|
+
import {
|
|
29
|
+
terminateProcessTree
|
|
30
|
+
} from "./chunk-I72ACQ6R.js";
|
|
31
31
|
import {
|
|
32
32
|
getCurrentContextWindowId,
|
|
33
33
|
getEventStore
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import {
|
|
36
|
-
createChatMessageMessage,
|
|
37
|
-
createSessionRunningMessage
|
|
38
|
-
} from "./chunk-567L5OJ6.js";
|
|
34
|
+
} from "./chunk-FGNJMKDV.js";
|
|
39
35
|
import {
|
|
40
36
|
findAgentById,
|
|
41
37
|
getRuntimeConfig,
|
|
42
38
|
loadAllAgentsDefault,
|
|
43
39
|
resolveDefaultAgentId
|
|
44
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-ELYHHEYL.js";
|
|
41
|
+
import {
|
|
42
|
+
createChatMessageMessage,
|
|
43
|
+
createSessionRunningMessage
|
|
44
|
+
} from "./chunk-P57IBMK4.js";
|
|
45
45
|
import {
|
|
46
46
|
LLMError
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-6EZDW4JS.js";
|
|
48
48
|
import {
|
|
49
49
|
logger
|
|
50
50
|
} from "./chunk-K44MW7JJ.js";
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
} from "./chunk-7OHXF5GW.js";
|
|
54
54
|
import {
|
|
55
55
|
createServerMessage
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-HCYSGLY2.js";
|
|
57
57
|
import {
|
|
58
58
|
getGlobalConfigDir
|
|
59
59
|
} from "./chunk-CQGTEGKL.js";
|
|
@@ -1002,4 +1002,4 @@ export {
|
|
|
1002
1002
|
abortRunnerRun,
|
|
1003
1003
|
launchWorkflowRun
|
|
1004
1004
|
};
|
|
1005
|
-
//# sourceMappingURL=chunk-
|
|
1005
|
+
//# sourceMappingURL=chunk-RQPHGBWI.js.map
|