nolo-cli 0.105.0 → 0.106.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.
Files changed (115) hide show
  1. package/{_executeModel-JXG5TLPE.js → _executeModel-EP6HAX3W.js} +38 -37
  2. package/{addContentAction-J3DLDV64.js → addContentAction-NZZNAVCB.js} +4 -4
  3. package/{addDialogAgentAction-PHIXJCF2.js → addDialogAgentAction-5HVGEIXI.js} +4 -4
  4. package/{agentDeleteCommand-2AWJGHXG.js → agentDeleteCommand-M25A6UGB.js} +45 -45
  5. package/{agentEmailCommands-VV5OSILE.js → agentEmailCommands-RUL4NL64.js} +46 -46
  6. package/{agentListCommands-OQMRBDWP.js → agentListCommands-KSPFKHFO.js} +23 -24
  7. package/{agentMachineCommands-3VLLR6RL.js → agentMachineCommands-IHBB6PHD.js} +20 -21
  8. package/{agentProviderCommands-XPJYZSCE.js → agentProviderCommands-ND4S2Q6Q.js} +1 -1
  9. package/{agentRecordCommands-GPIARVOW.js → agentRecordCommands-7OKIBN6H.js} +45 -45
  10. package/{agentRunCommand-LRJTZ7IM.js → agentRunCommand-GBKJTQQU.js} +45 -45
  11. package/{agentRuntimeLocal-PV6AZOEU.js → agentRuntimeLocal-E5HXZNXZ.js} +18 -19
  12. package/{agentSlice-6R3JKS6I.js → agentSlice-7T3ZLYET.js} +4 -4
  13. package/{appDeleteCommands-WEX73P5R.js → appDeleteCommands-TTJUYTQN.js} +21 -22
  14. package/{appDeployCommands-7BAXWA4M.js → appDeployCommands-65WYK2TQ.js} +21 -22
  15. package/{appDeployStatusCommands-EJ6A2U4X.js → appDeployStatusCommands-U4XESYYG.js} +21 -22
  16. package/{appGetCommands-SB355OEX.js → appGetCommands-VNHZZC4D.js} +21 -22
  17. package/{appListCommands-TSZDPIKJ.js → appListCommands-O667ZEU6.js} +21 -22
  18. package/{authCommand-5PB3YRVV.js → authCommand-SUHHTVHA.js} +8 -8
  19. package/{builtinSkillRegistry-SBBWTANC.js → builtinSkillRegistry-PUGT65WS.js} +5 -5
  20. package/{chunk-Z5NGE5DH.js → chunk-2NGKYC3L.js} +3 -3
  21. package/{chunk-S2NSK7AZ.js → chunk-3SXZ6SUC.js} +4 -4
  22. package/{chunk-NSBID7PR.js → chunk-3VKDWQMJ.js} +2 -2
  23. package/{chunk-QKTESDWK.js → chunk-4VDS344D.js} +3 -3
  24. package/{chunk-7KVZ5LDQ.js → chunk-5F7UKMLN.js} +8 -4
  25. package/{chunk-BB7LVBTS.js → chunk-6AIURTE7.js} +3 -3
  26. package/{chunk-HP57OUJO.js → chunk-7I25CBT5.js} +31 -5
  27. package/{chunk-NSAFG343.js → chunk-AM4G3LDJ.js} +59 -47
  28. package/{chunk-NTR4SD3P.js → chunk-AZB6HR4I.js} +13 -48
  29. package/{chunk-AFH5QC6R.js → chunk-BIH7KCDJ.js} +3 -3
  30. package/{chunk-UA324D4O.js → chunk-BPLIXNC6.js} +1 -1
  31. package/{chunk-YK5MHOWM.js → chunk-CEQ75WPL.js} +1 -1
  32. package/{chunk-K6U4NKFJ.js → chunk-DBKRC5O2.js} +1 -1
  33. package/{chunk-UWXDA7L5.js → chunk-DJ3JABG5.js} +22 -37
  34. package/{chunk-HYXABXCZ.js → chunk-DSXRVBTA.js} +98 -21
  35. package/{chunk-3Q7NEHAR.js → chunk-EBS4FKW4.js} +1 -1
  36. package/{chunk-ZBHR642M.js → chunk-EHGIEGLI.js} +161 -43
  37. package/{chunk-YVU4XVJD.js → chunk-FJKZSR5P.js} +1 -1
  38. package/{chunk-54VPQTOA.js → chunk-GMP3NBAA.js} +5 -7
  39. package/{chunk-3BXNTXYI.js → chunk-GU7DC2TD.js} +2 -1
  40. package/{chunk-FGSJ3YMD.js → chunk-HNA5KV37.js} +5 -5
  41. package/{chunk-CYSYR67N.js → chunk-I5YMDACN.js} +1 -1
  42. package/{chunk-WJ3B6FX6.js → chunk-IXH3HKY2.js} +0 -8
  43. package/{chunk-Y3PMXGLH.js → chunk-IYIXAIEB.js} +197 -92
  44. package/{chunk-RWX7AY7J.js → chunk-JWNBEIME.js} +1 -1
  45. package/{chunk-VVJ2ENLY.js → chunk-LGWABBTZ.js} +4 -4
  46. package/{chunk-QYUBY3OZ.js → chunk-LOPP5VT6.js} +1 -1
  47. package/{chunk-GSKPJIHY.js → chunk-LUBFABMJ.js} +2 -6
  48. package/{chunk-BNGW5ASC.js → chunk-LYLO5U3H.js} +15 -2
  49. package/{chunk-L5WOICCV.js → chunk-MJ3CRU77.js} +22 -6
  50. package/{chunk-AWVP7PPG.js → chunk-NTNKA5VL.js} +1 -1
  51. package/{chunk-EP7BWZ4B.js → chunk-OAXBDMT7.js} +1 -1
  52. package/{chunk-4DPP773Q.js → chunk-ODTBO4W6.js} +9 -6
  53. package/{chunk-B7APRSPS.js → chunk-OQ5IVGCV.js} +3 -3
  54. package/{chunk-EKPKW6RM.js → chunk-OYTWDOQV.js} +3 -3
  55. package/{chunk-P5GCTVGV.js → chunk-OZ2IIIRP.js} +2 -2
  56. package/{chunk-D2GQE6AF.js → chunk-PFLF4R4E.js} +1 -1
  57. package/{chunk-RILRSUGC.js → chunk-QDH32WF5.js} +1 -1
  58. package/{chunk-VCAQFMVN.js → chunk-QVAWUJAJ.js} +1 -1
  59. package/{chunk-27ONFIEY.js → chunk-SJ7CUF65.js} +2 -2
  60. package/{chunk-CNA27EMD.js → chunk-SYEBIZOF.js} +1 -1
  61. package/{chunk-ZSUDOTPL.js → chunk-TLKXNTQJ.js} +3 -3
  62. package/{chunk-A4SQRTZ6.js → chunk-TLYSGGPG.js} +1 -1
  63. package/chunk-UM7TA3K4.js +1008 -0
  64. package/{chunk-BZ7NPA6G.js → chunk-VBG7GWWR.js} +218 -6
  65. package/{chunk-DZ7R5V3Y.js → chunk-VBQGO5NX.js} +1 -1
  66. package/{chunk-44CU7CKA.js → chunk-VYKXIHRP.js} +181 -34
  67. package/chunk-VZLO4XJD.js +17 -0
  68. package/{chunk-IEJ5YDA4.js → chunk-WMWYWYK2.js} +2 -2
  69. package/{chunk-LWXE6IFU.js → chunk-XDQ7PHU3.js} +31 -196
  70. package/{chunk-AFSY3ZMB.js → chunk-XGOHDYM2.js} +1 -1
  71. package/{chunk-2WJ57RJA.js → chunk-XLWMNFBZ.js} +1 -1
  72. package/{chunk-3F424ASC.js → chunk-YFU5EELM.js} +1 -1
  73. package/{chunk-QMXJ5KDJ.js → chunk-YQFLBS6A.js} +13 -13
  74. package/{chunk-CFHWVEUJ.js → chunk-ZVGXD7UJ.js} +2 -2
  75. package/{chunk-4WMMIL66.js → chunk-ZYM73IHG.js} +3 -2
  76. package/{commandRegistry-QU62WJQX.js → commandRegistry-6QIAUQDS.js} +49 -49
  77. package/{contentThunks-VGV3JJVB.js → contentThunks-5DDMUQ7B.js} +17 -16
  78. package/{createAgentAutomationAction-ZNVLI4WV.js → createAgentAutomationAction-NQ6AZM42.js} +17 -16
  79. package/{createDialogAction-TTUA46DT.js → createDialogAction-QZ6X4A7O.js} +20 -19
  80. package/{createPageAction-KUFSC5XW.js → createPageAction-NCGEJBVK.js} +17 -16
  81. package/{dbSlice-MYEETO73.js → dbSlice-RCZ7NRAF.js} +3 -3
  82. package/{dialogCommands-DRDPEOTL.js → dialogCommands-OGQLEF63.js} +21 -22
  83. package/{dialogSlice-V2SVSTIV.js → dialogSlice-GIKNUHNW.js} +30 -17
  84. package/{docCreateCommands-M26CFDDQ.js → docCreateCommands-RW6LNYT6.js} +20 -21
  85. package/{docDeleteCommands-LRZHCKVX.js → docDeleteCommands-Z742TRNY.js} +21 -22
  86. package/{docReadCommands-6QJSISHK.js → docReadCommands-5DIGA42Y.js} +20 -21
  87. package/{docStore-4RWAFNDM.js → docStore-6GUOZH52.js} +4 -4
  88. package/{docUpdateCommands-W4KU4U5T.js → docUpdateCommands-ZFZ2QEVK.js} +20 -21
  89. package/{getPricing-NMMFT3YI.js → getPricing-QVSNUFZ6.js} +3 -3
  90. package/{handleSendMessageAction-VEWLGB5Z.js → handleSendMessageAction-B2VXOLMM.js} +16 -15
  91. package/index.js +3 -3
  92. package/{machineCommands-AEHHCJEW.js → machineCommands-AI3N7JHQ.js} +44 -44
  93. package/{machineWsRunDispatch-MY2KHS36.js → machineWsRunDispatch-RPF2D6VV.js} +44 -44
  94. package/{memberThunks-EE6TI3TV.js → memberThunks-YICJI4IS.js} +4 -4
  95. package/{models-ZPU5EDF4.js → models-FTNFVO3D.js} +2 -2
  96. package/package.json +1 -1
  97. package/{providerPresetApply-TEBH7FDX.js → providerPresetApply-OJJXQ7NM.js} +6 -6
  98. package/{providerRegistry-CBJLNCET.js → providerRegistry-DXFBDCGQ.js} +6 -6
  99. package/{read-PJIT2YEJ.js → read-XMBM52Y4.js} +2 -2
  100. package/{readDocTool-DRSXHGNL.js → readDocTool-LAQHKCVT.js} +1 -1
  101. package/{readlineWorkspace-7Q6MITLV.js → readlineWorkspace-EPUCVZ73.js} +48 -48
  102. package/{removeDialogAgentAction-IN4WUKJJ.js → removeDialogAgentAction-HDUI2MU3.js} +5 -5
  103. package/{runAgentClientLoop-H2JALUVD.js → runAgentClientLoop-OXQMDGAN.js} +36 -35
  104. package/{setDialogExtraReferencesAction-VDRF7LPK.js → setDialogExtraReferencesAction-ADBVOP4O.js} +5 -5
  105. package/{setPrimaryDialogAgentAction-RO6LIWJ4.js → setPrimaryDialogAgentAction-PXVXQJ62.js} +5 -5
  106. package/{settingThunks-3OPOLOIA.js → settingThunks-G2MJRKUE.js} +6 -6
  107. package/{spaceCommands-UBLL5EF2.js → spaceCommands-Z662QYY6.js} +20 -21
  108. package/{streamAgentChatTurn-FFJWW3FD.js → streamAgentChatTurn-YJYEJHP7.js} +40 -46
  109. package/{switchDialogAgentAction-MVF2JNE7.js → switchDialogAgentAction-Z3RZACGF.js} +4 -4
  110. package/{toolApiClient-EJT6TMFG.js → toolApiClient-AD7CXTA4.js} +3 -2
  111. package/{tools-AZRYLYNK.js → tools-GHI3WBEI.js} +32 -31
  112. package/{tuiSummaryLlmCaller-7S5HJ3MT.js → tuiSummaryLlmCaller-WTC6GCQC.js} +11 -12
  113. package/{updateDialogTitleAction-5WXTRUJM.js → updateDialogTitleAction-GJCNWTPY.js} +17 -16
  114. package/chunk-M7VLQGQP.js +0 -405
  115. package/chunk-NKWIS6G2.js +0 -442
package/chunk-M7VLQGQP.js DELETED
@@ -1,405 +0,0 @@
1
- import {
2
- asTrimmedLowercaseString
3
- } from "./chunk-QSJ3HFEF.js";
4
- import {
5
- isRecord
6
- } from "./chunk-KUG52IAP.js";
7
- import {
8
- asOptionalTrimmedString
9
- } from "./chunk-G3SUCT4W.js";
10
-
11
- // packages/core/ollamaEndpoint.ts
12
- function isOllamaEndpoint(endpoint) {
13
- if (!endpoint || typeof endpoint !== "string") return false;
14
- try {
15
- const url = new URL(endpoint.includes("://") ? endpoint : `http://${endpoint}`);
16
- if (url.port === "11434") return true;
17
- const host = url.hostname.toLowerCase();
18
- return host === "ollama.com" || host.endsWith(".ollama.com") || host === "ollama.ai" || host.endsWith(".ollama.ai");
19
- } catch {
20
- return false;
21
- }
22
- }
23
-
24
- // packages/ai/llm/usageRequestOptions.ts
25
- var STREAM_USAGE_PROVIDERS = /* @__PURE__ */ new Set([
26
- "google",
27
- "openrouter",
28
- "xai",
29
- "openai",
30
- "fireworks",
31
- "mistral",
32
- "cloudflare",
33
- "gmi",
34
- // OpenAI-compatible hosted providers expose the terminal usage chunk when
35
- // requested, including DeepInfra and Vultr. Keep this capability decision
36
- // in the shared seam so proxy and local runtimes cannot drift.
37
- "deepinfra",
38
- "vultr",
39
- // Explicit local-runtime providers with OpenAI-compatible streaming: both
40
- // DeepSeek official and Ollama honor stream_options.include_usage on their
41
- // chat.completions endpoints. Without them, locally-configured agents lose
42
- // token statistics / local billing (the whitelist replaced the previous
43
- // always-on include_usage). ollama-cloud is the Ollama Cloud subscription
44
- // endpoint (https://ollama.com/v1), an OpenAI-compatible API that likewise
45
- // honors stream_options.include_usage.
46
- "deepseek",
47
- "ollama",
48
- "ollama-cloud",
49
- // RunInfra hosted fallback channel: OpenAI-compatible chat.completions
50
- // endpoint, supports stream_options.include_usage (measured to return
51
- // prompt_tokens_details.cached_tokens).
52
- "runinfra",
53
- "baseten",
54
- // Kimi For Coding subscription (api.kimi.com/coding/v1): OpenAI-compatible
55
- // chat.completions streaming that only emits the terminal usage frame when
56
- // stream_options.include_usage is requested (measured; the official
57
- // kimi-code CLI also sends include_usage). Custom agents pointing at the
58
- // same endpoint are covered by the endpoint check below, not here.
59
- "kimi-code"
60
- ]);
61
- var KIMI_CODE_ENDPOINT_MARKER = "api.kimi.com";
62
- var isKimiCodeEndpoint = (endpoint) => typeof endpoint === "string" && endpoint.includes(KIMI_CODE_ENDPOINT_MARKER);
63
- var EXTRA_USAGE_FIELD_PROVIDERS = /* @__PURE__ */ new Set(["openrouter"]);
64
- var normalizeProviderName = (providerName) => asTrimmedLowercaseString(providerName);
65
- var getUsageRequestOptions = (providerName, options) => {
66
- const normalizedProvider = normalizeProviderName(providerName);
67
- const api = options?.api ?? "chat-completions";
68
- const shouldRequestStreamUsage = STREAM_USAGE_PROVIDERS.has(normalizedProvider) || normalizedProvider === "custom" && (isKimiCodeEndpoint(options?.endpoint) || isOllamaEndpoint(options?.endpoint));
69
- if (api === "responses") {
70
- return EXTRA_USAGE_FIELD_PROVIDERS.has(normalizedProvider) ? {
71
- usage: {
72
- include: true
73
- }
74
- } : {};
75
- }
76
- return {
77
- ...shouldRequestStreamUsage ? {
78
- stream_options: {
79
- include_usage: true
80
- }
81
- } : {},
82
- ...EXTRA_USAGE_FIELD_PROVIDERS.has(normalizedProvider) ? {
83
- usage: {
84
- include: true
85
- }
86
- } : {}
87
- };
88
- };
89
-
90
- // packages/agent-runtime/openAiCompatibleMessages.ts
91
- function preserveAgentStateFields(source, target, options) {
92
- const mutableTarget = target;
93
- if (source.role === "assistant") {
94
- if (!options?.stripReasoningContent && typeof source.reasoning_content === "string") {
95
- mutableTarget.reasoning_content = source.reasoning_content;
96
- }
97
- if (Array.isArray(source.tool_calls)) {
98
- mutableTarget.tool_calls = source.tool_calls;
99
- const replayPlaceholder = options?.replayReasoningPlaceholder;
100
- if (typeof replayPlaceholder === "string" && replayPlaceholder.length > 0 && !options?.stripReasoningContent && source.tool_calls.length > 0 && !(typeof mutableTarget.reasoning_content === "string" && mutableTarget.reasoning_content.length > 0)) {
101
- mutableTarget.reasoning_content = replayPlaceholder;
102
- }
103
- }
104
- }
105
- if (source.role === "tool") {
106
- const toolCallId = typeof source.tool_call_id === "string" ? source.tool_call_id.trim() : typeof source.toolCallId === "string" ? source.toolCallId.trim() : "";
107
- if (toolCallId) mutableTarget.tool_call_id = toolCallId;
108
- }
109
- return target;
110
- }
111
- function toOpenAiCompatibleMessages(messages, options) {
112
- return messages.map(
113
- (message) => preserveAgentStateFields(message, {
114
- role: message.role,
115
- content: message.content ?? ""
116
- }, options)
117
- );
118
- }
119
- function shouldStripReasoningContentForOutbound(provider, model) {
120
- const p = provider?.trim().toLowerCase();
121
- const m = model?.trim().toLowerCase();
122
- if (!p || !m) return false;
123
- if (p === "deepseek" || p === "nolo") {
124
- return m === "deepseek-flash" || m === "deepseek-v4-flash" || m === "deepseek-v4-flash-vision-exp" || m === "deepseek-v4-pro";
125
- }
126
- return false;
127
- }
128
- function shouldReplayReasoningContentForOutbound(provider, model) {
129
- const p = provider?.trim().toLowerCase();
130
- const m = model?.trim().toLowerCase();
131
- if (!p || !m) return false;
132
- return p === "opencode-go" && m.includes("deepseek");
133
- }
134
-
135
- // packages/integrations/openai/responsesHelpers.ts
136
- var RESPONSES_TOP_LEVEL_SCHEMA_KEYS = ["anyOf", "oneOf", "allOf", "enum", "not"];
137
- var sanitizeResponsesParameters = (parameters) => {
138
- if (!isRecord(parameters)) {
139
- return parameters;
140
- }
141
- const next = { ...parameters };
142
- for (const key of RESPONSES_TOP_LEVEL_SCHEMA_KEYS) {
143
- delete next[key];
144
- }
145
- return next;
146
- };
147
- var appendTextPart = (parts, text, role) => {
148
- if (!text) return;
149
- const last = parts.at(-1);
150
- const textType = role === "assistant" ? "output_text" : "input_text";
151
- if (last?.type === textType) {
152
- last.text += text;
153
- return;
154
- }
155
- parts.push({ type: textType, text });
156
- };
157
- var normalizeMessageParts = (content, role) => {
158
- if (typeof content === "string") {
159
- if (!content) return [];
160
- return [
161
- {
162
- type: role === "assistant" ? "output_text" : "input_text",
163
- text: content
164
- }
165
- ];
166
- }
167
- const parts = [];
168
- for (const part of content ?? []) {
169
- const typedPart = part;
170
- if (typedPart?.type === "text" && typeof typedPart.text === "string") {
171
- appendTextPart(parts, typedPart.text, role);
172
- continue;
173
- }
174
- if (typedPart?.type === "image_url" && typeof typedPart.image_url?.url === "string" && typedPart.image_url.url) {
175
- if (role === "assistant") continue;
176
- parts.push({
177
- type: "input_image",
178
- image_url: typedPart.image_url.url,
179
- detail: typedPart.image_url.detail
180
- });
181
- }
182
- }
183
- return parts;
184
- };
185
- var normalizeToolOutput = (content) => {
186
- if (typeof content === "string") return content;
187
- return JSON.stringify(content ?? "");
188
- };
189
- var toResponsesTools = (tools) => {
190
- if (!Array.isArray(tools) || tools.length === 0) return void 0;
191
- const normalized = tools.map((tool) => {
192
- const fn = tool?.function;
193
- const name = fn?.name ?? tool?.name;
194
- if (!name) return null;
195
- const parameters = fn?.parameters ?? tool?.parameters;
196
- return {
197
- type: "function",
198
- name,
199
- ...typeof (fn?.description ?? tool?.description) === "string" ? { description: fn?.description ?? tool?.description } : {},
200
- parameters: sanitizeResponsesParameters(parameters),
201
- ...fn?.strict !== void 0 || tool?.strict !== void 0 ? { strict: fn?.strict ?? tool?.strict } : {}
202
- };
203
- }).filter(Boolean);
204
- return normalized.length > 0 ? normalized : void 0;
205
- };
206
- var convertMessagesToResponsesInput = (messages, options) => {
207
- const input = [];
208
- for (const message of messages) {
209
- if (!message?.role) continue;
210
- if (message.role === "tool") {
211
- if (!message.tool_call_id) continue;
212
- input.push({
213
- type: "function_call_output",
214
- call_id: message.tool_call_id,
215
- output: normalizeToolOutput(message.content)
216
- });
217
- continue;
218
- }
219
- const role = message.role;
220
- if (role === "assistant" && !options?.stripReasoningContent && typeof message.reasoning_content === "string" && message.reasoning_content) {
221
- input.push({
222
- type: "reasoning",
223
- content: [
224
- { type: "reasoning_text", text: message.reasoning_content }
225
- ]
226
- });
227
- }
228
- const contentParts = normalizeMessageParts(message.content, role);
229
- if (contentParts.length > 0) {
230
- input.push({
231
- type: "message",
232
- role,
233
- content: contentParts
234
- });
235
- }
236
- if (role === "assistant" && Array.isArray(message.content)) {
237
- const replayImages = message.content.map((part) => part).filter(
238
- (part) => part?.type === "image_url" && typeof part.image_url?.url === "string" && Boolean(part.image_url.url)
239
- ).map((part) => ({
240
- type: "input_image",
241
- image_url: part.image_url.url,
242
- detail: part.image_url.detail
243
- }));
244
- if (replayImages.length > 0) {
245
- input.push({
246
- type: "message",
247
- role: "user",
248
- content: replayImages
249
- });
250
- }
251
- }
252
- if (role === "assistant" && Array.isArray(message.tool_calls)) {
253
- for (const toolCall of message.tool_calls) {
254
- if (!toolCall?.id || !toolCall.function?.name) continue;
255
- input.push({
256
- type: "function_call",
257
- call_id: toolCall.id,
258
- name: toolCall.function.name,
259
- arguments: typeof toolCall.function.arguments === "string" ? toolCall.function.arguments : JSON.stringify(toolCall.function.arguments ?? {})
260
- });
261
- }
262
- }
263
- }
264
- return input;
265
- };
266
- var extractTextFromResponseOutput = (response) => {
267
- const parts = [];
268
- for (const item of response?.output ?? []) {
269
- if (item?.type !== "message") continue;
270
- for (const content of item.content ?? []) {
271
- if (content?.type === "output_text" && typeof content.text === "string") {
272
- parts.push(content.text);
273
- }
274
- }
275
- }
276
- return parts.join("");
277
- };
278
- var extractReasoningFromResponseOutput = (response) => {
279
- const parts = [];
280
- for (const item of response?.output ?? []) {
281
- if (item?.type !== "reasoning") continue;
282
- if (typeof item.content === "string") {
283
- parts.push(item.content);
284
- continue;
285
- }
286
- for (const content of item.content ?? []) {
287
- if (typeof content === "string") parts.push(content);
288
- else if (typeof content?.text === "string") parts.push(content.text);
289
- }
290
- }
291
- return parts.join("");
292
- };
293
- var toDataUrl = (base64Data, mimeType) => {
294
- const normalizedMimeType = asOptionalTrimmedString(mimeType) ?? "image/png";
295
- return `data:${normalizedMimeType};base64,${base64Data}`;
296
- };
297
- var extractImagePartsFromResponseOutput = (response) => {
298
- const images = [];
299
- for (const item of response?.output ?? []) {
300
- if (item?.type === "image_generation_call") {
301
- const result = asOptionalTrimmedString(item.result);
302
- if (result) {
303
- const outputFormat = asOptionalTrimmedString(item.output_format);
304
- images.push({
305
- type: "image_url",
306
- image_url: {
307
- url: toDataUrl(
308
- result,
309
- outputFormat ? `image/${outputFormat}` : void 0
310
- )
311
- }
312
- });
313
- }
314
- continue;
315
- }
316
- if (item?.type !== "message") continue;
317
- for (const content of item.content ?? []) {
318
- const result = asOptionalTrimmedString(content?.result);
319
- if (content?.type === "output_image" && result) {
320
- images.push({
321
- type: "image_url",
322
- image_url: {
323
- url: toDataUrl(
324
- result,
325
- content.mime_type ?? content.mimeType ?? null
326
- )
327
- }
328
- });
329
- }
330
- }
331
- }
332
- return images;
333
- };
334
- var extractToolCallsFromResponseOutput = (response) => {
335
- const calls = [];
336
- for (const item of response?.output ?? []) {
337
- if (item?.type !== "function_call") continue;
338
- if (!item.call_id || !item.name) continue;
339
- calls.push({
340
- id: item.call_id,
341
- type: "function",
342
- function: {
343
- name: item.name,
344
- arguments: typeof item.arguments === "string" ? item.arguments : JSON.stringify(item.arguments ?? {})
345
- }
346
- });
347
- }
348
- return calls;
349
- };
350
-
351
- // packages/agent-runtime/promptCacheKey.ts
352
- function collectStablePromptPrefix(messages, fallbackPrompt) {
353
- const systemTexts = [];
354
- if (fallbackPrompt?.trim()) systemTexts.push(fallbackPrompt.trim());
355
- for (const raw of messages) {
356
- if (!raw || typeof raw !== "object") continue;
357
- const message = raw;
358
- const role = String(message.role ?? "");
359
- if (role !== "system" && role !== "developer") continue;
360
- if (typeof message.content === "string") {
361
- const boundary = Number(message.stable_prefix_chars);
362
- const text = Number.isFinite(boundary) && boundary > 0 ? message.content.slice(0, boundary) : message.content;
363
- if (text.trim()) systemTexts.push(text.trim());
364
- }
365
- }
366
- return systemTexts.join("\n\n");
367
- }
368
- function stablePromptCacheKey(parts, namespace) {
369
- const value = JSON.stringify(parts);
370
- let hash = 2166136261;
371
- for (let index = 0; index < value.length; index += 1) {
372
- hash ^= value.charCodeAt(index);
373
- hash = Math.imul(hash, 16777619) >>> 0;
374
- }
375
- return `${namespace}-${hash.toString(16).padStart(8, "0")}`;
376
- }
377
-
378
- // packages/core/chat/imageParts.ts
379
- function isImageUrlPart(part) {
380
- return isRecord(part) && part.type === "image_url";
381
- }
382
- function hasImageParts(messages) {
383
- return messages.some(
384
- (message) => Array.isArray(message.content) && message.content.some(isImageUrlPart)
385
- );
386
- }
387
-
388
- export {
389
- isOllamaEndpoint,
390
- getUsageRequestOptions,
391
- isImageUrlPart,
392
- hasImageParts,
393
- preserveAgentStateFields,
394
- toOpenAiCompatibleMessages,
395
- shouldStripReasoningContentForOutbound,
396
- shouldReplayReasoningContentForOutbound,
397
- toResponsesTools,
398
- convertMessagesToResponsesInput,
399
- extractTextFromResponseOutput,
400
- extractReasoningFromResponseOutput,
401
- extractImagePartsFromResponseOutput,
402
- extractToolCallsFromResponseOutput,
403
- collectStablePromptPrefix,
404
- stablePromptCacheKey
405
- };