@eum-agent/skill-management 1.1.0 → 1.2.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.
package/ui/ui.js CHANGED
@@ -19,9 +19,14 @@ var CATALOGUES$1 = {
19
19
  "skills.preloadOff": "按需读取:需要时再加载正文。点击开启预加载。",
20
20
  "skills.layer.global": "全局",
21
21
  "skills.layer.agent": "智能体",
22
+ "skills.layer.plugin": "插件",
23
+ "skills.overrides": "覆盖插件 {{source}}",
24
+ "skills.overridesHint": "会话与预载都使用这里的技能;工作空间中的同名技能只影响会话,不影响预载。",
25
+ "skills.plugin.duplicate": "多个插件提供同名技能:{{detail}}",
26
+ "skills.plugin.invalid": "插件技能无效:{{detail}}",
22
27
  "skills.preload": "预载 {{id}}",
23
28
  "skills.missing": "缺失",
24
- "skills.missingHint": "已预载,但全局层和智能体层都找不到。",
29
+ "skills.missingHint": "已预载,但插件、全局层和智能体层都找不到。",
25
30
  "skills.unpreload": "取消预载",
26
31
  "skills.failed": "无法读取的技能",
27
32
  "skills.empty": "还没有技能",
@@ -61,9 +66,7 @@ var CATALOGUES$1 = {
61
66
  "install.title": "安装技能",
62
67
  "install.queryPlaceholder": "搜索名称、用途或关键词",
63
68
  "install.load": "读取",
64
- "install.chooseDirectory": "选择目录",
65
- "install.chooseArchive": "选择压缩包",
66
- "install.selectAll": "全选",
69
+ "install.chooseLocal": "选择目录或压缩包",
67
70
  "install.stars": "星标",
68
71
  "install.downloads": "下载量",
69
72
  "install.searchEmpty": "输入关键词搜索技能",
@@ -74,7 +77,7 @@ var CATALOGUES$1 = {
74
77
  "install.list": "技能列表",
75
78
  "install.close": "关闭",
76
79
  "install.from": "安装来源",
77
- "install.from.registry": "SkillHub",
80
+ "install.from.registry": "技能市场",
78
81
  "install.from.github": "GitHub",
79
82
  "install.from.local": "本地文件",
80
83
  "install.registry": "技能市场",
@@ -102,7 +105,8 @@ var CATALOGUES$1 = {
102
105
  "install.target.global": "所有智能体",
103
106
  "install.sourceLabel": "安装来源",
104
107
  "install.id": "技能标识",
105
- "install.files": "{{count}} 个文件 · {{size}}",
108
+ "install.editId": "修改技能标识",
109
+ "install.confirmId": "确定",
106
110
  "install.scripts": "脚本文件({{count}})",
107
111
  "install.willNormalize": "格式规范化",
108
112
  "install.normalizeHelp": "安装时将按 Agent Skills 规范整理 SKILL.md 的技能信息。",
@@ -118,7 +122,6 @@ var CATALOGUES$1 = {
118
122
  "install.confirm": "安装",
119
123
  "install.installing": "正在安装…",
120
124
  "install.done": "完成",
121
- "install.installed": "已安装",
122
125
  "install.skipped": "已跳过",
123
126
  "install.installedToast": "已安装 {{count}} 个技能",
124
127
  "install.pick": "安装 {{id}}",
@@ -152,9 +155,14 @@ var CATALOGUES$1 = {
152
155
  "skills.preloadOff": "Read on demand. Click to preload into the prompt.",
153
156
  "skills.layer.global": "Global",
154
157
  "skills.layer.agent": "Agent",
158
+ "skills.layer.plugin": "Plugin",
159
+ "skills.overrides": "Overrides plugin {{source}}",
160
+ "skills.overridesHint": "Sessions and preloading both use this skill; a same-id workspace skill affects sessions only, never preloading.",
161
+ "skills.plugin.duplicate": "Several plugins provide this id: {{detail}}",
162
+ "skills.plugin.invalid": "Invalid plugin skill: {{detail}}",
155
163
  "skills.preload": "Preload {{id}}",
156
164
  "skills.missing": "Missing",
157
- "skills.missingHint": "Preloaded, but neither the global nor the agent layer has it.",
165
+ "skills.missingHint": "Preloaded, but no plugin, global or agent layer has it.",
158
166
  "skills.unpreload": "Stop preloading",
159
167
  "skills.failed": "Skills that cannot be read",
160
168
  "skills.empty": "No skills yet",
@@ -194,9 +202,7 @@ var CATALOGUES$1 = {
194
202
  "install.title": "Install skill",
195
203
  "install.queryPlaceholder": "Search names, uses or keywords",
196
204
  "install.load": "Load",
197
- "install.chooseDirectory": "Choose directory",
198
- "install.chooseArchive": "Choose archive",
199
- "install.selectAll": "Select all",
205
+ "install.chooseLocal": "Choose directory or archive",
200
206
  "install.stars": "Stars",
201
207
  "install.downloads": "Downloads",
202
208
  "install.searchEmpty": "Enter keywords to search for skills",
@@ -207,7 +213,7 @@ var CATALOGUES$1 = {
207
213
  "install.list": "Skill list",
208
214
  "install.close": "Close",
209
215
  "install.from": "Installation source",
210
- "install.from.registry": "SkillHub",
216
+ "install.from.registry": "Skill marketplace",
211
217
  "install.from.github": "GitHub",
212
218
  "install.from.local": "Local files",
213
219
  "install.registry": "Marketplace",
@@ -235,7 +241,8 @@ var CATALOGUES$1 = {
235
241
  "install.target.global": "All agents",
236
242
  "install.sourceLabel": "Installation source",
237
243
  "install.id": "Skill ID",
238
- "install.files": "{{count}} files · {{size}}",
244
+ "install.editId": "Edit skill ID",
245
+ "install.confirmId": "Confirm",
239
246
  "install.scripts": "Script files ({{count}})",
240
247
  "install.willNormalize": "Format normalization",
241
248
  "install.normalizeHelp": "Installation formats the skill metadata in SKILL.md according to the Agent Skills specification.",
@@ -251,7 +258,6 @@ var CATALOGUES$1 = {
251
258
  "install.confirm": "Install",
252
259
  "install.installing": "Installing…",
253
260
  "install.done": "Done",
254
- "install.installed": "Installed",
255
261
  "install.skipped": "Skipped",
256
262
  "install.installedToast": "Installed {{count}} skills",
257
263
  "install.pick": "Install {{id}}",
@@ -282,76 +288,11 @@ var TOOL_NAMES = [
282
288
  "skill_write",
283
289
  "skill_install",
284
290
  "skill_uninstall",
285
- "skill_set_preload"
291
+ "skill_set_preload",
292
+ "skill_validate",
293
+ "skill_publish"
286
294
  ];
287
295
  //#endregion
288
- //#region src/ui/metadata.ts
289
- var CATALOGUES = {
290
- "en-US": {
291
- section: "Built-in plugins",
292
- group: "Skills",
293
- skill_read: "Read skill",
294
- skill_search: "Find skills",
295
- skill_write: "Save skill",
296
- skill_install: "Install skill",
297
- skill_uninstall: "Uninstall skill",
298
- skill_set_preload: "Set preloaded skills"
299
- },
300
- "zh-CN": {
301
- section: "内置插件",
302
- group: "技能",
303
- skill_read: "读取技能",
304
- skill_search: "查找技能",
305
- skill_write: "保存技能",
306
- skill_install: "安装技能",
307
- skill_uninstall: "卸载技能",
308
- skill_set_preload: "设置预加载技能"
309
- }
310
- };
311
- var names = new Set(TOOL_NAMES);
312
- /** Registers presentation facets with the same activation lifetime as the tools. */
313
- function registerMetadata(ctx) {
314
- ctx.i18n.register(CATALOGUES, "en-US");
315
- ctx.i18n.contribute(Object.fromEntries(Object.entries(CATALOGUES).map(([language, catalogue]) => [language, Object.fromEntries([...names].map((tool) => [`transcript.actions.${tool}`, catalogue[tool] ?? tool]))])), "en-US");
316
- ctx.slots.register("chat.tool.presentation", {
317
- id: "tool-metadata",
318
- describe: ({ call }) => {
319
- if (!names.has(call.name)) return void 0;
320
- const input = call.input !== null && typeof call.input === "object" ? call.input : {};
321
- const summary = [
322
- "path",
323
- "url",
324
- "query",
325
- "command",
326
- "skill",
327
- "id",
328
- "name",
329
- "task",
330
- "prompt"
331
- ].flatMap((key) => typeof input[key] === "string" ? [input[key]] : []).slice(0, 2).join(" · ").replace(/\s+/g, " ").slice(0, 240);
332
- return {
333
- label: names.has(call.name) ? ctx.i18n.t(call.name) : call.name,
334
- icon: "hammer",
335
- summary
336
- };
337
- }
338
- });
339
- ctx.slots.register("shell.tools.group", {
340
- id: "tool-groups",
341
- describe: (tool) => {
342
- if (tool.plugin !== ctx.plugin) return void 0;
343
- return {
344
- key: `plugin:${ctx.plugin}`,
345
- label: ctx.i18n.t("group"),
346
- source: ctx.plugin,
347
- sectionLabel: ctx.i18n.t("section"),
348
- sectionOrder: 1,
349
- order: 3
350
- };
351
- }
352
- });
353
- }
354
- //#endregion
355
296
  //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
356
297
  var _a$1;
357
298
  function $constructor(name, initializer, params) {
@@ -960,6 +901,7 @@ var string$1 = (params) => {
960
901
  var integer = /^-?\d+$/;
961
902
  var number$1 = /^-?\d+(?:\.\d+)?$/;
962
903
  var boolean$1 = /^(?:true|false)$/i;
904
+ var _null$2 = /^null$/i;
963
905
  var lowercase = /^[^A-Z]*$/;
964
906
  var uppercase = /^[^a-z]*$/;
965
907
  //#endregion
@@ -1776,6 +1718,22 @@ var $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
1776
1718
  return payload;
1777
1719
  };
1778
1720
  });
1721
+ var $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
1722
+ $ZodType.init(inst, def);
1723
+ inst._zod.pattern = _null$2;
1724
+ inst._zod.values = /* @__PURE__ */ new Set([null]);
1725
+ inst._zod.parse = (payload, _ctx) => {
1726
+ const input = payload.value;
1727
+ if (input === null) return payload;
1728
+ payload.issues.push({
1729
+ expected: "null",
1730
+ code: "invalid_type",
1731
+ input,
1732
+ inst
1733
+ });
1734
+ return payload;
1735
+ };
1736
+ });
1779
1737
  var $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
1780
1738
  $ZodType.init(inst, def);
1781
1739
  inst._zod.parse = (payload) => payload;
@@ -2889,6 +2847,13 @@ function _boolean(Class, params) {
2889
2847
  });
2890
2848
  }
2891
2849
  // @__NO_SIDE_EFFECTS__
2850
+ function _null$1(Class, params) {
2851
+ return new Class({
2852
+ type: "null",
2853
+ ...normalizeParams(params)
2854
+ });
2855
+ }
2856
+ // @__NO_SIDE_EFFECTS__
2892
2857
  function _unknown(Class) {
2893
2858
  return new Class({ type: "unknown" });
2894
2859
  }
@@ -3441,6 +3406,13 @@ var numberProcessor = (schema, ctx, _json, _params) => {
3441
3406
  var booleanProcessor = (_schema, _ctx, json, _params) => {
3442
3407
  json.type = "boolean";
3443
3408
  };
3409
+ var nullProcessor = (_schema, ctx, json, _params) => {
3410
+ if (ctx.target === "openapi-3.0") {
3411
+ json.type = "string";
3412
+ json.nullable = true;
3413
+ json.enum = [null];
3414
+ } else json.type = "null";
3415
+ };
3444
3416
  var neverProcessor = (_schema, _ctx, json, _params) => {
3445
3417
  json.not = {};
3446
3418
  };
@@ -4102,6 +4074,14 @@ var ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
4102
4074
  function boolean(params) {
4103
4075
  return /* @__PURE__ */ _boolean(ZodBoolean, params);
4104
4076
  }
4077
+ var ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
4078
+ $ZodNull.init(inst, def);
4079
+ ZodType.init(inst, def);
4080
+ inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
4081
+ });
4082
+ function _null(params) {
4083
+ return /* @__PURE__ */ _null$1(ZodNull, params);
4084
+ }
4105
4085
  var ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
4106
4086
  $ZodUnknown.init(inst, def);
4107
4087
  ZodType.init(inst, def);
@@ -4480,6 +4460,169 @@ function superRefine(fn, params) {
4480
4460
  return /* @__PURE__ */ _superRefine(fn, params);
4481
4461
  }
4482
4462
  //#endregion
4463
+ //#region src/body-document.ts
4464
+ /** A validated immutable body descriptor; eligibility is always checked by the host. */
4465
+ var LocalBodyRefSchema = strictObject({
4466
+ bodyId: uuid(),
4467
+ codec: _enum([
4468
+ "utf8-text",
4469
+ "json",
4470
+ "opaque"
4471
+ ]),
4472
+ formatVersion: literal(1),
4473
+ byteLength: number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
4474
+ sha256: string().regex(/^[a-f0-9]{64}$/)
4475
+ });
4476
+ //#endregion
4477
+ //#region src/read-data.ts
4478
+ /** Browser-safe skill read inputs and source descriptors. */
4479
+ /** Host-bound plugin provenance; diagnostic only, it grants no path or execution. */
4480
+ var PluginSkillSourceSchema = strictObject({
4481
+ kind: literal("plugin"),
4482
+ owner: string(),
4483
+ packageVersion: string(),
4484
+ digest: string(),
4485
+ registrationId: string()
4486
+ });
4487
+ /** Native sources keep their authorized root; plugin sources never carry one. */
4488
+ var SkillSourceSchema = discriminatedUnion("kind", [
4489
+ strictObject({
4490
+ kind: literal("native"),
4491
+ layer: _enum([
4492
+ "global",
4493
+ "agent",
4494
+ "workspace"
4495
+ ]),
4496
+ root: string().min(1)
4497
+ }),
4498
+ PluginSkillSourceSchema,
4499
+ strictObject({
4500
+ kind: literal("snapshot"),
4501
+ ref: string().min(1),
4502
+ digest: string().regex(/^[a-f0-9]{64}$/),
4503
+ origin: _enum(["native", "plugin"])
4504
+ })
4505
+ ]);
4506
+ var Budget = number().int().positive().max(Number.MAX_SAFE_INTEGER).optional().describe("Desired delivery tokens, default 8000 when omitted; the host may reserve fewer. A skill body must fit completely to count as loaded.");
4507
+ /** Ordered skill identifiers; physical collection limits are owner policy, never model declarations. */
4508
+ var ReadStart = strictObject({
4509
+ items: array(strictObject({
4510
+ id: string().min(1).max(200).describe("Exact available skill identifier from skill_search."),
4511
+ file: string().min(1).max(4096).optional().describe("Optional resource name relative to this skill root. Omit to load its complete main body.")
4512
+ })).min(1).max(64).describe("Ordered skill bodies or resources. All members share one delivery allowance."),
4513
+ outputTokens: Budget
4514
+ });
4515
+ var Continue$1 = strictObject({
4516
+ cursor: string().min(1).max(512).regex(/^[\x21-\x7e]+$/).describe("Opaque resource continuation; use alone without changing items."),
4517
+ outputTokens: Budget
4518
+ });
4519
+ /** Initial body/resource collections and opaque continuations are mutually exclusive. */
4520
+ var ReadSkillInput = union([ReadStart, Continue$1]);
4521
+ var ErrorBody = strictObject({
4522
+ code: string(),
4523
+ message: string().refine((value) => [...value].length <= 256).meta({ maxLength: 256 }),
4524
+ retryable: boolean()
4525
+ });
4526
+ /** Native skill read facts and bounded collection refusals. */
4527
+ var SkillReadOutputSchema = union([strictObject({
4528
+ ok: literal(true),
4529
+ complete: boolean(),
4530
+ next: strictObject({
4531
+ tool: literal("skill_read"),
4532
+ arguments: Continue$1
4533
+ }).nullable(),
4534
+ results: array(discriminatedUnion("ok", [strictObject({
4535
+ index: number().int().nonnegative(),
4536
+ target: string(),
4537
+ ok: literal(true),
4538
+ complete: boolean(),
4539
+ value: strictObject({
4540
+ body: LocalBodyRefSchema,
4541
+ startByte: number().int().nonnegative(),
4542
+ endByte: number().int().nonnegative(),
4543
+ source: SkillSourceSchema,
4544
+ kind: _enum(["body", "file"]),
4545
+ range: strictObject({
4546
+ offset: number().int().nonnegative(),
4547
+ bytes: number().int().nonnegative()
4548
+ }).optional()
4549
+ })
4550
+ }), strictObject({
4551
+ index: number().int().nonnegative(),
4552
+ target: string(),
4553
+ ok: literal(false),
4554
+ error: ErrorBody,
4555
+ next: strictObject({
4556
+ tool: literal("skill_read"),
4557
+ arguments: ReadSkillInput
4558
+ }).nullable()
4559
+ })])),
4560
+ effective: strictObject({ outputTokens: number().int().nonnegative() })
4561
+ }), strictObject({
4562
+ ok: literal(false),
4563
+ error: ErrorBody,
4564
+ next: strictObject({
4565
+ tool: literal("skill_read"),
4566
+ arguments: ReadSkillInput
4567
+ }).nullable()
4568
+ })]);
4569
+ //#endregion
4570
+ //#region src/search-data.ts
4571
+ /** Browser-safe skill discovery schemas. */
4572
+ var Tokens = number().int().positive().max(Number.MAX_SAFE_INTEGER).optional().describe("Desired delivery tokens; actual allocation may be smaller.");
4573
+ var Start = strictObject({
4574
+ query: string().refine((value) => [...value].length <= 256, "Query exceeds 256 code points").meta({ maxLength: 256 }).optional().describe("Case-insensitive literal substring in the skill id or description; maximum 256 Unicode code points. Omit to list."),
4575
+ limit: number().int().min(1).max(10).default(5).describe("Maximum discovery entries: default 5, hard maximum 10."),
4576
+ outputTokens: Tokens
4577
+ });
4578
+ var Continue = strictObject({
4579
+ cursor: string().min(1).max(512).regex(/^[\x21-\x7e]+$/).describe("Opaque server cursor. Copy next.arguments unchanged; cannot change the query."),
4580
+ outputTokens: Tokens
4581
+ });
4582
+ /** Initial metadata queries and opaque continuations are mutually exclusive. */
4583
+ var SkillSearchInput = union([Start, Continue]);
4584
+ var Item = strictObject({
4585
+ id: string(),
4586
+ description: string(),
4587
+ layer: _enum([
4588
+ "plugin",
4589
+ "global",
4590
+ "agent",
4591
+ "workspace",
4592
+ "snapshot"
4593
+ ]),
4594
+ source: PluginSkillSourceSchema.optional(),
4595
+ next: strictObject({
4596
+ tool: literal("skill_read"),
4597
+ arguments: strictObject({ items: array(strictObject({ id: string() })).length(1) })
4598
+ }).nullable()
4599
+ });
4600
+ /** Complete discovery members and bounded collection refusals. */
4601
+ var SkillSearchOutputSchema = union([strictObject({
4602
+ ok: literal(true),
4603
+ complete: boolean(),
4604
+ items: array(Item).max(10),
4605
+ next: strictObject({
4606
+ tool: literal("skill_search"),
4607
+ arguments: Continue
4608
+ }).nullable(),
4609
+ effective: strictObject({
4610
+ limit: number(),
4611
+ outputTokens: number()
4612
+ })
4613
+ }), strictObject({
4614
+ ok: literal(false),
4615
+ error: strictObject({
4616
+ code: string(),
4617
+ message: string().max(256),
4618
+ retryable: boolean()
4619
+ }),
4620
+ next: strictObject({
4621
+ tool: literal("skill_search"),
4622
+ arguments: SkillSearchInput
4623
+ }).nullable()
4624
+ })]);
4625
+ //#endregion
4483
4626
  //#region src/install/types.ts
4484
4627
  /**
4485
4628
  * The words installing is spoken in: where a package is (a source), what a
@@ -4515,6 +4658,10 @@ var SkillSource = discriminatedUnion("kind", [
4515
4658
  })
4516
4659
  ]);
4517
4660
  //#endregion
4661
+ //#region src/install/limits.ts
4662
+ /** Bytes one install source may download, and separately expand to, in total. */
4663
+ var SOURCE_BYTE_LIMIT = 209715200;
4664
+ //#endregion
4518
4665
  //#region src/contracts.ts
4519
4666
  /** Browser-safe schemas are the sole skill mutation wire declarations. */
4520
4667
  /** Describes one collection response without embedding host control metadata. */
@@ -4537,7 +4684,9 @@ function SkillBatch(value) {
4537
4684
  ok: literal(false),
4538
4685
  error: strictObject({
4539
4686
  code: string(),
4540
- message: string().max(512)
4687
+ message: string().max(512),
4688
+ /** Present when the member's operation certainly changed nothing. */
4689
+ confirmedNotCommitted: literal(true).optional()
4541
4690
  })
4542
4691
  })])).max(64) });
4543
4692
  }
@@ -4589,10 +4738,10 @@ var PreviewsParams = strictObject({
4589
4738
  items: array(strictObject({
4590
4739
  source: SkillSource,
4591
4740
  operationId: OperationId,
4592
- maxSourceBytes: number().int().min(1).max(20971520),
4741
+ maxSourceBytes: number().int().min(1).max(SOURCE_BYTE_LIMIT),
4593
4742
  maxItemBytes: number().int().min(1).max(262144)
4594
4743
  })).min(1).max(32),
4595
- maxTotalSourceBytes: number().int().min(1).max(20971520).default(20971520),
4744
+ maxTotalSourceBytes: number().int().min(1).max(SOURCE_BYTE_LIMIT).default(SOURCE_BYTE_LIMIT),
4596
4745
  maxTotalBytes: number().int().min(1).max(8388608).default(8388608)
4597
4746
  }).refine((input) => new Set(input.items.map((item) => item.operationId)).size === input.items.length, "duplicate operation identity");
4598
4747
  /** Preview response schema consumed directly by the owner browser. */
@@ -4617,7 +4766,9 @@ var InstallsResult = SkillBatch(strictObject({
4617
4766
  skipped: array(strictObject({ key: string() })),
4618
4767
  failed: array(strictObject({
4619
4768
  key: string(),
4620
- reason: string()
4769
+ reason: string(),
4770
+ /** Present when the pick was refused before any layer change. */
4771
+ confirmedNotCommitted: literal(true).optional()
4621
4772
  }))
4622
4773
  }));
4623
4774
  /** Independent normalization intents bind dryRun to their original operation identity. */
@@ -4722,9 +4873,350 @@ strictObject({
4722
4873
  id: string(),
4723
4874
  layer: Layer,
4724
4875
  reason: string()
4725
- }))
4876
+ })),
4877
+ /** Read-only plugin registrations visible to the Agent and how each resolves for it. */
4878
+ plugins: array(strictObject({
4879
+ id: string(),
4880
+ description: string().optional(),
4881
+ owner: string(),
4882
+ packageVersion: string(),
4883
+ digest: string(),
4884
+ registrationId: string(),
4885
+ /** `active` wins; `shadowed` loses the whole id to a native layer; `duplicate` and
4886
+ * `invalid` are unavailable with `reason`. */
4887
+ state: _enum([
4888
+ "active",
4889
+ "shadowed",
4890
+ "duplicate",
4891
+ "invalid"
4892
+ ]),
4893
+ shadowedBy: Layer.optional(),
4894
+ reason: string().optional()
4895
+ })).optional()
4726
4896
  });
4727
4897
  //#endregion
4898
+ //#region src/tool-data.ts
4899
+ /** Browser-safe native skill receipts and bounded failures. */
4900
+ /** A refused or failed skill operation with no embedded model document. */
4901
+ var SkillFailureSchema = strictObject({
4902
+ ok: literal(false),
4903
+ error: strictObject({
4904
+ code: string().min(1).max(128),
4905
+ message: string().max(512),
4906
+ retryable: boolean()
4907
+ }),
4908
+ next: _null()
4909
+ });
4910
+ /** Saved file outcomes preserve unchanged, committed and uncertain publication separately. */
4911
+ var SkillWriteDataSchema = union([
4912
+ strictObject({
4913
+ ok: literal(true),
4914
+ committed: boolean(),
4915
+ unchanged: boolean(),
4916
+ id: string(),
4917
+ layer: _enum([
4918
+ "global",
4919
+ "agent",
4920
+ "workspace"
4921
+ ]),
4922
+ cleanup: array(strictObject({
4923
+ code: string(),
4924
+ message: string()
4925
+ })).optional()
4926
+ }),
4927
+ strictObject({
4928
+ ok: literal(false),
4929
+ partial: literal(true),
4930
+ message: string().max(512),
4931
+ written: array(string()),
4932
+ uncertain: string().optional(),
4933
+ cleanup: array(strictObject({
4934
+ code: string(),
4935
+ message: string()
4936
+ })).optional()
4937
+ }),
4938
+ SkillFailureSchema
4939
+ ]);
4940
+ /** Saved own-Agent preload selection, captured from the actual committed revision. */
4941
+ var SkillPreloadDataSchema = union([strictObject({
4942
+ ok: literal(true),
4943
+ committed: literal(true),
4944
+ id: string(),
4945
+ ids: array(string()),
4946
+ revision: string()
4947
+ }), SkillFailureSchema]);
4948
+ /** Native installation collections retain each installed, skipped, failed and cleanup result. */
4949
+ var SkillInstallDataSchema = union([InstallsResult.extend({ notificationError: literal("change_notification_failed").optional() }), SkillFailureSchema]);
4950
+ /** Native removal collections preserve removed and already absent targets independently. */
4951
+ var SkillUninstallDataSchema = union([UninstallSkillsResult.extend({ notificationError: literal("change_notification_failed").optional() }), SkillFailureSchema]);
4952
+ //#endregion
4953
+ //#region src/ui/tool-summary.ts
4954
+ /** The fields of a `skill_validate` report this summary reads. */
4955
+ var ValidateReport = object({
4956
+ ok: literal(true),
4957
+ passed: boolean(),
4958
+ counts: object({ errors: number().int().nonnegative() })
4959
+ });
4960
+ /** The field of a `skill_publish` receipt this summary reads. */
4961
+ var PublishReceipt = object({ state: _enum([
4962
+ "committed",
4963
+ "unchanged",
4964
+ "refused",
4965
+ "unknown"
4966
+ ]) });
4967
+ var LAYERS = /* @__PURE__ */ new Set([
4968
+ "global",
4969
+ "agent",
4970
+ "workspace"
4971
+ ]);
4972
+ function record(value) {
4973
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
4974
+ }
4975
+ function items(input) {
4976
+ return Array.isArray(input.items) ? input.items.map(record) : [];
4977
+ }
4978
+ function strings(value) {
4979
+ return Array.isArray(value) ? value.filter((one) => typeof one === "string") : [];
4980
+ }
4981
+ function isContinuation(input) {
4982
+ return typeof input.cursor === "string" && input.cursor !== "";
4983
+ }
4984
+ /** The last `segments` `/`- or `\`-separated parts of a path, behind `…/` when it has more. */
4985
+ function pathTail(path, segments = 3) {
4986
+ const trimmed = path.replace(/[/\\]+$/, "");
4987
+ const parts = trimmed.split(/[/\\]+/).filter((part) => part !== "");
4988
+ if (parts.length <= segments) return trimmed === "" ? path : trimmed;
4989
+ return `…/${parts.slice(-segments).join("/")}`;
4990
+ }
4991
+ /** How a `skill_install` source reads in the transcript, or undefined for a malformed one. */
4992
+ function sourceText(value) {
4993
+ const source = record(value);
4994
+ const text = (key) => typeof source[key] === "string" ? source[key] : void 0;
4995
+ switch (source.kind) {
4996
+ case "clawhub": {
4997
+ const slug = text("slug");
4998
+ const owner = text("owner");
4999
+ return slug === void 0 ? void 0 : owner === void 0 ? slug : `${owner}/${slug}`;
5000
+ }
5001
+ case "tencent-skillhub": return text("slug");
5002
+ case "skills-sh": {
5003
+ const repo = text("repo");
5004
+ const skill = text("skill");
5005
+ return repo === void 0 || skill === void 0 ? void 0 : `${repo}/${skill}`;
5006
+ }
5007
+ case "github": return text("url");
5008
+ case "local": {
5009
+ const path = text("path");
5010
+ return path === void 0 ? void 0 : pathTail(path);
5011
+ }
5012
+ default: return;
5013
+ }
5014
+ }
5015
+ function layerText(value, t) {
5016
+ return typeof value === "string" && LAYERS.has(value) ? t(`summary.layer.${value}`) : void 0;
5017
+ }
5018
+ function failed(count, t) {
5019
+ return count > 0 ? {
5020
+ text: t("summary.failed", { count }),
5021
+ tone: "warning"
5022
+ } : void 0;
5023
+ }
5024
+ function readOutcome(data, t) {
5025
+ const parsed = SkillReadOutputSchema.safeParse(data);
5026
+ if (!parsed.success || !parsed.data.ok) return void 0;
5027
+ return failed(parsed.data.results.filter((one) => !one.ok).length, t);
5028
+ }
5029
+ function searchOutcome(data, t) {
5030
+ const parsed = SkillSearchOutputSchema.safeParse(data);
5031
+ if (!parsed.success || !parsed.data.ok) return void 0;
5032
+ return { text: t("summary.found", { count: parsed.data.items.length }) };
5033
+ }
5034
+ /** Counts failed sources and the failed picks inside sources that were read. */
5035
+ function installOutcome(data, t) {
5036
+ const parsed = SkillInstallDataSchema.safeParse(data);
5037
+ if (!parsed.success || !("results" in parsed.data)) return void 0;
5038
+ return failed(parsed.data.results.reduce((sum, one) => sum + (one.ok ? one.value.failed.length : 1), 0), t);
5039
+ }
5040
+ function uninstallOutcome(data, t) {
5041
+ const parsed = SkillUninstallDataSchema.safeParse(data);
5042
+ if (!parsed.success || !("results" in parsed.data)) return void 0;
5043
+ return failed(parsed.data.results.filter((one) => !one.ok).length, t);
5044
+ }
5045
+ function validateOutcome(data, t) {
5046
+ const parsed = ValidateReport.safeParse(data);
5047
+ if (!parsed.success) return void 0;
5048
+ if (parsed.data.passed) return { text: t("summary.passed") };
5049
+ return {
5050
+ text: t("summary.errors", { count: parsed.data.counts.errors }),
5051
+ tone: "warning"
5052
+ };
5053
+ }
5054
+ function publishOutcome(data, t) {
5055
+ const parsed = PublishReceipt.safeParse(data);
5056
+ if (!parsed.success) return void 0;
5057
+ const { state } = parsed.data;
5058
+ const text = t(`summary.state.${state}`);
5059
+ return state === "refused" || state === "unknown" ? {
5060
+ text,
5061
+ tone: "warning"
5062
+ } : { text };
5063
+ }
5064
+ /** The targets, detail and continuation a call's arguments give, before any result. */
5065
+ function argumentSummary(name, input, t) {
5066
+ const continued = isContinuation(input) ? { continuation: true } : {};
5067
+ switch (name) {
5068
+ case "skill_read": return {
5069
+ targets: items(input).flatMap(({ id, file }) => typeof id !== "string" ? [] : [typeof file === "string" ? `${id}/${file}` : id]),
5070
+ ...continued
5071
+ };
5072
+ case "skill_search": return {
5073
+ targets: typeof input.query === "string" ? [`"${input.query}"`] : [],
5074
+ ...continued
5075
+ };
5076
+ case "skill_write": {
5077
+ const detail = layerText(input.layer, t);
5078
+ return {
5079
+ targets: typeof input.id === "string" ? [input.id] : [],
5080
+ ...detail === void 0 ? {} : { detail }
5081
+ };
5082
+ }
5083
+ case "skill_install": {
5084
+ const groups = items(input);
5085
+ const count = groups.reduce((sum, group) => sum + (Array.isArray(group.picks) ? group.picks.length : 0), 0);
5086
+ return {
5087
+ targets: groups.flatMap(({ source }) => sourceText(source) ?? []),
5088
+ ...count > 0 ? { detail: t("summary.selected", { count }) } : {}
5089
+ };
5090
+ }
5091
+ case "skill_uninstall": return { targets: items(input).flatMap(({ id }) => typeof id === "string" ? [id] : []) };
5092
+ case "skill_set_preload": return { targets: strings(input.ids) };
5093
+ case "skill_validate": return {
5094
+ targets: typeof input.candidateRoot === "string" ? [pathTail(input.candidateRoot)] : [],
5095
+ ...continued
5096
+ };
5097
+ case "skill_publish": {
5098
+ if (typeof input.operationId === "string") return {
5099
+ targets: [input.operationId.slice(0, 8)],
5100
+ continuation: true
5101
+ };
5102
+ const target = record(input.target);
5103
+ const detail = layerText(target.layer, t);
5104
+ return {
5105
+ targets: typeof target.id === "string" ? [target.id] : [],
5106
+ ...detail === void 0 ? {} : { detail }
5107
+ };
5108
+ }
5109
+ default: return;
5110
+ }
5111
+ }
5112
+ var OUTCOMES = {
5113
+ skill_read: readOutcome,
5114
+ skill_search: searchOutcome,
5115
+ skill_install: installOutcome,
5116
+ skill_uninstall: uninstallOutcome,
5117
+ skill_validate: validateOutcome,
5118
+ skill_publish: publishOutcome
5119
+ };
5120
+ /**
5121
+ * The summary for a skill tool call, or undefined for a tool this owner does
5122
+ * not summarize. Targets and detail come from the arguments; the outcome
5123
+ * appears only once a result exists and its data matches the tool's output
5124
+ * shape. Malformed arguments or data yield fewer fields, never an error.
5125
+ */
5126
+ function skillSummary({ call, result }, t) {
5127
+ const summary = argumentSummary(call.name, record(call.input), t);
5128
+ if (summary === void 0 || result === void 0) return summary;
5129
+ const outcome = OUTCOMES[call.name]?.(result.data, t);
5130
+ return outcome === void 0 ? summary : {
5131
+ ...summary,
5132
+ outcome
5133
+ };
5134
+ }
5135
+ //#endregion
5136
+ //#region src/ui/metadata.ts
5137
+ var CATALOGUES = {
5138
+ "en-US": {
5139
+ section: "Built-in plugins",
5140
+ group: "Skills",
5141
+ skill_read: "Read skill",
5142
+ skill_search: "Find skills",
5143
+ skill_validate: "Validate skill",
5144
+ skill_publish: "Publish skill",
5145
+ skill_write: "Save skill",
5146
+ skill_install: "Install skill",
5147
+ skill_uninstall: "Uninstall skill",
5148
+ skill_set_preload: "Set preloaded skills",
5149
+ "summary.failed": "{{count}} failed",
5150
+ "summary.found": "{{count}} found",
5151
+ "summary.selected": "{{count}} selected",
5152
+ "summary.passed": "Passed",
5153
+ "summary.errors": "{{count}} errors",
5154
+ "summary.layer.global": "Global",
5155
+ "summary.layer.agent": "Agent",
5156
+ "summary.layer.workspace": "Workspace",
5157
+ "summary.state.committed": "Published",
5158
+ "summary.state.unchanged": "Unchanged",
5159
+ "summary.state.refused": "Refused",
5160
+ "summary.state.unknown": "Outcome unknown"
5161
+ },
5162
+ "zh-CN": {
5163
+ section: "内置插件",
5164
+ group: "技能",
5165
+ skill_read: "读取技能",
5166
+ skill_search: "查找技能",
5167
+ skill_validate: "验证技能",
5168
+ skill_publish: "发布技能",
5169
+ skill_write: "保存技能",
5170
+ skill_install: "安装技能",
5171
+ skill_uninstall: "卸载技能",
5172
+ skill_set_preload: "设置预加载技能",
5173
+ "summary.failed": "{{count}} 个失败",
5174
+ "summary.found": "找到 {{count}} 个",
5175
+ "summary.selected": "选中 {{count}} 个",
5176
+ "summary.passed": "通过",
5177
+ "summary.errors": "{{count}} 个错误",
5178
+ "summary.layer.global": "全局",
5179
+ "summary.layer.agent": "智能体",
5180
+ "summary.layer.workspace": "工作区",
5181
+ "summary.state.committed": "已发布",
5182
+ "summary.state.unchanged": "未变化",
5183
+ "summary.state.refused": "已拒绝",
5184
+ "summary.state.unknown": "结果未知"
5185
+ }
5186
+ };
5187
+ var names = new Set(TOOL_NAMES);
5188
+ /** Registers presentation facets with the same activation lifetime as the tools. */
5189
+ function registerMetadata(ctx) {
5190
+ ctx.i18n.register(CATALOGUES, "en-US");
5191
+ ctx.i18n.contribute(Object.fromEntries(Object.entries(CATALOGUES).map(([language, catalogue]) => [language, Object.fromEntries([...names].map((tool) => [`transcript.actions.${tool}`, catalogue[tool] ?? tool]))])), "en-US");
5192
+ ctx.slots.register("chat.tool.presentation", {
5193
+ id: "tool-metadata",
5194
+ describe: (props) => {
5195
+ if (!names.has(props.call.name)) return void 0;
5196
+ const summary = skillSummary(props, (key, options) => ctx.i18n.t(key, options));
5197
+ return {
5198
+ label: ctx.i18n.t(props.call.name),
5199
+ icon: "hammer",
5200
+ ...summary === void 0 ? {} : { summary }
5201
+ };
5202
+ }
5203
+ });
5204
+ ctx.slots.register("shell.tools.group", {
5205
+ id: "tool-groups",
5206
+ describe: (tool) => {
5207
+ if (tool.plugin !== ctx.plugin) return void 0;
5208
+ return {
5209
+ key: `plugin:${ctx.plugin}`,
5210
+ label: ctx.i18n.t("group"),
5211
+ source: ctx.plugin,
5212
+ sectionLabel: ctx.i18n.t("section"),
5213
+ sectionOrder: 1,
5214
+ order: 3
5215
+ };
5216
+ }
5217
+ });
5218
+ }
5219
+ //#endregion
4728
5220
  //#region src/ui/collections.ts
4729
5221
  var pending = /* @__PURE__ */ new WeakMap();
4730
5222
  async function invoke(ctx, method, params, schema, targets) {
@@ -4842,11 +5334,6 @@ function failureText(_ctx, error) {
4842
5334
  if (failure === "offline" || failure === "authentication") return null;
4843
5335
  return (error instanceof Error ? error.message : String(error)).replace(/^plugin "[^"]+" failed in \w+: /, "");
4844
5336
  }
4845
- function formatBytes(bytes) {
4846
- if (bytes < 1024) return `${bytes} B`;
4847
- if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
4848
- return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
4849
- }
4850
5337
  /** Captures one view and connection lifetime for asynchronous UI completions. */
4851
5338
  function useViewScope(ctx, identity) {
4852
5339
  const live = useRef(true);
@@ -4879,6 +5366,8 @@ function useViewScope(ctx, identity) {
4879
5366
  }
4880
5367
  //#endregion
4881
5368
  //#region src/ui/confirm.tsx
5369
+ /** The most items one `uninstallSkills` collection accepts (`UninstallSkillsParams`). */
5370
+ var UNINSTALL_CHUNK = 64;
4882
5371
  function UninstallDialog({ ctx, agentId, skill, preloaded, onClose, onDone }) {
4883
5372
  const t = ctx.i18n.t;
4884
5373
  const ui = ctx.ui;
@@ -5108,16 +5597,20 @@ function BulkUninstallDialog({ ctx, agentId, skills, onClose, onDone }) {
5108
5597
  const current = capture();
5109
5598
  const failed = [];
5110
5599
  const messages = [];
5600
+ let settled = 0;
5111
5601
  try {
5112
- const answer = await uninstallSkills(ctx, agentId, remaining.map(({ layer, id }) => ({
5113
- layer,
5114
- id
5115
- })));
5116
- for (const member of answer.results) if (!member.ok) {
5117
- const skill = remaining[member.index];
5118
- if (skill) {
5119
- failed.push(skill);
5120
- messages.push(`${skill.id}: ${member.error.message}`);
5602
+ for (; settled < remaining.length; settled += UNINSTALL_CHUNK) {
5603
+ const chunk = remaining.slice(settled, settled + UNINSTALL_CHUNK);
5604
+ const answer = await uninstallSkills(ctx, agentId, chunk.map(({ layer, id }) => ({
5605
+ layer,
5606
+ id
5607
+ })));
5608
+ for (const member of answer.results) if (!member.ok) {
5609
+ const skill = chunk[member.index];
5610
+ if (skill) {
5611
+ failed.push(skill);
5612
+ messages.push(`${skill.id}: ${member.error.message}`);
5613
+ }
5121
5614
  }
5122
5615
  }
5123
5616
  if (!current()) return;
@@ -5126,8 +5619,12 @@ function BulkUninstallDialog({ ctx, agentId, skills, onClose, onDone }) {
5126
5619
  onDone();
5127
5620
  if (failed.length === 0) onClose();
5128
5621
  } catch (error) {
5622
+ if (settled > 0 && current()) {
5623
+ setRemaining([...failed, ...remaining.slice(settled)]);
5624
+ onDone();
5625
+ }
5129
5626
  const reason = failureText(ctx, error);
5130
- if (reason !== null) setFailures([reason]);
5627
+ if (reason !== null) setFailures([...messages, reason]);
5131
5628
  } finally {
5132
5629
  if (current()) {
5133
5630
  running.current = false;
@@ -5196,6 +5693,7 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5196
5693
  const [preview, setPreview] = useState(null);
5197
5694
  const [picked, setPicked] = useState(/* @__PURE__ */ new Set());
5198
5695
  const [ids, setIds] = useState(/* @__PURE__ */ new Map());
5696
+ const [editing, setEditing] = useState(null);
5199
5697
  const [correction, setCorrection] = useState(null);
5200
5698
  const [busy, setBusy] = useState(null);
5201
5699
  const [failure, setFailure] = useState(null);
@@ -5219,7 +5717,7 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5219
5717
  if (!intent) {
5220
5718
  intent = {
5221
5719
  operationId: ctx.uuid(),
5222
- maxSourceBytes: Math.floor(20971520 / count),
5720
+ maxSourceBytes: Math.floor(SOURCE_BYTE_LIMIT / count),
5223
5721
  maxItemBytes: Math.min(262144, Math.floor(8380416 / count))
5224
5722
  };
5225
5723
  previewIntents.current.set(key, intent);
@@ -5249,6 +5747,7 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5249
5747
  setPreview(null);
5250
5748
  setPicked(/* @__PURE__ */ new Set());
5251
5749
  setIds(/* @__PURE__ */ new Map());
5750
+ setEditing(null);
5252
5751
  setCorrection(null);
5253
5752
  setSelected(/* @__PURE__ */ new Map());
5254
5753
  setResults([]);
@@ -5364,7 +5863,13 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5364
5863
  agentId,
5365
5864
  source: job.source
5366
5865
  }));
5367
- } else views.set(job.key, new Error(member.error.message));
5866
+ } else {
5867
+ if (member.error.confirmedNotCommitted) previewIntents.current.delete(JSON.stringify({
5868
+ agentId,
5869
+ source: job.source
5870
+ }));
5871
+ views.set(job.key, new Error(member.error.message));
5872
+ }
5368
5873
  });
5369
5874
  if (!alive.current || !current() || token !== generation.current) return;
5370
5875
  if (jobs.reduce((sum, job) => {
@@ -5566,8 +6071,11 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5566
6071
  if (current()) setBusy(null);
5567
6072
  }
5568
6073
  }
5569
- const visible = results.filter((item) => !item.needsLogin);
5570
- const all = from === "registry" && correction === null ? visible.length > 0 && visible.every((item) => selected.has(sourceKey(item))) : available.length > 0 && available.every((item) => picked.has(item.key));
6074
+ const commitId = () => {
6075
+ if (!editing || !isStandardName(editing.draft)) return;
6076
+ setIds((current) => new Map(current).set(editing.key, editing.draft));
6077
+ setEditing(null);
6078
+ };
5571
6079
  const row = (label, content) => /* @__PURE__ */ jsxs("div", {
5572
6080
  className: "skl-install-field",
5573
6081
  children: [/* @__PURE__ */ jsx("span", {
@@ -5680,18 +6188,18 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5680
6188
  })]
5681
6189
  })),
5682
6190
  from === "local" && row(t("install.from.local"), /* @__PURE__ */ jsxs("div", {
5683
- className: "skl-local-buttons",
5684
- children: [["directory", "file"].map((mode) => /* @__PURE__ */ jsx(ui.PathInput, {
6191
+ className: "skl-local-picker",
6192
+ children: [/* @__PURE__ */ jsx(ui.PathInput, {
5685
6193
  buttonOnly: true,
5686
- browseLabel: t(mode === "directory" ? "install.chooseDirectory" : "install.chooseArchive"),
5687
- title: t(mode === "directory" ? "install.chooseDirectory" : "install.chooseArchive"),
5688
- mode,
6194
+ browseLabel: t("install.chooseLocal"),
6195
+ title: t("install.chooseLocal"),
6196
+ mode: "any",
5689
6197
  value: path,
5690
6198
  disabled: locked,
5691
- filters: mode === "file" ? [{
6199
+ filters: [{
5692
6200
  label: "ZIP",
5693
6201
  extensions: ["zip"]
5694
- }] : void 0,
6202
+ }],
5695
6203
  onValueChange: (value) => {
5696
6204
  setPath(value);
5697
6205
  load({
@@ -5699,7 +6207,7 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5699
6207
  path: value
5700
6208
  });
5701
6209
  }
5702
- }, mode)), path && /* @__PURE__ */ jsx("span", {
6210
+ }), path && /* @__PURE__ */ jsx("span", {
5703
6211
  className: "skl-muted skl-local-path",
5704
6212
  title: path,
5705
6213
  children: path
@@ -5708,32 +6216,10 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5708
6216
  ]
5709
6217
  }),
5710
6218
  /* @__PURE__ */ jsxs("section", {
5711
- className: "skl-install-scroll",
5712
- tabIndex: 0,
6219
+ className: "skl-install-list",
5713
6220
  "aria-label": t("install.list"),
5714
6221
  "aria-busy": reading,
5715
6222
  children: [
5716
- /* @__PURE__ */ jsxs("div", {
5717
- className: "skl-results-heading",
5718
- children: [/* @__PURE__ */ jsxs("strong", { children: [t("install.list"), reading ? "" : from === "registry" ? ` · ${results.length}` : preview ? ` · ${preview.candidates.length}` : ""] }), /* @__PURE__ */ jsxs("label", {
5719
- className: "skl-select-all",
5720
- children: [/* @__PURE__ */ jsx(ui.Checkbox, {
5721
- "aria-label": t("install.selectAll"),
5722
- disabled: busy !== null || (from === "registry" && correction === null ? visible.length === 0 : available.length === 0),
5723
- checked: all,
5724
- onChange: (event) => {
5725
- const checked = event.currentTarget.checked;
5726
- if (from === "registry" && correction === null) setSelected((current) => {
5727
- const next = new Map(current);
5728
- for (const item of visible) if (checked) next.set(sourceKey(item), item);
5729
- else next.delete(sourceKey(item));
5730
- return next;
5731
- });
5732
- else setPicked(new Set(checked ? available.map((item) => item.key) : []));
5733
- }
5734
- }), t("install.selectAll")]
5735
- })]
5736
- }),
5737
6223
  failure && /* @__PURE__ */ jsx("p", {
5738
6224
  role: "alert",
5739
6225
  className: "skl-error skl-install-error",
@@ -5745,21 +6231,15 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5745
6231
  children: notice
5746
6232
  }),
5747
6233
  from === "registry" && correction === null && /* @__PURE__ */ jsx("div", {
6234
+ className: "skl-install-results",
5748
6235
  "data-slot": "install-results",
5749
6236
  children: /* @__PURE__ */ jsx(ui.DataTable, {
6237
+ fill: true,
5750
6238
  ariaLabel: t("install.list"),
5751
6239
  items: results,
5752
6240
  loading: busy === "search",
5753
6241
  keyOf: sourceKey,
5754
6242
  labelOf: (result) => result.name,
5755
- pagination: {
5756
- pageSize: 10,
5757
- pageSizeOptions: [
5758
- 10,
5759
- 20,
5760
- 50
5761
- ]
5762
- },
5763
6243
  selection: {
5764
6244
  keys: new Set(selected.keys()),
5765
6245
  disabled: locked,
@@ -5817,20 +6297,13 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5817
6297
  })
5818
6298
  }),
5819
6299
  (from !== "registry" || correction !== null) && /* @__PURE__ */ jsx(ui.DataTable, {
6300
+ fill: true,
5820
6301
  ariaLabel: t("install.list"),
5821
6302
  items: preview?.candidates ?? [],
5822
6303
  loading: busy === "fetch",
5823
6304
  keyOf: (item) => item.key,
5824
6305
  labelOf: (item) => idOf(item.key, item.suggestedId) || item.key,
5825
6306
  searchOf: (item) => `${item.key} ${idOf(item.key, item.suggestedId)} ${item.description}`,
5826
- pagination: {
5827
- pageSize: 10,
5828
- pageSizeOptions: [
5829
- 10,
5830
- 20,
5831
- 50
5832
- ]
5833
- },
5834
6307
  selection: {
5835
6308
  keys: new Set(available.filter((item) => picked.has(item.key)).map((item) => item.key)),
5836
6309
  disabled: locked,
@@ -5847,60 +6320,69 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5847
6320
  render: (item) => {
5848
6321
  const id = idOf(item.key, item.suggestedId);
5849
6322
  const taken = (preview?.taken[layer] ?? []).includes(id);
6323
+ const draft = editing?.key === item.key ? editing.draft : null;
6324
+ const shown = draft ?? id;
5850
6325
  return /* @__PURE__ */ jsxs("span", {
5851
6326
  className: "skl-grow",
5852
6327
  "data-slot": "install-candidate",
5853
6328
  "data-disabled": taken,
5854
6329
  children: [
5855
- /* @__PURE__ */ jsx("strong", { children: id || item.key }),
5856
- /* @__PURE__ */ jsx("span", {
5857
- className: "skl-description",
5858
- children: item.description
5859
- }),
5860
- /* @__PURE__ */ jsxs("span", {
5861
- className: "skl-muted",
5862
- children: [
5863
- item.key,
5864
- " ·",
5865
- " ",
5866
- fill(t("install.files"), {
5867
- count: item.files.length,
5868
- size: formatBytes(item.bytes)
5869
- })
5870
- ]
5871
- }),
5872
- taken && /* @__PURE__ */ jsx(ui.Badge, {
5873
- size: "sm",
5874
- children: t("install.installed")
5875
- })
5876
- ]
5877
- });
5878
- }
5879
- }, {
5880
- id: "id",
5881
- label: t("install.id"),
5882
- render: (item) => {
5883
- const id = idOf(item.key, item.suggestedId);
5884
- return /* @__PURE__ */ jsxs("div", {
5885
- className: "skl-id-editor",
5886
- children: [
5887
- /* @__PURE__ */ jsx("span", {
5888
- className: "skl-muted",
5889
- children: t("install.id")
6330
+ draft === null ? /* @__PURE__ */ jsxs("span", {
6331
+ className: "skl-id-line",
6332
+ children: [/* @__PURE__ */ jsx("strong", { children: id || item.key }), /* @__PURE__ */ jsx(ui.Button, {
6333
+ size: "sm",
6334
+ variant: "ghost",
6335
+ className: "skl-icon-action",
6336
+ "aria-label": t("install.editId"),
6337
+ title: t("install.editId"),
6338
+ disabled: locked,
6339
+ onClick: () => setEditing({
6340
+ key: item.key,
6341
+ draft: id
6342
+ }),
6343
+ children: /* @__PURE__ */ jsx(ui.Icon, { name: "square-pen" })
6344
+ })]
6345
+ }) : /* @__PURE__ */ jsxs("form", {
6346
+ className: "skl-id-line",
6347
+ onSubmit: (event) => {
6348
+ event.preventDefault();
6349
+ commitId();
6350
+ },
6351
+ children: [/* @__PURE__ */ jsx(ui.Input, {
6352
+ autoFocus: true,
6353
+ size: "sm",
6354
+ "aria-label": t("install.id"),
6355
+ "aria-invalid": !isStandardName(draft),
6356
+ maxLength: 64,
6357
+ disabled: locked,
6358
+ value: draft,
6359
+ onChange: (event) => setEditing({
6360
+ key: item.key,
6361
+ draft: event.currentTarget.value
6362
+ }),
6363
+ onKeyDown: (event) => {
6364
+ if (event.key !== "Escape") return;
6365
+ event.stopPropagation();
6366
+ setEditing(null);
6367
+ }
6368
+ }), /* @__PURE__ */ jsx(ui.Button, {
6369
+ type: "submit",
6370
+ size: "sm",
6371
+ variant: "ghost",
6372
+ className: "skl-icon-action",
6373
+ "aria-label": t("install.confirmId"),
6374
+ title: t("install.confirmId"),
6375
+ disabled: locked || !isStandardName(draft),
6376
+ children: /* @__PURE__ */ jsx(ui.Icon, { name: "check" })
6377
+ })]
5890
6378
  }),
5891
- /* @__PURE__ */ jsx(ui.Input, {
5892
- "aria-label": t("install.id"),
5893
- maxLength: 64,
5894
- disabled: locked,
5895
- value: id,
5896
- onChange: (event) => {
5897
- const nextId = event.currentTarget.value;
5898
- setIds((current) => new Map(current).set(item.key, nextId));
5899
- }
5900
- }),
5901
- !isStandardName(id) && /* @__PURE__ */ jsx("span", {
6379
+ !isStandardName(shown) && /* @__PURE__ */ jsx("span", {
5902
6380
  className: "skl-error",
5903
6381
  children: t("install.idInvalid")
6382
+ }),
6383
+ /* @__PURE__ */ jsx("span", {
6384
+ className: "skl-description",
6385
+ children: item.description
5904
6386
  })
5905
6387
  ]
5906
6388
  });
@@ -5949,6 +6431,7 @@ function InstallDialog({ ctx, agentId, onClose, onInstalled }) {
5949
6431
  }
5950
6432
  //#endregion
5951
6433
  //#region src/ui/skills-tab.tsx
6434
+ var pluginLabel = (plugin) => `${plugin.owner} · ${plugin.packageVersion}`;
5952
6435
  function originText(ctx, origin) {
5953
6436
  const t = ctx.i18n.t;
5954
6437
  switch (origin.kind) {
@@ -6060,7 +6543,20 @@ function skillsTabFor(ctx) {
6060
6543
  const without = (preloaded ?? []).filter((one) => one !== id);
6061
6544
  save(on ? [...without, id] : without);
6062
6545
  };
6063
- const skills = [...catalog?.skills ?? []].sort((a, b) => Number(a.layer === "agent") - Number(b.layer === "agent") || a.id.localeCompare(b.id));
6546
+ const plugins = catalog?.plugins ?? [];
6547
+ const nativeSkills = [...catalog?.skills ?? []].sort((a, b) => Number(a.layer === "agent") - Number(b.layer === "agent") || a.id.localeCompare(b.id));
6548
+ const skills = [...plugins.filter((plugin) => plugin.state === "active").map((plugin) => ({
6549
+ id: plugin.id,
6550
+ description: plugin.description ?? "",
6551
+ plugin,
6552
+ overrides: []
6553
+ })), ...nativeSkills.map((skill) => ({
6554
+ id: skill.id,
6555
+ description: skill.description,
6556
+ skill,
6557
+ overrides: plugins.filter((one) => one.state === "shadowed" && one.id === skill.id)
6558
+ }))].sort((a, b) => Number(a.skill?.layer === "agent") - Number(b.skill?.layer === "agent") || a.id.localeCompare(b.id));
6559
+ const unavailable = plugins.filter((one) => one.state === "duplicate" || one.state === "invalid");
6064
6560
  const known = new Set(skills.map((one) => one.id));
6065
6561
  const missing = catalog && preloaded ? preloaded.filter((id) => !known.has(id)) : [];
6066
6562
  const changeEnabled = (enabled) => {
@@ -6147,7 +6643,7 @@ function skillsTabFor(ctx) {
6147
6643
  items: skills,
6148
6644
  keyOf: (skill) => skill.id,
6149
6645
  labelOf: (skill) => skill.id,
6150
- searchOf: (skill) => `${skill.id} ${skill.description} ${skill.origin === void 0 ? "" : originText(ctx, skill.origin)}`,
6646
+ searchOf: (row) => `${row.id} ${row.description} ${row.skill?.origin === void 0 ? "" : originText(ctx, row.skill.origin)} ${row.plugin ? pluginLabel(row.plugin) : ""}`,
6151
6647
  toolbar: /* @__PURE__ */ jsx(ui.Tooltip, {
6152
6648
  content: t("skills.resetDefaultsHint"),
6153
6649
  children: /* @__PURE__ */ jsx(ui.Button, {
@@ -6163,24 +6659,46 @@ function skillsTabFor(ctx) {
6163
6659
  columns: [{
6164
6660
  id: "skill",
6165
6661
  label: t("skills.column.skill"),
6166
- render: (skill) => /* @__PURE__ */ jsxs("div", {
6662
+ render: (row) => /* @__PURE__ */ jsxs("div", {
6167
6663
  className: "skl-skill-cell",
6168
6664
  children: [/* @__PURE__ */ jsxs("div", {
6169
6665
  className: "skl-skill-heading",
6170
6666
  children: [
6171
6667
  /* @__PURE__ */ jsx("span", {
6172
6668
  className: "skl-skill-name",
6173
- title: skill.id,
6174
- children: skill.id
6669
+ title: row.id,
6670
+ children: row.id
6175
6671
  }),
6176
- skill.origin !== void 0 && skill.origin.kind !== "local" && /* @__PURE__ */ jsx("span", {
6672
+ row.plugin && /* @__PURE__ */ jsx(ui.Tooltip, {
6673
+ content: pluginLabel(row.plugin),
6674
+ children: /* @__PURE__ */ jsx("button", {
6675
+ type: "button",
6676
+ className: "skl-skill-plugin",
6677
+ children: /* @__PURE__ */ jsx(ui.Badge, {
6678
+ size: "sm",
6679
+ "data-slot": "skill-plugin",
6680
+ children: row.plugin.owner
6681
+ })
6682
+ })
6683
+ }),
6684
+ row.overrides.map((plugin) => /* @__PURE__ */ jsx(ui.Tooltip, {
6685
+ content: t("skills.overridesHint"),
6686
+ children: /* @__PURE__ */ jsx("button", {
6687
+ type: "button",
6688
+ "data-slot": "skill-overrides",
6689
+ className: "skl-skill-managed",
6690
+ title: fill(t("skills.overrides"), { source: pluginLabel(plugin) }),
6691
+ children: fill(t("skills.overrides"), { source: pluginLabel(plugin) })
6692
+ })
6693
+ }, plugin.registrationId)),
6694
+ row.skill?.origin !== void 0 && row.skill.origin.kind !== "local" && /* @__PURE__ */ jsx("span", {
6177
6695
  className: "skl-skill-origin",
6178
6696
  "data-slot": "skill-origin",
6179
- title: originText(ctx, skill.origin),
6180
- children: originText(ctx, skill.origin)
6697
+ title: originText(ctx, row.skill.origin),
6698
+ children: originText(ctx, row.skill.origin)
6181
6699
  }),
6182
- skill.issues.length > 0 && /* @__PURE__ */ jsx(ui.Tooltip, {
6183
- content: skill.issues.map((issue) => issueText(ctx, issue)).join("\n"),
6700
+ row.skill && row.skill.issues.length > 0 && /* @__PURE__ */ jsx(ui.Tooltip, {
6701
+ content: row.skill.issues.map((issue) => issueText(ctx, issue)).join("\n"),
6184
6702
  children: /* @__PURE__ */ jsx("button", {
6185
6703
  type: "button",
6186
6704
  "data-slot": "skill-nonstandard",
@@ -6205,16 +6723,16 @@ function skillsTabFor(ctx) {
6205
6723
  })
6206
6724
  })
6207
6725
  ]
6208
- }), skill.description && /* @__PURE__ */ jsx(ui.Tooltip, {
6726
+ }), row.description && /* @__PURE__ */ jsx(ui.Tooltip, {
6209
6727
  content: /* @__PURE__ */ jsx("span", {
6210
6728
  className: "skl-description-detail",
6211
- children: skill.description
6729
+ children: row.description
6212
6730
  }),
6213
6731
  side: "bottom",
6214
6732
  children: /* @__PURE__ */ jsx("button", {
6215
6733
  type: "button",
6216
6734
  className: "skl-skill-description",
6217
- children: skill.description
6735
+ children: row.description
6218
6736
  })
6219
6737
  })]
6220
6738
  })
@@ -6225,24 +6743,24 @@ function skillsTabFor(ctx) {
6225
6743
  onChange: changeEnabled,
6226
6744
  disabled: preloaded === null || saving
6227
6745
  },
6228
- rowActions: (skill) => /* @__PURE__ */ jsxs("div", {
6746
+ rowActions: ({ id, skill }) => /* @__PURE__ */ jsxs("div", {
6229
6747
  className: "skl-skill-actions",
6230
6748
  children: [
6231
6749
  /* @__PURE__ */ jsx(ui.Tooltip, {
6232
- content: t(disabledSkills.includes(skill.id) ? "skills.preloadDisabled" : preloaded?.includes(skill.id) ? "skills.preloadOn" : "skills.preloadOff"),
6750
+ content: t(disabledSkills.includes(id) ? "skills.preloadDisabled" : preloaded?.includes(id) ? "skills.preloadOn" : "skills.preloadOff"),
6233
6751
  children: /* @__PURE__ */ jsx(ui.Button, {
6234
6752
  size: "sm",
6235
6753
  variant: "ghost",
6236
6754
  className: "skl-preload",
6237
- "aria-label": fill(t("skills.preload"), { id: skill.id }),
6238
- "aria-pressed": preloaded?.includes(skill.id) === true,
6239
- disabled: preloaded === null || saving || disabledSkills.includes(skill.id),
6240
- onClick: () => toggle(skill.id, !preloaded?.includes(skill.id)),
6755
+ "aria-label": fill(t("skills.preload"), { id }),
6756
+ "aria-pressed": preloaded?.includes(id) === true,
6757
+ disabled: preloaded === null || saving || disabledSkills.includes(id),
6758
+ onClick: () => toggle(id, !preloaded?.includes(id)),
6241
6759
  children: /* @__PURE__ */ jsx("svg", {
6242
6760
  viewBox: "0 0 24 24",
6243
6761
  width: "16",
6244
6762
  height: "16",
6245
- fill: preloaded?.includes(skill.id) ? "currentColor" : "none",
6763
+ fill: preloaded?.includes(id) ? "currentColor" : "none",
6246
6764
  stroke: "currentColor",
6247
6765
  strokeWidth: "1.6",
6248
6766
  strokeLinejoin: "round",
@@ -6251,7 +6769,7 @@ function skillsTabFor(ctx) {
6251
6769
  })
6252
6770
  })
6253
6771
  }),
6254
- skill.issues.length > 0 && /* @__PURE__ */ jsx(ui.Tooltip, {
6772
+ skill && skill.issues.length > 0 && /* @__PURE__ */ jsx(ui.Tooltip, {
6255
6773
  content: t("skills.normalize"),
6256
6774
  children: /* @__PURE__ */ jsx(ui.Button, {
6257
6775
  size: "sm",
@@ -6262,7 +6780,7 @@ function skillsTabFor(ctx) {
6262
6780
  onClick: () => setNormalizing(skill)
6263
6781
  })
6264
6782
  }),
6265
- /* @__PURE__ */ jsx(ui.Tooltip, {
6783
+ skill && /* @__PURE__ */ jsx(ui.Tooltip, {
6266
6784
  content: t("skills.uninstall"),
6267
6785
  children: /* @__PURE__ */ jsx(ui.Button, {
6268
6786
  size: "sm",
@@ -6281,7 +6799,7 @@ function skillsTabFor(ctx) {
6281
6799
  title: t("skills.empty"),
6282
6800
  description: t("skills.emptyHint")
6283
6801
  }),
6284
- className: skills.some((skill) => skill.issues.length > 0) ? "skl-skill-table skl-skill-table-with-issues" : "skl-skill-table"
6802
+ className: skills.some((row) => (row.skill?.issues.length ?? 0) > 0) ? "skl-skill-table skl-skill-table-with-issues" : "skl-skill-table"
6285
6803
  }, `${agentId}:${catalog === null ? "loading" : "ready"}`),
6286
6804
  missing.length > 0 && /* @__PURE__ */ jsxs("section", {
6287
6805
  "aria-label": t("skills.missing"),
@@ -6308,13 +6826,13 @@ function skillsTabFor(ctx) {
6308
6826
  }, id))
6309
6827
  })]
6310
6828
  }),
6311
- catalog && catalog.failed.length > 0 && /* @__PURE__ */ jsxs("section", {
6829
+ catalog && (catalog.failed.length > 0 || unavailable.length > 0) && /* @__PURE__ */ jsxs("section", {
6312
6830
  "aria-label": t("skills.failed"),
6313
6831
  "data-slot": "skill-failed",
6314
6832
  className: "skl-section",
6315
- children: [/* @__PURE__ */ jsx("h4", { children: t("skills.failed") }), /* @__PURE__ */ jsx("ul", {
6833
+ children: [/* @__PURE__ */ jsx("h4", { children: t("skills.failed") }), /* @__PURE__ */ jsxs("ul", {
6316
6834
  className: "skl-list",
6317
- children: catalog.failed.map((one) => /* @__PURE__ */ jsxs("li", {
6835
+ children: [catalog.failed.map((one) => /* @__PURE__ */ jsxs("li", {
6318
6836
  className: "skl-row skl-column",
6319
6837
  children: [/* @__PURE__ */ jsxs("span", {
6320
6838
  className: "skl-line",
@@ -6329,11 +6847,33 @@ function skillsTabFor(ctx) {
6329
6847
  className: "skl-error",
6330
6848
  children: one.reason
6331
6849
  })]
6332
- }, `${one.layer}:${one.id}`))
6850
+ }, `${one.layer}:${one.id}`)), unavailable.map((one) => /* @__PURE__ */ jsxs("li", {
6851
+ className: "skl-row skl-column",
6852
+ children: [/* @__PURE__ */ jsxs("span", {
6853
+ className: "skl-line",
6854
+ children: [
6855
+ /* @__PURE__ */ jsx("span", {
6856
+ className: "skl-mono",
6857
+ children: one.id
6858
+ }),
6859
+ /* @__PURE__ */ jsx(ui.Badge, {
6860
+ size: "sm",
6861
+ children: t("skills.layer.plugin")
6862
+ }),
6863
+ /* @__PURE__ */ jsx("span", {
6864
+ className: "skl-muted",
6865
+ children: pluginLabel(one)
6866
+ })
6867
+ ]
6868
+ }), /* @__PURE__ */ jsx("span", {
6869
+ className: "skl-error",
6870
+ children: fill(t(one.state === "duplicate" ? "skills.plugin.duplicate" : "skills.plugin.invalid"), { detail: one.reason ?? "" })
6871
+ })]
6872
+ }, one.registrationId))]
6333
6873
  })]
6334
6874
  })
6335
6875
  ]
6336
- }), skills.length > 0 && /* @__PURE__ */ jsx("fieldset", {
6876
+ }), nativeSkills.length > 0 && /* @__PURE__ */ jsx("fieldset", {
6337
6877
  className: "skl-bulk-actions",
6338
6878
  "aria-label": t("skills.bulkActions"),
6339
6879
  children: /* @__PURE__ */ jsx(ui.Button, {
@@ -6342,7 +6882,7 @@ function skillsTabFor(ctx) {
6342
6882
  icon: "trash",
6343
6883
  className: "skl-delete-all",
6344
6884
  disabled: saving,
6345
- onClick: () => setBulkUninstalling([...skills]),
6885
+ onClick: () => setBulkUninstalling([...nativeSkills]),
6346
6886
  children: t("skills.deleteAll")
6347
6887
  })
6348
6888
  })]
@@ -6380,6 +6920,639 @@ function skillsTabFor(ctx) {
6380
6920
  };
6381
6921
  }
6382
6922
  //#endregion
6923
+ //#region src/ui/saved-body.tsx
6924
+ function scopeOf(ref) {
6925
+ const source = ref.source;
6926
+ switch (source.kind) {
6927
+ case "history": return {
6928
+ kind: source.kind,
6929
+ sessionId: source.sessionId,
6930
+ historyGeneration: source.historyGeneration
6931
+ };
6932
+ case "operation": return {
6933
+ kind: source.kind,
6934
+ sessionId: source.sessionId,
6935
+ operationId: source.operationId
6936
+ };
6937
+ case "summary": return {
6938
+ kind: source.kind,
6939
+ sessionId: source.sessionId,
6940
+ metadataEpoch: source.metadataEpoch
6941
+ };
6942
+ case "live": return {
6943
+ kind: source.kind,
6944
+ sessionId: source.sessionId,
6945
+ processEpoch: source.processEpoch,
6946
+ liveEpoch: source.liveEpoch,
6947
+ ...source.streamEpoch ? { streamEpoch: source.streamEpoch } : {}
6948
+ };
6949
+ }
6950
+ }
6951
+ /** Source and body identity depend on scalar values, never JSON insertion order. */
6952
+ function referenceIdentity(ref) {
6953
+ const ordered = (value) => Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
6954
+ return JSON.stringify([ordered(ref.body), ordered(ref.source)]);
6955
+ }
6956
+ async function readVerifiedRange(ctx, ref, offset, maxBytes, signal) {
6957
+ signal.throwIfAborted();
6958
+ const response = await ctx.call("session.messageContents", {
6959
+ scope: scopeOf(ref),
6960
+ items: [{
6961
+ ref,
6962
+ offset,
6963
+ maxBytes
6964
+ }],
6965
+ maxTotalBytes: maxBytes
6966
+ }, { signal });
6967
+ signal.throwIfAborted();
6968
+ const member = response.results[0];
6969
+ if (!member || member.index !== 0) throw new Error("Saved source response is incomplete.");
6970
+ if (!member.ok) throw new Error(member.error.message);
6971
+ const value = member.value;
6972
+ if (referenceIdentity(value.ref) !== referenceIdentity(ref) || value.offset !== offset || value.bodySha256 !== ref.body.sha256 || value.nextOffset < offset || value.nextOffset > ref.body.byteLength || value.nextOffset - offset > maxBytes || value.complete !== (value.nextOffset === ref.body.byteLength) || value.nextOffset === offset && offset < ref.body.byteLength) throw new Error("Saved source identity changed. Reopen this result.");
6973
+ if (value.base64.length > Math.ceil(maxBytes / 3) * 4) throw new Error("Saved source byte range is invalid.");
6974
+ const bytes = Uint8Array.from(atob(value.base64), (character) => character.charCodeAt(0));
6975
+ if (bytes.byteLength !== value.nextOffset - offset || bytes.byteLength > maxBytes) throw new Error("Saved source byte range is invalid.");
6976
+ const digest = await crypto.subtle.digest("SHA-256", bytes);
6977
+ const hash = [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
6978
+ signal.throwIfAborted();
6979
+ if (hash !== value.rangeSha256) throw new Error("Saved source integrity check failed. Retry the read.");
6980
+ return {
6981
+ bytes,
6982
+ nextOffset: value.nextOffset,
6983
+ complete: value.complete
6984
+ };
6985
+ }
6986
+ var reads = /* @__PURE__ */ new WeakMap();
6987
+ var admission = /* @__PURE__ */ new WeakMap();
6988
+ function admitRead(ctx, signal, work) {
6989
+ let state = admission.get(ctx);
6990
+ if (!state) {
6991
+ state = {
6992
+ active: 0,
6993
+ pending: []
6994
+ };
6995
+ admission.set(ctx, state);
6996
+ }
6997
+ const queue = state;
6998
+ if (queue.pending.length >= 64) return Promise.reject(/* @__PURE__ */ new Error("Saved source reading queue is busy. Retry after current reads finish."));
6999
+ const pump = () => {
7000
+ while (queue.active < 3 && queue.pending.length) queue.pending.shift()?.();
7001
+ };
7002
+ return new Promise((resolve, reject) => {
7003
+ queue.pending.push(() => {
7004
+ if (signal.aborted) {
7005
+ reject(signal.reason);
7006
+ return;
7007
+ }
7008
+ queue.active++;
7009
+ work().then(resolve, reject).finally(() => {
7010
+ queue.active--;
7011
+ pump();
7012
+ });
7013
+ });
7014
+ pump();
7015
+ });
7016
+ }
7017
+ /** Shares identical source-bound reads; the last cancellation drains the physical request. */
7018
+ function readSavedBodyRange(ctx, ref, offset, maxBytes, signal) {
7019
+ if (signal.aborted) return Promise.reject(signal.reason);
7020
+ let pending = reads.get(ctx);
7021
+ if (!pending) {
7022
+ pending = /* @__PURE__ */ new Map();
7023
+ reads.set(ctx, pending);
7024
+ }
7025
+ const current = pending;
7026
+ const key = JSON.stringify([
7027
+ referenceIdentity(ref),
7028
+ offset,
7029
+ maxBytes
7030
+ ]);
7031
+ let entry = pending.get(key);
7032
+ if (entry?.cancel.signal.aborted) entry = void 0;
7033
+ if (!entry) {
7034
+ const cancel = new AbortController();
7035
+ const finish = () => {
7036
+ if (current.get(key)?.cancel === cancel) current.delete(key);
7037
+ };
7038
+ const sharedSignal = AbortSignal.any([ctx.signal, cancel.signal]);
7039
+ entry = {
7040
+ cancel,
7041
+ promise: admitRead(ctx, sharedSignal, () => readVerifiedRange(ctx, ref, offset, maxBytes, sharedSignal)).then((range) => {
7042
+ finish();
7043
+ return range;
7044
+ }, (error) => {
7045
+ finish();
7046
+ throw error;
7047
+ }),
7048
+ readers: 0
7049
+ };
7050
+ pending.set(key, entry);
7051
+ }
7052
+ const shared = entry;
7053
+ shared.readers++;
7054
+ return new Promise((resolve, reject) => {
7055
+ let finished = false;
7056
+ const release = () => {
7057
+ if (finished) return false;
7058
+ finished = true;
7059
+ signal.removeEventListener("abort", abort);
7060
+ if (--shared.readers === 0) shared.cancel.abort();
7061
+ return true;
7062
+ };
7063
+ const abort = () => {
7064
+ if (release()) reject(signal.reason);
7065
+ };
7066
+ signal.addEventListener("abort", abort, { once: true });
7067
+ shared.promise.then((range) => {
7068
+ if (release()) resolve(range);
7069
+ }, (error) => {
7070
+ if (release()) reject(error);
7071
+ });
7072
+ });
7073
+ }
7074
+ /** Displays one bounded saved range with retry and explicit continuation; it never executes a tool. */
7075
+ function SavedBodyText({ ctx, reference, startByte = 0, endByte, className = "tool-code", part = "saved-source" }) {
7076
+ const host = useSyncExternalStore(ctx.host.subscribe, ctx.host.get);
7077
+ const key = reference ? JSON.stringify([
7078
+ referenceIdentity(reference),
7079
+ startByte,
7080
+ endByte
7081
+ ]) : "";
7082
+ const [position, setPosition] = useState({
7083
+ context: ctx,
7084
+ key,
7085
+ offset: startByte
7086
+ });
7087
+ const offset = position.context === ctx && position.key === key ? position.offset : startByte;
7088
+ const [retry, setRetry] = useState(0);
7089
+ const identity = JSON.stringify([
7090
+ key,
7091
+ offset,
7092
+ retry,
7093
+ host.connection,
7094
+ host.sessionId
7095
+ ]);
7096
+ const allowed = reference?.body.codec === "utf8-text" && host.connection === "online" && host.sessionId === reference.source.sessionId;
7097
+ const [stored, setState] = useState({
7098
+ context: ctx,
7099
+ identity: "",
7100
+ loading: false
7101
+ });
7102
+ const state = stored.context === ctx && stored.identity === identity ? stored : {
7103
+ context: ctx,
7104
+ identity,
7105
+ loading: allowed,
7106
+ ...!allowed ? { error: ctx.i18n.t("saved.body.unavailable") } : {}
7107
+ };
7108
+ const current = useRef(0);
7109
+ useEffect(() => {
7110
+ const request = ++current.current;
7111
+ const cancel = new AbortController();
7112
+ const signal = AbortSignal.any([ctx.signal, cancel.signal]);
7113
+ if (!reference || reference.body.codec !== "utf8-text" || host.connection !== "online" || host.sessionId !== reference.source.sessionId) {
7114
+ setState({
7115
+ context: ctx,
7116
+ identity,
7117
+ loading: false,
7118
+ error: ctx.i18n.t("saved.body.unavailable")
7119
+ });
7120
+ return () => cancel.abort();
7121
+ }
7122
+ const end = Math.min(endByte ?? reference.body.byteLength, reference.body.byteLength);
7123
+ if (offset >= end) {
7124
+ setState({
7125
+ context: ctx,
7126
+ identity,
7127
+ loading: false,
7128
+ text: ""
7129
+ });
7130
+ return () => cancel.abort();
7131
+ }
7132
+ setState({
7133
+ context: ctx,
7134
+ identity,
7135
+ loading: true
7136
+ });
7137
+ readSavedBodyRange(ctx, reference, offset, Math.max(4, Math.min(65536, end - offset)), signal).then((range) => {
7138
+ if (signal.aborted || current.current !== request) return;
7139
+ const next = Math.min(range.nextOffset, end);
7140
+ const text = new TextDecoder("utf-8", {
7141
+ fatal: true,
7142
+ ignoreBOM: true
7143
+ }).decode(range.bytes.subarray(0, next - offset));
7144
+ setState({
7145
+ context: ctx,
7146
+ identity,
7147
+ loading: false,
7148
+ text,
7149
+ ...next < end ? { next } : {}
7150
+ });
7151
+ }).catch((error) => {
7152
+ if (!signal.aborted && current.current === request) setState({
7153
+ context: ctx,
7154
+ identity,
7155
+ loading: false,
7156
+ error: error instanceof Error ? error.message : String(error)
7157
+ });
7158
+ });
7159
+ return () => cancel.abort();
7160
+ }, [
7161
+ ctx,
7162
+ key,
7163
+ offset,
7164
+ retry,
7165
+ host.connection,
7166
+ host.sessionId
7167
+ ]);
7168
+ return /* @__PURE__ */ jsxs("section", { children: [
7169
+ state.loading && /* @__PURE__ */ jsx("p", {
7170
+ role: "status",
7171
+ children: ctx.i18n.t("saved.body.loading")
7172
+ }),
7173
+ state.error && /* @__PURE__ */ jsxs("p", {
7174
+ role: "alert",
7175
+ children: [
7176
+ state.error,
7177
+ " ",
7178
+ /* @__PURE__ */ jsx(ctx.ui.Button, {
7179
+ size: "sm",
7180
+ variant: "text",
7181
+ disabled: !reference || host.connection !== "online" || state.loading,
7182
+ onClick: () => setRetry((value) => value + 1),
7183
+ children: ctx.i18n.t("saved.body.retry")
7184
+ })
7185
+ ]
7186
+ }),
7187
+ state.text !== void 0 && /* @__PURE__ */ jsx("pre", {
7188
+ className,
7189
+ "data-part": part,
7190
+ children: state.text
7191
+ }),
7192
+ state.next !== void 0 && /* @__PURE__ */ jsx(ctx.ui.Button, {
7193
+ size: "sm",
7194
+ variant: "text",
7195
+ disabled: state.loading || host.connection !== "online",
7196
+ onClick: () => setPosition({
7197
+ context: ctx,
7198
+ key,
7199
+ offset: state.next
7200
+ }),
7201
+ children: ctx.i18n.t("saved.body.next")
7202
+ })
7203
+ ] });
7204
+ }
7205
+ /** Registers saved-content states under the same producing owner as the result detail. */
7206
+ function registerSavedBodyCopy(ctx) {
7207
+ ctx.i18n.register({
7208
+ "en-US": {
7209
+ "saved.body.loading": "Reading saved source…",
7210
+ "saved.body.unavailable": "Saved source is unavailable. Reconnect or reopen this result.",
7211
+ "saved.body.retry": "Retry read",
7212
+ "saved.body.next": "Read next saved range"
7213
+ },
7214
+ "zh-CN": {
7215
+ "saved.body.loading": "正在读取已保存原文…",
7216
+ "saved.body.unavailable": "已保存来源暂不可用,请重新连接或重新打开结果。",
7217
+ "saved.body.retry": "重试读取",
7218
+ "saved.body.next": "阅读下一段已保存原文"
7219
+ }
7220
+ }, "en-US");
7221
+ }
7222
+ //#endregion
7223
+ //#region src/ui/tool-details.tsx
7224
+ /** Registers the six saved-result views; source reads use only host-bound original references. */
7225
+ function registerSkillToolDetails(ctx) {
7226
+ registerSavedBodyCopy(ctx);
7227
+ ctx.i18n.register({
7228
+ "en-US": {
7229
+ "skill.saved.unavailable": "Saved skill result is unavailable.",
7230
+ "skill.saved.notification": "Changes committed; change notification failed.",
7231
+ "skill.saved.committed": "Committed",
7232
+ "skill.saved.unchanged": "Unchanged",
7233
+ "skill.saved.partial": "Partial write",
7234
+ "skill.saved.written": "Written files",
7235
+ "skill.saved.uncertain": "Uncertain publication",
7236
+ "skill.saved.removed": "Removed",
7237
+ "skill.saved.absent": "Already absent",
7238
+ "skill.saved.installed": "Installed",
7239
+ "skill.saved.skipped": "Skipped",
7240
+ "skill.saved.failed": "Failed",
7241
+ "skill.saved.more": "More results remain. A continuation is available for a new tool call.",
7242
+ "skill.saved.skill": "Skill",
7243
+ "skill.saved.root": "Root",
7244
+ "skill.saved.plugin": "Plugin",
7245
+ "skill.saved.partialContent": "Partial content",
7246
+ "skill.saved.authority": "Saved paths and installed code do not grant new execution authority."
7247
+ },
7248
+ "zh-CN": {
7249
+ "skill.saved.unavailable": "已保存的技能结果不可用。",
7250
+ "skill.saved.notification": "变更已提交,变更通知失败。",
7251
+ "skill.saved.committed": "已提交",
7252
+ "skill.saved.unchanged": "未变化",
7253
+ "skill.saved.partial": "部分写入",
7254
+ "skill.saved.written": "已写入文件",
7255
+ "skill.saved.uncertain": "提交状态不确定",
7256
+ "skill.saved.removed": "已移除",
7257
+ "skill.saved.absent": "原已不存在",
7258
+ "skill.saved.installed": "已安装",
7259
+ "skill.saved.skipped": "已跳过",
7260
+ "skill.saved.failed": "失败",
7261
+ "skill.saved.more": "还有后续结果,可在新的工具调用中继续查询。",
7262
+ "skill.saved.skill": "技能",
7263
+ "skill.saved.root": "根目录",
7264
+ "skill.saved.plugin": "插件",
7265
+ "skill.saved.partialContent": "部分内容",
7266
+ "skill.saved.authority": "已保存的路径和安装代码不授予新的执行权限。"
7267
+ }
7268
+ }, "en-US");
7269
+ const t = ctx.i18n.t;
7270
+ function Unavailable({ result }) {
7271
+ const error = SkillFailureSchema.safeParse(result?.data);
7272
+ return /* @__PURE__ */ jsx("p", {
7273
+ role: "alert",
7274
+ className: "tool-error",
7275
+ children: error.success ? error.data.error.message : t("skill.saved.unavailable")
7276
+ });
7277
+ }
7278
+ function Write(props) {
7279
+ const saved = SkillWriteDataSchema.safeParse(props.result?.data);
7280
+ if (!saved.success || !saved.data.ok && !("partial" in saved.data)) return /* @__PURE__ */ jsx(Unavailable, { ...props });
7281
+ const data = saved.data;
7282
+ return /* @__PURE__ */ jsxs("section", {
7283
+ className: "tool-section",
7284
+ children: [data.ok ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
7285
+ className: "tool-target",
7286
+ children: [/* @__PURE__ */ jsxs("p", {
7287
+ className: "tool-target-text",
7288
+ children: [
7289
+ data.id,
7290
+ " · ",
7291
+ data.layer
7292
+ ]
7293
+ }), /* @__PURE__ */ jsx("span", {
7294
+ className: "tool-target-meta",
7295
+ children: t(data.unchanged ? "skill.saved.unchanged" : "skill.saved.committed")
7296
+ })]
7297
+ }), data.cleanup?.map((item, index) => /* @__PURE__ */ jsx("p", {
7298
+ role: "status",
7299
+ className: "tool-meta",
7300
+ children: item.message
7301
+ }, index))] }) : "partial" in data ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", {
7302
+ role: "alert",
7303
+ className: "tool-error",
7304
+ children: [
7305
+ t("skill.saved.partial"),
7306
+ ": ",
7307
+ data.message
7308
+ ]
7309
+ }), /* @__PURE__ */ jsxs("dl", {
7310
+ className: "tool-fields",
7311
+ children: [
7312
+ /* @__PURE__ */ jsx("dt", { children: t("skill.saved.written") }),
7313
+ /* @__PURE__ */ jsx("dd", { children: data.written.join(", ") || "—" }),
7314
+ data.uncertain && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: t("skill.saved.uncertain") }), /* @__PURE__ */ jsx("dd", { children: data.uncertain })] })
7315
+ ]
7316
+ })] }) : null, /* @__PURE__ */ jsx("p", {
7317
+ className: "tool-meta",
7318
+ children: t("skill.saved.authority")
7319
+ })]
7320
+ });
7321
+ }
7322
+ function Preload(props) {
7323
+ const saved = SkillPreloadDataSchema.safeParse(props.result?.data);
7324
+ if (!saved.success || !saved.data.ok) return /* @__PURE__ */ jsx(Unavailable, { ...props });
7325
+ return /* @__PURE__ */ jsxs("section", {
7326
+ className: "tool-section",
7327
+ children: [/* @__PURE__ */ jsx("p", {
7328
+ className: "tool-target-text",
7329
+ children: saved.data.id
7330
+ }), /* @__PURE__ */ jsx("ul", {
7331
+ className: "tool-list",
7332
+ children: saved.data.ids.map((id) => /* @__PURE__ */ jsx("li", {
7333
+ className: "tool-row",
7334
+ children: /* @__PURE__ */ jsx("span", {
7335
+ className: "tool-row-name",
7336
+ children: id
7337
+ })
7338
+ }, id))
7339
+ })]
7340
+ });
7341
+ }
7342
+ function Search(props) {
7343
+ const saved = SkillSearchOutputSchema.safeParse(props.result?.data);
7344
+ if (!saved.success || !saved.data.ok) return /* @__PURE__ */ jsx(Unavailable, { ...props });
7345
+ return /* @__PURE__ */ jsxs("section", {
7346
+ className: "tool-section",
7347
+ children: [/* @__PURE__ */ jsx("ul", {
7348
+ className: "tool-list",
7349
+ children: saved.data.items.map((item) => /* @__PURE__ */ jsxs("li", {
7350
+ className: "tool-group tool-section",
7351
+ children: [
7352
+ /* @__PURE__ */ jsx("p", {
7353
+ className: "tool-title",
7354
+ children: item.id
7355
+ }),
7356
+ /* @__PURE__ */ jsx("p", {
7357
+ className: "tool-meta",
7358
+ children: item.layer
7359
+ }),
7360
+ /* @__PURE__ */ jsx("p", { children: item.description })
7361
+ ]
7362
+ }, item.id))
7363
+ }), !saved.data.complete && /* @__PURE__ */ jsx("p", {
7364
+ className: "tool-meta",
7365
+ children: t("skill.saved.more")
7366
+ })]
7367
+ });
7368
+ }
7369
+ function Read(props) {
7370
+ const saved = SkillReadOutputSchema.safeParse(props.result?.data);
7371
+ if (!saved.success || !saved.data.ok) return /* @__PURE__ */ jsx(Unavailable, { ...props });
7372
+ return /* @__PURE__ */ jsxs("section", {
7373
+ className: "tool-section",
7374
+ children: [
7375
+ saved.data.results.map((row) => /* @__PURE__ */ jsx("article", {
7376
+ className: "tool-group tool-section",
7377
+ children: !row.ok ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("p", {
7378
+ className: "tool-target-text",
7379
+ children: row.target
7380
+ }), /* @__PURE__ */ jsx("p", {
7381
+ role: "alert",
7382
+ className: "tool-error",
7383
+ children: row.error.message
7384
+ })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7385
+ /* @__PURE__ */ jsxs("dl", {
7386
+ className: "tool-fields",
7387
+ children: [
7388
+ /* @__PURE__ */ jsx("dt", { children: t("skill.saved.skill") }),
7389
+ /* @__PURE__ */ jsx("dd", { children: row.target }),
7390
+ row.value.source.kind === "native" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: t("skill.saved.root") }), /* @__PURE__ */ jsx("dd", {
7391
+ className: "font-mono",
7392
+ children: row.value.source.root
7393
+ })] }) : row.value.source.kind === "plugin" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: t("skill.saved.plugin") }), /* @__PURE__ */ jsx("dd", { children: `${row.value.source.owner} · ${row.value.source.packageVersion}` })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: t("skill.saved.skill") }), /* @__PURE__ */ jsx("dd", {
7394
+ className: "font-mono",
7395
+ children: row.value.source.digest
7396
+ })] })
7397
+ ]
7398
+ }),
7399
+ !row.complete && /* @__PURE__ */ jsx("p", {
7400
+ className: "tool-meta",
7401
+ children: t("skill.saved.partialContent")
7402
+ }),
7403
+ /* @__PURE__ */ jsx(SavedBodyText, {
7404
+ ctx,
7405
+ reference: props.result?.presentation?.bodyRefs.find((ref) => ref.body.bodyId === row.value.body.bodyId),
7406
+ startByte: row.value.startByte,
7407
+ endByte: row.value.endByte,
7408
+ className: "tool-code"
7409
+ })
7410
+ ] })
7411
+ }, row.index)),
7412
+ !saved.data.complete && /* @__PURE__ */ jsx("p", {
7413
+ className: "tool-meta",
7414
+ children: t("skill.saved.more")
7415
+ }),
7416
+ /* @__PURE__ */ jsx("p", {
7417
+ className: "tool-meta",
7418
+ children: t("skill.saved.authority")
7419
+ })
7420
+ ]
7421
+ });
7422
+ }
7423
+ function Install(props) {
7424
+ const saved = SkillInstallDataSchema.safeParse(props.result?.data);
7425
+ if (!saved.success || "error" in saved.data) return /* @__PURE__ */ jsx(Unavailable, { ...props });
7426
+ return /* @__PURE__ */ jsxs("section", {
7427
+ className: "tool-section",
7428
+ children: [
7429
+ saved.data.results.map((row) => /* @__PURE__ */ jsxs("article", {
7430
+ className: "tool-group tool-section",
7431
+ children: [/* @__PURE__ */ jsx("p", {
7432
+ className: "tool-target-text",
7433
+ children: row.target
7434
+ }), !row.ok ? /* @__PURE__ */ jsx("p", {
7435
+ role: "alert",
7436
+ className: "tool-error",
7437
+ children: row.error.message
7438
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7439
+ /* @__PURE__ */ jsxs("ul", {
7440
+ className: "tool-list",
7441
+ children: [row.value.installed.map((item, index) => /* @__PURE__ */ jsxs("li", {
7442
+ className: "tool-row",
7443
+ children: [/* @__PURE__ */ jsxs("span", {
7444
+ className: "tool-row-name",
7445
+ children: [
7446
+ item.id,
7447
+ " · ",
7448
+ item.layer
7449
+ ]
7450
+ }), /* @__PURE__ */ jsx("span", {
7451
+ className: "tool-row-meta",
7452
+ children: t("skill.saved.installed")
7453
+ })]
7454
+ }, `installed-${index}`)), row.value.skipped.map((item, index) => /* @__PURE__ */ jsxs("li", {
7455
+ className: "tool-row",
7456
+ children: [/* @__PURE__ */ jsx("span", {
7457
+ className: "tool-row-name",
7458
+ children: item.key
7459
+ }), /* @__PURE__ */ jsx("span", {
7460
+ className: "tool-row-meta",
7461
+ children: t("skill.saved.skipped")
7462
+ })]
7463
+ }, `skipped-${index}`))]
7464
+ }),
7465
+ row.value.failed.map((item, index) => /* @__PURE__ */ jsxs("p", {
7466
+ role: "alert",
7467
+ className: "tool-error",
7468
+ children: [
7469
+ t("skill.saved.failed"),
7470
+ ": ",
7471
+ item.key,
7472
+ " · ",
7473
+ item.reason
7474
+ ]
7475
+ }, `failed-${index}`)),
7476
+ row.cleanup?.map((item, index) => /* @__PURE__ */ jsx("p", {
7477
+ role: "status",
7478
+ className: "tool-meta",
7479
+ children: item.message
7480
+ }, `cleanup-${index}`))
7481
+ ] })]
7482
+ }, row.index)),
7483
+ saved.data.notificationError && /* @__PURE__ */ jsx("p", {
7484
+ role: "status",
7485
+ className: "tool-warning",
7486
+ children: t("skill.saved.notification")
7487
+ }),
7488
+ /* @__PURE__ */ jsx("p", {
7489
+ className: "tool-meta",
7490
+ children: t("skill.saved.authority")
7491
+ })
7492
+ ]
7493
+ });
7494
+ }
7495
+ function Uninstall(props) {
7496
+ const saved = SkillUninstallDataSchema.safeParse(props.result?.data);
7497
+ if (!saved.success || "error" in saved.data) return /* @__PURE__ */ jsx(Unavailable, { ...props });
7498
+ return /* @__PURE__ */ jsxs("section", {
7499
+ className: "tool-section",
7500
+ children: [saved.data.results.map((row) => /* @__PURE__ */ jsx("article", {
7501
+ className: "tool-group tool-section",
7502
+ children: !row.ok ? /* @__PURE__ */ jsxs("p", {
7503
+ role: "alert",
7504
+ className: "tool-error",
7505
+ children: [
7506
+ row.target,
7507
+ ": ",
7508
+ row.error.message
7509
+ ]
7510
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
7511
+ className: "tool-target",
7512
+ children: [/* @__PURE__ */ jsxs("p", {
7513
+ className: "tool-target-text",
7514
+ children: [
7515
+ row.value.id,
7516
+ " · ",
7517
+ row.value.layer
7518
+ ]
7519
+ }), /* @__PURE__ */ jsx("span", {
7520
+ className: "tool-target-meta",
7521
+ children: t(row.value.outcome === "removed" ? "skill.saved.removed" : "skill.saved.absent")
7522
+ })]
7523
+ }), row.cleanup?.map((item, index) => /* @__PURE__ */ jsx("p", {
7524
+ role: "status",
7525
+ className: "tool-meta",
7526
+ children: item.message
7527
+ }, index))] })
7528
+ }, row.index)), saved.data.notificationError && /* @__PURE__ */ jsx("p", {
7529
+ role: "status",
7530
+ className: "tool-warning",
7531
+ children: t("skill.saved.notification")
7532
+ })]
7533
+ });
7534
+ }
7535
+ for (const [tool, detail] of Object.entries({
7536
+ skill_read: Read,
7537
+ skill_search: Search,
7538
+ skill_write: Write,
7539
+ skill_install: Install,
7540
+ skill_uninstall: Uninstall,
7541
+ skill_set_preload: Preload
7542
+ })) ctx.slots.register("chat.transcript.tool", {
7543
+ id: tool,
7544
+ tool,
7545
+ label: () => ctx.i18n.t(tool),
7546
+ icon: "hammer",
7547
+ detail,
7548
+ hasDetail: ({ call, result }) => {
7549
+ const data = result?.data;
7550
+ return !(call.name === "skill_search" && !result?.isError && Array.isArray(data?.items) && data.items.length === 0 && data.complete !== false);
7551
+ },
7552
+ state: ({ result }) => result?.isError ? "failed" : void 0
7553
+ });
7554
+ }
7555
+ //#endregion
6383
7556
  //#region src/ui/index.tsx
6384
7557
  var runtimeVersion = 5;
6385
7558
  var STYLES = `
@@ -6423,11 +7596,16 @@ button.skl-preload[aria-pressed=true] svg { fill: currentColor; }
6423
7596
  .skl-skill-table thead th:last-child, .skl-skill-table tbody td:last-child:not([colspan]) { width: 5rem; }
6424
7597
  .skl-skill-table-with-issues thead th:last-child, .skl-skill-table-with-issues tbody td:last-child:not([colspan]) { width: 7rem; }
6425
7598
  .skl-skill-cell { display: flex; width: 100%; min-width: 0; max-width: 100%; flex-direction: column; gap: .25rem; }
6426
- .skl-skill-heading { display: flex; min-width: 0; align-items: center; gap: .5rem; white-space: nowrap; }
6427
- .skl-skill-name { min-width: 0; max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--foreground); font-family: var(--font-mono, ui-monospace, monospace); font-size: .75rem; }
6428
- .skl-skill-origin { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-foreground); font-size: .75rem; }
7599
+ .skl-skill-heading { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; }
7600
+ .skl-skill-name { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow-wrap: anywhere; white-space: normal; color: var(--foreground); font-family: var(--font-mono, ui-monospace, monospace); font-size: .75rem; }
7601
+ .skl-skill-origin { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-foreground); font-size: .75rem; }
6429
7602
  .skl-skill-description, .skl-skill-issue { margin: 0; border: 0; padding: 0; background: none; font: inherit; text-align: start; cursor: help; }
6430
7603
  .skl-skill-issue { display: inline-flex; flex: none; color: var(--warning); }
7604
+ .skl-skill-managed { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; border: 0; padding: 0; background: none; font: inherit; font-size: .75rem; color: var(--muted-foreground); cursor: help; border-radius: var(--radius-control); }
7605
+ .skl-skill-managed:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
7606
+ .skl-skill-plugin { display: inline-flex; min-width: 0; max-width: 100%; margin: 0; border: 0; padding: 0; background: none; font: inherit; cursor: help; border-radius: var(--radius-control); }
7607
+ .skl-skill-plugin:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
7608
+ .skl-skill-plugin [data-slot="skill-plugin"] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
6431
7609
  .skl-skill-description { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-foreground); font-size: .75rem; border-radius: var(--radius-control); }
6432
7610
  .skl-skill-description:focus-visible, .skl-skill-issue:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
6433
7611
  .skl-description-detail { max-height: 16rem; overflow-y: auto; white-space: pre-wrap; }
@@ -6455,13 +7633,10 @@ button.skl-reset { width: var(--control-height, 28px); padding: 0; }
6455
7633
  .skl-search-input { position: relative; }
6456
7634
  .skl-search-input > svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: var(--muted-foreground); pointer-events: none; }
6457
7635
  .skl-search-input > input { width: 100%; padding-inline-start: 2.25rem; }
6458
- .skl-local-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
6459
- .skl-local-path { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
6460
- .skl-install-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; padding: .25rem; margin: -.25rem; }
6461
- .skl-install-scroll:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; border-radius: var(--radius-control); }
6462
- .skl-results-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 0 .25rem .75rem; font-size: .75rem; }
6463
- .skl-results-heading strong { font-weight: 500; }
6464
- .skl-select-all { display: flex; align-items: center; gap: .5rem; color: var(--muted-foreground); cursor: pointer; }
7636
+ .skl-local-picker { display: flex; align-items: center; gap: .75rem; min-width: 0; }
7637
+ .skl-local-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
7638
+ .skl-install-list, .skl-install-results { display: flex; flex: 1; min-height: 0; flex-direction: column; }
7639
+ .skl-install-list > :not(.skl-install-results, [data-slot=data-table]) { flex: none; }
6465
7640
  .skl-results { display: flex; flex-direction: column; gap: .25rem; padding: 0; margin: 0; list-style: none; }
6466
7641
  .skl-results > li + li { border-top: 1px solid var(--border); }
6467
7642
  .skl-install-item { display: flex; align-items: center; gap: .75rem; padding: .875rem .5rem; min-width: 0; border-radius: var(--radius-control); cursor: pointer; }
@@ -6469,8 +7644,8 @@ button.skl-reset { width: var(--control-height, 28px); padding: 0; }
6469
7644
  .skl-install-item[data-selected=true] { background: color-mix(in srgb, var(--primary) 7%, transparent); }
6470
7645
  .skl-install-item[data-disabled=true] { opacity: .55; cursor: default; }
6471
7646
  .skl-install-item strong { font-size: .8125rem; font-weight: 600; overflow-wrap: anywhere; }
6472
- .skl-id-editor { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; font-size: .75rem; }
6473
- .skl-id-editor input { width: min(100%, 16rem); }
7647
+ .skl-id-line { display: flex; align-items: center; gap: .25rem; min-width: 0; }
7648
+ .skl-id-line input { width: min(100%, 16rem); }
6474
7649
  .skl-install-item .skl-description { -webkit-line-clamp: 1; margin-block: .125rem; }
6475
7650
  .skl-package-icon { display: grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: .5rem; border: 1px solid color-mix(in srgb, var(--primary) 15%, var(--border)); color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--background)); }
6476
7651
  .skl-package-icon svg { width: 1.125rem; height: 1.125rem; }
@@ -6528,6 +7703,7 @@ var register = (ctx) => {
6528
7703
  "zh-CN": { "skills.composerSource": "技能" }
6529
7704
  }, "en-US");
6530
7705
  registerMetadata(ctx);
7706
+ registerSkillToolDetails(ctx);
6531
7707
  ctx.i18n.register(CATALOGUES$1, "en-US");
6532
7708
  ctx.styles.add(STYLES);
6533
7709
  ctx.slots.register("shell.agentEditor.tab", {