nolo-cli 0.34.0-alpha.3 → 0.35.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 (61) hide show
  1. package/{_executeModel-TMUXL7J5.js → _executeModel-RV52PPE3.js} +14 -13
  2. package/{agentDeleteCommand-KA2IQAPG.js → agentDeleteCommand-FBBW3IIM.js} +2 -2
  3. package/{agentEmailCommands-UIYBGCZW.js → agentEmailCommands-7F4PCABZ.js} +14 -13
  4. package/{agentListCommands-L6JNUOLH.js → agentListCommands-ZQXPSB6U.js} +2 -2
  5. package/{agentMachineCommands-5CQW5NZR.js → agentMachineCommands-E3NB67GM.js} +3 -3
  6. package/{agentRecordCommands-VUDJQIZH.js → agentRecordCommands-7PXWHCQM.js} +14 -13
  7. package/{agentRunCommand-EJWYF3BL.js → agentRunCommand-Z4654ONK.js} +15 -14
  8. package/{agentRuntimeLocal-XXBMDMBU.js → agentRuntimeLocal-OBKWKEKW.js} +2 -2
  9. package/{agentSlice-HTIEYKIU.js → agentSlice-B2IMSPH5.js} +1 -1
  10. package/{appDeleteCommands-OUBL6VHB.js → appDeleteCommands-72BE7DSA.js} +2 -2
  11. package/{appDeployCommands-BZSS2MX4.js → appDeployCommands-XJBLKCYO.js} +2 -2
  12. package/{appDeployStatusCommands-P2ZQOY5X.js → appDeployStatusCommands-EC4HWCBQ.js} +2 -2
  13. package/{appGetCommands-WCFWQZZM.js → appGetCommands-62BAATPL.js} +2 -2
  14. package/{appListCommands-FVJ3QNL7.js → appListCommands-5EZCONM7.js} +2 -2
  15. package/{chatQueueReduxAdapter-ZP2ZS63U.js → chatQueueReduxAdapter-SSF3DNBX.js} +2 -2
  16. package/{chunk-P2I7ELDC.js → chunk-2KO5QQFV.js} +1 -1
  17. package/{chunk-TLBZMLLJ.js → chunk-55C3UZSC.js} +3 -3
  18. package/{chunk-5GQ6XCJY.js → chunk-5Q4DXT47.js} +11 -11
  19. package/{chunk-6HIGYUBQ.js → chunk-6XIE5ZGI.js} +1 -1
  20. package/{chunk-PILJX4DH.js → chunk-7KY6U7MW.js} +8 -8
  21. package/chunk-AETZ7AD6.js +274 -0
  22. package/{chunk-I7VDDN45.js → chunk-EFN2AFWF.js} +233 -4
  23. package/{chunk-Z7COG62J.js → chunk-INXNBCEY.js} +2 -2
  24. package/{chunk-EY7V7REW.js → chunk-KHCLMKZZ.js} +6 -280
  25. package/{chunk-XMFDQYWA.js → chunk-KPJYUEPE.js} +1 -1
  26. package/{chunk-WBZE7C6S.js → chunk-LFOILL6R.js} +1 -1
  27. package/{chunk-QI3CHZUT.js → chunk-OCJNJUR4.js} +2 -2
  28. package/chunk-OFZPJ3NT.js +114 -0
  29. package/{chunk-ILZY5B4U.js → chunk-OGPQ3AMC.js} +11 -11
  30. package/{chunk-Y5W623XU.js → chunk-P62APAXL.js} +3 -3
  31. package/{chunk-AA2YUJNV.js → chunk-P66M7LSQ.js} +4 -0
  32. package/{chunk-AE5GVFMG.js → chunk-RUVWTAK7.js} +4 -4
  33. package/{chunk-FT4XBCK4.js → chunk-SDAPQUSO.js} +7 -7
  34. package/{chunk-5LDKQUOT.js → chunk-Z7D7MBWR.js} +1 -1
  35. package/{chunk-RKRXAL3V.js → chunk-ZOEE4OVX.js} +5 -5
  36. package/{chunk-IEEEWIVO.js → chunk-ZZDWMZFU.js} +3 -3
  37. package/{codingSkills-6F4EQFCM.js → codingSkills-H6N5EKSX.js} +3 -2
  38. package/{createAgentAutomationAction-TGUXUZCY.js → createAgentAutomationAction-IDIY6K45.js} +3 -3
  39. package/{createDialogAction-FD5AEOUF.js → createDialogAction-5LB4YBPS.js} +6 -5
  40. package/{createPageAction-NPC3LYNK.js → createPageAction-TJWVDPZD.js} +5 -4
  41. package/{dialogCommands-ZF2RSNCG.js → dialogCommands-44NGBPJJ.js} +2 -2
  42. package/{dialogSlice-6BINHWQT.js → dialogSlice-62JC4ZMX.js} +2 -2
  43. package/{docCreateCommands-4VQ5MOHP.js → docCreateCommands-IOGYJ7F7.js} +5 -4
  44. package/{docDeleteCommands-M7WLNVPB.js → docDeleteCommands-RO4BZWFP.js} +5 -4
  45. package/{docReadCommands-6LU6P2WT.js → docReadCommands-F2KNOJFW.js} +5 -4
  46. package/{docStore-SIUFLABN.js → docStore-ZRNKZZXU.js} +4 -4
  47. package/{docUpdateCommands-S2LX4ENL.js → docUpdateCommands-2VG4AYOC.js} +5 -4
  48. package/{handleSendMessageAction-QVG5YNZY.js → handleSendMessageAction-YB64A32O.js} +2 -2
  49. package/index.js +40 -40
  50. package/{machineCommands-OSEBN7BZ.js → machineCommands-6WPICTON.js} +14 -13
  51. package/{machineWsRunDispatch-NTJQCIIF.js → machineWsRunDispatch-4OGEZTYG.js} +14 -13
  52. package/package.json +1 -1
  53. package/{readlineWorkspace-JPME5S7A.js → readlineWorkspace-BZAZ5YXM.js} +15 -14
  54. package/{runAgentClientLoop-SOKEXCUF.js → runAgentClientLoop-SOZS3YTQ.js} +11 -10
  55. package/{skillDiscovery-GPUDHDTZ.js → skillDiscovery-COX56OBO.js} +2 -1
  56. package/{spaceCommands-Z5JLMFFJ.js → spaceCommands-WEASK3IV.js} +2 -2
  57. package/{spaceSlice-Z3BGCLGX.js → spaceSlice-2QNUKRN6.js} +3 -3
  58. package/{streamAgentChatTurn-INF5RGK4.js → streamAgentChatTurn-BYI7UXAA.js} +13 -12
  59. package/{tools-ZELMSJZ3.js → tools-E6FEUNZY.js} +9 -8
  60. package/{updateDialogTitleAction-EDUCIB7G.js → updateDialogTitleAction-2A3BEXSP.js} +3 -3
  61. package/chunk-2BWU4ORW.js +0 -2574
@@ -1,11 +1,4 @@
1
- import {
2
- asTrimmedNonEmptyStringArray
3
- } from "./chunk-I42VC5KR.js";
4
- import {
5
- asOptionalTrimmedString
6
- } from "./chunk-G3SUCT4W.js";
7
-
8
- // packages/ai/node_modules/js-yaml/dist/js-yaml.mjs
1
+ // node_modules/js-yaml/dist/js-yaml.mjs
9
2
  function getDefaultExportFromCjs(x) {
10
3
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
11
4
  }
@@ -1283,21 +1276,16 @@ function requireLoader() {
1283
1276
  state.result += _result;
1284
1277
  }
1285
1278
  }
1286
- function chargeMergeWork(state) {
1287
- state.totalMergeKeys++;
1288
- if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) {
1289
- throwError(state, "merge keys exceeded maxTotalMergeKeys (" + state.maxTotalMergeKeys + ")");
1290
- }
1291
- }
1292
1279
  function mergeMappings(state, destination, source, overridableKeys) {
1293
1280
  if (!common2.isObject(source)) {
1294
1281
  throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1295
1282
  }
1296
- chargeMergeWork(state);
1297
1283
  const sourceKeys = Object.keys(source);
1298
1284
  for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1299
1285
  const key = sourceKeys[index];
1300
- chargeMergeWork(state);
1286
+ if (state.maxTotalMergeKeys !== -1 && ++state.totalMergeKeys > state.maxTotalMergeKeys) {
1287
+ throwError(state, "merge keys exceeded maxTotalMergeKeys (" + state.maxTotalMergeKeys + ")");
1288
+ }
1301
1289
  if (!_hasOwnProperty.call(destination, key)) {
1302
1290
  setProperty(destination, key, source[key]);
1303
1291
  overridableKeys[key] = true;
@@ -1325,9 +1313,6 @@ function requireLoader() {
1325
1313
  }
1326
1314
  if (keyTag === "tag:yaml.org,2002:merge") {
1327
1315
  if (Array.isArray(valueNode)) {
1328
- if (valueNode.length > 100) {
1329
- throwError(state, "abnormal merge sequence size");
1330
- }
1331
1316
  for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1332
1317
  mergeMappings(state, _result, valueNode[index], overridableKeys);
1333
1318
  }
@@ -3071,266 +3056,7 @@ var {
3071
3056
  safeDump
3072
3057
  } = yaml;
3073
3058
 
3074
- // packages/ai/skills/skillDocProtocol.ts
3075
- var SKILL_DOC_ENUMS = {
3076
- triggerMode: ["explicit", "required", "recommended"],
3077
- // budgetTier 只服务 WorkflowReferenceConfig;skill 侧已移除(零读点)。
3078
- budgetTier: ["low", "medium", "high"],
3079
- modality: ["text", "image", "video", "audio", "3d"],
3080
- docKind: ["knowledge", "instruction", "skill"]
3081
- };
3082
- var SKILL_CONFIG_BLOCK = "skill-config";
3083
- var EVAL_CONFIG_BLOCK = "eval-config";
3084
- var WORKFLOW_CONFIG_BLOCK = "workflow-config";
3085
- var normalizeStringArray = (value) => {
3086
- if (!Array.isArray(value)) return void 0;
3087
- const items = [...new Set(asTrimmedNonEmptyStringArray(value))];
3088
- return items.length > 0 ? items : void 0;
3089
- };
3090
- var normalizeSkillEnumValue = (key, value) => typeof value === "string" && SKILL_DOC_ENUMS[key].includes(value) ? value : void 0;
3091
- var normalizeSkillModalities = (value) => {
3092
- const raw = normalizeStringArray(value);
3093
- if (!raw) return void 0;
3094
- const filtered = raw.flatMap((item) => {
3095
- const modality = normalizeSkillEnumValue("modality", item);
3096
- return modality ? [modality] : [];
3097
- });
3098
- return filtered.length > 0 ? Array.from(new Set(filtered)) : void 0;
3099
- };
3100
- var normalizeSkillConfig = (value, fallbackTools) => {
3101
- if (!value || typeof value !== "object") return void 0;
3102
- const record = value;
3103
- const name = asOptionalTrimmedString(record.name) ?? "";
3104
- const description = asOptionalTrimmedString(record.description) ?? "";
3105
- if (!name || !description) return void 0;
3106
- const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
3107
- const modalities = normalizeSkillModalities(record.modalities);
3108
- const toolNames = normalizeStringArray(record.toolNames) ?? normalizeStringArray(fallbackTools) ?? void 0;
3109
- return {
3110
- version: "0.1",
3111
- kind: "skill",
3112
- id: asOptionalTrimmedString(record.id),
3113
- name,
3114
- description,
3115
- triggerMode,
3116
- toolNames,
3117
- modalities,
3118
- requiredSkills: normalizeStringArray(record.requiredSkills),
3119
- recommendedSkills: normalizeStringArray(record.recommendedSkills),
3120
- promptPatch: asOptionalTrimmedString(record.promptPatch)
3121
- };
3122
- };
3123
- var normalizeEvalConfig = (value) => {
3124
- if (!value || typeof value !== "object") return void 0;
3125
- const record = value;
3126
- if (!Array.isArray(record.cases)) return void 0;
3127
- const cases = [];
3128
- for (const item of record.cases) {
3129
- if (!item || typeof item !== "object") continue;
3130
- const testCase = item;
3131
- const input = asOptionalTrimmedString(testCase.input) ?? "";
3132
- if (!input) continue;
3133
- cases.push({
3134
- input,
3135
- expectedTools: normalizeStringArray(testCase.expectedTools),
3136
- expectedSignals: normalizeStringArray(testCase.expectedSignals),
3137
- forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals)
3138
- });
3139
- }
3140
- return cases.length > 0 ? {
3141
- version: "0.1",
3142
- cases
3143
- } : void 0;
3144
- };
3145
- var normalizeWorkflowConfig = (value) => {
3146
- if (!value || typeof value !== "object") return void 0;
3147
- const record = value;
3148
- const name = asOptionalTrimmedString(record.name) ?? "";
3149
- const description = asOptionalTrimmedString(record.description) ?? "";
3150
- if (!name || !description) return void 0;
3151
- const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
3152
- return {
3153
- version: "0.1",
3154
- kind: "workflow",
3155
- id: asOptionalTrimmedString(record.id),
3156
- name,
3157
- description,
3158
- defaultAgent: asOptionalTrimmedString(record.defaultAgent),
3159
- inputs: normalizeStringArray(record.inputs),
3160
- recommendedTools: normalizeStringArray(record.recommendedTools),
3161
- requiredTools: normalizeStringArray(record.requiredTools),
3162
- requiredOutputs: normalizeStringArray(record.requiredOutputs),
3163
- gates: normalizeStringArray(record.gates),
3164
- budgetTier,
3165
- contextStrategy: asOptionalTrimmedString(record.contextStrategy),
3166
- failureProtocol: asOptionalTrimmedString(record.failureProtocol)
3167
- };
3168
- };
3169
- var normalizePageSkillMetadata = (value, fallbackTools) => {
3170
- if (!value || typeof value !== "object") return void 0;
3171
- const record = value;
3172
- const kind = normalizeSkillEnumValue("docKind", record.kind);
3173
- const meta = {
3174
- kind,
3175
- requiredSkills: normalizeStringArray(record.requiredSkills),
3176
- recommendedSkills: normalizeStringArray(record.recommendedSkills),
3177
- skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
3178
- evalConfig: normalizeEvalConfig(record.evalConfig),
3179
- workflowConfig: normalizeWorkflowConfig(record.workflowConfig)
3180
- };
3181
- if (meta.skillConfig && !meta.kind) {
3182
- meta.kind = "skill";
3183
- }
3184
- if (meta.workflowConfig && !meta.kind) {
3185
- meta.kind = "instruction";
3186
- }
3187
- return meta.kind || meta.requiredSkills || meta.recommendedSkills || meta.skillConfig || meta.evalConfig || meta.workflowConfig ? meta : void 0;
3188
- };
3189
- var extractCommentBlock = (markdown, blockName) => {
3190
- if (!markdown) return void 0;
3191
- const matcher = new RegExp(
3192
- `<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
3193
- "i"
3194
- );
3195
- const match = markdown.match(matcher);
3196
- return asOptionalTrimmedString(match?.[1]);
3197
- };
3198
- var removeCommentBlock = (markdown, blockName) => markdown.replace(
3199
- new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
3200
- "\n\n"
3201
- );
3202
- var parseYamlObject = (raw) => {
3203
- if (!raw) return void 0;
3204
- try {
3205
- const parsed = load(raw);
3206
- return parsed && typeof parsed === "object" ? parsed : void 0;
3207
- } catch {
3208
- return void 0;
3209
- }
3210
- };
3211
- var parseSkillDocProtocol = (markdown, existingMeta, fallbackTools) => {
3212
- const source = typeof markdown === "string" ? markdown : "";
3213
- const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
3214
- const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
3215
- const workflowBlock = parseYamlObject(extractCommentBlock(source, WORKFLOW_CONFIG_BLOCK));
3216
- const cleanedContent = removeCommentBlock(
3217
- removeCommentBlock(
3218
- removeCommentBlock(source, SKILL_CONFIG_BLOCK),
3219
- EVAL_CONFIG_BLOCK
3220
- ),
3221
- WORKFLOW_CONFIG_BLOCK
3222
- ).replace(/\n{3,}/g, "\n\n").trim();
3223
- const parsedMeta = normalizePageSkillMetadata(
3224
- {
3225
- ...existingMeta ?? {},
3226
- ...skillBlock ? {
3227
- kind: existingMeta?.kind === "skill" || skillBlock.kind === "skill" ? "skill" : existingMeta?.kind,
3228
- requiredSkills: skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
3229
- recommendedSkills: skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
3230
- skillConfig: skillBlock
3231
- } : {},
3232
- ...evalBlock ? { evalConfig: evalBlock } : {},
3233
- ...workflowBlock ? { workflowConfig: workflowBlock } : {}
3234
- },
3235
- fallbackTools
3236
- );
3237
- return {
3238
- content: cleanedContent,
3239
- meta: parsedMeta
3240
- };
3241
- };
3242
- var resolvePageSkillMetadata = (page) => {
3243
- if (!page) return void 0;
3244
- const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
3245
- return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
3246
- };
3247
- var yamlBlock = (value) => dump(value, { lineWidth: 120, noRefs: true }).trim();
3248
- var buildSkillConfigComment = (config) => {
3249
- const payload = {
3250
- version: config.version,
3251
- kind: config.kind,
3252
- ...config.id ? { id: config.id } : {},
3253
- name: config.name,
3254
- description: config.description,
3255
- ...config.triggerMode ? { triggerMode: config.triggerMode } : {},
3256
- ...config.requiredSkills?.length ? { requiredSkills: config.requiredSkills } : {},
3257
- ...config.recommendedSkills?.length ? { recommendedSkills: config.recommendedSkills } : {},
3258
- ...config.toolNames?.length ? { toolNames: config.toolNames } : {},
3259
- ...config.modalities?.length ? { modalities: config.modalities } : {},
3260
- ...config.promptPatch ? { promptPatch: config.promptPatch } : {}
3261
- };
3262
- return `<!-- ${SKILL_CONFIG_BLOCK}
3263
- ${yamlBlock(payload)}
3264
- -->`;
3265
- };
3266
- var buildEvalConfigComment = (config) => `<!-- ${EVAL_CONFIG_BLOCK}
3267
- ${yamlBlock({
3268
- version: config.version,
3269
- cases: config.cases
3270
- })}
3271
- -->`;
3272
- var buildWorkflowConfigComment = (config) => `<!-- ${WORKFLOW_CONFIG_BLOCK}
3273
- ${yamlBlock({
3274
- version: config.version,
3275
- kind: config.kind,
3276
- ...config.id ? { id: config.id } : {},
3277
- name: config.name,
3278
- description: config.description,
3279
- ...config.defaultAgent ? { defaultAgent: config.defaultAgent } : {},
3280
- ...config.inputs?.length ? { inputs: config.inputs } : {},
3281
- ...config.recommendedTools?.length ? { recommendedTools: config.recommendedTools } : {},
3282
- ...config.requiredTools?.length ? { requiredTools: config.requiredTools } : {},
3283
- ...config.requiredOutputs?.length ? { requiredOutputs: config.requiredOutputs } : {},
3284
- ...config.gates?.length ? { gates: config.gates } : {},
3285
- ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
3286
- ...config.contextStrategy ? { contextStrategy: config.contextStrategy } : {},
3287
- ...config.failureProtocol ? { failureProtocol: config.failureProtocol } : {}
3288
- })}
3289
- -->`;
3290
- var buildSkillDocMarkdown = (options) => {
3291
- const sections = [
3292
- asOptionalTrimmedString(options.body) ?? "",
3293
- buildSkillConfigComment(options.skillConfig),
3294
- options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
3295
- options.workflowConfig ? buildWorkflowConfigComment(options.workflowConfig) : ""
3296
- ].filter(Boolean);
3297
- return sections.join("\n\n").trim();
3298
- };
3299
- var extractFrontmatter = (markdown) => {
3300
- const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
3301
- if (!match) return { body: markdown.trim() };
3302
- const frontmatter = parseYamlObject(match[1]);
3303
- const body = markdown.slice(match[0].length).trim();
3304
- return { frontmatter, body };
3305
- };
3306
- var normalizeAllowedTools = (value) => {
3307
- if (Array.isArray(value)) {
3308
- return normalizeStringArray(value) ?? [];
3309
- }
3310
- if (typeof value === "string") {
3311
- return value.split(/\s+/).map((item) => item.trim()).filter(Boolean);
3312
- }
3313
- return [];
3314
- };
3315
- var parseExternalSkillMarkdown = (markdown) => {
3316
- const { frontmatter, body } = extractFrontmatter(markdown);
3317
- return {
3318
- name: asOptionalTrimmedString(frontmatter?.name),
3319
- description: asOptionalTrimmedString(frontmatter?.description),
3320
- compatibility: asOptionalTrimmedString(frontmatter?.compatibility),
3321
- allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
3322
- metadata: frontmatter?.metadata && typeof frontmatter.metadata === "object" ? Object.fromEntries(
3323
- Object.entries(frontmatter.metadata).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
3324
- ) : void 0,
3325
- body
3326
- };
3327
- };
3328
-
3329
3059
  export {
3330
- normalizeStringArray,
3331
- normalizeSkillModalities,
3332
- parseSkillDocProtocol,
3333
- resolvePageSkillMetadata,
3334
- buildSkillDocMarkdown,
3335
- parseExternalSkillMarkdown
3060
+ load,
3061
+ dump
3336
3062
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  i18n_default,
3
3
  toolRegistry
4
- } from "./chunk-5GQ6XCJY.js";
4
+ } from "./chunk-5Q4DXT47.js";
5
5
  import {
6
6
  canonicalizeToolNames
7
7
  } from "./chunk-O6OSWFZQ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchReferenceContents,
3
3
  resolveReferenceAssets
4
- } from "./chunk-AE5GVFMG.js";
4
+ } from "./chunk-RUVWTAK7.js";
5
5
 
6
6
  // packages/ai/agent/fetchAgentContexts.ts
7
7
  async function fetchAgentContexts(references, dispatch) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  deleteDialog,
3
3
  toast
4
- } from "./chunk-PILJX4DH.js";
4
+ } from "./chunk-7KY6U7MW.js";
5
5
  import {
6
6
  deleteServerSyncedCredential
7
- } from "./chunk-TLBZMLLJ.js";
7
+ } from "./chunk-55C3UZSC.js";
8
8
  import {
9
9
  require_date_fns
10
10
  } from "./chunk-M76ECQRD.js";
@@ -0,0 +1,114 @@
1
+ import {
2
+ load
3
+ } from "./chunk-KHCLMKZZ.js";
4
+ import {
5
+ buildSkillDiscoveryLayer
6
+ } from "./chunk-3AOLVADY.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
+ };
@@ -20,7 +20,7 @@ import {
20
20
  parseAgentRunEvent,
21
21
  t,
22
22
  toolLabel
23
- } from "./chunk-RKRXAL3V.js";
23
+ } from "./chunk-ZOEE4OVX.js";
24
24
  import {
25
25
  getReadableCliDb
26
26
  } from "./chunk-UNHKVD2N.js";
@@ -51,7 +51,7 @@ import {
51
51
  } from "./chunk-LTRXGFMS.js";
52
52
  import {
53
53
  formatAgentListCard
54
- } from "./chunk-5GQ6XCJY.js";
54
+ } from "./chunk-5Q4DXT47.js";
55
55
  import {
56
56
  isGatewayHttpStatus
57
57
  } from "./chunk-RQSOAMPJ.js";
@@ -70,28 +70,28 @@ import {
70
70
  chooseMemoryOwners,
71
71
  loadMemoryCandidatesFromDb,
72
72
  resolveAgentMemoryPolicy
73
- } from "./chunk-Y5W623XU.js";
73
+ } from "./chunk-P62APAXL.js";
74
74
  import {
75
75
  API_REPORTED_COST_MULTIPLIER,
76
76
  normalizeUsage,
77
77
  parseUiAskChoiceContent
78
- } from "./chunk-PILJX4DH.js";
78
+ } from "./chunk-7KY6U7MW.js";
79
79
  import {
80
80
  getDefaultCliLocalRuntimeDb
81
81
  } from "./chunk-N4XRDM26.js";
82
82
  import {
83
83
  buildSkillDiscoveryContextLayer
84
- } from "./chunk-2BWU4ORW.js";
84
+ } from "./chunk-OFZPJ3NT.js";
85
85
  import {
86
86
  parseExternalSkillMarkdown,
87
87
  parseSkillDocProtocol
88
- } from "./chunk-EY7V7REW.js";
88
+ } from "./chunk-AETZ7AD6.js";
89
89
  import {
90
90
  LOCAL_AGENT_CONFIG_MISSING_CODE,
91
91
  LOCAL_TURN_ABORTED_CODE,
92
92
  readActionGate,
93
93
  readCommandActionGatePayload
94
- } from "./chunk-I7VDDN45.js";
94
+ } from "./chunk-EFN2AFWF.js";
95
95
  import {
96
96
  resolveAgentRuntimeConfigFromRecord
97
97
  } from "./chunk-64KIQZA2.js";
@@ -5359,7 +5359,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
5359
5359
  // packages/cli/client/agentRun.ts
5360
5360
  import { ulid } from "ulid";
5361
5361
  async function loadRunLocalAgentTurn() {
5362
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-XXBMDMBU.js");
5362
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-OBKWKEKW.js");
5363
5363
  return runLocalAgentTurn;
5364
5364
  }
5365
5365
  async function resolveCurrentMachineId(options) {
@@ -7149,9 +7149,9 @@ async function runAgentRunCommand(args, deps) {
7149
7149
  }
7150
7150
  }
7151
7151
  if (typeof childRunId === "string" && childRunId.length > 0) {
7152
- const isTruncated = result.emptyAssistantFallbackReason === "length_truncated" || result.emptyAssistantFallbackReason === "stream_truncated";
7153
- const truncationNote = isTruncated ? { note: `empty assistant output: ${result.emptyAssistantFallbackReason}` } : {};
7154
- const finalStatus = isTruncated || result.exitCode !== 0 ? "failed" : "done";
7152
+ const isStalledOrTruncated = result.emptyAssistantFallbackReason === "length_truncated" || result.emptyAssistantFallbackReason === "stream_truncated" || result.emptyAssistantFallbackReason === "repetition_loop" || result.emptyAssistantFallbackReason === "stagnant_tool_calls";
7153
+ const truncationNote = isStalledOrTruncated ? { note: `empty assistant output: ${result.emptyAssistantFallbackReason}` } : {};
7154
+ const finalStatus = isStalledOrTruncated || result.exitCode !== 0 ? "failed" : "done";
7155
7155
  await (deps.finalizeRunRecord ?? finalizeRunRecord)(
7156
7156
  childRunId,
7157
7157
  {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  addContentToSpace
3
- } from "./chunk-QI3CHZUT.js";
3
+ } from "./chunk-OCJNJUR4.js";
4
4
  import {
5
5
  prepareAndPersistMessage,
6
6
  uiAskChoiceFunc,
7
7
  uiAskChoiceFunctionSchema
8
- } from "./chunk-PILJX4DH.js";
8
+ } from "./chunk-7KY6U7MW.js";
9
9
  import {
10
10
  require_date_fns
11
11
  } from "./chunk-M76ECQRD.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-IIOHYLIG.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_DEEPSEEK_FLASH_PEAK_PRICE,
@@ -3,6 +3,8 @@ var EMPTY_ASSISTANT_REPAIR_PROMPT = "\u8BF7\u7ED9\u51FA\u660E\u786E\u7684\u6587\
3
3
  var EMPTY_ASSISTANT_FALLBACK_MESSAGE = "\u6A21\u578B\u8FDE\u7EED\u8FD4\u56DE\u7A7A\u6D88\u606F\uFF0C\u5F53\u524D\u4EFB\u52A1\u672A\u5B8C\u6210\u3002\u8BF7\u91CD\u8BD5\u5F53\u524D\u6B65\u9AA4\uFF0C\u6216\u7ED9\u51FA\u66F4\u5177\u4F53\u7684\u4FEE\u6539\u8303\u56F4\u3002";
4
4
  var LENGTH_TRUNCATED_FALLBACK_MESSAGE = "\u8F93\u51FA\u8FBE\u5230\u957F\u5EA6\u4E0A\u9650\u88AB\u622A\u65AD\uFF0C\u5EFA\u8BAE\u7F29\u77ED\u4EFB\u52A1\u6216\u63D0\u9AD8\u8F93\u51FA\u4E0A\u9650\u3002";
5
5
  var STREAM_TRUNCATED_FALLBACK_MESSAGE = "\u4E0A\u6E38\u54CD\u5E94\u6D41\u5728\u6536\u5C3E\u524D\u88AB\u4E2D\u65AD\uFF08\u672A\u6536\u5230\u7ED3\u675F\u6807\u8BB0\uFF09\uFF0C\u672C\u8F6E\u8F93\u51FA\u4E0D\u5B8C\u6574\u3002\u8BF7\u91CD\u8BD5\u5F53\u524D\u6B65\u9AA4\u3002";
6
+ var REPETITION_LOOP_FALLBACK_MESSAGE = "\u68C0\u6D4B\u5230\u6A21\u578B\u9677\u5165\u91CD\u590D\u8F93\u51FA\u6B7B\u5FAA\u73AF\uFF0C\u5DF2\u81EA\u52A8\u7194\u65AD\u7EC8\u6B62\u5F53\u524D\u4EFB\u52A1\u3002";
7
+ var STAGNANT_TOOL_CALLS_FALLBACK_MESSAGE = "\u68C0\u6D4B\u5230\u8FDE\u7EED\u591A\u6B21\u76F8\u540C\u5DE5\u5177\u8C03\u7528\u4E14\u65E0\u5B9E\u8D28\u8FDB\u5C55\uFF0C\u5DF2\u81EA\u52A8\u7194\u65AD\u7EC8\u6B62\u5F53\u524D\u4EFB\u52A1\u3002";
6
8
  var MAX_REASONING_ONLY_REPAIRS = 2;
7
9
  function resolveEmptyAssistantOutcome(args) {
8
10
  if (args.hasToolCalls || args.hasVisibleOutput) return { kind: "ok" };
@@ -20,6 +22,8 @@ function resolveEmptyAssistantOutcome(args) {
20
22
  function resolveEmptyAssistantFallbackMessage(reason) {
21
23
  if (reason === "length_truncated") return LENGTH_TRUNCATED_FALLBACK_MESSAGE;
22
24
  if (reason === "stream_truncated") return STREAM_TRUNCATED_FALLBACK_MESSAGE;
25
+ if (reason === "repetition_loop") return REPETITION_LOOP_FALLBACK_MESSAGE;
26
+ if (reason === "stagnant_tool_calls") return STAGNANT_TOOL_CALLS_FALLBACK_MESSAGE;
23
27
  return EMPTY_ASSISTANT_FALLBACK_MESSAGE;
24
28
  }
25
29
  function hasAssistantVisibleOutput(content) {
@@ -10,7 +10,7 @@ import {
10
10
  fetchAndSerializeTable,
11
11
  resolveBuiltinSkillPage,
12
12
  waitForAbortableDelay
13
- } from "./chunk-5GQ6XCJY.js";
13
+ } from "./chunk-5Q4DXT47.js";
14
14
  import {
15
15
  createDrainExhaustedResponse,
16
16
  isCoreDrainingBody,
@@ -26,18 +26,18 @@ import {
26
26
  } from "./chunk-MEYIRKDN.js";
27
27
  import {
28
28
  fetchAndCacheMessages
29
- } from "./chunk-PILJX4DH.js";
29
+ } from "./chunk-7KY6U7MW.js";
30
30
  import {
31
31
  shouldUseServerProxy
32
32
  } from "./chunk-YYLHWIW6.js";
33
33
  import {
34
34
  fetchServerSyncedCredential
35
- } from "./chunk-TLBZMLLJ.js";
35
+ } from "./chunk-55C3UZSC.js";
36
36
  import {
37
37
  buildSkillGuidancePromptBlock,
38
38
  extractRuntimePageCapabilities,
39
39
  resolveSkillGraphFromRoots
40
- } from "./chunk-P2I7ELDC.js";
40
+ } from "./chunk-2KO5QQFV.js";
41
41
  import {
42
42
  buildCurrentTimeBlock,
43
43
  buildIdentityBlock,
@@ -5,14 +5,14 @@ import {
5
5
  inlineImageUrlsForCustomProvider,
6
6
  prepareTools,
7
7
  shouldInlineImageUrlsForAgent
8
- } from "./chunk-XMFDQYWA.js";
8
+ } from "./chunk-KPJYUEPE.js";
9
9
  import {
10
10
  INVALID_TOOL_ARGS_REPLACEMENT,
11
11
  buildInvalidToolCallSelfHealResult,
12
12
  parseToolCallArguments,
13
13
  performFetchRequest,
14
14
  sanitizeOutboundMessages
15
- } from "./chunk-AE5GVFMG.js";
15
+ } from "./chunk-RUVWTAK7.js";
16
16
  import {
17
17
  createSSEParser,
18
18
  createToolRunId,
@@ -23,22 +23,22 @@ import {
23
23
  toolRunSetPending,
24
24
  toolRunStarted,
25
25
  toolRunSucceeded
26
- } from "./chunk-5GQ6XCJY.js";
26
+ } from "./chunk-5Q4DXT47.js";
27
27
  import {
28
28
  getPublicImageAgentMode
29
29
  } from "./chunk-VIDPVFP3.js";
30
30
  import {
31
31
  getCurrentSpaceId
32
- } from "./chunk-QI3CHZUT.js";
32
+ } from "./chunk-OCJNJUR4.js";
33
33
  import {
34
34
  addToolMessage,
35
35
  messageStreamEnd,
36
36
  messageStreaming,
37
37
  updateToolMessage
38
- } from "./chunk-PILJX4DH.js";
38
+ } from "./chunk-7KY6U7MW.js";
39
39
  import {
40
40
  streamAgentChatTurn
41
- } from "./chunk-TLBZMLLJ.js";
41
+ } from "./chunk-55C3UZSC.js";
42
42
  import {
43
43
  addActiveController,
44
44
  removeActiveController,
@@ -46,7 +46,7 @@ import {
46
46
  } from "./chunk-MRWGHF56.js";
47
47
  import {
48
48
  EMPTY_ASSISTANT_REPAIR_PROMPT
49
- } from "./chunk-AA2YUJNV.js";
49
+ } from "./chunk-P66M7LSQ.js";
50
50
  import {
51
51
  accumulateToolCallDelta,
52
52
  createThinkParserState,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearCliLocalRuntimePreparedAgentCache
3
- } from "./chunk-RKRXAL3V.js";
3
+ } from "./chunk-ZOEE4OVX.js";
4
4
  import {
5
5
  getReadableCliDb
6
6
  } from "./chunk-UNHKVD2N.js";