nolo-cli 0.11.0 → 0.12.0-alpha.2

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 (123) hide show
  1. package/{_executeModel-ZEDPX6OF.js → _executeModel-K23VU36L.js} +51 -50
  2. package/{action-AA4IJ5K2.js → action-RAXNQQKC.js} +8 -9
  3. package/{addContentAction-QYVO4SYP.js → addContentAction-ZHI7TVV3.js} +7 -9
  4. package/{addDialogAgentAction-WVVKT5WQ.js → addDialogAgentAction-JWXPKXNC.js} +9 -10
  5. package/{agentDeleteCommand-RDPGYIWF.js → agentDeleteCommand-MWB2LXG6.js} +38 -28
  6. package/{agentEmailCommands-2HJJKS5F.js → agentEmailCommands-7IBTXHNQ.js} +64 -62
  7. package/{agentListCommands-HFEVV3ZW.js → agentListCommands-SKUYB2RQ.js} +127 -31
  8. package/{agentMachineCommands-25ZOENJU.js → agentMachineCommands-5ZM2DB3X.js} +37 -26
  9. package/{agentPullCommand-GOL2S4W2.js → agentPullCommand-KRBRIFIY.js} +7 -7
  10. package/{agentRecordCommands-GTCOAM3L.js → agentRecordCommands-5IVBEJLP.js} +56 -54
  11. package/{agentRunCommand-YBS3JDLD.js → agentRunCommand-UCAEMXQF.js} +59 -59
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-IX4F5W2C.js} +3 -3
  13. package/{agentRuntimeLocal-UQBMQI2M.js → agentRuntimeLocal-PR67XWQK.js} +30 -15
  14. package/{agentSlice-6EKOBCCS.js → agentSlice-LWIPUATN.js} +8 -9
  15. package/{authCommand-O2OWACN4.js → authCommand-DMW336GT.js} +15 -15
  16. package/{authCommands-H7365TZP.js → authCommands-GH5T6RYV.js} +6 -6
  17. package/{chunk-7D3JY6C2.js → chunk-3HHTVM6G.js} +64 -5
  18. package/{chunk-KJR5KAUQ.js → chunk-3LVXNJON.js} +20 -7
  19. package/{chunk-AFON4QUU.js → chunk-45JUQTYY.js} +19 -11
  20. package/{chunk-KQQVGRA3.js → chunk-47TVQ7LF.js} +35 -29
  21. package/{chunk-FXXSGWAJ.js → chunk-4GBNEA5B.js} +1 -1
  22. package/{chunk-PXZAAB4L.js → chunk-4LG74DRG.js} +4 -4
  23. package/{chunk-2FTTDCD4.js → chunk-4ON5AV72.js} +2 -1
  24. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  25. package/{chunk-4SOKXIW4.js → chunk-5DVIMRVT.js} +8 -11
  26. package/{chunk-ISNCLGUZ.js → chunk-5NBHQD4D.js} +4 -3
  27. package/{chunk-NEM67FX7.js → chunk-672VQUVH.js} +1 -1
  28. package/{chunk-2W2VYVI5.js → chunk-6EFMBEQG.js} +528 -177
  29. package/{chunk-GBDSZATH.js → chunk-6LMFFG3K.js} +3 -3
  30. package/{chunk-CKOJQDKR.js → chunk-7JJCGV7N.js} +146 -3
  31. package/{chunk-MQI77IRB.js → chunk-7MYHLZ3F.js} +2 -2
  32. package/chunk-BYXBJQAS.js +0 -0
  33. package/{chunk-LAX2JSTX.js → chunk-CJIOTRWY.js} +20 -2
  34. package/{chunk-ZEYDOXHF.js → chunk-ESR6LPO5.js} +1467 -868
  35. package/{chunk-EVZKZF32.js → chunk-F22FKI27.js} +182 -75
  36. package/{chunk-OUI3ZHYD.js → chunk-FHTPQXHP.js} +1 -1
  37. package/{chunk-5MOUAAMK.js → chunk-FVGPOJYM.js} +194 -2580
  38. package/{chunk-AEZAORLG.js → chunk-FW4SQ6II.js} +5 -5
  39. package/chunk-IKXL2HZ3.js +70 -0
  40. package/{chunk-QNMFBBZK.js → chunk-IVAOVLM7.js} +1 -1
  41. package/{chunk-S3GS2PRL.js → chunk-JCU2JDCV.js} +597 -68
  42. package/{chunk-Q3UKJVU4.js → chunk-JJR3NP7R.js} +10 -10
  43. package/{chunk-PXQN7IBQ.js → chunk-JNMELOHI.js} +2 -2
  44. package/{chunk-XYZA7S7V.js → chunk-LNTQ7UXG.js} +6 -6
  45. package/{chunk-YOCHZD7D.js → chunk-NCGFB7NN.js} +5 -3
  46. package/{chunk-O26GI2JP.js → chunk-NITP2JDG.js} +39 -8
  47. package/{chunk-YPRZSPF3.js → chunk-OCDEWRE2.js} +1 -1
  48. package/{chunk-PNEW2Z3T.js → chunk-OHEKYYJF.js} +7 -7
  49. package/{chunk-DWGAEFJL.js → chunk-OILEWBXT.js} +1 -1
  50. package/chunk-OOIN7HSO.js +146 -0
  51. package/{chunk-C4FTUXVF.js → chunk-QLUFR47U.js} +11 -1
  52. package/{chunk-BX6U3ETE.js → chunk-RNYKVIND.js} +293 -89
  53. package/{chunk-L53FGHA4.js → chunk-RSEUHW6T.js} +1 -1
  54. package/chunk-S3UTETIC.js +4885 -0
  55. package/chunk-S73OEOHH.js +2286 -0
  56. package/{chunk-E4HNJSHC.js → chunk-TEOXBCYU.js} +81 -19
  57. package/{chunk-YTBMA7NO.js → chunk-TSKWE74T.js} +58 -8
  58. package/{chunk-5OIFWVX7.js → chunk-UG3WOFU6.js} +1 -1
  59. package/{chunk-LP65VRCI.js → chunk-UJ5L6X7H.js} +6 -6
  60. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  61. package/{chunk-IPYUUY4E.js → chunk-WPHL6ALY.js} +1 -1
  62. package/{chunk-3NSIQZZ6.js → chunk-WTYKCU4W.js} +9 -9
  63. package/{chunk-XFOLQLDN.js → chunk-XHQWJUW4.js} +2 -2
  64. package/{chunk-TACHTH5D.js → chunk-XJFP4EXZ.js} +18 -18
  65. package/{chunk-C2MDQQ4O.js → chunk-XRFEX5ZP.js} +1 -1
  66. package/{chunk-D6OQHXVG.js → chunk-YDCZVUFP.js} +7 -7
  67. package/{chunk-SV5MWASH.js → chunk-Z6ZZXQOZ.js} +12 -12
  68. package/{chunk-X2S7JTIG.js → chunk-ZR4RO4ZC.js} +1240 -136
  69. package/{chunk-ZPRK73XY.js → chunk-ZR4VHQ5D.js} +14 -13
  70. package/cliEnvHelpers-VYC2OPTB.js +30 -0
  71. package/{createAgentAutomationAction-LTI5QU35.js → createAgentAutomationAction-PJTUHFYB.js} +25 -26
  72. package/{createDialogAction-OJJ7L3L3.js → createDialogAction-QUCXTRAC.js} +26 -27
  73. package/{createPageAction-5MXWVRGY.js → createPageAction-2EWMGYFH.js} +26 -27
  74. package/{dbSlice-RQFQQVHT.js → dbSlice-WDP2ZZHK.js} +6 -7
  75. package/{deleteFile-7XP5BGC7.js → deleteFile-M7UNIUOO.js} +4 -4
  76. package/{dialogCommands-JTJ3RPPW.js → dialogCommands-BTHTTSE2.js} +33 -23
  77. package/{dialogSlice-OWROKURJ.js → dialogSlice-724QVE7A.js} +26 -27
  78. package/{docCreateCommands-WJBEW2V7.js → docCreateCommands-PQEX44Q7.js} +33 -23
  79. package/{docDeleteCommands-BVEHJOY5.js → docDeleteCommands-B3Q2M42N.js} +34 -25
  80. package/{docReadCommands-NEWOZIJV.js → docReadCommands-RCUVTX3Q.js} +33 -23
  81. package/{docStore-3DXRYBMD.js → docStore-R3US5ZU5.js} +25 -26
  82. package/{docUpdateCommands-C7WHT7UU.js → docUpdateCommands-NS5QAUAJ.js} +33 -23
  83. package/fetchMessages-KTNM7QAR.js +1 -1
  84. package/{getPricing-3E6UNPKL.js → getPricing-6TOZXPAU.js} +7 -3
  85. package/{handleSendMessageAction-B5PRR7BE.js → handleSendMessageAction-NTK7QUU2.js} +29 -30
  86. package/index.js +77 -76
  87. package/{localDialogRead-YSKFFRTT.js → localDialogRead-2VRI24F4.js} +1 -1
  88. package/{machineCommands-IIIREAEK.js → machineCommands-XOU6Q7Y2.js} +63 -61
  89. package/{machineWsRunDispatch-3SIU6ILW.js → machineWsRunDispatch-QRI3MSNV.js} +55 -53
  90. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-AFMES3LN.js} +5 -5
  91. package/{models-4OPOOLFS.js → models-LSCRJJ6P.js} +2 -2
  92. package/package.json +1 -1
  93. package/{read-QJNKRROM.js → read-2MIMRBZ2.js} +4 -4
  94. package/{readDocTool-H6X6KO6X.js → readDocTool-QHVGQHUJ.js} +1 -1
  95. package/{readlineWorkspace-HGP3I3OC.js → readlineWorkspace-3MDU7AYQ.js} +1113 -678
  96. package/{removeDialogAgentAction-TCT35SOF.js → removeDialogAgentAction-GTX5AN54.js} +13 -13
  97. package/{runAgentClientLoop-EFM4PTVI.js → runAgentClientLoop-ZIQQIOUB.js} +47 -47
  98. package/{runtimeDoctorCommands-ID43Z7VX.js → runtimeDoctorCommands-QNF3J3UV.js} +6 -6
  99. package/{setDialogExtraReferencesAction-CGYLZMFH.js → setDialogExtraReferencesAction-WFQ63KYO.js} +9 -10
  100. package/{setPrimaryDialogAgentAction-F6BFQDJU.js → setPrimaryDialogAgentAction-P57FXTSU.js} +13 -13
  101. package/{settingSlice-2I5HMG47.js → settingSlice-CK5YZGNI.js} +7 -8
  102. package/{skillDiscovery-UGSQGX2U.js → skillDiscovery-SZEA7TH6.js} +3 -3
  103. package/{spaceCommands-MT7BWCIL.js → spaceCommands-VTJYPRFQ.js} +37 -29
  104. package/{spaceSlice-BS5TSW3W.js → spaceSlice-DX7Y4RUE.js} +28 -27
  105. package/{streamAgentChatTurn-I3VBFNR3.js → streamAgentChatTurn-7OF2I3KI.js} +222 -128
  106. package/{toolApiClient-C7P7YSE4.js → toolApiClient-QI3YBNWB.js} +2 -2
  107. package/{tools-XSD2BOEN.js → tools-4IILQ24N.js} +34 -34
  108. package/{tuiSummaryLlmCaller-32NRHTT2.js → tuiSummaryLlmCaller-TXLF4MEI.js} +8 -6
  109. package/{updateCommands-VOSPKXFF.js → updateCommands-XZDOOYFH.js} +13 -5
  110. package/{updateDialogTitleAction-7FYNJOGP.js → updateDialogTitleAction-GNQXACIP.js} +29 -29
  111. package/chunk-5MMAK75Q.js +0 -15
  112. package/chunk-AZPCASRE.js +0 -36
  113. package/chunk-BBYVOSU2.js +0 -792
  114. package/chunk-DCOA4QSN.js +0 -105
  115. package/chunk-UAD2WT54.js +0 -64
  116. package/{chunk-JK7VW2FN.js → chunk-5MIDPSSK.js} +3 -3
  117. package/{chunk-5CS33IBL.js → chunk-PDL2AV3E.js} +3 -3
  118. package/{chunk-5MMZUWSG.js → chunk-TOILAPLH.js} +5 -5
  119. package/{chunk-OOM6SJNR.js → chunk-TSUJOM6N.js} +6 -6
  120. package/{db-6QED3ZVO.js → db-HCJ5PRB5.js} +3 -3
  121. package/{offlineMarxistsAgentCommand-BCPJITJL.js → offlineMarxistsAgentCommand-5OOWZLJI.js} +3 -3
  122. package/{tableCommands-M3DJUETS.js → tableCommands-E4SQWDOX.js} +6 -6
  123. package/{understanding-ZOESBLF3.js → understanding-3CUQQ6SV.js} +3 -3
@@ -1,17 +1,17 @@
1
- import {
2
- patch,
3
- remove,
4
- write
5
- } from "./chunk-O26GI2JP.js";
6
1
  import {
7
2
  applyAgentSecretMigrationUpdates,
8
3
  createFileCredentialBroker,
9
4
  migrateAgentSecrets,
10
5
  normalizeAgentRuntimeToolPolicy
11
- } from "./chunk-5CS33IBL.js";
6
+ } from "./chunk-PDL2AV3E.js";
12
7
  import {
13
8
  asRecordOrEmpty
14
9
  } from "./chunk-KX6YBIHG.js";
10
+ import {
11
+ patch,
12
+ remove,
13
+ write
14
+ } from "./chunk-NITP2JDG.js";
15
15
  import {
16
16
  createAgentKey,
17
17
  toTrimmedString
@@ -20,7 +20,7 @@ import {
20
20
  asyncThunkCreator,
21
21
  buildCreateSlice,
22
22
  getRuntimeServerContext
23
- } from "./chunk-OOM6SJNR.js";
23
+ } from "./chunk-TSUJOM6N.js";
24
24
  import {
25
25
  asTrimmedString
26
26
  } from "./chunk-3EUW3WEO.js";
@@ -300,7 +300,7 @@ var slice = createSliceWithThunks({
300
300
  const overrides = {};
301
301
  if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
302
302
  if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
303
- const { _executeModel } = await import("./_executeModel-ZEDPX6OF.js");
303
+ const { _executeModel } = await import("./_executeModel-K23VU36L.js");
304
304
  return _executeModel(
305
305
  {
306
306
  isStreaming: args.isStreaming ?? false,
@@ -321,7 +321,7 @@ var slice = createSliceWithThunks({
321
321
  * - 循环直到无工具调用或触发其他运行时停止条件
322
322
  */
323
323
  runAgent: create.asyncThunk(async (args, thunkApi) => {
324
- const { runAgentClientLoop } = await import("./runAgentClientLoop-EFM4PTVI.js");
324
+ const { runAgentClientLoop } = await import("./runAgentClientLoop-ZIQQIOUB.js");
325
325
  const { content: loopContent, toolCallCount } = await runAgentClientLoop(
326
326
  {
327
327
  agentKey: args.agentKey,
@@ -337,7 +337,7 @@ var slice = createSliceWithThunks({
337
337
  * 聊天轮次流式 Agent 调用
338
338
  */
339
339
  streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
340
- const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-I3VBFNR3.js");
340
+ const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-7OF2I3KI.js");
341
341
  return streamAgentChatTurnHandler(args, thunkApi);
342
342
  }),
343
343
  /**
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  i18n_default,
3
3
  toolRegistry
4
- } from "./chunk-2W2VYVI5.js";
4
+ } from "./chunk-6EFMBEQG.js";
5
5
  import {
6
6
  canonicalizeToolNames
7
- } from "./chunk-4SOKXIW4.js";
7
+ } from "./chunk-5DVIMRVT.js";
8
8
  import {
9
9
  asTrimmedLowercaseString
10
10
  } from "./chunk-QSJ3HFEF.js";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  updateContentTitle
3
- } from "./chunk-5MOUAAMK.js";
3
+ } from "./chunk-FVGPOJYM.js";
4
4
  import {
5
5
  require_date_fns
6
6
  } from "./chunk-M76ECQRD.js";
7
- import {
8
- patch,
9
- readAndWait
10
- } from "./chunk-O26GI2JP.js";
11
7
  import {
12
8
  require_react
13
9
  } from "./chunk-3ASDTTEI.js";
14
10
  import {
15
11
  toErrorMessage
16
12
  } from "./chunk-HNMXYYJR.js";
13
+ import {
14
+ patch,
15
+ readAndWait
16
+ } from "./chunk-NITP2JDG.js";
17
17
  import {
18
18
  asOptionalTrimmedString
19
19
  } from "./chunk-G3SUCT4W.js";
@@ -367,7 +367,7 @@ async function saveDocState(arg, { dispatch, getState }) {
367
367
  }
368
368
  }
369
369
  async function createDocState(args, thunkApi) {
370
- const { createPageAction } = await import("./createPageAction-5MXWVRGY.js");
370
+ const { createPageAction } = await import("./createPageAction-2EWMGYFH.js");
371
371
  return createPageAction(args, thunkApi);
372
372
  }
373
373
  function subscribe(listener) {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  asOptionalFiniteNumber
3
3
  } from "./chunk-WWC7I6TA.js";
4
- import {
5
- asTrimmedString
6
- } from "./chunk-3EUW3WEO.js";
7
4
  import {
8
5
  isRecord
9
6
  } from "./chunk-KUG52IAP.js";
7
+ import {
8
+ asTrimmedString
9
+ } from "./chunk-3EUW3WEO.js";
10
10
  import {
11
11
  asOptionalTrimmedString
12
12
  } from "./chunk-G3SUCT4W.js";
@@ -261,6 +261,8 @@ function pickAllowlistedAgentConfigFields(source, dbKey) {
261
261
  }
262
262
  const tools = uniqueToolNames(source.tools) ?? uniqueToolNames(source.toolNames);
263
263
  if (tools) snapshot.tools = tools;
264
+ const enabledPacks = uniqueToolNames(source.enabledPacks);
265
+ if (enabledPacks) snapshot.enabledPacks = enabledPacks;
264
266
  for (const key of DESKTOP_AGENT_CONFIG_SNAPSHOT_OBJECT_FIELDS) {
265
267
  const value = sanitizePlainObject(source[key]);
266
268
  if (value) {
@@ -1,11 +1,8 @@
1
- import {
2
- resolveFileCategory
3
- } from "./chunk-AZPCASRE.js";
4
1
  import {
5
2
  loadFileFromIndexedDb,
6
3
  removeAction,
7
4
  saveFileToIndexedDb
8
- } from "./chunk-IPYUUY4E.js";
5
+ } from "./chunk-WPHL6ALY.js";
9
6
  import {
10
7
  fileKey,
11
8
  getFileIdFromKey,
@@ -15,7 +12,7 @@ import {
15
12
  readAction,
16
13
  readRequestManager,
17
14
  resolveAgentReadServers
18
- } from "./chunk-XFOLQLDN.js";
15
+ } from "./chunk-XHQWJUW4.js";
19
16
  import {
20
17
  asyncThunkCreator,
21
18
  buildCreateSlice,
@@ -35,7 +32,7 @@ import {
35
32
  shouldReplaceLocalWithRemoteRecord,
36
33
  shouldReplicateLocalRecord,
37
34
  uploadToCurrentServer
38
- } from "./chunk-OOM6SJNR.js";
35
+ } from "./chunk-TSUJOM6N.js";
39
36
  import {
40
37
  fetchFromClientDb,
41
38
  fetchFromServer,
@@ -456,6 +453,39 @@ var upsertAction = async (upsertConfig, thunkApi) => {
456
453
  }
457
454
  };
458
455
 
456
+ // packages/app/utils/fileUtils.ts
457
+ var fileConstructor = typeof globalThis !== "undefined" && typeof globalThis.File === "function" ? globalThis.File : void 0;
458
+ var isImageMimeType = (value) => typeof value === "string" && value.toLowerCase().startsWith("image/");
459
+ var IMAGE_FILE_NAME_RE = /\.(avif|bmp|gif|heic|heif|ico|jpe?g|png|svg|tiff?|webp)$/i;
460
+ var VIDEO_FILE_NAME_RE = /\.(avi|m4v|mkv|mov|mp4|mpeg|mpg|webm)$/i;
461
+ var AUDIO_FILE_NAME_RE = /\.(aac|flac|m4a|mp3|ogg|wav|weba)$/i;
462
+ var DOCUMENT_FILE_NAME_RE = /\.(csv|doc|docx|md|odt|pdf|ppt|pptx|rtf|txt|xls|xlsx)$/i;
463
+ var isImageFileName = (value) => typeof value === "string" && IMAGE_FILE_NAME_RE.test(value.trim());
464
+ var isVideoMimeType = (value) => typeof value === "string" && value.toLowerCase().startsWith("video/");
465
+ var isAudioMimeType = (value) => typeof value === "string" && value.toLowerCase().startsWith("audio/");
466
+ var isPdfMimeType = (value) => typeof value === "string" && value.toLowerCase() === "application/pdf";
467
+ var isDocumentMimeType = (value) => {
468
+ if (typeof value !== "string") return false;
469
+ const normalized = value.toLowerCase();
470
+ return isPdfMimeType(normalized) || normalized === "text/plain" || normalized === "text/markdown" || normalized === "text/csv" || normalized === "application/msword" || normalized === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || normalized === "application/vnd.ms-powerpoint" || normalized === "application/vnd.openxmlformats-officedocument.presentationml.presentation" || normalized === "application/vnd.ms-excel" || normalized === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || normalized === "application/rtf" || normalized === "application/vnd.oasis.opendocument.text";
471
+ };
472
+ var resolveFileCategory = ({
473
+ mimeType,
474
+ fileName
475
+ }) => {
476
+ if (isImageMimeType(mimeType) || isImageFileName(fileName)) return "image";
477
+ if (isVideoMimeType(mimeType) || typeof fileName === "string" && VIDEO_FILE_NAME_RE.test(fileName.trim())) {
478
+ return "video";
479
+ }
480
+ if (isAudioMimeType(mimeType) || typeof fileName === "string" && AUDIO_FILE_NAME_RE.test(fileName.trim())) {
481
+ return "audio";
482
+ }
483
+ if (isDocumentMimeType(mimeType) || typeof fileName === "string" && DOCUMENT_FILE_NAME_RE.test(fileName.trim())) {
484
+ return "document";
485
+ }
486
+ return "other";
487
+ };
488
+
459
489
  // packages/database/actions/upload.ts
460
490
  var saveToClientDb2 = async (clientDb, dbKey, metadata) => {
461
491
  if (!clientDb) {
@@ -674,7 +704,7 @@ var dbSlice = createSliceWithThunks({
674
704
  // 动态 import 在调用期解析,避开 TDZ/求值顺序问题(同下方 share)。
675
705
  read: create.asyncThunk(
676
706
  async (payload, thunkApi) => {
677
- const { readAction: readAction2 } = await import("./read-QJNKRROM.js");
707
+ const { readAction: readAction2 } = await import("./read-2MIMRBZ2.js");
678
708
  return readAction2(payload, thunkApi);
679
709
  },
680
710
  {
@@ -748,7 +778,7 @@ var dbSlice = createSliceWithThunks({
748
778
  // 这里改成动态 import,运行期才解析,彻底断开这条边。
749
779
  share: create.asyncThunk(
750
780
  async (config, thunkApi) => {
751
- const { shareResourceAction } = await import("./action-AA4IJ5K2.js");
781
+ const { shareResourceAction } = await import("./action-RAXNQQKC.js");
752
782
  return shareResourceAction(config, thunkApi);
753
783
  }
754
784
  ),
@@ -784,6 +814,7 @@ var dbSlice_default = dbSlice.reducer;
784
814
  export {
785
815
  readAndWaitAction,
786
816
  toTimestampMs,
817
+ resolveFileCategory,
787
818
  uploadFileAction,
788
819
  dbAdapter,
789
820
  selectById,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-CWMSB67P.js";
7
7
  import {
8
8
  getModelConfig
9
- } from "./chunk-BBYVOSU2.js";
9
+ } from "./chunk-S3UTETIC.js";
10
10
  import {
11
11
  asOptionalFiniteNumber
12
12
  } from "./chunk-WWC7I6TA.js";
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  resolveMachineId
3
3
  } from "./chunk-6HYVJV7B.js";
4
+ import {
5
+ getDefaultCliLocalRuntimeDb
6
+ } from "./chunk-H33743XH.js";
4
7
  import {
5
8
  buildCliRuntimeEnv,
6
9
  clearProfileAuthToken,
@@ -18,18 +21,15 @@ import {
18
21
  import {
19
22
  asTrimmedNonEmptyStringArray
20
23
  } from "./chunk-I42VC5KR.js";
24
+ import {
25
+ asTrimmedString
26
+ } from "./chunk-3EUW3WEO.js";
21
27
  import {
22
28
  resolveAuthTokenFromEnv
23
- } from "./chunk-ISNCLGUZ.js";
29
+ } from "./chunk-5NBHQD4D.js";
24
30
  import {
25
31
  DEFAULT_NOLO_SERVER_URL
26
32
  } from "./chunk-OLZBQWZU.js";
27
- import {
28
- getDefaultCliLocalRuntimeDb
29
- } from "./chunk-H33743XH.js";
30
- import {
31
- asTrimmedString
32
- } from "./chunk-3EUW3WEO.js";
33
33
  import {
34
34
  normalizeServerOrigin
35
35
  } from "./chunk-CF7PE763.js";
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-AEZAORLG.js";
5
+ } from "./chunk-FW4SQ6II.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-KQHGZWSV.js";
@@ -0,0 +1,146 @@
1
+ import {
2
+ getModelAbility
3
+ } from "./chunk-IKXL2HZ3.js";
4
+
5
+ // packages/ai/agent/safeAgentSummary.ts
6
+ function parseTimestamp(val) {
7
+ if (typeof val === "number" && Number.isFinite(val)) return val;
8
+ if (typeof val === "string") return Date.parse(val) || 0;
9
+ return 0;
10
+ }
11
+ function safeTimestamp(val) {
12
+ if (typeof val === "number" && Number.isFinite(val)) return val;
13
+ if (typeof val === "string") return val;
14
+ return null;
15
+ }
16
+ function parseAgentRecordId(privateKey, explicitId) {
17
+ if (explicitId && typeof explicitId === "string" && explicitId.trim()) {
18
+ return explicitId.trim();
19
+ }
20
+ if (privateKey && typeof privateKey === "string") {
21
+ const match = privateKey.match(/^agent-[^-]+-(.+)$/i);
22
+ if (match?.[1]) return match[1];
23
+ }
24
+ return null;
25
+ }
26
+ function resolveFavoriteStatus(record, options) {
27
+ if (options?.isFavorite !== void 0) {
28
+ return {
29
+ isFavorite: !!options.isFavorite,
30
+ favoritedAt: safeTimestamp(options.favoritedAt)
31
+ };
32
+ }
33
+ if (record?.isFavorite === true) {
34
+ return {
35
+ isFavorite: true,
36
+ favoritedAt: safeTimestamp(record?.favoritedAt)
37
+ };
38
+ }
39
+ const favoritesMap = options?.favoritesMap;
40
+ if (!favoritesMap) {
41
+ return { isFavorite: false, favoritedAt: null };
42
+ }
43
+ const candidateKeys = [];
44
+ if (typeof record?.dbKey === "string" && record.dbKey) candidateKeys.push(record.dbKey);
45
+ if (typeof record?.privateKey === "string" && record.privateKey) candidateKeys.push(record.privateKey);
46
+ if (typeof record?.publicKey === "string" && record.publicKey) candidateKeys.push(record.publicKey);
47
+ if (typeof record?.id === "string" && record.id) {
48
+ candidateKeys.push(record.id);
49
+ candidateKeys.push(`agent-pub-${record.id}`);
50
+ if (options?.userId) {
51
+ candidateKeys.push(`agent-${options.userId}-${record.id}`);
52
+ }
53
+ }
54
+ let matched = false;
55
+ let highestFavAt = null;
56
+ let highestFavTime = -1;
57
+ for (const key of candidateKeys) {
58
+ const val = favoritesMap instanceof Map ? favoritesMap.get(key) : favoritesMap[key];
59
+ if (val !== void 0 && val !== false && val !== null) {
60
+ const favAt = val === true ? 1 : safeTimestamp(val);
61
+ if (favAt === null) continue;
62
+ matched = true;
63
+ const time = parseTimestamp(favAt);
64
+ if (time > highestFavTime) {
65
+ highestFavTime = time;
66
+ highestFavAt = favAt;
67
+ }
68
+ }
69
+ }
70
+ if (matched) {
71
+ return {
72
+ isFavorite: true,
73
+ favoritedAt: highestFavAt ?? 1
74
+ };
75
+ }
76
+ return { isFavorite: false, favoritedAt: null };
77
+ }
78
+ function toSafeAgentSummary(record, options) {
79
+ const rawId = parseAgentRecordId(
80
+ typeof record?.privateKey === "string" ? record.privateKey : record?.dbKey,
81
+ typeof record?.id === "string" ? record.id : void 0
82
+ );
83
+ const id = rawId ?? (typeof record?.id === "string" ? record.id : null);
84
+ const publicRecordDenied = record?.publicRecordExists === false || options?.publicRecordExists === false;
85
+ const publicRecordConfirmed = record?.publicRecordExists === true || options?.publicRecordExists === true;
86
+ let publicKey;
87
+ if (typeof record?.publicKey === "string" && record.publicKey && !publicRecordDenied) {
88
+ publicKey = record.publicKey;
89
+ } else if (publicRecordConfirmed && id) {
90
+ publicKey = `agent-pub-${id}`;
91
+ }
92
+ const name = typeof record?.name === "string" && record.name ? record.name : "(unnamed)";
93
+ const handle = typeof record?.handle === "string" && record.handle ? record.handle : null;
94
+ const introduction = typeof record?.introduction === "string" && record.introduction ? record.introduction : typeof record?.description === "string" && record.description ? record.description : null;
95
+ const model = typeof record?.model === "string" && record.model ? record.model : null;
96
+ const provider = typeof record?.provider === "string" && record.provider ? record.provider : typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
97
+ const apiSource = typeof record?.apiSource === "string" && record.apiSource ? record.apiSource : null;
98
+ const cliProvider = typeof record?.cliProvider === "string" && record.cliProvider ? record.cliProvider : null;
99
+ const tools = Array.isArray(record?.tools) ? record.tools.filter((t) => typeof t === "string") : [];
100
+ const inputPrice = typeof record?.inputPrice === "number" && Number.isFinite(record.inputPrice) ? record.inputPrice : null;
101
+ const outputPrice = typeof record?.outputPrice === "number" && Number.isFinite(record.outputPrice) ? record.outputPrice : null;
102
+ const modelAbility = model ? getModelAbility(model) ?? null : null;
103
+ const favStatus = resolveFavoriteStatus(record, options);
104
+ const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
105
+ const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
106
+ return {
107
+ id,
108
+ ...publicKey !== void 0 ? { publicKey } : {},
109
+ name,
110
+ handle,
111
+ introduction,
112
+ model,
113
+ provider,
114
+ apiSource,
115
+ cliProvider,
116
+ tools,
117
+ inputPrice,
118
+ outputPrice,
119
+ modelAbility,
120
+ isFavorite: favStatus.isFavorite,
121
+ favoritedAt: favStatus.favoritedAt,
122
+ isPublic,
123
+ updatedAt
124
+ };
125
+ }
126
+ function sortSafeAgentSummaries(agents) {
127
+ return [...agents].sort((left, right) => {
128
+ const leftFav = left.isFavorite === true;
129
+ const rightFav = right.isFavorite === true;
130
+ if (leftFav && !rightFav) return -1;
131
+ if (!leftFav && rightFav) return 1;
132
+ if (leftFav && rightFav) {
133
+ const leftFavAt = parseTimestamp(left.favoritedAt);
134
+ const rightFavAt = parseTimestamp(right.favoritedAt);
135
+ if (leftFavAt !== rightFavAt) return rightFavAt - leftFavAt;
136
+ }
137
+ const leftUpdated = parseTimestamp(left.updatedAt ?? left.createdAt);
138
+ const rightUpdated = parseTimestamp(right.updatedAt ?? right.createdAt);
139
+ return rightUpdated - leftUpdated;
140
+ });
141
+ }
142
+
143
+ export {
144
+ toSafeAgentSummary,
145
+ sortSafeAgentSummaries
146
+ };
@@ -1,5 +1,6 @@
1
1
  import {
2
- MEMORY_USE_GUIDANCE
2
+ MEMORY_USE_GUIDANCE,
3
+ wrapHistoricalSummaryWithReplayGuard
3
4
  } from "./chunk-KKY4B2Q2.js";
4
5
 
5
6
  // packages/agent-runtime/turnContext.ts
@@ -122,6 +123,14 @@ var buildLinkedSpacesSection = async (args) => {
122
123
  "\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"
123
124
  ].join("\n");
124
125
  };
126
+ var buildDialogSummaryLayer = (args) => {
127
+ const historical = wrapHistoricalSummaryWithReplayGuard(
128
+ asTrimmed(args.summary)
129
+ );
130
+ if (!historical) return null;
131
+ return makeLayer("dialog-summary", `--- \u5386\u53F2\u5BF9\u8BDD\u6458\u8981 ---
132
+ ${historical}`);
133
+ };
125
134
  var buildMemoryOverlayLayer = (args) => {
126
135
  const promptBlock = asTrimmed(args.promptBlock);
127
136
  if (!promptBlock) return null;
@@ -141,6 +150,7 @@ export {
141
150
  buildSpaceContextLayer,
142
151
  buildSkillDiscoveryLayer,
143
152
  buildLinkedSpacesSection,
153
+ buildDialogSummaryLayer,
144
154
  buildMemoryOverlayLayer,
145
155
  buildMemoryUseGuidanceLayer
146
156
  };