@webskill/sdk 0.2.4 → 0.2.6

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.
@@ -1,7 +1,7 @@
1
- import { F as SkillDocument, N as SkillCatalogEntry, c as LlmClient, u as LlmMessage, v as UiBridge, w as FileSystemProvider, z as SkillManifest } from "./types-CKm5G_eQ-BqyXnvoR.js";
2
- import { Q as ScriptExecutor, dt as WebSkillRuntime, ft as WebSkillRuntimeDeps, q as RuntimeRun, tt as SkillStateGuard } from "./index-DZShzhon.js";
3
- import { d as SkillManager } from "./index-DrHelz72.js";
4
- //#region ../governance/dist/index.d.ts
1
+ import { B as SkillManifest, I as SkillDocument, P as SkillCatalogEntry, c as LlmClient, u as LlmMessage, v as UiBridge, w as FileSystemProvider } from "./types-CKm5G_eQ-krKWW8WV.js";
2
+ import { Q as ScriptExecutor, dt as WebSkillRuntime, ft as WebSkillRuntimeDeps, q as RuntimeRun, tt as SkillStateGuard } from "./index-DJOha4b6.js";
3
+ import { d as SkillManager } from "./index-DRlYzdr2.js";
4
+ //#region ../governance/dist/documentSource-9dhqKIVQ.d.ts
5
5
  //#region src/types.d.ts
6
6
  type CandidateStatus = 'draft' | 'pending-review' | 'approved' | 'published' | 'rejected';
7
7
  type CandidateSource = 'runtime-miss' | 'document' | 'manual';
@@ -60,32 +60,6 @@ interface SkillVersion {
60
60
  }
61
61
  type SkillState = 'active' | 'quarantined' | 'deprecated' | 'disabled';
62
62
  //#endregion
63
- //#region src/candidate/candidateNormalizer.d.ts
64
- /** 剥 markdown fence 与 <think> 块、截取首尾 {};非对象 → CANDIDATE_INVALID */
65
- declare function parseJsonObject(raw: string): Record<string, unknown>;
66
- /** 小写连字符化、≤64、过 isValidSkillName */
67
- declare function sanitizeCandidateName(raw: string): string;
68
- /**
69
- * 文件归一:补 SKILL.md;路径含 `..` / 以 `/` 开头 / 含 `\` → CANDIDATE_INVALID;
70
- * scripts/ 下必须是 .ts/.js。
71
- */
72
- declare function normalizeCandidateFiles(files: Array<{
73
- path: string;
74
- content: string;
75
- }>, name: string, description: string): CandidateFile[];
76
- /** 含脚本且 LLM 自报 low → 强制 medium 并追加"必须人工审批"原因 */
77
- declare function normalizeRisk(declared: unknown, files: CandidateFile[], reasons: string[]): {
78
- risk: CandidateRisk;
79
- reasons: string[];
80
- };
81
- /** 不信任归一化管线全链路;状态恒为 draft */
82
- declare function normalizeCandidate(input: {
83
- raw: Record<string, unknown>;
84
- source: CandidateSource;
85
- now?: () => string;
86
- createId?: () => string;
87
- }): CandidateSkill;
88
- //#endregion
89
63
  //#region src/candidate/candidateValidator.d.ts
90
64
  /** 候选校验:缺 SKILL.md / 非法扩展名 → CANDIDATE_INVALID */
91
65
  declare function validateCandidate(candidate: CandidateSkill): void;
@@ -123,27 +97,9 @@ declare class LlmCandidateGenerator {
123
97
  }): Promise<CandidateSkill>;
124
98
  }
125
99
  //#endregion
126
- //#region src/approval/policies.d.ts
127
- interface ApprovalDecision {
128
- needsHuman: boolean;
129
- reason: string;
130
- }
131
- interface ApprovalPolicy {
132
- evaluate(candidate: CandidateSkill): ApprovalDecision;
133
- }
134
- /** 默认策略:任何候选都必须人工审批 */
135
- declare class AlwaysHumanApprovalPolicy implements ApprovalPolicy {
136
- evaluate(candidate: CandidateSkill): ApprovalDecision;
137
- }
138
- /** 规则组合策略:首个命中的规则胜出,全部未命中走 fallback(默认 AlwaysHuman) */
139
- declare class CompositeApprovalPolicy implements ApprovalPolicy {
140
- #private;
141
- constructor(rules: Array<(candidate: CandidateSkill) => ApprovalDecision | undefined>, fallback?: ApprovalPolicy);
142
- evaluate(candidate: CandidateSkill): ApprovalDecision;
143
- }
144
- //#endregion
145
100
  //#region src/versioning/skillVersionStore.d.ts
146
- /** 版本存储:manifest 快照 + parentVersionId 链;回滚 = 追加新版本(谱系不断) */
101
+ /** 版本存储:manifest 快照 + parentVersionId 链;回滚 = 追加新版本(谱系不断)。
102
+ * 保留策略:maxArchivesPerSkill(默认 5)超出时清理最旧版本(json + zip 归档一并删除)。 */
147
103
  declare class SkillVersionStore {
148
104
  #private;
149
105
  constructor(deps: {
@@ -152,6 +108,8 @@ declare class SkillVersionStore {
152
108
  now?: () => string;
153
109
  createId?: () => string;
154
110
  audit?: AuditLog;
111
+ /** 每技能保留的版本/归档上限(默认 5,超出清理最旧) */
112
+ maxArchivesPerSkill?: number;
155
113
  });
156
114
  add(skillName: string, input: {
157
115
  reason: string;
@@ -170,38 +128,6 @@ declare class SkillVersionStore {
170
128
  }): Promise<SkillVersion>;
171
129
  }
172
130
  //#endregion
173
- //#region src/approval/approvalWorkflow.d.ts
174
- /** 审批工作流:review(UiBridge confirm 真实接线)/ publish(校验→安装→版本→审计) */
175
- declare class ApprovalWorkflow {
176
- #private;
177
- constructor(deps: {
178
- policy: ApprovalPolicy;
179
- audit: AuditLog;
180
- store: CandidateStore;
181
- skillManager: SkillManager;
182
- versions: SkillVersionStore;
183
- fs?: FileSystemProvider;
184
- });
185
- /** 策略评估;needs-human 时经 UiBridge confirm 真实询问,按应答迁移状态 */
186
- review(candidateId: string, input: {
187
- actor: string;
188
- uiBridge?: UiBridge;
189
- }): Promise<CandidateSkill>;
190
- /** publish 全链路:approved 前置 → 写出 staging → validateSkills → install → 版本 → 审计 */
191
- publish(candidateId: string, input: {
192
- actor: string;
193
- }): Promise<SkillManifest>;
194
- /**
195
- * 真实回滚(受审批保护:仅经显式 actor 调用并全程审计):
196
- * 版本归档解包 → staging 校验 → 原子安装(复用安装管线 swap)→ 追加新版本 + 审计。
197
- * RepairPlanner 的 rollback 选项(targetVersionId)经本方法执行。
198
- */
199
- applyRollback(skillName: string, versionId: string, input: {
200
- actor: string;
201
- reason?: string;
202
- }): Promise<SkillManifest>;
203
- }
204
- //#endregion
205
131
  //#region src/audit/fsAuditLog.d.ts
206
132
  interface AuditChainVerification {
207
133
  ok: boolean;
@@ -362,18 +288,6 @@ declare class EvaluationRunner {
362
288
  run(tasks: EvaluationTask[]): Promise<EvaluationReport>;
363
289
  }
364
290
  //#endregion
365
- //#region src/evaluation/evaluationRuntime.d.ts
366
- /**
367
- * 治理评估专用 runtime 装配(不可信技能试用路径):
368
- * 默认注入 ProcessSandboxExecutor(fork + --permission 真实进程隔离;子进程
369
- * env 默认清空防密钥泄露,需透传时经 ProcessSandboxOptions.envWhitelist 显式放行)。
370
- * 可配置 executor 切回 SandboxedScriptExecutor(worker_threads 能力面收敛形态,
371
- * 非安全边界;envWhitelist 同样适用于该执行器)。
372
- */
373
- declare function createEvaluationRuntime(deps: WebSkillRuntimeDeps & {
374
- executor?: ScriptExecutor;
375
- }): WebSkillRuntime;
376
- //#endregion
377
291
  //#region src/evaluation/testSuggestion.d.ts
378
292
  /** 失败 trace → 回归评估任务建议(prompt 复现 + expected 错误模式) */
379
293
  declare function suggestFromFailedRun(run: RuntimeRun): EvaluationTask;
@@ -445,6 +359,96 @@ interface SourceDocument {
445
359
  /** 读文档 + sha256 hash(变更检测用) */
446
360
  declare function readDocument(fs: FileSystemProvider, path: string): Promise<SourceDocument>;
447
361
  //#endregion
362
+ //#region ../governance/dist/index.d.ts
363
+ //#region src/candidate/candidateNormalizer.d.ts
364
+ /** 剥 markdown fence 与 <think> 块、截取首尾 {};非对象 → CANDIDATE_INVALID */
365
+ declare function parseJsonObject(raw: string): Record<string, unknown>;
366
+ /** 小写连字符化、≤64、过 isValidSkillName */
367
+ declare function sanitizeCandidateName(raw: string): string;
368
+ /**
369
+ * 文件归一:补 SKILL.md;路径含 `..` / 以 `/` 开头 / 含 `\` → CANDIDATE_INVALID;
370
+ * scripts/ 下必须是 .ts/.js。
371
+ */
372
+ declare function normalizeCandidateFiles(files: Array<{
373
+ path: string;
374
+ content: string;
375
+ }>, name: string, description: string): CandidateFile[];
376
+ /** 含脚本且 LLM 自报 low → 强制 medium 并追加"必须人工审批"原因 */
377
+ declare function normalizeRisk(declared: unknown, files: CandidateFile[], reasons: string[]): {
378
+ risk: CandidateRisk;
379
+ reasons: string[];
380
+ };
381
+ /** 不信任归一化管线全链路;状态恒为 draft */
382
+ declare function normalizeCandidate(input: {
383
+ raw: Record<string, unknown>;
384
+ source: CandidateSource;
385
+ now?: () => string;
386
+ createId?: () => string;
387
+ }): CandidateSkill;
388
+ //#endregion
389
+ //#region src/approval/policies.d.ts
390
+ interface ApprovalDecision {
391
+ needsHuman: boolean;
392
+ reason: string;
393
+ }
394
+ interface ApprovalPolicy {
395
+ evaluate(candidate: CandidateSkill): ApprovalDecision;
396
+ }
397
+ /** 默认策略:任何候选都必须人工审批 */
398
+ declare class AlwaysHumanApprovalPolicy implements ApprovalPolicy {
399
+ evaluate(candidate: CandidateSkill): ApprovalDecision;
400
+ }
401
+ /** 规则组合策略:首个命中的规则胜出,全部未命中走 fallback(默认 AlwaysHuman) */
402
+ declare class CompositeApprovalPolicy implements ApprovalPolicy {
403
+ #private;
404
+ constructor(rules: Array<(candidate: CandidateSkill) => ApprovalDecision | undefined>, fallback?: ApprovalPolicy);
405
+ evaluate(candidate: CandidateSkill): ApprovalDecision;
406
+ }
407
+ //#endregion
408
+ //#region src/approval/approvalWorkflow.d.ts
409
+ /** 审批工作流:review(UiBridge confirm 真实接线)/ publish(校验→安装→版本→审计) */
410
+ declare class ApprovalWorkflow {
411
+ #private;
412
+ constructor(deps: {
413
+ policy: ApprovalPolicy;
414
+ audit: AuditLog;
415
+ store: CandidateStore;
416
+ skillManager: SkillManager;
417
+ versions: SkillVersionStore;
418
+ fs?: FileSystemProvider;
419
+ });
420
+ /** 策略评估;needs-human 时经 UiBridge confirm 真实询问,按应答迁移状态 */
421
+ review(candidateId: string, input: {
422
+ actor: string;
423
+ uiBridge?: UiBridge;
424
+ }): Promise<CandidateSkill>;
425
+ /** publish 全链路:approved 前置 → 写出 staging → validateSkills → install → 版本 → 审计 */
426
+ publish(candidateId: string, input: {
427
+ actor: string;
428
+ }): Promise<SkillManifest>;
429
+ /**
430
+ * 真实回滚(受审批保护:仅经显式 actor 调用并全程审计):
431
+ * 版本归档解包 → staging 校验 → 原子安装(复用安装管线 swap)→ 追加新版本 + 审计。
432
+ * RepairPlanner 的 rollback 选项(targetVersionId)经本方法执行。
433
+ */
434
+ applyRollback(skillName: string, versionId: string, input: {
435
+ actor: string;
436
+ reason?: string;
437
+ }): Promise<SkillManifest>;
438
+ }
439
+ //#endregion
440
+ //#region src/evaluation/evaluationRuntime.d.ts
441
+ /**
442
+ * 治理评估专用 runtime 装配(不可信技能试用路径):
443
+ * 默认注入 ProcessSandboxExecutor(fork + --permission 真实进程隔离;子进程
444
+ * env 默认清空防密钥泄露,需透传时经 ProcessSandboxOptions.envWhitelist 显式放行)。
445
+ * 可配置 executor 切回 SandboxedScriptExecutor(worker_threads 能力面收敛形态,
446
+ * 非安全边界;envWhitelist 同样适用于该执行器)。
447
+ */
448
+ declare function createEvaluationRuntime(deps: WebSkillRuntimeDeps & {
449
+ executor?: ScriptExecutor;
450
+ }): WebSkillRuntime;
451
+ //#endregion
448
452
  //#region src/documents/documentSkillExtractor.d.ts
449
453
  /** 文档 → LLM 抽取 → 完整防御管线 → draft 候选(source: document) */
450
454
  declare class DocumentSkillExtractor {