nolo-cli 0.14.0-alpha.9 → 0.15.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 (92) hide show
  1. package/{_executeModel-OQ6KPFSB.js → _executeModel-QAUS6B7J.js} +24 -24
  2. package/{action-N3KXFO5V.js → action-GUOZYYGN.js} +4 -4
  3. package/{addContentAction-4Z762DMR.js → addContentAction-QDGHGUBH.js} +3 -3
  4. package/{addDialogAgentAction-FALLEKPR.js → addDialogAgentAction-Z4YCYZIV.js} +2 -2
  5. package/{agentDeleteCommand-UBXH2FDO.js → agentDeleteCommand-QDO62EZA.js} +20 -20
  6. package/{agentEmailCommands-ZI2FIUBV.js → agentEmailCommands-UZ5BKX3P.js} +37 -37
  7. package/{agentListCommands-7M6FHCSH.js → agentListCommands-ZC33UDWT.js} +22 -22
  8. package/{agentMachineCommands-R3FW62QH.js → agentMachineCommands-RZGZEZRL.js} +20 -20
  9. package/{agentRecordCommands-WUY3C3HZ.js → agentRecordCommands-DGDXE2VH.js} +32 -32
  10. package/{agentRunCommand-CWXYVYPZ.js → agentRunCommand-SRZWFOPH.js} +34 -34
  11. package/{agentRuntimeLocal-BONMVACL.js → agentRuntimeLocal-4YCF6IRF.js} +11 -11
  12. package/{agentSlice-IHOSTSWC.js → agentSlice-IVE735EV.js} +3 -3
  13. package/appDeleteCommands-7I26L64I.js +124 -0
  14. package/appDeployCommands-TZLZNTJN.js +163 -0
  15. package/appDeployStatusCommands-OPPTLHRW.js +144 -0
  16. package/appGetCommands-N2S4HYKY.js +119 -0
  17. package/appListCommands-OBTPPKUM.js +122 -0
  18. package/{authCommand-IKIU4FZY.js → authCommand-YFTR3347.js} +5 -5
  19. package/{authCommands-QP43ADV3.js → authCommands-YXGOXNBZ.js} +3 -3
  20. package/{chunk-3B2LFO6R.js → browser-image-compression-MFDTD7K6.js} +4 -518
  21. package/{chunk-YQAG2J2T.js → chunk-472E5RMQ.js} +1 -1
  22. package/chunk-4QQFLN5C.js +552 -0
  23. package/{chunk-SZ7RUWAQ.js → chunk-5VMYGIIL.js} +97 -38
  24. package/{chunk-P6DRYHVM.js → chunk-6565R2TI.js} +16 -14
  25. package/{chunk-2ROIXEDX.js → chunk-6MHDWKOT.js} +2 -2
  26. package/{chunk-GGHFCK3X.js → chunk-AWDOJBHW.js} +426 -430
  27. package/{chunk-DUE6E46E.js → chunk-BFRVXJJJ.js} +43 -16
  28. package/{chunk-UONU6Q4P.js → chunk-G2MKOQCB.js} +1 -1
  29. package/chunk-GFUIQ4RY.js +136 -0
  30. package/{chunk-SRKNB2WB.js → chunk-HRQCKQA5.js} +4 -4
  31. package/{chunk-CDQ2ICPR.js → chunk-IOQ7IBPU.js} +1 -1
  32. package/{chunk-QLO2G5HP.js → chunk-ISYE6GZB.js} +1 -1
  33. package/{chunk-CXLGUR7M.js → chunk-IZ2QRVEU.js} +2 -2
  34. package/{chunk-U4J6ZZFY.js → chunk-JBKVPAYK.js} +7 -140
  35. package/{chunk-V6VXDXGY.js → chunk-JS33TCQ3.js} +2 -2
  36. package/{chunk-YG3CCS7C.js → chunk-K53477EY.js} +4 -4
  37. package/{chunk-3WGLLTK4.js → chunk-LSFAWXKC.js} +100 -3
  38. package/{chunk-BHK5ZAW7.js → chunk-N5424GSW.js} +1 -1
  39. package/chunk-NTC6I2FN.js +107 -0
  40. package/{chunk-QNXEDF7V.js → chunk-O53CP2QR.js} +3 -3
  41. package/{chunk-CY4TAX6S.js → chunk-OKSYPTDZ.js} +9 -9
  42. package/{chunk-NFHGY5T5.js → chunk-OQMPU2ML.js} +4 -4
  43. package/{chunk-NSZB7BYV.js → chunk-P4MJQWWF.js} +2 -2
  44. package/{chunk-JHFMRUGX.js → chunk-RKM3K52F.js} +1 -1
  45. package/{chunk-A5V7UEZJ.js → chunk-SFXYKGK2.js} +3 -3
  46. package/{chunk-S5UACFUP.js → chunk-TTGAVETO.js} +10 -2
  47. package/{chunk-BOJVWKNA.js → chunk-U7LEGLEB.js} +1 -1
  48. package/{chunk-YDOTMXTK.js → chunk-UXKQQ2MR.js} +9 -9
  49. package/{chunk-KUDUXBNE.js → chunk-VE6XMVKG.js} +189 -41
  50. package/{chunk-NJVPXLRY.js → chunk-VPTJB4HM.js} +1 -1
  51. package/{chunk-3AE4NQ5O.js → chunk-WA6KZL5V.js} +25 -6
  52. package/{chunk-T3X232L6.js → chunk-WNLPAOIT.js} +1 -1
  53. package/{chunk-MEXNTURY.js → chunk-WRN5EQT7.js} +1 -1
  54. package/{chunk-FVGJNXPJ.js → chunk-XGQZFBO5.js} +83 -206
  55. package/{chunk-3FCSMQAC.js → chunk-XVP3C2KY.js} +1 -1
  56. package/{chunk-SW3Q2OV5.js → chunk-YNHQIXX5.js} +774 -5735
  57. package/{chunk-7VKJDLPO.js → chunk-Z24FGIU2.js} +2 -2
  58. package/{createAgentAutomationAction-W4OZQ63I.js → createAgentAutomationAction-TS6NNZ4X.js} +9 -9
  59. package/{createDialogAction-G6XQLPAN.js → createDialogAction-5HVQ33EX.js} +10 -10
  60. package/{createPageAction-RNT4LCAX.js → createPageAction-4F3ZGQJD.js} +9 -9
  61. package/{dbSlice-7Q23HSWH.js → dbSlice-OP6UPXKA.js} +2 -2
  62. package/{dialogCommands-YUTOCICO.js → dialogCommands-3GEPXHFB.js} +16 -16
  63. package/{dialogSlice-QZZF4JXD.js → dialogSlice-FAWUQDJW.js} +9 -9
  64. package/{docCreateCommands-LQYOVE7D.js → docCreateCommands-ZE3S6BCP.js} +22 -20
  65. package/{docDeleteCommands-LNS5V76K.js → docDeleteCommands-TW6PGTRT.js} +21 -19
  66. package/{docReadCommands-IRCP66BG.js → docReadCommands-LDXL3B6J.js} +20 -18
  67. package/{docStore-66Q4JTTG.js → docStore-2UHVWLTV.js} +10 -10
  68. package/{docUpdateCommands-4VUX3Q7W.js → docUpdateCommands-GYD6XI5O.js} +21 -19
  69. package/{handleSendMessageAction-CB5UKK2X.js → handleSendMessageAction-LJPUYNOH.js} +9 -9
  70. package/index.js +92 -61
  71. package/{machineCommands-PX2BADIB.js → machineCommands-OKNDYS3M.js} +35 -35
  72. package/{machineWsRunDispatch-IBNCRCEQ.js → machineWsRunDispatch-ZX5AJ6FJ.js} +31 -31
  73. package/package.json +1 -1
  74. package/{read-SIWMJRHC.js → read-HXHAZBKH.js} +1 -1
  75. package/{readDocTool-TCYJY4PP.js → readDocTool-VPBDTO4G.js} +1 -1
  76. package/{readlineWorkspace-YIXJ2OOO.js → readlineWorkspace-MB3ANKHM.js} +92 -92
  77. package/{removeDialogAgentAction-WKHZT6VJ.js → removeDialogAgentAction-HUFVN35S.js} +4 -4
  78. package/{runAgentClientLoop-BXMDAQB2.js → runAgentClientLoop-A75BUU6D.js} +19 -19
  79. package/{setDialogExtraReferencesAction-GCI5QU6E.js → setDialogExtraReferencesAction-2VLGWQKG.js} +2 -2
  80. package/{setPrimaryDialogAgentAction-NRO57AS6.js → setPrimaryDialogAgentAction-VB4UV2CC.js} +4 -4
  81. package/{settingSlice-FTWZ5ZHT.js → settingSlice-7JYPQNAC.js} +3 -3
  82. package/{spaceCommands-7Z6DZFEE.js → spaceCommands-O3KJNCON.js} +21 -21
  83. package/{spaceSlice-3GLIRD3Q.js → spaceSlice-444MFUP6.js} +9 -9
  84. package/{streamAgentChatTurn-SN7YS2VV.js → streamAgentChatTurn-DJAE7USZ.js} +42 -39
  85. package/{tools-4JSNWHIK.js → tools-YB6LXSVN.js} +14 -14
  86. package/{tuiSummaryLlmCaller-PS5BDLHV.js → tuiSummaryLlmCaller-QQL3JA5I.js} +3 -3
  87. package/{updateDialogTitleAction-DUJ2JZXX.js → updateDialogTitleAction-6HGFBM64.js} +9 -9
  88. package/{agentGrantCommands-JMTM6U4B.js → agentGrantCommands-JNDE4RWR.js} +1 -1
  89. package/{agentPullCommand-UXANSFU3.js → agentPullCommand-6HWUT3SW.js} +1 -1
  90. package/{chunk-3QAF2LTL.js → chunk-DZ3XJVET.js} +3 -3
  91. package/{chunk-HBRZXXP5.js → chunk-KMQPSTMJ.js} +6 -6
  92. package/{tableCommands-V5O7QMXY.js → tableCommands-3P7MJ3PF.js} +3 -3
@@ -5,13 +5,10 @@ import {
5
5
  inlineImageUrlsForCustomProvider,
6
6
  prepareTools,
7
7
  shouldInlineImageUrlsForAgent
8
- } from "./chunk-MEXNTURY.js";
8
+ } from "./chunk-WRN5EQT7.js";
9
9
  import {
10
10
  performFetchRequest
11
- } from "./chunk-P6DRYHVM.js";
12
- import {
13
- getPublicImageAgentMode
14
- } from "./chunk-VIDPVFP3.js";
11
+ } from "./chunk-6565R2TI.js";
15
12
  import {
16
13
  createSSEParser,
17
14
  createToolRunId,
@@ -22,29 +19,35 @@ import {
22
19
  toolRunSetPending,
23
20
  toolRunStarted,
24
21
  toolRunSucceeded
25
- } from "./chunk-KUDUXBNE.js";
22
+ } from "./chunk-VE6XMVKG.js";
23
+ import {
24
+ getPublicImageAgentMode
25
+ } from "./chunk-VIDPVFP3.js";
26
26
  import {
27
27
  addToolMessage,
28
28
  messageStreamEnd,
29
29
  messageStreaming,
30
30
  selectCurrentSpaceId,
31
31
  updateToolMessage
32
- } from "./chunk-SW3Q2OV5.js";
32
+ } from "./chunk-YNHQIXX5.js";
33
33
  import {
34
34
  streamAgentChatTurn
35
- } from "./chunk-NFHGY5T5.js";
35
+ } from "./chunk-OQMPU2ML.js";
36
36
  import {
37
37
  EMPTY_ASSISTANT_REPAIR_PROMPT
38
- } from "./chunk-2ROIXEDX.js";
38
+ } from "./chunk-6MHDWKOT.js";
39
39
  import {
40
40
  accumulateToolCallDelta,
41
41
  createThinkParserState,
42
+ createToolCallTextParserState,
42
43
  flushThinkParser,
44
+ flushToolCallTextParserIntoCallback,
45
+ processContentChunkWithToolCallStripping,
43
46
  processThinkChunk
44
- } from "./chunk-3WGLLTK4.js";
47
+ } from "./chunk-LSFAWXKC.js";
45
48
  import {
46
49
  getModelInfo
47
- } from "./chunk-3B2LFO6R.js";
50
+ } from "./chunk-4QQFLN5C.js";
48
51
  import {
49
52
  getApiEndpoint
50
53
  } from "./chunk-OGGHETUE.js";
@@ -61,10 +64,10 @@ import {
61
64
  } from "./chunk-HNMXYYJR.js";
62
65
  import {
63
66
  selectCurrentServer
64
- } from "./chunk-S5UACFUP.js";
67
+ } from "./chunk-TTGAVETO.js";
65
68
  import {
66
69
  write
67
- } from "./chunk-A5V7UEZJ.js";
70
+ } from "./chunk-SFXYKGK2.js";
68
71
  import {
69
72
  createDialogMessageKeyAndId,
70
73
  dialogMessageKey,
@@ -1105,6 +1108,7 @@ function createInitialStreamState() {
1105
1108
  accumulatedToolCalls: [],
1106
1109
  reasoningBuffer: "",
1107
1110
  thinkState: createThinkParserState(),
1111
+ toolCallTextState: createToolCallTextParserState(),
1108
1112
  assistantToolCalls: void 0,
1109
1113
  hasHandedOff: false,
1110
1114
  hasProcessedToolCalls: false,
@@ -1248,7 +1252,19 @@ function applyDelta(state, delta) {
1248
1252
  }
1249
1253
  const contentChunk = delta.content || "";
1250
1254
  if (contentChunk) {
1251
- const parsed = processThinkChunk(contentChunk, next.thinkState);
1255
+ const { cleanedContent, state: tcState } = processContentChunkWithToolCallStripping(
1256
+ contentChunk,
1257
+ next.toolCallTextState,
1258
+ (name, arguments_) => {
1259
+ next.accumulatedToolCalls = accumulateToolCallChunks(
1260
+ next.accumulatedToolCalls ?? [],
1261
+ [{ index: next.accumulatedToolCalls.length, type: "function", function: { name, arguments: arguments_ } }]
1262
+ );
1263
+ }
1264
+ );
1265
+ next.toolCallTextState = tcState;
1266
+ if (!cleanedContent) return { state: next, hasNewVisibleContent };
1267
+ const parsed = processThinkChunk(cleanedContent, next.thinkState);
1252
1268
  next.thinkState = parsed.state;
1253
1269
  if (parsed.reasoning) {
1254
1270
  next.reasoningBuffer = (next.reasoningBuffer || "") + parsed.reasoning;
@@ -1438,15 +1454,26 @@ async function readStreamChunkWithTimeout(reader, signal) {
1438
1454
  async function handleStreamCompletion(state, ctx, finalizeCtx) {
1439
1455
  let hasHandedOff = false;
1440
1456
  let hasPendingInteraction = false;
1457
+ const { residualContent, state: tcFlushState } = flushToolCallTextParserIntoCallback(
1458
+ state.toolCallTextState,
1459
+ (name, arguments_) => {
1460
+ state.accumulatedToolCalls = accumulateToolCallChunks(
1461
+ state.accumulatedToolCalls ?? [],
1462
+ [{ index: state.accumulatedToolCalls.length, type: "function", function: { name, arguments: arguments_ } }]
1463
+ );
1464
+ }
1465
+ );
1466
+ state.toolCallTextState = tcFlushState;
1441
1467
  const flushed = flushThinkParser(state.thinkState);
1442
1468
  state.thinkState = flushed.state;
1443
1469
  if (flushed.reasoning) {
1444
1470
  state.reasoningBuffer = (state.reasoningBuffer || "") + flushed.reasoning;
1445
1471
  }
1446
- if (flushed.content) {
1472
+ const combinedFlushContent = residualContent + (flushed.content ?? "");
1473
+ if (combinedFlushContent) {
1447
1474
  state = {
1448
1475
  ...state,
1449
- contentBuffer: appendTextChunk(state.contentBuffer, flushed.content)
1476
+ contentBuffer: appendTextChunk(state.contentBuffer, combinedFlushContent)
1450
1477
  };
1451
1478
  }
1452
1479
  if (!state.hasProcessedToolCalls && state.accumulatedToolCalls.length > 0) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-P6DRYHVM.js";
4
+ } from "./chunk-6565R2TI.js";
5
5
 
6
6
  // packages/ai/agent/fetchAgentContexts.ts
7
7
  async function fetchAgentContexts(references, dispatch) {
@@ -0,0 +1,136 @@
1
+ import {
2
+ buildSkillDocMarkdown
3
+ } from "./chunk-VC6OZXO5.js";
4
+
5
+ // packages/cli/docPageHelpers.ts
6
+ import { readFileSync } from "node:fs";
7
+ import { ulid } from "ulid";
8
+ function getCliArg(args, flag) {
9
+ const idx = args.indexOf(flag);
10
+ return idx !== -1 ? args[idx + 1] : void 0;
11
+ }
12
+ function readBodyArg(args, fallback = "") {
13
+ const bodyFile = getCliArg(args, "--body-file");
14
+ if (bodyFile !== void 0) {
15
+ return readFileSync(bodyFile, "utf8");
16
+ }
17
+ return getCliArg(args, "--body") ?? fallback;
18
+ }
19
+ function textToSlate(text) {
20
+ return text.split("\n").map((line) => ({
21
+ type: "paragraph",
22
+ children: [{ text: line }]
23
+ }));
24
+ }
25
+ function createPageId() {
26
+ return ulid();
27
+ }
28
+ function buildPageKey(userId, pageId) {
29
+ return `page-${userId}-${pageId}`;
30
+ }
31
+ function buildPageRecord(args) {
32
+ const { dbKey, pageId, title, spaceId, content, existing, meta, slateData } = args;
33
+ const now = Date.now();
34
+ const createdAt = typeof existing?.createdAt === "number" ? existing.createdAt : now;
35
+ const created = typeof existing?.created === "string" ? existing.created : new Date(createdAt).toISOString();
36
+ const nextRecord = {
37
+ ...existing ?? {},
38
+ id: existing?.id ?? pageId,
39
+ dbKey,
40
+ type: "page",
41
+ title,
42
+ spaceId,
43
+ content,
44
+ updatedAt: now,
45
+ createdAt,
46
+ created
47
+ };
48
+ if (meta !== void 0) {
49
+ if (meta === null) {
50
+ delete nextRecord.meta;
51
+ } else {
52
+ nextRecord.meta = meta;
53
+ }
54
+ }
55
+ if (slateData !== void 0) {
56
+ if (slateData === null) {
57
+ delete nextRecord.slateData;
58
+ } else {
59
+ nextRecord.slateData = slateData;
60
+ }
61
+ } else if (!existing?.slateData) {
62
+ nextRecord.slateData = textToSlate(content);
63
+ }
64
+ return nextRecord;
65
+ }
66
+
67
+ // packages/cli/docSkillHelpers.ts
68
+ function normalizeSkillSeed(input) {
69
+ return input.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/g, "-").replace(/^-+|-+$/g, "");
70
+ }
71
+ function deterministicId(prefix, seed) {
72
+ let h = 2166136261;
73
+ for (let i = 0; i < seed.length; i++) {
74
+ h ^= seed.charCodeAt(i);
75
+ h = h * 16777619 >>> 0;
76
+ }
77
+ const suffix = h.toString(36).toUpperCase().padStart(14, "0");
78
+ return (prefix + suffix).slice(0, 26);
79
+ }
80
+ function buildSkillDocId(input) {
81
+ return deterministicId("01SK", normalizeSkillSeed(input) || input);
82
+ }
83
+ function buildSkillPageKey(userId, skillId) {
84
+ return buildPageKey(userId, skillId);
85
+ }
86
+ function buildSkillPageRecord(args) {
87
+ const {
88
+ dbKey,
89
+ skillId,
90
+ title,
91
+ spaceId,
92
+ body,
93
+ skillConfig,
94
+ evalConfig,
95
+ workflowConfig,
96
+ existing
97
+ } = args;
98
+ return {
99
+ ...buildPageRecord({
100
+ dbKey,
101
+ pageId: skillId,
102
+ title,
103
+ spaceId,
104
+ content: buildSkillDocMarkdown({
105
+ body,
106
+ skillConfig,
107
+ evalConfig,
108
+ workflowConfig
109
+ }),
110
+ existing,
111
+ meta: {
112
+ ...existing?.meta ?? {},
113
+ kind: "skill",
114
+ skillConfig,
115
+ ...evalConfig ? { evalConfig } : {},
116
+ ...workflowConfig ? { workflowConfig } : {}
117
+ },
118
+ slateData: null
119
+ })
120
+ };
121
+ }
122
+ function parseJsonArg(raw, fallback) {
123
+ if (raw === void 0) return fallback;
124
+ return JSON.parse(raw);
125
+ }
126
+
127
+ export {
128
+ readBodyArg,
129
+ createPageId,
130
+ buildPageKey,
131
+ buildPageRecord,
132
+ buildSkillDocId,
133
+ buildSkillPageKey,
134
+ buildSkillPageRecord,
135
+ parseJsonArg
136
+ };
@@ -345,10 +345,10 @@ async function buildProviderExecutionPlan(args) {
345
345
  }
346
346
 
347
347
  // packages/agent-runtime/openAiCompatibleMessages.ts
348
- function preserveAgentStateFields(source, target) {
348
+ function preserveAgentStateFields(source, target, options) {
349
349
  const mutableTarget = target;
350
350
  if (source.role === "assistant") {
351
- if (typeof source.reasoning_content === "string") {
351
+ if (!options?.stripReasoningContent && typeof source.reasoning_content === "string") {
352
352
  mutableTarget.reasoning_content = source.reasoning_content;
353
353
  }
354
354
  if (Array.isArray(source.tool_calls)) {
@@ -361,12 +361,12 @@ function preserveAgentStateFields(source, target) {
361
361
  }
362
362
  return target;
363
363
  }
364
- function toOpenAiCompatibleMessages(messages) {
364
+ function toOpenAiCompatibleMessages(messages, options) {
365
365
  return messages.map(
366
366
  (message) => preserveAgentStateFields(message, {
367
367
  role: message.role,
368
368
  content: message.content ?? ""
369
- })
369
+ }, options)
370
370
  );
371
371
  }
372
372
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildAgentRuntimeAgentLookupKeys,
3
3
  shouldFetchAgentRuntimeRecordRemotely
4
- } from "./chunk-SZ7RUWAQ.js";
4
+ } from "./chunk-5VMYGIIL.js";
5
5
 
6
6
  // packages/cli/client/localAgentRecords.ts
7
7
  var buildLocalAgentLookupKeys = buildAgentRuntimeAgentLookupKeys;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  trimTrailingSlash
3
- } from "./chunk-SRKNB2WB.js";
3
+ } from "./chunk-HRQCKQA5.js";
4
4
  import {
5
5
  asTrimmedLowercaseString
6
6
  } from "./chunk-QSJ3HFEF.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  listUserRecordsFromServers,
3
3
  readLiveDbRecordAfterTombstoneMerge
4
- } from "./chunk-YQAG2J2T.js";
4
+ } from "./chunk-472E5RMQ.js";
5
5
  import {
6
6
  agentRecordHasConfiguredCredential
7
- } from "./chunk-YG3CCS7C.js";
7
+ } from "./chunk-K53477EY.js";
8
8
  import {
9
9
  toSafeAgentSummary
10
10
  } from "./chunk-OOIN7HSO.js";
@@ -1,25 +1,22 @@
1
1
  import {
2
2
  readDbRecord,
3
3
  writeAgentRecord
4
- } from "./chunk-YG3CCS7C.js";
4
+ } from "./chunk-K53477EY.js";
5
5
  import {
6
6
  buildSkillSummaryMarker
7
7
  } from "./chunk-VF4K2QE6.js";
8
- import {
9
- buildSkillDocMarkdown
10
- } from "./chunk-VC6OZXO5.js";
11
- import {
12
- createSpaceKey
13
- } from "./chunk-3FCSMQAC.js";
14
- import {
15
- asTrimmedLowercaseString
16
- } from "./chunk-QSJ3HFEF.js";
17
8
  import {
18
9
  parseUserIdFromAuthToken,
19
10
  readOption,
20
11
  resolveAuthToken,
21
12
  resolveServerUrl
22
13
  } from "./chunk-A7GB5UGH.js";
14
+ import {
15
+ createSpaceKey
16
+ } from "./chunk-XVP3C2KY.js";
17
+ import {
18
+ asTrimmedLowercaseString
19
+ } from "./chunk-QSJ3HFEF.js";
23
20
  import {
24
21
  NOLO_CLUSTER_SERVERS
25
22
  } from "./chunk-LCBAMY2M.js";
@@ -30,128 +27,6 @@ import {
30
27
  normalizeServerOrigin
31
28
  } from "./chunk-CF7PE763.js";
32
29
 
33
- // packages/cli/docPageHelpers.ts
34
- import { readFileSync } from "node:fs";
35
- import { ulid } from "ulid";
36
- function getCliArg(args, flag) {
37
- const idx = args.indexOf(flag);
38
- return idx !== -1 ? args[idx + 1] : void 0;
39
- }
40
- function readBodyArg(args, fallback = "") {
41
- const bodyFile = getCliArg(args, "--body-file");
42
- if (bodyFile !== void 0) {
43
- return readFileSync(bodyFile, "utf8");
44
- }
45
- return getCliArg(args, "--body") ?? fallback;
46
- }
47
- function textToSlate(text) {
48
- return text.split("\n").map((line) => ({
49
- type: "paragraph",
50
- children: [{ text: line }]
51
- }));
52
- }
53
- function createPageId() {
54
- return ulid();
55
- }
56
- function buildPageKey(userId, pageId) {
57
- return `page-${userId}-${pageId}`;
58
- }
59
- function buildPageRecord(args) {
60
- const { dbKey, pageId, title, spaceId, content, existing, meta, slateData } = args;
61
- const now = Date.now();
62
- const createdAt = typeof existing?.createdAt === "number" ? existing.createdAt : now;
63
- const created = typeof existing?.created === "string" ? existing.created : new Date(createdAt).toISOString();
64
- const nextRecord = {
65
- ...existing ?? {},
66
- id: existing?.id ?? pageId,
67
- dbKey,
68
- type: "page",
69
- title,
70
- spaceId,
71
- content,
72
- updatedAt: now,
73
- createdAt,
74
- created
75
- };
76
- if (meta !== void 0) {
77
- if (meta === null) {
78
- delete nextRecord.meta;
79
- } else {
80
- nextRecord.meta = meta;
81
- }
82
- }
83
- if (slateData !== void 0) {
84
- if (slateData === null) {
85
- delete nextRecord.slateData;
86
- } else {
87
- nextRecord.slateData = slateData;
88
- }
89
- } else if (!existing?.slateData) {
90
- nextRecord.slateData = textToSlate(content);
91
- }
92
- return nextRecord;
93
- }
94
-
95
- // packages/cli/docSkillHelpers.ts
96
- function normalizeSkillSeed(input) {
97
- return input.trim().toLowerCase().replace(/[^a-z0-9\u4e00-\u9fa5]+/g, "-").replace(/^-+|-+$/g, "");
98
- }
99
- function deterministicId(prefix, seed) {
100
- let h = 2166136261;
101
- for (let i = 0; i < seed.length; i++) {
102
- h ^= seed.charCodeAt(i);
103
- h = h * 16777619 >>> 0;
104
- }
105
- const suffix = h.toString(36).toUpperCase().padStart(14, "0");
106
- return (prefix + suffix).slice(0, 26);
107
- }
108
- function buildSkillDocId(input) {
109
- return deterministicId("01SK", normalizeSkillSeed(input) || input);
110
- }
111
- function buildSkillPageKey(userId, skillId) {
112
- return buildPageKey(userId, skillId);
113
- }
114
- function buildSkillPageRecord(args) {
115
- const {
116
- dbKey,
117
- skillId,
118
- title,
119
- spaceId,
120
- body,
121
- skillConfig,
122
- evalConfig,
123
- workflowConfig,
124
- existing
125
- } = args;
126
- return {
127
- ...buildPageRecord({
128
- dbKey,
129
- pageId: skillId,
130
- title,
131
- spaceId,
132
- content: buildSkillDocMarkdown({
133
- body,
134
- skillConfig,
135
- evalConfig,
136
- workflowConfig
137
- }),
138
- existing,
139
- meta: {
140
- ...existing?.meta ?? {},
141
- kind: "skill",
142
- skillConfig,
143
- ...evalConfig ? { evalConfig } : {},
144
- ...workflowConfig ? { workflowConfig } : {}
145
- },
146
- slateData: null
147
- })
148
- };
149
- }
150
- function parseJsonArg(raw, fallback) {
151
- if (raw === void 0) return fallback;
152
- return JSON.parse(raw);
153
- }
154
-
155
30
  // packages/cli/docSpaceHelpers.ts
156
31
  async function ensurePageAttachedToSpace(params) {
157
32
  const { baseUrl, userId, authToken, spaceId, contentKey, title, skillSummary } = params;
@@ -333,14 +208,6 @@ function buildSkillSummaryForRecord(record) {
333
208
  }
334
209
 
335
210
  export {
336
- readBodyArg,
337
- createPageId,
338
- buildPageKey,
339
- buildPageRecord,
340
- buildSkillDocId,
341
- buildSkillPageKey,
342
- buildSkillPageRecord,
343
- parseJsonArg,
344
211
  removePageFromSpace,
345
212
  hasHelpArg,
346
213
  hasFlag,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  selectCurrentServer
3
- } from "./chunk-S5UACFUP.js";
3
+ } from "./chunk-TTGAVETO.js";
4
4
  import {
5
5
  patch
6
- } from "./chunk-A5V7UEZJ.js";
6
+ } from "./chunk-SFXYKGK2.js";
7
7
  import {
8
8
  selectIdentityToken
9
9
  } from "./chunk-DVRHHFEA.js";
@@ -2,7 +2,7 @@ import {
2
2
  buildLocalAgentLookupKeys,
3
3
  normalizeAgentHandle,
4
4
  shouldReadAgentKeyRemotely
5
- } from "./chunk-CDQ2ICPR.js";
5
+ } from "./chunk-IOQ7IBPU.js";
6
6
  import {
7
7
  resolveCliAgentKeyInput
8
8
  } from "./chunk-VHBWHNVT.js";
@@ -13,9 +13,6 @@ import {
13
13
  readPipeText,
14
14
  spawnProcess
15
15
  } from "./chunk-IDZTNRP2.js";
16
- import {
17
- createAgentKey
18
- } from "./chunk-O4BU24WZ.js";
19
16
  import {
20
17
  parseUserIdFromAuthToken,
21
18
  readOption,
@@ -23,6 +20,9 @@ import {
23
20
  resolveServerCandidates,
24
21
  resolveServerUrl
25
22
  } from "./chunk-A7GB5UGH.js";
23
+ import {
24
+ createAgentKey
25
+ } from "./chunk-O4BU24WZ.js";
26
26
 
27
27
  // packages/cli/agentRecordHelpers.ts
28
28
  import { readFileSync } from "node:fs";
@@ -1,6 +1,4 @@
1
- // packages/agent-runtime/thinkTagParser.ts
2
- var OPEN_TAG = "<think>";
3
- var CLOSE_TAG = "</think>";
1
+ // packages/agent-runtime/tagPrefixMatch.ts
4
2
  function longestTagPrefixLength(buffer, tag) {
5
3
  const max = Math.min(buffer.length, tag.length - 1);
6
4
  for (let len = max; len > 0; len--) {
@@ -10,6 +8,10 @@ function longestTagPrefixLength(buffer, tag) {
10
8
  }
11
9
  return 0;
12
10
  }
11
+
12
+ // packages/agent-runtime/thinkTagParser.ts
13
+ var OPEN_TAG = "<think>";
14
+ var CLOSE_TAG = "</think>";
13
15
  function extractThinkContent(content) {
14
16
  const regex = new RegExp(`${OPEN_TAG}([\\s\\S]*?)${CLOSE_TAG}`, "g");
15
17
  const matches = [...content.matchAll(regex)];
@@ -81,6 +83,98 @@ function flushThinkParser(state) {
81
83
  };
82
84
  }
83
85
 
86
+ // packages/agent-runtime/toolCallTextParser.ts
87
+ var OPEN_TAG2 = "<tool_call>";
88
+ var CLOSE_TAG2 = "</tool_call>";
89
+ function createToolCallTextParserState() {
90
+ return { mode: "content", buffer: "" };
91
+ }
92
+ function processToolCallTextChunk(chunk, state) {
93
+ let visible = "";
94
+ let toolCallTexts = [];
95
+ let { mode, buffer } = state;
96
+ buffer += chunk;
97
+ while (true) {
98
+ if (mode === "content") {
99
+ const idx = buffer.indexOf(OPEN_TAG2);
100
+ if (idx === -1) {
101
+ const keep = longestTagPrefixLength(buffer, OPEN_TAG2);
102
+ visible += buffer.slice(0, buffer.length - keep);
103
+ buffer = buffer.slice(buffer.length - keep);
104
+ break;
105
+ }
106
+ visible += buffer.slice(0, idx);
107
+ buffer = buffer.slice(idx + OPEN_TAG2.length);
108
+ mode = "toolcall";
109
+ } else {
110
+ const idx = buffer.indexOf(CLOSE_TAG2);
111
+ if (idx === -1) {
112
+ break;
113
+ }
114
+ toolCallTexts.push(buffer.slice(0, idx));
115
+ buffer = buffer.slice(idx + CLOSE_TAG2.length);
116
+ mode = "content";
117
+ }
118
+ }
119
+ return {
120
+ content: visible,
121
+ toolCallTexts,
122
+ state: { mode, buffer }
123
+ };
124
+ }
125
+ function flushToolCallTextParser(state) {
126
+ const { mode, buffer } = state;
127
+ if (mode === "toolcall") {
128
+ const keep = longestTagPrefixLength(buffer, CLOSE_TAG2);
129
+ const text = buffer.slice(0, buffer.length - keep);
130
+ return {
131
+ content: "",
132
+ toolCallTexts: text ? [text] : [],
133
+ state: { mode: "content", buffer: "" }
134
+ };
135
+ }
136
+ return {
137
+ content: buffer,
138
+ toolCallTexts: [],
139
+ state: { mode: "content", buffer: "" }
140
+ };
141
+ }
142
+ function tryParseToolCallText(text) {
143
+ const trimmed = text.trim();
144
+ if (!trimmed) return null;
145
+ try {
146
+ const parsed = JSON.parse(trimmed);
147
+ if (typeof parsed === "object" && parsed !== null && typeof parsed.name === "string") {
148
+ return {
149
+ name: parsed.name,
150
+ arguments: typeof parsed.arguments === "string" ? parsed.arguments : JSON.stringify(parsed.arguments ?? {})
151
+ };
152
+ }
153
+ } catch {
154
+ }
155
+ return null;
156
+ }
157
+ function processContentChunkWithToolCallStripping(chunk, state, onToolCall) {
158
+ const stripped = processToolCallTextChunk(chunk, state);
159
+ for (const text of stripped.toolCallTexts) {
160
+ const parsedTc = tryParseToolCallText(text);
161
+ if (parsedTc) {
162
+ onToolCall(parsedTc.name, parsedTc.arguments);
163
+ }
164
+ }
165
+ return { cleanedContent: stripped.content, state: stripped.state };
166
+ }
167
+ function flushToolCallTextParserIntoCallback(state, onToolCall) {
168
+ const flushed = flushToolCallTextParser(state);
169
+ for (const text of flushed.toolCallTexts) {
170
+ const parsedTc = tryParseToolCallText(text);
171
+ if (parsedTc) {
172
+ onToolCall(parsedTc.name, parsedTc.arguments);
173
+ }
174
+ }
175
+ return { residualContent: flushed.content, state: flushed.state };
176
+ }
177
+
84
178
  // packages/agent-runtime/toolCallAccumulator.ts
85
179
  function createToolCallAccumulator() {
86
180
  return { slots: [] };
@@ -141,6 +235,9 @@ export {
141
235
  createThinkParserState,
142
236
  processThinkChunk,
143
237
  flushThinkParser,
238
+ createToolCallTextParserState,
239
+ processContentChunkWithToolCallStripping,
240
+ flushToolCallTextParserIntoCallback,
144
241
  createToolCallAccumulator,
145
242
  accumulateToolCallDelta,
146
243
  finalizeAccumulatedToolCalls
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  selectCurrentServer,
3
3
  selectRemoteServers
4
- } from "./chunk-S5UACFUP.js";
4
+ } from "./chunk-TTGAVETO.js";
5
5
  import {
6
6
  createUserKey,
7
7
  extractAgentInfo,