nolo-cli 0.31.0-alpha.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.
@@ -7,7 +7,7 @@ import {
7
7
  prependSubjectDialogMarker,
8
8
  resolveWorkflowReference,
9
9
  runAgentRunCommand
10
- } from "./chunk-H6COXALE.js";
10
+ } from "./chunk-EB5AQGXR.js";
11
11
  import {
12
12
  parseAgentRunArgs
13
13
  } from "./chunk-AOS5IN2I.js";
@@ -4458,6 +4458,9 @@ 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",
@@ -4486,42 +4489,31 @@ var KIND_PRIORITY = {
4486
4489
  procedural: 1,
4487
4490
  episodic: 2
4488
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
+ };
4489
4504
  var normalizeDisplayContent = (item) => {
4490
- const normalized = item.content.trim().replace(/^(你要记住|请记住|以后记住|记住)[,,。.\s::]*/u, "").replace(/[。!?!?]+$/u, "").trim();
4491
- 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();
4492
4506
  if (item.kind === "semantic") {
4493
- if (item.tags?.includes("understanding-memory")) {
4494
- switch (item.facet) {
4495
- case "unfinished":
4496
- return `\u7528\u6237\u4ECD\u672A\u5B9A\u4E0B\uFF1A${stripPrefix("\u8FD8\u6CA1\u51B3\u5B9A")}`;
4497
- case "tension":
4498
- return `\u7528\u6237\u5F53\u524D\u5728\u6743\u8861\uFF1A${stripPrefix("\u5728\u6743\u8861")}`;
4499
- case "preference":
4500
- return `\u7528\u6237\u5F53\u524D\u66F4\u5728\u610F\uFF1A${stripPrefix("\u66F4\u5728\u610F")}`;
4501
- case "style":
4502
- return `\u7528\u6237\u4E92\u52A8\u504F\u597D\uFF1A${stripPrefix("\u66F4\u559C\u6B22")}`;
4503
- case "goal":
4504
- return `\u7528\u6237\u5F53\u524D\u76EE\u6807\uFF1A${stripPrefix("\u60F3\u63A8\u8FDB")}`;
4505
- }
4507
+ if (item.tags?.includes("understanding-memory") && item.facet) {
4508
+ return formatFacetContent(item.facet, normalized, "\u7528\u6237\u5F53\u524D");
4506
4509
  }
4507
4510
  return `\u7528\u6237\u957F\u671F\u504F\u597D/\u4E8B\u5B9E\uFF1A${normalized}`;
4508
4511
  }
4509
4512
  if (item.kind === "episodic" && (item.patternKey === "explicit-remember" || item.patternKey === "agent-remember")) {
4510
4513
  return `\u7528\u6237\u660E\u786E\u8981\u6C42\u4F60\u8BB0\u4F4F\uFF1A${normalized}`;
4511
4514
  }
4512
- if (item.kind === "episodic" && item.tags?.includes("understanding-memory")) {
4513
- switch (item.facet) {
4514
- case "unfinished":
4515
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u8FD8\u6CA1\u5B9A\u4E0B ${stripPrefix("\u8FD8\u6CA1\u51B3\u5B9A")}`;
4516
- case "tension":
4517
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u8FD8\u5728\u6743\u8861 ${stripPrefix("\u5728\u6743\u8861")}`;
4518
- case "preference":
4519
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u66F4\u5728\u610F ${stripPrefix("\u66F4\u5728\u610F")}`;
4520
- case "style":
4521
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u66F4\u504F\u597D ${stripPrefix("\u66F4\u559C\u6B22")}`;
4522
- case "goal":
4523
- return `\u6700\u8FD1\u4E00\u6B21\u5BF9\u8BDD\u663E\u793A\uFF1A\u7528\u6237\u60F3\u63A8\u8FDB ${stripPrefix("\u60F3\u63A8\u8FDB")}`;
4524
- }
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");
4525
4517
  }
4526
4518
  return normalized;
4527
4519
  };
@@ -4537,27 +4529,16 @@ var buildMemoryOverlay = (items, options) => {
4537
4529
  for (const item of items) {
4538
4530
  byKind[item.kind].push(item);
4539
4531
  }
4540
- const cappedByKind = Object.entries(byKind).filter(([, list]) => list.length > 0).map(([kind, list]) => [kind, list.slice(0, perKindLimit)]);
4541
4532
  const remainingBudget = maxTokens - OVERLAY_HEADER_TOKENS;
4542
4533
  if (remainingBudget <= 0) {
4543
4534
  return OVERLAY_HEADER_LINES.join("\n");
4544
4535
  }
4545
- const allLines = [];
4546
- for (const [kind, list] of cappedByKind) {
4547
- for (const item of list) {
4536
+ const allLines = Object.entries(byKind).filter(([, list]) => list.length > 0).flatMap(
4537
+ ([kind, list]) => list.slice(0, perKindLimit).map((item) => {
4548
4538
  const lineText = `- ${normalizeDisplayContent(item)}`;
4549
- allLines.push({
4550
- kind,
4551
- lineText,
4552
- lineTokens: estimateTokens(lineText)
4553
- });
4554
- }
4555
- }
4556
- allLines.sort((a, b) => {
4557
- const pa = KIND_PRIORITY[a.kind] ?? 99;
4558
- const pb = KIND_PRIORITY[b.kind] ?? 99;
4559
- return pa - pb;
4560
- });
4539
+ return { kind, lineText, lineTokens: estimateTokens(lineText) };
4540
+ })
4541
+ ).sort((a, b) => (KIND_PRIORITY[a.kind] ?? 99) - (KIND_PRIORITY[b.kind] ?? 99));
4561
4542
  let usedTokens = 0;
4562
4543
  const keptByKind = {};
4563
4544
  for (const candidate of allLines) {
@@ -4683,7 +4664,7 @@ var rankMemoryCandidates = (items, query, context) => {
4683
4664
  // packages/ai/memory/runtime.ts
4684
4665
  var COLD_STORAGE_CONFIDENCE = 0.3;
4685
4666
  var MEMORY_OVERLAY_TOKEN_BUDGET = 800;
4686
- var normalizeSelectedContent = (text) => text.trim().replace(/^(你要记住|请记住|以后记住|记住)[,,。.\s::]*/u, "").replace(/[。!?!?]+$/u, "").trim();
4667
+ var normalizeSelectedContent = (text) => text.trim().replace(EXPLICIT_REMEMBER_PREFIX_REGEX, "").replace(/[。!?!?]+$/u, "").trim();
4687
4668
  var STACK_TERMS = [
4688
4669
  "typescript",
4689
4670
  "javascript",
@@ -4831,6 +4812,74 @@ var resolveMemoryRuntime = async (input) => {
4831
4812
  };
4832
4813
  };
4833
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
+
4834
4883
  // packages/ai/tools/agent/quotaCircuitBreaker.ts
4835
4884
  var QUOTA_ERROR_PATTERNS = [
4836
4885
  /429/,
@@ -5154,46 +5203,15 @@ async function runAgentRunCommand(args, deps) {
5154
5203
  skillContentBlocks.push(...buildSkillContextBlocks(skillReferences));
5155
5204
  scopedLayers.push(buildSkillDiscoveryContextLayer(cliCwd));
5156
5205
  if (!deps.memoryRecallDisabled) {
5157
- const memoryServerUrl = resolveServerUrl(env);
5158
- const memoryAuthToken = resolveAuthToken(args, env);
5159
- const memoryAgentKey = effectiveAgentKey;
5160
- const memorySpaceId = parsed.spaceId ?? void 0;
5161
5206
  try {
5162
- const resolvedRuntimeMode = parsed.runtimeMode ?? (env.NOLO_RUNTIME_MODE === "local" || env.NOLO_RUNTIME_MODE === "server" || env.NOLO_RUNTIME_MODE === "auto" ? env.NOLO_RUNTIME_MODE : "auto");
5163
- const usesExplicitServerRuntime = resolvedRuntimeMode === "server";
5164
- if (usesExplicitServerRuntime && memoryAuthToken && memoryServerUrl) {
5165
- const memoryResponse = await fetch(`${memoryServerUrl}/api/memory/query`, {
5166
- method: "POST",
5167
- headers: {
5168
- "Content-Type": "application/json",
5169
- Authorization: `Bearer ${memoryAuthToken}`
5170
- },
5171
- body: JSON.stringify({
5172
- agentKey: memoryAgentKey,
5173
- userInput: effectiveMessage,
5174
- ...memorySpaceId ? { spaceId: memorySpaceId } : {}
5175
- }),
5176
- signal: AbortSignal.timeout(5e3)
5177
- });
5178
- if (memoryResponse.ok) {
5179
- const memoryPayload = await memoryResponse.json().catch(() => null);
5180
- const block = typeof memoryPayload?.promptBlock === "string" ? memoryPayload.promptBlock.trim() : "";
5181
- memoryPromptBlock = block || null;
5182
- } else {
5183
- console.warn("[cli-memory] memory query returned non-ok status:", memoryResponse.status);
5184
- }
5185
- } else {
5186
- const localDb = await getDefaultCliLocalRuntimeDb({ env });
5187
- const machineId = resolveMachineId();
5188
- const resolution = await resolveMemoryRuntime({
5189
- db: localDb,
5190
- userId: machineId,
5191
- agentKey: memoryAgentKey,
5192
- userInput: effectiveMessage,
5193
- ...memorySpaceId ? { spaceId: memorySpaceId } : {}
5194
- });
5195
- memoryPromptBlock = resolution.promptBlock;
5196
- }
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
+ });
5197
5215
  } catch (memoryError) {
5198
5216
  console.warn("[cli-memory] memory recall failed, omitting memory layer:", memoryError);
5199
5217
  }
package/index.js CHANGED
@@ -126,7 +126,7 @@ function createDaemonShortcutCommand(path, description, command2) {
126
126
  // packages/cli/agentInternalCommandEntries.ts
127
127
  function getAgentInternalCommandEntries() {
128
128
  const createAgentRunCommand = (path, description) => createContextCommand(path, description, async (args2, ctx) => {
129
- const { runAgentRunCommand } = await import("./agentRunCommand-LH4RA6FA.js");
129
+ const { runAgentRunCommand } = await import("./agentRunCommand-QDNDC76O.js");
130
130
  return runAgentRunCommand(args2, {
131
131
  env: ctx.env,
132
132
  scriptDir: ctx.scriptDir,
@@ -796,7 +796,7 @@ async function runScript(script, forwardedArgs, env) {
796
796
  return proc.exited;
797
797
  }
798
798
  async function launchTuiWorkspace(args2) {
799
- const { startTuiWorkspace } = await import("./readlineWorkspace-S4A6UYVJ.js");
799
+ const { startTuiWorkspace } = await import("./readlineWorkspace-35GFHS37.js");
800
800
  const { createTuiSummaryLlmCaller } = await import("./tuiSummaryLlmCaller-SRZ4QQUP.js");
801
801
  return startTuiWorkspace({
802
802
  ...args2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nolo-cli",
3
- "version": "0.31.0-alpha.1",
3
+ "version": "0.31.0-alpha.2",
4
4
  "type": "module",
5
5
  "description": "Agent-first terminal workspace for Nolo",
6
6
  "bin": {
@@ -57,7 +57,7 @@ import {
57
57
  visibleWidth,
58
58
  wrapTextToLines,
59
59
  wrapTranscriptLine
60
- } from "./chunk-H6COXALE.js";
60
+ } from "./chunk-EB5AQGXR.js";
61
61
  import "./chunk-AOS5IN2I.js";
62
62
  import "./chunk-6HYVJV7B.js";
63
63
  import {