nolo-cli 0.185.0-alpha.3 → 0.186.0-alpha.1

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 (62) hide show
  1. package/{_executeModel-5SGPPCT6.js → _executeModel-35LFG5KF.js} +12 -12
  2. package/{agentDeleteCommand-RUBWHUMZ.js → agentDeleteCommand-TMFQR6QL.js} +11 -11
  3. package/{agentEmailCommands-RXCDWZDW.js → agentEmailCommands-JZ6GYJ4H.js} +13 -13
  4. package/{agentListCommands-PRG4ZBJC.js → agentListCommands-PFZRMIAI.js} +2 -2
  5. package/{agentMachineCommands-SPQ3CCYU.js → agentMachineCommands-BT643ADE.js} +3 -3
  6. package/{agentRecordCommands-AKAQ7BRK.js → agentRecordCommands-LJ5EWR67.js} +12 -12
  7. package/{agentRunCommand-S3VSGTS4.js → agentRunCommand-6CPXONR3.js} +14 -14
  8. package/{agentRuntimeLocal-CBDP2OYK.js → agentRuntimeLocal-3QBUFZEC.js} +2 -2
  9. package/{agentSlice-2PEJP3NV.js → agentSlice-RW25WUPR.js} +1 -1
  10. package/{appDeleteCommands-OP4GGXEJ.js → appDeleteCommands-WEBDQMVH.js} +2 -2
  11. package/{appDeployCommands-LHTVLNL5.js → appDeployCommands-HFZ3I7Z4.js} +2 -2
  12. package/{appDeployStatusCommands-BSDDQU7S.js → appDeployStatusCommands-TVBQOFIY.js} +2 -2
  13. package/{appGetCommands-LNHGUJKF.js → appGetCommands-Y5RKR25C.js} +2 -2
  14. package/{appListCommands-RGOFZV5M.js → appListCommands-4UZIZPB3.js} +2 -2
  15. package/{chunk-D4JCY67U.js → chunk-37ZDGCX6.js} +10 -9
  16. package/{chunk-IOQHM7ID.js → chunk-4ALQFIFF.js} +720 -92
  17. package/{chunk-VXCDYN6M.js → chunk-4GZ2LY5F.js} +12 -8
  18. package/{chunk-MIPGIRJJ.js → chunk-6HFMPUSN.js} +2 -2
  19. package/{chunk-AU7AXHUL.js → chunk-7KWPNGVJ.js} +57 -21
  20. package/{chunk-7DPEOMDL.js → chunk-BRBG72OP.js} +7 -7
  21. package/{chunk-DWTNJZ63.js → chunk-CDUK5BF6.js} +2 -2
  22. package/{chunk-YXTQJ2QR.js → chunk-DK7QNJVM.js} +2 -2
  23. package/{chunk-BJPALUYR.js → chunk-ECAGROXS.js} +2 -2
  24. package/{chunk-M4JDIVIS.js → chunk-IOB5RBBZ.js} +1 -1
  25. package/{chunk-JJU5FBYH.js → chunk-J5Y3BXJP.js} +124 -22
  26. package/{chunk-HRLKX6YP.js → chunk-PEOLOK72.js} +1 -1
  27. package/{chunk-WVIBJBDF.js → chunk-PL6YNOF7.js} +10 -10
  28. package/chunk-Q6RMLYSA.js +385 -0
  29. package/{chunk-CN6T5QKA.js → chunk-QBMO66MI.js} +3 -3
  30. package/{chunk-NCC2SYOD.js → chunk-SIX7N4AH.js} +2 -2
  31. package/{chunk-ZYI6K46I.js → chunk-TB7E6UEO.js} +1 -1
  32. package/{chunk-DBEIHUCJ.js → chunk-VMMS7L64.js} +3 -3
  33. package/{chunk-7YW5OUQE.js → chunk-XJECR5M3.js} +2 -2
  34. package/{chunk-ZU2BF6Q4.js → chunk-ZV6ESGA7.js} +2 -2
  35. package/{chunk-MROMTEHV.js → chunk-ZXUPGFJ5.js} +6 -6
  36. package/{commandRegistry-OTD2XOHY.js → commandRegistry-6EEZMM43.js} +40 -40
  37. package/{contentThunks-BSCTL5G3.js → contentThunks-EPHFLF62.js} +3 -3
  38. package/{createAgentAutomationAction-Y5W2FW3Y.js → createAgentAutomationAction-MFE4QIL4.js} +3 -3
  39. package/{createDialogAction-GIZ7QCRQ.js → createDialogAction-SGOXQ7BC.js} +4 -4
  40. package/{createPageAction-GFH4DXMX.js → createPageAction-OTNUT7WI.js} +3 -3
  41. package/{dialogCommands-6MR232CJ.js → dialogCommands-KNE72SUM.js} +2 -2
  42. package/{dialogSlice-U3X3CBR7.js → dialogSlice-PHPLFD5F.js} +2 -2
  43. package/{docCreateCommands-DAZJ2Y5E.js → docCreateCommands-MG67RHCR.js} +2 -2
  44. package/{docDeleteCommands-XO26LNIO.js → docDeleteCommands-2UAG5JVZ.js} +2 -2
  45. package/{docReadCommands-77XGRLD6.js → docReadCommands-JKJJ4FNU.js} +2 -2
  46. package/{docStore-H2XCYODR.js → docStore-HI7P3MVA.js} +1 -1
  47. package/{docUpdateCommands-QXN3MJAJ.js → docUpdateCommands-6D7ADVPS.js} +2 -2
  48. package/{handleSendMessageAction-MZKFIPYL.js → handleSendMessageAction-YAO4RDWU.js} +8 -8
  49. package/index.js +3 -3
  50. package/{localRuntimeAdapter-E2QDYFTW.js → localRuntimeAdapter-4J62I4YU.js} +11 -11
  51. package/{machineCommands-SQELO6HH.js → machineCommands-XW5I55QW.js} +12 -12
  52. package/{machineWsRunDispatch-E33LUXWG.js → machineWsRunDispatch-W5VEHHMI.js} +12 -12
  53. package/package.json +1 -1
  54. package/{readlineWorkspace-B2MGBCUY.js → readlineWorkspace-EE6JMRIW.js} +14 -14
  55. package/{runAgentClientLoop-JRW5EA5U.js → runAgentClientLoop-BU6GOWQI.js} +10 -10
  56. package/skillDiscovery-F3TMVQOJ.js +28 -0
  57. package/{spaceCommands-PHLKQ2AW.js → spaceCommands-GTQQ6GFS.js} +2 -2
  58. package/{streamAgentChatTurn-CBGAGRQL.js → streamAgentChatTurn-MHRXV7XZ.js} +13 -13
  59. package/{tools-RVVZ2Y6V.js → tools-YA5NIWI7.js} +7 -7
  60. package/{updateDialogTitleAction-2RKLYUPB.js → updateDialogTitleAction-M6U2VK5L.js} +3 -3
  61. package/chunk-VEA7H5FG.js +0 -173
  62. package/skillDiscovery-QC35EQY4.js +0 -18
@@ -9,7 +9,7 @@ import {
9
9
  resolveRawAgentInput,
10
10
  resolveServerUrl,
11
11
  writeUsage
12
- } from "./chunk-ZYI6K46I.js";
12
+ } from "./chunk-TB7E6UEO.js";
13
13
  import {
14
14
  getReadableCliDb
15
15
  } from "./chunk-62TBKWTV.js";
@@ -31,7 +31,7 @@ import {
31
31
  resolveFileWriteGateEnabled,
32
32
  resolveLocalUserId,
33
33
  validateInstaboxWorkspaceSelection
34
- } from "./chunk-JJU5FBYH.js";
34
+ } from "./chunk-J5Y3BXJP.js";
35
35
  import {
36
36
  clearCredentialAvailability,
37
37
  readEffectiveCredentialEntry,
@@ -72,14 +72,14 @@ import {
72
72
  } from "./chunk-BMQ2MJUK.js";
73
73
  import {
74
74
  resolveCliLocalRuntimeKeyCapability
75
- } from "./chunk-D4JCY67U.js";
75
+ } from "./chunk-37ZDGCX6.js";
76
76
  import {
77
77
  isTransientFetchError
78
78
  } from "./chunk-KFHREHUQ.js";
79
79
  import {
80
80
  parseUiCard,
81
81
  uiCardFallback
82
- } from "./chunk-7YW5OUQE.js";
82
+ } from "./chunk-XJECR5M3.js";
83
83
  import {
84
84
  isGatewayHttpStatus
85
85
  } from "./chunk-NF64D32W.js";
@@ -88,7 +88,7 @@ import {
88
88
  chooseMemoryOwners,
89
89
  loadMemoryCandidatesFromDb,
90
90
  resolveAgentMemoryPolicy
91
- } from "./chunk-YXTQJ2QR.js";
91
+ } from "./chunk-DK7QNJVM.js";
92
92
  import {
93
93
  getDefaultCliLocalRuntimeDb
94
94
  } from "./chunk-FDLDMJTM.js";
@@ -99,10 +99,10 @@ import {
99
99
  resolveAgentContextWindow,
100
100
  resolveOccupancy,
101
101
  resolveOccupancyWindow
102
- } from "./chunk-VXCDYN6M.js";
102
+ } from "./chunk-4GZ2LY5F.js";
103
103
  import {
104
104
  buildSkillDiscoveryContextLayer
105
- } from "./chunk-AU7AXHUL.js";
105
+ } from "./chunk-7KWPNGVJ.js";
106
106
  import {
107
107
  parseExternalSkillMarkdown,
108
108
  parseSkillDocProtocol
@@ -111,7 +111,7 @@ import {
111
111
  LOCAL_AGENT_CONFIG_MISSING_CODE,
112
112
  LOCAL_TURN_ABORTED_CODE,
113
113
  readActionGate
114
- } from "./chunk-IOQHM7ID.js";
114
+ } from "./chunk-4ALQFIFF.js";
115
115
  import {
116
116
  resolveAgentRuntimeConfigFromRecord
117
117
  } from "./chunk-CR5WXQX7.js";
@@ -159,7 +159,7 @@ import {
159
159
  buildMemoryUseGuidanceLayer,
160
160
  partitionScopedBlocks,
161
161
  renderTurnContextBlocksWithScope
162
- } from "./chunk-VEA7H5FG.js";
162
+ } from "./chunk-Q6RMLYSA.js";
163
163
  import {
164
164
  BUILTIN_NOLO_AGENT_KEY,
165
165
  BUILTIN_NOLO_AGENT_NAME,
@@ -11376,7 +11376,7 @@ function isBalanceExhaustedError(error) {
11376
11376
 
11377
11377
  // packages/cli/client/agentRun.ts
11378
11378
  async function loadRunLocalAgentTurn() {
11379
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-CBDP2OYK.js");
11379
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-3QBUFZEC.js");
11380
11380
  return runLocalAgentTurn;
11381
11381
  }
11382
11382
  var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
@@ -0,0 +1,385 @@
1
+ import {
2
+ MEMORY_USE_GUIDANCE,
3
+ wrapHistoricalSummaryWithReplayGuard
4
+ } from "./chunk-4VJAC32I.js";
5
+
6
+ // packages/agent-runtime/skillCatalog.ts
7
+ var SKILL_CATALOG_PRIORITY = Object.freeze([
8
+ "local-workspace",
9
+ "builtin",
10
+ "platform"
11
+ ]);
12
+ var DEFAULT_SKILL_CATALOG_BUDGET = Object.freeze({
13
+ maxEntries: 50,
14
+ descriptionBudget: 4e3,
15
+ minDescriptionLength: 80
16
+ });
17
+ var MAX_DESCRIPTION_BUDGET_PASSES = 200;
18
+ var normalizeKey = (name) => name.trim().toLowerCase();
19
+ var SKILL_TEXT_MAX_LENGTH = 200;
20
+ var sanitizeSkillText = (value) => (value ?? "").trim().replace(/^["']|["']$/g, "").replace(/[\n\r]+/g, " ").slice(0, SKILL_TEXT_MAX_LENGTH);
21
+ var hardenSkillText = (value) => (value ?? "").replace(/[\n\r]+/g, " ").slice(0, SKILL_TEXT_MAX_LENGTH);
22
+ var BLANK_NAME_LOOKUP_PREFIX = "\0blank-name:";
23
+ var sourceRank = (source) => {
24
+ const index = SKILL_CATALOG_PRIORITY.indexOf(source);
25
+ return index === -1 ? SKILL_CATALOG_PRIORITY.length : index;
26
+ };
27
+ function applySkillDescriptionBudget(entries, budget = DEFAULT_SKILL_CATALOG_BUDGET) {
28
+ if (entries.length === 0) return [...entries];
29
+ let current = [...entries];
30
+ for (let pass = 0; pass < MAX_DESCRIPTION_BUDGET_PASSES; pass += 1) {
31
+ const totalDescLen = current.reduce((sum, entry) => sum + entry.description.length, 0);
32
+ if (totalDescLen <= budget.descriptionBudget) break;
33
+ const scale = budget.descriptionBudget / totalDescLen;
34
+ let changed = false;
35
+ current = current.map((entry) => {
36
+ const targetLen = Math.max(
37
+ budget.minDescriptionLength,
38
+ Math.floor(entry.description.length * scale)
39
+ );
40
+ if (entry.description.length <= targetLen) return entry;
41
+ changed = true;
42
+ return { ...entry, description: entry.description.slice(0, targetLen).trimEnd() };
43
+ });
44
+ if (!changed) break;
45
+ }
46
+ return current;
47
+ }
48
+ function mergeSkillCatalog(inputs, budget = DEFAULT_SKILL_CATALOG_BUDGET) {
49
+ const candidates = inputs.map((input, index) => {
50
+ const key = normalizeKey(input.name);
51
+ const blank = key === "";
52
+ return {
53
+ input,
54
+ index,
55
+ rank: sourceRank(input.source),
56
+ blank,
57
+ key: blank ? `${BLANK_NAME_LOOKUP_PREFIX}${index}` : key
58
+ };
59
+ });
60
+ const blankNameEntries = candidates.filter((candidate) => candidate.blank);
61
+ if (blankNameEntries.length > 0) {
62
+ console.warn(
63
+ `[skillCatalog] ${blankNameEntries.length} \u4E2A\u6280\u80FD\u6761\u76EE\u7F3A\u5C11\u53EF\u7528 name\uFF0C\u5DF2\u4FDD\u7559\u4F46\u6807\u8BB0\u4E3A\u4E0D\u53EF\u7528\uFF1A${blankNameEntries.map((candidate) => candidate.input.id).join(", ")}`
64
+ );
65
+ }
66
+ const ordered = [...candidates].sort(
67
+ (a, b) => a.rank - b.rank || a.index - b.index
68
+ );
69
+ const winnerByKey = /* @__PURE__ */ new Map();
70
+ for (const candidate of ordered) {
71
+ if (!winnerByKey.has(candidate.key)) winnerByKey.set(candidate.key, candidate);
72
+ }
73
+ const conflictByKey = /* @__PURE__ */ new Map();
74
+ for (const candidate of ordered) {
75
+ const winner = winnerByKey.get(candidate.key);
76
+ if (!winner || winner === candidate) continue;
77
+ if (winner.input.source === candidate.input.source) continue;
78
+ let conflict = conflictByKey.get(candidate.key);
79
+ if (!conflict) {
80
+ conflict = {
81
+ key: candidate.key,
82
+ name: winner.input.name,
83
+ winner: { id: winner.input.id, source: winner.input.source },
84
+ shadowed: []
85
+ };
86
+ conflictByKey.set(candidate.key, conflict);
87
+ }
88
+ conflict.shadowed.push({ id: candidate.input.id, source: candidate.input.source });
89
+ }
90
+ const winners = ordered.filter((candidate) => {
91
+ const winner = winnerByKey.get(candidate.key);
92
+ if (!winner) return false;
93
+ return winner === candidate || winner.input.source === candidate.input.source;
94
+ });
95
+ const idOccurrences = /* @__PURE__ */ new Map();
96
+ const uniqueId = (baseId) => {
97
+ const seen = (idOccurrences.get(baseId) ?? 0) + 1;
98
+ idOccurrences.set(baseId, seen);
99
+ return seen === 1 ? baseId : `${baseId}#${seen}`;
100
+ };
101
+ const toEntry = (candidate) => {
102
+ const input = candidate.input;
103
+ const shadowedSources = (conflictByKey.get(candidate.key)?.shadowed ?? []).map((shadowed) => shadowed.source).filter((source, index, all) => all.indexOf(source) === index).sort((a, b) => sourceRank(a) - sourceRank(b));
104
+ const available = input.available !== false && !candidate.blank;
105
+ const unavailableReason = candidate.blank ? "empty-name" : hardenSkillText(input.unavailableReason).trim() || "unknown";
106
+ return {
107
+ id: uniqueId(input.id),
108
+ source: input.source,
109
+ // name 走完整清洗(MEDIUM-4):换行若能进契约,就能在提示里伪造一条
110
+ // 不存在的技能条目。name 是短标识符、已清洗路径下与既有输出逐字相同。
111
+ name: sanitizeSkillText(input.name),
112
+ // description 只做换行折叠 + 截断,不 trim 尾部——见 `hardenSkillText`
113
+ // 的说明(保真实工作区逐字一致,MEDIUM-2)。
114
+ description: hardenSkillText(input.description),
115
+ available,
116
+ ...available ? {} : { unavailableReason },
117
+ ...input.relativePath ? { relativePath: input.relativePath } : {},
118
+ ...input.contentRef ? { contentRef: input.contentRef } : {},
119
+ shadowedSources
120
+ };
121
+ };
122
+ const kept = winners.slice(0, Math.max(0, budget.maxEntries)).map(toEntry);
123
+ const droppedEntries = winners.slice(Math.max(0, budget.maxEntries)).map(toEntry);
124
+ return {
125
+ entries: applySkillDescriptionBudget(kept, budget),
126
+ conflicts: [...conflictByKey.values()],
127
+ droppedEntries,
128
+ budget
129
+ };
130
+ }
131
+ function mapDiscoveredSkillsToCatalogEntries(discovered) {
132
+ return discovered.map((skill) => ({
133
+ id: `local-workspace:${skill.name}`,
134
+ source: "local-workspace",
135
+ name: skill.name,
136
+ description: skill.description ?? "",
137
+ available: true,
138
+ ...skill.relativePath ? { relativePath: skill.relativePath } : {},
139
+ ...skill.relativePath ? { contentRef: skill.relativePath } : {}
140
+ }));
141
+ }
142
+ var warnSourceFailure = (id, error) => {
143
+ console.warn(
144
+ `[skillCatalog] source "${id}" failed to list skills: ${error instanceof Error ? error.message : String(error)}`
145
+ );
146
+ };
147
+ async function resolveSkillCatalog(sources, query = {}, budget = DEFAULT_SKILL_CATALOG_BUDGET) {
148
+ const lists = await Promise.all(
149
+ sources.map(async (source) => {
150
+ try {
151
+ return await source.list(query);
152
+ } catch (error) {
153
+ warnSourceFailure(source.id, error);
154
+ return [];
155
+ }
156
+ })
157
+ );
158
+ return mergeSkillCatalog(lists.flat(), budget);
159
+ }
160
+ function resolveSkillCatalogSync(sources, query = {}, budget = DEFAULT_SKILL_CATALOG_BUDGET, options = {}) {
161
+ const collected = [];
162
+ for (const source of sources) {
163
+ let listed;
164
+ try {
165
+ listed = source.list(query);
166
+ } catch (error) {
167
+ warnSourceFailure(source.id, error);
168
+ continue;
169
+ }
170
+ if (typeof listed?.then === "function") {
171
+ if (options.onAsyncSource !== "skip") {
172
+ throw new Error(
173
+ `[skillCatalog] source "${source.id}" is async; use resolveSkillCatalog() instead of the sync path`
174
+ );
175
+ }
176
+ void listed.then(
177
+ () => {
178
+ },
179
+ () => {
180
+ }
181
+ );
182
+ console.warn(
183
+ `[skillCatalog] source "${source.id}" is async and was skipped on the sync path; its skills are NOT in this turn's index (kept the ${collected.length} entries collected so far)`
184
+ );
185
+ continue;
186
+ }
187
+ collected.push(...listed);
188
+ }
189
+ return mergeSkillCatalog(collected, budget);
190
+ }
191
+
192
+ // packages/agent-runtime/turnContext.ts
193
+ var DEFAULT_RECENT_CONTENT_LIMIT = 10;
194
+ var asTrimmed = (value) => typeof value === "string" ? value.trim() : "";
195
+ var asFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
196
+ var spaceRecordKey = (spaceId) => spaceId.startsWith("space-") ? spaceId : `space-${spaceId}`;
197
+ var makeLayer = (id, content, cacheScope = "turn") => ({ id, owner: "runtime", cacheScope, content });
198
+ var renderSpaceStructure = (spaceRecord, recentLimit) => {
199
+ const categories = spaceRecord.categories ?? {};
200
+ const validCategories = Object.entries(categories).filter((entry) => entry[1] !== null).sort(
201
+ (a, b) => asFiniteNumber(a[1].order) - asFiniteNumber(b[1].order)
202
+ );
203
+ const categoryNameById = /* @__PURE__ */ new Map();
204
+ let struct = "Directory Structure (Categories):\n";
205
+ if (validCategories.length === 0) struct += "(No categories defined)\n";
206
+ validCategories.forEach(([id, category]) => {
207
+ const name = asTrimmed(category.name) || id;
208
+ categoryNameById.set(id, name);
209
+ struct += `- ${name} (ID: ${id})
210
+ `;
211
+ });
212
+ const contents = spaceRecord.contents ?? {};
213
+ const recentContents = recentLimit > 0 ? Object.values(contents).filter((content) => content !== null).sort(
214
+ (a, b) => asFiniteNumber(b.updatedAt) - asFiniteNumber(a.updatedAt)
215
+ ).slice(0, recentLimit) : [];
216
+ if (recentContents.length > 0) {
217
+ struct += `
218
+ Recent Contents (Top ${recentLimit}):
219
+ `;
220
+ recentContents.forEach((content) => {
221
+ const categoryId = asTrimmed(content.categoryId);
222
+ const categoryName = categoryId ? categoryNameById.get(categoryId) || "Unknown" : "Uncategorized";
223
+ struct += `- [${asTrimmed(content.type) || "content"}] ${asTrimmed(content.title)} (Category: ${categoryName}, dbKey: ${asTrimmed(content.contentKey)})
224
+ `;
225
+ });
226
+ }
227
+ return struct;
228
+ };
229
+ var buildSpaceContextLayer = async (args) => {
230
+ const spaceId = asTrimmed(args.spaceId);
231
+ if (!spaceId) return null;
232
+ const recentLimit = args.recentContentLimit ?? DEFAULT_RECENT_CONTENT_LIMIT;
233
+ let spaceRecord = null;
234
+ let readError = null;
235
+ try {
236
+ spaceRecord = await args.source.readRecord(spaceRecordKey(spaceId));
237
+ } catch (error) {
238
+ readError = error instanceof Error ? error.message : String(error);
239
+ }
240
+ if (!spaceRecord) {
241
+ return makeLayer(
242
+ "space-context",
243
+ [
244
+ "--- \u5F53\u524D\u7A7A\u95F4\uFF08Space\uFF09---",
245
+ `\u672C\u5BF9\u8BDD\u8BB0\u5F55\u58F0\u660E\u5C5E\u4E8E Space ${spaceId}\uFF0C\u4F46\u5F53\u524D\u65E0\u6CD5\u8BFB\u53D6\u8BE5 Space \u7684\u6570\u636E${readError ? `\uFF08${readError}\uFF09` : "\uFF08\u8BB0\u5F55\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8FBE\uFF09"}\u3002`,
246
+ "\u5982\u88AB\u95EE\u53CA\uFF0C\u8BF7\u5982\u5B9E\u8BF4\u660E\u300C\u5BF9\u8BDD\u5C5E\u4E8E\u8BE5 Space \u4F46\u6682\u65F6\u8BFB\u4E0D\u5230\u7A7A\u95F4\u8BE6\u60C5\u300D\uFF0C\u4E0D\u8981\u58F0\u79F0\u5BF9\u8BDD\u4E0D\u5C5E\u4E8E\u4EFB\u4F55\u7A7A\u95F4\u3002"
247
+ ].join("\n")
248
+ );
249
+ }
250
+ const name = asTrimmed(spaceRecord.name);
251
+ const description = asTrimmed(spaceRecord.description);
252
+ const structure = renderSpaceStructure(spaceRecord, recentLimit);
253
+ return makeLayer(
254
+ "space-context",
255
+ [
256
+ "--- \u5F53\u524D\u7A7A\u95F4\uFF08Space\uFF09---",
257
+ "\u672C\u5BF9\u8BDD\u5C5E\u4E8E\u4EE5\u4E0B Space\uFF1A",
258
+ `Space Title: ${name || spaceId}`,
259
+ `Space ID: ${spaceId}`,
260
+ `Description: ${description || "N/A"}`,
261
+ "",
262
+ structure.trimEnd()
263
+ ].join("\n")
264
+ );
265
+ };
266
+ var buildSkillDiscoveryCatalogLayer = (catalog) => {
267
+ if (catalog.entries.length === 0) return null;
268
+ const sources = catalog.entries.map((entry) => entry.source).filter((source, index, all) => all.indexOf(source) === index);
269
+ const multiSource = sources.length > 1;
270
+ const lines = [
271
+ "--- \u53EF\u7528\u6280\u80FD\uFF08Skills\uFF09---",
272
+ multiSource ? `\u5171\u53D1\u73B0 ${catalog.entries.length} \u4E2A\u6280\u80FD\uFF08\u6765\u6E90\uFF1A${sources.join(", ")}\uFF09\uFF0C\u6A21\u578B\u53EF\u6309\u9700\u7528 loadSkill \u6309\u540D\u52A0\u8F7D\u6216 readFile \u76F4\u63A5\u8BFB\u53D6\uFF08\u8DEF\u5F84\u89C4\u5219 .agents/skills/<name>/SKILL.md\uFF09\uFF1A` : `\u5DE5\u4F5C\u533A\u4E2D\u53D1\u73B0\u4E86 ${catalog.entries.length} \u4E2A\u6280\u80FD\uFF08SKILL.md\uFF09\uFF0C\u6A21\u578B\u53EF\u6309\u9700\u7528 loadSkill \u6309\u540D\u52A0\u8F7D\u6216 readFile \u76F4\u63A5\u8BFB\u53D6\uFF08\u8DEF\u5F84\u89C4\u5219 .agents/skills/<name>/SKILL.md\uFF09\uFF1A`,
273
+ ...catalog.entries.map((entry) => {
274
+ const marks = [
275
+ multiSource ? ` [${entry.source}]` : "",
276
+ entry.available ? "" : ` [\u4E0D\u53EF\u7528\uFF1A${entry.unavailableReason ?? "unknown"}]`
277
+ ].join("");
278
+ return `- ${entry.name}${marks}: ${entry.description}`;
279
+ })
280
+ ];
281
+ if (catalog.droppedEntries.length > 0) {
282
+ const names = catalog.droppedEntries.map((entry) => entry.name || entry.id).join(", ");
283
+ lines.push(
284
+ `\u53E6\u6709 ${catalog.droppedEntries.length} \u4E2A\u6280\u80FD\u8D85\u51FA\u76EE\u5F55\u4E0A\u9650\uFF08${catalog.budget.maxEntries} \u9879\uFF09\u672A\u5217\u51FA\uFF1A${names}`
285
+ );
286
+ }
287
+ if (catalog.conflicts.length > 0) {
288
+ lines.push("\u540C\u540D\u6280\u80FD\u53EA\u5217\u51FA\u751F\u6548\u7684\u4E00\u4EFD\uFF08\u6309\u6765\u6E90\u4F18\u5148\u7EA7\uFF0C\u524D\u8005\u751F\u6548\uFF09\uFF1A");
289
+ for (const conflict of catalog.conflicts) {
290
+ const shadowedSources = conflict.shadowed.map((entry) => entry.source).filter((source, index, all) => all.indexOf(source) === index);
291
+ lines.push(
292
+ `- ${conflict.name}: \u751F\u6548 ${conflict.winner.source}\uFF0C\u8986\u76D6 ${shadowedSources.join(" / ")}`
293
+ );
294
+ }
295
+ }
296
+ return makeLayer("skill-discovery", lines.join("\n"), "session");
297
+ };
298
+ var buildAgentsMdLayer = (content, fileName = "AGENTS.md") => {
299
+ const trimmed = content.trim();
300
+ if (!trimmed) return null;
301
+ return makeLayer(
302
+ "agents-md",
303
+ `--- \u9879\u76EE\u6307\u4EE4\uFF08${fileName}\uFF09---
304
+ ${trimmed}`,
305
+ "session"
306
+ );
307
+ };
308
+ var buildLinkedSpacesSection = async (args) => {
309
+ const ids = (args.linkedSpaceIds ?? []).filter(
310
+ (id) => typeof id === "string" && id.trim() !== ""
311
+ );
312
+ if (ids.length === 0) return null;
313
+ const lines = [];
314
+ for (const rawId of ids) {
315
+ const spaceId = asTrimmed(rawId);
316
+ let spaceData = null;
317
+ try {
318
+ spaceData = await args.source.readRecord(spaceRecordKey(spaceId));
319
+ } catch {
320
+ spaceData = null;
321
+ }
322
+ if (spaceData) {
323
+ const name = asTrimmed(spaceData.name) || spaceId;
324
+ const desc = asTrimmed(spaceData.description);
325
+ lines.push(`- ${name} (ID: ${spaceId})${desc ? `: ${desc}` : ""}`);
326
+ } else {
327
+ lines.push(`- [\u65E0\u6CD5\u8BBF\u95EE] ${spaceId}`);
328
+ }
329
+ }
330
+ if (lines.length === 0) return null;
331
+ return [
332
+ "--- \u5173\u8054\u7A7A\u95F4 (Linked Spaces) ---",
333
+ "\u4EE5\u4E0B\u662F Agent \u53EF\u8BBF\u95EE\u7684\u5176\u4ED6\u5DE5\u4F5C\u7A7A\u95F4\uFF08\u7C97\u7565\u4E0A\u4E0B\u6587\uFF09\uFF1A",
334
+ lines.join("\n"),
335
+ "",
336
+ "\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"
337
+ ].join("\n");
338
+ };
339
+ var renderTurnContextBlocksWithScope = (layers) => layers.filter((layer) => Boolean(layer?.content?.trim())).map((layer) => ({
340
+ content: layer.content.trim(),
341
+ cacheScope: layer.cacheScope
342
+ }));
343
+ var partitionScopedBlocks = (blocks) => [
344
+ ...blocks.filter((block) => block.cacheScope === "session"),
345
+ ...blocks.filter((block) => block.cacheScope === "turn")
346
+ ];
347
+ var buildDialogSummaryLayer = (args) => {
348
+ const historical = wrapHistoricalSummaryWithReplayGuard(
349
+ asTrimmed(args.summary)
350
+ );
351
+ if (!historical) return null;
352
+ return makeLayer("dialog-summary", `--- \u5386\u53F2\u5BF9\u8BDD\u6458\u8981 ---
353
+ ${historical}`);
354
+ };
355
+ var buildMemoryOverlayLayer = (args) => {
356
+ const promptBlock = asTrimmed(args.promptBlock);
357
+ if (!promptBlock) return null;
358
+ return makeLayer("memory-overlay", promptBlock, "session");
359
+ };
360
+ var buildMemoryUseGuidanceLayer = (args) => {
361
+ const promptBlock = asTrimmed(args.promptBlock);
362
+ if (!promptBlock) return null;
363
+ return makeLayer(
364
+ "memory-use-guidance",
365
+ MEMORY_USE_GUIDANCE,
366
+ "session"
367
+ );
368
+ };
369
+
370
+ export {
371
+ DEFAULT_SKILL_CATALOG_BUDGET,
372
+ applySkillDescriptionBudget,
373
+ mapDiscoveredSkillsToCatalogEntries,
374
+ resolveSkillCatalog,
375
+ resolveSkillCatalogSync,
376
+ buildSpaceContextLayer,
377
+ buildSkillDiscoveryCatalogLayer,
378
+ buildAgentsMdLayer,
379
+ buildLinkedSpacesSection,
380
+ renderTurnContextBlocksWithScope,
381
+ partitionScopedBlocks,
382
+ buildDialogSummaryLayer,
383
+ buildMemoryOverlayLayer,
384
+ buildMemoryUseGuidanceLayer
385
+ };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-JJU5FBYH.js";
4
+ } from "./chunk-J5Y3BXJP.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-7YW5OUQE.js";
7
+ } from "./chunk-XJECR5M3.js";
8
8
  import {
9
9
  runLocalAgentTurn
10
- } from "./chunk-IOQHM7ID.js";
10
+ } from "./chunk-4ALQFIFF.js";
11
11
  import {
12
12
  applyToolSurfaceConstraints
13
13
  } from "./chunk-FKOCI2WR.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  toolRegistry
3
- } from "./chunk-D4JCY67U.js";
3
+ } from "./chunk-37ZDGCX6.js";
4
4
  import {
5
5
  runtime_default
6
- } from "./chunk-VXCDYN6M.js";
6
+ } from "./chunk-4GZ2LY5F.js";
7
7
  import {
8
8
  canonicalizeToolNames
9
9
  } from "./chunk-AKE53VMW.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-NBTY7YJF.js";
6
6
  import {
7
7
  resolveCliLocalRuntimeKeyCapability
8
- } from "./chunk-D4JCY67U.js";
8
+ } from "./chunk-37ZDGCX6.js";
9
9
  import {
10
10
  HIGH_RISK_MUTATION_TOOL_NAMES
11
11
  } from "./chunk-FKOCI2WR.js";
@@ -347,7 +347,7 @@ var slice = createSliceWithThunks({
347
347
  const overrides = {};
348
348
  if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
349
349
  if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
350
- const { _executeModel } = await import("./_executeModel-5SGPPCT6.js");
350
+ const { _executeModel } = await import("./_executeModel-35LFG5KF.js");
351
351
  return _executeModel(
352
352
  {
353
353
  isStreaming: args.isStreaming ?? false,
@@ -368,7 +368,7 @@ var slice = createSliceWithThunks({
368
368
  * - 循环直到无工具调用或触发其他运行时停止条件
369
369
  */
370
370
  runAgent: create.asyncThunk(async (args, thunkApi) => {
371
- const { runAgentClientLoop } = await import("./runAgentClientLoop-JRW5EA5U.js");
371
+ const { runAgentClientLoop } = await import("./runAgentClientLoop-BU6GOWQI.js");
372
372
  const { content: loopContent, toolCallCount } = await runAgentClientLoop(
373
373
  {
374
374
  agentKey: args.agentKey,
@@ -384,7 +384,7 @@ var slice = createSliceWithThunks({
384
384
  * 聊天轮次流式 Agent 调用
385
385
  */
386
386
  streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
387
- const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-CBGAGRQL.js");
387
+ const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-MHRXV7XZ.js");
388
388
  return streamAgentChatTurnHandler(args, thunkApi);
389
389
  }),
390
390
  /**
@@ -8,7 +8,7 @@ import {
8
8
  } from "./chunk-VYNMQ6HW.js";
9
9
  import {
10
10
  fetchAndCacheTableRows
11
- } from "./chunk-HRLKX6YP.js";
11
+ } from "./chunk-PEOLOK72.js";
12
12
  import {
13
13
  require_react
14
14
  } from "./chunk-YDH3FDFQ.js";
@@ -521,7 +521,7 @@ var executeToolRun = createAsyncThunk(
521
521
  if (!executionInput) {
522
522
  throw new Error(`ToolRun ${id} has no input to execute with.`);
523
523
  }
524
- const { findToolExecutor } = await import("./tools-RVVZ2Y6V.js");
524
+ const { findToolExecutor } = await import("./tools-YA5NIWI7.js");
525
525
  const { executor } = findToolExecutor(run.toolName);
526
526
  toolRunStarted({
527
527
  id: run.id,
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-HS7MLR74.js";
4
4
  import {
5
5
  performServerProxyFetchWithRetry
6
- } from "./chunk-MIPGIRJJ.js";
6
+ } from "./chunk-6HFMPUSN.js";
7
7
  import {
8
8
  fetchServerSyncedCredential
9
- } from "./chunk-DBEIHUCJ.js";
9
+ } from "./chunk-VMMS7L64.js";
10
10
  import {
11
11
  buildSkillGuidancePromptBlock
12
12
  } from "./chunk-ZZE2IJ5U.js";
@@ -7,7 +7,7 @@ import {
7
7
  mergeReferences,
8
8
  resolveReferenceAssets,
9
9
  resolveToolsFromKeys
10
- } from "./chunk-MIPGIRJJ.js";
10
+ } from "./chunk-6HFMPUSN.js";
11
11
  import {
12
12
  UI_CARD_ENVELOPE_MAX_BYTES,
13
13
  getAllToolRuns,
@@ -20,7 +20,7 @@ import {
20
20
  selectSpaceContextLevel,
21
21
  selectUserTonePreset,
22
22
  uiCardFallback
23
- } from "./chunk-7YW5OUQE.js";
23
+ } from "./chunk-XJECR5M3.js";
24
24
  import {
25
25
  resolveToolBaseUrl
26
26
  } from "./chunk-MYOH447Z.js";
@@ -32,10 +32,10 @@ import {
32
32
  } from "./chunk-TDNAAXUQ.js";
33
33
  import {
34
34
  getDocState
35
- } from "./chunk-BJPALUYR.js";
35
+ } from "./chunk-ECAGROXS.js";
36
36
  import {
37
37
  getTableState
38
- } from "./chunk-HRLKX6YP.js";
38
+ } from "./chunk-PEOLOK72.js";
39
39
  import {
40
40
  getCurrentSpaceIdRaw,
41
41
  getViewMode
@@ -44,7 +44,7 @@ import {
44
44
  PERSONALIZATION_DIALOG_CATEGORY,
45
45
  buildPersonalizationDialogPolicyContext,
46
46
  selectAllMsgs
47
- } from "./chunk-VXCDYN6M.js";
47
+ } from "./chunk-4GZ2LY5F.js";
48
48
  import {
49
49
  selectPendingFiles
50
50
  } from "./chunk-OWYYDMGJ.js";
@@ -90,7 +90,7 @@ import {
90
90
  import {
91
91
  buildLinkedSpacesSection,
92
92
  buildSpaceContextLayer
93
- } from "./chunk-VEA7H5FG.js";
93
+ } from "./chunk-Q6RMLYSA.js";
94
94
  import {
95
95
  canonicalizeToolNames,
96
96
  prioritizeToolNames