nolo-cli 0.9.1 → 0.11.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 (114) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-UD44KGZ4.js → _executeModel-ZEDPX6OF.js} +50 -48
  3. package/{action-ZJWE3Y5S.js → action-AA4IJ5K2.js} +11 -11
  4. package/{addContentAction-TVDBNJM5.js → addContentAction-QYVO4SYP.js} +10 -10
  5. package/{addDialogAgentAction-EKH774VT.js → addDialogAgentAction-WVVKT5WQ.js} +12 -12
  6. package/{agentDeleteCommand-TCPEFJTF.js → agentDeleteCommand-RDPGYIWF.js} +25 -25
  7. package/{agentEmailCommands-CZ3UILZ4.js → agentEmailCommands-2HJJKS5F.js} +62 -59
  8. package/{agentListCommands-SJKO2FFB.js → agentListCommands-HFEVV3ZW.js} +30 -29
  9. package/{agentMachineCommands-PSNABISZ.js → agentMachineCommands-25ZOENJU.js} +29 -29
  10. package/{agentRecordCommands-MH2JKFHS.js → agentRecordCommands-GTCOAM3L.js} +53 -50
  11. package/{agentRunCommand-4KH6MIZR.js → agentRunCommand-YBS3JDLD.js} +62 -56
  12. package/{agentRuntimeLocal-SKHJUWSS.js → agentRuntimeLocal-UQBMQI2M.js} +12 -12
  13. package/{agentSlice-3WXXN4VK.js → agentSlice-6EKOBCCS.js} +11 -11
  14. package/{authCommand-PXFX6JDT.js → authCommand-O2OWACN4.js} +12 -12
  15. package/{authCommands-356AYWEK.js → authCommands-H7365TZP.js} +6 -6
  16. package/{chunk-MKMWT7SA.js → chunk-2W2VYVI5.js} +336 -92
  17. package/{chunk-TSS3XJY4.js → chunk-3NSIQZZ6.js} +5 -5
  18. package/{chunk-AUQ747NZ.js → chunk-4SOKXIW4.js} +70 -6
  19. package/{chunk-ZIG5LJ7X.js → chunk-5MOUAAMK.js} +106 -2342
  20. package/{chunk-6GANEXVO.js → chunk-5OIFWVX7.js} +1 -1
  21. package/{chunk-MGOJ5R6J.js → chunk-7D3JY6C2.js} +2 -2
  22. package/{chunk-7OOXPE3N.js → chunk-AEZAORLG.js} +4 -4
  23. package/chunk-AFON4QUU.js +112 -0
  24. package/{chunk-YBWOP46I.js → chunk-BX6U3ETE.js} +20 -13
  25. package/{chunk-2PUGVR6E.js → chunk-C2MDQQ4O.js} +1 -1
  26. package/{chunk-SL35K7AH.js → chunk-C4FTUXVF.js} +2 -82
  27. package/{chunk-GAKEBQD6.js → chunk-D6OQHXVG.js} +11 -7
  28. package/{chunk-WKM6FH35.js → chunk-DWGAEFJL.js} +1 -1
  29. package/{chunk-PG5PNA7Y.js → chunk-E4HNJSHC.js} +20 -20
  30. package/{chunk-SBR32ZZS.js → chunk-EVZKZF32.js} +73 -40
  31. package/{chunk-C3RUNRHT.js → chunk-FXXSGWAJ.js} +1 -1
  32. package/{chunk-KTVVPRJS.js → chunk-GBDSZATH.js} +4 -4
  33. package/{chunk-3TZDXYSF.js → chunk-HNW7IJSK.js} +1 -1
  34. package/{chunk-2EISRLRC.js → chunk-IPYUUY4E.js} +2 -2
  35. package/{chunk-2K2ECKSG.js → chunk-KJR5KAUQ.js} +2 -2
  36. package/{chunk-XE635NI4.js → chunk-KQQVGRA3.js} +24 -24
  37. package/{chunk-AVMKZHBC.js → chunk-L53FGHA4.js} +3 -2
  38. package/{chunk-GG4AJPSR.js → chunk-LAX2JSTX.js} +2 -2
  39. package/{chunk-5PJ3VWCS.js → chunk-LP65VRCI.js} +7 -13
  40. package/chunk-LTRXGFMS.js +83 -0
  41. package/{chunk-63SLEOLK.js → chunk-MQI77IRB.js} +4 -4
  42. package/{chunk-PCWC3JTN.js → chunk-MTU75CZ2.js} +1 -1
  43. package/{chunk-3WYQEUBI.js → chunk-NEM67FX7.js} +1 -1
  44. package/{chunk-COMXDWNM.js → chunk-O26GI2JP.js} +10 -10
  45. package/{chunk-SH2CFQOH.js → chunk-O4BU24WZ.js} +2 -181
  46. package/{chunk-EYEEHCU4.js → chunk-OOM6SJNR.js} +10 -10
  47. package/chunk-OOSFSFMA.js +271 -0
  48. package/{chunk-PAKN26FP.js → chunk-OUI3ZHYD.js} +1 -1
  49. package/{chunk-EXTIQUCI.js → chunk-PNEW2Z3T.js} +9 -9
  50. package/{chunk-CPB2YM4D.js → chunk-PXQN7IBQ.js} +2 -2
  51. package/{chunk-4IJYA27C.js → chunk-PXZAAB4L.js} +4 -4
  52. package/{chunk-4K2KKCSD.js → chunk-Q3UKJVU4.js} +12 -16
  53. package/{chunk-XKIMRZO2.js → chunk-QNMFBBZK.js} +1 -1
  54. package/{chunk-XS466O7S.js → chunk-S3GS2PRL.js} +65 -30
  55. package/{chunk-YYUCRDOK.js → chunk-SOTZ6RDN.js} +1 -1
  56. package/{chunk-G43KEVSC.js → chunk-SV5MWASH.js} +17 -17
  57. package/{chunk-7QRKCBOP.js → chunk-TACHTH5D.js} +15 -15
  58. package/chunk-VC6OZXO5.js +298 -0
  59. package/{chunk-ZQ2UM4KG.js → chunk-WZSRQNQG.js} +1 -292
  60. package/{chunk-LARL2V6G.js → chunk-X2S7JTIG.js} +298 -66
  61. package/{chunk-Q2YZULBH.js → chunk-XENYHRUE.js} +1 -1
  62. package/{chunk-ELRRLDWI.js → chunk-XFOLQLDN.js} +2 -2
  63. package/{chunk-UUJDGGAK.js → chunk-XYZA7S7V.js} +6 -6
  64. package/{chunk-KOCA5FCS.js → chunk-ZEYDOXHF.js} +185 -147
  65. package/{chunk-5KLGBAAR.js → chunk-ZPRK73XY.js} +1 -1
  66. package/{cliExecutor-DNE7TCC4.js → cliExecutor-K3F7DMRO.js} +2 -2
  67. package/{createAgentAutomationAction-63OIP6X5.js → createAgentAutomationAction-LTI5QU35.js} +25 -25
  68. package/{createDialogAction-ZLYZDYBB.js → createDialogAction-OJJ7L3L3.js} +26 -25
  69. package/{createPageAction-AL5FSDCK.js → createPageAction-5MXWVRGY.js} +30 -29
  70. package/{dbSlice-PR44QPXY.js → dbSlice-RQFQQVHT.js} +9 -9
  71. package/{deleteFile-4SKGPHOZ.js → deleteFile-7XP5BGC7.js} +6 -6
  72. package/{dialogCommands-F6YI5742.js → dialogCommands-JTJ3RPPW.js} +23 -23
  73. package/{dialogSlice-JSBNZRLR.js → dialogSlice-OWROKURJ.js} +22 -22
  74. package/{docCreateCommands-4CTO7ERT.js → docCreateCommands-WJBEW2V7.js} +23 -22
  75. package/{docDeleteCommands-VBWERDRG.js → docDeleteCommands-BVEHJOY5.js} +25 -24
  76. package/{docReadCommands-KNP4MFYB.js → docReadCommands-NEWOZIJV.js} +23 -22
  77. package/{docStore-ADP5VYY4.js → docStore-3DXRYBMD.js} +23 -23
  78. package/{docUpdateCommands-4BCBJQHA.js → docUpdateCommands-C7WHT7UU.js} +23 -22
  79. package/{fetchMessages-U6ZHN56A.js → fetchMessages-KTNM7QAR.js} +3 -3
  80. package/{handleSendMessageAction-IJDQ6ARA.js → handleSendMessageAction-B5PRR7BE.js} +27 -27
  81. package/index.js +58 -58
  82. package/{localDialogRead-Z5UTAJPU.js → localDialogRead-YSKFFRTT.js} +2 -2
  83. package/{machineCommands-EA3M4XTN.js → machineCommands-IIIREAEK.js} +67 -62
  84. package/{machineWsRunDispatch-NAPKE5ZA.js → machineWsRunDispatch-3SIU6ILW.js} +52 -49
  85. package/package.json +4 -2
  86. package/{read-RIJCIVKX.js → read-QJNKRROM.js} +6 -6
  87. package/{readDocTool-GZD2N3LO.js → readDocTool-H6X6KO6X.js} +1 -1
  88. package/{readlineWorkspace-KMWT4T4S.js → readlineWorkspace-HGP3I3OC.js} +97 -79
  89. package/{removeDialogAgentAction-GJQJNDW6.js → removeDialogAgentAction-TCT35SOF.js} +14 -14
  90. package/{runAgentClientLoop-U5Q6NDTJ.js → runAgentClientLoop-EFM4PTVI.js} +46 -44
  91. package/{setDialogExtraReferencesAction-M7OQG54N.js → setDialogExtraReferencesAction-CGYLZMFH.js} +12 -12
  92. package/{setPrimaryDialogAgentAction-46UNFJDL.js → setPrimaryDialogAgentAction-F6BFQDJU.js} +14 -14
  93. package/{settingSlice-FVUUH4JA.js → settingSlice-2I5HMG47.js} +10 -10
  94. package/skillDiscovery-UGSQGX2U.js +16 -0
  95. package/{spaceCommands-E2CFRPZJ.js → spaceCommands-MT7BWCIL.js} +32 -36
  96. package/{spaceSlice-L3R6IMXE.js → spaceSlice-BS5TSW3W.js} +22 -22
  97. package/{streamAgentChatTurn-UBDAOQWE.js → streamAgentChatTurn-I3VBFNR3.js} +85 -81
  98. package/{tableCommands-GOFP7QKA.js → tableCommands-M3DJUETS.js} +11 -11
  99. package/{toolApiClient-QI3YBNWB.js → toolApiClient-C7P7YSE4.js} +2 -2
  100. package/{tools-TMJXZTCA.js → tools-XSD2BOEN.js} +34 -32
  101. package/{tuiSummaryLlmCaller-RV3THLZF.js → tuiSummaryLlmCaller-32NRHTT2.js} +3 -3
  102. package/{understanding-GQKNDDWM.js → understanding-ZOESBLF3.js} +5 -5
  103. package/{updateDialogTitleAction-ZTWRDXI2.js → updateDialogTitleAction-7FYNJOGP.js} +25 -25
  104. package/chunk-QYXLLLGL.js +0 -4519
  105. package/{agentPullCommand-O2MTUAFR.js → agentPullCommand-GOL2S4W2.js} +1 -1
  106. package/{chunk-DZ3XJVET.js → chunk-3QAF2LTL.js} +3 -3
  107. package/{chunk-EHLHSX7R.js → chunk-5MMZUWSG.js} +3 -3
  108. package/{chunk-X7W4TNB4.js → chunk-CMKUBIGW.js} +3 -3
  109. package/{chunk-4CQLVGRV.js → chunk-ID4G2MAR.js} +3 -3
  110. package/{chunk-5MIDPSSK.js → chunk-JK7VW2FN.js} +3 -3
  111. package/{chunk-TILFE6LV.js → chunk-YOCHZD7D.js} +3 -3
  112. package/{chunk-JRKKFRAV.js → chunk-YTBMA7NO.js} +3 -3
  113. package/{db-HCJ5PRB5.js → db-6QED3ZVO.js} +3 -3
  114. package/{runtimeDoctorCommands-LRHLPDRC.js → runtimeDoctorCommands-ID43Z7VX.js} +3 -3
@@ -1,36 +1,32 @@
1
+ import {
2
+ patch,
3
+ remove,
4
+ write
5
+ } from "./chunk-O26GI2JP.js";
1
6
  import {
2
7
  applyAgentSecretMigrationUpdates,
3
8
  createFileCredentialBroker,
4
9
  migrateAgentSecrets,
5
10
  normalizeAgentRuntimeToolPolicy
6
11
  } from "./chunk-5CS33IBL.js";
7
- import {
8
- patch,
9
- remove,
10
- write
11
- } from "./chunk-COMXDWNM.js";
12
12
  import {
13
13
  asRecordOrEmpty
14
14
  } from "./chunk-KX6YBIHG.js";
15
15
  import {
16
16
  createAgentKey,
17
- require_index_umd,
18
17
  toTrimmedString
19
- } from "./chunk-SH2CFQOH.js";
18
+ } from "./chunk-O4BU24WZ.js";
20
19
  import {
21
20
  asyncThunkCreator,
22
21
  buildCreateSlice,
23
22
  getRuntimeServerContext
24
- } from "./chunk-EYEEHCU4.js";
23
+ } from "./chunk-OOM6SJNR.js";
25
24
  import {
26
25
  asTrimmedString
27
26
  } from "./chunk-3EUW3WEO.js";
28
27
  import {
29
28
  asOptionalTrimmedString
30
29
  } from "./chunk-G3SUCT4W.js";
31
- import {
32
- __toESM
33
- } from "./chunk-4VNS5WPM.js";
34
30
 
35
31
  // packages/ai/chat/agentCredentialSyncClient.ts
36
32
  function buildUrl(currentServer, credentialRef) {
@@ -86,7 +82,7 @@ var sanitizeOptionalModelString = (value) => {
86
82
  };
87
83
 
88
84
  // packages/ai/agent/agentSlice.ts
89
- var import_ulid = __toESM(require_index_umd());
85
+ import { ulid } from "ulid";
90
86
  var createAgentCredentialBroker = createFileCredentialBroker;
91
87
  function setAgentCredentialBrokerFactoryForTests(factory) {
92
88
  createAgentCredentialBroker = factory ?? createFileCredentialBroker;
@@ -304,7 +300,7 @@ var slice = createSliceWithThunks({
304
300
  const overrides = {};
305
301
  if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
306
302
  if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
307
- const { _executeModel } = await import("./_executeModel-UD44KGZ4.js");
303
+ const { _executeModel } = await import("./_executeModel-ZEDPX6OF.js");
308
304
  return _executeModel(
309
305
  {
310
306
  isStreaming: args.isStreaming ?? false,
@@ -325,7 +321,7 @@ var slice = createSliceWithThunks({
325
321
  * - 循环直到无工具调用或触发其他运行时停止条件
326
322
  */
327
323
  runAgent: create.asyncThunk(async (args, thunkApi) => {
328
- const { runAgentClientLoop } = await import("./runAgentClientLoop-U5Q6NDTJ.js");
324
+ const { runAgentClientLoop } = await import("./runAgentClientLoop-EFM4PTVI.js");
329
325
  const { content: loopContent, toolCallCount } = await runAgentClientLoop(
330
326
  {
331
327
  agentKey: args.agentKey,
@@ -341,7 +337,7 @@ var slice = createSliceWithThunks({
341
337
  * 聊天轮次流式 Agent 调用
342
338
  */
343
339
  streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
344
- const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-UBDAOQWE.js");
340
+ const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-I3VBFNR3.js");
345
341
  return streamAgentChatTurnHandler(args, thunkApi);
346
342
  }),
347
343
  /**
@@ -355,7 +351,7 @@ var slice = createSliceWithThunks({
355
351
  const effectiveUserId = asOptionalTrimmedString(userId) ?? "local";
356
352
  const processed = processAgentCreateForm(formData, effectiveUserId);
357
353
  const now = Date.now();
358
- const id = (0, import_ulid.ulid)();
354
+ const id = ulid();
359
355
  const privateKey = createAgentKey.private(effectiveUserId, id);
360
356
  const publicKey = createAgentKey.public(id);
361
357
  let agent = {
@@ -199,7 +199,7 @@ async function readDocFunc(args, thunkApi) {
199
199
  throw new Error(`\u65E0\u6548\u7684\u9875\u9762 ID: ${id}\u3002\u9875\u9762 ID \u901A\u5E38\u4EE5 "page-" \u5F00\u5934\u3002`);
200
200
  }
201
201
  try {
202
- const { readAction } = await import("./read-RIJCIVKX.js");
202
+ const { readAction } = await import("./read-QJNKRROM.js");
203
203
  const pageData = await readAction({ dbKey: id }, thunkApi);
204
204
  if (!pageData) {
205
205
  throw new Error(`\u672A\u627E\u5230 ID \u4E3A ${id} \u7684\u9875\u9762\u3002`);
@@ -2,10 +2,10 @@ import {
2
2
  buildCurrentTimeBlock,
3
3
  buildIdentityBlock,
4
4
  buildRuntimeGuidanceBlocks
5
- } from "./chunk-PAKN26FP.js";
5
+ } from "./chunk-OUI3ZHYD.js";
6
6
  import {
7
7
  canonicalizeToolNames
8
- } from "./chunk-AUQ747NZ.js";
8
+ } from "./chunk-4SOKXIW4.js";
9
9
  import {
10
10
  clipCompactText
11
11
  } from "./chunk-5MMAK75Q.js";
@@ -13,12 +13,6 @@ import {
13
13
  findModelConfig,
14
14
  getProviderByModelName
15
15
  } from "./chunk-BBYVOSU2.js";
16
- import {
17
- compactWhitespace
18
- } from "./chunk-DWLEOOGR.js";
19
- import {
20
- toErrorMessage
21
- } from "./chunk-HNMXYYJR.js";
22
16
  import {
23
17
  asRecordOrEmpty
24
18
  } from "./chunk-KX6YBIHG.js";
@@ -26,11 +20,17 @@ import {
26
20
  asTrimmedLowercaseString
27
21
  } from "./chunk-QSJ3HFEF.js";
28
22
  import {
29
- asOptionalTrimmedString
30
- } from "./chunk-G3SUCT4W.js";
23
+ compactWhitespace
24
+ } from "./chunk-DWLEOOGR.js";
25
+ import {
26
+ toErrorMessage
27
+ } from "./chunk-HNMXYYJR.js";
31
28
  import {
32
29
  isRecord
33
30
  } from "./chunk-KUG52IAP.js";
31
+ import {
32
+ asOptionalTrimmedString
33
+ } from "./chunk-G3SUCT4W.js";
34
34
 
35
35
  // packages/agent-runtime/actionGate.ts
36
36
  function readCommandActionGatePayload(payload) {
@@ -624,6 +624,37 @@ function extractUserInputText(content) {
624
624
  if (!Array.isArray(content)) return "";
625
625
  return content.flatMap((part) => part?.type === "text" && part.text ? [part.text] : []).join("\n").trim();
626
626
  }
627
+ function attachDialogIdToError(error, dialogId) {
628
+ if (!dialogId) return;
629
+ if (typeof error === "object" && error !== null) {
630
+ error.dialogId = dialogId;
631
+ }
632
+ }
633
+ async function persistFailedLocalTurn(args) {
634
+ const errorMessage = toErrorMessage(args.error);
635
+ try {
636
+ const saved = await args.adapter.saveTurn({
637
+ agentKey: args.agentKey,
638
+ messages: args.messages,
639
+ result: {
640
+ content: args.partialContent || `[nolo] Agent run failed: ${errorMessage}`,
641
+ model: args.model ?? "unknown",
642
+ toolCallCount: args.toolCallCount ?? 0,
643
+ error: true,
644
+ errorMessage
645
+ },
646
+ ...args.input.runtimeContext ? { runtimeContext: args.input.runtimeContext } : {},
647
+ ...args.input.continueDialogId ? { continueDialogId: args.input.continueDialogId } : {},
648
+ ...args.input.spaceId ? { spaceId: args.input.spaceId } : {},
649
+ ...args.input.category ? { category: args.input.category } : {},
650
+ ...args.input.inheritedFromDialogKey ? { inheritedFromDialogKey: args.input.inheritedFromDialogKey } : {},
651
+ ...args.input.parentDialogId ? { parentDialogId: args.input.parentDialogId } : {}
652
+ });
653
+ return saved?.dialogId;
654
+ } catch {
655
+ return args.input.continueDialogId;
656
+ }
657
+ }
627
658
  async function runLocalAgentTurn(input) {
628
659
  const agentConfig = await input.adapter.loadAgentConfig(input.agentRef);
629
660
  if (!agentConfig) {
@@ -632,7 +663,21 @@ async function runLocalAgentTurn(input) {
632
663
  error.agentRef = input.agentRef;
633
664
  throw error;
634
665
  }
635
- const history = input.continueDialogId ? await input.adapter.loadDialogHistory(input.continueDialogId) : [];
666
+ let history = [];
667
+ try {
668
+ history = input.continueDialogId ? await input.adapter.loadDialogHistory(input.continueDialogId) : [];
669
+ } catch (error) {
670
+ const dialogId = await persistFailedLocalTurn({
671
+ adapter: input.adapter,
672
+ agentKey: agentConfig.key,
673
+ messages: [{ role: "user", content: input.input }],
674
+ error,
675
+ model: agentConfig.model,
676
+ input
677
+ });
678
+ attachDialogIdToError(error, dialogId);
679
+ throw error;
680
+ }
636
681
  const identityBlock = buildIdentityBlock({
637
682
  agentName: agentConfig.name,
638
683
  agentId: agentConfig.key,
@@ -669,7 +714,6 @@ async function runLocalAgentTurn(input) {
669
714
  history,
670
715
  input: input.input
671
716
  });
672
- const provider = await input.adapter.resolveProvider(agentConfig);
673
717
  const supportsImages = resolveAgentImageInputSupport({
674
718
  apiSource: agentConfig.apiSource,
675
719
  provider: agentConfig.provider,
@@ -688,6 +732,7 @@ async function runLocalAgentTurn(input) {
688
732
  let skipFinalAppend = false;
689
733
  let partialContent = "";
690
734
  try {
735
+ const provider = await input.adapter.resolveProvider(agentConfig);
691
736
  while (true) {
692
737
  partialContent = "";
693
738
  throwIfAborted(input);
@@ -858,28 +903,18 @@ async function runLocalAgentTurn(input) {
858
903
  loopError = error;
859
904
  }
860
905
  if (loopError) {
861
- const errorMessage = toErrorMessage(loopError);
862
906
  const turnMessages2 = messages.slice(turnStartIndex);
863
- const saved2 = await input.adapter.saveTurn({
907
+ const dialogId = await persistFailedLocalTurn({
908
+ adapter: input.adapter,
864
909
  agentKey: agentConfig.key,
865
910
  messages: turnMessages2,
866
- result: {
867
- content: partialContent || `[nolo] Agent run failed: ${errorMessage}`,
868
- model: agentConfig.model ?? "unknown",
869
- toolCallCount,
870
- error: true,
871
- errorMessage
872
- },
873
- ...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {},
874
- ...input.continueDialogId ? { continueDialogId: input.continueDialogId } : {},
875
- ...input.spaceId ? { spaceId: input.spaceId } : {},
876
- ...input.category ? { category: input.category } : {},
877
- ...input.inheritedFromDialogKey ? { inheritedFromDialogKey: input.inheritedFromDialogKey } : {},
878
- ...input.parentDialogId ? { parentDialogId: input.parentDialogId } : {}
911
+ error: loopError,
912
+ model: agentConfig.model,
913
+ toolCallCount,
914
+ partialContent,
915
+ input
879
916
  });
880
- if (saved2?.dialogId && typeof loopError === "object" && loopError !== null) {
881
- loopError.dialogId = saved2.dialogId;
882
- }
917
+ attachDialogIdToError(loopError, dialogId);
883
918
  throw loopError;
884
919
  }
885
920
  result = result;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  dialogMessageRange
3
- } from "./chunk-SH2CFQOH.js";
3
+ } from "./chunk-O4BU24WZ.js";
4
4
  import {
5
5
  isTombstoneRecord
6
6
  } from "./chunk-GBRG75BQ.js";
@@ -1,17 +1,27 @@
1
1
  import {
2
2
  buildSpaceLookup,
3
3
  getSpaceContentKeys
4
- } from "./chunk-4CQLVGRV.js";
4
+ } from "./chunk-ID4G2MAR.js";
5
5
  import {
6
6
  deleteDbRecordOnServers,
7
7
  listUserRecordsFromServers,
8
8
  readDbRecordFromServers,
9
9
  readLiveDbRecordAfterTombstoneMerge
10
- } from "./chunk-WKM6FH35.js";
10
+ } from "./chunk-DWGAEFJL.js";
11
11
  import {
12
12
  buildDialogAttachmentPlan,
13
13
  extractFileContentIds
14
- } from "./chunk-PCWC3JTN.js";
14
+ } from "./chunk-MTU75CZ2.js";
15
+ import {
16
+ parsePositiveFiniteNumberOrFallback
17
+ } from "./chunk-Y5GCAMGP.js";
18
+ import {
19
+ asRecordOrEmpty
20
+ } from "./chunk-KX6YBIHG.js";
21
+ import {
22
+ asNonEmptyStringArray,
23
+ asTrimmedNonEmptyStringArray
24
+ } from "./chunk-I42VC5KR.js";
15
25
  import {
16
26
  parseUserIdFromAuthToken,
17
27
  readOption,
@@ -23,25 +33,15 @@ import {
23
33
  import {
24
34
  toErrorMessage
25
35
  } from "./chunk-HNMXYYJR.js";
26
- import {
27
- parsePositiveFiniteNumberOrFallback
28
- } from "./chunk-Y5GCAMGP.js";
29
- import {
30
- asRecordOrEmpty
31
- } from "./chunk-KX6YBIHG.js";
32
- import {
33
- asNonEmptyStringArray,
34
- asTrimmedNonEmptyStringArray
35
- } from "./chunk-I42VC5KR.js";
36
36
  import {
37
37
  asTrimmedString
38
38
  } from "./chunk-3EUW3WEO.js";
39
- import {
40
- asOptionalTrimmedString
41
- } from "./chunk-G3SUCT4W.js";
42
39
  import {
43
40
  isRecord
44
41
  } from "./chunk-KUG52IAP.js";
42
+ import {
43
+ asOptionalTrimmedString
44
+ } from "./chunk-G3SUCT4W.js";
45
45
 
46
46
  // packages/cli/dialogAttachmentCleanup.ts
47
47
  function asText(value) {
@@ -625,7 +625,7 @@ async function tryHttpDialogCandidates(args) {
625
625
  throw Object.assign(new Error("All HTTP dialog reads failed"), { attempts });
626
626
  }
627
627
  async function readDialogFromLocalDb(dialogKey, dialogId, limit) {
628
- const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-Z5UTAJPU.js");
628
+ const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-YSKFFRTT.js");
629
629
  const result = await readLocalDialog({ dialogKey, dialogId, limit });
630
630
  return {
631
631
  ...result,
@@ -1,47 +1,47 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-LARL2V6G.js";
4
+ } from "./chunk-X2S7JTIG.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-MKMWT7SA.js";
7
+ } from "./chunk-2W2VYVI5.js";
8
8
  import {
9
9
  readPipeText,
10
10
  spawnProcess
11
11
  } from "./chunk-IDZTNRP2.js";
12
- import {
13
- parseUserIdFromAuthToken
14
- } from "./chunk-ISNCLGUZ.js";
15
- import {
16
- DEFAULT_NOLO_SERVER_URL
17
- } from "./chunk-OLZBQWZU.js";
18
12
  import {
19
13
  runLocalAgentTurn
20
- } from "./chunk-XS466O7S.js";
14
+ } from "./chunk-S3GS2PRL.js";
21
15
  import {
22
16
  resolveLocalRuntimeEnvFromPolicy
23
17
  } from "./chunk-5CS33IBL.js";
24
- import {
25
- toErrorMessage
26
- } from "./chunk-HNMXYYJR.js";
27
18
  import {
28
19
  asRecordOrEmpty
29
20
  } from "./chunk-KX6YBIHG.js";
30
21
  import {
31
22
  asTrimmedNonEmptyStringArray
32
23
  } from "./chunk-I42VC5KR.js";
24
+ import {
25
+ parseUserIdFromAuthToken
26
+ } from "./chunk-ISNCLGUZ.js";
27
+ import {
28
+ DEFAULT_NOLO_SERVER_URL
29
+ } from "./chunk-OLZBQWZU.js";
30
+ import {
31
+ toErrorMessage
32
+ } from "./chunk-HNMXYYJR.js";
33
33
  import {
34
34
  asTrimmedString
35
35
  } from "./chunk-3EUW3WEO.js";
36
36
  import {
37
37
  asOptionalPositiveFiniteNumber
38
38
  } from "./chunk-U6VC4MU4.js";
39
- import {
40
- asOptionalTrimmedString
41
- } from "./chunk-G3SUCT4W.js";
42
39
  import {
43
40
  isRecord
44
41
  } from "./chunk-KUG52IAP.js";
42
+ import {
43
+ asOptionalTrimmedString
44
+ } from "./chunk-G3SUCT4W.js";
45
45
 
46
46
  // packages/ai/agent/machineRunPermissions.ts
47
47
  var DEFAULT_POLICY = {
@@ -0,0 +1,298 @@
1
+ import {
2
+ dump,
3
+ load
4
+ } from "./chunk-WZSRQNQG.js";
5
+ import {
6
+ asTrimmedNonEmptyStringArray
7
+ } from "./chunk-I42VC5KR.js";
8
+ import {
9
+ asOptionalTrimmedString
10
+ } from "./chunk-G3SUCT4W.js";
11
+
12
+ // packages/ai/skills/skillDocProtocol.ts
13
+ var SKILL_DOC_ENUMS = {
14
+ triggerMode: ["explicit", "required", "recommended"],
15
+ budgetTier: ["low", "medium", "high"],
16
+ modality: ["text", "image", "video", "audio", "3d"],
17
+ docKind: ["knowledge", "instruction", "skill"]
18
+ };
19
+ var SKILL_CONFIG_BLOCK = "skill-config";
20
+ var EVAL_CONFIG_BLOCK = "eval-config";
21
+ var WORKFLOW_CONFIG_BLOCK = "workflow-config";
22
+ var normalizeStringArray = (value) => {
23
+ if (!Array.isArray(value)) return void 0;
24
+ const items = [...new Set(asTrimmedNonEmptyStringArray(value))];
25
+ return items.length > 0 ? items : void 0;
26
+ };
27
+ var normalizeBoolean = (value) => typeof value === "boolean" ? value : void 0;
28
+ var normalizeSkillEnumValue = (key, value) => typeof value === "string" && SKILL_DOC_ENUMS[key].includes(value) ? value : void 0;
29
+ var normalizeSkillBudgetTier = (value) => normalizeSkillEnumValue("budgetTier", value);
30
+ var normalizeSkillModalities = (value) => {
31
+ const raw = normalizeStringArray(value);
32
+ if (!raw) return void 0;
33
+ const filtered = raw.flatMap((item) => {
34
+ const modality = normalizeSkillEnumValue("modality", item);
35
+ return modality ? [modality] : [];
36
+ });
37
+ return filtered.length > 0 ? Array.from(new Set(filtered)) : void 0;
38
+ };
39
+ var normalizeSkillConfig = (value, fallbackTools) => {
40
+ if (!value || typeof value !== "object") return void 0;
41
+ const record = value;
42
+ const name = asOptionalTrimmedString(record.name) ?? "";
43
+ const description = asOptionalTrimmedString(record.description) ?? "";
44
+ if (!name || !description) return void 0;
45
+ const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
46
+ const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
47
+ const modalities = normalizeSkillModalities(record.modalities);
48
+ const toolNames = normalizeStringArray(record.toolNames) ?? normalizeStringArray(fallbackTools) ?? void 0;
49
+ const discover = record.discover && typeof record.discover === "object" ? {
50
+ keywords: normalizeStringArray(
51
+ record.discover.keywords
52
+ ),
53
+ examples: normalizeStringArray(
54
+ record.discover.examples
55
+ )
56
+ } : void 0;
57
+ return {
58
+ version: "0.1",
59
+ kind: "skill",
60
+ id: asOptionalTrimmedString(record.id),
61
+ name,
62
+ description,
63
+ triggerMode,
64
+ toolNames,
65
+ preferredAgents: normalizeStringArray(record.preferredAgents),
66
+ budgetTier,
67
+ dispatchPreferred: normalizeBoolean(record.dispatchPreferred),
68
+ modalities,
69
+ requiredSkills: normalizeStringArray(record.requiredSkills),
70
+ recommendedSkills: normalizeStringArray(record.recommendedSkills),
71
+ promptPatch: asOptionalTrimmedString(record.promptPatch),
72
+ discover: discover?.keywords || discover?.examples ? discover : void 0
73
+ };
74
+ };
75
+ var normalizeEvalConfig = (value) => {
76
+ if (!value || typeof value !== "object") return void 0;
77
+ const record = value;
78
+ if (!Array.isArray(record.cases)) return void 0;
79
+ const cases = [];
80
+ for (const item of record.cases) {
81
+ if (!item || typeof item !== "object") continue;
82
+ const testCase = item;
83
+ const input = asOptionalTrimmedString(testCase.input) ?? "";
84
+ if (!input) continue;
85
+ cases.push({
86
+ input,
87
+ expectedTools: normalizeStringArray(testCase.expectedTools),
88
+ expectedSignals: normalizeStringArray(testCase.expectedSignals),
89
+ forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals)
90
+ });
91
+ }
92
+ return cases.length > 0 ? {
93
+ version: "0.1",
94
+ cases
95
+ } : void 0;
96
+ };
97
+ var normalizeWorkflowConfig = (value) => {
98
+ if (!value || typeof value !== "object") return void 0;
99
+ const record = value;
100
+ const name = asOptionalTrimmedString(record.name) ?? "";
101
+ const description = asOptionalTrimmedString(record.description) ?? "";
102
+ if (!name || !description) return void 0;
103
+ const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
104
+ return {
105
+ version: "0.1",
106
+ kind: "workflow",
107
+ id: asOptionalTrimmedString(record.id),
108
+ name,
109
+ description,
110
+ defaultAgent: asOptionalTrimmedString(record.defaultAgent),
111
+ inputs: normalizeStringArray(record.inputs),
112
+ recommendedTools: normalizeStringArray(record.recommendedTools),
113
+ requiredTools: normalizeStringArray(record.requiredTools),
114
+ requiredOutputs: normalizeStringArray(record.requiredOutputs),
115
+ gates: normalizeStringArray(record.gates),
116
+ budgetTier,
117
+ contextStrategy: asOptionalTrimmedString(record.contextStrategy),
118
+ failureProtocol: asOptionalTrimmedString(record.failureProtocol)
119
+ };
120
+ };
121
+ var normalizePageSkillMetadata = (value, fallbackTools) => {
122
+ if (!value || typeof value !== "object") return void 0;
123
+ const record = value;
124
+ const kind = normalizeSkillEnumValue("docKind", record.kind);
125
+ const meta = {
126
+ kind,
127
+ requiredSkills: normalizeStringArray(record.requiredSkills),
128
+ recommendedSkills: normalizeStringArray(record.recommendedSkills),
129
+ skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
130
+ evalConfig: normalizeEvalConfig(record.evalConfig),
131
+ workflowConfig: normalizeWorkflowConfig(record.workflowConfig)
132
+ };
133
+ if (meta.skillConfig && !meta.kind) {
134
+ meta.kind = "skill";
135
+ }
136
+ if (meta.workflowConfig && !meta.kind) {
137
+ meta.kind = "instruction";
138
+ }
139
+ return meta.kind || meta.requiredSkills || meta.recommendedSkills || meta.skillConfig || meta.evalConfig || meta.workflowConfig ? meta : void 0;
140
+ };
141
+ var extractCommentBlock = (markdown, blockName) => {
142
+ if (!markdown) return void 0;
143
+ const matcher = new RegExp(
144
+ `<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
145
+ "i"
146
+ );
147
+ const match = markdown.match(matcher);
148
+ return asOptionalTrimmedString(match?.[1]);
149
+ };
150
+ var removeCommentBlock = (markdown, blockName) => markdown.replace(
151
+ new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
152
+ "\n\n"
153
+ );
154
+ var parseYamlObject = (raw) => {
155
+ if (!raw) return void 0;
156
+ try {
157
+ const parsed = load(raw);
158
+ return parsed && typeof parsed === "object" ? parsed : void 0;
159
+ } catch {
160
+ return void 0;
161
+ }
162
+ };
163
+ var parseSkillDocProtocol = (markdown, existingMeta, fallbackTools) => {
164
+ const source = typeof markdown === "string" ? markdown : "";
165
+ const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
166
+ const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
167
+ const workflowBlock = parseYamlObject(extractCommentBlock(source, WORKFLOW_CONFIG_BLOCK));
168
+ const cleanedContent = removeCommentBlock(
169
+ removeCommentBlock(
170
+ removeCommentBlock(source, SKILL_CONFIG_BLOCK),
171
+ EVAL_CONFIG_BLOCK
172
+ ),
173
+ WORKFLOW_CONFIG_BLOCK
174
+ ).replace(/\n{3,}/g, "\n\n").trim();
175
+ const parsedMeta = normalizePageSkillMetadata(
176
+ {
177
+ ...existingMeta ?? {},
178
+ ...skillBlock ? {
179
+ kind: existingMeta?.kind === "skill" || skillBlock.kind === "skill" ? "skill" : existingMeta?.kind,
180
+ requiredSkills: skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
181
+ recommendedSkills: skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
182
+ skillConfig: skillBlock
183
+ } : {},
184
+ ...evalBlock ? { evalConfig: evalBlock } : {},
185
+ ...workflowBlock ? { workflowConfig: workflowBlock } : {}
186
+ },
187
+ fallbackTools
188
+ );
189
+ return {
190
+ content: cleanedContent,
191
+ meta: parsedMeta
192
+ };
193
+ };
194
+ var resolvePageSkillMetadata = (page) => {
195
+ if (!page) return void 0;
196
+ const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
197
+ return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
198
+ };
199
+ var yamlBlock = (value) => dump(value, { lineWidth: 120, noRefs: true }).trim();
200
+ var buildSkillConfigComment = (config) => {
201
+ const payload = {
202
+ version: config.version,
203
+ kind: config.kind,
204
+ ...config.id ? { id: config.id } : {},
205
+ name: config.name,
206
+ description: config.description,
207
+ ...config.triggerMode ? { triggerMode: config.triggerMode } : {},
208
+ ...config.requiredSkills?.length ? { requiredSkills: config.requiredSkills } : {},
209
+ ...config.recommendedSkills?.length ? { recommendedSkills: config.recommendedSkills } : {},
210
+ ...config.toolNames?.length ? { toolNames: config.toolNames } : {},
211
+ ...config.preferredAgents?.length ? { preferredAgents: config.preferredAgents } : {},
212
+ ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
213
+ ...typeof config.dispatchPreferred === "boolean" ? { dispatchPreferred: config.dispatchPreferred } : {},
214
+ ...config.modalities?.length ? { modalities: config.modalities } : {},
215
+ ...config.discover?.keywords?.length || config.discover?.examples?.length ? {
216
+ discover: {
217
+ ...config.discover?.keywords?.length ? { keywords: config.discover.keywords } : {},
218
+ ...config.discover?.examples?.length ? { examples: config.discover.examples } : {}
219
+ }
220
+ } : {},
221
+ ...config.promptPatch ? { promptPatch: config.promptPatch } : {}
222
+ };
223
+ return `<!-- ${SKILL_CONFIG_BLOCK}
224
+ ${yamlBlock(payload)}
225
+ -->`;
226
+ };
227
+ var buildEvalConfigComment = (config) => `<!-- ${EVAL_CONFIG_BLOCK}
228
+ ${yamlBlock({
229
+ version: config.version,
230
+ cases: config.cases
231
+ })}
232
+ -->`;
233
+ var buildWorkflowConfigComment = (config) => `<!-- ${WORKFLOW_CONFIG_BLOCK}
234
+ ${yamlBlock({
235
+ version: config.version,
236
+ kind: config.kind,
237
+ ...config.id ? { id: config.id } : {},
238
+ name: config.name,
239
+ description: config.description,
240
+ ...config.defaultAgent ? { defaultAgent: config.defaultAgent } : {},
241
+ ...config.inputs?.length ? { inputs: config.inputs } : {},
242
+ ...config.recommendedTools?.length ? { recommendedTools: config.recommendedTools } : {},
243
+ ...config.requiredTools?.length ? { requiredTools: config.requiredTools } : {},
244
+ ...config.requiredOutputs?.length ? { requiredOutputs: config.requiredOutputs } : {},
245
+ ...config.gates?.length ? { gates: config.gates } : {},
246
+ ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
247
+ ...config.contextStrategy ? { contextStrategy: config.contextStrategy } : {},
248
+ ...config.failureProtocol ? { failureProtocol: config.failureProtocol } : {}
249
+ })}
250
+ -->`;
251
+ var buildSkillDocMarkdown = (options) => {
252
+ const sections = [
253
+ asOptionalTrimmedString(options.body) ?? "",
254
+ buildSkillConfigComment(options.skillConfig),
255
+ options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
256
+ options.workflowConfig ? buildWorkflowConfigComment(options.workflowConfig) : ""
257
+ ].filter(Boolean);
258
+ return sections.join("\n\n").trim();
259
+ };
260
+ var extractFrontmatter = (markdown) => {
261
+ const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
262
+ if (!match) return { body: markdown.trim() };
263
+ const frontmatter = parseYamlObject(match[1]);
264
+ const body = markdown.slice(match[0].length).trim();
265
+ return { frontmatter, body };
266
+ };
267
+ var normalizeAllowedTools = (value) => {
268
+ if (Array.isArray(value)) {
269
+ return normalizeStringArray(value) ?? [];
270
+ }
271
+ if (typeof value === "string") {
272
+ return value.split(/\s+/).map((item) => item.trim()).filter(Boolean);
273
+ }
274
+ return [];
275
+ };
276
+ var parseExternalSkillMarkdown = (markdown) => {
277
+ const { frontmatter, body } = extractFrontmatter(markdown);
278
+ return {
279
+ name: asOptionalTrimmedString(frontmatter?.name),
280
+ description: asOptionalTrimmedString(frontmatter?.description),
281
+ compatibility: asOptionalTrimmedString(frontmatter?.compatibility),
282
+ allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
283
+ metadata: frontmatter?.metadata && typeof frontmatter.metadata === "object" ? Object.fromEntries(
284
+ Object.entries(frontmatter.metadata).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
285
+ ) : void 0,
286
+ body
287
+ };
288
+ };
289
+
290
+ export {
291
+ normalizeStringArray,
292
+ normalizeSkillBudgetTier,
293
+ normalizeSkillModalities,
294
+ parseSkillDocProtocol,
295
+ resolvePageSkillMetadata,
296
+ buildSkillDocMarkdown,
297
+ parseExternalSkillMarkdown
298
+ };