@skaile/workspaces 1.14.1 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/NOTICE +13 -0
- package/dist/app-sdk/index.js +1 -1
- package/dist/{asset-feeds-ZQLJ2DCP.js → asset-feeds-MWEMXMZA.js} +5 -5
- package/dist/{asset-feeds-ZQLJ2DCP.js.map → asset-feeds-MWEMXMZA.js.map} +1 -1
- package/dist/asset-manager/index.js +5 -5
- package/dist/asset-manager/installer.js +1 -1
- package/dist/bridge/drivers/claude-sdk.js +31 -26
- package/dist/bridge/drivers/claude-sdk.js.map +1 -1
- package/dist/bridge/drivers/codex.js +1 -1
- package/dist/bridge/drivers/continue.js +2 -2
- package/dist/bridge/drivers/echo.js +1 -1
- package/dist/bridge/drivers/gemini.js +3 -3
- package/dist/bridge/drivers/goose.js +2 -2
- package/dist/bridge/drivers/omp.js +1 -1
- package/dist/bridge/drivers/opencode.js +2 -2
- package/dist/bridge/drivers/qwen.js +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/bridge/src/drivers/claude-sdk.d.ts +12 -56
- package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
- package/dist/channels/adapters/msteams/activity.d.ts +70 -0
- package/dist/channels/adapters/msteams/activity.d.ts.map +1 -0
- package/dist/channels/adapters/msteams/client.d.ts +46 -0
- package/dist/channels/adapters/msteams/client.d.ts.map +1 -0
- package/dist/channels/adapters/msteams/index.d.ts +81 -0
- package/dist/channels/adapters/msteams/index.d.ts.map +1 -0
- package/dist/channels/adapters/msteams/jwt.d.ts +27 -0
- package/dist/channels/adapters/msteams/jwt.d.ts.map +1 -0
- package/dist/channels/adapters/msteams.d.ts +2 -0
- package/dist/channels/adapters/msteams.js +595 -0
- package/dist/channels/adapters/msteams.js.map +1 -0
- package/dist/channels/index.d.ts +2 -0
- package/dist/channels/index.js +1069 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/src/adapter.d.ts +54 -0
- package/dist/channels/src/adapter.d.ts.map +1 -0
- package/dist/channels/src/dedupe.d.ts +67 -0
- package/dist/channels/src/dedupe.d.ts.map +1 -0
- package/dist/channels/src/egress/output-mirror.d.ts +63 -0
- package/dist/channels/src/egress/output-mirror.d.ts.map +1 -0
- package/dist/channels/src/egress/vendor/auto-close-streaming.d.ts +26 -0
- package/dist/channels/src/egress/vendor/auto-close-streaming.d.ts.map +1 -0
- package/dist/channels/src/egress/vendor/chunked-message-stream.d.ts +79 -0
- package/dist/channels/src/egress/vendor/chunked-message-stream.d.ts.map +1 -0
- package/dist/channels/src/egress/vendor/markdown-to-mrkdwn.d.ts +21 -0
- package/dist/channels/src/egress/vendor/markdown-to-mrkdwn.d.ts.map +1 -0
- package/dist/channels/src/egress/vendor/message-stream.d.ts +57 -0
- package/dist/channels/src/egress/vendor/message-stream.d.ts.map +1 -0
- package/dist/channels/src/engine.d.ts +125 -0
- package/dist/channels/src/engine.d.ts.map +1 -0
- package/dist/channels/src/format/adaptive-card.d.ts +17 -0
- package/dist/channels/src/format/adaptive-card.d.ts.map +1 -0
- package/dist/channels/src/format/mrkdwn.d.ts +4 -0
- package/dist/channels/src/format/mrkdwn.d.ts.map +1 -0
- package/dist/channels/src/format/types.d.ts +9 -0
- package/dist/channels/src/format/types.d.ts.map +1 -0
- package/dist/channels/src/index.d.ts +17 -0
- package/dist/channels/src/index.d.ts.map +1 -0
- package/dist/channels/src/mention/lookup-tool.d.ts +23 -0
- package/dist/channels/src/mention/lookup-tool.d.ts.map +1 -0
- package/dist/channels/src/mention/normalize.d.ts +27 -0
- package/dist/channels/src/mention/normalize.d.ts.map +1 -0
- package/dist/channels/src/mention/render.d.ts +10 -0
- package/dist/channels/src/mention/render.d.ts.map +1 -0
- package/dist/channels/src/ports.d.ts +71 -0
- package/dist/channels/src/ports.d.ts.map +1 -0
- package/dist/channels/src/types.d.ts +169 -0
- package/dist/channels/src/types.d.ts.map +1 -0
- package/dist/{chunk-A7GDV5BV.js → chunk-2BQBWWFX.js} +2 -2
- package/dist/{chunk-A7GDV5BV.js.map → chunk-2BQBWWFX.js.map} +1 -1
- package/dist/{chunk-MWE7DEGC.js → chunk-344DEXZS.js} +3 -3
- package/dist/{chunk-MWE7DEGC.js.map → chunk-344DEXZS.js.map} +1 -1
- package/dist/{chunk-T2H2ZCU4.js → chunk-73HV7RV3.js} +3 -3
- package/dist/{chunk-T2H2ZCU4.js.map → chunk-73HV7RV3.js.map} +1 -1
- package/dist/{chunk-HLIN4HRK.js → chunk-ACWCVB5Q.js} +2 -2
- package/dist/{chunk-HLIN4HRK.js.map → chunk-ACWCVB5Q.js.map} +1 -1
- package/dist/{chunk-P5VLR3L7.js → chunk-BI2NKPA4.js} +8 -4
- package/dist/chunk-BI2NKPA4.js.map +1 -0
- package/dist/{chunk-4RI4TNMO.js → chunk-DB264AVQ.js} +2 -2
- package/dist/{chunk-4RI4TNMO.js.map → chunk-DB264AVQ.js.map} +1 -1
- package/dist/{chunk-IIGWJE5T.js → chunk-DPUZJI45.js} +3 -3
- package/dist/{chunk-IIGWJE5T.js.map → chunk-DPUZJI45.js.map} +1 -1
- package/dist/{chunk-ZWPXSHMW.js → chunk-EKGB4ZWR.js} +336 -100
- package/dist/chunk-EKGB4ZWR.js.map +1 -0
- package/dist/chunk-F2IBDVBP.js +72 -0
- package/dist/chunk-F2IBDVBP.js.map +1 -0
- package/dist/{chunk-G73FOLLO.js → chunk-M5GJT3D7.js} +3 -3
- package/dist/{chunk-G73FOLLO.js.map → chunk-M5GJT3D7.js.map} +1 -1
- package/dist/{chunk-CS6NFRNQ.js → chunk-MJEUK6VJ.js} +2 -2
- package/dist/{chunk-CS6NFRNQ.js.map → chunk-MJEUK6VJ.js.map} +1 -1
- package/dist/{chunk-NIZNN42B.js → chunk-MNKUZUN2.js} +3 -3
- package/dist/{chunk-NIZNN42B.js.map → chunk-MNKUZUN2.js.map} +1 -1
- package/dist/{chunk-AF2NTM4B.js → chunk-NRXVS7E4.js} +6 -6
- package/dist/{chunk-AF2NTM4B.js.map → chunk-NRXVS7E4.js.map} +1 -1
- package/dist/{chunk-CC6LFFTI.js → chunk-O5VCUU6D.js} +4 -4
- package/dist/{chunk-CC6LFFTI.js.map → chunk-O5VCUU6D.js.map} +1 -1
- package/dist/{chunk-UDUFMVJD.js → chunk-RADBQ5XJ.js} +7 -7
- package/dist/{chunk-UDUFMVJD.js.map → chunk-RADBQ5XJ.js.map} +1 -1
- package/dist/{chunk-TSB46BHR.js → chunk-RDE43ORT.js} +4 -4
- package/dist/{chunk-TSB46BHR.js.map → chunk-RDE43ORT.js.map} +1 -1
- package/dist/{chunk-KECY74AL.js → chunk-SRWIVMJI.js} +4 -4
- package/dist/{chunk-KECY74AL.js.map → chunk-SRWIVMJI.js.map} +1 -1
- package/dist/{chunk-VK24PIAB.js → chunk-TFIFNDT2.js} +3 -3
- package/dist/{chunk-VK24PIAB.js.map → chunk-TFIFNDT2.js.map} +1 -1
- package/dist/{chunk-BIAA3N2A.js → chunk-Z6NGK5YC.js} +3 -3
- package/dist/{chunk-BIAA3N2A.js.map → chunk-Z6NGK5YC.js.map} +1 -1
- package/dist/cli/index.js +41 -41
- package/dist/connectors/config.js +1 -1
- package/dist/connectors/index.js +1 -1
- package/dist/core/index.js +1 -1
- package/dist/deploy/index.js +1 -1
- package/dist/{ensure-sources-O7X3LYLG.js → ensure-sources-QGL44IRI.js} +8 -8
- package/dist/{ensure-sources-O7X3LYLG.js.map → ensure-sources-QGL44IRI.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +1 -1
- package/dist/factory-assets/connectors/deploy.js +1 -1
- package/dist/factory-assets/connectors/devserver.js +1 -1
- package/dist/factory-assets/connectors/flow/adapter.js +1 -1
- package/dist/factory-assets/connectors/flow/engine.js +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +2 -2
- package/dist/factory-assets/connectors/flow.js +1 -1
- package/dist/factory-assets/connectors/git.js +1 -1
- package/dist/factory-assets/connectors/gmail.js +1 -1
- package/dist/factory-assets/connectors/googledrive.js +1 -1
- package/dist/factory-assets/connectors/local.js +1 -1
- package/dist/factory-assets/connectors/mattermost.js +1 -1
- package/dist/factory-assets/connectors/memory.js +1 -1
- package/dist/factory-assets/connectors/minio.js +1 -1
- package/dist/factory-assets/connectors/postgres.js +1 -1
- package/dist/factory-assets/connectors/s3.js +1 -1
- package/dist/factory-assets/connectors/sharepoint.js +1 -1
- package/dist/factory-assets/connectors/sqlite.js +1 -1
- package/dist/factory-assets/connectors/static-server.js +1 -1
- package/dist/factory-assets/connectors/tunnel.js +1 -1
- package/dist/factory-assets/connectors/webdav.js +1 -1
- package/dist/factory-assets/connectors/xstate-store.js +1 -1
- package/dist/factory-assets/connectors/xstate.js +1 -1
- package/dist/{flows-TIUWM7SZ.js → flows-FHWBCLXF.js} +3 -3
- package/dist/{flows-TIUWM7SZ.js.map → flows-FHWBCLXF.js.map} +1 -1
- package/dist/{helpers-DNTGJSA5.js → helpers-FMWODXTW.js} +8 -8
- package/dist/{helpers-DNTGJSA5.js.map → helpers-FMWODXTW.js.map} +1 -1
- package/dist/library/index.js +4 -4
- package/dist/library/install.js +1 -1
- package/dist/{library-publish-XKQN6RTR.js → library-publish-7YDHQGBN.js} +10 -10
- package/dist/{library-publish-XKQN6RTR.js.map → library-publish-7YDHQGBN.js.map} +1 -1
- package/dist/{open-library-2BWIUK4F.js → open-library-O6T3ELPK.js} +9 -9
- package/dist/{open-library-2BWIUK4F.js.map → open-library-O6T3ELPK.js.map} +1 -1
- package/dist/{paths-KOKCMBL5.js → paths-5QJJBAND.js} +7 -7
- package/dist/{paths-KOKCMBL5.js.map → paths-5QJJBAND.js.map} +1 -1
- package/dist/{plugin-store-QMJ2B3VM.js → plugin-store-ZBJZ7F6D.js} +3 -3
- package/dist/{plugin-store-QMJ2B3VM.js.map → plugin-store-ZBJZ7F6D.js.map} +1 -1
- package/dist/{project-4NPDM7R3.js → project-HAMLHLD5.js} +9 -9
- package/dist/{project-4NPDM7R3.js.map → project-HAMLHLD5.js.map} +1 -1
- package/dist/runner/index.js +8 -8
- package/dist/runner/src/serve.d.ts +138 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +5 -5
- package/dist/sdk/bridge.js +2 -2
- package/dist/sdk/core.js +1 -1
- package/dist/sdk/flow.js +1 -1
- package/dist/sdk/index.js +8 -8
- package/dist/sdk/runner.js +8 -8
- package/dist/sdk/session.js +2 -2
- package/dist/sdk/transport/ws.js +1 -1
- package/dist/sdk/transport.js +1 -1
- package/dist/sdk/types.js +1 -1
- package/dist/session/index.js +2 -2
- package/dist/session/src/dispatcher.d.ts.map +1 -1
- package/dist/{setup-TNHKXCBL.js → setup-WJPNUE32.js} +5 -5
- package/dist/{setup-TNHKXCBL.js.map → setup-WJPNUE32.js.map} +1 -1
- package/dist/{source-HVMQJZU7.js → source-ITDH4367.js} +10 -10
- package/dist/{source-HVMQJZU7.js.map → source-ITDH4367.js.map} +1 -1
- package/dist/{source-manifest-publish-JN62UMZD.js → source-manifest-publish-RMHC7R6M.js} +11 -11
- package/dist/{source-manifest-publish-JN62UMZD.js.map → source-manifest-publish-RMHC7R6M.js.map} +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/transport/ws.js +1 -1
- package/dist/tui/index.js +8 -8
- package/dist/types/index.js +1 -1
- package/dist/types/src/events.d.ts +74 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/flow.d.ts +34 -0
- package/dist/types/src/flow.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/protocol.d.ts +6 -0
- package/dist/types/src/protocol.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +23 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +1 -1
- package/dist/workspace-plugin/adapters/omp.js +3 -3
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +15 -2
- package/dist/chunk-P5VLR3L7.js.map +0 -1
- package/dist/chunk-ZWPXSHMW.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/commands/source-manifest.ts","../cli/src/commands/source.ts"],"names":["path2","existsSync","spawnSync"],"mappings":";;;;;;;;;;;;;;AA+CA,IAAM,aAAA,GACJ,2IAAA;AAGF,SAAS,SAAS,IAAA,EAAqB;AACrC,EAAA,MAAA,CAAO,CAAA,EAAG,aAAa,CAAA,wBAAA,EAA2B,IAAI,CAAA,CAAA,CAAG,CAAA;AACzD,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB;AAkBO,SAAS,gBAAA,CACd,KACA,UAAA,EACmE;AACnE,EAAA,MAAM,IAAA,GAAO,kBAAkB,UAAU,CAAA;AACzC,EAAA,MAAM,UAAA,GAA4B,OAC9B,kBAAA,CAAwB,IAAA,CAAA,IAAA,CAAK,MAAM,uBAAA,EAAyB,CAAC,CAAA,GAC7D,EAAC;AACL,EAAA,MAAM,KAAA,GAAQ,WAAW,IAAA,CAAK,CAAC,MAAM,gBAAA,CAAiB,CAAA,EAAG,GAAG,CAAC,CAAA;AAC7D,EAAA,MAAM,MAAA,GAAS,CAAC,KAAA,GAAQ,kBAAA,CAAmB,GAAG,CAAA,GAAI,MAAA;AAClD,EAAA,MAAM,MAAM,KAAA,GAAQ,KAAA,CAAM,MAAO,MAAA,EAAQ,GAAA,IAAO,mBAAmB,GAAG,CAAA;AACtE,EAAA,MAAM,IAAA,GAAO,gBAAgB,GAAG,CAAA;AAChC,EAAA,MAAM,IAAA,GAAO,eAAA,CAAgB,cAAA,CAAe,GAAG,CAAC,CAAA;AAChD,EAAA,OAAO,EAAE,KAAK,IAAA,EAAM,IAAA,EAAM,cAAc,MAAA,EAAQ,YAAA,IAAgB,iBAAA,CAAkB,GAAG,CAAA,EAAE;AACzF;AAQA,SAAS,mBAAmB,GAAA,EAAgE;AAG1F,EAAA,IAAI,CAAC,oBAAoB,IAAA,CAAK,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;AAGH,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,OAAO,GAAA;AACT","file":"chunk-UDUFMVJD.js","sourcesContent":["/**\n * `skaile source manifest …` — curated `skaile.manifest.yaml` lifecycle for a\n * source you do NOT own. `init` generates a curated manifest from a discovery\n * run and stores it OUTSIDE the source, under the local store catalog\n * (`~/.skaile/store/manifests/<slug>.yaml`); `edit` opens it in `$EDITOR` and\n * re-validates on save. `source add`/`sync` then apply it as a read overlay\n * (see `source.ts` `refreshManifestCache`).\n *\n * `rebuild` refreshes a curated manifest after an upstream change (merge by\n * default — curation is sacred; `--overwrite` re-scans). `verify` is a\n * read-only integrity check (paths, declared hashes, schema, dep refs).\n * `publish`/`propose`/`yank` remain stubs — they need the store publish\n * endpoint (`POST /sources/<id>/manifest`), which lands in a follow-up.\n *\n * @docLink cli/commands/source#manifest\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n type AssetEntry,\n decodeSkaileManifest,\n encodeSkaileManifest,\n findWorkspaceRoot,\n parseAssetRef,\n resolveSourcePublisher,\n type SkPublishManifest,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n storeManifestSlug,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { computeDeterministicHash, discoverAssetsInTree } from \"@skaile/workspaces/discovery\";\nimport { getStoreManifestsDir, writeCuratedManifest } from \"@skaile/workspaces/library\";\nimport type { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport {\n ensureClone,\n normalizeSourceUrl,\n readProjectSources,\n sourceClonePath,\n sourceMatchesKey,\n} from \"./source.ts\";\n\nconst NOT_WIRED_MSG =\n \"`skaile source manifest *` is scaffolded but not yet wired. \" +\n \"Server-side endpoint (`POST /sources/<id>/manifest`) lands in a follow-up PR.\";\n\nfunction notWired(verb: string): never {\n logErr(`${NOT_WIRED_MSG} (verb: source manifest ${verb})`);\n process.exit(2);\n}\n\n/**\n * Resolve a `source manifest` argument into a `{ url, slug, dest }` triple.\n *\n * Resolution order:\n * 1. A key matching an already-registered project source (stored URL, cache\n * key, or short slug).\n * 2. A collision-free **store slug** (`<host>__<owner>__<repo>`) whose\n * manifest already exists at `~/.skaile/store/manifests/<arg>.yaml`. This\n * MUST be tried before bare-name expansion: a bare name like `cli` would\n * otherwise expand (via `normalizeSourceUrl`) to the skaile-ai org and a\n * DIFFERENT slug than the one `init` wrote (e.g. `larksuite`). The slug is\n * the exact identifier `init`'s next-step hint prints back.\n * 3. Otherwise a git URL / `owner/repo` / bare name via `normalizeSourceUrl`.\n *\n * The clone dir is the same URL-keyed cache `source add` uses.\n */\nexport function resolveSourceArg(\n arg: string,\n projectDir: string,\n): { url: string; slug: string; dest: string; manifestFile: string } {\n const root = findWorkspaceRoot(projectDir);\n const registered: SourceEntry[] = root\n ? readProjectSources(path.join(root, workspaceConfigFilename()))\n : [];\n const match = registered.find((e) => sourceMatchesKey(e, arg));\n const bySlug = !match ? resolveByStoreSlug(arg) : undefined;\n const url = match ? match.url : (bySlug?.url ?? normalizeSourceUrl(arg));\n const slug = sourceShortName(url); // human-facing label\n const dest = sourceClonePath(sourceCacheKey(url));\n return { url, slug, dest, manifestFile: bySlug?.manifestFile ?? storeManifestPath(url) };\n}\n\n/**\n * When `arg` is a bare store slug (`<host>__<owner>__<repo>`) whose curated\n * manifest already exists on disk, recover the source URL from the slug and\n * point at that manifest file directly. Returns `undefined` when the arg isn't\n * a slug or has no manifest yet (fall back to URL normalization).\n */\nfunction resolveByStoreSlug(arg: string): { url: string; manifestFile: string } | undefined {\n // A slug is our own encoding — no path/URL sigils, at least the `<host>__…`\n // separator. Anything URL/owner-repo shaped is not a slug.\n if (!/^[\\w.-]+__[\\w.-]+/.test(arg) || /[/:\\\\]/.test(arg)) return undefined;\n const manifestFile = path.join(getStoreManifestsDir(), `${arg}.yaml`);\n if (!existsSync(manifestFile)) return undefined;\n // `<host>__<owner>__<repo>` → `https://<host>/<owner>/<repo>` — good enough to\n // key the clone dir + re-derive the same slug; the manifest file is what edit\n // actually opens.\n const [host, owner, repo] = arg.split(\"__\");\n const url = host && owner && repo ? `https://${host}/${owner}/${repo}` : arg;\n return { url, manifestFile };\n}\n\n/**\n * Absolute path to a source's curated store manifest. Keyed by the\n * collision-free {@link storeManifestSlug} (`<host>__<owner>__<repo>`) so\n * `orgA/cli` and `orgB/cli` don't share `cli.yaml`.\n */\nfunction storeManifestPath(url: string): string {\n return path.join(getStoreManifestsDir(), `${storeManifestSlug(url)}.yaml`);\n}\n\n/**\n * Directory-name segments that mark a test-fixture tree. `init`/`rebuild` drop\n * any asset whose repo-relative root contains one of these as an exact path\n * SEGMENT. Repos routinely ship fixture \"skills\" under such dirs (e.g.\n * `scripts/skill-format-check/tests`, `internal/qualitygate/skillscan/testdata/skills/lark-demo`)\n * that are not real, publishable assets.\n */\nconst TEST_FIXTURE_SEGMENTS = new Set([\n \"tests\",\n \"test\",\n \"__tests__\",\n \"testdata\",\n \"fixtures\",\n \"__fixtures__\",\n]);\n\n/**\n * True when an asset's repo-relative `root` sits under a test-fixture directory\n * (see {@link TEST_FIXTURE_SEGMENTS}). Conservative, not repo-specific — finer\n * curation (keeping a genuine fixture asset) stays the user's job via `edit`.\n * `init`/`rebuild`-path only; the general discovery walk (`source add`) is\n * untouched.\n */\nfunction isTestFixtureAsset(relativePath: string): boolean {\n const segments = relativePath.replace(/\\\\/g, \"/\").split(\"/\");\n return segments.some((s) => TEST_FIXTURE_SEGMENTS.has(s));\n}\n\n/**\n * `source manifest init <src>` — clone (if needed), run discovery, and write a\n * curated `skaile.manifest.yaml` to `~/.skaile/store/manifests/<slug>.yaml`.\n */\nasync function runInit(\n arg: string,\n opts: { projectDir: string; publisher?: string; dev?: boolean; force?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (existsSync(target) && !opts.force) {\n logWarn(\n `A curated manifest already exists at ${S.dim(target)}. ` +\n \"Edit it with `skaile source manifest edit`, refresh it after an upstream \" +\n \"change with `skaile source manifest rebuild`, or pass --force to regenerate.\",\n );\n return;\n }\n\n const entry: SourceEntry = { url };\n ensureClone(entry);\n\n const { assets, errors } = discoverCuratableAssets(dest, opts.dev ?? false);\n\n const publisher = opts.publisher ?? resolveSourcePublisher(dest) ?? sourceShortName(url);\n\n const written = writeCuratedManifest({\n manifestFile: target,\n publisher,\n assets,\n force: opts.force,\n // Init: every asset inherits the top-level repo `publisher`. Do NOT stamp a\n // per-asset publisher — on the glob path each DiscoveredAsset.publisher is\n // the bare first path segment (`scripts`/`skills`/…), which would clobber\n // the intended org/`--publisher` default with junk per-asset overrides.\n inheritPublisher: true,\n });\n\n if (!written.wrote) {\n logWarn(\n `Curated manifest already exists at ${S.dim(target)} — not overwritten. ` +\n \"Pass --force to regenerate.\",\n );\n return;\n }\n\n logOk(`Wrote curated manifest with ${written.assetCount} assets to ${S.dim(target)}.`);\n // Echo the EXACT <src> the user passed so the printed commands actually run.\n // A bare short name would mis-resolve through `normalizeSourceUrl` (→ the\n // skaile-ai org, wrong slug); the original arg is what `resolveSourceArg`\n // maps back to this same manifest.\n logInfo(\n `Edit it with \\`skaile source manifest edit ${arg}\\`, then ` +\n `\\`skaile source add ${arg}\\` to consume it.`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the manifest before consuming.`);\n }\n}\n\n/**\n * Run discovery over a clone and drop the test-fixture assets (see\n * {@link isTestFixtureAsset}). Shared by `init` and `rebuild` so both paths\n * produce an identical inventory from the same tree.\n */\nfunction discoverCuratableAssets(\n dest: string,\n includeDev: boolean,\n): { assets: ReturnType<typeof discoverAssetsInTree>[\"assets\"]; errors: string[] } {\n const result = discoverAssetsInTree(dest, {\n registry: createFullRegistry(),\n includeDev,\n });\n const assets = result.assets.filter((a) => !isTestFixtureAsset(a.relativePath));\n return { assets, errors: result.errors.map((e) => `${e.path}: ${e.error}`) };\n}\n\n/**\n * Best-effort `git pull --ff-only` on an existing clone. Never throws: a pull\n * failure (offline, diverged, detached) is warned and the caller continues with\n * the clone as-is.\n */\nfunction pullCloneFfOnly(dest: string): void {\n const res = spawnSync(\"git\", [\"-C\", dest, \"pull\", \"--ff-only\"], { stdio: \"pipe\" });\n if (res.status !== 0) {\n logWarn(\n \"git pull --ff-only failed — continuing with the existing clone \" +\n \"(it may be behind upstream).\",\n );\n }\n}\n\n/**\n * Repo-relative `root` path for a manifest asset entry — the merge match key\n * between an existing curated entry and a freshly-discovered asset. `root:`\n * entries use their declared path; a `files:`-only entry (rare for a curated\n * sidecar) falls back to the entry's dirname of the first file, else the name.\n */\nfunction entryRootKey(entry: AssetEntry): string {\n if (entry.root) return entry.root.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n const files = entry.files;\n if (files && files.length > 0) {\n const first = typeof files[0] === \"string\" ? files[0] : files[0].path;\n const dir = path.posix.dirname(first.replace(/\\\\/g, \"/\"));\n return dir === \".\" ? entry.name : dir;\n }\n return entry.name;\n}\n\n/** Repo-relative `root` path a discovered asset maps to (matches init's writer). */\nfunction discoveredRootKey(relativePath: string): string {\n const dir = path.posix.dirname(relativePath.replace(/\\\\/g, \"/\"));\n return dir === \".\" ? path.posix.basename(relativePath.replace(/\\\\/g, \"/\")) : dir;\n}\n\n/** Human ref for reporting: `kind:name`. */\nfunction entryRef(entry: AssetEntry): string {\n return `${entry.kind}:${entry.name}`;\n}\n\n/**\n * `source manifest rebuild <src>` — refresh a curated manifest after the\n * upstream repo changed. MERGE is the default (curation is sacred); `--overwrite`\n * re-scans from scratch with `init --force` semantics.\n *\n * Merge algorithm (match by repo-relative `root` path):\n * - Existing entries whose root is STILL discovered → KEPT verbatim (all\n * hand-edits preserved).\n * - Existing entries whose root is GONE upstream → DROPPED (reported).\n * - Freshly-discovered assets not already in the manifest → NOT auto-added,\n * only REPORTED (a curated foreign sidecar must not silently absorb new\n * upstream skills). An asset the curator deliberately dropped stays dropped\n * because it is neither in the existing manifest nor re-added here.\n */\nasync function runRebuild(\n arg: string,\n opts: { projectDir: string; publisher?: string; dev?: boolean; overwrite?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(target)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n // Update the clone: clone if absent, else pull --ff-only (best-effort).\n const entry: SourceEntry = { url };\n const cloned = ensureClone(entry);\n if (!cloned) pullCloneFfOnly(dest);\n\n const { assets: freshAssets, errors } = discoverCuratableAssets(dest, opts.dev ?? false);\n\n if (opts.overwrite) {\n logWarn(\n \"--overwrite: replacing the curated manifest with a full fresh inventory. \" +\n \"All hand-curation (dropped assets, per-asset edits) is discarded.\",\n );\n const publisher = opts.publisher ?? resolveSourcePublisher(dest) ?? sourceShortName(url);\n const written = writeCuratedManifest({\n manifestFile: target,\n publisher,\n assets: freshAssets,\n force: true,\n inheritPublisher: true,\n });\n logOk(\n `Rebuilt curated manifest with ${written.assetCount} assets to ${S.dim(target)} (overwrite).`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the manifest before consuming.`);\n }\n return;\n }\n\n // MERGE (default). `--publisher` only applies to the full re-derive path.\n if (opts.publisher) {\n logWarn(\n \"--publisher is ignored in merge mode (the curated publisher is preserved). \" +\n \"Use --overwrite to re-derive the publisher from a full re-scan.\",\n );\n }\n\n // Read the existing curated manifest and keep it as the base.\n const { manifest: existing } = decodeSkaileManifest(readFileSync(target, \"utf-8\"));\n const existingEntries = existing.assets ?? [];\n\n // Index fresh discovery by repo-relative root path.\n const freshByRoot = new Map<string, (typeof freshAssets)[number]>();\n for (const a of freshAssets) freshByRoot.set(discoveredRootKey(a.relativePath), a);\n\n const kept: AssetEntry[] = [];\n const dropped: string[] = [];\n for (const e of existingEntries) {\n if (freshByRoot.has(entryRootKey(e))) kept.push(e);\n else dropped.push(entryRef(e));\n }\n\n // Fresh assets not already curated → report as available, do NOT add.\n const existingRoots = new Set(existingEntries.map(entryRootKey));\n const newlyAvailable: string[] = [];\n for (const a of freshAssets) {\n if (!existingRoots.has(discoveredRootKey(a.relativePath))) {\n newlyAvailable.push(`${a.kind}:${a.name}`);\n }\n }\n\n const changed = dropped.length > 0;\n if (dropped.length > 0) {\n logWarn(`removed (gone upstream): ${dropped.sort().join(\", \")}`);\n }\n if (newlyAvailable.length > 0) {\n logInfo(\n `${newlyAvailable.length} new upstream asset(s) available (not added): ` +\n `${newlyAvailable.sort().join(\", \")} — add with \\`skaile source manifest edit ${arg}\\` if wanted`,\n );\n }\n\n if (!changed) {\n logOk(\"already up to date\");\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the source before re-consuming.`);\n }\n return;\n }\n\n const merged: SkPublishManifest = { ...existing, assets: kept };\n writeFileSync(target, encodeSkaileManifest(merged), \"utf-8\");\n logOk(\n `Rebuilt curated manifest: kept ${kept.length}, dropped ${dropped.length} → ${S.dim(target)}.`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the source before re-consuming.`);\n }\n}\n\n/**\n * `source manifest verify <src>` — READ-ONLY integrity check of a curated\n * manifest against its clone. Writes nothing. Exit 0 when no errors; with\n * `--strict`, any warning also forces a nonzero exit.\n *\n * Per-asset checks:\n * - `root`/`files` paths still exist upstream (missing → error).\n * - A declared `sha256` recomputes to the same deterministic hash (mismatch → error).\n * - Schema decode diagnostics map to errors/warnings.\n * - Dependency refs parse via `parseAssetRef` (malformed → warning).\n */\nasync function runVerify(\n arg: string,\n opts: { projectDir: string; strict?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(target)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n // Ensure a clone exists to verify paths/hashes against (best-effort; no pull).\n ensureClone({ url });\n\n const text = readFileSync(target, \"utf-8\");\n const { manifest, diagnostics } = decodeSkaileManifest(text);\n\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Schema diagnostics from the decoder.\n for (const d of diagnostics) {\n const line = `${d.code}: ${d.message}`;\n if (d.severity === \"error\") errors.push(line);\n else warnings.push(line);\n }\n\n const assets = manifest.assets ?? [];\n for (const entry of assets) {\n const ref = entryRef(entry);\n\n // Path existence: `root` dir and/or each `files[]` path.\n const relPaths: string[] = [];\n if (entry.root) relPaths.push(entry.root);\n if (entry.files) {\n for (const f of entry.files) relPaths.push(typeof f === \"string\" ? f : f.path);\n }\n if (relPaths.length === 0) relPaths.push(entry.name);\n for (const rel of relPaths) {\n if (!existsSync(path.join(dest, rel))) {\n errors.push(`${ref}: path not found upstream: ${rel}`);\n }\n }\n\n // Declared sha256 → recompute + compare, but ONLY for granular `files:`\n // entries. Discovery (`discover-manifest.ts`) anchors a `files:`-only entry\n // at the REPO ROOT and hashes the files VERBATIM as repo-relative strings\n // (the path is folded into the digest), so verify must hash the same way:\n // `assetRoot = dest`, files kept repo-relative — NOT rebased onto the root.\n // A `root:` entry cannot be verified this way (discovery hashes only the\n // per-kind filtered set, not the whole-dir walk), and the writer never emits\n // sha256 for `root:` entries, so skip the hash check for them.\n if (entry.sha256) {\n if (entry.files && entry.files.length > 0) {\n const hashFiles = entry.files.map((f) =>\n (typeof f === \"string\" ? f : f.path).replace(/\\\\/g, \"/\"),\n );\n const actual = computeDeterministicHash(dest, hashFiles);\n if (actual !== entry.sha256) {\n errors.push(\n `${ref}: sha256 mismatch (declared ${entry.sha256.slice(0, 12)}…, got ${actual.slice(0, 12)}…)`,\n );\n }\n } else {\n warnings.push(\n `${ref}: declared sha256 on a root:-mode entry is not verifiable (discovery hashes only the per-kind filtered set) — skipped`,\n );\n }\n }\n\n // Dependency refs parse.\n for (const dep of entry.dependencies ?? []) {\n try {\n parseAssetRef(dep);\n } catch (err) {\n warnings.push(\n `${ref}: malformed dependency \"${dep}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n for (const w of warnings) logWarn(w);\n for (const e of errors) logErr(e);\n\n if (errors.length === 0) {\n logOk(`verified ${assets.length} asset(s).`);\n } else {\n logErr(`${errors.length} issue(s).`);\n }\n\n const failStrict = opts.strict && warnings.length > 0;\n if (errors.length > 0 || failStrict) process.exit(1);\n}\n\n/**\n * Split a `$VISUAL`/`$EDITOR` value into `{ command, args }` and append the file\n * as the final arg. The env value is a full command line, not a bare binary —\n * `EDITOR=\"code --wait\"` must spawn `code` with `[\"--wait\", <file>]`, and\n * `EDITOR=code` (which returns before save) is the user's problem, not ours.\n * A whitespace split covers the common editors (`code --wait`, `code -w`,\n * `subl -w`, `vi`); paths with embedded spaces are not supported (rare for an\n * editor binary and out of scope). Falls back to `vi` when unset/empty.\n *\n * @docLink cli/commands/source#manifest-edit\n */\nexport function resolveEditorCommand(\n editorEnv: string | undefined,\n target: string,\n): { command: string; args: string[] } {\n const parts = (editorEnv ?? \"\").trim().split(/\\s+/).filter(Boolean);\n const [command, ...rest] = parts.length > 0 ? parts : [\"vi\"];\n return { command: command as string, args: [...rest, target] };\n}\n\n/** Minimal spawn contract runEdit needs — lets tests inject a fake. */\ntype SpawnLike = (\n command: string,\n args: string[],\n opts: { stdio: \"inherit\" },\n) => { status: number | null };\n\n/**\n * `source manifest edit <src>` — open the curated store manifest in `$EDITOR`\n * and re-validate on save. Warnings are surfaced but never hard-fail.\n *\n * `spawn` is injectable so tests can assert the argv without launching a real\n * editor; production passes the default `spawnSync`.\n */\nexport function runEdit(\n arg: string,\n opts: { projectDir: string },\n spawn: SpawnLike = spawnSync as unknown as SpawnLike,\n): void {\n const projectDir = path.resolve(opts.projectDir);\n const { slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${target}. ` +\n \"Run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n const { command, args } = resolveEditorCommand(process.env.VISUAL || process.env.EDITOR, target);\n const res = spawn(command, args, { stdio: \"inherit\" });\n if (res.status !== 0 && res.status !== null) {\n logErr(`Editor exited with status ${res.status}.`);\n process.exit(1);\n }\n\n // Re-validate the saved file; surface diagnostics as warnings, don't hard-fail.\n const { diagnostics } = decodeSkaileManifest(readFileSync(target, \"utf-8\"));\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n const warnings = diagnostics.filter((d) => d.severity !== \"error\");\n if (errors.length > 0) {\n for (const d of errors) logErr(`${d.code}: ${d.message}`);\n logWarn(\"Manifest has errors — fix them before `skaile source add` will consume it.\");\n } else if (warnings.length > 0) {\n for (const d of warnings) logWarn(`${d.code}: ${d.message}`);\n logOk(\"Saved (with warnings).\");\n } else {\n logOk(\"Saved.\");\n }\n}\n\n/**\n * Append the `manifest` sub-tree to a `source` command.\n *\n * Called from `makeSourceCommand()` in `source.ts`.\n */\nexport function addSourceManifestCommands(src: Command): void {\n // enablePositionalOptions so options on the leaf verb (`source manifest init\n // --publisher …`) route to that verb instead of being rejected by `manifest`.\n const manifest = src\n .command(\"manifest\")\n .description(\"Curated manifest lifecycle for a source\")\n .enablePositionalOptions();\n\n manifest\n .command(\"init <src>\")\n .description(\"Generate a curated manifest for a source (stored in the local store catalog)\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--publisher <name>\", \"Override the publisher (default: source's GitHub org)\")\n .option(\"--dev\", \"Include assets under the source's dev_paths\", false)\n .option(\"--force\", \"Overwrite an existing curated manifest\", false)\n .action((arg, opts) => runInit(arg, opts));\n\n manifest\n .command(\"edit <src>\")\n .description(\"Open the curated manifest in $EDITOR and re-validate on save\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .action((arg, opts) => runEdit(arg, opts));\n\n manifest\n .command(\"rebuild <src>\")\n .description(\n \"Refresh a curated manifest after an upstream change (merge by default: \" +\n \"keeps curation, drops assets gone upstream, reports new ones without adding)\",\n )\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--publisher <name>\", \"Override the publisher (--overwrite only)\")\n .option(\"--dev\", \"Include assets under the source's dev_paths\", false)\n .option(\"--overwrite\", \"Discard curation and re-scan the full inventory\", false)\n .action((arg, opts) => runRebuild(arg, opts));\n\n manifest\n .command(\"verify <src>\")\n .description(\"Verify hashes, deps, and schema (read-only)\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--strict\", \"Fail on advisory checks (warnings force a nonzero exit)\", false)\n .action((arg, opts) => runVerify(arg, opts));\n\n manifest\n .command(\"publish <src>\")\n .description(\"Push the curated sidecar manifest and publish it to the store\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--as <namespace>\", \"Publisher namespace (default: your store username)\")\n .option(\"--sidecar-repo <url>\", \"Public GitHub repo you own to hold the curated manifest\")\n .option(\"--ref <gitref>\", \"Foreign source ref to ingest (branch/sha; default: main)\")\n .option(\"--dry-run\", \"Print the publish plan without pushing or calling the store\", false)\n .action(async (arg, opts) => {\n const { runPublish } = await import(\"./source-manifest-publish.ts\");\n await runPublish(arg, opts);\n });\n\n manifest\n .command(\"propose <src>\")\n .description(\"Open a PR to upstream with the sidecar manifest\")\n .action(() => notWired(\"propose\"));\n\n manifest\n .command(\"yank <src>\")\n .description(\"Retract the source's published assets from the store\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--asset <ref>\", \"Yank only the asset matching this ref/name\")\n .action(async (arg, opts) => {\n const { runYank } = await import(\"./source-manifest-publish.ts\");\n await runYank(arg, opts);\n });\n}\n","/**\n * `skaile source …` — manage github sources for the current project.\n *\n * A *source* is a third-party github repo of AI assets. The project's\n * `skaile.yaml` `sources:` array is the source of truth for which sources\n * this project uses. The clone itself lives at\n * `~/.skaile/cache/sources/<host>/<owner>/<repo>/` (machine-global cache, shared\n * across projects, URL-keyed so cross-org repos never collide), and the manifest is\n * mirrored into `~/.skaile/index.db` (machine-global manifest cache).\n *\n * @docLink cli/commands/source\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, renameSync, rmSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n findWorkspaceRoot,\n getGlobalCacheDir,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n storeManifestSlug,\n WorkspaceYamlEditor,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { getStoreManifestsDir, LocalCatalogSource } from \"@skaile/workspaces/library\";\nimport * as p from \"@clack/prompts\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { openLibraryManager } from \"../open-library.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport { addSourceManifestCommands } from \"./source-manifest.ts\";\n\n/**\n * Clone dir for one source cache key (`<host>/<owner>/<repo>`). Exported for the\n * cache-path regression test. Callers pass `sourceCacheKey(url)`.\n */\nexport function sourceClonePath(key: string): string {\n return path.join(getGlobalCacheDir(), key);\n}\n\nconst SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\nconst LEGACY_SOURCE_CONFIG_FILENAME = \".skaile-source.yaml\";\n\n/**\n * Whether a manifest-cache refresh actually failed to index something. Keyed on\n * `errors`, NOT on `assetsUpdated < assetsFound`: the discovery walk counts\n * presets (and other intentionally-not-cataloged kinds) toward `assetsFound` but\n * never upserts them, so a source shipping a `.preset.yaml` would otherwise read\n * as a partial failure — false `! N asset(s) failed to index` + exit 1 — with\n * zero real errors.\n */\nexport function indexingHadFailures(result: { errors: string[] }): boolean {\n return result.errors.length > 0;\n}\n\n/**\n * A clone that ships only the legacy `.skaile-source.yaml` (no\n * `skaile.manifest.yaml`) has its declared `publisher_default` silently ignored\n * — discovery only reads `skaile.manifest.yaml`, so publisher resolution falls\n * back to the first path segment. Surface a hint so the author can fix it.\n */\nexport function legacySourceConfigHint(dest: string): string | undefined {\n const hasLegacy = existsSync(path.join(dest, LEGACY_SOURCE_CONFIG_FILENAME));\n const hasManifest = existsSync(path.join(dest, SKAILE_MANIFEST_FILENAME));\n if (hasLegacy && !hasManifest) {\n return (\n `This source ships a legacy ${LEGACY_SOURCE_CONFIG_FILENAME} but no ` +\n `${SKAILE_MANIFEST_FILENAME}; its declared publisher is ignored and assets ` +\n `are published under their first path segment. Add a ${SKAILE_MANIFEST_FILENAME} ` +\n `(\\`skaile source manifest init\\`) to set the publisher and asset inventory.`\n );\n }\n return undefined;\n}\n\n/**\n * Normalize a `source add` argument into a clonable git URL. Full URLs and\n * scp-style (`git@host:…`) specs pass through unchanged; an `owner/repo`\n * shorthand and a bare repo name expand to GitHub over SSH — a bare name\n * defaults to the `skaile-ai` org (`git@github.com:skaile-ai/<name>.git`).\n */\nexport function normalizeSourceUrl(input: string): string {\n const s = input.trim();\n if (/^(?:https?|git|ssh|file):\\/\\//.test(s) || /^git@/.test(s)) return s;\n const repo = s.replace(/\\.git$/, \"\");\n if (/^[\\w.-]+\\/[\\w.-]+$/.test(repo)) return `git@github.com:${repo}.git`;\n if (/^[\\w.-]+$/.test(repo)) return `git@github.com:skaile-ai/${repo}.git`;\n return s;\n}\n\n/**\n * Match a stored source against a user-supplied key. Mirrors the shortcut\n * expansion `source add` applies (`normalizeSourceUrl`) so any form that `add`\n * accepted — bare name, `owner/repo`, `.git`-suffixed, full URL — also resolves\n * at `sync`/`show`/`remove` time, not just the raw stored URL or derived slug.\n */\nexport function sourceMatchesKey(entry: SourceEntry, key: string): boolean {\n if (entry.url === key) return true;\n if (sourceCacheKey(entry.url) === key || sourceShortName(entry.url) === key) return true;\n return entry.url === normalizeSourceUrl(key);\n}\n\n/**\n * Find an already-registered source that maps to the same cache key as `url`\n * but is stored under a *different* URL string (e.g. the `.git`-suffixed or\n * scp form of the same remote). Two such entries would fight over one clone\n * dir, so `source add` rejects the ambiguity. Returns the colliding entry, or\n * `undefined` when the URL is unique or only matches an exact-string duplicate\n * (which `setSource` updates in place).\n */\nexport function findCacheKeyCollision(\n sources: SourceEntry[],\n url: string,\n): SourceEntry | undefined {\n const key = sourceCacheKey(url);\n return sources.find((s) => s.url !== url && sourceCacheKey(s.url) === key);\n}\n\nfunction requireProjectYamlPath(): string {\n const root = findWorkspaceRoot(process.cwd());\n if (!root) {\n logErr(\n \"No skaile.yaml found in the current directory or any parent. \" + \"Run `skaile init` first.\",\n );\n process.exit(1);\n }\n return path.join(root, workspaceConfigFilename());\n}\n\nexport function readProjectSources(yamlPath: string): SourceEntry[] {\n if (!existsSync(yamlPath)) return [];\n try {\n return WorkspaceYamlEditor.load(yamlPath).getSources();\n } catch (err) {\n logErr(`Could not read ${yamlPath}: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Clone the source if its clone directory does not yet exist. When `force` is\n * set, the existing clone is replaced by a fresh checkout. Returns true when a\n * clone happened. The cache slug is derived from the URL.\n *\n * A `--force` re-clone moves the old clone aside first and only deletes it once\n * the fresh clone succeeds — so a failed re-clone restores the previous clone\n * rather than leaving the source registered with no cache behind it.\n */\nexport function ensureClone(entry: SourceEntry, opts: { force?: boolean } = {}): boolean {\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n let backup: string | undefined;\n if (existsSync(dest)) {\n if (!opts.force) return false;\n backup = `${dest}.bak`;\n rmSync(backup, { recursive: true, force: true });\n renameSync(dest, backup);\n }\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n // `pin` may be a branch/tag; pass it as the clone branch when present.\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"inherit\" });\n if (clone.status !== 0) {\n if (backup) {\n rmSync(dest, { recursive: true, force: true });\n renameSync(backup, dest);\n }\n logErr(`git clone failed for ${entry.url}`);\n process.exit(1);\n }\n if (backup) rmSync(backup, { recursive: true, force: true });\n return true;\n}\n\n/**\n * Refresh the machine-global manifest cache for `entry` by running discovery\n * and upserting AssetDefinitions into `~/.skaile/index.db`. Creates the\n * libraries-table cache row if missing (ownership: reader = cache state).\n */\nasync function refreshManifestCache(\n entry: SourceEntry,\n includeDev = false,\n): Promise<{\n assetsFound: number;\n assetsUpdated: number;\n errors: string[];\n advisories: string[];\n}> {\n const { manager, library, close } = await openLibraryManager();\n try {\n const name = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n const lib =\n existing ??\n (await manager.addLibrary({\n name,\n path: dest,\n backend: \"git\",\n backendConfig: { url: entry.url, branch: entry.pin ?? \"main\", authHint: \"ssh\" },\n ownership: \"reader\",\n }));\n // Curated overlay: a `skaile source manifest init` writes a curated\n // manifest to the local store at `~/.skaile/store/manifests/<slug>.yaml`.\n // When present, route discovery through it so the curated publisher +\n // asset inventory win over the upstream repo's raw glob discovery. Keyed by\n // the collision-free `storeManifestSlug` (matches the init writer + resolver).\n const overlayFile = path.join(getStoreManifestsDir(), `${storeManifestSlug(entry.url)}.yaml`);\n const catalog = new LocalCatalogSource(library, lib.id, dest, createFullRegistry(), {\n sidecarManifestFile: existsSync(overlayFile) ? overlayFile : undefined,\n });\n const result = await catalog.sync({ includeDev });\n await library.syncSource(lib.id);\n return result;\n } finally {\n close();\n }\n}\n\n/**\n * Auto-sync hook for `skaile search` on an unsynced workspace. Clones/pulls and\n * re-indexes every source declared in the project's `skaile.yaml`, then returns\n * whether the manifest cache may have changed (caller re-queries on `true`).\n *\n * Unlike `source sync`, this degrades gracefully — a clone/pull/index failure is\n * logged and skipped (never `process.exit`) so a failed auto-sync falls back to\n * the \"run sync first\" hint rather than killing the search. Returns `false`\n * (silently, no announce) when no sources are declared. Callers must guard\n * air-gapped mode themselves — this always touches the network.\n */\nexport async function autoSyncForSearch(projectDir: string): Promise<boolean> {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return false;\n if (readProjectSources(path.join(root, workspaceConfigFilename())).length === 0) return false;\n\n logInfo(\"sources not synced — syncing now…\");\n const { synced } = await syncProjectSources(projectDir);\n return synced > 0;\n}\n\n/**\n * Clone-or-pull every source declared in the project's `skaile.yaml`, then\n * refresh its manifest cache. Shared by `autoSyncForSearch` and `skaile update`\n * (the latter offers it behind a confirm) so a re-deploy can see upstream\n * commits — `update` re-deploys against the local source cache, which is\n * otherwise frozen at the commit captured when the source was first cloned.\n *\n * Graceful by design: a clone/pull/index failure for one source is logged and\n * skipped (never `process.exit`), so a single bad remote can't abort the run.\n * Existing clones are advanced with `git pull --ff-only` (no `--depth=1`, unlike\n * the installer's `pullRepo`, so it fast-forwards instead of tripping the\n * shallow-divergence path). Returns a count summary for the caller to report.\n */\nexport async function syncProjectSources(\n projectDir: string,\n opts: { dev?: boolean } = {},\n): Promise<{ total: number; synced: number; failed: number }> {\n const root = findWorkspaceRoot(projectDir) ?? projectDir;\n const sources = readProjectSources(path.join(root, workspaceConfigFilename()));\n let synced = 0;\n let failed = 0;\n for (const entry of sources) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n try {\n // Quiet git — the sync is a preparatory step; keep progress bars out of\n // the foreground output (spinner / install result).\n if (!existsSync(dest)) {\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"ignore\" });\n if (clone.status !== 0) {\n logWarn(`${slug}: git clone failed, skipping.`);\n failed++;\n continue;\n }\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"ignore\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n failed++;\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n for (const advisory of result.advisories) logInfo(`${slug}: ${advisory}`);\n synced++;\n } catch (err) {\n logWarn(`${slug}: sync failed — ${err instanceof Error ? err.message : String(err)}`);\n failed++;\n }\n }\n return { total: sources.length, synced, failed };\n}\n\n/** Remove the libraries-table cache row and (optionally) the clone bytes. */\nasync function dropManifestCache(url: string, purgeClone: boolean): Promise<void> {\n const name = sourceShortName(url);\n const { manager, close } = await openLibraryManager();\n try {\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n if (existing) {\n await manager.removeLibrary(name, { purge: false });\n }\n } finally {\n close();\n }\n if (purgeClone) {\n const dest = sourceClonePath(sourceCacheKey(url));\n if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });\n }\n}\n\nexport function makeSourceCommand(): Command {\n const cmd = new Command(\"source\").description(\n \"Manage github sources for the current project (recorded in skaile.yaml)\",\n );\n\n // ── source add ──────────────────────────────────────────────────────────\n cmd\n .command(\"add <source>\")\n .description(\n \"Clone a github repo and register it in this project's skaile.yaml. \" +\n \"<source> may be a full git URL, an owner/repo shorthand, or a bare \" +\n \"name (→ git@github.com:skaile-ai/<name>.git).\",\n )\n .option(\"--name <slug>\", \"[deprecated] no-op — the source entry stores only the URL\")\n .option(\"--pin <ref>\", \"Pin a branch, tag, or 40-char SHA\")\n .option(\"--branch <branch>\", \"[deprecated] alias for --pin\")\n .option(\"--force\", \"Remove an existing clone and re-clone\", false)\n .option(\"--dev\", \"Also index dev-only assets under the source's dev_paths\", false)\n .action(\n async (\n source: string,\n opts: {\n name?: string;\n pin?: string;\n branch?: string;\n force?: boolean;\n dev?: boolean;\n },\n ) => {\n const url = normalizeSourceUrl(source);\n const yamlPath = requireProjectYamlPath();\n\n // A different URL string that maps to the same cache key (e.g. the\n // `.git`-suffixed or scp form of an already-registered remote) would\n // fight over one clone dir. setSource only dedupes exact strings, so\n // reject the ambiguous collision here instead of silently shadowing.\n const collision = findCacheKeyCollision(readProjectSources(yamlPath), url);\n if (collision) {\n logErr(\n `\"${url}\" maps to the same cache key (${sourceCacheKey(url)}) as ` +\n `already-registered \"${collision.url}\". Remove that source first ` +\n `(skaile source remove) or re-use its exact URL to update it.`,\n );\n process.exitCode = 1;\n return;\n }\n\n if (opts.name) {\n logWarn(\n \"the --name flag is deprecated; the source entry now stores only the URL \" +\n \"(the cache slug is derived from it).\",\n );\n }\n const pin = opts.pin ?? opts.branch;\n const slug = sourceShortName(url);\n const entry: SourceEntry = { url };\n if (pin) entry.pin = pin;\n\n const dest = sourceClonePath(sourceCacheKey(url));\n const preexisting = existsSync(dest);\n // Clone/validate the repo BEFORE touching skaile.yaml — a failed clone\n // (repo not found, bad URL, network error) hard-exits in ensureClone, so\n // the entry is only ever recorded once the source is known-good.\n const cloned = ensureClone(entry, { force: opts.force });\n if (!cloned) {\n logOk(`Reusing cached clone at ${dest}`);\n } else if (preexisting) {\n logOk(`Re-cloned ${url} → ${dest}`);\n } else {\n logOk(`Cloned ${url} → ${dest}`);\n }\n\n const editor = WorkspaceYamlEditor.load(yamlPath);\n editor.setSource(entry);\n editor.save();\n\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `Indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s) from \"${slug}\".`;\n if (failed) {\n logWarn(indexedMsg);\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(err);\n for (const advisory of result.advisories) logInfo(advisory);\n\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(legacyHint);\n\n const where = path.relative(process.cwd(), yamlPath);\n if (failed) {\n // The entry IS recorded in skaile.yaml, but indexing did not fully\n // succeed — don't present it as a clean success.\n logWarn(\n `Source \"${slug}\" registered in ${where}, but ${result.errors.length} ` +\n `asset(s) failed to index (see above). Fix the cause, then re-run ` +\n `\\`skaile source sync ${slug}\\`.`,\n );\n process.exitCode = 1;\n } else {\n logOk(`Source \"${slug}\" registered in ${where}.`);\n }\n },\n );\n\n // ── source list ─────────────────────────────────────────────────────────\n cmd\n .command(\"list\")\n .description(\"List sources registered in this project's skaile.yaml\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts: { json?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (opts.json) return console.log(JSON.stringify(sources, null, 2));\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml. Run `skaile source add <git-url>` to register one.\");\n return;\n }\n console.log();\n console.log(S.heading(\" Sources\"));\n for (const s of sources) {\n const slug = sourceShortName(s.url);\n const cached = existsSync(sourceClonePath(sourceCacheKey(s.url)))\n ? \"\"\n : S.warn(\" (not cached)\");\n console.log(` ${S.cmd(slug.padEnd(24))} ${S.dim(s.url)}${cached}`);\n }\n console.log(`\\n ${S.dim(`${sources.length} source(s)`)}\\n`);\n });\n\n // ── source show ─────────────────────────────────────────────────────────\n cmd\n .command(\"show <name-or-url>\")\n .description(\"Show details for a source (matched by URL or derived slug)\")\n .action(async (key: string) => {\n const yamlPath = requireProjectYamlPath();\n const entry = readProjectSources(yamlPath).find((s) => sourceMatchesKey(s, key));\n if (!entry) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(entry.url);\n const clonePath = sourceClonePath(sourceCacheKey(entry.url));\n console.log(\n JSON.stringify(\n {\n ...entry,\n slug,\n clonePath,\n cached: existsSync(clonePath),\n },\n null,\n 2,\n ),\n );\n });\n\n // ── source remove ───────────────────────────────────────────────────────\n cmd\n .command(\"remove <name-or-url>\")\n .description(\"Remove a source from this project's skaile.yaml (matched by URL or slug)\")\n .option(\"--purge\", \"Also delete the cached clone from ~/.skaile/cache/sources/\", false)\n .action(async (key: string, opts: { purge: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const editor = WorkspaceYamlEditor.load(yamlPath);\n // Resolve to the stored URL (entries are keyed by url in the editor).\n const match = editor.getSources().find((s) => sourceMatchesKey(s, key));\n if (!match) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(match.url);\n editor.removeSource(match.url);\n editor.save();\n await dropManifestCache(match.url, opts.purge);\n logOk(\n opts.purge\n ? `Removed source \"${slug}\" and purged its clone.`\n : `Removed source \"${slug}\" from skaile.yaml (clone left in ~/.skaile/cache/sources/ — pass --purge to remove it, or run \\`skaile cache clean\\`).`,\n );\n });\n\n // ── source sync ─────────────────────────────────────────────────────────\n cmd\n .command(\"sync [name]\")\n .description(\"Pull upstream changes and refresh the manifest cache\")\n .option(\"--dev\", \"Also index dev-only assets under each source's dev_paths\", false)\n .option(\"--all\", \"Sync every source without prompting\", false)\n .action(async (key: string | undefined, opts: { dev?: boolean; all?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml.\");\n return;\n }\n\n let targets: SourceEntry[];\n if (key) {\n targets = sources.filter((s) => sourceMatchesKey(s, key));\n if (targets.length === 0) {\n logInfo(`No source matching \"${key}\".`);\n return;\n }\n } else if (opts.all || sources.length === 1 || !process.stdin.isTTY) {\n // --all, a single source, or a non-interactive shell: sync everything.\n targets = sources;\n } else {\n const selected = await p.multiselect({\n message: \"Select sources to sync\",\n options: sources.map((s) => ({\n value: s.url,\n label: sourceShortName(s.url),\n hint: s.url,\n })),\n required: true,\n });\n if (p.isCancel(selected)) {\n p.cancel(\"Cancelled.\");\n return;\n }\n const picked = new Set(selected as string[]);\n targets = sources.filter((s) => picked.has(s.url));\n }\n for (const entry of targets) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n if (!existsSync(dest)) {\n ensureClone(entry);\n logOk(`${slug}: cloned to ${dest}.`);\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"inherit\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `${slug}: indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s).`;\n if (failed) {\n logWarn(indexedMsg);\n process.exitCode = 1;\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n for (const advisory of result.advisories) logInfo(`${slug}: ${advisory}`);\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(`${slug}: ${legacyHint}`);\n }\n });\n\n // ── source patch / propose (stubs) ──────────────────────────────────────\n cmd\n .command(\"patch <ref>\")\n .description(\"Extract an asset for editing against the source\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source patch` is scaffolded but not yet wired. \" +\n \"The patch flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n cmd\n .command(\"propose <ref>\")\n .description(\"Open a PR with the patch against the source upstream\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source propose` is scaffolded but not yet wired. \" +\n \"The propose flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n // ── source manifest * ───────────────────────────────────────────────────\n addSourceManifestCommands(cmd);\n\n return cmd;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/commands/source-manifest.ts","../cli/src/commands/source.ts"],"names":["path2","existsSync","spawnSync"],"mappings":";;;;;;;;;;;;;;AA+CA,IAAM,aAAA,GACJ,2IAAA;AAGF,SAAS,SAAS,IAAA,EAAqB;AACrC,EAAA,MAAA,CAAO,CAAA,EAAG,aAAa,CAAA,wBAAA,EAA2B,IAAI,CAAA,CAAA,CAAG,CAAA;AACzD,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB;AAkBO,SAAS,gBAAA,CACd,KACA,UAAA,EACmE;AACnE,EAAA,MAAM,IAAA,GAAO,kBAAkB,UAAU,CAAA;AACzC,EAAA,MAAM,UAAA,GAA4B,OAC9B,kBAAA,CAAwB,IAAA,CAAA,IAAA,CAAK,MAAM,uBAAA,EAAyB,CAAC,CAAA,GAC7D,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,MAAA,MAAM,UAAA,GAAa,uBAAuB,IAAI,CAAA;AAC9C,MAAA,IAAI,YAAY,OAAA,CAAQ,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,UAAU,CAAA,CAAE,CAAA;AAAA,IAClD;AAAA,EACF,CAAC,CAAA;AAGH,EAAA,GAAA,CACG,OAAA,CAAQ,aAAa,CAAA,CACrB,WAAA,CAAY,iDAAiD,CAAA,CAC7D,MAAA,CAAO,CAAC,IAAA,KAAiB;AACxB,IAAA,MAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAEH,EAAA,GAAA,CACG,OAAA,CAAQ,eAAe,CAAA,CACvB,WAAA,CAAY,sDAAsD,CAAA,CAClE,MAAA,CAAO,CAAC,IAAA,KAAiB;AACxB,IAAA,MAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB,CAAC,CAAA;AAGH,EAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,EAAA,OAAO,GAAA;AACT","file":"chunk-RADBQ5XJ.js","sourcesContent":["/**\n * `skaile source manifest …` — curated `skaile.manifest.yaml` lifecycle for a\n * source you do NOT own. `init` generates a curated manifest from a discovery\n * run and stores it OUTSIDE the source, under the local store catalog\n * (`~/.skaile/store/manifests/<slug>.yaml`); `edit` opens it in `$EDITOR` and\n * re-validates on save. `source add`/`sync` then apply it as a read overlay\n * (see `source.ts` `refreshManifestCache`).\n *\n * `rebuild` refreshes a curated manifest after an upstream change (merge by\n * default — curation is sacred; `--overwrite` re-scans). `verify` is a\n * read-only integrity check (paths, declared hashes, schema, dep refs).\n * `publish`/`propose`/`yank` remain stubs — they need the store publish\n * endpoint (`POST /sources/<id>/manifest`), which lands in a follow-up.\n *\n * @docLink cli/commands/source#manifest\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n type AssetEntry,\n decodeSkaileManifest,\n encodeSkaileManifest,\n findWorkspaceRoot,\n parseAssetRef,\n resolveSourcePublisher,\n type SkPublishManifest,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n storeManifestSlug,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { computeDeterministicHash, discoverAssetsInTree } from \"@skaile/workspaces/discovery\";\nimport { getStoreManifestsDir, writeCuratedManifest } from \"@skaile/workspaces/library\";\nimport type { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport {\n ensureClone,\n normalizeSourceUrl,\n readProjectSources,\n sourceClonePath,\n sourceMatchesKey,\n} from \"./source.ts\";\n\nconst NOT_WIRED_MSG =\n \"`skaile source manifest *` is scaffolded but not yet wired. \" +\n \"Server-side endpoint (`POST /sources/<id>/manifest`) lands in a follow-up PR.\";\n\nfunction notWired(verb: string): never {\n logErr(`${NOT_WIRED_MSG} (verb: source manifest ${verb})`);\n process.exit(2);\n}\n\n/**\n * Resolve a `source manifest` argument into a `{ url, slug, dest }` triple.\n *\n * Resolution order:\n * 1. A key matching an already-registered project source (stored URL, cache\n * key, or short slug).\n * 2. A collision-free **store slug** (`<host>__<owner>__<repo>`) whose\n * manifest already exists at `~/.skaile/store/manifests/<arg>.yaml`. This\n * MUST be tried before bare-name expansion: a bare name like `cli` would\n * otherwise expand (via `normalizeSourceUrl`) to the skaile-ai org and a\n * DIFFERENT slug than the one `init` wrote (e.g. `larksuite`). The slug is\n * the exact identifier `init`'s next-step hint prints back.\n * 3. Otherwise a git URL / `owner/repo` / bare name via `normalizeSourceUrl`.\n *\n * The clone dir is the same URL-keyed cache `source add` uses.\n */\nexport function resolveSourceArg(\n arg: string,\n projectDir: string,\n): { url: string; slug: string; dest: string; manifestFile: string } {\n const root = findWorkspaceRoot(projectDir);\n const registered: SourceEntry[] = root\n ? readProjectSources(path.join(root, workspaceConfigFilename()))\n : [];\n const match = registered.find((e) => sourceMatchesKey(e, arg));\n const bySlug = !match ? resolveByStoreSlug(arg) : undefined;\n const url = match ? match.url : (bySlug?.url ?? normalizeSourceUrl(arg));\n const slug = sourceShortName(url); // human-facing label\n const dest = sourceClonePath(sourceCacheKey(url));\n return { url, slug, dest, manifestFile: bySlug?.manifestFile ?? storeManifestPath(url) };\n}\n\n/**\n * When `arg` is a bare store slug (`<host>__<owner>__<repo>`) whose curated\n * manifest already exists on disk, recover the source URL from the slug and\n * point at that manifest file directly. Returns `undefined` when the arg isn't\n * a slug or has no manifest yet (fall back to URL normalization).\n */\nfunction resolveByStoreSlug(arg: string): { url: string; manifestFile: string } | undefined {\n // A slug is our own encoding — no path/URL sigils, at least the `<host>__…`\n // separator. Anything URL/owner-repo shaped is not a slug.\n if (!/^[\\w.-]+__[\\w.-]+/.test(arg) || /[/:\\\\]/.test(arg)) return undefined;\n const manifestFile = path.join(getStoreManifestsDir(), `${arg}.yaml`);\n if (!existsSync(manifestFile)) return undefined;\n // `<host>__<owner>__<repo>` → `https://<host>/<owner>/<repo>` — good enough to\n // key the clone dir + re-derive the same slug; the manifest file is what edit\n // actually opens.\n const [host, owner, repo] = arg.split(\"__\");\n const url = host && owner && repo ? `https://${host}/${owner}/${repo}` : arg;\n return { url, manifestFile };\n}\n\n/**\n * Absolute path to a source's curated store manifest. Keyed by the\n * collision-free {@link storeManifestSlug} (`<host>__<owner>__<repo>`) so\n * `orgA/cli` and `orgB/cli` don't share `cli.yaml`.\n */\nfunction storeManifestPath(url: string): string {\n return path.join(getStoreManifestsDir(), `${storeManifestSlug(url)}.yaml`);\n}\n\n/**\n * Directory-name segments that mark a test-fixture tree. `init`/`rebuild` drop\n * any asset whose repo-relative root contains one of these as an exact path\n * SEGMENT. Repos routinely ship fixture \"skills\" under such dirs (e.g.\n * `scripts/skill-format-check/tests`, `internal/qualitygate/skillscan/testdata/skills/lark-demo`)\n * that are not real, publishable assets.\n */\nconst TEST_FIXTURE_SEGMENTS = new Set([\n \"tests\",\n \"test\",\n \"__tests__\",\n \"testdata\",\n \"fixtures\",\n \"__fixtures__\",\n]);\n\n/**\n * True when an asset's repo-relative `root` sits under a test-fixture directory\n * (see {@link TEST_FIXTURE_SEGMENTS}). Conservative, not repo-specific — finer\n * curation (keeping a genuine fixture asset) stays the user's job via `edit`.\n * `init`/`rebuild`-path only; the general discovery walk (`source add`) is\n * untouched.\n */\nfunction isTestFixtureAsset(relativePath: string): boolean {\n const segments = relativePath.replace(/\\\\/g, \"/\").split(\"/\");\n return segments.some((s) => TEST_FIXTURE_SEGMENTS.has(s));\n}\n\n/**\n * `source manifest init <src>` — clone (if needed), run discovery, and write a\n * curated `skaile.manifest.yaml` to `~/.skaile/store/manifests/<slug>.yaml`.\n */\nasync function runInit(\n arg: string,\n opts: { projectDir: string; publisher?: string; dev?: boolean; force?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (existsSync(target) && !opts.force) {\n logWarn(\n `A curated manifest already exists at ${S.dim(target)}. ` +\n \"Edit it with `skaile source manifest edit`, refresh it after an upstream \" +\n \"change with `skaile source manifest rebuild`, or pass --force to regenerate.\",\n );\n return;\n }\n\n const entry: SourceEntry = { url };\n ensureClone(entry);\n\n const { assets, errors } = discoverCuratableAssets(dest, opts.dev ?? false);\n\n const publisher = opts.publisher ?? resolveSourcePublisher(dest) ?? sourceShortName(url);\n\n const written = writeCuratedManifest({\n manifestFile: target,\n publisher,\n assets,\n force: opts.force,\n // Init: every asset inherits the top-level repo `publisher`. Do NOT stamp a\n // per-asset publisher — on the glob path each DiscoveredAsset.publisher is\n // the bare first path segment (`scripts`/`skills`/…), which would clobber\n // the intended org/`--publisher` default with junk per-asset overrides.\n inheritPublisher: true,\n });\n\n if (!written.wrote) {\n logWarn(\n `Curated manifest already exists at ${S.dim(target)} — not overwritten. ` +\n \"Pass --force to regenerate.\",\n );\n return;\n }\n\n logOk(`Wrote curated manifest with ${written.assetCount} assets to ${S.dim(target)}.`);\n // Echo the EXACT <src> the user passed so the printed commands actually run.\n // A bare short name would mis-resolve through `normalizeSourceUrl` (→ the\n // skaile-ai org, wrong slug); the original arg is what `resolveSourceArg`\n // maps back to this same manifest.\n logInfo(\n `Edit it with \\`skaile source manifest edit ${arg}\\`, then ` +\n `\\`skaile source add ${arg}\\` to consume it.`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the manifest before consuming.`);\n }\n}\n\n/**\n * Run discovery over a clone and drop the test-fixture assets (see\n * {@link isTestFixtureAsset}). Shared by `init` and `rebuild` so both paths\n * produce an identical inventory from the same tree.\n */\nfunction discoverCuratableAssets(\n dest: string,\n includeDev: boolean,\n): { assets: ReturnType<typeof discoverAssetsInTree>[\"assets\"]; errors: string[] } {\n const result = discoverAssetsInTree(dest, {\n registry: createFullRegistry(),\n includeDev,\n });\n const assets = result.assets.filter((a) => !isTestFixtureAsset(a.relativePath));\n return { assets, errors: result.errors.map((e) => `${e.path}: ${e.error}`) };\n}\n\n/**\n * Best-effort `git pull --ff-only` on an existing clone. Never throws: a pull\n * failure (offline, diverged, detached) is warned and the caller continues with\n * the clone as-is.\n */\nfunction pullCloneFfOnly(dest: string): void {\n const res = spawnSync(\"git\", [\"-C\", dest, \"pull\", \"--ff-only\"], { stdio: \"pipe\" });\n if (res.status !== 0) {\n logWarn(\n \"git pull --ff-only failed — continuing with the existing clone \" +\n \"(it may be behind upstream).\",\n );\n }\n}\n\n/**\n * Repo-relative `root` path for a manifest asset entry — the merge match key\n * between an existing curated entry and a freshly-discovered asset. `root:`\n * entries use their declared path; a `files:`-only entry (rare for a curated\n * sidecar) falls back to the entry's dirname of the first file, else the name.\n */\nfunction entryRootKey(entry: AssetEntry): string {\n if (entry.root) return entry.root.replace(/\\\\/g, \"/\").replace(/\\/+$/, \"\");\n const files = entry.files;\n if (files && files.length > 0) {\n const first = typeof files[0] === \"string\" ? files[0] : files[0].path;\n const dir = path.posix.dirname(first.replace(/\\\\/g, \"/\"));\n return dir === \".\" ? entry.name : dir;\n }\n return entry.name;\n}\n\n/** Repo-relative `root` path a discovered asset maps to (matches init's writer). */\nfunction discoveredRootKey(relativePath: string): string {\n const dir = path.posix.dirname(relativePath.replace(/\\\\/g, \"/\"));\n return dir === \".\" ? path.posix.basename(relativePath.replace(/\\\\/g, \"/\")) : dir;\n}\n\n/** Human ref for reporting: `kind:name`. */\nfunction entryRef(entry: AssetEntry): string {\n return `${entry.kind}:${entry.name}`;\n}\n\n/**\n * `source manifest rebuild <src>` — refresh a curated manifest after the\n * upstream repo changed. MERGE is the default (curation is sacred); `--overwrite`\n * re-scans from scratch with `init --force` semantics.\n *\n * Merge algorithm (match by repo-relative `root` path):\n * - Existing entries whose root is STILL discovered → KEPT verbatim (all\n * hand-edits preserved).\n * - Existing entries whose root is GONE upstream → DROPPED (reported).\n * - Freshly-discovered assets not already in the manifest → NOT auto-added,\n * only REPORTED (a curated foreign sidecar must not silently absorb new\n * upstream skills). An asset the curator deliberately dropped stays dropped\n * because it is neither in the existing manifest nor re-added here.\n */\nasync function runRebuild(\n arg: string,\n opts: { projectDir: string; publisher?: string; dev?: boolean; overwrite?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(target)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n // Update the clone: clone if absent, else pull --ff-only (best-effort).\n const entry: SourceEntry = { url };\n const cloned = ensureClone(entry);\n if (!cloned) pullCloneFfOnly(dest);\n\n const { assets: freshAssets, errors } = discoverCuratableAssets(dest, opts.dev ?? false);\n\n if (opts.overwrite) {\n logWarn(\n \"--overwrite: replacing the curated manifest with a full fresh inventory. \" +\n \"All hand-curation (dropped assets, per-asset edits) is discarded.\",\n );\n const publisher = opts.publisher ?? resolveSourcePublisher(dest) ?? sourceShortName(url);\n const written = writeCuratedManifest({\n manifestFile: target,\n publisher,\n assets: freshAssets,\n force: true,\n inheritPublisher: true,\n });\n logOk(\n `Rebuilt curated manifest with ${written.assetCount} assets to ${S.dim(target)} (overwrite).`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the manifest before consuming.`);\n }\n return;\n }\n\n // MERGE (default). `--publisher` only applies to the full re-derive path.\n if (opts.publisher) {\n logWarn(\n \"--publisher is ignored in merge mode (the curated publisher is preserved). \" +\n \"Use --overwrite to re-derive the publisher from a full re-scan.\",\n );\n }\n\n // Read the existing curated manifest and keep it as the base.\n const { manifest: existing } = decodeSkaileManifest(readFileSync(target, \"utf-8\"));\n const existingEntries = existing.assets ?? [];\n\n // Index fresh discovery by repo-relative root path.\n const freshByRoot = new Map<string, (typeof freshAssets)[number]>();\n for (const a of freshAssets) freshByRoot.set(discoveredRootKey(a.relativePath), a);\n\n const kept: AssetEntry[] = [];\n const dropped: string[] = [];\n for (const e of existingEntries) {\n if (freshByRoot.has(entryRootKey(e))) kept.push(e);\n else dropped.push(entryRef(e));\n }\n\n // Fresh assets not already curated → report as available, do NOT add.\n const existingRoots = new Set(existingEntries.map(entryRootKey));\n const newlyAvailable: string[] = [];\n for (const a of freshAssets) {\n if (!existingRoots.has(discoveredRootKey(a.relativePath))) {\n newlyAvailable.push(`${a.kind}:${a.name}`);\n }\n }\n\n const changed = dropped.length > 0;\n if (dropped.length > 0) {\n logWarn(`removed (gone upstream): ${dropped.sort().join(\", \")}`);\n }\n if (newlyAvailable.length > 0) {\n logInfo(\n `${newlyAvailable.length} new upstream asset(s) available (not added): ` +\n `${newlyAvailable.sort().join(\", \")} — add with \\`skaile source manifest edit ${arg}\\` if wanted`,\n );\n }\n\n if (!changed) {\n logOk(\"already up to date\");\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the source before re-consuming.`);\n }\n return;\n }\n\n const merged: SkPublishManifest = { ...existing, assets: kept };\n writeFileSync(target, encodeSkaileManifest(merged), \"utf-8\");\n logOk(\n `Rebuilt curated manifest: kept ${kept.length}, dropped ${dropped.length} → ${S.dim(target)}.`,\n );\n if (errors.length > 0) {\n logWarn(`${errors.length} discovery error(s) — inspect the source before re-consuming.`);\n }\n}\n\n/**\n * `source manifest verify <src>` — READ-ONLY integrity check of a curated\n * manifest against its clone. Writes nothing. Exit 0 when no errors; with\n * `--strict`, any warning also forces a nonzero exit.\n *\n * Per-asset checks:\n * - `root`/`files` paths still exist upstream (missing → error).\n * - A declared `sha256` recomputes to the same deterministic hash (mismatch → error).\n * - Schema decode diagnostics map to errors/warnings.\n * - Dependency refs parse via `parseAssetRef` (malformed → warning).\n */\nasync function runVerify(\n arg: string,\n opts: { projectDir: string; strict?: boolean },\n): Promise<void> {\n const projectDir = path.resolve(opts.projectDir);\n const { url, dest, slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(target)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n // Ensure a clone exists to verify paths/hashes against (best-effort; no pull).\n ensureClone({ url });\n\n const text = readFileSync(target, \"utf-8\");\n const { manifest, diagnostics } = decodeSkaileManifest(text);\n\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Schema diagnostics from the decoder.\n for (const d of diagnostics) {\n const line = `${d.code}: ${d.message}`;\n if (d.severity === \"error\") errors.push(line);\n else warnings.push(line);\n }\n\n const assets = manifest.assets ?? [];\n for (const entry of assets) {\n const ref = entryRef(entry);\n\n // Path existence: `root` dir and/or each `files[]` path.\n const relPaths: string[] = [];\n if (entry.root) relPaths.push(entry.root);\n if (entry.files) {\n for (const f of entry.files) relPaths.push(typeof f === \"string\" ? f : f.path);\n }\n if (relPaths.length === 0) relPaths.push(entry.name);\n for (const rel of relPaths) {\n if (!existsSync(path.join(dest, rel))) {\n errors.push(`${ref}: path not found upstream: ${rel}`);\n }\n }\n\n // Declared sha256 → recompute + compare, but ONLY for granular `files:`\n // entries. Discovery (`discover-manifest.ts`) anchors a `files:`-only entry\n // at the REPO ROOT and hashes the files VERBATIM as repo-relative strings\n // (the path is folded into the digest), so verify must hash the same way:\n // `assetRoot = dest`, files kept repo-relative — NOT rebased onto the root.\n // A `root:` entry cannot be verified this way (discovery hashes only the\n // per-kind filtered set, not the whole-dir walk), and the writer never emits\n // sha256 for `root:` entries, so skip the hash check for them.\n if (entry.sha256) {\n if (entry.files && entry.files.length > 0) {\n const hashFiles = entry.files.map((f) =>\n (typeof f === \"string\" ? f : f.path).replace(/\\\\/g, \"/\"),\n );\n const actual = computeDeterministicHash(dest, hashFiles);\n if (actual !== entry.sha256) {\n errors.push(\n `${ref}: sha256 mismatch (declared ${entry.sha256.slice(0, 12)}…, got ${actual.slice(0, 12)}…)`,\n );\n }\n } else {\n warnings.push(\n `${ref}: declared sha256 on a root:-mode entry is not verifiable (discovery hashes only the per-kind filtered set) — skipped`,\n );\n }\n }\n\n // Dependency refs parse.\n for (const dep of entry.dependencies ?? []) {\n try {\n parseAssetRef(dep);\n } catch (err) {\n warnings.push(\n `${ref}: malformed dependency \"${dep}\": ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n for (const w of warnings) logWarn(w);\n for (const e of errors) logErr(e);\n\n if (errors.length === 0) {\n logOk(`verified ${assets.length} asset(s).`);\n } else {\n logErr(`${errors.length} issue(s).`);\n }\n\n const failStrict = opts.strict && warnings.length > 0;\n if (errors.length > 0 || failStrict) process.exit(1);\n}\n\n/**\n * Split a `$VISUAL`/`$EDITOR` value into `{ command, args }` and append the file\n * as the final arg. The env value is a full command line, not a bare binary —\n * `EDITOR=\"code --wait\"` must spawn `code` with `[\"--wait\", <file>]`, and\n * `EDITOR=code` (which returns before save) is the user's problem, not ours.\n * A whitespace split covers the common editors (`code --wait`, `code -w`,\n * `subl -w`, `vi`); paths with embedded spaces are not supported (rare for an\n * editor binary and out of scope). Falls back to `vi` when unset/empty.\n *\n * @docLink cli/commands/source#manifest-edit\n */\nexport function resolveEditorCommand(\n editorEnv: string | undefined,\n target: string,\n): { command: string; args: string[] } {\n const parts = (editorEnv ?? \"\").trim().split(/\\s+/).filter(Boolean);\n const [command, ...rest] = parts.length > 0 ? parts : [\"vi\"];\n return { command: command as string, args: [...rest, target] };\n}\n\n/** Minimal spawn contract runEdit needs — lets tests inject a fake. */\ntype SpawnLike = (\n command: string,\n args: string[],\n opts: { stdio: \"inherit\" },\n) => { status: number | null };\n\n/**\n * `source manifest edit <src>` — open the curated store manifest in `$EDITOR`\n * and re-validate on save. Warnings are surfaced but never hard-fail.\n *\n * `spawn` is injectable so tests can assert the argv without launching a real\n * editor; production passes the default `spawnSync`.\n */\nexport function runEdit(\n arg: string,\n opts: { projectDir: string },\n spawn: SpawnLike = spawnSync as unknown as SpawnLike,\n): void {\n const projectDir = path.resolve(opts.projectDir);\n const { slug, manifestFile: target } = resolveSourceArg(arg, projectDir);\n\n if (!existsSync(target)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${target}. ` +\n \"Run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n const { command, args } = resolveEditorCommand(process.env.VISUAL || process.env.EDITOR, target);\n const res = spawn(command, args, { stdio: \"inherit\" });\n if (res.status !== 0 && res.status !== null) {\n logErr(`Editor exited with status ${res.status}.`);\n process.exit(1);\n }\n\n // Re-validate the saved file; surface diagnostics as warnings, don't hard-fail.\n const { diagnostics } = decodeSkaileManifest(readFileSync(target, \"utf-8\"));\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n const warnings = diagnostics.filter((d) => d.severity !== \"error\");\n if (errors.length > 0) {\n for (const d of errors) logErr(`${d.code}: ${d.message}`);\n logWarn(\"Manifest has errors — fix them before `skaile source add` will consume it.\");\n } else if (warnings.length > 0) {\n for (const d of warnings) logWarn(`${d.code}: ${d.message}`);\n logOk(\"Saved (with warnings).\");\n } else {\n logOk(\"Saved.\");\n }\n}\n\n/**\n * Append the `manifest` sub-tree to a `source` command.\n *\n * Called from `makeSourceCommand()` in `source.ts`.\n */\nexport function addSourceManifestCommands(src: Command): void {\n // enablePositionalOptions so options on the leaf verb (`source manifest init\n // --publisher …`) route to that verb instead of being rejected by `manifest`.\n const manifest = src\n .command(\"manifest\")\n .description(\"Curated manifest lifecycle for a source\")\n .enablePositionalOptions();\n\n manifest\n .command(\"init <src>\")\n .description(\"Generate a curated manifest for a source (stored in the local store catalog)\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--publisher <name>\", \"Override the publisher (default: source's GitHub org)\")\n .option(\"--dev\", \"Include assets under the source's dev_paths\", false)\n .option(\"--force\", \"Overwrite an existing curated manifest\", false)\n .action((arg, opts) => runInit(arg, opts));\n\n manifest\n .command(\"edit <src>\")\n .description(\"Open the curated manifest in $EDITOR and re-validate on save\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .action((arg, opts) => runEdit(arg, opts));\n\n manifest\n .command(\"rebuild <src>\")\n .description(\n \"Refresh a curated manifest after an upstream change (merge by default: \" +\n \"keeps curation, drops assets gone upstream, reports new ones without adding)\",\n )\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--publisher <name>\", \"Override the publisher (--overwrite only)\")\n .option(\"--dev\", \"Include assets under the source's dev_paths\", false)\n .option(\"--overwrite\", \"Discard curation and re-scan the full inventory\", false)\n .action((arg, opts) => runRebuild(arg, opts));\n\n manifest\n .command(\"verify <src>\")\n .description(\"Verify hashes, deps, and schema (read-only)\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--strict\", \"Fail on advisory checks (warnings force a nonzero exit)\", false)\n .action((arg, opts) => runVerify(arg, opts));\n\n manifest\n .command(\"publish <src>\")\n .description(\"Push the curated sidecar manifest and publish it to the store\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--as <namespace>\", \"Publisher namespace (default: your store username)\")\n .option(\"--sidecar-repo <url>\", \"Public GitHub repo you own to hold the curated manifest\")\n .option(\"--ref <gitref>\", \"Foreign source ref to ingest (branch/sha; default: main)\")\n .option(\"--dry-run\", \"Print the publish plan without pushing or calling the store\", false)\n .action(async (arg, opts) => {\n const { runPublish } = await import(\"./source-manifest-publish.ts\");\n await runPublish(arg, opts);\n });\n\n manifest\n .command(\"propose <src>\")\n .description(\"Open a PR to upstream with the sidecar manifest\")\n .action(() => notWired(\"propose\"));\n\n manifest\n .command(\"yank <src>\")\n .description(\"Retract the source's published assets from the store\")\n .option(\"-C, --project-dir <dir>\", \"Project directory\", process.cwd())\n .option(\"--asset <ref>\", \"Yank only the asset matching this ref/name\")\n .action(async (arg, opts) => {\n const { runYank } = await import(\"./source-manifest-publish.ts\");\n await runYank(arg, opts);\n });\n}\n","/**\n * `skaile source …` — manage github sources for the current project.\n *\n * A *source* is a third-party github repo of AI assets. The project's\n * `skaile.yaml` `sources:` array is the source of truth for which sources\n * this project uses. The clone itself lives at\n * `~/.skaile/cache/sources/<host>/<owner>/<repo>/` (machine-global cache, shared\n * across projects, URL-keyed so cross-org repos never collide), and the manifest is\n * mirrored into `~/.skaile/index.db` (machine-global manifest cache).\n *\n * @docLink cli/commands/source\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, renameSync, rmSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n findWorkspaceRoot,\n getGlobalCacheDir,\n type SourceEntry,\n sourceCacheKey,\n sourceShortName,\n storeManifestSlug,\n WorkspaceYamlEditor,\n workspaceConfigFilename,\n} from \"@skaile/workspaces/core\";\nimport { getStoreManifestsDir, LocalCatalogSource } from \"@skaile/workspaces/library\";\nimport * as p from \"@clack/prompts\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { openLibraryManager } from \"../open-library.ts\";\nimport { createFullRegistry } from \"../open-registry.ts\";\nimport { addSourceManifestCommands } from \"./source-manifest.ts\";\n\n/**\n * Clone dir for one source cache key (`<host>/<owner>/<repo>`). Exported for the\n * cache-path regression test. Callers pass `sourceCacheKey(url)`.\n */\nexport function sourceClonePath(key: string): string {\n return path.join(getGlobalCacheDir(), key);\n}\n\nconst SKAILE_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\nconst LEGACY_SOURCE_CONFIG_FILENAME = \".skaile-source.yaml\";\n\n/**\n * Whether a manifest-cache refresh actually failed to index something. Keyed on\n * `errors`, NOT on `assetsUpdated < assetsFound`: the discovery walk counts\n * presets (and other intentionally-not-cataloged kinds) toward `assetsFound` but\n * never upserts them, so a source shipping a `.preset.yaml` would otherwise read\n * as a partial failure — false `! N asset(s) failed to index` + exit 1 — with\n * zero real errors.\n */\nexport function indexingHadFailures(result: { errors: string[] }): boolean {\n return result.errors.length > 0;\n}\n\n/**\n * A clone that ships only the legacy `.skaile-source.yaml` (no\n * `skaile.manifest.yaml`) has its declared `publisher_default` silently ignored\n * — discovery only reads `skaile.manifest.yaml`, so publisher resolution falls\n * back to the first path segment. Surface a hint so the author can fix it.\n */\nexport function legacySourceConfigHint(dest: string): string | undefined {\n const hasLegacy = existsSync(path.join(dest, LEGACY_SOURCE_CONFIG_FILENAME));\n const hasManifest = existsSync(path.join(dest, SKAILE_MANIFEST_FILENAME));\n if (hasLegacy && !hasManifest) {\n return (\n `This source ships a legacy ${LEGACY_SOURCE_CONFIG_FILENAME} but no ` +\n `${SKAILE_MANIFEST_FILENAME}; its declared publisher is ignored and assets ` +\n `are published under their first path segment. Add a ${SKAILE_MANIFEST_FILENAME} ` +\n `(\\`skaile source manifest init\\`) to set the publisher and asset inventory.`\n );\n }\n return undefined;\n}\n\n/**\n * Normalize a `source add` argument into a clonable git URL. Full URLs and\n * scp-style (`git@host:…`) specs pass through unchanged; an `owner/repo`\n * shorthand and a bare repo name expand to GitHub over SSH — a bare name\n * defaults to the `skaile-ai` org (`git@github.com:skaile-ai/<name>.git`).\n */\nexport function normalizeSourceUrl(input: string): string {\n const s = input.trim();\n if (/^(?:https?|git|ssh|file):\\/\\//.test(s) || /^git@/.test(s)) return s;\n const repo = s.replace(/\\.git$/, \"\");\n if (/^[\\w.-]+\\/[\\w.-]+$/.test(repo)) return `git@github.com:${repo}.git`;\n if (/^[\\w.-]+$/.test(repo)) return `git@github.com:skaile-ai/${repo}.git`;\n return s;\n}\n\n/**\n * Match a stored source against a user-supplied key. Mirrors the shortcut\n * expansion `source add` applies (`normalizeSourceUrl`) so any form that `add`\n * accepted — bare name, `owner/repo`, `.git`-suffixed, full URL — also resolves\n * at `sync`/`show`/`remove` time, not just the raw stored URL or derived slug.\n */\nexport function sourceMatchesKey(entry: SourceEntry, key: string): boolean {\n if (entry.url === key) return true;\n if (sourceCacheKey(entry.url) === key || sourceShortName(entry.url) === key) return true;\n return entry.url === normalizeSourceUrl(key);\n}\n\n/**\n * Find an already-registered source that maps to the same cache key as `url`\n * but is stored under a *different* URL string (e.g. the `.git`-suffixed or\n * scp form of the same remote). Two such entries would fight over one clone\n * dir, so `source add` rejects the ambiguity. Returns the colliding entry, or\n * `undefined` when the URL is unique or only matches an exact-string duplicate\n * (which `setSource` updates in place).\n */\nexport function findCacheKeyCollision(\n sources: SourceEntry[],\n url: string,\n): SourceEntry | undefined {\n const key = sourceCacheKey(url);\n return sources.find((s) => s.url !== url && sourceCacheKey(s.url) === key);\n}\n\nfunction requireProjectYamlPath(): string {\n const root = findWorkspaceRoot(process.cwd());\n if (!root) {\n logErr(\n \"No skaile.yaml found in the current directory or any parent. \" + \"Run `skaile init` first.\",\n );\n process.exit(1);\n }\n return path.join(root, workspaceConfigFilename());\n}\n\nexport function readProjectSources(yamlPath: string): SourceEntry[] {\n if (!existsSync(yamlPath)) return [];\n try {\n return WorkspaceYamlEditor.load(yamlPath).getSources();\n } catch (err) {\n logErr(`Could not read ${yamlPath}: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Clone the source if its clone directory does not yet exist. When `force` is\n * set, the existing clone is replaced by a fresh checkout. Returns true when a\n * clone happened. The cache slug is derived from the URL.\n *\n * A `--force` re-clone moves the old clone aside first and only deletes it once\n * the fresh clone succeeds — so a failed re-clone restores the previous clone\n * rather than leaving the source registered with no cache behind it.\n */\nexport function ensureClone(entry: SourceEntry, opts: { force?: boolean } = {}): boolean {\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n let backup: string | undefined;\n if (existsSync(dest)) {\n if (!opts.force) return false;\n backup = `${dest}.bak`;\n rmSync(backup, { recursive: true, force: true });\n renameSync(dest, backup);\n }\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n // `pin` may be a branch/tag; pass it as the clone branch when present.\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"inherit\" });\n if (clone.status !== 0) {\n if (backup) {\n rmSync(dest, { recursive: true, force: true });\n renameSync(backup, dest);\n }\n logErr(`git clone failed for ${entry.url}`);\n process.exit(1);\n }\n if (backup) rmSync(backup, { recursive: true, force: true });\n return true;\n}\n\n/**\n * Refresh the machine-global manifest cache for `entry` by running discovery\n * and upserting AssetDefinitions into `~/.skaile/index.db`. Creates the\n * libraries-table cache row if missing (ownership: reader = cache state).\n */\nasync function refreshManifestCache(\n entry: SourceEntry,\n includeDev = false,\n): Promise<{\n assetsFound: number;\n assetsUpdated: number;\n errors: string[];\n advisories: string[];\n}> {\n const { manager, library, close } = await openLibraryManager();\n try {\n const name = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n const lib =\n existing ??\n (await manager.addLibrary({\n name,\n path: dest,\n backend: \"git\",\n backendConfig: { url: entry.url, branch: entry.pin ?? \"main\", authHint: \"ssh\" },\n ownership: \"reader\",\n }));\n // Curated overlay: a `skaile source manifest init` writes a curated\n // manifest to the local store at `~/.skaile/store/manifests/<slug>.yaml`.\n // When present, route discovery through it so the curated publisher +\n // asset inventory win over the upstream repo's raw glob discovery. Keyed by\n // the collision-free `storeManifestSlug` (matches the init writer + resolver).\n const overlayFile = path.join(getStoreManifestsDir(), `${storeManifestSlug(entry.url)}.yaml`);\n const catalog = new LocalCatalogSource(library, lib.id, dest, createFullRegistry(), {\n sidecarManifestFile: existsSync(overlayFile) ? overlayFile : undefined,\n });\n const result = await catalog.sync({ includeDev });\n await library.syncSource(lib.id);\n return result;\n } finally {\n close();\n }\n}\n\n/**\n * Auto-sync hook for `skaile search` on an unsynced workspace. Clones/pulls and\n * re-indexes every source declared in the project's `skaile.yaml`, then returns\n * whether the manifest cache may have changed (caller re-queries on `true`).\n *\n * Unlike `source sync`, this degrades gracefully — a clone/pull/index failure is\n * logged and skipped (never `process.exit`) so a failed auto-sync falls back to\n * the \"run sync first\" hint rather than killing the search. Returns `false`\n * (silently, no announce) when no sources are declared. Callers must guard\n * air-gapped mode themselves — this always touches the network.\n */\nexport async function autoSyncForSearch(projectDir: string): Promise<boolean> {\n const root = findWorkspaceRoot(projectDir);\n if (!root) return false;\n if (readProjectSources(path.join(root, workspaceConfigFilename())).length === 0) return false;\n\n logInfo(\"sources not synced — syncing now…\");\n const { synced } = await syncProjectSources(projectDir);\n return synced > 0;\n}\n\n/**\n * Clone-or-pull every source declared in the project's `skaile.yaml`, then\n * refresh its manifest cache. Shared by `autoSyncForSearch` and `skaile update`\n * (the latter offers it behind a confirm) so a re-deploy can see upstream\n * commits — `update` re-deploys against the local source cache, which is\n * otherwise frozen at the commit captured when the source was first cloned.\n *\n * Graceful by design: a clone/pull/index failure for one source is logged and\n * skipped (never `process.exit`), so a single bad remote can't abort the run.\n * Existing clones are advanced with `git pull --ff-only` (no `--depth=1`, unlike\n * the installer's `pullRepo`, so it fast-forwards instead of tripping the\n * shallow-divergence path). Returns a count summary for the caller to report.\n */\nexport async function syncProjectSources(\n projectDir: string,\n opts: { dev?: boolean } = {},\n): Promise<{ total: number; synced: number; failed: number }> {\n const root = findWorkspaceRoot(projectDir) ?? projectDir;\n const sources = readProjectSources(path.join(root, workspaceConfigFilename()));\n let synced = 0;\n let failed = 0;\n for (const entry of sources) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n try {\n // Quiet git — the sync is a preparatory step; keep progress bars out of\n // the foreground output (spinner / install result).\n if (!existsSync(dest)) {\n mkdirSync(path.dirname(dest), { recursive: true });\n const args = [\"clone\", entry.url, dest];\n if (entry.pin) args.splice(1, 0, \"--branch\", entry.pin);\n const clone = spawnSync(\"git\", args, { stdio: \"ignore\" });\n if (clone.status !== 0) {\n logWarn(`${slug}: git clone failed, skipping.`);\n failed++;\n continue;\n }\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"ignore\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n failed++;\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n for (const advisory of result.advisories) logInfo(`${slug}: ${advisory}`);\n synced++;\n } catch (err) {\n logWarn(`${slug}: sync failed — ${err instanceof Error ? err.message : String(err)}`);\n failed++;\n }\n }\n return { total: sources.length, synced, failed };\n}\n\n/** Remove the libraries-table cache row and (optionally) the clone bytes. */\nasync function dropManifestCache(url: string, purgeClone: boolean): Promise<void> {\n const name = sourceShortName(url);\n const { manager, close } = await openLibraryManager();\n try {\n const existing = (await manager.listLibraries()).find((l) => l.name === name);\n if (existing) {\n await manager.removeLibrary(name, { purge: false });\n }\n } finally {\n close();\n }\n if (purgeClone) {\n const dest = sourceClonePath(sourceCacheKey(url));\n if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });\n }\n}\n\nexport function makeSourceCommand(): Command {\n const cmd = new Command(\"source\").description(\n \"Manage github sources for the current project (recorded in skaile.yaml)\",\n );\n\n // ── source add ──────────────────────────────────────────────────────────\n cmd\n .command(\"add <source>\")\n .description(\n \"Clone a github repo and register it in this project's skaile.yaml. \" +\n \"<source> may be a full git URL, an owner/repo shorthand, or a bare \" +\n \"name (→ git@github.com:skaile-ai/<name>.git).\",\n )\n .option(\"--name <slug>\", \"[deprecated] no-op — the source entry stores only the URL\")\n .option(\"--pin <ref>\", \"Pin a branch, tag, or 40-char SHA\")\n .option(\"--branch <branch>\", \"[deprecated] alias for --pin\")\n .option(\"--force\", \"Remove an existing clone and re-clone\", false)\n .option(\"--dev\", \"Also index dev-only assets under the source's dev_paths\", false)\n .action(\n async (\n source: string,\n opts: {\n name?: string;\n pin?: string;\n branch?: string;\n force?: boolean;\n dev?: boolean;\n },\n ) => {\n const url = normalizeSourceUrl(source);\n const yamlPath = requireProjectYamlPath();\n\n // A different URL string that maps to the same cache key (e.g. the\n // `.git`-suffixed or scp form of an already-registered remote) would\n // fight over one clone dir. setSource only dedupes exact strings, so\n // reject the ambiguous collision here instead of silently shadowing.\n const collision = findCacheKeyCollision(readProjectSources(yamlPath), url);\n if (collision) {\n logErr(\n `\"${url}\" maps to the same cache key (${sourceCacheKey(url)}) as ` +\n `already-registered \"${collision.url}\". Remove that source first ` +\n `(skaile source remove) or re-use its exact URL to update it.`,\n );\n process.exitCode = 1;\n return;\n }\n\n if (opts.name) {\n logWarn(\n \"the --name flag is deprecated; the source entry now stores only the URL \" +\n \"(the cache slug is derived from it).\",\n );\n }\n const pin = opts.pin ?? opts.branch;\n const slug = sourceShortName(url);\n const entry: SourceEntry = { url };\n if (pin) entry.pin = pin;\n\n const dest = sourceClonePath(sourceCacheKey(url));\n const preexisting = existsSync(dest);\n // Clone/validate the repo BEFORE touching skaile.yaml — a failed clone\n // (repo not found, bad URL, network error) hard-exits in ensureClone, so\n // the entry is only ever recorded once the source is known-good.\n const cloned = ensureClone(entry, { force: opts.force });\n if (!cloned) {\n logOk(`Reusing cached clone at ${dest}`);\n } else if (preexisting) {\n logOk(`Re-cloned ${url} → ${dest}`);\n } else {\n logOk(`Cloned ${url} → ${dest}`);\n }\n\n const editor = WorkspaceYamlEditor.load(yamlPath);\n editor.setSource(entry);\n editor.save();\n\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `Indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s) from \"${slug}\".`;\n if (failed) {\n logWarn(indexedMsg);\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(err);\n for (const advisory of result.advisories) logInfo(advisory);\n\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(legacyHint);\n\n const where = path.relative(process.cwd(), yamlPath);\n if (failed) {\n // The entry IS recorded in skaile.yaml, but indexing did not fully\n // succeed — don't present it as a clean success.\n logWarn(\n `Source \"${slug}\" registered in ${where}, but ${result.errors.length} ` +\n `asset(s) failed to index (see above). Fix the cause, then re-run ` +\n `\\`skaile source sync ${slug}\\`.`,\n );\n process.exitCode = 1;\n } else {\n logOk(`Source \"${slug}\" registered in ${where}.`);\n }\n },\n );\n\n // ── source list ─────────────────────────────────────────────────────────\n cmd\n .command(\"list\")\n .description(\"List sources registered in this project's skaile.yaml\")\n .option(\"--json\", \"Output as JSON\")\n .action(async (opts: { json?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (opts.json) return console.log(JSON.stringify(sources, null, 2));\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml. Run `skaile source add <git-url>` to register one.\");\n return;\n }\n console.log();\n console.log(S.heading(\" Sources\"));\n for (const s of sources) {\n const slug = sourceShortName(s.url);\n const cached = existsSync(sourceClonePath(sourceCacheKey(s.url)))\n ? \"\"\n : S.warn(\" (not cached)\");\n console.log(` ${S.cmd(slug.padEnd(24))} ${S.dim(s.url)}${cached}`);\n }\n console.log(`\\n ${S.dim(`${sources.length} source(s)`)}\\n`);\n });\n\n // ── source show ─────────────────────────────────────────────────────────\n cmd\n .command(\"show <name-or-url>\")\n .description(\"Show details for a source (matched by URL or derived slug)\")\n .action(async (key: string) => {\n const yamlPath = requireProjectYamlPath();\n const entry = readProjectSources(yamlPath).find((s) => sourceMatchesKey(s, key));\n if (!entry) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(entry.url);\n const clonePath = sourceClonePath(sourceCacheKey(entry.url));\n console.log(\n JSON.stringify(\n {\n ...entry,\n slug,\n clonePath,\n cached: existsSync(clonePath),\n },\n null,\n 2,\n ),\n );\n });\n\n // ── source remove ───────────────────────────────────────────────────────\n cmd\n .command(\"remove <name-or-url>\")\n .description(\"Remove a source from this project's skaile.yaml (matched by URL or slug)\")\n .option(\"--purge\", \"Also delete the cached clone from ~/.skaile/cache/sources/\", false)\n .action(async (key: string, opts: { purge: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const editor = WorkspaceYamlEditor.load(yamlPath);\n // Resolve to the stored URL (entries are keyed by url in the editor).\n const match = editor.getSources().find((s) => sourceMatchesKey(s, key));\n if (!match) {\n logErr(`No source matching \"${key}\" in ${yamlPath}.`);\n process.exit(1);\n }\n const slug = sourceShortName(match.url);\n editor.removeSource(match.url);\n editor.save();\n await dropManifestCache(match.url, opts.purge);\n logOk(\n opts.purge\n ? `Removed source \"${slug}\" and purged its clone.`\n : `Removed source \"${slug}\" from skaile.yaml (clone left in ~/.skaile/cache/sources/ — pass --purge to remove it, or run \\`skaile cache clean\\`).`,\n );\n });\n\n // ── source sync ─────────────────────────────────────────────────────────\n cmd\n .command(\"sync [name]\")\n .description(\"Pull upstream changes and refresh the manifest cache\")\n .option(\"--dev\", \"Also index dev-only assets under each source's dev_paths\", false)\n .option(\"--all\", \"Sync every source without prompting\", false)\n .action(async (key: string | undefined, opts: { dev?: boolean; all?: boolean }) => {\n const yamlPath = requireProjectYamlPath();\n const sources = readProjectSources(yamlPath);\n if (sources.length === 0) {\n logInfo(\"No sources in skaile.yaml.\");\n return;\n }\n\n let targets: SourceEntry[];\n if (key) {\n targets = sources.filter((s) => sourceMatchesKey(s, key));\n if (targets.length === 0) {\n logInfo(`No source matching \"${key}\".`);\n return;\n }\n } else if (opts.all || sources.length === 1 || !process.stdin.isTTY) {\n // --all, a single source, or a non-interactive shell: sync everything.\n targets = sources;\n } else {\n const selected = await p.multiselect({\n message: \"Select sources to sync\",\n options: sources.map((s) => ({\n value: s.url,\n label: sourceShortName(s.url),\n hint: s.url,\n })),\n required: true,\n });\n if (p.isCancel(selected)) {\n p.cancel(\"Cancelled.\");\n return;\n }\n const picked = new Set(selected as string[]);\n targets = sources.filter((s) => picked.has(s.url));\n }\n for (const entry of targets) {\n const slug = sourceShortName(entry.url);\n const dest = sourceClonePath(sourceCacheKey(entry.url));\n if (!existsSync(dest)) {\n ensureClone(entry);\n logOk(`${slug}: cloned to ${dest}.`);\n } else {\n const pull = spawnSync(\"git\", [\"pull\", \"--ff-only\"], { cwd: dest, stdio: \"inherit\" });\n if (pull.status !== 0) {\n logWarn(`${slug}: git pull failed, skipping manifest refresh.`);\n continue;\n }\n }\n const result = await refreshManifestCache(entry, opts.dev);\n const failed = indexingHadFailures(result);\n const indexedMsg = `${slug}: indexed ${result.assetsUpdated} of ${result.assetsFound} asset(s).`;\n if (failed) {\n logWarn(indexedMsg);\n process.exitCode = 1;\n } else {\n logOk(indexedMsg);\n }\n for (const err of result.errors) logWarn(`${slug}: ${err}`);\n for (const advisory of result.advisories) logInfo(`${slug}: ${advisory}`);\n const legacyHint = legacySourceConfigHint(dest);\n if (legacyHint) logWarn(`${slug}: ${legacyHint}`);\n }\n });\n\n // ── source patch / propose (stubs) ──────────────────────────────────────\n cmd\n .command(\"patch <ref>\")\n .description(\"Extract an asset for editing against the source\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source patch` is scaffolded but not yet wired. \" +\n \"The patch flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n cmd\n .command(\"propose <ref>\")\n .description(\"Open a PR with the patch against the source upstream\")\n .action((_ref: string) => {\n logErr(\n \"`skaile source propose` is scaffolded but not yet wired. \" +\n \"The propose flow lands in a follow-up PR.\",\n );\n process.exit(2);\n });\n\n // ── source manifest * ───────────────────────────────────────────────────\n addSourceManifestCommands(cmd);\n\n return cmd;\n}\n"]}
|
|
@@ -43,8 +43,8 @@ function isUserInvokable(cap) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// types/src/version.ts
|
|
46
|
-
var PROTOCOL_VERSION = { major: 3, minor:
|
|
47
|
-
var PROTOCOL_VERSION_STRING = "3.
|
|
46
|
+
var PROTOCOL_VERSION = { major: 3, minor: 7, patch: 0 };
|
|
47
|
+
var PROTOCOL_VERSION_STRING = "3.7.0";
|
|
48
48
|
function parseVersion(s) {
|
|
49
49
|
const parts = s.split(".");
|
|
50
50
|
if (parts.length !== 3) {
|
|
@@ -64,5 +64,5 @@ function formatVersion(v) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export { MENTION_GROUPS, PROTOCOL_VERSION, PROTOCOL_VERSION_STRING, QUICK_REACTIONS, formatVersion, isRenderCapability, isUserInvokable, parseVersion };
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
68
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-RDE43ORT.js.map
|
|
68
|
+
//# sourceMappingURL=chunk-RDE43ORT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../types/src/mentions.ts","../types/src/reactions.ts","../types/src/capabilities.ts","../types/src/version.ts"],"names":[],"mappings":";AAmBO,IAAM,iBAAiB,CAAC,OAAA,EAAS,QAAA,EAAU,aAAA,EAAe,QAAQ,KAAK;;;ACevE,IAAM,eAAA,GAAkB;AAAA,EAC7B,WAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;;;AC8LO,SAAS,mBAAmB,GAAA,EAA0C;AAC3E,EAAA,OAAO,IAAI,MAAA,KAAW,MAAA;AACxB;AAs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AACxB,EAAA,MAAM,KAAA,GAAQ,OAAO,GAAG,CAAA;AACxB,EAAA,IACE,CAAC,OAAO,SAAA,CAAU,KAAK,KACvB,CAAC,MAAA,CAAO,UAAU,KAAK,CAAA,IACvB,CAAC,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IACvB,KAAA,GAAQ,KACR,KAAA,GAAQ,CAAA,IACR,QAAQ,CAAA,EACR;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0BAAA,EAA6B,CAAC,CAAA,4CAAA,CAA8C,CAAA;AAAA,EAC9F;AACA,EAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAM;AAC/B;AAiBO,SAAS,cAAc,CAAA,EAA4B;AACxD,EAAA,OAAO,CAAA,EAAG,EAAE,KAAK,CAAA,CAAA,EAAI,EAAE,KAAK,CAAA,CAAA,EAAI,EAAE,KAAK,CAAA,CAAA;AACzC","file":"chunk-TSB46BHR.js","sourcesContent":["/**\n * Mentions — types for @-mention support in session messages.\n *\n * A Mention records who was addressed in a message, whether a specific user\n * or a well-known group. Group mentions carry a resolved array of user IDs\n * so consumers can perform membership checks without the resolver.\n */\n\n// ---------------------------------------------------------------------------\n// Groups\n// ---------------------------------------------------------------------------\n\n/**\n * Well-known group mention targets as a `const` array.\n *\n * Use this for validation or exhaustive checks against `MentionGroup`.\n *\n * @docLink packages/types/messages#mention\n */\nexport const MENTION_GROUPS = [\"agent\", \"humans\", \"humans_here\", \"here\", \"all\"] as const;\n\n/**\n * A well-known group that can be `@`-mentioned: `'agent' | 'humans' | 'humans_here' | 'here' | 'all'`.\n *\n * @docLink packages/types/messages#mention\n */\nexport type MentionGroup = (typeof MENTION_GROUPS)[number];\n\n// ---------------------------------------------------------------------------\n// Mention discriminated union\n// ---------------------------------------------------------------------------\n\n/**\n * A parsed `@`-mention in a session message. Records who was addressed — either a\n * specific user or a well-known group — along with the source text position.\n *\n * Group mentions carry a resolved array of user IDs so consumers can perform\n * membership checks without needing the resolver.\n *\n * @docLink packages/types/messages#mention\n */\nexport type Mention =\n | {\n type: \"user\";\n userId: string;\n name: string;\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n }\n | {\n type: \"group\";\n group: MentionGroup;\n /** User IDs resolved at parse time (e.g. all online users for `@here`). */\n resolved: string[];\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n }\n | {\n type: \"custom\";\n /** Consumer-defined mention kind, e.g. \"assistant\". */\n kind: string;\n /** User IDs this mention resolves to (so isMentioned works); may be empty. */\n resolved: string[];\n /** Optional consumer payload, e.g. { sessionId, ownerId }. */\n data?: Record<string, unknown>;\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n };\n","/**\n * Reactions -- emoji reactions on session messages.\n *\n * Any session participant (user or agent) can react to any message.\n * Reactions are persisted in a dedicated DB model and broadcast as\n * transient events for real-time updates.\n */\n\n/**\n * A single emoji reaction on a message, set by any session participant (user or agent).\n *\n * Reactions are persisted in a dedicated DB model and broadcast as transient events\n * for real-time updates.\n *\n * @docLink packages/types/messages#reaction\n */\nexport type Reaction = {\n /** Unicode emoji character (e.g. \"thumbs up\", not \":thumbsup:\"). */\n emoji: string;\n /** ID of the user (or \"agent\" for agent reactions). */\n userId: string;\n /** Display name at reaction time (avoids extra lookups for tooltip rendering). */\n userName: string;\n /** Unix epoch milliseconds. */\n timestamp: number;\n};\n\n/**\n * Quick-access emojis shown in the reaction bar picker.\n *\n * An `as const` array of eight Unicode emoji characters in display order.\n *\n * @docLink packages/types/messages#reaction\n */\nexport const QUICK_REACTIONS = [\n \"\\u{1F44D}\",\n \"\\u{1F440}\",\n \"\\u2705\",\n \"\\u2764\\uFE0F\",\n \"\\u{1F914}\",\n \"\\u{1FAE1}\",\n \"\\u{1F44F}\",\n \"\\u{1F389}\",\n] as const;\n","/**\n * Capability layer — Protocol v2's unified registry of LLM-invokable entry points.\n *\n * A {@link Capability} is a named, schema-typed entry point that the LLM can call\n * during a session. Capabilities are registered into a per-session\n * registry by either side (host platform via `side: 'client'` or runtime via\n * `side: 'agent'`) and routed by the bridge at invocation time.\n *\n * This module defines the wire types only; the runtime registry, the\n * `defineCapability` helper, and the per-handler logger live in\n * `@skaile/workspaces/runner`.\n *\n * @see {@link MessageV2} envelope that carries capability commands and events\n * @see {@link ProtocolVersion} for the version contract\n *\n * @category Capabilities\n * @since 2.0.0\n */\n\n// ---------------------------------------------------------------------------\n// Capability shape\n// ---------------------------------------------------------------------------\n\n/**\n * Visibility scope for a capability. Determines which surfaces the capability\n * appears on and which callers can invoke it.\n *\n * - `'llm'`: registered as an LLM tool, surfaced in the `<CAPABILITIES>` system\n * prompt section. The agent driver can invoke it.\n * - `'user'`: appears in user-facing surfaces — the command palette (cmdK),\n * debug menus, capability lists.\n * - `'runtime'`: invocable only by trusted runner / platform code paths. Never\n * reaches the LLM tool list. Never reaches the command palette. Used for\n * host RPCs (`host.refresh_credential`, `host.audit`, `host.notify_user`,\n * `host.persist_compaction_attempt`) and runner RPCs (`runner.add_mount`,\n * `runner.set_log_level`, `runner.lifecycle`, ...).\n *\n * Multiple audiences are allowed (e.g. `['llm', 'user']`). The default when\n * {@link Capability.audience} is omitted is `['llm', 'user']`, preserving the\n * v2.x default visibility for capabilities that haven't migrated yet.\n *\n * @category Capabilities\n * @since 3.0.0\n * @docLink packages/types/capabilities#capability-audience\n */\nexport type CapabilityAudience = \"llm\" | \"user\" | \"runtime\";\n\n/**\n * Source of truth for who registered a capability. Used for trust enforcement\n * (the bridge rejects mismatches between registering side and origin kind)\n * and for the `capability:<origin>:<name>` log taxonomy.\n *\n * Variants:\n * - `framework`: built-in (e.g. `__capabilities.list`)\n * - `client`: host platform (e.g. `platform.react`)\n * - `agent`: self-registered by the agent runtime\n * - `flow`: injected by an active flow execution\n * - `skill`: from a skill's MCP surface\n * - `mcp`: from a generic MCP server\n * - `connector`: from a connector (e.g. `postgres.query`)\n * - `mount`: surfaced by a filesystem mount\n * - `app`: from an embedded, agent-controllable app (carries the originating\n * `appId`). Handlers run in the app itself — see {@link Capability.side} `'app'`.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-origin\n */\nexport type CapabilityOrigin =\n | { kind: \"framework\" }\n | { kind: \"client\" }\n | { kind: \"agent\" }\n | { kind: \"flow\"; flowId: string }\n | { kind: \"skill\"; skillId: string }\n | { kind: \"mcp\"; serverId: string }\n | { kind: \"connector\"; connectorId: string }\n | { kind: \"mount\"; mountId: string }\n | { kind: \"app\"; appId: string };\n\n/**\n * Render contract for a capability that produces a UI surface when invoked.\n *\n * When the LLM invokes a capability whose `render` is set, the bridge emits\n * a {@link RenderInvokedEvent} carrying the capability name and props. The\n * client renders the configured `source` at the chosen `target`. Clients\n * without a render layer can fall back to the markdown `fallback` template.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-spec\n */\nexport type RenderSpec = {\n /** Where the rendered component lives. */\n source: { kind: \"web-component\"; url: string; tagName: string } | { kind: \"iframe\"; url: string };\n /** Render placements supported by the component. */\n targets: (\"chat\" | \"preview\" | \"modal\" | \"input-extension\")[];\n /** Markdown template with `{{prop}}` placeholders for clients without a render layer. */\n fallback?: string;\n /** True when props may be partial during streaming. */\n streaming?: boolean;\n /** Interaction names the rendered component may fire back as state events. */\n interactions?: string[];\n};\n\n/**\n * A named, schema-typed entry point that the LLM can invoke during a session.\n *\n * Capabilities can be declared statically (via `ConfigureCommand.capabilities`)\n * or dynamically (via {@link CapabilityRegisterCommand} /\n * {@link CapabilityRegisterEvent}). They are cached for replay across\n * subscriber reconnects and session hibernation.\n *\n * @example Defining a client-side fire-and-forget tool (uses the runner's\n * `defineCapability` helper, which serializes a {@link Capability} to the wire):\n * ```ts\n * const reactTool = defineCapability({\n * name: 'platform.react',\n * description: 'Acknowledge a user message with a Unicode emoji.',\n * side: 'client',\n * origin: { kind: 'client' },\n * fireAndForget: true,\n * input: z.object({ emoji: z.string(), targetSeq: z.number().optional() }),\n * handler: async ({ emoji, targetSeq }, ctx) => { ... },\n * });\n * ```\n *\n * @see {@link RenderCapability} for capabilities that render UI components\n * @see {@link CapabilityOrigin} for who-registered-it metadata\n * @see {@link isRenderCapability} for the type-guard\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability\n */\nexport type Capability = {\n /** Unique within a session. Convention: namespaced as `<origin>.<name>` (e.g. `platform.react`, `ui.gif`). */\n name: string;\n /**\n * Human-readable label for user-facing surfaces (cmdK action palette,\n * capability menus, debug panels). Falls back to {@link Capability.name}\n * when omitted. Pure presentation — the LLM sees `name`, not `displayName`.\n */\n displayName?: string;\n /** Human/LLM-readable summary. Shown to the LLM as part of tool registration. */\n description: string;\n /** JSON Schema validating the invocation arguments. Authored as Zod, converted at register time. */\n inputSchema: Record<string, unknown>;\n /** Optional return shape. Omit for fire-and-forget effects. */\n outputSchema?: Record<string, unknown>;\n /** Where the handler runs. `client` = host platform, `agent` = runtime/skill/connector, `app` = embedded app. */\n side: \"client\" | \"agent\" | \"app\";\n /** Discriminated tag identifying who registered the capability. Used for trust enforcement and audit. */\n origin: CapabilityOrigin;\n /** Lifetime: `session` survives the whole session, `turn` is dropped at end-of-turn. */\n scope?: \"session\" | \"turn\";\n /** When true, the bridge auto-resolves with `{}` immediately and runs the handler in the background. */\n fireAndForget?: boolean;\n /** When true, the platform shows a confirm UI before dispatch and waits for {@link CapabilityApproveCommand}. */\n requiresApproval?: boolean;\n /** Documentation hint (not enforced) describing whether this is a side-effect, render, or pure query. */\n kind?: \"effect\" | \"render\" | \"query\";\n /**\n * Whether this capability should be exposed in user-facing surfaces (cmdK\n * action palette, capability menus). When omitted, the consumer applies a\n * default per-origin via {@link isUserInvokable}.\n *\n * - `true`: surface in cmdK and capability menus.\n * - `false`: hide from user surfaces (LLM-only or low-level).\n * - `undefined`: defer to {@link isUserInvokable}'s inference rules.\n *\n * @deprecated Set {@link Capability.audience} instead. `userInvokable` is\n * kept as a read-only shim for v2.x consumers and is honoured by\n * {@link isUserInvokable} when {@link Capability.audience} is absent.\n */\n userInvokable?: boolean;\n /**\n * Audience scoping for this capability. See {@link CapabilityAudience} for\n * the meaning of each value and combinations.\n *\n * When omitted, consumers treat the capability as `['llm', 'user']` (the\n * v2.x default). Host RPCs and runner RPCs MUST set this to `['runtime']`\n * so they never leak to the LLM tool list or the user-facing surfaces.\n *\n * @category Capabilities\n * @since 3.0.0\n */\n audience?: CapabilityAudience[];\n /** Appended to the system prompt's `<CAPABILITIES>` section. Use for usage hints the LLM should always see. */\n promptFragment?: string;\n /**\n * Per-capability override for how long the runner waits on the\n * `capability_result` round-trip before timing out. When omitted the\n * runner applies its default (`DEFAULT_CAPABILITY_CALL_TIMEOUT_MS`, 60s).\n *\n * Set this for capabilities that legitimately block far longer than a\n * normal tool call — e.g. `platform.ask_session` suspends the caller's\n * turn until a peer session answers, which can take minutes.\n *\n * @category Capabilities\n * @since 3.3.0\n */\n callTimeoutMs?: number;\n /** Present iff this is a render capability — see {@link RenderCapability}. */\n render?: RenderSpec;\n};\n\n/**\n * A {@link Capability} that produces a UI surface when invoked. The narrowed\n * type guarantees `render` is set, which simplifies frontend lookup.\n *\n * @see {@link isRenderCapability}\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-capability\n */\nexport type RenderCapability = Capability & { render: NonNullable<Capability[\"render\"]> };\n\n/**\n * Type-guard for {@link RenderCapability}. Use after {@link Capability}\n * lookup to narrow the type before reading `render`.\n *\n * @example\n * ```ts\n * for (const cap of registry.list()) {\n * if (isRenderCapability(cap)) console.log(cap.render.targets);\n * }\n * ```\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#is-render-capability\n */\nexport function isRenderCapability(cap: Capability): cap is RenderCapability {\n return cap.render !== undefined;\n}\n\n/**\n * Decide whether a capability should be surfaced in user-facing actions\n * (cmdK action palette, capability menus).\n *\n * Resolution order (first match wins):\n *\n * 1. {@link Capability.audience} is set — return `audience.includes('user')`.\n * Capabilities scoped to `'runtime'` only never appear in user surfaces.\n * 2. {@link Capability.userInvokable} is set (v2.x shim) — return that value.\n * 3. Default per-origin inference table below.\n *\n * Default-inference rules (when both `audience` and `userInvokable` are\n * omitted):\n * | Origin | Default |\n * | ------------ | ---------------------------------------------------------------------- |\n * | `framework` | `false` (LLM discovery surfaces, e.g. `__capabilities.list`) |\n * | `client` | `false` (platform ack tools — `platform.react`, `platform.pass`) |\n * | `agent` | `false` (agent-defined; assume internal unless flagged) |\n * | `flow` | `false` (per-cap opt-in) |\n * | `connector` | `false` (low-level FS / data ops) |\n * | `mount` | `false` (low-level FS ops) |\n * | `app` | `false` (LLM-only; app authors opt in via `audience: ['llm','user']`) |\n * | `mcp` | `true` if `kind === 'effect'`, else `false` |\n * | `skill` | `true` if `kind` ∈ {`effect`, `render`}, else `false` |\n *\n * @example\n * ```ts\n * for (const cap of capabilities.values()) {\n * if (isUserInvokable(cap)) registerCommandPaletteAction(cap);\n * }\n * ```\n *\n * @category Capabilities\n * @since 2.1.0\n * @docLink packages/types/capabilities#is-user-invokable\n */\nexport function isUserInvokable(cap: Capability): boolean {\n if (cap.audience !== undefined) {\n return cap.audience.includes(\"user\");\n }\n if (cap.userInvokable !== undefined) {\n return cap.userInvokable;\n }\n switch (cap.origin.kind) {\n case \"framework\":\n case \"client\":\n case \"agent\":\n case \"flow\":\n case \"connector\":\n case \"mount\":\n case \"app\":\n return false;\n case \"mcp\":\n return cap.kind === \"effect\";\n case \"skill\":\n return cap.kind === \"effect\" || cap.kind === \"render\";\n default:\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Capability commands (client → agent)\n// ---------------------------------------------------------------------------\n\n/**\n * Register one or more capabilities mid-session (client → agent).\n *\n * The platform sends this when a new client-side tool becomes available\n * after `configure` has already returned (e.g. a user installs a new\n * extension during the session).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-register-command\n */\nexport type CapabilityRegisterCommand = {\n type: \"capability_register\";\n capabilities: Capability[];\n};\n\n/**\n * Deregister capabilities by name (client → agent). Names that are not\n * currently registered are ignored silently.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-deregister-command\n */\nexport type CapabilityDeregisterCommand = {\n type: \"capability_deregister\";\n names: string[];\n};\n\n/**\n * Return the result of a previously {@link CapabilityInvokedEvent | invoked} client-side\n * capability (client → agent). Bridges that registered the capability with\n * `fireAndForget: true` MAY skip this command; the bridge auto-resolves with `{}`.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-result-command\n */\nexport type CapabilityResultCommand = {\n type: \"capability_result\";\n /** Correlation token matching the {@link CapabilityInvokedEvent.callId}. */\n callId: string;\n /** Successful result payload, or an error envelope. */\n result: unknown | { error: string };\n};\n\n/**\n * Approve or reject a capability call that was invoked with\n * `requiresApproval: true` (client → agent). The platform shows a confirm\n * UI and forwards the user's decision via this command.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-approve-command\n */\nexport type CapabilityApproveCommand = {\n type: \"capability_approve\";\n /** Correlation token matching the {@link CapabilityInvokedEvent.callId}. */\n callId: string;\n /** User's decision. */\n decision: \"approved\" | \"rejected\";\n /** Optional rationale stored alongside the decision for audit. */\n feedback?: string;\n /** User ID of the decider (informational — framework enforces no policy). */\n decidedBy: string;\n};\n\n// ---------------------------------------------------------------------------\n// Capability events (agent → client)\n// ---------------------------------------------------------------------------\n\n/**\n * Register one or more capabilities mid-session (agent → client). Mirrors\n * {@link CapabilityRegisterCommand} for the agent-initiated direction; used\n * when the runtime adds a capability after `configure` (e.g. when a flow\n * starts and injects flow-scoped tools).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-register-event\n */\nexport type CapabilityRegisterEvent = {\n type: \"capability_register\";\n capabilities: Capability[];\n};\n\n/**\n * Deregister capabilities by name (agent → client).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-deregister-event\n */\nexport type CapabilityDeregisterEvent = {\n type: \"capability_deregister\";\n names: string[];\n};\n\n/**\n * Notify the client that a capability has been invoked by the LLM (agent →\n * client). For client-side capabilities the platform's handler runs in\n * response to this event and replies with {@link CapabilityResultCommand}.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-invoked-event\n */\nexport type CapabilityInvokedEvent = {\n type: \"capability_invoked\";\n /** Correlation token for the eventual {@link CapabilityResultCommand}. */\n callId: string;\n /** Name of the invoked {@link Capability}. */\n name: string;\n /** Validated input payload (already conforms to the capability's `inputSchema`). */\n input: unknown;\n /** In v2.0.0 the LLM is the only invoker. */\n invokedBy: \"agent\";\n};\n\n/**\n * Notify the client that a render capability should be drawn (agent →\n * client). Emitted alongside {@link CapabilityInvokedEvent} when the\n * invoked capability's `render` block is populated.\n *\n * Clients without a render layer can fall back to the capability's\n * `render.fallback` markdown template.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-invoked-event\n */\nexport type RenderInvokedEvent = {\n type: \"render_invoked\";\n /** Name of the invoked render capability. */\n capabilityName: string;\n /** Props passed to the rendered component (already conforms to `inputSchema`). */\n props: unknown;\n /** Correlation token shared with the matching {@link CapabilityInvokedEvent}. */\n callId: string;\n};\n","/**\n * Protocol versioning primitives for Skaile Agent Protocol v2.\n *\n * The protocol is versioned by a structured {@link ProtocolVersion} record\n * (`major.minor.patch`). The compatibility rule applied at handshake is\n * **major-equality**: a runner emits {@link IncompatibleProtocolEvent} and\n * shuts down when its declared major does not match the platform's announced\n * major. Minor and patch differences ride through transparently because\n * unknown fields are preserved on round-trip (see `MessageMeta` round-trip\n * contract in `messaging.ts`).\n *\n * @category Protocol\n * @since 2.0.0\n */\n\n/**\n * Structured semantic version triple for the agent protocol.\n *\n * @example\n * ```ts\n * const v: ProtocolVersion = { major: 2, minor: 0, patch: 0 };\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#protocol-version\n */\nexport type ProtocolVersion = {\n /** Incremented on breaking wire-format changes (field removed, semantics changed, required field added). */\n major: number;\n /** Incremented on additive wire-format changes (new optional fields, new event types). */\n minor: number;\n /** Incremented on bug-fix or doc-only changes that do not affect the wire. */\n patch: number;\n};\n\n/**\n * The protocol version the framework currently speaks. Runners and platforms\n * compare this against the peer's announced version at session boot via\n * `SessionInitCommand.protocolVersion`.\n *\n * @example\n * ```ts\n * import { PROTOCOL_VERSION } from '@skaile/workspaces/types';\n * if (cmd.protocolVersion.major !== PROTOCOL_VERSION.major) {\n * emit({ type: 'incompatible_protocol', agentVersion: PROTOCOL_VERSION, platformVersion: cmd.protocolVersion });\n * }\n * ```\n *\n * @category Protocol\n * @since 3.0.0\n *\n * Changed in 3.6.0:\n * Additive resolved-agent-config wire field. `ResolvedSkaileConfig` gains an\n * optional `agentConfig?: ResolvedAgentConfig` carrying the platform-resolved\n * driver / provider / model / cloud / cloudConfig / thinking / effort — the\n * same values the platform bakes into the generated skaile.yaml\n * `agent-config.default`. The runner applies it disk-first: any on-disk\n * `agent-config` profile with at least one agent setting disables the wire\n * value outright, so yaml-on-disk (docker-mode) sessions are byte-identical.\n * Additive under the major-equality rule: an older runner ignores the field\n * and an older platform simply omits it.\n *\n * Changed in 3.5.0:\n * Flow-connector host-contract fix (workspaces#379). Three coordinated changes,\n * all additive under the major-equality rule:\n * - `op:\"hydrate\"` on the bare `\"flow\"` connector now auto-creates the\n * `flow:<runId>` connector on a cold container from its `{ state, flow }`\n * payload, so a persisted run rehydrates in one op. A peer that still issues\n * `start` then `hydrate` keeps working unchanged.\n * - The dead `SessionInit.activeFlows` field (never read by the runner) and its\n * `ActiveFlowRehydration` type are removed — wire-compatible (nothing produced\n * or consumed them) but source-breaking for typed hosts, hence the bump.\n * - Malformed / conflicting flow `start` and `hydrate` payloads now fail loudly\n * (warn with a reason) instead of silently falling through.\n * Because the handshake compares only `major`, a 3.4 host and a 3.5 runner\n * interoperate: the auto-create path is opt-in on the payload the host sends, and\n * the removed field was already inert. Spec: `runner/MIGRATION-flow-connector.md`.\n *\n * Changed in 3.4.0:\n * Additive embedded-app capability source. `CapabilityOrigin` gains a\n * `{ kind: 'app'; appId: string }` variant and `Capability.side` gains `'app'`\n * (\"the handler runs in the embedded app\"). Both are additive: a peer that does\n * not understand `origin:'app'` / `side:'app'` never produces or routes them, so\n * they ride through transparently under the major-equality rule. No new message\n * types — `capability_register` / `capability_invoked` / `capability_result` /\n * `capability_approve` / `render_invoked` are reused verbatim. Spec:\n * `_devlog/specs/2026-07-07-app-capability-source.md`.\n *\n * Changed in 3.3.0:\n * Additive agent-to-agent (session-to-session) communication extension.\n * `AgentEvent` gains an `a2a_message` variant carrying cross-session messages\n * (`direction`, `peerSessionId`, `peerName`, `exchangeId`, `text`). `Capability`\n * gains an optional `callTimeoutMs?: number` so a long-running capability call\n * (e.g. a 5-minute `platform.ask_session`) can exceed the default capability-call\n * timeout. Both are additive: a peer that does not understand them ignores the\n * event / falls back to the default timeout, so they ride through transparently\n * under the major-equality rule.\n *\n * Changed in 3.2.0:\n * Additive wake-time resume cascade. `AgentReconfigureOptions` gains optional\n * `resumeSessionId` and `expectedCapabilitySignature` fields driving the tier-1\n * native SDK resume path; `AgentEvent` gains `ResumeAttemptedEvent` and\n * `ResumeFailedEvent`. `FinishedEvent` gains optional `customType` /\n * `customData` for capability-routed custom payloads. All additive — clients\n * that omit the resume hint or ignore the new events keep working unchanged.\n *\n * Changed in 3.1.0:\n * Additive cost / token usage extension. `FinishedEvent` gains an optional\n * `tokens?: TokenUsage` field carrying per-turn input / output / cache-read /\n * cache-creation / reasoning token counts. `AgentDriver.getTokenUsage()` is\n * widened to return the same `TokenUsage` shape (existing consumers reading\n * `inputTokens` / `outputTokens` keep working unchanged). Drivers that do not\n * surface token usage continue to return `null` / omit the field.\n *\n * Changed in 3.0.0:\n * Major bump for the deterministic session bootstrap rewrite. `ConfigureCommandV2`,\n * `provision_secrets`, `request_access_token`, `add_resource`, `remove_resource`,\n * `set_log_level`, `state_action`, `lifecycle`, `remount_mount`, `compact`, and\n * `reconfigure_agent` are removed from the `AgentCommand` union. Their semantics\n * are reachable through:\n * - `session_init` (one deterministic envelope at session start that delivers\n * identity, resolved config, pre-minted credentials, secrets, capabilities,\n * shared state, active flows, resume hints, and logging config),\n * - `host.refresh_credential` (capability invocation that replaces the\n * refresh-on-401 path of `request_access_token`), and\n * - `runner.*` capabilities (`runner.add_mount`, `runner.add_connector`,\n * `runner.remove_resource`, `runner.update_credential`, `runner.set_log_level`,\n * `runner.set_state`, `runner.lifecycle`) invoked by the platform via the\n * bidirectional capability registry.\n *\n * Capabilities gain an `audience: ('llm' | 'user' | 'runtime')[]` field that\n * scopes visibility: host RPCs (`host.*`) and runner RPCs (`runner.*`) are\n * `['runtime']` and never reach the LLM tool list or the user-facing command\n * palette. v2.x capabilities without an explicit `audience` default to\n * `['llm', 'user']`, preserving prior behaviour.\n *\n * Spec: `_devlog/specs/2026-05-10-deterministic-session-bootstrap.md`.\n *\n * @docLink packages/types/protocol-v3#protocol-version\n */\nexport const PROTOCOL_VERSION: ProtocolVersion = { major: 3, minor: 6, patch: 0 };\n\n/**\n * String form of {@link PROTOCOL_VERSION}, kept in lock-step. Useful for\n * `package.json` version fields and HTTP `User-Agent` strings.\n *\n * @category Protocol\n * @since 3.0.0\n * @docLink packages/types/protocol-v3#protocol-version\n */\nexport const PROTOCOL_VERSION_STRING = \"3.6.0\";\n\n/**\n * Parse a `\"major.minor.patch\"` string into a {@link ProtocolVersion}.\n *\n * @param s - the version string to parse, exactly three dot-separated non-negative integers\n * @returns the parsed protocol version\n * @throws {Error} if the string is not exactly three dot-separated non-negative integers\n *\n * @example\n * ```ts\n * parseVersion('2.0.0'); // { major: 2, minor: 0, patch: 0 }\n * parseVersion('2.1'); // throws\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#parse-version\n */\nexport function parseVersion(s: string): ProtocolVersion {\n const parts = s.split(\".\");\n if (parts.length !== 3) {\n throw new Error(`Invalid ProtocolVersion: \"${s}\" (expected \"major.minor.patch\")`);\n }\n const [maj, min, pat] = parts;\n const major = Number(maj);\n const minor = Number(min);\n const patch = Number(pat);\n if (\n !Number.isInteger(major) ||\n !Number.isInteger(minor) ||\n !Number.isInteger(patch) ||\n major < 0 ||\n minor < 0 ||\n patch < 0\n ) {\n throw new Error(`Invalid ProtocolVersion: \"${s}\" (each part must be a non-negative integer)`);\n }\n return { major, minor, patch };\n}\n\n/**\n * Format a {@link ProtocolVersion} record into its `\"major.minor.patch\"` string form.\n *\n * @param v - the protocol version to format\n * @returns the dot-joined string form\n *\n * @example\n * ```ts\n * formatVersion({ major: 2, minor: 0, patch: 0 }); // '2.0.0'\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#format-version\n */\nexport function formatVersion(v: ProtocolVersion): string {\n return `${v.major}.${v.minor}.${v.patch}`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../types/src/mentions.ts","../types/src/reactions.ts","../types/src/capabilities.ts","../types/src/version.ts"],"names":[],"mappings":";AAmBO,IAAM,iBAAiB,CAAC,OAAA,EAAS,QAAA,EAAU,aAAA,EAAe,QAAQ,KAAK;;;ACevE,IAAM,eAAA,GAAkB;AAAA,EAC7B,WAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;;;AC8LO,SAAS,mBAAmB,GAAA,EAA0C;AAC3E,EAAA,OAAO,IAAI,MAAA,KAAW,MAAA;AACxB;AAsCO,SAAS,gBAAgB,GAAA,EAA0B;AACxD,EAAA,IAAI,GAAA,CAAI,aAAa,MAAA,EAAW;AAC9B,IAAA,OAAO,GAAA,CAAI,QAAA,CAAS,QAAA,CAAS,MAAM,CAAA;AAAA,EACrC;AACA,EAAA,IAAI,GAAA,CAAI,kBAA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KAAA,GAAQ,KACR,KAAA,GAAQ,CAAA,IACR,QAAQ,CAAA,EACR;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0BAAA,EAA6B,CAAC,CAAA,4CAAA,CAA8C,CAAA;AAAA,EAC9F;AACA,EAAA,OAAO,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAM;AAC/B;AAiBO,SAAS,cAAc,CAAA,EAA4B;AACxD,EAAA,OAAO,CAAA,EAAG,EAAE,KAAK,CAAA,CAAA,EAAI,EAAE,KAAK,CAAA,CAAA,EAAI,EAAE,KAAK,CAAA,CAAA;AACzC","file":"chunk-RDE43ORT.js","sourcesContent":["/**\n * Mentions — types for @-mention support in session messages.\n *\n * A Mention records who was addressed in a message, whether a specific user\n * or a well-known group. Group mentions carry a resolved array of user IDs\n * so consumers can perform membership checks without the resolver.\n */\n\n// ---------------------------------------------------------------------------\n// Groups\n// ---------------------------------------------------------------------------\n\n/**\n * Well-known group mention targets as a `const` array.\n *\n * Use this for validation or exhaustive checks against `MentionGroup`.\n *\n * @docLink packages/types/messages#mention\n */\nexport const MENTION_GROUPS = [\"agent\", \"humans\", \"humans_here\", \"here\", \"all\"] as const;\n\n/**\n * A well-known group that can be `@`-mentioned: `'agent' | 'humans' | 'humans_here' | 'here' | 'all'`.\n *\n * @docLink packages/types/messages#mention\n */\nexport type MentionGroup = (typeof MENTION_GROUPS)[number];\n\n// ---------------------------------------------------------------------------\n// Mention discriminated union\n// ---------------------------------------------------------------------------\n\n/**\n * A parsed `@`-mention in a session message. Records who was addressed — either a\n * specific user or a well-known group — along with the source text position.\n *\n * Group mentions carry a resolved array of user IDs so consumers can perform\n * membership checks without needing the resolver.\n *\n * @docLink packages/types/messages#mention\n */\nexport type Mention =\n | {\n type: \"user\";\n userId: string;\n name: string;\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n }\n | {\n type: \"group\";\n group: MentionGroup;\n /** User IDs resolved at parse time (e.g. all online users for `@here`). */\n resolved: string[];\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n }\n | {\n type: \"custom\";\n /** Consumer-defined mention kind, e.g. \"assistant\". */\n kind: string;\n /** User IDs this mention resolves to (so isMentioned works); may be empty. */\n resolved: string[];\n /** Optional consumer payload, e.g. { sessionId, ownerId }. */\n data?: Record<string, unknown>;\n /** Position of the `@` character in the source text. */\n offset: number;\n /** Length of the full `@token` string including the `@`. */\n length: number;\n };\n","/**\n * Reactions -- emoji reactions on session messages.\n *\n * Any session participant (user or agent) can react to any message.\n * Reactions are persisted in a dedicated DB model and broadcast as\n * transient events for real-time updates.\n */\n\n/**\n * A single emoji reaction on a message, set by any session participant (user or agent).\n *\n * Reactions are persisted in a dedicated DB model and broadcast as transient events\n * for real-time updates.\n *\n * @docLink packages/types/messages#reaction\n */\nexport type Reaction = {\n /** Unicode emoji character (e.g. \"thumbs up\", not \":thumbsup:\"). */\n emoji: string;\n /** ID of the user (or \"agent\" for agent reactions). */\n userId: string;\n /** Display name at reaction time (avoids extra lookups for tooltip rendering). */\n userName: string;\n /** Unix epoch milliseconds. */\n timestamp: number;\n};\n\n/**\n * Quick-access emojis shown in the reaction bar picker.\n *\n * An `as const` array of eight Unicode emoji characters in display order.\n *\n * @docLink packages/types/messages#reaction\n */\nexport const QUICK_REACTIONS = [\n \"\\u{1F44D}\",\n \"\\u{1F440}\",\n \"\\u2705\",\n \"\\u2764\\uFE0F\",\n \"\\u{1F914}\",\n \"\\u{1FAE1}\",\n \"\\u{1F44F}\",\n \"\\u{1F389}\",\n] as const;\n","/**\n * Capability layer — Protocol v2's unified registry of LLM-invokable entry points.\n *\n * A {@link Capability} is a named, schema-typed entry point that the LLM can call\n * during a session. Capabilities are registered into a per-session\n * registry by either side (host platform via `side: 'client'` or runtime via\n * `side: 'agent'`) and routed by the bridge at invocation time.\n *\n * This module defines the wire types only; the runtime registry, the\n * `defineCapability` helper, and the per-handler logger live in\n * `@skaile/workspaces/runner`.\n *\n * @see {@link MessageV2} envelope that carries capability commands and events\n * @see {@link ProtocolVersion} for the version contract\n *\n * @category Capabilities\n * @since 2.0.0\n */\n\n// ---------------------------------------------------------------------------\n// Capability shape\n// ---------------------------------------------------------------------------\n\n/**\n * Visibility scope for a capability. Determines which surfaces the capability\n * appears on and which callers can invoke it.\n *\n * - `'llm'`: registered as an LLM tool, surfaced in the `<CAPABILITIES>` system\n * prompt section. The agent driver can invoke it.\n * - `'user'`: appears in user-facing surfaces — the command palette (cmdK),\n * debug menus, capability lists.\n * - `'runtime'`: invocable only by trusted runner / platform code paths. Never\n * reaches the LLM tool list. Never reaches the command palette. Used for\n * host RPCs (`host.refresh_credential`, `host.audit`, `host.notify_user`,\n * `host.persist_compaction_attempt`) and runner RPCs (`runner.add_mount`,\n * `runner.set_log_level`, `runner.lifecycle`, ...).\n *\n * Multiple audiences are allowed (e.g. `['llm', 'user']`). The default when\n * {@link Capability.audience} is omitted is `['llm', 'user']`, preserving the\n * v2.x default visibility for capabilities that haven't migrated yet.\n *\n * @category Capabilities\n * @since 3.0.0\n * @docLink packages/types/capabilities#capability-audience\n */\nexport type CapabilityAudience = \"llm\" | \"user\" | \"runtime\";\n\n/**\n * Source of truth for who registered a capability. Used for trust enforcement\n * (the bridge rejects mismatches between registering side and origin kind)\n * and for the `capability:<origin>:<name>` log taxonomy.\n *\n * Variants:\n * - `framework`: built-in (e.g. `__capabilities.list`)\n * - `client`: host platform (e.g. `platform.react`)\n * - `agent`: self-registered by the agent runtime\n * - `flow`: injected by an active flow execution\n * - `skill`: from a skill's MCP surface\n * - `mcp`: from a generic MCP server\n * - `connector`: from a connector (e.g. `postgres.query`)\n * - `mount`: surfaced by a filesystem mount\n * - `app`: from an embedded, agent-controllable app (carries the originating\n * `appId`). Handlers run in the app itself — see {@link Capability.side} `'app'`.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-origin\n */\nexport type CapabilityOrigin =\n | { kind: \"framework\" }\n | { kind: \"client\" }\n | { kind: \"agent\" }\n | { kind: \"flow\"; flowId: string }\n | { kind: \"skill\"; skillId: string }\n | { kind: \"mcp\"; serverId: string }\n | { kind: \"connector\"; connectorId: string }\n | { kind: \"mount\"; mountId: string }\n | { kind: \"app\"; appId: string };\n\n/**\n * Render contract for a capability that produces a UI surface when invoked.\n *\n * When the LLM invokes a capability whose `render` is set, the bridge emits\n * a {@link RenderInvokedEvent} carrying the capability name and props. The\n * client renders the configured `source` at the chosen `target`. Clients\n * without a render layer can fall back to the markdown `fallback` template.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-spec\n */\nexport type RenderSpec = {\n /** Where the rendered component lives. */\n source: { kind: \"web-component\"; url: string; tagName: string } | { kind: \"iframe\"; url: string };\n /** Render placements supported by the component. */\n targets: (\"chat\" | \"preview\" | \"modal\" | \"input-extension\")[];\n /** Markdown template with `{{prop}}` placeholders for clients without a render layer. */\n fallback?: string;\n /** True when props may be partial during streaming. */\n streaming?: boolean;\n /** Interaction names the rendered component may fire back as state events. */\n interactions?: string[];\n};\n\n/**\n * A named, schema-typed entry point that the LLM can invoke during a session.\n *\n * Capabilities can be declared statically (via `ConfigureCommand.capabilities`)\n * or dynamically (via {@link CapabilityRegisterCommand} /\n * {@link CapabilityRegisterEvent}). They are cached for replay across\n * subscriber reconnects and session hibernation.\n *\n * @example Defining a client-side fire-and-forget tool (uses the runner's\n * `defineCapability` helper, which serializes a {@link Capability} to the wire):\n * ```ts\n * const reactTool = defineCapability({\n * name: 'platform.react',\n * description: 'Acknowledge a user message with a Unicode emoji.',\n * side: 'client',\n * origin: { kind: 'client' },\n * fireAndForget: true,\n * input: z.object({ emoji: z.string(), targetSeq: z.number().optional() }),\n * handler: async ({ emoji, targetSeq }, ctx) => { ... },\n * });\n * ```\n *\n * @see {@link RenderCapability} for capabilities that render UI components\n * @see {@link CapabilityOrigin} for who-registered-it metadata\n * @see {@link isRenderCapability} for the type-guard\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability\n */\nexport type Capability = {\n /** Unique within a session. Convention: namespaced as `<origin>.<name>` (e.g. `platform.react`, `ui.gif`). */\n name: string;\n /**\n * Human-readable label for user-facing surfaces (cmdK action palette,\n * capability menus, debug panels). Falls back to {@link Capability.name}\n * when omitted. Pure presentation — the LLM sees `name`, not `displayName`.\n */\n displayName?: string;\n /** Human/LLM-readable summary. Shown to the LLM as part of tool registration. */\n description: string;\n /** JSON Schema validating the invocation arguments. Authored as Zod, converted at register time. */\n inputSchema: Record<string, unknown>;\n /** Optional return shape. Omit for fire-and-forget effects. */\n outputSchema?: Record<string, unknown>;\n /** Where the handler runs. `client` = host platform, `agent` = runtime/skill/connector, `app` = embedded app. */\n side: \"client\" | \"agent\" | \"app\";\n /** Discriminated tag identifying who registered the capability. Used for trust enforcement and audit. */\n origin: CapabilityOrigin;\n /** Lifetime: `session` survives the whole session, `turn` is dropped at end-of-turn. */\n scope?: \"session\" | \"turn\";\n /** When true, the bridge auto-resolves with `{}` immediately and runs the handler in the background. */\n fireAndForget?: boolean;\n /** When true, the platform shows a confirm UI before dispatch and waits for {@link CapabilityApproveCommand}. */\n requiresApproval?: boolean;\n /** Documentation hint (not enforced) describing whether this is a side-effect, render, or pure query. */\n kind?: \"effect\" | \"render\" | \"query\";\n /**\n * Whether this capability should be exposed in user-facing surfaces (cmdK\n * action palette, capability menus). When omitted, the consumer applies a\n * default per-origin via {@link isUserInvokable}.\n *\n * - `true`: surface in cmdK and capability menus.\n * - `false`: hide from user surfaces (LLM-only or low-level).\n * - `undefined`: defer to {@link isUserInvokable}'s inference rules.\n *\n * @deprecated Set {@link Capability.audience} instead. `userInvokable` is\n * kept as a read-only shim for v2.x consumers and is honoured by\n * {@link isUserInvokable} when {@link Capability.audience} is absent.\n */\n userInvokable?: boolean;\n /**\n * Audience scoping for this capability. See {@link CapabilityAudience} for\n * the meaning of each value and combinations.\n *\n * When omitted, consumers treat the capability as `['llm', 'user']` (the\n * v2.x default). Host RPCs and runner RPCs MUST set this to `['runtime']`\n * so they never leak to the LLM tool list or the user-facing surfaces.\n *\n * @category Capabilities\n * @since 3.0.0\n */\n audience?: CapabilityAudience[];\n /** Appended to the system prompt's `<CAPABILITIES>` section. Use for usage hints the LLM should always see. */\n promptFragment?: string;\n /**\n * Per-capability override for how long the runner waits on the\n * `capability_result` round-trip before timing out. When omitted the\n * runner applies its default (`DEFAULT_CAPABILITY_CALL_TIMEOUT_MS`, 60s).\n *\n * Set this for capabilities that legitimately block far longer than a\n * normal tool call — e.g. `platform.ask_session` suspends the caller's\n * turn until a peer session answers, which can take minutes.\n *\n * @category Capabilities\n * @since 3.3.0\n */\n callTimeoutMs?: number;\n /** Present iff this is a render capability — see {@link RenderCapability}. */\n render?: RenderSpec;\n};\n\n/**\n * A {@link Capability} that produces a UI surface when invoked. The narrowed\n * type guarantees `render` is set, which simplifies frontend lookup.\n *\n * @see {@link isRenderCapability}\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-capability\n */\nexport type RenderCapability = Capability & { render: NonNullable<Capability[\"render\"]> };\n\n/**\n * Type-guard for {@link RenderCapability}. Use after {@link Capability}\n * lookup to narrow the type before reading `render`.\n *\n * @example\n * ```ts\n * for (const cap of registry.list()) {\n * if (isRenderCapability(cap)) console.log(cap.render.targets);\n * }\n * ```\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#is-render-capability\n */\nexport function isRenderCapability(cap: Capability): cap is RenderCapability {\n return cap.render !== undefined;\n}\n\n/**\n * Decide whether a capability should be surfaced in user-facing actions\n * (cmdK action palette, capability menus).\n *\n * Resolution order (first match wins):\n *\n * 1. {@link Capability.audience} is set — return `audience.includes('user')`.\n * Capabilities scoped to `'runtime'` only never appear in user surfaces.\n * 2. {@link Capability.userInvokable} is set (v2.x shim) — return that value.\n * 3. Default per-origin inference table below.\n *\n * Default-inference rules (when both `audience` and `userInvokable` are\n * omitted):\n * | Origin | Default |\n * | ------------ | ---------------------------------------------------------------------- |\n * | `framework` | `false` (LLM discovery surfaces, e.g. `__capabilities.list`) |\n * | `client` | `false` (platform ack tools — `platform.react`, `platform.pass`) |\n * | `agent` | `false` (agent-defined; assume internal unless flagged) |\n * | `flow` | `false` (per-cap opt-in) |\n * | `connector` | `false` (low-level FS / data ops) |\n * | `mount` | `false` (low-level FS ops) |\n * | `app` | `false` (LLM-only; app authors opt in via `audience: ['llm','user']`) |\n * | `mcp` | `true` if `kind === 'effect'`, else `false` |\n * | `skill` | `true` if `kind` ∈ {`effect`, `render`}, else `false` |\n *\n * @example\n * ```ts\n * for (const cap of capabilities.values()) {\n * if (isUserInvokable(cap)) registerCommandPaletteAction(cap);\n * }\n * ```\n *\n * @category Capabilities\n * @since 2.1.0\n * @docLink packages/types/capabilities#is-user-invokable\n */\nexport function isUserInvokable(cap: Capability): boolean {\n if (cap.audience !== undefined) {\n return cap.audience.includes(\"user\");\n }\n if (cap.userInvokable !== undefined) {\n return cap.userInvokable;\n }\n switch (cap.origin.kind) {\n case \"framework\":\n case \"client\":\n case \"agent\":\n case \"flow\":\n case \"connector\":\n case \"mount\":\n case \"app\":\n return false;\n case \"mcp\":\n return cap.kind === \"effect\";\n case \"skill\":\n return cap.kind === \"effect\" || cap.kind === \"render\";\n default:\n return false;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Capability commands (client → agent)\n// ---------------------------------------------------------------------------\n\n/**\n * Register one or more capabilities mid-session (client → agent).\n *\n * The platform sends this when a new client-side tool becomes available\n * after `configure` has already returned (e.g. a user installs a new\n * extension during the session).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-register-command\n */\nexport type CapabilityRegisterCommand = {\n type: \"capability_register\";\n capabilities: Capability[];\n};\n\n/**\n * Deregister capabilities by name (client → agent). Names that are not\n * currently registered are ignored silently.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-deregister-command\n */\nexport type CapabilityDeregisterCommand = {\n type: \"capability_deregister\";\n names: string[];\n};\n\n/**\n * Return the result of a previously {@link CapabilityInvokedEvent | invoked} client-side\n * capability (client → agent). Bridges that registered the capability with\n * `fireAndForget: true` MAY skip this command; the bridge auto-resolves with `{}`.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-result-command\n */\nexport type CapabilityResultCommand = {\n type: \"capability_result\";\n /** Correlation token matching the {@link CapabilityInvokedEvent.callId}. */\n callId: string;\n /** Successful result payload, or an error envelope. */\n result: unknown | { error: string };\n};\n\n/**\n * Approve or reject a capability call that was invoked with\n * `requiresApproval: true` (client → agent). The platform shows a confirm\n * UI and forwards the user's decision via this command.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-approve-command\n */\nexport type CapabilityApproveCommand = {\n type: \"capability_approve\";\n /** Correlation token matching the {@link CapabilityInvokedEvent.callId}. */\n callId: string;\n /** User's decision. */\n decision: \"approved\" | \"rejected\";\n /** Optional rationale stored alongside the decision for audit. */\n feedback?: string;\n /** User ID of the decider (informational — framework enforces no policy). */\n decidedBy: string;\n};\n\n// ---------------------------------------------------------------------------\n// Capability events (agent → client)\n// ---------------------------------------------------------------------------\n\n/**\n * Register one or more capabilities mid-session (agent → client). Mirrors\n * {@link CapabilityRegisterCommand} for the agent-initiated direction; used\n * when the runtime adds a capability after `configure` (e.g. when a flow\n * starts and injects flow-scoped tools).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-register-event\n */\nexport type CapabilityRegisterEvent = {\n type: \"capability_register\";\n capabilities: Capability[];\n};\n\n/**\n * Deregister capabilities by name (agent → client).\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-deregister-event\n */\nexport type CapabilityDeregisterEvent = {\n type: \"capability_deregister\";\n names: string[];\n};\n\n/**\n * Notify the client that a capability has been invoked by the LLM (agent →\n * client). For client-side capabilities the platform's handler runs in\n * response to this event and replies with {@link CapabilityResultCommand}.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#capability-invoked-event\n */\nexport type CapabilityInvokedEvent = {\n type: \"capability_invoked\";\n /** Correlation token for the eventual {@link CapabilityResultCommand}. */\n callId: string;\n /** Name of the invoked {@link Capability}. */\n name: string;\n /** Validated input payload (already conforms to the capability's `inputSchema`). */\n input: unknown;\n /** In v2.0.0 the LLM is the only invoker. */\n invokedBy: \"agent\";\n};\n\n/**\n * Notify the client that a render capability should be drawn (agent →\n * client). Emitted alongside {@link CapabilityInvokedEvent} when the\n * invoked capability's `render` block is populated.\n *\n * Clients without a render layer can fall back to the capability's\n * `render.fallback` markdown template.\n *\n * @category Capabilities\n * @since 2.0.0\n * @docLink packages/types/capabilities#render-invoked-event\n */\nexport type RenderInvokedEvent = {\n type: \"render_invoked\";\n /** Name of the invoked render capability. */\n capabilityName: string;\n /** Props passed to the rendered component (already conforms to `inputSchema`). */\n props: unknown;\n /** Correlation token shared with the matching {@link CapabilityInvokedEvent}. */\n callId: string;\n};\n","/**\n * Protocol versioning primitives for Skaile Agent Protocol v2.\n *\n * The protocol is versioned by a structured {@link ProtocolVersion} record\n * (`major.minor.patch`). The compatibility rule applied at handshake is\n * **major-equality**: a runner emits {@link IncompatibleProtocolEvent} and\n * shuts down when its declared major does not match the platform's announced\n * major. Minor and patch differences ride through transparently because\n * unknown fields are preserved on round-trip (see `MessageMeta` round-trip\n * contract in `messaging.ts`).\n *\n * @category Protocol\n * @since 2.0.0\n */\n\n/**\n * Structured semantic version triple for the agent protocol.\n *\n * @example\n * ```ts\n * const v: ProtocolVersion = { major: 2, minor: 0, patch: 0 };\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#protocol-version\n */\nexport type ProtocolVersion = {\n /** Incremented on breaking wire-format changes (field removed, semantics changed, required field added). */\n major: number;\n /** Incremented on additive wire-format changes (new optional fields, new event types). */\n minor: number;\n /** Incremented on bug-fix or doc-only changes that do not affect the wire. */\n patch: number;\n};\n\n/**\n * The protocol version the framework currently speaks. Runners and platforms\n * compare this against the peer's announced version at session boot via\n * `SessionInitCommand.protocolVersion`.\n *\n * @example\n * ```ts\n * import { PROTOCOL_VERSION } from '@skaile/workspaces/types';\n * if (cmd.protocolVersion.major !== PROTOCOL_VERSION.major) {\n * emit({ type: 'incompatible_protocol', agentVersion: PROTOCOL_VERSION, platformVersion: cmd.protocolVersion });\n * }\n * ```\n *\n * @category Protocol\n * @since 3.0.0\n *\n * Changed in 3.7.0:\n * Additive `connector_mutate` acknowledgement + flow-hydrate reconciliation.\n * Three changes, all additive under the major-equality rule:\n * - `ConnectorMutateCommand` gains an optional `requestId`. When set, the\n * runner emits exactly one new `connector_mutate_response` event (with\n * `ok` / `result` / `error` / `code` / `reconciled`) on every terminal path,\n * including the paths that previously only logged. When absent nothing is\n * emitted, so a 3.6 host sees byte-identical behaviour.\n * - `flow.hydrate` accepts an optional `payload.pendingDecisions` —\n * `PendingGateDecision[]` the runner replays against the snapshot in the\n * same invocation that creates the flow connector, reporting the outcome as\n * `reconciled`. A host that omits the key gets today's hydrate.\n * - A flow-targeted mutate whose connector is not yet registered now waits\n * (bounded, `SKAILE_FLOW_MUTATE_CONNECTOR_WAIT_MS`, default 8000 ms) and\n * re-plans instead of failing — a behaviour change on a path that used to\n * fail silently, visible to a 3.6 host only as the op succeeding.\n * A 3.6 peer is unaffected: no symbol was removed or re-shaped, the ack is\n * opt-in on a field a 3.6 host never sets, and unknown fields ride through the\n * round-trip. A 3.7 host against a 3.6 runner sees `requestId` ignored and no\n * response, which it must treat as \"unacknowledged\" (feature-detect on\n * `major === 3 && minor >= 7`). Spec: `runner/MIGRATION-flow-connector.md`.\n *\n * Changed in 3.6.0:\n * Additive resolved-agent-config wire field. `ResolvedSkaileConfig` gains an\n * optional `agentConfig?: ResolvedAgentConfig` carrying the platform-resolved\n * driver / provider / model / cloud / cloudConfig / thinking / effort — the\n * same values the platform bakes into the generated skaile.yaml\n * `agent-config.default`. The runner applies it disk-first: any on-disk\n * `agent-config` profile with at least one agent setting disables the wire\n * value outright, so yaml-on-disk (docker-mode) sessions are byte-identical.\n * Additive under the major-equality rule: an older runner ignores the field\n * and an older platform simply omits it.\n *\n * Changed in 3.5.0:\n * Flow-connector host-contract fix (workspaces#379). Three coordinated changes,\n * all additive under the major-equality rule:\n * - `op:\"hydrate\"` on the bare `\"flow\"` connector now auto-creates the\n * `flow:<runId>` connector on a cold container from its `{ state, flow }`\n * payload, so a persisted run rehydrates in one op. A peer that still issues\n * `start` then `hydrate` keeps working unchanged.\n * - The dead `SessionInit.activeFlows` field (never read by the runner) and its\n * `ActiveFlowRehydration` type are removed — wire-compatible (nothing produced\n * or consumed them) but source-breaking for typed hosts, hence the bump.\n * - Malformed / conflicting flow `start` and `hydrate` payloads now fail loudly\n * (warn with a reason) instead of silently falling through.\n * Because the handshake compares only `major`, a 3.4 host and a 3.5 runner\n * interoperate: the auto-create path is opt-in on the payload the host sends, and\n * the removed field was already inert. Spec: `runner/MIGRATION-flow-connector.md`.\n *\n * Changed in 3.4.0:\n * Additive embedded-app capability source. `CapabilityOrigin` gains a\n * `{ kind: 'app'; appId: string }` variant and `Capability.side` gains `'app'`\n * (\"the handler runs in the embedded app\"). Both are additive: a peer that does\n * not understand `origin:'app'` / `side:'app'` never produces or routes them, so\n * they ride through transparently under the major-equality rule. No new message\n * types — `capability_register` / `capability_invoked` / `capability_result` /\n * `capability_approve` / `render_invoked` are reused verbatim. Spec:\n * `_devlog/specs/2026-07-07-app-capability-source.md`.\n *\n * Changed in 3.3.0:\n * Additive agent-to-agent (session-to-session) communication extension.\n * `AgentEvent` gains an `a2a_message` variant carrying cross-session messages\n * (`direction`, `peerSessionId`, `peerName`, `exchangeId`, `text`). `Capability`\n * gains an optional `callTimeoutMs?: number` so a long-running capability call\n * (e.g. a 5-minute `platform.ask_session`) can exceed the default capability-call\n * timeout. Both are additive: a peer that does not understand them ignores the\n * event / falls back to the default timeout, so they ride through transparently\n * under the major-equality rule.\n *\n * Changed in 3.2.0:\n * Additive wake-time resume cascade. `AgentReconfigureOptions` gains optional\n * `resumeSessionId` and `expectedCapabilitySignature` fields driving the tier-1\n * native SDK resume path; `AgentEvent` gains `ResumeAttemptedEvent` and\n * `ResumeFailedEvent`. `FinishedEvent` gains optional `customType` /\n * `customData` for capability-routed custom payloads. All additive — clients\n * that omit the resume hint or ignore the new events keep working unchanged.\n *\n * Changed in 3.1.0:\n * Additive cost / token usage extension. `FinishedEvent` gains an optional\n * `tokens?: TokenUsage` field carrying per-turn input / output / cache-read /\n * cache-creation / reasoning token counts. `AgentDriver.getTokenUsage()` is\n * widened to return the same `TokenUsage` shape (existing consumers reading\n * `inputTokens` / `outputTokens` keep working unchanged). Drivers that do not\n * surface token usage continue to return `null` / omit the field.\n *\n * Changed in 3.0.0:\n * Major bump for the deterministic session bootstrap rewrite. `ConfigureCommandV2`,\n * `provision_secrets`, `request_access_token`, `add_resource`, `remove_resource`,\n * `set_log_level`, `state_action`, `lifecycle`, `remount_mount`, `compact`, and\n * `reconfigure_agent` are removed from the `AgentCommand` union. Their semantics\n * are reachable through:\n * - `session_init` (one deterministic envelope at session start that delivers\n * identity, resolved config, pre-minted credentials, secrets, capabilities,\n * shared state, active flows, resume hints, and logging config),\n * - `host.refresh_credential` (capability invocation that replaces the\n * refresh-on-401 path of `request_access_token`), and\n * - `runner.*` capabilities (`runner.add_mount`, `runner.add_connector`,\n * `runner.remove_resource`, `runner.update_credential`, `runner.set_log_level`,\n * `runner.set_state`, `runner.lifecycle`) invoked by the platform via the\n * bidirectional capability registry.\n *\n * Capabilities gain an `audience: ('llm' | 'user' | 'runtime')[]` field that\n * scopes visibility: host RPCs (`host.*`) and runner RPCs (`runner.*`) are\n * `['runtime']` and never reach the LLM tool list or the user-facing command\n * palette. v2.x capabilities without an explicit `audience` default to\n * `['llm', 'user']`, preserving prior behaviour.\n *\n * Spec: `_devlog/specs/2026-05-10-deterministic-session-bootstrap.md`.\n *\n * @docLink packages/types/protocol-v3#protocol-version\n */\nexport const PROTOCOL_VERSION: ProtocolVersion = { major: 3, minor: 7, patch: 0 };\n\n/**\n * String form of {@link PROTOCOL_VERSION}, kept in lock-step. Useful for\n * `package.json` version fields and HTTP `User-Agent` strings.\n *\n * @category Protocol\n * @since 3.0.0\n * @docLink packages/types/protocol-v3#protocol-version\n */\nexport const PROTOCOL_VERSION_STRING = \"3.7.0\";\n\n/**\n * Parse a `\"major.minor.patch\"` string into a {@link ProtocolVersion}.\n *\n * @param s - the version string to parse, exactly three dot-separated non-negative integers\n * @returns the parsed protocol version\n * @throws {Error} if the string is not exactly three dot-separated non-negative integers\n *\n * @example\n * ```ts\n * parseVersion('2.0.0'); // { major: 2, minor: 0, patch: 0 }\n * parseVersion('2.1'); // throws\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#parse-version\n */\nexport function parseVersion(s: string): ProtocolVersion {\n const parts = s.split(\".\");\n if (parts.length !== 3) {\n throw new Error(`Invalid ProtocolVersion: \"${s}\" (expected \"major.minor.patch\")`);\n }\n const [maj, min, pat] = parts;\n const major = Number(maj);\n const minor = Number(min);\n const patch = Number(pat);\n if (\n !Number.isInteger(major) ||\n !Number.isInteger(minor) ||\n !Number.isInteger(patch) ||\n major < 0 ||\n minor < 0 ||\n patch < 0\n ) {\n throw new Error(`Invalid ProtocolVersion: \"${s}\" (each part must be a non-negative integer)`);\n }\n return { major, minor, patch };\n}\n\n/**\n * Format a {@link ProtocolVersion} record into its `\"major.minor.patch\"` string form.\n *\n * @param v - the protocol version to format\n * @returns the dot-joined string form\n *\n * @example\n * ```ts\n * formatVersion({ major: 2, minor: 0, patch: 0 }); // '2.0.0'\n * ```\n *\n * @category Protocol\n * @since 2.0.0\n * @docLink packages/types/protocol-v2#format-version\n */\nexport function formatVersion(v: ProtocolVersion): string {\n return `${v.major}.${v.minor}.${v.patch}`;\n}\n"]}
|