nolo-cli 0.61.0-alpha.2 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/{_executeModel-CKT6RGTL.js → _executeModel-R26QYY66.js} +13 -12
  2. package/{agentDeleteCommand-VN7NPXQ4.js → agentDeleteCommand-6GNQA4J4.js} +1 -1
  3. package/{agentEmailCommands-F2TNAV4A.js → agentEmailCommands-HH67CYKD.js} +13 -12
  4. package/{agentListCommands-OSM2ANI3.js → agentListCommands-23XW3OPZ.js} +1 -1
  5. package/{agentMachineCommands-MTPWYVRV.js → agentMachineCommands-HXHASEWO.js} +2 -2
  6. package/{agentRecordCommands-VWAWTVVC.js → agentRecordCommands-UHTQJVGC.js} +13 -12
  7. package/{agentRunCommand-PLZOBNVK.js → agentRunCommand-OAMT77EX.js} +14 -13
  8. package/{agentRuntimeLocal-XCJLRWQE.js → agentRuntimeLocal-QBK4H3T2.js} +1 -1
  9. package/{agentSlice-F6DOP4IW.js → agentSlice-7XJH5WQF.js} +1 -1
  10. package/{appDeleteCommands-3BCFTRFJ.js → appDeleteCommands-AX2O6VDV.js} +1 -1
  11. package/{appDeployCommands-B4GMHCYA.js → appDeployCommands-L5ZR26CB.js} +1 -1
  12. package/{appDeployStatusCommands-4MN36WIG.js → appDeployStatusCommands-5HQHELRA.js} +1 -1
  13. package/{appGetCommands-4GJIEUAX.js → appGetCommands-HVSYOS57.js} +1 -1
  14. package/{appListCommands-CHU53GSX.js → appListCommands-XV2FPTWX.js} +1 -1
  15. package/{chatQueueReduxAdapter-HNSQXNIR.js → chatQueueReduxAdapter-F3R253JE.js} +2 -2
  16. package/{chunk-6HIGYUBQ.js → chunk-6XIE5ZGI.js} +1 -1
  17. package/{chunk-B7DXRX7F.js → chunk-7KELZLC2.js} +4 -4
  18. package/chunk-AETZ7AD6.js +274 -0
  19. package/{chunk-2HPRMEEZ.js → chunk-CQ2OZMLQ.js} +10 -10
  20. package/{chunk-ES6CVKVD.js → chunk-DWYSDNOH.js} +3 -3
  21. package/{chunk-DZZL7UBV.js → chunk-E3YVTQWT.js} +1 -1
  22. package/chunk-E4MARS3Q.js +114 -0
  23. package/{chunk-HQP7HJDL.js → chunk-F44FAXP2.js} +3 -3
  24. package/{chunk-7UF7CQ6B.js → chunk-GSXDRMDO.js} +2 -2
  25. package/{chunk-EY7V7REW.js → chunk-KHCLMKZZ.js} +6 -280
  26. package/{chunk-4C4ST2YE.js → chunk-KSCXMC6U.js} +3 -3
  27. package/{chunk-AVE2YR4F.js → chunk-N6HLMLKE.js} +1 -1
  28. package/{chunk-GAL47RNP.js → chunk-NO42UD73.js} +1 -1
  29. package/{chunk-HLU5Q2GV.js → chunk-NRRPKMM7.js} +1 -1
  30. package/{chunk-37QVS7BU.js → chunk-SKIRVYEI.js} +3 -3
  31. package/{chunk-3JWKQDA4.js → chunk-SYNKICCB.js} +1 -1
  32. package/{chunk-D5XKNNUV.js → chunk-TBHAHL33.js} +8 -8
  33. package/{chunk-IYCUMIYS.js → chunk-VAKVNHK5.js} +5 -5
  34. package/{chunk-HBPV76EK.js → chunk-VHO3TMQZ.js} +8 -8
  35. package/{chunk-7O7KH4X5.js → chunk-Z5MHFBJZ.js} +5 -5
  36. package/{codingSkills-VDXQYWX4.js → codingSkills-TKROLCBA.js} +3 -2
  37. package/{contentThunks-7YG2ZYQC.js → contentThunks-OZPK5B4Z.js} +3 -3
  38. package/{createAgentAutomationAction-PJQSCAIO.js → createAgentAutomationAction-LCIBGE5T.js} +3 -3
  39. package/{createDialogAction-SFEJX6SP.js → createDialogAction-JPJZMHJE.js} +6 -5
  40. package/{createPageAction-B7WRHOQO.js → createPageAction-6P2WLNHO.js} +5 -4
  41. package/{dialogCommands-VL2X22QC.js → dialogCommands-WAFKC3KK.js} +1 -1
  42. package/{dialogSlice-ANMACABO.js → dialogSlice-R5RZHFTU.js} +2 -2
  43. package/{docCreateCommands-ITLGZ5YI.js → docCreateCommands-GHGB42S7.js} +4 -3
  44. package/{docDeleteCommands-LH3YNL4C.js → docDeleteCommands-Y5I7ZEX4.js} +4 -3
  45. package/{docReadCommands-YAJ77F36.js → docReadCommands-BMXM6J7T.js} +4 -3
  46. package/{docStore-D4HGHPWI.js → docStore-DKWZ6XJ5.js} +1 -1
  47. package/{docUpdateCommands-DQBOMH2G.js → docUpdateCommands-QNABH3M2.js} +4 -3
  48. package/{handleSendMessageAction-DF2OABGW.js → handleSendMessageAction-UQGKM4UX.js} +2 -2
  49. package/index.js +40 -40
  50. package/{machineCommands-JXDYQ5LB.js → machineCommands-YDAIPYU5.js} +13 -12
  51. package/{machineWsRunDispatch-3QHI7JX5.js → machineWsRunDispatch-O6RM2ECT.js} +13 -12
  52. package/package.json +1 -1
  53. package/{readlineWorkspace-KVZTEAHB.js → readlineWorkspace-5DP3AJWN.js} +14 -13
  54. package/{runAgentClientLoop-KGTEL7ZP.js → runAgentClientLoop-Y6HWP2PT.js} +11 -10
  55. package/{skillDiscovery-NTRLM6KP.js → skillDiscovery-CYUCJMAG.js} +2 -1
  56. package/{spaceCommands-KNAYWMCZ.js → spaceCommands-CLN45IE3.js} +1 -1
  57. package/{streamAgentChatTurn-FLYPTXKZ.js → streamAgentChatTurn-6WFQJ4DY.js} +12 -11
  58. package/{tools-CVLUXK6P.js → tools-RR53D65Q.js} +9 -8
  59. package/{updateDialogTitleAction-HWJIZEIV.js → updateDialogTitleAction-WXS3AKOL.js} +3 -3
  60. package/chunk-AQMVUA7N.js +0 -2575
@@ -0,0 +1,274 @@
1
+ import {
2
+ dump,
3
+ load
4
+ } from "./chunk-KHCLMKZZ.js";
5
+ import {
6
+ asTrimmedNonEmptyStringArray
7
+ } from "./chunk-I42VC5KR.js";
8
+ import {
9
+ asOptionalTrimmedString
10
+ } from "./chunk-G3SUCT4W.js";
11
+
12
+ // packages/ai/skills/skillDocProtocol.ts
13
+ var SKILL_DOC_ENUMS = {
14
+ triggerMode: ["explicit", "required", "recommended"],
15
+ // budgetTier 只服务 WorkflowReferenceConfig;skill 侧已移除(零读点)。
16
+ budgetTier: ["low", "medium", "high"],
17
+ modality: ["text", "image", "video", "audio", "3d"],
18
+ docKind: ["knowledge", "instruction", "skill"]
19
+ };
20
+ var SKILL_CONFIG_BLOCK = "skill-config";
21
+ var EVAL_CONFIG_BLOCK = "eval-config";
22
+ var WORKFLOW_CONFIG_BLOCK = "workflow-config";
23
+ var normalizeStringArray = (value) => {
24
+ if (!Array.isArray(value)) return void 0;
25
+ const items = [...new Set(asTrimmedNonEmptyStringArray(value))];
26
+ return items.length > 0 ? items : void 0;
27
+ };
28
+ var normalizeSkillEnumValue = (key, value) => typeof value === "string" && SKILL_DOC_ENUMS[key].includes(value) ? value : void 0;
29
+ var normalizeSkillModalities = (value) => {
30
+ const raw = normalizeStringArray(value);
31
+ if (!raw) return void 0;
32
+ const filtered = raw.flatMap((item) => {
33
+ const modality = normalizeSkillEnumValue("modality", item);
34
+ return modality ? [modality] : [];
35
+ });
36
+ return filtered.length > 0 ? Array.from(new Set(filtered)) : void 0;
37
+ };
38
+ var normalizeSkillConfig = (value, fallbackTools) => {
39
+ if (!value || typeof value !== "object") return void 0;
40
+ const record = value;
41
+ const name = asOptionalTrimmedString(record.name) ?? "";
42
+ const description = asOptionalTrimmedString(record.description) ?? "";
43
+ if (!name || !description) return void 0;
44
+ const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
45
+ const modalities = normalizeSkillModalities(record.modalities);
46
+ const toolNames = normalizeStringArray(record.toolNames) ?? normalizeStringArray(fallbackTools) ?? void 0;
47
+ return {
48
+ version: "0.1",
49
+ kind: "skill",
50
+ id: asOptionalTrimmedString(record.id),
51
+ name,
52
+ description,
53
+ triggerMode,
54
+ toolNames,
55
+ modalities,
56
+ requiredSkills: normalizeStringArray(record.requiredSkills),
57
+ recommendedSkills: normalizeStringArray(record.recommendedSkills),
58
+ promptPatch: asOptionalTrimmedString(record.promptPatch)
59
+ };
60
+ };
61
+ var normalizeEvalConfig = (value) => {
62
+ if (!value || typeof value !== "object") return void 0;
63
+ const record = value;
64
+ if (!Array.isArray(record.cases)) return void 0;
65
+ const cases = [];
66
+ for (const item of record.cases) {
67
+ if (!item || typeof item !== "object") continue;
68
+ const testCase = item;
69
+ const input = asOptionalTrimmedString(testCase.input) ?? "";
70
+ if (!input) continue;
71
+ cases.push({
72
+ input,
73
+ expectedTools: normalizeStringArray(testCase.expectedTools),
74
+ expectedSignals: normalizeStringArray(testCase.expectedSignals),
75
+ forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals)
76
+ });
77
+ }
78
+ return cases.length > 0 ? {
79
+ version: "0.1",
80
+ cases
81
+ } : void 0;
82
+ };
83
+ var normalizeWorkflowConfig = (value) => {
84
+ if (!value || typeof value !== "object") return void 0;
85
+ const record = value;
86
+ const name = asOptionalTrimmedString(record.name) ?? "";
87
+ const description = asOptionalTrimmedString(record.description) ?? "";
88
+ if (!name || !description) return void 0;
89
+ const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
90
+ return {
91
+ version: "0.1",
92
+ kind: "workflow",
93
+ id: asOptionalTrimmedString(record.id),
94
+ name,
95
+ description,
96
+ defaultAgent: asOptionalTrimmedString(record.defaultAgent),
97
+ inputs: normalizeStringArray(record.inputs),
98
+ recommendedTools: normalizeStringArray(record.recommendedTools),
99
+ requiredTools: normalizeStringArray(record.requiredTools),
100
+ requiredOutputs: normalizeStringArray(record.requiredOutputs),
101
+ gates: normalizeStringArray(record.gates),
102
+ budgetTier,
103
+ contextStrategy: asOptionalTrimmedString(record.contextStrategy),
104
+ failureProtocol: asOptionalTrimmedString(record.failureProtocol)
105
+ };
106
+ };
107
+ var normalizePageSkillMetadata = (value, fallbackTools) => {
108
+ if (!value || typeof value !== "object") return void 0;
109
+ const record = value;
110
+ const kind = normalizeSkillEnumValue("docKind", record.kind);
111
+ const meta = {
112
+ kind,
113
+ requiredSkills: normalizeStringArray(record.requiredSkills),
114
+ recommendedSkills: normalizeStringArray(record.recommendedSkills),
115
+ skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
116
+ evalConfig: normalizeEvalConfig(record.evalConfig),
117
+ workflowConfig: normalizeWorkflowConfig(record.workflowConfig)
118
+ };
119
+ if (meta.skillConfig && !meta.kind) {
120
+ meta.kind = "skill";
121
+ }
122
+ if (meta.workflowConfig && !meta.kind) {
123
+ meta.kind = "instruction";
124
+ }
125
+ return meta.kind || meta.requiredSkills || meta.recommendedSkills || meta.skillConfig || meta.evalConfig || meta.workflowConfig ? meta : void 0;
126
+ };
127
+ var extractCommentBlock = (markdown, blockName) => {
128
+ if (!markdown) return void 0;
129
+ const matcher = new RegExp(
130
+ `<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
131
+ "i"
132
+ );
133
+ const match = markdown.match(matcher);
134
+ return asOptionalTrimmedString(match?.[1]);
135
+ };
136
+ var removeCommentBlock = (markdown, blockName) => markdown.replace(
137
+ new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
138
+ "\n\n"
139
+ );
140
+ var parseYamlObject = (raw) => {
141
+ if (!raw) return void 0;
142
+ try {
143
+ const parsed = load(raw);
144
+ return parsed && typeof parsed === "object" ? parsed : void 0;
145
+ } catch {
146
+ return void 0;
147
+ }
148
+ };
149
+ var parseSkillDocProtocol = (markdown, existingMeta, fallbackTools) => {
150
+ const source = typeof markdown === "string" ? markdown : "";
151
+ const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
152
+ const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
153
+ const workflowBlock = parseYamlObject(extractCommentBlock(source, WORKFLOW_CONFIG_BLOCK));
154
+ const cleanedContent = removeCommentBlock(
155
+ removeCommentBlock(
156
+ removeCommentBlock(source, SKILL_CONFIG_BLOCK),
157
+ EVAL_CONFIG_BLOCK
158
+ ),
159
+ WORKFLOW_CONFIG_BLOCK
160
+ ).replace(/\n{3,}/g, "\n\n").trim();
161
+ const parsedMeta = normalizePageSkillMetadata(
162
+ {
163
+ ...existingMeta ?? {},
164
+ ...skillBlock ? {
165
+ kind: existingMeta?.kind === "skill" || skillBlock.kind === "skill" ? "skill" : existingMeta?.kind,
166
+ requiredSkills: skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
167
+ recommendedSkills: skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
168
+ skillConfig: skillBlock
169
+ } : {},
170
+ ...evalBlock ? { evalConfig: evalBlock } : {},
171
+ ...workflowBlock ? { workflowConfig: workflowBlock } : {}
172
+ },
173
+ fallbackTools
174
+ );
175
+ return {
176
+ content: cleanedContent,
177
+ meta: parsedMeta
178
+ };
179
+ };
180
+ var resolvePageSkillMetadata = (page) => {
181
+ if (!page) return void 0;
182
+ const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
183
+ return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
184
+ };
185
+ var yamlBlock = (value) => dump(value, { lineWidth: 120, noRefs: true }).trim();
186
+ var buildSkillConfigComment = (config) => {
187
+ const payload = {
188
+ version: config.version,
189
+ kind: config.kind,
190
+ ...config.id ? { id: config.id } : {},
191
+ name: config.name,
192
+ description: config.description,
193
+ ...config.triggerMode ? { triggerMode: config.triggerMode } : {},
194
+ ...config.requiredSkills?.length ? { requiredSkills: config.requiredSkills } : {},
195
+ ...config.recommendedSkills?.length ? { recommendedSkills: config.recommendedSkills } : {},
196
+ ...config.toolNames?.length ? { toolNames: config.toolNames } : {},
197
+ ...config.modalities?.length ? { modalities: config.modalities } : {},
198
+ ...config.promptPatch ? { promptPatch: config.promptPatch } : {}
199
+ };
200
+ return `<!-- ${SKILL_CONFIG_BLOCK}
201
+ ${yamlBlock(payload)}
202
+ -->`;
203
+ };
204
+ var buildEvalConfigComment = (config) => `<!-- ${EVAL_CONFIG_BLOCK}
205
+ ${yamlBlock({
206
+ version: config.version,
207
+ cases: config.cases
208
+ })}
209
+ -->`;
210
+ var buildWorkflowConfigComment = (config) => `<!-- ${WORKFLOW_CONFIG_BLOCK}
211
+ ${yamlBlock({
212
+ version: config.version,
213
+ kind: config.kind,
214
+ ...config.id ? { id: config.id } : {},
215
+ name: config.name,
216
+ description: config.description,
217
+ ...config.defaultAgent ? { defaultAgent: config.defaultAgent } : {},
218
+ ...config.inputs?.length ? { inputs: config.inputs } : {},
219
+ ...config.recommendedTools?.length ? { recommendedTools: config.recommendedTools } : {},
220
+ ...config.requiredTools?.length ? { requiredTools: config.requiredTools } : {},
221
+ ...config.requiredOutputs?.length ? { requiredOutputs: config.requiredOutputs } : {},
222
+ ...config.gates?.length ? { gates: config.gates } : {},
223
+ ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
224
+ ...config.contextStrategy ? { contextStrategy: config.contextStrategy } : {},
225
+ ...config.failureProtocol ? { failureProtocol: config.failureProtocol } : {}
226
+ })}
227
+ -->`;
228
+ var buildSkillDocMarkdown = (options) => {
229
+ const sections = [
230
+ asOptionalTrimmedString(options.body) ?? "",
231
+ buildSkillConfigComment(options.skillConfig),
232
+ options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
233
+ options.workflowConfig ? buildWorkflowConfigComment(options.workflowConfig) : ""
234
+ ].filter(Boolean);
235
+ return sections.join("\n\n").trim();
236
+ };
237
+ var extractFrontmatter = (markdown) => {
238
+ const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
239
+ if (!match) return { body: markdown.trim() };
240
+ const frontmatter = parseYamlObject(match[1]);
241
+ const body = markdown.slice(match[0].length).trim();
242
+ return { frontmatter, body };
243
+ };
244
+ var normalizeAllowedTools = (value) => {
245
+ if (Array.isArray(value)) {
246
+ return normalizeStringArray(value) ?? [];
247
+ }
248
+ if (typeof value === "string") {
249
+ return value.split(/\s+/).map((item) => item.trim()).filter(Boolean);
250
+ }
251
+ return [];
252
+ };
253
+ var parseExternalSkillMarkdown = (markdown) => {
254
+ const { frontmatter, body } = extractFrontmatter(markdown);
255
+ return {
256
+ name: asOptionalTrimmedString(frontmatter?.name),
257
+ description: asOptionalTrimmedString(frontmatter?.description),
258
+ compatibility: asOptionalTrimmedString(frontmatter?.compatibility),
259
+ allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
260
+ metadata: frontmatter?.metadata && typeof frontmatter.metadata === "object" ? Object.fromEntries(
261
+ Object.entries(frontmatter.metadata).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
262
+ ) : void 0,
263
+ body
264
+ };
265
+ };
266
+
267
+ export {
268
+ normalizeStringArray,
269
+ normalizeSkillModalities,
270
+ parseSkillDocProtocol,
271
+ resolvePageSkillMetadata,
272
+ buildSkillDocMarkdown,
273
+ parseExternalSkillMarkdown
274
+ };
@@ -80,14 +80,14 @@ import {
80
80
  } from "./chunk-VF4K2QE6.js";
81
81
  import {
82
82
  createDocState
83
- } from "./chunk-7UF7CQ6B.js";
83
+ } from "./chunk-GSXDRMDO.js";
84
84
  import {
85
85
  BUILTIN_OBJECT_SKILL_IDS,
86
86
  buildBuiltinObjectSkillConfig,
87
87
  buildBuiltinObjectSkillDbKey,
88
88
  buildBuiltinObjectSkillPageContent,
89
89
  createDialogAction
90
- } from "./chunk-ES6CVKVD.js";
90
+ } from "./chunk-DWYSDNOH.js";
91
91
  import {
92
92
  DEFAULT_COLLAPSED_CATEGORIES,
93
93
  addContentToSpace,
@@ -108,7 +108,7 @@ import {
108
108
  updateContentCategory,
109
109
  updateContentTitle,
110
110
  writeStoredCollapsedCategories
111
- } from "./chunk-AVE2YR4F.js";
111
+ } from "./chunk-N6HLMLKE.js";
112
112
  import {
113
113
  getCurrentSpaceId,
114
114
  getCurrentSpaceIdRaw,
@@ -129,14 +129,14 @@ import {
129
129
  selectMsgById,
130
130
  uiAskChoiceFunc,
131
131
  uiAskChoiceFunctionSchema
132
- } from "./chunk-D5XKNNUV.js";
132
+ } from "./chunk-TBHAHL33.js";
133
133
  import {
134
134
  createAgent,
135
135
  deleteServerSyncedCredential,
136
136
  runLlm,
137
137
  streamAgentChatTurn,
138
138
  updateAgent
139
- } from "./chunk-HQP7HJDL.js";
139
+ } from "./chunk-F44FAXP2.js";
140
140
  import {
141
141
  getActiveDialogKey,
142
142
  selectCurrentDialogKey,
@@ -151,7 +151,7 @@ import {
151
151
  buildCodingSkillContentBySlug,
152
152
  buildCodingSkillId,
153
153
  buildCodingSkillPageKey
154
- } from "./chunk-DZZL7UBV.js";
154
+ } from "./chunk-E3YVTQWT.js";
155
155
  import {
156
156
  CAPABILITY_PACKS
157
157
  } from "./chunk-ZRSJ3JEH.js";
@@ -162,7 +162,7 @@ import {
162
162
  parseExternalSkillMarkdown,
163
163
  parseSkillDocProtocol,
164
164
  resolvePageSkillMetadata
165
- } from "./chunk-EY7V7REW.js";
165
+ } from "./chunk-AETZ7AD6.js";
166
166
  import {
167
167
  NOLO_WORKSPACE_TOOL_NAMES,
168
168
  buildAgentRuntimeAgentLookupKeys,
@@ -16178,7 +16178,7 @@ async function deleteDialogsFunc(args, thunkApi) {
16178
16178
  const deletedDialogIds = [];
16179
16179
  const deletedDialogKeys = [];
16180
16180
  const failures = [];
16181
- const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-ANMACABO.js");
16181
+ const { deleteDialog: deleteDialog2 } = await import("./dialogSlice-R5RZHFTU.js");
16182
16182
  for (const target of targets) {
16183
16183
  try {
16184
16184
  await thunkApi.dispatch(deleteDialog2(target.dbKey)).unwrap();
@@ -26934,7 +26934,7 @@ var executeToolRun = createAsyncThunk(
26934
26934
  if (!executionInput) {
26935
26935
  throw new Error(`ToolRun ${id} has no input to execute with.`);
26936
26936
  }
26937
- const { findToolExecutor: findToolExecutor2 } = await import("./tools-CVLUXK6P.js");
26937
+ const { findToolExecutor: findToolExecutor2 } = await import("./tools-RR53D65Q.js");
26938
26938
  const { executor } = findToolExecutor2(run.toolName);
26939
26939
  toolRunStarted({
26940
26940
  id: run.id,
@@ -29441,7 +29441,7 @@ async function updateDocFunc(args, thunkApi) {
29441
29441
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
29442
29442
  };
29443
29443
  await dispatch(write({ data: updatedPageData, customKey: id })).unwrap();
29444
- const { getDocState, applyExternalDocUpdate } = await import("./docStore-D4HGHPWI.js");
29444
+ const { getDocState, applyExternalDocUpdate } = await import("./docStore-DKWZ6XJ5.js");
29445
29445
  if (getDocState().pageKey === id) {
29446
29446
  applyExternalDocUpdate({
29447
29447
  slateData: finalSlateData,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  addContentToSpace
3
- } from "./chunk-AVE2YR4F.js";
3
+ } from "./chunk-N6HLMLKE.js";
4
4
  import {
5
5
  prepareAndPersistMessage,
6
6
  uiAskChoiceFunc,
7
7
  uiAskChoiceFunctionSchema
8
- } from "./chunk-D5XKNNUV.js";
8
+ } from "./chunk-TBHAHL33.js";
9
9
  import {
10
10
  require_date_fns
11
11
  } from "./chunk-M76ECQRD.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-ZRSJ3JEH.js";
15
15
  import {
16
16
  buildSkillDocMarkdown
17
- } from "./chunk-EY7V7REW.js";
17
+ } from "./chunk-AETZ7AD6.js";
18
18
  import {
19
19
  PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
20
20
  PLATFORM_HOSTED_KIMI_PROVIDER
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  buildSkillDocMarkdown,
7
7
  resolvePageSkillMetadata
8
- } from "./chunk-EY7V7REW.js";
8
+ } from "./chunk-AETZ7AD6.js";
9
9
  import {
10
10
  canonicalizeToolNames
11
11
  } from "./chunk-O6OSWFZQ.js";
@@ -0,0 +1,114 @@
1
+ import {
2
+ load
3
+ } from "./chunk-KHCLMKZZ.js";
4
+ import {
5
+ buildSkillDiscoveryLayer
6
+ } from "./chunk-DVINR3PL.js";
7
+
8
+ // packages/agent-runtime/skillDiscovery.ts
9
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ var SKILL_SCAN_DIRS = [".agents/skills"];
12
+ var MAX_DISCOVERED_SKILLS = 50;
13
+ var MAX_DISCOVERY_DESC_BUDGET = 4e3;
14
+ var MIN_DESC_LENGTH = 80;
15
+ function parseSkillFrontmatter(filePath) {
16
+ try {
17
+ const content = readFileSync(filePath, "utf8").slice(0, 2048);
18
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
19
+ if (!fmMatch) return {};
20
+ const fm = (() => {
21
+ try {
22
+ return load(fmMatch[1]);
23
+ } catch (err) {
24
+ console.warn(
25
+ `[skillDiscovery] failed to parse frontmatter: ${filePath}: ${err.message}`
26
+ );
27
+ throw err;
28
+ }
29
+ })();
30
+ if (!fm || typeof fm !== "object") return {};
31
+ const name = typeof fm.name === "string" ? fm.name : void 0;
32
+ const rawDesc = fm.description;
33
+ const description = typeof rawDesc === "string" ? rawDesc : rawDesc == null ? void 0 : String(rawDesc);
34
+ const sanitizeName = (s) => s?.trim().replace(/^["']|["']$/g, "").replace(/[\n\r]+/g, " ").slice(0, 200);
35
+ const sanitizeDesc = (s) => s?.trim().replace(/^["']|["']$/g, "").replace(/[\n\r]+/g, " ").slice(0, 200);
36
+ return { name: sanitizeName(name), description: sanitizeDesc(description) };
37
+ } catch {
38
+ return {};
39
+ }
40
+ }
41
+ function discoverSkills(cwd) {
42
+ const skills = [];
43
+ for (const dir of SKILL_SCAN_DIRS) {
44
+ if (skills.length >= MAX_DISCOVERED_SKILLS) break;
45
+ const absDir = join(cwd, dir);
46
+ if (!existsSync(absDir) || !statSync(absDir).isDirectory()) continue;
47
+ try {
48
+ for (const entry of readdirSync(absDir)) {
49
+ if (skills.length >= MAX_DISCOVERED_SKILLS) break;
50
+ const skillMdPath = join(absDir, entry, "SKILL.md");
51
+ if (existsSync(skillMdPath)) {
52
+ const { name, description } = parseSkillFrontmatter(skillMdPath);
53
+ skills.push({ name: name ?? entry, description: description ?? "", relativePath: join(dir, entry, "SKILL.md") });
54
+ continue;
55
+ }
56
+ }
57
+ } catch {
58
+ }
59
+ }
60
+ const totalDescLen = skills.reduce((sum, s) => sum + s.description.length, 0);
61
+ if (totalDescLen > MAX_DISCOVERY_DESC_BUDGET && skills.length > 0) {
62
+ const scale = MAX_DISCOVERY_DESC_BUDGET / totalDescLen;
63
+ for (const s of skills) {
64
+ const targetLen = Math.max(MIN_DESC_LENGTH, Math.floor(s.description.length * scale));
65
+ if (s.description.length > targetLen) {
66
+ s.description = s.description.slice(0, targetLen).trimEnd();
67
+ }
68
+ }
69
+ }
70
+ return skills;
71
+ }
72
+ function resolveSkillByName(cwd, name) {
73
+ const trimmed = name.trim();
74
+ if (!trimmed || trimmed.includes("/") || trimmed.includes("\\") || trimmed.includes("..")) {
75
+ return null;
76
+ }
77
+ const agentsDir = join(cwd, ".agents", "skills", trimmed);
78
+ const agentsSkillMd = join(agentsDir, "SKILL.md");
79
+ if (existsSync(agentsSkillMd)) return agentsSkillMd;
80
+ const agentsParent = join(cwd, ".agents", "skills");
81
+ if (existsSync(agentsParent) && statSync(agentsParent).isDirectory()) {
82
+ try {
83
+ for (const entry of readdirSync(agentsParent)) {
84
+ const candidate = join(agentsParent, entry, "SKILL.md");
85
+ if (!existsSync(candidate)) continue;
86
+ try {
87
+ const { name: fmName } = parseSkillFrontmatter(candidate);
88
+ if (fmName && fmName === trimmed) return candidate;
89
+ } catch {
90
+ }
91
+ }
92
+ } catch {
93
+ }
94
+ }
95
+ return null;
96
+ }
97
+ function buildSkillDiscoveryContextLayer(cwd) {
98
+ try {
99
+ return buildSkillDiscoveryLayer(discoverSkills(cwd), cwd);
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+ function buildSkillDiscoveryContextBlock(cwd) {
105
+ return buildSkillDiscoveryContextLayer(cwd)?.content ?? null;
106
+ }
107
+
108
+ export {
109
+ parseSkillFrontmatter,
110
+ discoverSkills,
111
+ resolveSkillByName,
112
+ buildSkillDiscoveryContextLayer,
113
+ buildSkillDiscoveryContextBlock
114
+ };
@@ -304,7 +304,7 @@ var slice = createSliceWithThunks({
304
304
  const overrides = {};
305
305
  if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
306
306
  if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
307
- const { _executeModel } = await import("./_executeModel-CKT6RGTL.js");
307
+ const { _executeModel } = await import("./_executeModel-R26QYY66.js");
308
308
  return _executeModel(
309
309
  {
310
310
  isStreaming: args.isStreaming ?? false,
@@ -325,7 +325,7 @@ var slice = createSliceWithThunks({
325
325
  * - 循环直到无工具调用或触发其他运行时停止条件
326
326
  */
327
327
  runAgent: create.asyncThunk(async (args, thunkApi) => {
328
- const { runAgentClientLoop } = await import("./runAgentClientLoop-KGTEL7ZP.js");
328
+ const { runAgentClientLoop } = await import("./runAgentClientLoop-Y6HWP2PT.js");
329
329
  const { content: loopContent, toolCallCount } = await runAgentClientLoop(
330
330
  {
331
331
  agentKey: args.agentKey,
@@ -341,7 +341,7 @@ var slice = createSliceWithThunks({
341
341
  * 聊天轮次流式 Agent 调用
342
342
  */
343
343
  streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
344
- const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-FLYPTXKZ.js");
344
+ const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-6WFQJ4DY.js");
345
345
  return streamAgentChatTurnHandler(args, thunkApi);
346
346
  }),
347
347
  /**
@@ -326,7 +326,7 @@ async function saveDocState(arg, { dispatch, getState }) {
326
326
  ).unwrap();
327
327
  if (dbSpaceId) {
328
328
  try {
329
- const { updateContentTitle } = await import("./contentThunks-7YG2ZYQC.js");
329
+ const { updateContentTitle } = await import("./contentThunks-OZPK5B4Z.js");
330
330
  await dispatch(
331
331
  updateContentTitle({
332
332
  spaceId: dbSpaceId,
@@ -365,7 +365,7 @@ async function saveDocState(arg, { dispatch, getState }) {
365
365
  }
366
366
  }
367
367
  async function createDocState(args, thunkApi) {
368
- const { createPageAction } = await import("./createPageAction-B7WRHOQO.js");
368
+ const { createPageAction } = await import("./createPageAction-6P2WLNHO.js");
369
369
  return createPageAction(args, thunkApi);
370
370
  }
371
371
  function subscribe(listener) {