nolo-cli 0.8.0-alpha.7 → 0.9.0

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.
Files changed (99) hide show
  1. package/{_executeModel-XIGO7HW5.js → _executeModel-UD44KGZ4.js} +33 -28
  2. package/{action-PAXRPJJF.js → action-ZJWE3Y5S.js} +5 -4
  3. package/{addContentAction-CZVWF3QZ.js → addContentAction-TVDBNJM5.js} +4 -3
  4. package/{addDialogAgentAction-CCIDTPHC.js → addDialogAgentAction-EKH774VT.js} +3 -2
  5. package/{agentDeleteCommand-47B24JYG.js → agentDeleteCommand-TCPEFJTF.js} +15 -11
  6. package/{agentEmailCommands-D4FC6OZJ.js → agentEmailCommands-CZ3UILZ4.js} +36 -31
  7. package/{agentListCommands-UFET7CC4.js → agentListCommands-SJKO2FFB.js} +16 -12
  8. package/{agentMachineCommands-LH7QDQPP.js → agentMachineCommands-PSNABISZ.js} +15 -11
  9. package/{agentRecordCommands-CWS2B5IA.js → agentRecordCommands-MH2JKFHS.js} +36 -31
  10. package/{agentRunCommand-3FRPISLG.js → agentRunCommand-4KH6MIZR.js} +42 -34
  11. package/{agentRuntimeLocal-JNQQC2WG.js → agentRuntimeLocal-SKHJUWSS.js} +20 -15
  12. package/{agentSlice-XDFSELFJ.js → agentSlice-3WXXN4VK.js} +5 -4
  13. package/{authCommand-WXMD3IPR.js → authCommand-PXFX6JDT.js} +8 -1
  14. package/{authCommands-X74AFDTC.js → authCommands-356AYWEK.js} +10 -1
  15. package/{chunk-E5HMHIKL.js → chunk-2K2ECKSG.js} +4 -4
  16. package/{chunk-364VYAX2.js → chunk-2PUGVR6E.js} +1 -1
  17. package/chunk-3TZDXYSF.js +71 -0
  18. package/{chunk-YIJFUVKA.js → chunk-3WYQEUBI.js} +1 -1
  19. package/{chunk-543C7RDK.js → chunk-4K2KKCSD.js} +23 -8
  20. package/chunk-4ZDM73SD.js +34 -0
  21. package/{chunk-TDIQFT2F.js → chunk-5CS33IBL.js} +1 -1
  22. package/chunk-5KLGBAAR.js +386 -0
  23. package/{chunk-YD43KPCK.js → chunk-5PJ3VWCS.js} +3 -3
  24. package/{chunk-IAXBCTTE.js → chunk-63SLEOLK.js} +2 -2
  25. package/{chunk-BSTNFPHD.js → chunk-6GANEXVO.js} +1 -1
  26. package/{chunk-6PWWWMI7.js → chunk-7OOXPE3N.js} +2 -2
  27. package/{chunk-KK6SWS5B.js → chunk-7QRKCBOP.js} +5 -5
  28. package/{chunk-LM25IZBJ.js → chunk-AUQ747NZ.js} +2 -2
  29. package/{chunk-572EKYLF.js → chunk-BBYVOSU2.js} +1 -1
  30. package/{chunk-2MALU52L.js → chunk-C3RUNRHT.js} +1 -1
  31. package/{chunk-G5H7RNFL.js → chunk-COMXDWNM.js} +2 -2
  32. package/{chunk-2LMT6K6N.js → chunk-CPB2YM4D.js} +2 -2
  33. package/{chunk-USZMK5UT.js → chunk-DCOA4QSN.js} +1 -1
  34. package/{chunk-OF5H3QWS.js → chunk-EXTIQUCI.js} +182 -0
  35. package/{chunk-B76D3JJK.js → chunk-G43KEVSC.js} +4 -4
  36. package/{chunk-USZDUWOV.js → chunk-GG4AJPSR.js} +2 -2
  37. package/chunk-I42VC5KR.js +15 -0
  38. package/{chunk-BR2WP3DF.js → chunk-IWX4UW2E.js} +9 -9
  39. package/chunk-JEXVIMYZ.js +55 -0
  40. package/{chunk-XDVAYP26.js → chunk-JRKKFRAV.js} +1 -1
  41. package/{chunk-DA2OEKS6.js → chunk-KKY4B2Q2.js} +2 -8
  42. package/{chunk-A3X4Y7MO.js → chunk-KOCA5FCS.js} +482 -26
  43. package/{chunk-IYQV26RA.js → chunk-KTVVPRJS.js} +2 -2
  44. package/{chunk-V2F4OGYM.js → chunk-LARL2V6G.js} +22 -18
  45. package/{chunk-H2RMRZJE.js → chunk-MGOJ5R6J.js} +1 -1
  46. package/{chunk-UVPF33PW.js → chunk-MKMWT7SA.js} +63 -19862
  47. package/chunk-OPZYGHUC.js +89 -0
  48. package/chunk-PAKN26FP.js +239 -0
  49. package/{chunk-OVGXXUVI.js → chunk-PCWC3JTN.js} +2 -2
  50. package/{chunk-AR7ZSGDI.js → chunk-PG5PNA7Y.js} +16 -6
  51. package/{chunk-HEIIIZBX.js → chunk-Q2YZULBH.js} +1 -1
  52. package/{chunk-2JHWPW5B.js → chunk-SBR32ZZS.js} +77 -303
  53. package/{chunk-PN7AFLOK.js → chunk-SH2CFQOH.js} +3 -13
  54. package/{chunk-CM54RSSA.js → chunk-SL35K7AH.js} +21 -1
  55. package/{chunk-VEJLAVTC.js → chunk-TSS3XJY4.js} +4 -4
  56. package/{chunk-IECI4YHR.js → chunk-UUJDGGAK.js} +3 -3
  57. package/{chunk-GEKCOPTN.js → chunk-WKM6FH35.js} +1 -1
  58. package/{chunk-SL3EPWB4.js → chunk-XE635NI4.js} +21 -22
  59. package/{chunk-NE3E3XJ2.js → chunk-XS466O7S.js} +96 -99
  60. package/{chunk-5XH3NZ4T.js → chunk-YBWOP46I.js} +20 -379
  61. package/{chunk-VQ2AJRGD.js → chunk-YPRZSPF3.js} +1 -1
  62. package/{chunk-AUGHVUFE.js → chunk-YYUCRDOK.js} +1 -1
  63. package/{chunk-KTI2WDDG.js → chunk-ZIG5LJ7X.js} +357 -266
  64. package/{chunk-NXZGF7F7.js → chunk-ZQ2UM4KG.js} +1 -1
  65. package/{createAgentAutomationAction-3QTGNYJC.js → createAgentAutomationAction-63OIP6X5.js} +15 -13
  66. package/{createDialogAction-5YX3ARBK.js → createDialogAction-ZLYZDYBB.js} +18 -16
  67. package/{createPageAction-EQNQQRCW.js → createPageAction-AL5FSDCK.js} +16 -14
  68. package/{dbSlice-C4UJLRZP.js → dbSlice-PR44QPXY.js} +3 -2
  69. package/{dialogCommands-AOQS23FV.js → dialogCommands-F6YI5742.js} +17 -13
  70. package/{dialogSlice-GZE3NCMC.js → dialogSlice-JSBNZRLR.js} +15 -13
  71. package/{docCreateCommands-GVOQVJON.js → docCreateCommands-4CTO7ERT.js} +16 -12
  72. package/{docDeleteCommands-GEB7YAUZ.js → docDeleteCommands-VBWERDRG.js} +17 -13
  73. package/{docReadCommands-XYKI2DF2.js → docReadCommands-KNP4MFYB.js} +16 -12
  74. package/{docStore-MLM5AME5.js → docStore-ADP5VYY4.js} +16 -14
  75. package/{docUpdateCommands-4L3RAMHZ.js → docUpdateCommands-4BCBJQHA.js} +16 -12
  76. package/{fetchMessages-JOCYIFKL.js → fetchMessages-U6ZHN56A.js} +3 -2
  77. package/{getPricing-PWPJ6MNV.js → getPricing-3E6UNPKL.js} +3 -3
  78. package/{handleSendMessageAction-WG2GKTGZ.js → handleSendMessageAction-IJDQ6ARA.js} +15 -13
  79. package/index.js +60 -56
  80. package/lib-FYYBQIXS.js +19839 -0
  81. package/{localDialogRead-D3BELSTF.js → localDialogRead-Z5UTAJPU.js} +1 -1
  82. package/{machineCommands-ZNXKLH6Q.js → machineCommands-EA3M4XTN.js} +38 -33
  83. package/{machineWsRunDispatch-7WRG6HNV.js → machineWsRunDispatch-NAPKE5ZA.js} +34 -29
  84. package/{models-XLEOET3E.js → models-4OPOOLFS.js} +2 -2
  85. package/package.json +1 -1
  86. package/{readlineWorkspace-AQURUDN4.js → readlineWorkspace-KMWT4T4S.js} +196 -44
  87. package/{removeDialogAgentAction-CXLST3N6.js → removeDialogAgentAction-GJQJNDW6.js} +5 -4
  88. package/{runAgentClientLoop-VQUEKGA5.js → runAgentClientLoop-U5Q6NDTJ.js} +28 -25
  89. package/{setDialogExtraReferencesAction-LP6VYGU7.js → setDialogExtraReferencesAction-M7OQG54N.js} +3 -2
  90. package/{setPrimaryDialogAgentAction-D3GGH23T.js → setPrimaryDialogAgentAction-46UNFJDL.js} +5 -4
  91. package/{settingSlice-J4I3Z5H7.js → settingSlice-FVUUH4JA.js} +4 -3
  92. package/{spaceCommands-R2RXD5UY.js → spaceCommands-E2CFRPZJ.js} +15 -11
  93. package/{spaceSlice-5UT4JNIN.js → spaceSlice-L3R6IMXE.js} +15 -13
  94. package/{streamAgentChatTurn-NRWSQKFN.js → streamAgentChatTurn-UBDAOQWE.js} +60 -35
  95. package/{tableCommands-66XEWHAK.js → tableCommands-GOFP7QKA.js} +1 -1
  96. package/{tools-TNMUDDRK.js → tools-TMJXZTCA.js} +22 -20
  97. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  98. package/{understanding-HCSFPE7R.js → understanding-GQKNDDWM.js} +7 -54
  99. package/{updateDialogTitleAction-IXOKAVX3.js → updateDialogTitleAction-ZTWRDXI2.js} +17 -14
@@ -1,29 +1,27 @@
1
+ import {
2
+ applyChatCompletionDelta,
3
+ finalizeAccumulatedToolCalls,
4
+ flushChatCompletionStream,
5
+ readSseFrames,
6
+ throwIfChatCompletionStreamFailed,
7
+ toOpenAiCompatibleMessages
8
+ } from "./chunk-5KLGBAAR.js";
9
+ import {
10
+ parseToolArgumentsJson
11
+ } from "./chunk-XS466O7S.js";
1
12
  import {
2
13
  createThinkParserState,
3
- extractThinkContent,
4
- flushThinkParser,
5
- parseToolArgumentsJson,
6
- processThinkChunk
7
- } from "./chunk-NE3E3XJ2.js";
14
+ extractThinkContent
15
+ } from "./chunk-OPZYGHUC.js";
8
16
  import {
9
17
  buildProviderAuthHeaders,
10
- buildProviderExecutionPlan,
11
- canUsePlatformChatProvider,
12
- convertMessagesToResponsesInput,
13
- extractTextFromResponseOutput,
14
- extractToolCallsFromResponseOutput,
15
- hasDirectOpenAiCompatibleProvider,
16
- resolveAgentRuntimeLocation,
17
- resolvePlatformAuthToken,
18
- resolvePlatformServerUrl,
19
- resolveProviderTransportDecision,
20
- toResponsesTools
21
- } from "./chunk-XDVAYP26.js";
18
+ buildProviderExecutionPlan
19
+ } from "./chunk-JRKKFRAV.js";
22
20
  import {
23
21
  canonicalizeToolName,
24
22
  createGlob,
25
23
  resolveExecutableOnPath
26
- } from "./chunk-LM25IZBJ.js";
24
+ } from "./chunk-AUQ747NZ.js";
27
25
  import {
28
26
  toErrorMessage
29
27
  } from "./chunk-HNMXYYJR.js";
@@ -31,9 +29,11 @@ import {
31
29
  asRecordOrEmpty
32
30
  } from "./chunk-KX6YBIHG.js";
33
31
  import {
34
- asTrimmedNonEmptyStringArray,
35
32
  dialogMessageKey
36
- } from "./chunk-PN7AFLOK.js";
33
+ } from "./chunk-SH2CFQOH.js";
34
+ import {
35
+ asTrimmedNonEmptyStringArray
36
+ } from "./chunk-I42VC5KR.js";
37
37
  import {
38
38
  asOptionalFiniteNumber
39
39
  } from "./chunk-WWC7I6TA.js";
@@ -56,119 +56,6 @@ import {
56
56
  isRecord
57
57
  } from "./chunk-KUG52IAP.js";
58
58
 
59
- // packages/agent-runtime/toolCallAccumulator.ts
60
- function accumulateToolCallDelta(accumulated, deltas) {
61
- for (const delta of deltas) {
62
- const index = typeof delta.index === "number" ? delta.index : 0;
63
- const current = accumulated[index] ?? {
64
- id: "",
65
- type: "function",
66
- function: { name: "", arguments: "" }
67
- };
68
- if (typeof delta.id === "string" && delta.id) current.id = delta.id;
69
- const fn = delta.function;
70
- if (fn && typeof fn === "object") {
71
- const functionDelta = fn;
72
- if (typeof functionDelta.name === "string" && functionDelta.name) {
73
- current.function.name += functionDelta.name;
74
- }
75
- if (typeof functionDelta.arguments === "string" && functionDelta.arguments) {
76
- current.function.arguments += functionDelta.arguments;
77
- }
78
- }
79
- accumulated[index] = current;
80
- }
81
- }
82
- function finalizeAccumulatedToolCalls(accumulated) {
83
- return Object.keys(accumulated).map((key) => accumulated[Number(key)]).filter((call) => call?.function?.name);
84
- }
85
-
86
- // packages/agent-runtime/processChatCompletionDelta.ts
87
- function extractChatCompletionStreamError(parsed) {
88
- const raw = parsed?.error;
89
- if (!raw) return null;
90
- if (typeof raw === "string") {
91
- return raw.trim() ? { message: raw.trim() } : null;
92
- }
93
- if (typeof raw !== "object") return null;
94
- const message = typeof raw.msg === "string" && raw.msg.trim() ? raw.msg.trim() : typeof raw.message === "string" && raw.message.trim() ? raw.message.trim() : "";
95
- const code = typeof raw.code === "string" && raw.code.trim() ? raw.code.trim() : typeof raw.type === "string" && raw.type.trim() ? raw.type.trim() : void 0;
96
- if (!message && !code) return null;
97
- return {
98
- message: message || "upstream stream error",
99
- ...code ? { code } : {}
100
- };
101
- }
102
- function throwIfChatCompletionStreamFailed(state) {
103
- const failure = state.streamError;
104
- if (!failure) return;
105
- const error = new Error(
106
- failure.code ? `${failure.message} (${failure.code})` : failure.message
107
- );
108
- if (failure.code) error.code = failure.code;
109
- throw error;
110
- }
111
- function applyChatCompletionDelta(parsed, state) {
112
- const streamError = extractChatCompletionStreamError(parsed);
113
- if (streamError && !state.streamError) {
114
- state.streamError = streamError;
115
- }
116
- if (parsed?.usage && typeof parsed.usage === "object") {
117
- state.usage = parsed.usage;
118
- }
119
- const rawFinishReason = parsed?.choices?.[0]?.finish_reason;
120
- if (typeof rawFinishReason === "string" && rawFinishReason.length > 0) {
121
- state.finishReason = rawFinishReason;
122
- }
123
- const delta = parsed?.choices?.[0]?.delta;
124
- if (!delta || typeof delta !== "object") return false;
125
- const reasoningChunk = typeof delta.reasoning_content === "string" ? delta.reasoning_content : typeof delta.reasoning === "string" ? delta.reasoning : "";
126
- if (reasoningChunk) {
127
- state.reasoning += reasoningChunk;
128
- state.onReasoningDelta?.(reasoningChunk);
129
- }
130
- if (Array.isArray(delta.tool_calls) && delta.tool_calls.length > 0) {
131
- accumulateToolCallDelta(state.accumulatedToolCalls, delta.tool_calls);
132
- }
133
- const textChunk = typeof delta.content === "string" ? delta.content : "";
134
- if (textChunk) {
135
- const parsedChunk = processThinkChunk(textChunk, state.thinkState);
136
- state.thinkState = parsedChunk.state;
137
- if (parsedChunk.content) {
138
- state.content += parsedChunk.content;
139
- state.onTextDelta?.(parsedChunk.content);
140
- }
141
- if (parsedChunk.reasoning) {
142
- state.reasoning += parsedChunk.reasoning;
143
- state.onReasoningDelta?.(parsedChunk.reasoning);
144
- }
145
- }
146
- return true;
147
- }
148
- function flushChatCompletionStream(state) {
149
- const flushed = flushThinkParser(state.thinkState);
150
- state.thinkState = flushed.state;
151
- if (flushed.content) {
152
- state.content += flushed.content;
153
- state.onTextDelta?.(flushed.content);
154
- }
155
- if (flushed.reasoning) {
156
- state.reasoning += flushed.reasoning;
157
- state.onReasoningDelta?.(flushed.reasoning);
158
- }
159
- }
160
-
161
- // packages/agent-runtime/openAiCompatibleMessages.ts
162
- function toOpenAiCompatibleMessages(messages) {
163
- return messages.map((message) => ({
164
- role: message.role,
165
- content: message.content ?? "",
166
- ...message.tool_call_id ? { tool_call_id: message.tool_call_id } : {},
167
- ...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {},
168
- ...message.reasoning_content ? { reasoning_content: message.reasoning_content } : {}
169
- }));
170
- }
171
-
172
59
  // packages/agent-runtime/kimiUserAgent.ts
173
60
  var KIMI_CODE_CLI_VERSION = "0.29.2";
174
61
  var KIMI_CODE_USER_AGENT = `kimi-code-cli/${KIMI_CODE_CLI_VERSION} (nolo)`;
@@ -192,51 +79,6 @@ function parseSseDataLineJson(line) {
192
79
  }
193
80
  }
194
81
 
195
- // packages/agent-runtime/sseFrames.ts
196
- async function* readSseFrames(response) {
197
- const reader = response.body?.getReader();
198
- if (!reader) {
199
- throw new Error("SSE response did not include a readable body.");
200
- }
201
- const decoder = new TextDecoder();
202
- let buffer = "";
203
- while (true) {
204
- const { done, value } = await reader.read();
205
- if (done) break;
206
- buffer += decoder.decode(value, { stream: true });
207
- let boundary = buffer.indexOf("\n\n");
208
- while (boundary !== -1) {
209
- yield buffer.slice(0, boundary);
210
- buffer = buffer.slice(boundary + 2);
211
- boundary = buffer.indexOf("\n\n");
212
- }
213
- }
214
- if (buffer.trim()) yield buffer;
215
- }
216
- async function readSseDataValues(response, parse) {
217
- const reader = response.body?.getReader();
218
- if (!reader) return [];
219
- const decoder = new TextDecoder();
220
- const values = [];
221
- let buffer = "";
222
- while (true) {
223
- const { done, value } = await reader.read();
224
- if (done) break;
225
- buffer += decoder.decode(value, { stream: true });
226
- const lines = buffer.split("\n");
227
- buffer = lines.pop() ?? "";
228
- for (const line of lines) {
229
- const parsed = parse(line);
230
- if (parsed) values.push(parsed);
231
- }
232
- }
233
- if (buffer.trim()) {
234
- const parsed = parse(buffer);
235
- if (parsed) values.push(parsed);
236
- }
237
- return values;
238
- }
239
-
240
82
  // packages/agent-runtime/openAiCompatibleProvider.ts
241
83
  function buildOpenAiCompatibleChatCompletionRequest(args) {
242
84
  const body = {
@@ -529,199 +371,6 @@ public class NoloCredNative {
529
371
  }
530
372
  `.trim();
531
373
 
532
- // packages/agent-runtime/platformChatProvider.ts
533
- var CHAT_PROXY_PATH = "/api/v1/chat";
534
- function shouldDisableThinking(providerConfig) {
535
- return providerConfig.provider.toLowerCase() === "mimo" || /xiaomimimo\.com/i.test(providerConfig.endpoint);
536
- }
537
- function isResponsesEndpoint(endpoint) {
538
- return /\/responses$/i.test(endpoint.trim());
539
- }
540
- function toResponsesRequestOptions(options) {
541
- const next = { ...options };
542
- const reasoningEffort = next.reasoning_effort;
543
- if (typeof reasoningEffort === "string" && reasoningEffort) {
544
- next.reasoning = { effort: reasoningEffort };
545
- delete next.reasoning_effort;
546
- }
547
- if (next.max_tokens !== void 0) {
548
- next.max_output_tokens = next.max_tokens;
549
- delete next.max_tokens;
550
- }
551
- return next;
552
- }
553
- async function resolvePlatformChatProviderConfig(args) {
554
- const plan = await buildProviderExecutionPlan({
555
- agentConfig: args.agentConfig,
556
- env: args.env,
557
- runtimeKind: "local",
558
- ...args.apiKeyRefResolver ? { apiKeyRefResolver: args.apiKeyRefResolver } : {},
559
- ...args.credentialBroker ? { credentialBroker: args.credentialBroker } : {},
560
- ...args.syncFetcher ? { syncFetcher: args.syncFetcher } : {}
561
- });
562
- if (plan.mode === "cli") {
563
- throw new Error("Platform chat provider does not support cli agents.");
564
- }
565
- if (plan.transport === "direct") {
566
- return {
567
- serverUrl: resolvePlatformServerUrl(args.env),
568
- authToken: resolvePlatformAuthToken(args.env),
569
- agentKey: args.agentConfig.key,
570
- model: plan.model,
571
- provider: plan.provider,
572
- endpoint: plan.endpoint,
573
- requestOptions: plan.requestOptions,
574
- ...plan.apiKey ? { apiKey: plan.apiKey } : {},
575
- ...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
576
- ...args.agentConfig.apiSource ? { apiSource: args.agentConfig.apiSource } : {}
577
- };
578
- }
579
- return {
580
- serverUrl: plan.serverUrl,
581
- authToken: plan.authToken,
582
- agentKey: plan.agentKey,
583
- model: plan.model,
584
- provider: plan.provider,
585
- endpoint: plan.endpoint,
586
- requestOptions: plan.requestOptions,
587
- ...plan.apiKey ? { apiKey: plan.apiKey } : {},
588
- ...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
589
- ...plan.apiSource ? { apiSource: plan.apiSource } : {}
590
- };
591
- }
592
- function buildPlatformChatCompletionRequest(args) {
593
- const usesResponsesApi = isResponsesEndpoint(args.providerConfig.endpoint);
594
- const requestOptions = usesResponsesApi ? toResponsesRequestOptions(args.providerConfig.requestOptions) : args.providerConfig.requestOptions;
595
- const body = {
596
- model: args.providerConfig.model,
597
- ...usesResponsesApi ? { input: convertMessagesToResponsesInput(args.messages) } : { messages: toOpenAiCompatibleMessages(args.messages) },
598
- stream: args.stream ?? false,
599
- ...args.stream ? { stream_options: { include_usage: true } } : {},
600
- ...requestOptions,
601
- ...args.tools && args.tools.length > 0 ? {
602
- tools: usesResponsesApi ? toResponsesTools(args.tools) : args.tools,
603
- ...usesResponsesApi ? {} : { tool_choice: "auto" }
604
- } : {},
605
- ...shouldDisableThinking(args.providerConfig) ? { thinking: { type: "disabled" } } : {},
606
- url: args.providerConfig.endpoint,
607
- provider: args.providerConfig.provider,
608
- agentKey: args.providerConfig.agentKey,
609
- ...args.providerConfig.apiSource ? { apiSource: args.providerConfig.apiSource } : {},
610
- ...args.providerConfig.apiKey ? { KEY: args.providerConfig.apiKey } : {},
611
- ...args.providerConfig.apiKeyHeader ? { apiKeyHeader: args.providerConfig.apiKeyHeader } : {}
612
- };
613
- return {
614
- url: `${args.providerConfig.serverUrl}${CHAT_PROXY_PATH}`,
615
- init: {
616
- method: "POST",
617
- headers: {
618
- "Content-Type": "application/json",
619
- Authorization: `Bearer ${args.providerConfig.authToken}`
620
- },
621
- body: JSON.stringify(body)
622
- }
623
- };
624
- }
625
- function tryParseJson(raw) {
626
- try {
627
- return JSON.parse(raw);
628
- } catch {
629
- return null;
630
- }
631
- }
632
- function extractJsonObjects(raw) {
633
- const objects = [];
634
- let depth = 0;
635
- let start = -1;
636
- let inString = false;
637
- let escaped = false;
638
- for (let index = 0; index < raw.length; index += 1) {
639
- const char = raw[index];
640
- if (inString) {
641
- if (escaped) {
642
- escaped = false;
643
- } else if (char === "\\") {
644
- escaped = true;
645
- } else if (char === '"') {
646
- inString = false;
647
- }
648
- continue;
649
- }
650
- if (char === '"') {
651
- inString = true;
652
- continue;
653
- }
654
- if (char === "{") {
655
- if (depth === 0) start = index;
656
- depth += 1;
657
- continue;
658
- }
659
- if (char !== "}" || depth === 0) continue;
660
- depth -= 1;
661
- if (depth === 0 && start >= 0) {
662
- const parsed = tryParseJson(raw.slice(start, index + 1));
663
- if (parsed) objects.push(parsed);
664
- start = -1;
665
- }
666
- }
667
- return objects;
668
- }
669
- function parsePlatformChatCompletionData(raw) {
670
- const direct = tryParseJson(raw.trim());
671
- if (direct) return direct;
672
- const objects = extractJsonObjects(raw);
673
- return objects.find((object) => Array.isArray(object?.choices)) ?? objects[0] ?? {};
674
- }
675
- function parsePlatformChatCompletionResponse(args) {
676
- if (isResponsesEndpoint(args.providerConfig.endpoint)) {
677
- const content2 = extractTextFromResponseOutput(args.data);
678
- const tool_calls = extractToolCallsFromResponseOutput(args.data);
679
- return {
680
- content: content2,
681
- model: args.providerConfig.model,
682
- provider: args.providerConfig.provider,
683
- ...tool_calls.length > 0 ? { tool_calls } : {},
684
- usage: args.data?.usage,
685
- trace: args.trace
686
- };
687
- }
688
- const choiceMessage = args.data?.choices?.[0]?.message ?? {};
689
- const rawContent = String(choiceMessage?.content ?? "");
690
- const { content, reasoning } = extractThinkContent(rawContent);
691
- return {
692
- content,
693
- model: args.providerConfig.model,
694
- provider: args.providerConfig.provider,
695
- ...Array.isArray(choiceMessage?.tool_calls) ? { tool_calls: choiceMessage.tool_calls } : {},
696
- ...reasoning ? { reasoning_content: reasoning } : typeof choiceMessage?.reasoning_content === "string" && choiceMessage.reasoning_content ? { reasoning_content: choiceMessage.reasoning_content } : {},
697
- usage: args.data?.usage,
698
- trace: args.trace
699
- };
700
- }
701
- function canUsePlatformChatProvider2(env) {
702
- return canUsePlatformChatProvider(env);
703
- }
704
- function hasDirectOpenAiCompatibleProvider2(env) {
705
- return hasDirectOpenAiCompatibleProvider(env);
706
- }
707
- function shouldUsePlatformChatProvider(env, agentConfig) {
708
- if (!agentConfig) {
709
- return resolveProviderTransportDecision({
710
- agentConfig: { key: "default-platform" },
711
- env,
712
- runtimeLocation: "local-host"
713
- }).transport === "proxy";
714
- }
715
- return resolveProviderTransportDecision({
716
- agentConfig,
717
- env,
718
- runtimeLocation: resolveAgentRuntimeLocation({
719
- agentConfig,
720
- runtimeKind: "local"
721
- })
722
- }).transport === "proxy";
723
- }
724
-
725
374
  // packages/agent-runtime/agentRecordKeys.ts
726
375
  function buildAgentRuntimeAgentLookupKeys(args) {
727
376
  if (/^agent(-pub)?-/.test(args.agentRef)) {
@@ -3600,19 +3249,11 @@ function createLocalWorkspaceToolExecutors(args) {
3600
3249
 
3601
3250
  export {
3602
3251
  parseSseDataLineJson,
3603
- readSseDataValues,
3604
3252
  buildOpenAiCompatibleChatCompletionRequest,
3605
3253
  parseOpenAiCompatibleChatCompletionResponse,
3606
3254
  readOpenAiCompatibleSseCompletion,
3607
3255
  executeOpenAiCompatibleChatCompletion,
3608
3256
  resolveOpenAiCompatibleProviderConfig,
3609
- resolvePlatformChatProviderConfig,
3610
- buildPlatformChatCompletionRequest,
3611
- parsePlatformChatCompletionData,
3612
- parsePlatformChatCompletionResponse,
3613
- canUsePlatformChatProvider2 as canUsePlatformChatProvider,
3614
- hasDirectOpenAiCompatibleProvider2 as hasDirectOpenAiCompatibleProvider,
3615
- shouldUsePlatformChatProvider,
3616
3257
  buildAgentRuntimeAgentLookupKeys,
3617
3258
  shouldFetchAgentRuntimeRecordRemotely,
3618
3259
  dialogMessageRecordToAgentRuntimeMessage,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-CWMSB67P.js";
7
7
  import {
8
8
  getModelConfig
9
- } from "./chunk-572EKYLF.js";
9
+ } from "./chunk-BBYVOSU2.js";
10
10
  import {
11
11
  asOptionalFiniteNumber
12
12
  } from "./chunk-WWC7I6TA.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dialogMessageRange
3
- } from "./chunk-PN7AFLOK.js";
3
+ } from "./chunk-SH2CFQOH.js";
4
4
  import {
5
5
  isTombstoneRecord
6
6
  } from "./chunk-GBRG75BQ.js";