nolo-cli 0.8.0-alpha.12 → 0.8.0-alpha.14

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 (87) hide show
  1. package/{_executeModel-JOUHEEDS.js → _executeModel-KBMAUV6G.js} +26 -22
  2. package/{action-PAXRPJJF.js → action-SQGI5JY5.js} +5 -4
  3. package/{addContentAction-CZVWF3QZ.js → addContentAction-ZX2PUS3X.js} +4 -3
  4. package/{addDialogAgentAction-CCIDTPHC.js → addDialogAgentAction-ULADQX2Q.js} +3 -2
  5. package/{agentDeleteCommand-TVJH2JID.js → agentDeleteCommand-GNVYHOGZ.js} +11 -8
  6. package/{agentEmailCommands-TB2RKQJL.js → agentEmailCommands-QETL62SU.js} +29 -25
  7. package/{agentListCommands-GVD6ZQ3B.js → agentListCommands-FM4OWXYT.js} +12 -9
  8. package/{agentMachineCommands-UJI6CDKE.js → agentMachineCommands-LDHJBWQO.js} +11 -8
  9. package/{agentRecordCommands-IQBFI3QO.js → agentRecordCommands-UW76EZ25.js} +29 -25
  10. package/{agentRunCommand-VCQ5ONRC.js → agentRunCommand-UFBOW4ZF.js} +33 -26
  11. package/{agentRuntimeLocal-JTCFVEEL.js → agentRuntimeLocal-XL5PLRJV.js} +16 -12
  12. package/{agentSlice-NZMLVXT5.js → agentSlice-2IBSFH4O.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-FUU63UA7.js → chunk-2IRF4LEX.js} +418 -12
  16. package/chunk-3TZDXYSF.js +71 -0
  17. package/chunk-4ZDM73SD.js +34 -0
  18. package/{chunk-TDIQFT2F.js → chunk-5CS33IBL.js} +1 -1
  19. package/{chunk-IYQV26RA.js → chunk-6A3LI5TZ.js} +2 -2
  20. package/{chunk-VEJLAVTC.js → chunk-6CBN7GGH.js} +2 -2
  21. package/{chunk-BSTNFPHD.js → chunk-6XKX2N2E.js} +1 -1
  22. package/{chunk-IEPE5Z7Y.js → chunk-7IPLJUYC.js} +1 -1
  23. package/{chunk-6VTZSYDT.js → chunk-B6DFDN4R.js} +2 -2
  24. package/{chunk-QNCWJXVH.js → chunk-BKPVTIEK.js} +4 -4
  25. package/{chunk-LM25IZBJ.js → chunk-DG7AAAR3.js} +1 -1
  26. package/{chunk-K367HWYT.js → chunk-DGFWICQJ.js} +1 -1
  27. package/chunk-DSNONPGW.js +386 -0
  28. package/{chunk-GH7LOVLY.js → chunk-EQHI2AR3.js} +21 -17
  29. package/{chunk-OF5H3QWS.js → chunk-EXTIQUCI.js} +182 -0
  30. package/chunk-I42VC5KR.js +15 -0
  31. package/{chunk-FY4NQTEC.js → chunk-I6DI7SGU.js} +41 -19
  32. package/chunk-JEXVIMYZ.js +55 -0
  33. package/{chunk-4EPRP7A3.js → chunk-JRPR5M4O.js} +2 -2
  34. package/{chunk-VJEKUYDK.js → chunk-JW43YCM5.js} +1 -1
  35. package/{chunk-GSENGCXB.js → chunk-MMRAIO5Y.js} +3 -3
  36. package/{chunk-AAKR4CKW.js → chunk-MXLQWBVM.js} +1 -88
  37. package/chunk-OPZYGHUC.js +89 -0
  38. package/{chunk-J4576WMJ.js → chunk-PCWC3JTN.js} +1 -1
  39. package/{chunk-6HSAQUHW.js → chunk-PFUCDPUH.js} +19 -20
  40. package/{chunk-HEIIIZBX.js → chunk-Q2YZULBH.js} +1 -1
  41. package/{chunk-6G3WLUY5.js → chunk-QKRUUZCL.js} +6 -6
  42. package/{chunk-IAXBCTTE.js → chunk-QO4YO77G.js} +2 -2
  43. package/{chunk-NDZOFKHS.js → chunk-QTFSBLCF.js} +8 -15
  44. package/{chunk-RAUV2V7X.js → chunk-RJKDVL4L.js} +2 -2
  45. package/{chunk-MTV2I4IF.js → chunk-RLCFUU46.js} +3 -3
  46. package/{chunk-OF6IBT3Z.js → chunk-RTZFUR3V.js} +5 -5
  47. package/{chunk-U5CWPEKM.js → chunk-SACYB45H.js} +19 -378
  48. package/{chunk-PN7AFLOK.js → chunk-SH2CFQOH.js} +3 -13
  49. package/{chunk-CM54RSSA.js → chunk-SL35K7AH.js} +21 -1
  50. package/{chunk-OW6OA65Z.js → chunk-SRLZ7IVA.js} +170 -176
  51. package/{chunk-VEWET5JQ.js → chunk-TWPGVS2U.js} +2 -2
  52. package/{chunk-G5H7RNFL.js → chunk-V2AISYMA.js} +2 -2
  53. package/{chunk-5KDNEBJR.js → chunk-VH4YK6KZ.js} +14 -4
  54. package/{chunk-AUGHVUFE.js → chunk-YYUCRDOK.js} +1 -1
  55. package/{chunk-H2RMRZJE.js → chunk-ZDXZSXYQ.js} +1 -1
  56. package/{chunk-NXZGF7F7.js → chunk-ZQ2UM4KG.js} +1 -1
  57. package/{createAgentAutomationAction-CGYKGZQK.js → createAgentAutomationAction-CSWOQOY5.js} +12 -10
  58. package/{createDialogAction-W34WVXOG.js → createDialogAction-6VWL2TDI.js} +15 -13
  59. package/{createPageAction-BX3BTTBM.js → createPageAction-INRC4MH2.js} +13 -11
  60. package/{dbSlice-C4UJLRZP.js → dbSlice-TO2TSMWM.js} +3 -2
  61. package/{dialogCommands-DS6WHBNJ.js → dialogCommands-DWSE4PMW.js} +13 -10
  62. package/{dialogSlice-3QIHGXBA.js → dialogSlice-CELFVS3F.js} +12 -10
  63. package/{docCreateCommands-X6ACQKZU.js → docCreateCommands-UFJL5PUM.js} +12 -9
  64. package/{docDeleteCommands-NS7VBNDH.js → docDeleteCommands-XHEIBAB2.js} +13 -10
  65. package/{docReadCommands-U5PGIWTF.js → docReadCommands-PEDIC2CW.js} +12 -9
  66. package/{docStore-ZUQS4K5X.js → docStore-Q5AFYT6G.js} +13 -11
  67. package/{docUpdateCommands-MKUDMRFB.js → docUpdateCommands-WBRODQ7P.js} +12 -9
  68. package/{fetchMessages-JOCYIFKL.js → fetchMessages-U6ZHN56A.js} +3 -2
  69. package/{handleSendMessageAction-T4LFZFCM.js → handleSendMessageAction-PPIGKCBQ.js} +12 -10
  70. package/index.js +49 -45
  71. package/{localDialogRead-D3BELSTF.js → localDialogRead-Z5UTAJPU.js} +1 -1
  72. package/{machineCommands-EFFHN5DU.js → machineCommands-3D7JMHUP.js} +28 -24
  73. package/{machineWsRunDispatch-NXBROTNC.js → machineWsRunDispatch-PA5BR4AX.js} +28 -24
  74. package/package.json +1 -1
  75. package/{readlineWorkspace-32SJR27M.js → readlineWorkspace-7WPA5OUS.js} +166 -32
  76. package/{removeDialogAgentAction-CXLST3N6.js → removeDialogAgentAction-3MUQGFZX.js} +5 -4
  77. package/{runAgentClientLoop-AUA4XII6.js → runAgentClientLoop-DRAXPP6R.js} +21 -19
  78. package/{setDialogExtraReferencesAction-LP6VYGU7.js → setDialogExtraReferencesAction-MXHX2HPK.js} +3 -2
  79. package/{setPrimaryDialogAgentAction-D3GGH23T.js → setPrimaryDialogAgentAction-7DLDZHDT.js} +5 -4
  80. package/{settingSlice-J4I3Z5H7.js → settingSlice-PNLASZGI.js} +4 -3
  81. package/{spaceCommands-JLMZTC3V.js → spaceCommands-ORSFAWEY.js} +11 -8
  82. package/{spaceSlice-ECPEQE5G.js → spaceSlice-5F2CDP2O.js} +12 -10
  83. package/{streamAgentChatTurn-5UNGDRXQ.js → streamAgentChatTurn-ROOB5RLM.js} +29 -27
  84. package/{tools-BLAZGXMF.js → tools-BAWXW4F6.js} +19 -17
  85. package/tuiSummaryLlmCaller-JSI4GL6W.js +78 -0
  86. package/{understanding-HCSFPE7R.js → understanding-GQKNDDWM.js} +7 -54
  87. package/{updateDialogTitleAction-Y4SKBCZX.js → updateDialogTitleAction-KJM65IGF.js} +14 -11
@@ -1,29 +1,27 @@
1
+ import {
2
+ applyChatCompletionDelta,
3
+ finalizeAccumulatedToolCalls,
4
+ flushChatCompletionStream,
5
+ readSseFrames,
6
+ throwIfChatCompletionStreamFailed,
7
+ toOpenAiCompatibleMessages
8
+ } from "./chunk-DSNONPGW.js";
9
+ import {
10
+ parseToolArgumentsJson
11
+ } from "./chunk-MXLQWBVM.js";
1
12
  import {
2
13
  createThinkParserState,
3
- extractThinkContent,
4
- flushThinkParser,
5
- parseToolArgumentsJson,
6
- processThinkChunk
7
- } from "./chunk-AAKR4CKW.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
18
+ buildProviderExecutionPlan
21
19
  } from "./chunk-XDVAYP26.js";
22
20
  import {
23
21
  canonicalizeToolName,
24
22
  createGlob,
25
23
  resolveExecutableOnPath
26
- } from "./chunk-LM25IZBJ.js";
24
+ } from "./chunk-DG7AAAR3.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,
@@ -1,3 +1,6 @@
1
+ import {
2
+ asNonEmptyStringArray
3
+ } from "./chunk-I42VC5KR.js";
1
4
  import {
2
5
  asOptionalFiniteNumber
3
6
  } from "./chunk-WWC7I6TA.js";
@@ -2568,17 +2571,6 @@ var require_rambda = __commonJS({
2568
2571
  }
2569
2572
  });
2570
2573
 
2571
- // packages/core/stringArray.ts
2572
- function asNonEmptyStringArray(value) {
2573
- if (!Array.isArray(value)) return [];
2574
- return value.filter(
2575
- (item) => typeof item === "string" && !!item.trim()
2576
- );
2577
- }
2578
- function asTrimmedNonEmptyStringArray(value) {
2579
- return asNonEmptyStringArray(value).map((item) => item.trim());
2580
- }
2581
-
2582
2574
  // packages/core/toTrimmedString.ts
2583
2575
  function toTrimmedString(value) {
2584
2576
  return typeof value === "string" ? value.trim() : value == null ? "" : String(value).trim();
@@ -3351,8 +3343,6 @@ var sanitizeShareData = (data) => {
3351
3343
  };
3352
3344
 
3353
3345
  export {
3354
- asNonEmptyStringArray,
3355
- asTrimmedNonEmptyStringArray,
3356
3346
  require_index_umd,
3357
3347
  ulid,
3358
3348
  toTrimmedString,
@@ -1,3 +1,7 @@
1
+ import {
2
+ MEMORY_USE_GUIDANCE
3
+ } from "./chunk-KKY4B2Q2.js";
4
+
1
5
  // packages/agent-runtime/modelLayerOverride.ts
2
6
  var MODEL_LAYER_KEYS = [
3
7
  "provider",
@@ -196,11 +200,27 @@ var buildLinkedSpacesSection = async (args) => {
196
200
  "\u63D0\u793A\uFF1A\u5982\u9700\u67E5\u8BE2\u8FD9\u4E9B\u7A7A\u95F4\u7684\u8BE6\u7EC6\u5185\u5BB9\uFF0C\u53EF\u4F7F\u7528 read \u5DE5\u5177\u914D\u5408\u5BF9\u5E94\u7684 dbKey\u3002"
197
201
  ].join("\n");
198
202
  };
203
+ var buildMemoryOverlayLayer = (args) => {
204
+ const promptBlock = asTrimmed(args.promptBlock);
205
+ if (!promptBlock) return null;
206
+ return makeLayer("memory-overlay", promptBlock);
207
+ };
208
+ var buildMemoryUseGuidanceLayer = (args) => {
209
+ const promptBlock = asTrimmed(args.promptBlock);
210
+ if (!promptBlock) return null;
211
+ return makeLayer(
212
+ "memory-use-guidance",
213
+ MEMORY_USE_GUIDANCE,
214
+ "session"
215
+ );
216
+ };
199
217
 
200
218
  export {
201
219
  buildModelLayerOverride,
202
220
  applyModelLayerOverride,
203
221
  buildSpaceContextLayer,
204
222
  buildSkillDiscoveryLayer,
205
- buildLinkedSpacesSection
223
+ buildLinkedSpacesSection,
224
+ buildMemoryOverlayLayer,
225
+ buildMemoryUseGuidanceLayer
206
226
  };