/** brain endpoint base path(namespace 预留 v0.3 第三方 skill)*/ export declare const SKILL_BUNDLE_PATH: "/v1/skills/:slug/bundle.tar.gz"; export declare const SKILL_BUNDLE_PATH_NAMESPACED: "/v1/skills/:owner/:slug/bundle.tar.gz"; /** v0.2.1 默认 owner,路径上省略 */ export declare const DEFAULT_BUNDLE_OWNER: "skillfm-official"; /** slug 校验正则(path param + tool input 共用)*/ export declare const SKILL_SLUG_REGEX: RegExp; /** 赵云 bundle store 落盘路径(CI 写、brain 读)*/ export declare const ZHAOYUN_BUNDLE_STORE_DIR: "/opt/skill-bundles"; export declare const ZHAOYUN_BUNDLE_INDEX_FILENAME: "skills.index.json"; /** GET /v1/skills/:slug/bundle.tar.gz 的请求 header 契约 */ export interface BundleRequestHeaders { /** v0.2 一致:长效 agent_token */ 'X-Agent-Token': string; /** @skillfm/local 客户端版本(observability + min version 守门)*/ 'X-Skillfm-Local-Version'?: string; /** 推荐 application/gzip;缺省也 OK */ Accept?: string; } /** 可选 query params */ export interface BundleRequestQuery { /** pin 到特定版本;省略 = index 中 latest */ version?: string; /** v0.3 预留:'tarball' (默认) | 'zip' */ format?: 'tarball'; } /** * 200 OK 时 brain 必须设置的 response header。 * client(@skillfm/local)按这些 header 校验下载 + 决定安装目录命名。 */ export interface BundleResponseHeaders { 'Content-Type': 'application/gzip'; 'Content-Length': string; /** 跟 path param :slug 完全一致;防止 routing bug */ 'X-Skill-Slug': string; /** semver;client 按此命名 ~/.skillfm/skills/@/ */ 'X-Skill-Version': string; /** tarball 内容的 SHA-256 hex;client 落盘后必校验 */ 'X-Skill-Checksum-Sha256': string; /** bundle 内 skill.manifest.yaml 声明的 contract 版本 (e.g. 'v0.2');用于 client 拒绝过新 manifest */ 'X-Skill-Manifest-Version': string; /** 鉴权 → 不走 CDN edge cache */ 'Cache-Control': 'private, max-age=300'; /** 显式声明缓存 vary,防止公共代理混淆 */ Vary: 'X-Agent-Token'; } /** * brain endpoint + @skillfm/local 共用错误码。 * 跨工作空间稳定字符串,禁止悄悄改名。 */ export declare const SKILL_BUNDLE_ERROR_CODES: { readonly BAD_SLUG: "SKILL.BUNDLE.BAD_SLUG"; readonly AUTH_MISSING_TOKEN: "SKILL.BUNDLE.AUTH.MISSING_TOKEN"; readonly AUTH_BAD_TOKEN: "SKILL.BUNDLE.AUTH.BAD_TOKEN"; readonly AUTH_TOKEN_REVOKED: "SKILL.BUNDLE.AUTH.TOKEN_REVOKED"; /** alias for AUTH_MISSING_TOKEN — used by middleware code */ readonly MISSING_TOKEN: "SKILL.BUNDLE.AUTH.MISSING_TOKEN"; /** alias for AUTH_BAD_TOKEN — used by middleware code */ readonly INVALID_TOKEN: "SKILL.BUNDLE.AUTH.BAD_TOKEN"; /** alias for AUTH_TOKEN_REVOKED — used by middleware code */ readonly TOKEN_REVOKED: "SKILL.BUNDLE.AUTH.TOKEN_REVOKED"; readonly ACCESS_DENIED: "SKILL.BUNDLE.ACCESS.DENIED"; readonly NOT_FOUND: "SKILL.BUNDLE.NOT_FOUND"; readonly VERSION_NOT_FOUND: "SKILL.BUNDLE.VERSION_NOT_FOUND"; readonly CHECKSUM_MISMATCH: "SKILL.BUNDLE.CHECKSUM_MISMATCH"; readonly NOT_READY: "SKILL.BUNDLE.NOT_READY"; readonly INTERNAL: "SKILL.BUNDLE.INTERNAL"; }; export type SkillBundleErrorCode = (typeof SKILL_BUNDLE_ERROR_CODES)[keyof typeof SKILL_BUNDLE_ERROR_CODES]; /** HTTP status mapping(brain handler 用查表,client 错误处理也用)*/ export declare const SKILL_BUNDLE_ERROR_HTTP_STATUS: Record; /** error response body shape(4xx/5xx 时回的 JSON)*/ export interface BundleErrorResponseBody { ok: false; error: { code: SkillBundleErrorCode; message: string; /** 可选机读字段(如 slug / requested_version / hint 等)*/ details?: Record; }; } /** 单个 bundle 版本的元数据 */ export interface BundleVersionEntry { /** 同目录下的 tarball 文件名,e.g. 'xianyu-avatar-adult-1.0.0.tar.gz' */ tarball: string; /** SHA-256 hex(小写)*/ checksum_sha256: string; /** 字节数 */ size: number; /** bundle 内 skill.manifest.yaml 的 contract 版本 */ manifest_version: string; /** ISO 8601 UTC */ published_at: string; /** 触发本次构建的 git commit short SHA */ git_commit: string; } export interface SkillIndexEntry { /** 默认指向最新发布版(按 published_at 排序)*/ latest: string; /** version → entry 映射;保留所有历史版本 */ versions: Record; } /** /opt/skill-bundles/skills.index.json 顶层 shape */ export interface SkillsIndexFile { /** 当前 schema version。本 DELTA 是 1,未来不兼容改动时 bump */ version: 1; /** ISO 8601 UTC,brain 用作 etag / observability */ updated_at: string; /** slug → 版本表 */ skills: Record; } /** MCP tool name — 跨工作空间共用常量 */ export declare const SKILL_INSTALL_TOOL_NAME: "skill_install"; /** tool input schema (JSON Schema 描述见 mcp-stdio/server.ts,本类型用作 TS 校验) */ export interface SkillInstallInput { /** slug (must match SKILL_SLUG_REGEX) */ slug: string; /** 可选,pin 到特定版本 */ version?: string; /** * Optional install-time SAFE observation consent. * If omitted, local install still succeeds but upload scope is local_only. */ safe_observation_consent?: { decision: 'accepted' | 'declined'; upload_scope?: 'local_only' | 'aggregate' | 'redacted_case' | 'public_case'; reward_policy_ref?: string; }; } /** install 成功的 result */ export interface SkillInstallSuccess { ok: true; slug: string; version: string; install_dir: string; safe_observation_consent?: { consent_grant_id: string; upload_scope: 'local_only' | 'aggregate' | 'redacted_case' | 'public_case'; reward_policy_ref?: string; consented_at: string; user_can_revoke: true; }; /** 给 agent 看的下一步提示(中文)*/ hint_for_agent: string; } /** install 失败的 result */ export interface SkillInstallError { ok: false; /** SKILL_INSTALL_ERROR_CODES 之一 */ error: SkillInstallErrorCode; message: string; /** 可选的诊断信息(不含 secret)*/ details?: Record; /** 给 agent 看的中文 hint */ hint_for_agent?: string; } export type SkillInstallResult = SkillInstallSuccess | SkillInstallError; /** * client 侧 error codes — 比服务端错误码多几个本地步骤错误。 * 服务端错误(SKILL.BUNDLE.*)会被 client 重命名为更短的本地形式, * 见 mapServerErrorToInstallError() 实现约束(每个 subagent 必须遵守)。 */ export declare const SKILL_INSTALL_ERROR_CODES: { readonly NETWORK_UNREACHABLE: "NETWORK.UNREACHABLE"; readonly AGENT_NOT_BOUND: "AGENT.NOT_BOUND"; readonly SKILL_NOT_FOUND: "SKILL.NOT_FOUND"; readonly SKILL_ACCESS_DENIED: "SKILL.ACCESS.DENIED"; readonly SKILL_NOT_READY: "SKILL.NOT_READY"; readonly BUNDLE_CHECKSUM_MISMATCH: "BUNDLE.CHECKSUM_MISMATCH"; readonly BUNDLE_EXTRACT_FAILED: "BUNDLE.EXTRACT_FAILED"; readonly BUNDLE_NPM_CI_FAILED: "BUNDLE.NPM_CI_FAILED"; readonly BUNDLE_MISSING_SERVER_JS: "BUNDLE.MISSING_SERVER_JS"; readonly BUNDLE_DISK_FULL: "BUNDLE.DISK_FULL"; readonly BUNDLE_LOCK_BUSY: "BUNDLE.LOCK_BUSY"; readonly INPUT_BAD_SLUG: "INPUT.BAD_SLUG"; readonly INTERNAL: "INSTALL.INTERNAL"; }; export type SkillInstallErrorCode = (typeof SKILL_INSTALL_ERROR_CODES)[keyof typeof SKILL_INSTALL_ERROR_CODES]; /** * 客户端安装目录约定。Subagent B 实现 + Subagent A 测试都要参照。 * * ~/.skillfm/skills/ * ├── @/ ← 真实安装目录 * │ ├── skill.manifest.yaml * │ ├── package.json * │ ├── package-lock.json * │ ├── dist/runtime/server.js ← 必须存在 * │ ├── node_modules/ ← npm ci 后产生(不在 tarball 内) * │ └── ... * ├── ← 软链 (symlink) → @ * ├── .locks/.lock ← 并发互斥 * └── .cache/--.tar.gz ← 临时下载文件(用完删) */ export interface SkillInstallPaths { /** ~/.skillfm/skills/@/ */ installDir: string; /** ~/.skillfm/skills/(软链 / Windows copy 目标)*/ versionlessLink: string; /** ~/.skillfm/skills/.locks/.lock */ lockFile: string; /** ~/.skillfm/skills/.cache/--.tar.gz */ tmpTarball: string; } /** * tarball 解压后**必须存在**的入口文件。client 校验缺即 BUNDLE_MISSING_SERVER_JS。 * * Phase 4 (2026-04-26 esbuild bundle 化, audit 簇 1 解): * - 删 `package-lock.json` — esbuild bundle 已 inline workspace deps, * user 节点 npm ci 只装 yaml/playwright 等真 npm 包, 不需要 per-skill lock * - entry 改 `dist/bundle/server.js` — esbuild output, 0 @skillfm/* bare imports * * 历史 (P4 之前): ['skill.manifest.yaml', 'package.json', 'package-lock.json', 'dist/runtime/server.js'] * - lock 在 monorepo workspace 模式下根本生不出 (workspace * 不在 npm registry) * - dist/runtime/server.js 含 bare @skillfm/* import → user 节点 npm ci 必爆 R-3 */ export declare const BUNDLE_REQUIRED_ENTRY_FILES: readonly ["skill.manifest.yaml", "package.json", "dist/bundle/server.js"]; /** * tarball 故意排除的目录/glob。Subagent C tar 命令 --exclude 用此清单。 * 注:runtime 必须保留(里面的 server.js 是入口)。 */ export declare const BUNDLE_EXCLUDE_GLOBS: readonly ["node_modules", "*.test.*", "*.test.ts", "__tests__", "__mocks__", "src", ".storage", ".git*", ".env*", "*.local.*", ".DS_Store"]; export declare function mapServerErrorToInstallError(serverCode: SkillBundleErrorCode | string): SkillInstallErrorCode; //# sourceMappingURL=skill-distribution.d.ts.map