nolo-cli 0.12.0-alpha.1 → 0.12.0-alpha.10
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/{_executeModel-MWAY74HA.js → _executeModel-4F7VZR5U.js} +24 -23
- package/{action-RAXNQQKC.js → action-OTOWUMPW.js} +3 -3
- package/{addContentAction-ZHI7TVV3.js → addContentAction-JGBUVR7K.js} +2 -2
- package/{addDialogAgentAction-JWXPKXNC.js → addDialogAgentAction-V6CL2UCF.js} +1 -1
- package/{agentDeleteCommand-LXR5A5FV.js → agentDeleteCommand-MMRSG6AB.js} +15 -14
- package/{agentEmailCommands-DXRAP7BB.js → agentEmailCommands-YFVKOGM7.js} +28 -27
- package/{agentListCommands-ZFMS5ZLY.js → agentListCommands-2PZHIQ3I.js} +16 -15
- package/{agentMachineCommands-ZJLYVV52.js → agentMachineCommands-55UUZNHF.js} +17 -16
- package/{agentRecordCommands-DFS626TB.js → agentRecordCommands-BTP3OAPL.js} +28 -27
- package/{agentRunCommand-GWBIE2TS.js → agentRunCommand-AA4QLRQZ.js} +29 -28
- package/{agentRuntimeLocal-YNZSHMZC.js → agentRuntimeLocal-QDJCBXM2.js} +12 -11
- package/{agentSlice-T2PXOEPQ.js → agentSlice-6JAJOU3X.js} +2 -2
- package/{chunk-G3B356GF.js → chunk-2BVGERJ2.js} +67 -3
- package/{chunk-WWU275LU.js → chunk-3MI5LDDU.js} +2 -2
- package/{chunk-OPZYGHUC.js → chunk-3WGLLTK4.js} +59 -1
- package/{chunk-EBH7G34M.js → chunk-3XF6LCCN.js} +2 -2
- package/chunk-5MMAK75Q.js +15 -0
- package/{chunk-ZR4VHQ5D.js → chunk-5S4SWV5G.js} +38 -26
- package/{chunk-JUN3HFMN.js → chunk-5V524MHX.js} +25 -15
- package/{chunk-JZDIW766.js → chunk-ARSC56DC.js} +1 -1
- package/{chunk-3QKO4EHV.js → chunk-AS3ZQ3O2.js} +16 -25
- package/{chunk-43UD5ZP7.js → chunk-B4KT7RN2.js} +4 -4
- package/{chunk-YTQLJYLB.js → chunk-C3BFP57W.js} +95 -2
- package/{chunk-QCA3EPYK.js → chunk-CGDQDXKZ.js} +1 -1
- package/{chunk-7MYHLZ3F.js → chunk-DPFWKRHG.js} +1 -1
- package/{chunk-LHSJMY5V.js → chunk-EIMX5ER5.js} +3 -3
- package/{chunk-AM53Q2SD.js → chunk-FSUZIGIG.js} +28 -39
- package/{chunk-4GBNEA5B.js → chunk-H5Y2H2N6.js} +1 -1
- package/{chunk-S73OEOHH.js → chunk-JFANOO7I.js} +3 -15
- package/{chunk-OCDEWRE2.js → chunk-JKWWVF2I.js} +1 -1
- package/{chunk-WTYKCU4W.js → chunk-JU7J7EAV.js} +37 -37
- package/{chunk-5ITRDSHY.js → chunk-KWBH4RAL.js} +57 -18
- package/{chunk-6OVCRC72.js → chunk-LUKQQJFL.js} +39 -2
- package/{chunk-DRMGJFGQ.js → chunk-MG6BVV3T.js} +31 -17
- package/{chunk-RSEUHW6T.js → chunk-MQRZ5QUH.js} +1 -1
- package/{chunk-RZ735TLX.js → chunk-MZHSAPZP.js} +167 -20
- package/{chunk-OPKKB25T.js → chunk-O4FOPRCP.js} +1 -1
- package/{chunk-S3UTETIC.js → chunk-OGGHETUE.js} +19 -4
- package/{chunk-4EH7AR52.js → chunk-OPM2DE2J.js} +1 -1
- package/{chunk-UG3WOFU6.js → chunk-QJSTNKJY.js} +1 -1
- package/{chunk-DE5BA4O6.js → chunk-QUHUVG6Y.js} +2 -2
- package/{chunk-YDCZVUFP.js → chunk-RQSOAMPJ.js} +16 -0
- package/{chunk-ZPFRLGIZ.js → chunk-RUGEW4P7.js} +70 -37
- package/{chunk-6LMFFG3K.js → chunk-RWO5DGXI.js} +2 -2
- package/{chunk-4BTHUYMY.js → chunk-TA7VKOHU.js} +23 -9
- package/{chunk-MEVCDATU.js → chunk-TQYYGE6G.js} +3 -3
- package/{chunk-TSKWE74T.js → chunk-TYPHUVK5.js} +13 -1
- package/{chunk-RNQ5BLR2.js → chunk-VBSWHE5W.js} +1 -1
- package/{chunk-NITP2JDG.js → chunk-VKG4HXYV.js} +1 -1
- package/{chunk-3HHTVM6G.js → chunk-WVTBAALN.js} +1 -1
- package/{chunk-GPZM7QH6.js → chunk-Y5P3ZRGC.js} +4 -4
- package/{chunk-GDBCUWQ3.js → chunk-YUMYYXPI.js} +31 -167
- package/{createAgentAutomationAction-G32GKDGV.js → createAgentAutomationAction-4NY4JLOK.js} +9 -8
- package/{createDialogAction-TISANRZK.js → createDialogAction-I5WUWFJ6.js} +10 -9
- package/{createPageAction-O7KOYNV4.js → createPageAction-HFTIQ7TW.js} +9 -8
- package/{dbSlice-WDP2ZZHK.js → dbSlice-J4PUZ6Y5.js} +1 -1
- package/{dialogCommands-6JPB3YQY.js → dialogCommands-SVXRJFZS.js} +16 -15
- package/{dialogSlice-PRHHYSP5.js → dialogSlice-35LA3ZRG.js} +9 -8
- package/{docCreateCommands-75E6TZNN.js → docCreateCommands-Z7RIAYKQ.js} +15 -14
- package/{docDeleteCommands-EJHLN7LW.js → docDeleteCommands-NEYHUVZF.js} +16 -15
- package/{docReadCommands-RJYBC4FS.js → docReadCommands-I4US2SDE.js} +15 -14
- package/{docStore-H5VWKT5D.js → docStore-3CP2IO6M.js} +10 -9
- package/{docUpdateCommands-MG4CNISV.js → docUpdateCommands-UU5HQBRP.js} +15 -14
- package/{getPricing-6TOZXPAU.js → getPricing-UGDJHI7M.js} +2 -2
- package/{handleSendMessageAction-QTUGICSZ.js → handleSendMessageAction-FWTLQGOZ.js} +9 -8
- package/index.js +36 -36
- package/{machineCommands-MAV7M3TK.js → machineCommands-STHZKBDJ.js} +28 -27
- package/{machineWsRunDispatch-ZOEGTKHC.js → machineWsRunDispatch-7YHT4TPT.js} +27 -26
- package/package.json +1 -1
- package/{readlineWorkspace-SWQKC7ZS.js → readlineWorkspace-OMRWYMB6.js} +203 -75
- package/{removeDialogAgentAction-GTX5AN54.js → removeDialogAgentAction-XUZYQBV4.js} +3 -3
- package/{runAgentClientLoop-P25HACXX.js → runAgentClientLoop-FP2K33ZO.js} +20 -19
- package/{setDialogExtraReferencesAction-WFQ63KYO.js → setDialogExtraReferencesAction-PTAIFKGM.js} +1 -1
- package/{setPrimaryDialogAgentAction-P57FXTSU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +3 -3
- package/{settingSlice-CK5YZGNI.js → settingSlice-VGRJUSE5.js} +2 -2
- package/{skillDiscovery-ZYHSX7VD.js → skillDiscovery-6M2BZUFN.js} +1 -1
- package/{spaceCommands-6O5EFEM5.js → spaceCommands-GN73BCOB.js} +15 -14
- package/{spaceSlice-4EXTYXS4.js → spaceSlice-WTFNKOVA.js} +11 -8
- package/{streamAgentChatTurn-Q3FJAHG2.js → streamAgentChatTurn-HBAQQVNK.js} +244 -26
- package/{tools-AHNQE4GP.js → tools-TPQYTLQZ.js} +15 -14
- package/{tuiSummaryLlmCaller-TXLF4MEI.js → tuiSummaryLlmCaller-XDC7WG4K.js} +6 -4
- package/{updateDialogTitleAction-XZDVLKVX.js → updateDialogTitleAction-AWXNPUQJ.js} +9 -8
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
buildLocalAgentLookupKeys,
|
|
13
13
|
normalizeAgentHandle,
|
|
14
14
|
shouldReadAgentKeyRemotely
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VBSWHE5W.js";
|
|
16
16
|
import {
|
|
17
17
|
LOCAL_CODEX_AGENT_ID,
|
|
18
18
|
LOCAL_CODEX_AGENT_KEY,
|
|
@@ -21,19 +21,20 @@ import {
|
|
|
21
21
|
} from "./chunk-VHBWHNVT.js";
|
|
22
22
|
import {
|
|
23
23
|
inferCaptureIntent
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-QJSTNKJY.js";
|
|
25
25
|
import {
|
|
26
26
|
buildCliPrompt
|
|
27
27
|
} from "./chunk-ATNTHIZI.js";
|
|
28
28
|
import {
|
|
29
|
+
inlineImageUrlsForCustomProvider,
|
|
29
30
|
prepareTools
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-C3BFP57W.js";
|
|
31
32
|
import {
|
|
32
33
|
getAntigravityUserAgent,
|
|
33
34
|
isAntigravityOAuthAgent,
|
|
34
35
|
readAntigravityProjectId,
|
|
35
36
|
resolveAntigravityCloudCodeBaseUrl
|
|
36
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-H5Y2H2N6.js";
|
|
37
38
|
import {
|
|
38
39
|
FORCED_TOOLS,
|
|
39
40
|
addDefaultLightWebToolsForConfiguredAgents,
|
|
@@ -49,24 +50,25 @@ import {
|
|
|
49
50
|
readXPostFunctionSchema,
|
|
50
51
|
readXhsProfileFunc,
|
|
51
52
|
readXhsProfileFunctionSchema
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-MZHSAPZP.js";
|
|
53
54
|
import {
|
|
54
|
-
|
|
55
|
+
createDrainExhaustedResponse,
|
|
56
|
+
isCoreDrainingBody,
|
|
55
57
|
normalizeNonNegativeMs,
|
|
56
58
|
parseRetryAfterHeaderMs
|
|
57
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-RQSOAMPJ.js";
|
|
58
60
|
import {
|
|
59
61
|
normalizeDialogTitle
|
|
60
62
|
} from "./chunk-OWOHNGCN.js";
|
|
61
63
|
import {
|
|
62
64
|
prepareTokenUsageData
|
|
63
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-FSUZIGIG.js";
|
|
64
66
|
import {
|
|
65
67
|
BUILTIN_TITLE_LLM_CONFIG
|
|
66
68
|
} from "./chunk-V2J635L5.js";
|
|
67
69
|
import {
|
|
68
70
|
fetchServerSyncedCredential
|
|
69
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-Y5P3ZRGC.js";
|
|
70
72
|
import {
|
|
71
73
|
buildAgentRuntimeDialogWritePlan,
|
|
72
74
|
buildLocalWorkspaceOpenAiTools,
|
|
@@ -79,7 +81,7 @@ import {
|
|
|
79
81
|
parseSseDataLineJson,
|
|
80
82
|
readOpenAiCompatibleSseCompletion,
|
|
81
83
|
resolveOpenAiCompatibleProviderConfig
|
|
82
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-MG6BVV3T.js";
|
|
83
85
|
import {
|
|
84
86
|
buildPlatformChatCompletionRequest,
|
|
85
87
|
canUsePlatformChatProvider,
|
|
@@ -89,14 +91,14 @@ import {
|
|
|
89
91
|
resolveLegacyDeepSeekProxyChatFallback,
|
|
90
92
|
resolvePlatformChatProviderConfig,
|
|
91
93
|
shouldUsePlatformChatProvider
|
|
92
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-5S4SWV5G.js";
|
|
93
95
|
import {
|
|
94
96
|
resolveAgentRuntimeConfigFromRecord
|
|
95
97
|
} from "./chunk-NCGFB7NN.js";
|
|
96
98
|
import {
|
|
97
99
|
parseToolArgumentsJson,
|
|
98
100
|
summarizeToolArguments
|
|
99
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-TA7VKOHU.js";
|
|
100
102
|
import {
|
|
101
103
|
buildLoadSkillExecutor,
|
|
102
104
|
buildNoloWorkspaceCliToolExecutors,
|
|
@@ -104,10 +106,10 @@ import {
|
|
|
104
106
|
canonicalizeToolNames,
|
|
105
107
|
parseNoloWorkspaceToolArguments,
|
|
106
108
|
resolveRuntimeToolSurfaceForAgent
|
|
107
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-B4KT7RN2.js";
|
|
108
110
|
import {
|
|
109
111
|
clipCompactText
|
|
110
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-5MMAK75Q.js";
|
|
111
113
|
import {
|
|
112
114
|
createFileCredentialBroker,
|
|
113
115
|
resolveCurrentRunRuntimeToolPolicy,
|
|
@@ -718,6 +720,14 @@ var STRINGS = {
|
|
|
718
720
|
en: "Current dialog: new (nothing to compact yet)",
|
|
719
721
|
zh: "\u5F53\u524D\u5BF9\u8BDD\u8FD8\u662F\u65B0\u7684\uFF08\u8FD8\u6CA1\u6709\u53EF\u538B\u7F29\u7684\u5185\u5BB9\uFF09"
|
|
720
722
|
},
|
|
723
|
+
compactDone: {
|
|
724
|
+
en: "Compacted dialog {0} \u2192 {1}.",
|
|
725
|
+
zh: "\u5DF2\u538B\u7F29\u5BF9\u8BDD {0} \u2192 {1}\u3002"
|
|
726
|
+
},
|
|
727
|
+
compactDoneNoSummary: {
|
|
728
|
+
en: "Forked dialog {0} \u2192 {1} (no summary needed).",
|
|
729
|
+
zh: "\u5DF2\u5206\u53C9\u5BF9\u8BDD {0} \u2192 {1}\uFF08\u65E0\u9700\u538B\u7F29\uFF09\u3002"
|
|
730
|
+
},
|
|
721
731
|
agentCurrent: { en: "Current agent: {0} ({1})", zh: "\u5F53\u524D agent\uFF1A{0}\uFF08{1}\uFF09" },
|
|
722
732
|
agentUnknown: {
|
|
723
733
|
en: `I don't know agent "{0}" yet.
|
|
@@ -761,8 +771,8 @@ Use /switch, /switch list, /switch minimax-m3, or a full agent key.`,
|
|
|
761
771
|
zh: "\u5DF2\u6302\u8F7D\u6280\u80FD\uFF1A{0}\n\u7528\u6CD5\uFF1A/skill attach <ref> | /skill detach <ref> | /skill clear"
|
|
762
772
|
},
|
|
763
773
|
skillNoneHint: {
|
|
764
|
-
en: "No skills attached. Use /skill attach <skill-ref> to attach a skill.\nSkill refs can be a dbKey (page-xxx), a skill name (searched in .agents/skills/
|
|
765
|
-
zh: "\u8FD8\u6CA1\u6709\u6302\u8F7D\u6280\u80FD\u3002\u7528 /skill attach <skill-ref> \u6302\u8F7D\u6280\u80FD\u3002\n\u6280\u80FD\u5F15\u7528\u53EF\u4EE5\u662F dbKey\uFF08page-xxx\uFF09\u3001\u6280\u80FD\u540D\uFF08\u4F1A\u5728 .agents/skills/ \
|
|
774
|
+
en: "No skills attached. Use /skill attach <skill-ref> to attach a skill.\nSkill refs can be a dbKey (page-xxx), a skill name (searched in .agents/skills/), or a direct path.",
|
|
775
|
+
zh: "\u8FD8\u6CA1\u6709\u6302\u8F7D\u6280\u80FD\u3002\u7528 /skill attach <skill-ref> \u6302\u8F7D\u6280\u80FD\u3002\n\u6280\u80FD\u5F15\u7528\u53EF\u4EE5\u662F dbKey\uFF08page-xxx\uFF09\u3001\u6280\u80FD\u540D\uFF08\u4F1A\u5728 .agents/skills/ \u4E2D\u67E5\u627E\uFF09\u6216\u76F4\u63A5\u8DEF\u5F84\u3002"
|
|
766
776
|
},
|
|
767
777
|
customizeHint: {
|
|
768
778
|
en: "Tell nolo what to change, for example: /customize make my default agent more concise.",
|
|
@@ -1015,7 +1025,7 @@ async function isCoreDrainingResponse(response) {
|
|
|
1015
1025
|
if (response.status !== 503) return false;
|
|
1016
1026
|
try {
|
|
1017
1027
|
const body = await response.clone().json();
|
|
1018
|
-
return body
|
|
1028
|
+
return isCoreDrainingBody(body);
|
|
1019
1029
|
} catch {
|
|
1020
1030
|
return false;
|
|
1021
1031
|
}
|
|
@@ -1042,6 +1052,9 @@ async function fetchWithTransientRetry(fetchImpl, input, init, options = {}) {
|
|
|
1042
1052
|
await (options.sleep ?? defaultSleep)(delayMs);
|
|
1043
1053
|
continue;
|
|
1044
1054
|
}
|
|
1055
|
+
if (coreDraining) {
|
|
1056
|
+
return createDrainExhaustedResponse(response);
|
|
1057
|
+
}
|
|
1045
1058
|
}
|
|
1046
1059
|
return response;
|
|
1047
1060
|
} catch (error) {
|
|
@@ -10275,6 +10288,32 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10275
10288
|
model: providerConfig.model,
|
|
10276
10289
|
complete: async (messages, options) => {
|
|
10277
10290
|
const stream = Boolean(options?.onTextDelta);
|
|
10291
|
+
const inlinedMessages = (await inlineImageUrlsForCustomProvider(
|
|
10292
|
+
{ messages },
|
|
10293
|
+
{
|
|
10294
|
+
shouldInline: true,
|
|
10295
|
+
isAllowedImageUrl: (url) => {
|
|
10296
|
+
try {
|
|
10297
|
+
return new URL(url).origin === new URL(serverUrl).origin;
|
|
10298
|
+
} catch {
|
|
10299
|
+
return false;
|
|
10300
|
+
}
|
|
10301
|
+
},
|
|
10302
|
+
fetchImage: async (url) => {
|
|
10303
|
+
const response = await fetchImpl(url, {
|
|
10304
|
+
headers: authToken ? { Authorization: `Bearer ${authToken}` } : void 0
|
|
10305
|
+
});
|
|
10306
|
+
if (!response.ok) {
|
|
10307
|
+
return { ok: false, error: `HTTP ${response.status}` };
|
|
10308
|
+
}
|
|
10309
|
+
return {
|
|
10310
|
+
ok: true,
|
|
10311
|
+
mimeType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
10312
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
10313
|
+
};
|
|
10314
|
+
}
|
|
10315
|
+
}
|
|
10316
|
+
)).messages;
|
|
10278
10317
|
logLocalRuntimeDiagnostic("provider.request.start", {
|
|
10279
10318
|
agentKey: agentConfig.key,
|
|
10280
10319
|
transport: "direct-openai-compatible",
|
|
@@ -10288,7 +10327,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10288
10327
|
});
|
|
10289
10328
|
const result = await executeOpenAiCompatibleChatCompletion({
|
|
10290
10329
|
providerConfig,
|
|
10291
|
-
messages,
|
|
10330
|
+
messages: inlinedMessages,
|
|
10292
10331
|
tools,
|
|
10293
10332
|
fetchImpl: (url, init) => fetchWithTransientRetry(fetchImpl, url, init, {
|
|
10294
10333
|
sleep: deps.sleep,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isImageUrlPart
|
|
3
|
+
} from "./chunk-TYPHUVK5.js";
|
|
1
4
|
import {
|
|
2
5
|
canonicalizeToolNames
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-B4KT7RN2.js";
|
|
7
|
+
import {
|
|
8
|
+
asTrimmedLowercaseString
|
|
9
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
4
10
|
import {
|
|
5
11
|
asTrimmedString
|
|
6
12
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -232,8 +238,39 @@ var buildCurrentTimeBlock = (now = /* @__PURE__ */ new Date(), timeZone = resolv
|
|
|
232
238
|
"\u5F53\u7528\u6237\u8BF4\u201C\u4ECA\u5929\u201D\u201C\u4ECA\u65E5\u201D\u6216 today \u65F6\uFF0C\u9ED8\u8BA4\u6307\u5F53\u524D\u672C\u5730\u65E5\u671F\uFF0C\u9664\u975E\u7528\u6237\u660E\u786E\u7ED9\u51FA\u5176\u5B83\u65E5\u671F\u3002"
|
|
233
239
|
].join("\n");
|
|
234
240
|
|
|
241
|
+
// packages/core/chat/bareImageUrlShape.ts
|
|
242
|
+
function requiresBareImageUrl(args) {
|
|
243
|
+
const model = asTrimmedLowercaseString(args.model);
|
|
244
|
+
if (!model.startsWith("gpt-")) return false;
|
|
245
|
+
const provider = asTrimmedLowercaseString(args.provider);
|
|
246
|
+
if (provider === "opencode-go") return true;
|
|
247
|
+
return asTrimmedLowercaseString(args.endpoint).includes("opencode.ai/zen/go");
|
|
248
|
+
}
|
|
249
|
+
function toBareImageUrlContent(content) {
|
|
250
|
+
if (!Array.isArray(content)) return content;
|
|
251
|
+
let changed = false;
|
|
252
|
+
const parts = content.map((part) => {
|
|
253
|
+
if (!isImageUrlPart(part)) return part;
|
|
254
|
+
const imageUrl = part.image_url;
|
|
255
|
+
if (!imageUrl || typeof imageUrl !== "object") return part;
|
|
256
|
+
const url = imageUrl.url;
|
|
257
|
+
if (typeof url !== "string" || !url) return part;
|
|
258
|
+
changed = true;
|
|
259
|
+
return { ...part, image_url: url };
|
|
260
|
+
});
|
|
261
|
+
return changed ? parts : content;
|
|
262
|
+
}
|
|
263
|
+
function toBareImageUrlMessages(messages) {
|
|
264
|
+
return messages.map((message) => {
|
|
265
|
+
const content = toBareImageUrlContent(message.content);
|
|
266
|
+
return content === message.content ? message : { ...message, content };
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
235
270
|
export {
|
|
236
271
|
buildIdentityBlock,
|
|
237
272
|
buildRuntimeGuidanceBlocks,
|
|
238
|
-
buildCurrentTimeBlock
|
|
273
|
+
buildCurrentTimeBlock,
|
|
274
|
+
requiresBareImageUrl,
|
|
275
|
+
toBareImageUrlMessages
|
|
239
276
|
};
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyChatCompletionDelta,
|
|
3
|
-
finalizeAccumulatedToolCalls,
|
|
4
3
|
flushChatCompletionStream,
|
|
4
|
+
providerHttpFailure,
|
|
5
5
|
readSseFrames,
|
|
6
6
|
throwIfChatCompletionStreamFailed
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5S4SWV5G.js";
|
|
8
8
|
import {
|
|
9
9
|
parseToolArgumentsJson
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TA7VKOHU.js";
|
|
11
11
|
import {
|
|
12
12
|
createThinkParserState,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
createToolCallAccumulator,
|
|
14
|
+
extractThinkContent,
|
|
15
|
+
finalizeAccumulatedToolCalls
|
|
16
|
+
} from "./chunk-3WGLLTK4.js";
|
|
17
|
+
import {
|
|
18
|
+
requiresBareImageUrl,
|
|
19
|
+
toBareImageUrlMessages
|
|
20
|
+
} from "./chunk-LUKQQJFL.js";
|
|
15
21
|
import {
|
|
16
22
|
buildProviderAuthHeaders,
|
|
17
23
|
buildProviderExecutionPlan,
|
|
18
24
|
toOpenAiCompatibleMessages
|
|
19
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TYPHUVK5.js";
|
|
20
26
|
import {
|
|
21
27
|
canonicalizeToolName,
|
|
22
28
|
createGlob,
|
|
23
29
|
resolveExecutableOnPath
|
|
24
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-B4KT7RN2.js";
|
|
25
31
|
import {
|
|
26
32
|
toErrorMessage
|
|
27
33
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -81,9 +87,14 @@ function parseSseDataLineJson(line) {
|
|
|
81
87
|
|
|
82
88
|
// packages/agent-runtime/openAiCompatibleProvider.ts
|
|
83
89
|
function buildOpenAiCompatibleChatCompletionRequest(args) {
|
|
90
|
+
const messages = toOpenAiCompatibleMessages(args.messages);
|
|
84
91
|
const body = {
|
|
85
92
|
model: args.providerConfig.model,
|
|
86
|
-
messages:
|
|
93
|
+
messages: requiresBareImageUrl({
|
|
94
|
+
endpoint: args.providerConfig.endpoint,
|
|
95
|
+
provider: args.providerConfig.provider,
|
|
96
|
+
model: args.providerConfig.model
|
|
97
|
+
}) ? toBareImageUrlMessages(messages) : messages,
|
|
87
98
|
stream: args.stream ?? false,
|
|
88
99
|
...args.providerConfig.requestOptions,
|
|
89
100
|
...args.tools && args.tools.length > 0 ? { tools: args.tools } : {},
|
|
@@ -121,6 +132,9 @@ function parseOpenAiCompatibleChatCompletionResponse(args) {
|
|
|
121
132
|
...reasoning ? { reasoning_content: reasoning } : {},
|
|
122
133
|
...typeof choiceMessage?.reasoning_content === "string" && choiceMessage.reasoning_content ? { reasoning_content: choiceMessage.reasoning_content } : {},
|
|
123
134
|
...typeof rawFinishReason === "string" && rawFinishReason.length > 0 ? { finish_reason: rawFinishReason } : {},
|
|
135
|
+
// 非流式:拿到完整的 200 JSON body 本身就证明这次调用走完了,
|
|
136
|
+
// 不必等 finish_reason(有从不发它的上游,见 AgentRuntimeResult)。
|
|
137
|
+
stream_complete: true,
|
|
124
138
|
usage: args.data?.usage,
|
|
125
139
|
trace: args.trace
|
|
126
140
|
};
|
|
@@ -137,7 +151,7 @@ async function readOpenAiCompatibleSseCompletion(args) {
|
|
|
137
151
|
content: "",
|
|
138
152
|
reasoning: "",
|
|
139
153
|
usage: void 0,
|
|
140
|
-
accumulatedToolCalls:
|
|
154
|
+
accumulatedToolCalls: createToolCallAccumulator(),
|
|
141
155
|
thinkState: createThinkParserState(),
|
|
142
156
|
onTextDelta: args.onTextDelta,
|
|
143
157
|
onReasoningDelta: args.onReasoningDelta
|
|
@@ -152,7 +166,7 @@ async function readOpenAiCompatibleSseCompletion(args) {
|
|
|
152
166
|
content: state.content,
|
|
153
167
|
...state.reasoning ? { reasoning_content: state.reasoning } : {},
|
|
154
168
|
...tool_calls.length > 0 ? { tool_calls } : {},
|
|
155
|
-
...state.usage ? { usage: state.usage } : {},
|
|
169
|
+
...state.usage ? { usage: state.usage, stream_complete: true } : {},
|
|
156
170
|
...state.finishReason ? { finish_reason: state.finishReason } : {}
|
|
157
171
|
};
|
|
158
172
|
}
|
|
@@ -183,13 +197,12 @@ async function executeOpenAiCompatibleChatCompletion(args) {
|
|
|
183
197
|
}
|
|
184
198
|
}
|
|
185
199
|
if (!res.ok) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
throw new Error(`local provider failed: HTTP ${res.status} ${JSON.stringify(data2)}`);
|
|
200
|
+
throw providerHttpFailure({
|
|
201
|
+
label: "local provider",
|
|
202
|
+
status: res.status,
|
|
203
|
+
raw: await res.text().catch(() => ""),
|
|
204
|
+
messages: args.messages
|
|
205
|
+
});
|
|
193
206
|
}
|
|
194
207
|
const contentType = res.headers.get("content-type") ?? "";
|
|
195
208
|
const isEventStream = contentType.includes("text/event-stream");
|
|
@@ -206,6 +219,7 @@ async function executeOpenAiCompatibleChatCompletion(args) {
|
|
|
206
219
|
...streamed.tool_calls ? { tool_calls: streamed.tool_calls } : {},
|
|
207
220
|
...streamed.reasoning_content ? { reasoning_content: streamed.reasoning_content } : {},
|
|
208
221
|
...streamed.usage ? { usage: streamed.usage } : {},
|
|
222
|
+
...streamed.stream_complete ? { stream_complete: true } : {},
|
|
209
223
|
...streamed.finish_reason ? { finish_reason: streamed.finish_reason } : {},
|
|
210
224
|
trace: args.messages
|
|
211
225
|
};
|