nolo-cli 0.30.1 → 0.31.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 (108) hide show
  1. package/{_executeModel-FYUR7PQU.js → _executeModel-K47XKKPU.js} +32 -31
  2. package/{action-FENWPT3C.js → action-HI3VRQLP.js} +7 -7
  3. package/{addContentAction-Z5S5ZQ7I.js → addContentAction-NCURJ6PK.js} +6 -6
  4. package/{addDialogAgentAction-VUNVD2XR.js → addDialogAgentAction-RCY4ECF4.js} +5 -5
  5. package/{agentDeleteCommand-HHP47ZB2.js → agentDeleteCommand-7BBZCONG.js} +26 -25
  6. package/{agentEmailCommands-H6KRDTQW.js → agentEmailCommands-D6FAT5HM.js} +38 -37
  7. package/{agentListCommands-GNVFOTB4.js → agentListCommands-YPNNMGSJ.js} +28 -27
  8. package/{agentMachineCommands-4HJHI26F.js → agentMachineCommands-VYRVSKUC.js} +26 -25
  9. package/{agentRecordCommands-W6ITUONM.js → agentRecordCommands-4J52H5NK.js} +37 -36
  10. package/{agentRunCommand-VDLU4VKR.js → agentRunCommand-QDNDC76O.js} +38 -37
  11. package/{agentRunControl-AKBN2366.js → agentRunControl-SCIVRZWX.js} +9 -1
  12. package/{agentRuntimeLocal-3X3ZTFT2.js → agentRuntimeLocal-G7GK545E.js} +23 -22
  13. package/{agentSlice-5HYCSSTE.js → agentSlice-4ZLEPC3M.js} +6 -6
  14. package/{appDeleteCommands-WFUF34TE.js → appDeleteCommands-AOZED7QJ.js} +27 -26
  15. package/{appDeployCommands-J2EAE53G.js → appDeployCommands-XJY27BDS.js} +27 -26
  16. package/{appDeployStatusCommands-RLXDEHTV.js → appDeployStatusCommands-HKZYAPB2.js} +27 -26
  17. package/{appGetCommands-ZGV3CKCM.js → appGetCommands-VXJLPRYI.js} +27 -26
  18. package/{appListCommands-3VRX3EJI.js → appListCommands-3LU6AB4G.js} +27 -26
  19. package/{authCommand-RR5LAYSW.js → authCommand-3GQR43KB.js} +5 -5
  20. package/{chunk-ZFTCLBEX.js → chunk-2IJAKBK2.js} +3 -1
  21. package/chunk-2K4NDPT5.js +1524 -0
  22. package/{chunk-6QP7LEI6.js → chunk-2MSOY7A5.js} +49 -33
  23. package/{chunk-3IPBZISR.js → chunk-2YT3KLHX.js} +1 -1
  24. package/{chunk-GABCPUMC.js → chunk-3IU7WEJD.js} +1 -1
  25. package/{chunk-Q24P6TUS.js → chunk-43EPBPZ2.js} +1 -1
  26. package/{chunk-5NPAOURO.js → chunk-4URO6HMS.js} +1 -1
  27. package/{chunk-S342XWCB.js → chunk-5EDVWWE3.js} +1 -1
  28. package/{chunk-CTLXD6HB.js → chunk-5JQRISUS.js} +3 -3
  29. package/{chunk-4ZMTXQFB.js → chunk-5MVFYKBL.js} +5 -5
  30. package/{chunk-R5V5G73M.js → chunk-5RDLGLAP.js} +0 -1
  31. package/{chunk-4SAV7BD7.js → chunk-7KNERA53.js} +53 -15
  32. package/{chunk-XORE26Z4.js → chunk-7S54ZGF6.js} +2 -2
  33. package/{chunk-IZ3CBMD5.js → chunk-ATK5WJOA.js} +4 -4
  34. package/chunk-BGTUGS3T.js +702 -0
  35. package/{chunk-YX26YZL4.js → chunk-C3NYMZTQ.js} +16 -14
  36. package/{chunk-R2JHVPHL.js → chunk-CPUZW54L.js} +4 -4
  37. package/{chunk-PJY5AH5A.js → chunk-DPR66GY6.js} +1 -1
  38. package/{chunk-3Z6SPX5X.js → chunk-E2CFIWQR.js} +31 -23
  39. package/{chunk-PACNSC37.js → chunk-E3APEOIM.js} +1 -1
  40. package/{chunk-7QW64TCG.js → chunk-EATVNXFX.js} +7 -7
  41. package/{chunk-KH3JS4D5.js → chunk-EB5AQGXR.js} +164 -95
  42. package/{chunk-G5JHHUAK.js → chunk-F3MP7CP6.js} +1 -1
  43. package/{chunk-YK2QRWTO.js → chunk-FLYQAMF4.js} +3 -3
  44. package/{chunk-446VANPP.js → chunk-G5GVZAXF.js} +4 -4
  45. package/{chunk-MNUJETMH.js → chunk-K76HYM3O.js} +1 -1
  46. package/{chunk-DKRT67FG.js → chunk-KGEVMUMI.js} +3 -3
  47. package/{chunk-A4JDTA5T.js → chunk-LAXMH7JY.js} +6 -6
  48. package/{chunk-TAS3THIF.js → chunk-LBEWOWVL.js} +4 -4
  49. package/{chunk-72NVMKWA.js → chunk-NEGMZP6Q.js} +1 -1
  50. package/{chunk-QDNVDGLN.js → chunk-NMK2JHKM.js} +9 -7
  51. package/{chunk-JRI2BRJY.js → chunk-OT2AXEQD.js} +26 -5
  52. package/{chunk-LWP3HB56.js → chunk-PTHDLIRB.js} +1 -1
  53. package/{chunk-V5BWE46D.js → chunk-Q6L3O67D.js} +2 -2
  54. package/{chunk-LWYIHJKD.js → chunk-QHWPAW5M.js} +2 -2
  55. package/{chunk-KWCLUYGQ.js → chunk-QL6ELRVS.js} +1 -1
  56. package/chunk-RJ7KLCWY.js +5134 -0
  57. package/{chunk-WJD5RNVB.js → chunk-SFWZUTCI.js} +1 -1
  58. package/{chunk-WTPC3XD4.js → chunk-UDA3ZYLW.js} +1 -1
  59. package/{chunk-YLADSPDU.js → chunk-V54H24CQ.js} +2 -2
  60. package/{chunk-F3A5IZSX.js → chunk-WEID4JLC.js} +2 -2
  61. package/{chunk-IUA36RS4.js → chunk-WMH2G6XJ.js} +58 -124
  62. package/{chunk-4PWB7JRR.js → chunk-XFG3BAKN.js} +1 -0
  63. package/chunk-XGJ75KN2.js +7889 -0
  64. package/{chunk-2TZP235J.js → chunk-XPML3KYZ.js} +6 -6
  65. package/{chunk-2NYIVLAY.js → chunk-YHGHADBQ.js} +2 -2
  66. package/{chunk-MV6UZXZU.js → chunk-YJZGAAVX.js} +14 -12
  67. package/{chunk-BOL2D2JW.js → chunk-ZJ2WITOO.js} +2 -2
  68. package/{chunk-DWQNDGO7.js → chunk-ZJH3LKEW.js} +2 -2
  69. package/{createAgentAutomationAction-EKABYSSA.js → createAgentAutomationAction-AECD5YCU.js} +13 -12
  70. package/{createDialogAction-HLP6TV4H.js → createDialogAction-MZUC37CA.js} +14 -13
  71. package/{createPageAction-4NEEWW6S.js → createPageAction-KRTBWM2S.js} +13 -12
  72. package/{db-IPCJ43PW.js → db-6DPSJ6WT.js} +4 -2
  73. package/{dbSlice-OBV7VFCF.js → dbSlice-BBL3PEVW.js} +5 -5
  74. package/{deleteFile-AC45HYSM.js → deleteFile-RJTEPOT4.js} +3 -3
  75. package/{dialogCommands-XB3ZNSP3.js → dialogCommands-RFADXVV6.js} +27 -26
  76. package/{dialogSlice-4IWM2WIY.js → dialogSlice-EWNZ2HFD.js} +12 -12
  77. package/{docCreateCommands-QSPTTAN7.js → docCreateCommands-ZHX6SX5M.js} +26 -25
  78. package/{docDeleteCommands-2E6JZXCP.js → docDeleteCommands-3EEM7ITO.js} +27 -26
  79. package/{docReadCommands-N2DQVLLT.js → docReadCommands-JOMLMZTC.js} +26 -25
  80. package/{docStore-PFZCPHPC.js → docStore-YKTKKH3N.js} +14 -13
  81. package/{docUpdateCommands-53KFSYEP.js → docUpdateCommands-PGAYLKLC.js} +26 -25
  82. package/{getPricing-67TQVKFV.js → getPricing-QO5TYNCK.js} +2 -2
  83. package/{handleSendMessageAction-4IYJTQAL.js → handleSendMessageAction-VX4CGWAJ.js} +12 -12
  84. package/index.js +63 -63
  85. package/{localDialogRead-P72W2U2R.js → localDialogRead-3DBXVYXS.js} +1 -1
  86. package/{machineCommands-CR34SD5W.js → machineCommands-A2WFB37F.js} +36 -35
  87. package/{machineWsRunDispatch-G4O3NQ3I.js → machineWsRunDispatch-E5R54UWZ.js} +36 -35
  88. package/package.json +1 -1
  89. package/{read-QK7ZRX6G.js → read-64OQDO3I.js} +3 -3
  90. package/{readDocTool-EYDMVRBL.js → readDocTool-MXM3T6PE.js} +1 -1
  91. package/{readlineWorkspace-UAF5D7TC.js → readlineWorkspace-35GFHS37.js} +125 -79
  92. package/{removeDialogAgentAction-TBW3UZJW.js → removeDialogAgentAction-NEKVAMSH.js} +7 -7
  93. package/{runAgentClientLoop-R5WNOWHI.js → runAgentClientLoop-C6IIUQ36.js} +27 -26
  94. package/{setDialogExtraReferencesAction-Q3ANF2NR.js → setDialogExtraReferencesAction-WTOHQDIV.js} +6 -6
  95. package/{setPrimaryDialogAgentAction-FQ5R3EFJ.js → setPrimaryDialogAgentAction-LDJOYC4F.js} +7 -7
  96. package/{settingSlice-JKKV2T7O.js → settingSlice-4M37TN7V.js} +6 -6
  97. package/{skillDiscovery-I3QRA7NE.js → skillDiscovery-Y3HALY2U.js} +3 -3
  98. package/{spaceCommands-RZN5K5ND.js → spaceCommands-SKCMLOC6.js} +210 -28
  99. package/{spaceSlice-3BVGRL3V.js → spaceSlice-6VOPELQN.js} +13 -12
  100. package/{streamAgentChatTurn-RVOJZ2HO.js → streamAgentChatTurn-623CNKWF.js} +35 -32
  101. package/{switchDialogAgentAction-QQGVE4SL.js → switchDialogAgentAction-XVWGKR2Z.js} +5 -5
  102. package/{tableCommands-PRJNWN6Q.js → tableCommands-RJZ3V4TF.js} +1 -1
  103. package/{tools-QAKUH2P6.js → tools-IN4B36PN.js} +21 -20
  104. package/{tuiSummaryLlmCaller-YQBN5IMG.js → tuiSummaryLlmCaller-SRZ4QQUP.js} +19 -5
  105. package/{updateDialogTitleAction-4O5PZVQR.js → updateDialogTitleAction-4ABIVEYY.js} +18 -16
  106. package/chunk-EIQDGAAE.js +0 -5083
  107. package/chunk-O6YCGBJB.js +0 -16338
  108. package/chunk-OB6FBSH3.js +0 -47
@@ -19,12 +19,12 @@ import {
19
19
  parseAgentRunEvent,
20
20
  t,
21
21
  toolLabel
22
- } from "./chunk-3Z6SPX5X.js";
22
+ } from "./chunk-E2CFIWQR.js";
23
23
  import {
24
24
  createRunActivityTracker,
25
25
  finalizeRunRecord,
26
26
  spawnLocalBackgroundRun
27
- } from "./chunk-4SAV7BD7.js";
27
+ } from "./chunk-7KNERA53.js";
28
28
  import {
29
29
  CliProviderQuotaError
30
30
  } from "./chunk-JDSUTNYY.js";
@@ -38,14 +38,14 @@ import {
38
38
  normalizeAgentHandle,
39
39
  readDbRecord,
40
40
  resolveAgentRecordFromHybridStore
41
- } from "./chunk-MNUJETMH.js";
41
+ } from "./chunk-K76HYM3O.js";
42
42
  import {
43
43
  NOLO_PROJECT_MANAGER_AGENT_KEY,
44
44
  isLocalCliAgentKey
45
45
  } from "./chunk-K6QEHQZ3.js";
46
46
  import {
47
47
  buildSkillDiscoveryContextLayer
48
- } from "./chunk-KWCLUYGQ.js";
48
+ } from "./chunk-QL6ELRVS.js";
49
49
  import {
50
50
  applyModelLayerOverride,
51
51
  buildModelLayerOverride
@@ -58,7 +58,7 @@ import {
58
58
  LOCAL_TURN_ABORTED_CODE,
59
59
  readActionGate,
60
60
  readCommandActionGatePayload
61
- } from "./chunk-IUA36RS4.js";
61
+ } from "./chunk-WMH2G6XJ.js";
62
62
  import {
63
63
  createThinkParserState,
64
64
  flushThinkParser,
@@ -70,13 +70,13 @@ import {
70
70
  buildMemoryUseGuidanceLayer,
71
71
  partitionScopedBlocks,
72
72
  renderTurnContextBlocksWithScope
73
- } from "./chunk-PJY5AH5A.js";
73
+ } from "./chunk-DPR66GY6.js";
74
74
  import {
75
75
  resolvePlatformAuthToken
76
- } from "./chunk-WTPC3XD4.js";
76
+ } from "./chunk-UDA3ZYLW.js";
77
77
  import {
78
78
  formatAgentListCard
79
- } from "./chunk-6QP7LEI6.js";
79
+ } from "./chunk-2MSOY7A5.js";
80
80
  import {
81
81
  isGatewayHttpStatus
82
82
  } from "./chunk-Z5MXSEOJ.js";
@@ -95,17 +95,17 @@ import {
95
95
  chooseMemoryOwners,
96
96
  loadMemoryCandidatesFromDb,
97
97
  resolveAgentMemoryPolicy
98
- } from "./chunk-JRI2BRJY.js";
98
+ } from "./chunk-OT2AXEQD.js";
99
99
  import {
100
100
  API_REPORTED_COST_MULTIPLIER,
101
101
  DEFAULT_CONTEXT_WINDOW,
102
102
  getModelContextWindow,
103
103
  normalizeUsage,
104
104
  parseUiAskChoiceContent
105
- } from "./chunk-O6YCGBJB.js";
105
+ } from "./chunk-RJ7KLCWY.js";
106
106
  import {
107
107
  clipCompactText
108
- } from "./chunk-OB6FBSH3.js";
108
+ } from "./chunk-BGTUGS3T.js";
109
109
  import {
110
110
  toErrorMessage
111
111
  } from "./chunk-HNMXYYJR.js";
@@ -114,7 +114,7 @@ import {
114
114
  } from "./chunk-DWLEOOGR.js";
115
115
  import {
116
116
  findModelConfig
117
- } from "./chunk-EIQDGAAE.js";
117
+ } from "./chunk-2K4NDPT5.js";
118
118
  import {
119
119
  readPipeText,
120
120
  spawnProcess
@@ -124,14 +124,14 @@ import {
124
124
  } from "./chunk-A7GB5UGH.js";
125
125
  import {
126
126
  parsePositiveFiniteNumberOrFallback
127
- } from "./chunk-446VANPP.js";
127
+ } from "./chunk-G5GVZAXF.js";
128
128
  import {
129
129
  asTrimmedLowercaseString
130
130
  } from "./chunk-QSJ3HFEF.js";
131
131
  import {
132
132
  BUILTIN_NOLO_AGENT_KEY,
133
133
  PUBLIC_DEEPSEEK_V4_FLASH_AGENT_KEY
134
- } from "./chunk-DWQNDGO7.js";
134
+ } from "./chunk-ZJH3LKEW.js";
135
135
  import {
136
136
  isLoopbackUrl
137
137
  } from "./chunk-4SN6J65J.js";
@@ -3538,7 +3538,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
3538
3538
  // packages/cli/client/agentRun.ts
3539
3539
  import { ulid } from "ulid";
3540
3540
  async function loadRunLocalAgentTurn() {
3541
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-3X3ZTFT2.js");
3541
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-G7GK545E.js");
3542
3542
  return runLocalAgentTurn;
3543
3543
  }
3544
3544
  async function resolveCurrentMachineId(options) {
@@ -4458,53 +4458,69 @@ var touchMemoryItemsInDb = async (db, items, now = (/* @__PURE__ */ new Date()).
4458
4458
  await batch.write();
4459
4459
  };
4460
4460
 
4461
+ // packages/ai/memory/constants.ts
4462
+ var EXPLICIT_REMEMBER_PREFIX_REGEX = /^(你要记住|请记住|以后记住|记住)[,,。.\s::]*/u;
4463
+
4461
4464
  // packages/ai/memory/overlay.ts
4462
4465
  var KIND_TITLES = {
4463
4466
  episodic: "Episodic",
4464
4467
  semantic: "Semantic",
4465
4468
  procedural: "Procedural"
4466
4469
  };
4470
+ var estimateTokens = (text) => {
4471
+ let cjk = 0;
4472
+ let ascii = 0;
4473
+ for (const ch of text) {
4474
+ const code = ch.codePointAt(0) ?? 0;
4475
+ if (code >= 13312 && code <= 40959) cjk += 1;
4476
+ else ascii += 1;
4477
+ }
4478
+ return Math.ceil(cjk * 1.5 + ascii / 4);
4479
+ };
4480
+ var OVERLAY_HEADER_LINES = [
4481
+ "--- Memory Overlay ---",
4482
+ "\u4EE5\u4E0B\u662F\u5F53\u524D\u8BF7\u6C42\u53EF\u7528\u7684\u8BB0\u5FC6\u4E8B\u5B9E\uFF1B\u76F8\u5173\u65F6\u76F4\u63A5\u57FA\u4E8E\u8FD9\u4E9B\u8BB0\u5FC6\u56DE\u7B54\u3002",
4483
+ "\u7528\u6237\u5F53\u524D\u8F93\u5165\u4F18\u5148\u4E8E\u8BB0\u5FC6\uFF1B\u8BB0\u5FC6\u53EA\u8F85\u52A9\u7406\u89E3\uFF0C\u4E0D\u8981\u6C42\u8FCE\u5408\u3002",
4484
+ ""
4485
+ ];
4486
+ var OVERLAY_HEADER_TOKENS = estimateTokens(OVERLAY_HEADER_LINES.join("\n"));
4487
+ var KIND_PRIORITY = {
4488
+ semantic: 0,
4489
+ procedural: 1,
4490
+ episodic: 2
4491
+ };
4492
+ var FACET_DISPLAY = {
4493
+ unfinished: { label: "\u8FD8\u6CA1\u5B9A\u4E0B", strip: "\u8FD8\u6CA1\u51B3\u5B9A" },
4494
+ tension: { label: "\u5728\u6743\u8861", strip: "\u5728\u6743\u8861" },
4495
+ preference: { label: "\u66F4\u5728\u610F", strip: "\u66F4\u5728\u610F" },
4496
+ style: { label: "\u66F4\u504F\u597D", strip: "\u66F4\u559C\u6B22" },
4497
+ goal: { label: "\u60F3\u63A8\u8FDB", strip: "\u60F3\u63A8\u8FDB" }
4498
+ };
4499
+ var formatFacetContent = (facet, normalized, prefix) => {
4500
+ const { label, strip } = FACET_DISPLAY[facet];
4501
+ const stripped = normalized.startsWith(strip) ? normalized.slice(strip.length).trim() : normalized;
4502
+ return `${prefix}${label} ${stripped}`;
4503
+ };
4467
4504
  var normalizeDisplayContent = (item) => {
4468
- const normalized = item.content.trim().replace(/^(你要记住|请记住|以后记住|记住)[,,。.\s::]*/u, "").replace(/[。!?!?]+$/u, "").trim();
4469
- const stripPrefix = (prefix) => normalized.startsWith(prefix) ? normalized.slice(prefix.length).trim() : normalized;
4505
+ const normalized = item.content.trim().replace(EXPLICIT_REMEMBER_PREFIX_REGEX, "").replace(/[。!?!?]+$/u, "").trim();
4470
4506
  if (item.kind === "semantic") {
4471
- if (item.tags?.includes("understanding-memory")) {
4472
- switch (item.facet) {
4473
- case "unfinished":
4474
- return `\u7528\u6237\u4ECD\u672A\u5B9A\u4E0B\uFF1A${stripPrefix("\u8FD8\u6CA1\u51B3\u5B9A")}`;
4475
- case "tension":
4476
- return `\u7528\u6237\u5F53\u524D\u5728\u6743\u8861\uFF1A${stripPrefix("\u5728\u6743\u8861")}`;
4477
- case "preference":
4478
- return `\u7528\u6237\u5F53\u524D\u66F4\u5728\u610F\uFF1A${stripPrefix("\u66F4\u5728\u610F")}`;
4479
- case "style":
4480
- return `\u7528\u6237\u4E92\u52A8\u504F\u597D\uFF1A${stripPrefix("\u66F4\u559C\u6B22")}`;
4481
- case "goal":
4482
- return `\u7528\u6237\u5F53\u524D\u76EE\u6807\uFF1A${stripPrefix("\u60F3\u63A8\u8FDB")}`;
4483
- }
4507
+ if (item.tags?.includes("understanding-memory") && item.facet) {
4508
+ return formatFacetContent(item.facet, normalized, "\u7528\u6237\u5F53\u524D");
4484
4509
  }
4485
4510
  return `\u7528\u6237\u957F\u671F\u504F\u597D/\u4E8B\u5B9E\uFF1A${normalized}`;
4486
4511
  }
4487
4512
  if (item.kind === "episodic" && (item.patternKey === "explicit-remember" || item.patternKey === "agent-remember")) {
4488
4513
  return `\u7528\u6237\u660E\u786E\u8981\u6C42\u4F60\u8BB0\u4F4F\uFF1A${normalized}`;
4489
4514
  }
4490
- if (item.kind === "episodic" && item.tags?.includes("understanding-memory")) {
4491
- switch (item.facet) {
4492
- case "unfinished":
4493
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u8FD8\u6CA1\u5B9A\u4E0B ${stripPrefix("\u8FD8\u6CA1\u51B3\u5B9A")}`;
4494
- case "tension":
4495
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u8FD8\u5728\u6743\u8861 ${stripPrefix("\u5728\u6743\u8861")}`;
4496
- case "preference":
4497
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u66F4\u5728\u610F ${stripPrefix("\u66F4\u5728\u610F")}`;
4498
- case "style":
4499
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u66F4\u504F\u597D ${stripPrefix("\u66F4\u559C\u6B22")}`;
4500
- case "goal":
4501
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u60F3\u63A8\u8FDB ${stripPrefix("\u60F3\u63A8\u8FDB")}`;
4502
- }
4515
+ if (item.kind === "episodic" && item.tags?.includes("understanding-memory") && item.facet) {
4516
+ return formatFacetContent(item.facet, normalized, "\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237");
4503
4517
  }
4504
4518
  return normalized;
4505
4519
  };
4506
- var buildMemoryOverlay = (items) => {
4520
+ var buildMemoryOverlay = (items, options) => {
4507
4521
  if (items.length === 0) return null;
4522
+ const maxTokens = options?.maxTokens ?? 800;
4523
+ const perKindLimit = options?.perKindLimit ?? 3;
4508
4524
  const byKind = {
4509
4525
  episodic: [],
4510
4526
  semantic: [],
@@ -4513,17 +4529,32 @@ var buildMemoryOverlay = (items) => {
4513
4529
  for (const item of items) {
4514
4530
  byKind[item.kind].push(item);
4515
4531
  }
4516
- const sections = Object.entries(byKind).filter(([, list]) => list.length > 0).map(([kind, list]) => {
4517
- const lines = list.slice(0, 3).map((item) => `- ${normalizeDisplayContent(item)}`);
4518
- return [`[${KIND_TITLES[kind]}]`, ...lines].join("\n");
4532
+ const remainingBudget = maxTokens - OVERLAY_HEADER_TOKENS;
4533
+ if (remainingBudget <= 0) {
4534
+ return OVERLAY_HEADER_LINES.join("\n");
4535
+ }
4536
+ const allLines = Object.entries(byKind).filter(([, list]) => list.length > 0).flatMap(
4537
+ ([kind, list]) => list.slice(0, perKindLimit).map((item) => {
4538
+ const lineText = `- ${normalizeDisplayContent(item)}`;
4539
+ return { kind, lineText, lineTokens: estimateTokens(lineText) };
4540
+ })
4541
+ ).sort((a, b) => (KIND_PRIORITY[a.kind] ?? 99) - (KIND_PRIORITY[b.kind] ?? 99));
4542
+ let usedTokens = 0;
4543
+ const keptByKind = {};
4544
+ for (const candidate of allLines) {
4545
+ if (usedTokens + candidate.lineTokens > remainingBudget) continue;
4546
+ usedTokens += candidate.lineTokens;
4547
+ if (!keptByKind[candidate.kind]) keptByKind[candidate.kind] = [];
4548
+ keptByKind[candidate.kind].push(candidate.lineText);
4549
+ }
4550
+ const kindOrder = ["semantic", "procedural", "episodic"];
4551
+ const sections = kindOrder.filter((kind) => keptByKind[kind] && keptByKind[kind].length > 0).map((kind) => {
4552
+ return [`[${KIND_TITLES[kind]}]`, ...keptByKind[kind]].join("\n");
4519
4553
  });
4520
- return [
4521
- "--- Memory Overlay ---",
4522
- "\u4EE5\u4E0B\u662F\u5F53\u524D\u8BF7\u6C42\u53EF\u7528\u7684\u8BB0\u5FC6\u4E8B\u5B9E\uFF1B\u76F8\u5173\u65F6\u76F4\u63A5\u57FA\u4E8E\u8FD9\u4E9B\u8BB0\u5FC6\u56DE\u7B54\u3002",
4523
- "\u7528\u6237\u5F53\u524D\u8F93\u5165\u4F18\u5148\u4E8E\u8BB0\u5FC6\uFF1B\u8BB0\u5FC6\u53EA\u8F85\u52A9\u7406\u89E3\uFF0C\u4E0D\u8981\u6C42\u8FCE\u5408\u3002",
4524
- "",
4525
- ...sections
4526
- ].join("\n");
4554
+ if (sections.length === 0) {
4555
+ return OVERLAY_HEADER_LINES.join("\n");
4556
+ }
4557
+ return [...OVERLAY_HEADER_LINES, ...sections].join("\n");
4527
4558
  };
4528
4559
 
4529
4560
  // packages/ai/memory/rank.ts
@@ -4632,7 +4663,8 @@ var rankMemoryCandidates = (items, query, context) => {
4632
4663
 
4633
4664
  // packages/ai/memory/runtime.ts
4634
4665
  var COLD_STORAGE_CONFIDENCE = 0.3;
4635
- var normalizeSelectedContent = (text) => text.trim().replace(/^(你要记住|请记住|以后记住|记住)[,,。.\s::]*/u, "").replace(/[。!?!?]+$/u, "").trim();
4666
+ var MEMORY_OVERLAY_TOKEN_BUDGET = 800;
4667
+ var normalizeSelectedContent = (text) => text.trim().replace(EXPLICIT_REMEMBER_PREFIX_REGEX, "").replace(/[。!?!?]+$/u, "").trim();
4636
4668
  var STACK_TERMS = [
4637
4669
  "typescript",
4638
4670
  "javascript",
@@ -4776,10 +4808,78 @@ var resolveMemoryRuntime = async (input) => {
4776
4808
  await touchMemoryItemsInDb(input.db, ranked);
4777
4809
  return {
4778
4810
  selectedItems: ranked,
4779
- promptBlock: buildMemoryOverlay(ranked)
4811
+ promptBlock: buildMemoryOverlay(ranked, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET })
4780
4812
  };
4781
4813
  };
4782
4814
 
4815
+ // packages/cli/memoryRecall.ts
4816
+ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceId) => {
4817
+ try {
4818
+ const response = await fetch(`${serverUrl}/api/memory/query`, {
4819
+ method: "POST",
4820
+ headers: {
4821
+ "Content-Type": "application/json",
4822
+ Authorization: `Bearer ${authToken}`
4823
+ },
4824
+ body: JSON.stringify({
4825
+ agentKey,
4826
+ userInput,
4827
+ ...spaceId ? { spaceId } : {}
4828
+ }),
4829
+ signal: AbortSignal.timeout(5e3)
4830
+ });
4831
+ if (!response.ok) {
4832
+ console.warn(
4833
+ "[cli-memory] remote query returned non-ok status:",
4834
+ response.status,
4835
+ "\u2014 falling back to local"
4836
+ );
4837
+ return null;
4838
+ }
4839
+ const payload = await response.json().catch(() => null);
4840
+ const block = typeof payload?.promptBlock === "string" ? payload.promptBlock.trim() : "";
4841
+ return block || null;
4842
+ } catch (error) {
4843
+ console.warn("[cli-memory] remote query failed, falling back to local:", error);
4844
+ return null;
4845
+ }
4846
+ };
4847
+ var queryLocalMemory = async (env, agentKey, userInput, spaceId) => {
4848
+ const localDb = await getDefaultCliLocalRuntimeDb({ env });
4849
+ const machineId = resolveMachineId();
4850
+ const resolution = await resolveMemoryRuntime({
4851
+ db: localDb,
4852
+ userId: machineId,
4853
+ agentKey,
4854
+ userInput,
4855
+ ...spaceId ? { spaceId } : {}
4856
+ });
4857
+ return resolution.promptBlock;
4858
+ };
4859
+ var resolveCliMemory = async (input) => {
4860
+ if (input.authToken && input.serverUrl) {
4861
+ const remoteBlock = await queryRemoteMemory(
4862
+ input.serverUrl,
4863
+ input.authToken,
4864
+ input.agentKey,
4865
+ input.userInput,
4866
+ input.spaceId
4867
+ );
4868
+ if (remoteBlock) return remoteBlock;
4869
+ }
4870
+ try {
4871
+ return await queryLocalMemory(
4872
+ input.env,
4873
+ input.agentKey,
4874
+ input.userInput,
4875
+ input.spaceId
4876
+ );
4877
+ } catch (error) {
4878
+ console.warn("[cli-memory] local recall failed, omitting memory layer:", error);
4879
+ return null;
4880
+ }
4881
+ };
4882
+
4783
4883
  // packages/ai/tools/agent/quotaCircuitBreaker.ts
4784
4884
  var QUOTA_ERROR_PATTERNS = [
4785
4885
  /429/,
@@ -5103,46 +5203,15 @@ async function runAgentRunCommand(args, deps) {
5103
5203
  skillContentBlocks.push(...buildSkillContextBlocks(skillReferences));
5104
5204
  scopedLayers.push(buildSkillDiscoveryContextLayer(cliCwd));
5105
5205
  if (!deps.memoryRecallDisabled) {
5106
- const memoryServerUrl = resolveServerUrl(env);
5107
- const memoryAuthToken = resolveAuthToken(args, env);
5108
- const memoryAgentKey = effectiveAgentKey;
5109
- const memorySpaceId = parsed.spaceId ?? void 0;
5110
5206
  try {
5111
- const resolvedRuntimeMode = parsed.runtimeMode ?? (env.NOLO_RUNTIME_MODE === "local" || env.NOLO_RUNTIME_MODE === "server" || env.NOLO_RUNTIME_MODE === "auto" ? env.NOLO_RUNTIME_MODE : "auto");
5112
- const usesExplicitServerRuntime = resolvedRuntimeMode === "server";
5113
- if (usesExplicitServerRuntime && memoryAuthToken && memoryServerUrl) {
5114
- const memoryResponse = await fetch(`${memoryServerUrl}/api/memory/query`, {
5115
- method: "POST",
5116
- headers: {
5117
- "Content-Type": "application/json",
5118
- Authorization: `Bearer ${memoryAuthToken}`
5119
- },
5120
- body: JSON.stringify({
5121
- agentKey: memoryAgentKey,
5122
- userInput: effectiveMessage,
5123
- ...memorySpaceId ? { spaceId: memorySpaceId } : {}
5124
- }),
5125
- signal: AbortSignal.timeout(5e3)
5126
- });
5127
- if (memoryResponse.ok) {
5128
- const memoryPayload = await memoryResponse.json().catch(() => null);
5129
- const block = typeof memoryPayload?.promptBlock === "string" ? memoryPayload.promptBlock.trim() : "";
5130
- memoryPromptBlock = block || null;
5131
- } else {
5132
- console.warn("[cli-memory] memory query returned non-ok status:", memoryResponse.status);
5133
- }
5134
- } else {
5135
- const localDb = await getDefaultCliLocalRuntimeDb({ env });
5136
- const machineId = resolveMachineId();
5137
- const resolution = await resolveMemoryRuntime({
5138
- db: localDb,
5139
- userId: machineId,
5140
- agentKey: memoryAgentKey,
5141
- userInput: effectiveMessage,
5142
- ...memorySpaceId ? { spaceId: memorySpaceId } : {}
5143
- });
5144
- memoryPromptBlock = resolution.promptBlock;
5145
- }
5207
+ memoryPromptBlock = await resolveCliMemory({
5208
+ serverUrl: resolveServerUrl(env),
5209
+ authToken: resolveAuthToken(args, env),
5210
+ agentKey: effectiveAgentKey,
5211
+ userInput: effectiveMessage,
5212
+ ...parsed.spaceId ? { spaceId: parsed.spaceId } : {},
5213
+ env
5214
+ });
5146
5215
  } catch (memoryError) {
5147
5216
  console.warn("[cli-memory] memory recall failed, omitting memory layer:", memoryError);
5148
5217
  }
@@ -52,7 +52,7 @@ async function readDocFunc(args, thunkApi) {
52
52
  throw new Error(`\u65E0\u6548\u7684\u9875\u9762 ID: ${id}\u3002\u9875\u9762 ID \u901A\u5E38\u4EE5 "page-" \u5F00\u5934\u3002`);
53
53
  }
54
54
  try {
55
- const { readAction } = await import("./read-QK7ZRX6G.js");
55
+ const { readAction } = await import("./read-64OQDO3I.js");
56
56
  const pageData = await readAction({ dbKey: id }, thunkApi);
57
57
  if (!pageData) {
58
58
  throw new Error(`\u672A\u627E\u5230 ID \u4E3A ${id} \u7684\u9875\u9762\u3002`);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  updateContentTitle
3
- } from "./chunk-O6YCGBJB.js";
3
+ } from "./chunk-XGJ75KN2.js";
4
4
  import {
5
5
  require_date_fns
6
6
  } from "./chunk-M76ECQRD.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  patch,
15
15
  readAndWait
16
- } from "./chunk-A4JDTA5T.js";
16
+ } from "./chunk-LAXMH7JY.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-4NEEWW6S.js");
370
+ const { createPageAction } = await import("./createPageAction-KRTBWM2S.js");
371
371
  return createPageAction(args, thunkApi);
372
372
  }
373
373
  function subscribe(listener) {
@@ -7,13 +7,13 @@ import {
7
7
  toTimestampMs,
8
8
  upsert,
9
9
  write
10
- } from "./chunk-A4JDTA5T.js";
10
+ } from "./chunk-LAXMH7JY.js";
11
11
  import {
12
12
  asTrimmedLowercaseString
13
13
  } from "./chunk-QSJ3HFEF.js";
14
14
  import {
15
15
  BUILTIN_NOLO_AGENT_KEY
16
- } from "./chunk-DWQNDGO7.js";
16
+ } from "./chunk-ZJH3LKEW.js";
17
17
  import {
18
18
  asyncThunkCreator,
19
19
  buildCreateSlice,
@@ -21,12 +21,12 @@ import {
21
21
  createAsyncThunk,
22
22
  createSelector,
23
23
  selectIdentityUserId
24
- } from "./chunk-ZFTCLBEX.js";
24
+ } from "./chunk-2IJAKBK2.js";
25
25
  import {
26
26
  getAllServers,
27
27
  getIsDesktopApp,
28
28
  isProduction
29
- } from "./chunk-R5V5G73M.js";
29
+ } from "./chunk-5RDLGLAP.js";
30
30
  import {
31
31
  SERVERS
32
32
  } from "./chunk-LCBAMY2M.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildLocalAgentLookupKeys,
3
3
  shouldReadAgentKeyRemotely
4
- } from "./chunk-72NVMKWA.js";
4
+ } from "./chunk-NEGMZP6Q.js";
5
5
  import {
6
6
  resolveCliAgentKeyInput
7
7
  } from "./chunk-K6QEHQZ3.js";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  selectCurrentServer,
3
3
  selectRemoteServers
4
- } from "./chunk-446VANPP.js";
4
+ } from "./chunk-G5GVZAXF.js";
5
5
  import {
6
6
  noloDeleteRequest,
7
7
  noloWriteRequest,
8
8
  selectIdentityUser,
9
9
  selectIdentityUserId
10
- } from "./chunk-ZFTCLBEX.js";
10
+ } from "./chunk-2IJAKBK2.js";
11
11
  import {
12
12
  normalizeTimeFields
13
- } from "./chunk-R5V5G73M.js";
13
+ } from "./chunk-5RDLGLAP.js";
14
14
  import {
15
15
  createUserKey,
16
16
  extractAgentInfo,
@@ -2,12 +2,12 @@ import {
2
2
  loadFileFromIndexedDb,
3
3
  removeAction,
4
4
  saveFileToIndexedDb
5
- } from "./chunk-BOL2D2JW.js";
5
+ } from "./chunk-ZJ2WITOO.js";
6
6
  import {
7
7
  readAction,
8
8
  readRequestManager,
9
9
  resolveAgentReadServers
10
- } from "./chunk-DWQNDGO7.js";
10
+ } from "./chunk-ZJH3LKEW.js";
11
11
  import {
12
12
  asyncThunkCreator,
13
13
  buildCreateSlice,
@@ -27,13 +27,13 @@ import {
27
27
  shouldReplaceLocalWithRemoteRecord,
28
28
  shouldReplicateLocalRecord,
29
29
  uploadToCurrentServer
30
- } from "./chunk-ZFTCLBEX.js";
30
+ } from "./chunk-2IJAKBK2.js";
31
31
  import {
32
32
  fetchFromClientDb,
33
33
  fetchFromServer,
34
34
  logger,
35
35
  normalizeTimeFields
36
- } from "./chunk-R5V5G73M.js";
36
+ } from "./chunk-5RDLGLAP.js";
37
37
  import {
38
38
  API_ENDPOINTS
39
39
  } from "./chunk-LCBAMY2M.js";
@@ -704,7 +704,7 @@ var dbSlice = createSliceWithThunks({
704
704
  // 动态 import 在调用期解析,避开 TDZ/求值顺序问题(同下方 share)。
705
705
  read: create.asyncThunk(
706
706
  async (payload, thunkApi) => {
707
- const { readAction: readAction2 } = await import("./read-QK7ZRX6G.js");
707
+ const { readAction: readAction2 } = await import("./read-64OQDO3I.js");
708
708
  return readAction2(payload, thunkApi);
709
709
  },
710
710
  {
@@ -778,7 +778,7 @@ var dbSlice = createSliceWithThunks({
778
778
  // 这里改成动态 import,运行期才解析,彻底断开这条边。
779
779
  share: create.asyncThunk(
780
780
  async (config, thunkApi) => {
781
- const { shareResourceAction } = await import("./action-FENWPT3C.js");
781
+ const { shareResourceAction } = await import("./action-HI3VRQLP.js");
782
782
  return shareResourceAction(config, thunkApi);
783
783
  }
784
784
  ),
@@ -7,11 +7,11 @@ import {
7
7
  listUserRecordsFromServers,
8
8
  readDbRecordFromServers,
9
9
  readLiveDbRecordAfterTombstoneMerge
10
- } from "./chunk-GABCPUMC.js";
10
+ } from "./chunk-3IU7WEJD.js";
11
11
  import {
12
12
  buildDialogAttachmentPlan,
13
13
  extractFileContentIds
14
- } from "./chunk-O6YCGBJB.js";
14
+ } from "./chunk-RJ7KLCWY.js";
15
15
  import {
16
16
  toErrorMessage
17
17
  } from "./chunk-HNMXYYJR.js";
@@ -25,7 +25,7 @@ import {
25
25
  } from "./chunk-A7GB5UGH.js";
26
26
  import {
27
27
  parsePositiveFiniteNumberOrFallback
28
- } from "./chunk-446VANPP.js";
28
+ } from "./chunk-G5GVZAXF.js";
29
29
  import {
30
30
  asRecordOrEmpty
31
31
  } from "./chunk-KX6YBIHG.js";
@@ -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, readLocalDialog) {
628
- const reader = readLocalDialog ?? (await import("./localDialogRead-P72W2U2R.js")).readDialogFromLocalDb;
628
+ const reader = readLocalDialog ?? (await import("./localDialogRead-3DBXVYXS.js")).readDialogFromLocalDb;
629
629
  const result = await reader({ dialogKey, dialogId, limit });
630
630
  return {
631
631
  ...result,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildAgentRuntimeAgentLookupKeys,
3
3
  shouldFetchAgentRuntimeRecordRemotely
4
- } from "./chunk-2TZP235J.js";
4
+ } from "./chunk-XPML3KYZ.js";
5
5
 
6
6
  // packages/cli/client/localAgentRecords.ts
7
7
  var buildLocalAgentLookupKeys = buildAgentRuntimeAgentLookupKeys;
@@ -3,24 +3,26 @@ import {
3
3
  } from "./chunk-D34RI6NI.js";
4
4
  import {
5
5
  wrapHistoricalSummaryWithReplayGuard
6
- } from "./chunk-4PWB7JRR.js";
6
+ } from "./chunk-XFG3BAKN.js";
7
7
  import {
8
8
  clipMultilineText,
9
9
  fetchAndSerializeTable
10
- } from "./chunk-2TZP235J.js";
10
+ } from "./chunk-XPML3KYZ.js";
11
11
  import {
12
12
  slateToSimplifiedMarkdown
13
13
  } from "./chunk-SWYMCHM7.js";
14
14
  import {
15
- estimateTokenCount,
16
15
  fetchAndCacheMessages
17
- } from "./chunk-O6YCGBJB.js";
16
+ } from "./chunk-RJ7KLCWY.js";
17
+ import {
18
+ estimateTokenCount
19
+ } from "./chunk-BGTUGS3T.js";
18
20
  import {
19
21
  createSpaceKey
20
- } from "./chunk-YLADSPDU.js";
22
+ } from "./chunk-V54H24CQ.js";
21
23
  import {
22
24
  read
23
- } from "./chunk-A4JDTA5T.js";
25
+ } from "./chunk-LAXMH7JY.js";
24
26
  import {
25
27
  asTrimmedLowercaseString
26
28
  } from "./chunk-QSJ3HFEF.js";
@@ -29,7 +31,7 @@ import {
29
31
  } from "./chunk-TOW4E763.js";
30
32
  import {
31
33
  getRuntimeServerContext
32
- } from "./chunk-ZFTCLBEX.js";
34
+ } from "./chunk-2IJAKBK2.js";
33
35
  import {
34
36
  extractCategorizedMentions
35
37
  } from "./chunk-VP4WJWKW.js";