@skaile/workspaces 4.23.1 → 4.23.2
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 +6 -0
- package/dist/{asset-feeds-5WLES6EE.js → asset-feeds-LMP4FXEK.js} +4 -4
- package/dist/{asset-feeds-5WLES6EE.js.map → asset-feeds-LMP4FXEK.js.map} +1 -1
- package/dist/asset-manager/index.js +1 -1
- package/dist/{chunk-3DVBPLIZ.js → chunk-4SXAE6WY.js} +6 -6
- package/dist/{chunk-3DVBPLIZ.js.map → chunk-4SXAE6WY.js.map} +1 -1
- package/dist/{chunk-4FIF2QZH.js → chunk-5366G4XM.js} +3 -3
- package/dist/{chunk-4FIF2QZH.js.map → chunk-5366G4XM.js.map} +1 -1
- package/dist/{chunk-4BF3SNGJ.js → chunk-7AGRNJVR.js} +2 -2
- package/dist/{chunk-4BF3SNGJ.js.map → chunk-7AGRNJVR.js.map} +1 -1
- package/dist/{chunk-LLW2MCZE.js → chunk-7IVF7RDD.js} +3 -3
- package/dist/{chunk-LLW2MCZE.js.map → chunk-7IVF7RDD.js.map} +1 -1
- package/dist/{chunk-PTALRV5L.js → chunk-CRZCOGDW.js} +75 -5
- package/dist/chunk-CRZCOGDW.js.map +1 -0
- package/dist/{chunk-KFN55DUL.js → chunk-HMIRR6J7.js} +5 -5
- package/dist/{chunk-KFN55DUL.js.map → chunk-HMIRR6J7.js.map} +1 -1
- package/dist/{chunk-B6DXWEOC.js → chunk-MLNGBUPI.js} +2 -2
- package/dist/{chunk-B6DXWEOC.js.map → chunk-MLNGBUPI.js.map} +1 -1
- package/dist/{chunk-ORCSZZLG.js → chunk-SY4I5SHD.js} +3 -3
- package/dist/{chunk-ORCSZZLG.js.map → chunk-SY4I5SHD.js.map} +1 -1
- package/dist/{chunk-H7XC2IAQ.js → chunk-WGZUG26K.js} +3 -3
- package/dist/{chunk-H7XC2IAQ.js.map → chunk-WGZUG26K.js.map} +1 -1
- package/dist/{chunk-7B362FO3.js → chunk-XUQDVTB5.js} +3 -3
- package/dist/{chunk-7B362FO3.js.map → chunk-XUQDVTB5.js.map} +1 -1
- package/dist/{chunk-UOSXXZJX.js → chunk-ZFCY74KO.js} +6 -6
- package/dist/{chunk-UOSXXZJX.js.map → chunk-ZFCY74KO.js.map} +1 -1
- package/dist/cli/index.js +28 -28
- package/dist/connectors/index.js +1 -1
- package/dist/{ensure-sources-CUJPN27W.js → ensure-sources-DGA32WOD.js} +4 -4
- package/dist/{ensure-sources-CUJPN27W.js.map → ensure-sources-DGA32WOD.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/run-flow.js +2 -2
- package/dist/factory-assets/connectors/flow.js +1 -1
- package/dist/factory-assets/connectors/git/CONNECTOR.md +2 -1
- package/dist/factory-assets/connectors/git/driver.d.ts +11 -2
- package/dist/factory-assets/connectors/git/driver.d.ts.map +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/{helpers-TBUFHY4M.js → helpers-S2CEIHEY.js} +4 -4
- package/dist/{helpers-TBUFHY4M.js.map → helpers-S2CEIHEY.js.map} +1 -1
- package/dist/{library-publish-PQ4QUFSU.js → library-publish-DWRR3DRM.js} +6 -6
- package/dist/{library-publish-PQ4QUFSU.js.map → library-publish-DWRR3DRM.js.map} +1 -1
- package/dist/{open-library-DTHVX745.js → open-library-5WBEH5UI.js} +5 -5
- package/dist/{open-library-DTHVX745.js.map → open-library-5WBEH5UI.js.map} +1 -1
- package/dist/{project-2TGBVK5Z.js → project-Y7OGRH7R.js} +5 -5
- package/dist/{project-2TGBVK5Z.js.map → project-Y7OGRH7R.js.map} +1 -1
- package/dist/runner/index.js +4 -4
- package/dist/sdk/asset-manager.js +1 -1
- package/dist/sdk/index.js +4 -4
- package/dist/sdk/runner.js +4 -4
- package/dist/{setup-SVSZ72DE.js → setup-BPDOYM66.js} +5 -5
- package/dist/{setup-SVSZ72DE.js.map → setup-BPDOYM66.js.map} +1 -1
- package/dist/{source-65BYI424.js → source-IBWF4JUT.js} +6 -6
- package/dist/{source-65BYI424.js.map → source-IBWF4JUT.js.map} +1 -1
- package/dist/{source-manifest-publish-NZILVOLT.js → source-manifest-publish-S4OT5B63.js} +7 -7
- package/dist/{source-manifest-publish-NZILVOLT.js.map → source-manifest-publish-S4OT5B63.js.map} +1 -1
- package/dist/tui/index.js +4 -4
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PTALRV5L.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getStoreConfig, getStoreToken, storeFetch } from './chunk-IJTEDXWQ.js';
|
|
2
|
-
import { S, logErr, logWarn, logOk, logInfo } from './chunk-
|
|
2
|
+
import { S, logErr, logWarn, logOk, logInfo } from './chunk-5366G4XM.js';
|
|
3
3
|
|
|
4
4
|
// cli/src/store-publisher.ts
|
|
5
5
|
function makeHttpPublisherClient(config = getStoreConfig(), timeoutMs = 2e4) {
|
|
@@ -154,5 +154,5 @@ async function publishToStore(opts) {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
export { bareName, formatNamespaceAvailability, makeHttpPublisherClient, preflightNamespace, publishToStore, refFor };
|
|
157
|
-
//# sourceMappingURL=chunk-
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
157
|
+
//# sourceMappingURL=chunk-SY4I5SHD.js.map
|
|
158
|
+
//# sourceMappingURL=chunk-SY4I5SHD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/store-publisher.ts","../cli/src/commands/publish-core.ts"],"names":[],"mappings":";;;;AA+FO,SAAS,uBAAA,CACd,MAAA,GAAsB,cAAA,EAAe,EACrC,YAAY,GAAA,EACK;AAGjB,EAAA,MAAM,IAAA,GAAO,OACX,IAAA,EACA,IAAA,KACe;AACf,IAAA,MAAM,GAAA,GAAM,MAAM,aAAA,EAAc;AAChC,IAAA,OAAO,UAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,GAAA,EAAI,EAAG,IAAA,EAAM,EAAE,SAAA,EAAW,GAAG,IAAA,EAAM,CAAA;AAAA,EACvE,CAAA;AACA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,MAAM,IAAA,CAAK,YAAY,CAAA;AAAA,IAC3B,UAAA,EAAY,CAAC,IAAA,KAAS,IAAA,CAAK,mBAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,CAAA;AAAA,IACtE,WAAA,EAAa,MAAM,IAAA,CAAK,iBAAiB,CAAA;AAAA,IACzC,UAAA,EAAY,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,gBAAA,EAAmB,EAAE,CAAA,KAAA,CAAA,EAAS,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,IACnF,QAAQ,CAAC,KAAA,KAAU,IAAA,CAAK,CAAA,aAAA,EAAgB,KAAK,CAAA,CAAE,CAAA;AAAA,IAC/C,kBAAkB,CAAC,EAAA,KAAO,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5F;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,UAAA,EAAa,SAAA,CAAU,MAAM,CAAA,UAAA,CAAY,CAAA;AAC/C,EAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC3C,EAAA,OAAO,EAAE,SAAA,EAAU;AACrB","file":"chunk-ORCSZZLG.js","sourcesContent":["/**\n * Typed REST client for the AI Asset Store **publisher** surface — the\n * curator-publish flow (`skaile source manifest publish` / `yank`). Thin\n * wrappers over {@link storeFetch}; every method maps 1:1 to an `/api/v1/…`\n * endpoint. The {@link PublisherClient} interface is injectable so the\n * orchestration in `commands/source-manifest-publish.ts` can be unit-tested\n * against a fake without a live store.\n *\n * @docLink cli/dev-guide#store-publisher\n */\n\nimport { getStoreConfig, getStoreToken, type StoreConfig, storeFetch } from \"./store-client.ts\";\n\n/**\n * The publisher REST surface used by the curator-publish flow. Kept minimal —\n * only the endpoints `runPublish` / `runYank` actually call. Response shapes\n * are narrowed to the fields the orchestration reads (the server returns more).\n */\nexport interface PublisherClient {\n /**\n * Identity of the caller. `username` is the Keycloak login (personal-tier\n * namespace); `githubLogin` is the verified GitHub handle when connected —\n * the namespace to publish under when it differs from the login.\n */\n me(): Promise<{ username: string; githubLogin?: string | null }>;\n /** Register (or re-register) a source; returns the created/existing row id. */\n sourcesAdd(body: {\n url: string;\n ref: string;\n sidecarUrl?: string;\n sidecarRef?: string;\n /**\n * Target publisher namespace (the manifest's `publisher`). When it differs\n * from the caller's login username, the store resolves the CLAIMED Publisher\n * for it (the store must already have the claim). Omitted → the store\n * defaults to `@<username>` (personal).\n */\n namespace?: string;\n }): Promise<{ id: string }>;\n /** List sources — used to recover an id when `sourcesAdd` rejects a dup url. */\n sourcesList(): Promise<Array<{ id: string; url: string }>>;\n /** Kick off a source sync; returns the async job id to poll. */\n sourceSync(id: string): Promise<{ jobId: string }>;\n /** Poll a job's terminal status + per-item results. */\n jobGet(\n jobId: string,\n ): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }>;\n /** Discovered publishable candidates for a synced source. */\n sourceCandidates(id: string): Promise<\n Array<{\n id: string;\n name: string;\n version: string;\n kind: string;\n published: boolean;\n assetRoot: string;\n }>\n >;\n /** Per-asset preview — the discovered file set + resolved candidate metadata. */\n assetPreview(id: string): Promise<{\n discoveredFiles: string[];\n candidate: { name: string; version: string; kind: string; publisherNamespace: string };\n }>;\n /**\n * Publish one asset. `dryRun` returns the would-be `{ manifest }` without\n * launching a job; the normal path returns `{ jobId }`.\n */\n assetPublish(\n id: string,\n body: { ref: string; files: string[] },\n dryRun?: boolean,\n ): Promise<{ jobId?: string; manifest?: unknown }>;\n /** Retract a published asset. Response body is ignored. */\n assetUnpublish(id: string): Promise<unknown>;\n /**\n * Read-only \"can I publish under `@<ns>` right now, and if not, what's the\n * path?\" probe. Backs the `publish --dry-run` namespace status line; its\n * `message` is store-authored and meant to be surfaced verbatim.\n */\n namespaceAvailability(ns: string): Promise<{\n namespace: string;\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n claimMethod?: string;\n message: string;\n }>;\n}\n\n/**\n * Construct the real HTTP-backed {@link PublisherClient}. Every call carries a\n * longer timeout than the default store client because publish/sync trigger\n * server-side clone work.\n *\n * @param config - Store connection config; defaults to {@link getStoreConfig}.\n * @param timeoutMs - Per-request abort timeout (default 20s).\n */\nexport function makeHttpPublisherClient(\n config: StoreConfig = getStoreConfig(),\n timeoutMs = 20_000,\n): PublisherClient {\n // Acquire a fresh Keycloak token per call (device-flow session in\n // ~/.skaile/auth.json, refreshed on demand) rather than a static config.jwt.\n const call = async <T>(\n path: string,\n opts?: { method?: string; body?: unknown; params?: Record<string, string> },\n ): Promise<T> => {\n const jwt = await getStoreToken();\n return storeFetch<T>({ ...config, jwt }, path, { timeoutMs, ...opts });\n };\n return {\n me: () => call(\"/api/v1/me\"),\n sourcesAdd: (body) => call(\"/api/v1/sources\", { method: \"POST\", body }),\n sourcesList: () => call(\"/api/v1/sources\"),\n sourceSync: (id) => call(`/api/v1/sources/${id}/sync`, { method: \"POST\", body: {} }),\n jobGet: (jobId) => call(`/api/v1/jobs/${jobId}`),\n sourceCandidates: (id) => call(`/api/v1/sources/${id}/candidates`),\n assetPreview: (id) => call(`/api/v1/assets/${id}/preview`),\n assetPublish: (id, body, dryRun) =>\n call(`/api/v1/assets/${id}/publish`, {\n method: \"POST\",\n body,\n ...(dryRun ? { params: { dryRun: \"1\" } } : {}),\n }),\n assetUnpublish: (id) => call(`/api/v1/assets/${id}/unpublish`, { method: \"POST\", body: {} }),\n namespaceAvailability: (ns) =>\n call(`/api/v1/namespaces/${encodeURIComponent(ns)}/availability`),\n };\n}\n","/**\n * Shared store-interaction core for the two publish front-ends — the curator\n * sidecar flow (`source manifest publish`) and the first-party library flow\n * (`library publish`). Both differ only in their git side-effects + how they\n * resolve the source repo; the store orchestration below (register → sync →\n * candidates → per-asset preview+publish) is identical.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * so the orchestration stays unit/integration-testable without a live store.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport type { SkPublishManifest } from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport type { PublisherClient } from \"../store-publisher.ts\";\n\n/**\n * One-line rendering of a namespace-availability probe for a `--dry-run` plan.\n * The `message` is store-authored (identical to what a real publish would echo)\n * — we only prepend a status glyph so the reader sees green/amber/red at a\n * glance without the CLI re-deriving any authorization logic.\n */\nexport function formatNamespaceAvailability(a: {\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n message: string;\n}): string {\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return `${S.ok(\"✓\")} ${a.message}`;\n case \"claimable-by-you\":\n return `${S.warn(\"!\")} ${a.message}`;\n default:\n return `${S.err(\"✗\")} ${a.message}`;\n }\n}\n\n/**\n * Preflight the target namespace against the store's availability probe BEFORE a\n * publish does any irreversible work (a public git push). Returns `{ ok: false }`\n * with a guided message for `reserved` (not yours) and `claimable-by-you` (must\n * claim first) — the two states a real publish would reject — so the caller can\n * abort with actionable guidance instead of a raw 422 after pushing bytes.\n *\n * The probe is advisory: any failure (offline, older store) returns `{ ok: true }`\n * so the store stays the authority and a valid publish is never blocked.\n */\nexport async function preflightNamespace(\n client: PublisherClient,\n namespace: string,\n): Promise<{ ok: boolean; message?: string }> {\n let a: Awaited<ReturnType<PublisherClient[\"namespaceAvailability\"]>>;\n try {\n a = await client.namespaceAvailability(namespace);\n } catch {\n return { ok: true };\n }\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return { ok: true };\n case \"claimable-by-you\":\n return {\n ok: false,\n message:\n `@${namespace} isn't yours yet — claim it in the store first` +\n `${a.claimMethod ? ` (${a.claimMethod})` : \"\"}, then re-run. ${a.message}`,\n };\n default: // reserved, or any unrecognized future status (fail safe → block)\n return { ok: false, message: `Cannot publish under @${namespace} — ${a.message}` };\n }\n}\n\n/** One candidate row shape the matcher operates on (kind + name are the key). */\ninterface CandidateLike {\n kind: string;\n name: string;\n}\n\n/**\n * Keep only candidates whose `(kind, name)` pair is declared in the manifest.\n * The backend may merge extra assets from the base repo into the candidate\n * list; a publish only touches what the manifest curated/declared.\n */\nexport function matchCandidatesToManifest<T extends CandidateLike>(\n candidates: T[],\n manifest: SkPublishManifest,\n): T[] {\n const wanted = new Set((manifest.assets ?? []).map((a) => `${a.kind}:${a.name}`));\n return candidates.filter((c) => wanted.has(`${c.kind}:${c.name}`));\n}\n\n/** A canonical ref string `kind:@publisher/name[#version]` for reporting. */\nexport function refFor(kind: string, publisher: string, name: string, version?: string): string {\n const base = `${kind}:@${publisher}/${name}`;\n return version ? `${base}#${version}` : base;\n}\n\n/** The bare asset name from a `kind:@publisher/name#version` ref or a plain name. */\nexport function bareName(ref: string): string {\n const afterKind = ref.includes(\":\") ? ref.slice(ref.indexOf(\":\") + 1) : ref;\n const afterScope = afterKind.includes(\"/\")\n ? afterKind.slice(afterKind.indexOf(\"/\") + 1)\n : afterKind;\n return afterScope.split(\"#\")[0];\n}\n\n/**\n * Poll a job until it leaves `running` or the deadline passes. Returns the last\n * observed state — the caller MUST treat a still-`running` result as a timeout\n * (not success), since it means the deadline was hit before the job finished.\n */\nexport async function pollJob(\n client: PublisherClient,\n jobId: string,\n intervalMs = 1_500,\n timeoutMs = 60_000,\n): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }> {\n const deadline = Date.now() + timeoutMs;\n let job = await client.jobGet(jobId);\n while (job.status === \"running\" && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, intervalMs));\n job = await client.jobGet(jobId);\n }\n return job;\n}\n\n/**\n * True when a `sourcesAdd` rejection is a duplicate-URL conflict (the source is\n * already registered) — the only error the publish flow recovers from by looking\n * the existing row up. Every other failure (auth, 5xx, network) must propagate.\n */\nexport function isDupSourceError(err: unknown): boolean {\n const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();\n return /\\b409\\b|conflict|duplicate|already exists|already registered|unique/.test(msg);\n}\n\n/**\n * Register + sync the source, then publish its curated/declared candidates —\n * the store-side steps shared by both publish front-ends. Git side-effects (the\n * sidecar push, or the library commit+push) happen in the caller *before* this;\n * this function is purely store interaction.\n *\n * The sidecar front-end passes `sidecar` (so `sourcesAdd` carries the sidecar\n * pin); the library front-end omits it (the source repo IS the manifest host).\n * `assetName`, when set, narrows publication to the single candidate of that\n * name. Fatal store states (`sourcesAdd` non-dup failure) surface; sync failures\n * and empty candidate sets `process.exit(1)` with the same messages as before.\n */\nexport async function publishToStore(opts: {\n sourceUrl: string;\n ref: string;\n sidecar?: { url: string; ref: string };\n manifest: SkPublishManifest;\n assetName?: string;\n client: PublisherClient;\n}): Promise<{ published: string[] }> {\n const { sourceUrl, ref, sidecar, manifest, assetName, client: pub } = opts;\n\n let sourceId: string;\n try {\n const added = await pub.sourcesAdd({\n url: sourceUrl,\n ref,\n ...(sidecar ? { sidecarUrl: sidecar.url, sidecarRef: sidecar.ref } : {}),\n // Publish under the manifest's declared namespace; the store resolves a\n // claimed Publisher when it differs from the caller's login, else defaults\n // to `@<username>`. Omitted when the manifest carries no publisher.\n ...(manifest.publisher ? { namespace: manifest.publisher } : {}),\n });\n sourceId = added.id;\n } catch (err) {\n // Only a duplicate-url conflict is recoverable (source already registered);\n // auth/5xx/network failures must surface, not silently reuse a stale row.\n if (!isDupSourceError(err)) throw err;\n const rows = await pub.sourcesList();\n const found = rows.find((r) => r.url === sourceUrl);\n if (!found) {\n throw new Error(\n `Source ${sourceUrl} looked already-registered but no owned row matched: ` +\n `${err instanceof Error ? err.message : String(err)}`,\n );\n }\n sourceId = found.id;\n }\n\n const { jobId } = await pub.sourceSync(sourceId);\n const job = await pollJob(pub, jobId);\n if (job.status === \"failed\" || job.status === \"cancelled\") {\n const failed = (job.items ?? []).filter((i) => i.status === \"failed\");\n for (const i of failed) logErr(`sync: ${i.label}: ${i.error ?? \"failed\"}`);\n logErr(`Source sync ${job.status}.`);\n process.exit(1);\n }\n // A still-`running` job means the poll deadline was hit — do NOT proceed on an\n // unfinished sync (it would read incomplete candidates).\n if (job.status === \"running\") {\n logErr(\"Source sync timed out before completing — re-run `publish`, or check the store.\");\n process.exit(1);\n }\n\n let candidates = matchCandidatesToManifest(await pub.sourceCandidates(sourceId), manifest);\n if (assetName) candidates = candidates.filter((c) => c.name === assetName);\n if (candidates.length === 0) {\n logWarn(\"No candidates discovered — check the manifest and the source ref.\");\n process.exit(1);\n }\n\n const published: string[] = [];\n for (const c of candidates) {\n try {\n const preview = await pub.assetPreview(c.id);\n const res = await pub.assetPublish(c.id, { ref, files: preview.discoveredFiles });\n // Publish is async — wait for the job so we only report refs that actually\n // landed, not ones whose import is still in flight or about to fail.\n if (res.jobId) {\n const pubJob = await pollJob(pub, res.jobId);\n if (pubJob.status !== \"succeeded\") {\n const errs = (pubJob.items ?? [])\n .filter((i) => i.status === \"failed\")\n .map((i) => i.error)\n .filter(Boolean);\n logWarn(\n `Publish of ${c.kind}:${c.name} did not succeed (${pubJob.status})` +\n (errs.length ? `: ${errs.join(\"; \")}` : \"\"),\n );\n continue;\n }\n }\n published.push(refFor(c.kind, preview.candidate.publisherNamespace, c.name, c.version));\n } catch (err) {\n logWarn(\n `Failed to publish ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Published ${published.length} asset(s):`);\n for (const r of published) logInfo(` ${r}`);\n return { published };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/store-publisher.ts","../cli/src/commands/publish-core.ts"],"names":[],"mappings":";;;;AA+FO,SAAS,uBAAA,CACd,MAAA,GAAsB,cAAA,EAAe,EACrC,YAAY,GAAA,EACK;AAGjB,EAAA,MAAM,IAAA,GAAO,OACX,IAAA,EACA,IAAA,KACe;AACf,IAAA,MAAM,GAAA,GAAM,MAAM,aAAA,EAAc;AAChC,IAAA,OAAO,UAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,GAAA,EAAI,EAAG,IAAA,EAAM,EAAE,SAAA,EAAW,GAAG,IAAA,EAAM,CAAA;AAAA,EACvE,CAAA;AACA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,MAAM,IAAA,CAAK,YAAY,CAAA;AAAA,IAC3B,UAAA,EAAY,CAAC,IAAA,KAAS,IAAA,CAAK,mBAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,CAAA;AAAA,IACtE,WAAA,EAAa,MAAM,IAAA,CAAK,iBAAiB,CAAA;AAAA,IACzC,UAAA,EAAY,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,gBAAA,EAAmB,EAAE,CAAA,KAAA,CAAA,EAAS,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,IACnF,QAAQ,CAAC,KAAA,KAAU,IAAA,CAAK,CAAA,aAAA,EAAgB,KAAK,CAAA,CAAE,C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AAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OAC5F;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,UAAA,EAAa,SAAA,CAAU,MAAM,CAAA,UAAA,CAAY,CAAA;AAC/C,EAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC3C,EAAA,OAAO,EAAE,SAAA,EAAU;AACrB","file":"chunk-SY4I5SHD.js","sourcesContent":["/**\n * Typed REST client for the AI Asset Store **publisher** surface — the\n * curator-publish flow (`skaile source manifest publish` / `yank`). Thin\n * wrappers over {@link storeFetch}; every method maps 1:1 to an `/api/v1/…`\n * endpoint. The {@link PublisherClient} interface is injectable so the\n * orchestration in `commands/source-manifest-publish.ts` can be unit-tested\n * against a fake without a live store.\n *\n * @docLink cli/dev-guide#store-publisher\n */\n\nimport { getStoreConfig, getStoreToken, type StoreConfig, storeFetch } from \"./store-client.ts\";\n\n/**\n * The publisher REST surface used by the curator-publish flow. Kept minimal —\n * only the endpoints `runPublish` / `runYank` actually call. Response shapes\n * are narrowed to the fields the orchestration reads (the server returns more).\n */\nexport interface PublisherClient {\n /**\n * Identity of the caller. `username` is the Keycloak login (personal-tier\n * namespace); `githubLogin` is the verified GitHub handle when connected —\n * the namespace to publish under when it differs from the login.\n */\n me(): Promise<{ username: string; githubLogin?: string | null }>;\n /** Register (or re-register) a source; returns the created/existing row id. */\n sourcesAdd(body: {\n url: string;\n ref: string;\n sidecarUrl?: string;\n sidecarRef?: string;\n /**\n * Target publisher namespace (the manifest's `publisher`). When it differs\n * from the caller's login username, the store resolves the CLAIMED Publisher\n * for it (the store must already have the claim). Omitted → the store\n * defaults to `@<username>` (personal).\n */\n namespace?: string;\n }): Promise<{ id: string }>;\n /** List sources — used to recover an id when `sourcesAdd` rejects a dup url. */\n sourcesList(): Promise<Array<{ id: string; url: string }>>;\n /** Kick off a source sync; returns the async job id to poll. */\n sourceSync(id: string): Promise<{ jobId: string }>;\n /** Poll a job's terminal status + per-item results. */\n jobGet(\n jobId: string,\n ): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }>;\n /** Discovered publishable candidates for a synced source. */\n sourceCandidates(id: string): Promise<\n Array<{\n id: string;\n name: string;\n version: string;\n kind: string;\n published: boolean;\n assetRoot: string;\n }>\n >;\n /** Per-asset preview — the discovered file set + resolved candidate metadata. */\n assetPreview(id: string): Promise<{\n discoveredFiles: string[];\n candidate: { name: string; version: string; kind: string; publisherNamespace: string };\n }>;\n /**\n * Publish one asset. `dryRun` returns the would-be `{ manifest }` without\n * launching a job; the normal path returns `{ jobId }`.\n */\n assetPublish(\n id: string,\n body: { ref: string; files: string[] },\n dryRun?: boolean,\n ): Promise<{ jobId?: string; manifest?: unknown }>;\n /** Retract a published asset. Response body is ignored. */\n assetUnpublish(id: string): Promise<unknown>;\n /**\n * Read-only \"can I publish under `@<ns>` right now, and if not, what's the\n * path?\" probe. Backs the `publish --dry-run` namespace status line; its\n * `message` is store-authored and meant to be surfaced verbatim.\n */\n namespaceAvailability(ns: string): Promise<{\n namespace: string;\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n claimMethod?: string;\n message: string;\n }>;\n}\n\n/**\n * Construct the real HTTP-backed {@link PublisherClient}. Every call carries a\n * longer timeout than the default store client because publish/sync trigger\n * server-side clone work.\n *\n * @param config - Store connection config; defaults to {@link getStoreConfig}.\n * @param timeoutMs - Per-request abort timeout (default 20s).\n */\nexport function makeHttpPublisherClient(\n config: StoreConfig = getStoreConfig(),\n timeoutMs = 20_000,\n): PublisherClient {\n // Acquire a fresh Keycloak token per call (device-flow session in\n // ~/.skaile/auth.json, refreshed on demand) rather than a static config.jwt.\n const call = async <T>(\n path: string,\n opts?: { method?: string; body?: unknown; params?: Record<string, string> },\n ): Promise<T> => {\n const jwt = await getStoreToken();\n return storeFetch<T>({ ...config, jwt }, path, { timeoutMs, ...opts });\n };\n return {\n me: () => call(\"/api/v1/me\"),\n sourcesAdd: (body) => call(\"/api/v1/sources\", { method: \"POST\", body }),\n sourcesList: () => call(\"/api/v1/sources\"),\n sourceSync: (id) => call(`/api/v1/sources/${id}/sync`, { method: \"POST\", body: {} }),\n jobGet: (jobId) => call(`/api/v1/jobs/${jobId}`),\n sourceCandidates: (id) => call(`/api/v1/sources/${id}/candidates`),\n assetPreview: (id) => call(`/api/v1/assets/${id}/preview`),\n assetPublish: (id, body, dryRun) =>\n call(`/api/v1/assets/${id}/publish`, {\n method: \"POST\",\n body,\n ...(dryRun ? { params: { dryRun: \"1\" } } : {}),\n }),\n assetUnpublish: (id) => call(`/api/v1/assets/${id}/unpublish`, { method: \"POST\", body: {} }),\n namespaceAvailability: (ns) =>\n call(`/api/v1/namespaces/${encodeURIComponent(ns)}/availability`),\n };\n}\n","/**\n * Shared store-interaction core for the two publish front-ends — the curator\n * sidecar flow (`source manifest publish`) and the first-party library flow\n * (`library publish`). Both differ only in their git side-effects + how they\n * resolve the source repo; the store orchestration below (register → sync →\n * candidates → per-asset preview+publish) is identical.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * so the orchestration stays unit/integration-testable without a live store.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport type { SkPublishManifest } from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport type { PublisherClient } from \"../store-publisher.ts\";\n\n/**\n * One-line rendering of a namespace-availability probe for a `--dry-run` plan.\n * The `message` is store-authored (identical to what a real publish would echo)\n * — we only prepend a status glyph so the reader sees green/amber/red at a\n * glance without the CLI re-deriving any authorization logic.\n */\nexport function formatNamespaceAvailability(a: {\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n message: string;\n}): string {\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return `${S.ok(\"✓\")} ${a.message}`;\n case \"claimable-by-you\":\n return `${S.warn(\"!\")} ${a.message}`;\n default:\n return `${S.err(\"✗\")} ${a.message}`;\n }\n}\n\n/**\n * Preflight the target namespace against the store's availability probe BEFORE a\n * publish does any irreversible work (a public git push). Returns `{ ok: false }`\n * with a guided message for `reserved` (not yours) and `claimable-by-you` (must\n * claim first) — the two states a real publish would reject — so the caller can\n * abort with actionable guidance instead of a raw 422 after pushing bytes.\n *\n * The probe is advisory: any failure (offline, older store) returns `{ ok: true }`\n * so the store stays the authority and a valid publish is never blocked.\n */\nexport async function preflightNamespace(\n client: PublisherClient,\n namespace: string,\n): Promise<{ ok: boolean; message?: string }> {\n let a: Awaited<ReturnType<PublisherClient[\"namespaceAvailability\"]>>;\n try {\n a = await client.namespaceAvailability(namespace);\n } catch {\n return { ok: true };\n }\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return { ok: true };\n case \"claimable-by-you\":\n return {\n ok: false,\n message:\n `@${namespace} isn't yours yet — claim it in the store first` +\n `${a.claimMethod ? ` (${a.claimMethod})` : \"\"}, then re-run. ${a.message}`,\n };\n default: // reserved, or any unrecognized future status (fail safe → block)\n return { ok: false, message: `Cannot publish under @${namespace} — ${a.message}` };\n }\n}\n\n/** One candidate row shape the matcher operates on (kind + name are the key). */\ninterface CandidateLike {\n kind: string;\n name: string;\n}\n\n/**\n * Keep only candidates whose `(kind, name)` pair is declared in the manifest.\n * The backend may merge extra assets from the base repo into the candidate\n * list; a publish only touches what the manifest curated/declared.\n */\nexport function matchCandidatesToManifest<T extends CandidateLike>(\n candidates: T[],\n manifest: SkPublishManifest,\n): T[] {\n const wanted = new Set((manifest.assets ?? []).map((a) => `${a.kind}:${a.name}`));\n return candidates.filter((c) => wanted.has(`${c.kind}:${c.name}`));\n}\n\n/** A canonical ref string `kind:@publisher/name[#version]` for reporting. */\nexport function refFor(kind: string, publisher: string, name: string, version?: string): string {\n const base = `${kind}:@${publisher}/${name}`;\n return version ? `${base}#${version}` : base;\n}\n\n/** The bare asset name from a `kind:@publisher/name#version` ref or a plain name. */\nexport function bareName(ref: string): string {\n const afterKind = ref.includes(\":\") ? ref.slice(ref.indexOf(\":\") + 1) : ref;\n const afterScope = afterKind.includes(\"/\")\n ? afterKind.slice(afterKind.indexOf(\"/\") + 1)\n : afterKind;\n return afterScope.split(\"#\")[0];\n}\n\n/**\n * Poll a job until it leaves `running` or the deadline passes. Returns the last\n * observed state — the caller MUST treat a still-`running` result as a timeout\n * (not success), since it means the deadline was hit before the job finished.\n */\nexport async function pollJob(\n client: PublisherClient,\n jobId: string,\n intervalMs = 1_500,\n timeoutMs = 60_000,\n): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }> {\n const deadline = Date.now() + timeoutMs;\n let job = await client.jobGet(jobId);\n while (job.status === \"running\" && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, intervalMs));\n job = await client.jobGet(jobId);\n }\n return job;\n}\n\n/**\n * True when a `sourcesAdd` rejection is a duplicate-URL conflict (the source is\n * already registered) — the only error the publish flow recovers from by looking\n * the existing row up. Every other failure (auth, 5xx, network) must propagate.\n */\nexport function isDupSourceError(err: unknown): boolean {\n const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();\n return /\\b409\\b|conflict|duplicate|already exists|already registered|unique/.test(msg);\n}\n\n/**\n * Register + sync the source, then publish its curated/declared candidates —\n * the store-side steps shared by both publish front-ends. Git side-effects (the\n * sidecar push, or the library commit+push) happen in the caller *before* this;\n * this function is purely store interaction.\n *\n * The sidecar front-end passes `sidecar` (so `sourcesAdd` carries the sidecar\n * pin); the library front-end omits it (the source repo IS the manifest host).\n * `assetName`, when set, narrows publication to the single candidate of that\n * name. Fatal store states (`sourcesAdd` non-dup failure) surface; sync failures\n * and empty candidate sets `process.exit(1)` with the same messages as before.\n */\nexport async function publishToStore(opts: {\n sourceUrl: string;\n ref: string;\n sidecar?: { url: string; ref: string };\n manifest: SkPublishManifest;\n assetName?: string;\n client: PublisherClient;\n}): Promise<{ published: string[] }> {\n const { sourceUrl, ref, sidecar, manifest, assetName, client: pub } = opts;\n\n let sourceId: string;\n try {\n const added = await pub.sourcesAdd({\n url: sourceUrl,\n ref,\n ...(sidecar ? { sidecarUrl: sidecar.url, sidecarRef: sidecar.ref } : {}),\n // Publish under the manifest's declared namespace; the store resolves a\n // claimed Publisher when it differs from the caller's login, else defaults\n // to `@<username>`. Omitted when the manifest carries no publisher.\n ...(manifest.publisher ? { namespace: manifest.publisher } : {}),\n });\n sourceId = added.id;\n } catch (err) {\n // Only a duplicate-url conflict is recoverable (source already registered);\n // auth/5xx/network failures must surface, not silently reuse a stale row.\n if (!isDupSourceError(err)) throw err;\n const rows = await pub.sourcesList();\n const found = rows.find((r) => r.url === sourceUrl);\n if (!found) {\n throw new Error(\n `Source ${sourceUrl} looked already-registered but no owned row matched: ` +\n `${err instanceof Error ? err.message : String(err)}`,\n );\n }\n sourceId = found.id;\n }\n\n const { jobId } = await pub.sourceSync(sourceId);\n const job = await pollJob(pub, jobId);\n if (job.status === \"failed\" || job.status === \"cancelled\") {\n const failed = (job.items ?? []).filter((i) => i.status === \"failed\");\n for (const i of failed) logErr(`sync: ${i.label}: ${i.error ?? \"failed\"}`);\n logErr(`Source sync ${job.status}.`);\n process.exit(1);\n }\n // A still-`running` job means the poll deadline was hit — do NOT proceed on an\n // unfinished sync (it would read incomplete candidates).\n if (job.status === \"running\") {\n logErr(\"Source sync timed out before completing — re-run `publish`, or check the store.\");\n process.exit(1);\n }\n\n let candidates = matchCandidatesToManifest(await pub.sourceCandidates(sourceId), manifest);\n if (assetName) candidates = candidates.filter((c) => c.name === assetName);\n if (candidates.length === 0) {\n logWarn(\"No candidates discovered — check the manifest and the source ref.\");\n process.exit(1);\n }\n\n const published: string[] = [];\n for (const c of candidates) {\n try {\n const preview = await pub.assetPreview(c.id);\n const res = await pub.assetPublish(c.id, { ref, files: preview.discoveredFiles });\n // Publish is async — wait for the job so we only report refs that actually\n // landed, not ones whose import is still in flight or about to fail.\n if (res.jobId) {\n const pubJob = await pollJob(pub, res.jobId);\n if (pubJob.status !== \"succeeded\") {\n const errs = (pubJob.items ?? [])\n .filter((i) => i.status === \"failed\")\n .map((i) => i.error)\n .filter(Boolean);\n logWarn(\n `Publish of ${c.kind}:${c.name} did not succeed (${pubJob.status})` +\n (errs.length ? `: ${errs.join(\"; \")}` : \"\"),\n );\n continue;\n }\n }\n published.push(refFor(c.kind, preview.candidate.publisherNamespace, c.name, c.version));\n } catch (err) {\n logWarn(\n `Failed to publish ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Published ${published.length} asset(s):`);\n for (const r of published) logInfo(` ${r}`);\n return { published };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logErr, logWarn, S, logOk, logInfo } from './chunk-
|
|
1
|
+
import { logErr, logWarn, S, logOk, logInfo } from './chunk-5366G4XM.js';
|
|
2
2
|
import { catalogLayer, getProviderPreset, expandPreset, listProviderPresets, presetBaseUrl, probeProviderEntry } from './chunk-IRGI7Q62.js';
|
|
3
3
|
import { loadProviderRegistry, saveProviderRegistryFile, workspaceProviderRegistryPath, userProviderRegistryPath } from './chunk-UWU572Q6.js';
|
|
4
4
|
import { resolveCredential } from './chunk-DPLIN2RA.js';
|
|
@@ -496,5 +496,5 @@ function makeProvidersCommand() {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
export { ProviderRegistryWriteError, addProviderEntry, credentialEnvVarName, loadRegistryView, makeProvidersCommand };
|
|
499
|
-
//# sourceMappingURL=chunk-
|
|
500
|
-
//# sourceMappingURL=chunk-
|
|
499
|
+
//# sourceMappingURL=chunk-WGZUG26K.js.map
|
|
500
|
+
//# sourceMappingURL=chunk-WGZUG26K.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/commands/providers.ts"],"names":[],"mappings":";;;;;;;;;AAkDA,IAAM,aAAA,GAAgB,QAAA;AAStB,SAAS,WAAW,IAAA,EAAmE;AACrF,EAAA,IAAI,KAAK,SAAA,EAAW;AAClB,I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\n *\n * Endpoints are defined once, in `~/.skaile/providers.yml`, optionally\n * overridden per project in `<workspace>/.skaile/providers.yml` (gitignored by\n * `skaile init`). Every subcommand writes exactly one of those two files and\n * validates the result before it lands — a literal secret never reaches disk.\n *\n * @see PROVIDER-CONFIG-PLAN.md §1, §2.5\n */\n\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport {\n catalogLayer,\n expandPreset,\n getProviderPreset,\n listProviderPresets,\n presetBaseUrl,\n probeProviderEntry,\n} from \"@skaile/workspaces/bridge\";\nimport {\n AI_PROVIDER_LAYERS,\n AI_PROVIDER_SURFACES,\n type AIProviderDiagnostic,\n type AIProviderEntry,\n type AIProviderLayerId,\n type AIProviderLlmEntry,\n type AIProviderRegistryDocument,\n type AIProviderSurface,\n entryTransport,\n isEntryEnabled,\n isSafeProviderId,\n loadProviderRegistry,\n type MergedAIProviderRegistry,\n mergeRegistries,\n parseCredentialRef,\n type ProviderRegistryFile,\n resolveCredential,\n resolveEntryBaseUrl,\n saveProviderRegistryFile,\n userProviderRegistryPath,\n validateMergedRegistry,\n validateRegistry,\n workspaceProviderRegistryPath,\n} from \"@skaile/workspaces/core\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\n\n/** Preset id that means \"no preset — I will supply the three literals\". */\nconst CUSTOM_PRESET = \"custom\";\n\n/** Which of the two registry files a command reads or writes. */\nexport interface ScopeOptions {\n projectDir?: string;\n workspace?: boolean;\n}\n\n/** The file a mutating subcommand writes: the workspace layer or the user one. */\nfunction targetFile(opts: ScopeOptions): { layer: \"user\" | \"workspace\"; path: string } {\n if (opts.workspace) {\n return { layer: \"workspace\", path: workspaceProviderRegistryPath(resolveProjectDir(opts)) };\n }\n return { layer: \"user\", path: userProviderRegistryPath() };\n}\n\n/** Project directory a subcommand operates on — `--project-dir` or the cwd. */\nfunction resolveProjectDir(opts: ScopeOptions): string {\n return opts.projectDir ? path.resolve(opts.projectDir) : process.cwd();\n}\n\n/** Both file layers plus the catalog, merged — what every reader sees. */\nexport interface RegistryView {\n merged: MergedAIProviderRegistry;\n files: ProviderRegistryFile[];\n diagnostics: AIProviderDiagnostic[];\n}\n\n/**\n * Load both file layers and merge them with the catalog layer the configured\n * `preset:` keys pull in, then gate the result. Read once, merged twice — the\n * catalog layer can only be built after the configured entries are known,\n * and it is built from the **pre-gate** merge: an entry that leaves `kind` or\n * its transport `params` to the preset fails the first gate by design.\n *\n * The gate is on the merged view, not per file: a workspace entry that sets\n * one field of an entry the user file defines is an override (§1.5), so it is\n * only here that an entry can be judged complete.\n */\nexport function loadRegistryView(opts: ScopeOptions): RegistryView {\n const loaded = loadProviderRegistry({ projectDir: resolveProjectDir(opts) });\n const fileLayers = loaded.files.map((file) => ({\n layer: file.layer as AIProviderLayerId,\n providers: file.document.providers,\n }));\n const catalog = catalogLayer(loaded.patches);\n const { registry, diagnostics } = validateMergedRegistry(\n mergeRegistries([...fileLayers, catalog]),\n {\n sources: [\n ...loaded.files.map((file) => ({ label: file.path, providers: file.document.providers })),\n ],\n },\n );\n return {\n merged: registry,\n files: loaded.files,\n // `loaded.diagnostics` already carries the merge notes for the file layers\n // alone; this second merge adds the catalog, so its notes replace them.\n diagnostics: [...loaded.files.flatMap((file) => file.diagnostics), ...diagnostics],\n };\n}\n\n/** Print diagnostics; returns how many were errors. */\nfunction reportDiagnostics(diagnostics: AIProviderDiagnostic[]): number {\n let errors = 0;\n for (const diagnostic of diagnostics) {\n const where = diagnostic.path ? `${diagnostic.path}: ` : \"\";\n if (diagnostic.severity === \"error\") {\n errors++;\n logErr(`${where}${diagnostic.message}`);\n } else {\n logWarn(`${where}${diagnostic.message}`);\n }\n }\n return errors;\n}\n\n/** Highest layer that pins an entry with `locked: true`. */\nfunction lockOwner(id: string, files: ProviderRegistryFile[]): AIProviderLayerId | undefined {\n let owner: AIProviderLayerId | undefined;\n for (const file of files) {\n if (file.document.providers[id]?.locked) {\n const layer = file.layer as AIProviderLayerId;\n if (!owner || AI_PROVIDER_LAYERS.indexOf(layer) > AI_PROVIDER_LAYERS.indexOf(owner)) {\n owner = layer;\n }\n }\n }\n return owner;\n}\n\n/**\n * The message for an edit a lock forbids, or `undefined` when it is allowed.\n * The merge ignores a lower layer silently; the CLI must not, or the operator\n * would watch an accepted edit have no effect.\n *\n * `set <id> locked <value>` stays legal at the locking layer itself —\n * otherwise a lock could never be lifted without hand-editing the file.\n */\nfunction lockConflict(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): string | undefined {\n const owner = lockOwner(id, files);\n if (!owner) return undefined;\n const ownerRank = AI_PROVIDER_LAYERS.indexOf(owner);\n const targetRank = AI_PROVIDER_LAYERS.indexOf(target.layer);\n if (ownerRank === targetRank && key === \"locked\") return undefined;\n if (ownerRank < targetRank) return undefined;\n return (\n `'${id}' is locked by the ${owner} layer and cannot be changed from ${target.layer}.\\n` +\n (ownerRank === targetRank\n ? ` Unlock it first: skaile providers set ${id} locked false`\n : ` A higher layer owns this entry — change it there.`)\n );\n}\n\n/** Refuse loudly when a locked entry would be edited. */\nfunction exitIfLocked(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): void {\n const message = lockConflict(id, target, files, key);\n if (!message) return;\n logErr(message);\n process.exit(1);\n}\n\n/** Read the target file, or an empty document when it does not exist yet. */\nfunction readTargetDocument(\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n): AIProviderRegistryDocument {\n const file = files.find((f) => f.path === target.path);\n return file?.document ?? { version: 1, providers: {} };\n}\n\n/**\n * Validate the file that is about to be written; exits non-zero on errors.\n *\n * Validated as the layer it is, so `set` may leave a one-field override in the\n * workspace file (§1.5). Completeness is the merged registry's business, and\n * `loadRegistryView` reports it on the next read.\n */\nfunction validateOrExit(\n document: AIProviderRegistryDocument,\n target: { layer: \"user\" | \"workspace\"; path: string },\n): void {\n const { diagnostics } = validateRegistry(\n { version: 1, providers: document.providers },\n { source: target.path, layer: target.layer },\n );\n if (reportDiagnostics(diagnostics) > 0) process.exit(1);\n}\n\n// ── list ───────────────────────────────────────────────────────────────────\n\nfunction pad(value: string, width: number): string {\n return value.length >= width ? value : value + \" \".repeat(width - value.length);\n}\n\nfunction credentialSummary(entry: AIProviderEntry): string {\n const credential = entry.credential;\n if (!credential || credential.kind === \"none\") return \"none\";\n return credential.ref ? `${credential.kind} ${credential.ref}` : credential.kind;\n}\n\nfunction printPresets(): void {\n const presets = listProviderPresets();\n console.log();\n console.log(` ${S.heading(\"Catalog presets\")}`);\n const idWidth = Math.max(...presets.map((x) => x.id.length)) + 2;\n const surfaceWidth = Math.max(...AI_PROVIDER_SURFACES.map((s) => s.length)) + 2;\n const header = `${pad(\"preset\", idWidth)}${pad(\"kind\", 7)}${pad(\"surface\", surfaceWidth)}${pad(\"transport\", 14)}default base URL`;\n console.log(` ${S.dim(header)}`);\n for (const preset of presets) {\n const row =\n pad(preset.id, idWidth) +\n pad(preset.kind, 7) +\n pad(preset.surface ?? \"—\", surfaceWidth) +\n pad(\n preset.kind === \"llm\" || preset.kind === \"embed\" ? (preset.transport ?? \"direct\") : \"—\",\n 14,\n ) +\n (presetBaseUrl(preset) ?? \"—\");\n console.log(` ${row}`);\n }\n}\n\nfunction printConfigured(view: RegistryView): void {\n const ids = view.merged.order;\n console.log();\n console.log(` ${S.heading(\"Configured providers\")}`);\n if (ids.length === 0) {\n console.log(\n ` ${S.dim(\"none — add one with\")} ${S.cmd(\"skaile providers add --preset <preset>\")}`,\n );\n console.log();\n return;\n }\n const idWidth = Math.max(...ids.map((id) => id.length)) + 2;\n const header = `${pad(\"id\", idWidth)}${pad(\"layer\", 11)}${pad(\"surface\", 26)}${pad(\"transport\", 14)}endpoint`;\n console.log(` ${S.dim(header)}`);\n for (const id of ids) {\n const entry = view.merged.providers[id];\n const surface = (entry as AIProviderLlmEntry).surface ?? \"—\";\n const transport = entryTransport(entry) ?? \"—\";\n const url = resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\");\n const flags = [\n isEntryEnabled(entry) ? \"\" : S.warn(\"disabled\"),\n entry.locked ? S.warn(\"locked\") : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n console.log(\n ` ${pad(id, idWidth)}${pad(view.merged.origin[id], 11)}${pad(surface, 26)}${pad(transport, 14)}${url} ${flags}`.trimEnd(),\n );\n console.log(` ${S.dim(`${pad(\"\", idWidth)}${credentialSummary(entry)}`)}`);\n }\n console.log();\n}\n\n// ── add ────────────────────────────────────────────────────────────────────\n\ninterface AddOptions extends ScopeOptions {\n preset?: string;\n credential?: string;\n baseUrl?: string;\n surface?: string;\n label?: string;\n kind?: string;\n param: string[];\n force?: boolean;\n}\n\nfunction parseParams(pairs: string[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const pair of pairs) {\n const eq = pair.indexOf(\"=\");\n if (eq <= 0) {\n logErr(`--param expects <key>=<value> (got '${pair}')`);\n process.exit(1);\n }\n out[pair.slice(0, eq)] = pair.slice(eq + 1);\n }\n return out;\n}\n\n/** Ask for the three literals a custom endpoint needs. Nothing else. */\nasync function promptCustomEntry(\n id: string,\n opts: AddOptions,\n): Promise<{ surface: AIProviderSurface; baseUrl: string; credentialRef: string }> {\n const interactive = process.stdin.isTTY === true;\n let surface = opts.surface as AIProviderSurface | undefined;\n let baseUrl = opts.baseUrl;\n let credentialRef = opts.credential;\n\n if (!interactive && (!surface || !baseUrl || !credentialRef)) {\n logErr(\n \"--preset custom needs --surface, --base-url and --credential when there is no terminal to prompt on\",\n );\n process.exit(1);\n }\n\n if (!surface) {\n const answer = await p.select({\n message: \"Wire surface:\",\n options: AI_PROVIDER_SURFACES.map((value) => ({ value, label: value })),\n initialValue: \"openai-completions\" as AIProviderSurface,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n surface = answer as AIProviderSurface;\n }\n if (!baseUrl) {\n const answer = await p.text({\n message: \"Base URL:\",\n placeholder: \"https://api.example.com/v1\",\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n baseUrl = answer as string;\n }\n if (!credentialRef) {\n const answer = await p.text({\n message: \"Credential reference (env:NAME, cmd:<shell>, platform:<id>, keyring:<svc>/<acct>):\",\n initialValue: `env:${id.toUpperCase().replace(/[^A-Z0-9]/g, \"_\")}_API_KEY`,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n credentialRef = answer as string;\n }\n return { surface, baseUrl, credentialRef };\n}\n\n/** A rejected registry write. The message is already CLI-ready. */\nexport class ProviderRegistryWriteError extends Error {}\n\n/** What {@link addProviderEntry} writes. */\nexport interface AddProviderEntryInput extends ScopeOptions {\n /** Registry entry id — `[a-z0-9][a-z0-9_-]*`. */\n id: string;\n /** Catalog preset to expand. Mutually exclusive with `entry`. */\n presetId?: string;\n /** A fully-built entry (the `--preset custom` path, which needs prompts). */\n entry?: AIProviderEntry;\n /** `env:NAME` / `cmd:…` / `platform:…` / `keyring:…` — never a literal. */\n credentialRef?: string;\n baseUrl?: string;\n surface?: AIProviderSurface;\n label?: string;\n params?: Record<string, string>;\n /** Overwrite an entry that already exists in the target file. */\n force?: boolean;\n}\n\n/** Result of {@link addProviderEntry}. */\nexport interface AddedProviderEntry {\n id: string;\n layer: \"user\" | \"workspace\";\n path: string;\n entry: AIProviderEntry;\n /** True when an existing entry in the target file was overwritten. */\n replaced: boolean;\n}\n\n/**\n * Write one entry into a registry file — the single write path behind\n * `skaile providers add` and the `skaile setup` wizard.\n *\n * Throws {@link ProviderRegistryWriteError} instead of exiting, so a wizard\n * can report the failure in its own idiom. Every rejection a caller can\n * provoke (bad id, unknown preset, missing transport parameter, locked entry,\n * a literal secret) lands here, and the document is validated before it is\n * written — a secret cannot reach disk through this function.\n */\nexport function addProviderEntry(input: AddProviderEntryInput): AddedProviderEntry {\n const { id } = input;\n if (!isSafeProviderId(id)) {\n throw new ProviderRegistryWriteError(\n `'${id}' is not a valid entry id — use [a-z0-9][a-z0-9_-]*`,\n );\n }\n if (input.credentialRef && !parseCredentialRef(input.credentialRef)) {\n throw new ProviderRegistryWriteError(\n \"the credential must be a reference, not a secret: \" +\n \"env:NAME, cmd:<shell>, platform:<configId> or keyring:<service>/<account>\",\n );\n }\n\n const view = loadRegistryView(input);\n const target = targetFile(input);\n const locked = lockConflict(id, target, view.files);\n if (locked) throw new ProviderRegistryWriteError(locked);\n\n const document = readTargetDocument(target, view.files);\n const replaced = document.providers[id] !== undefined;\n if (replaced && !input.force) {\n throw new ProviderRegistryWriteError(\n `'${id}' already exists in ${target.path} — pass --force to overwrite it.`,\n );\n }\n\n let entry: AIProviderEntry;\n if (input.entry) {\n entry = input.entry;\n } else {\n const preset = input.presetId ? getProviderPreset(input.presetId) : undefined;\n if (!preset) {\n throw new ProviderRegistryWriteError(\n `Unknown preset '${input.presetId}'. Run \\`skaile providers list\\` to see the catalog, ` +\n \"or use `--preset custom`.\",\n );\n }\n entry = expandPreset(preset, {\n credentialRef: input.credentialRef,\n baseUrl: input.baseUrl,\n surface: input.surface,\n label: input.label,\n params: input.params,\n });\n const missing = (preset.required_params ?? []).filter(\n (key) => !(key in ((entry as AIProviderLlmEntry).params ?? {})),\n );\n if (missing.length > 0) {\n throw new ProviderRegistryWriteError(\n `Preset '${preset.id}' needs ${missing.map((m) => `--param ${m}=<value>`).join(\" \")}`,\n );\n }\n }\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: entry },\n };\n const { diagnostics } = validateRegistry(\n { version: 1, providers: next.providers },\n { source: target.path },\n );\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n if (errors.length > 0) {\n throw new ProviderRegistryWriteError(\n errors.map((d) => (d.path ? `${d.path}: ${d.message}` : d.message)).join(\"\\n\"),\n );\n }\n saveProviderRegistryFile(target.path, next);\n\n return { id, layer: target.layer, path: target.path, entry, replaced };\n}\n\n/** The env var an `env:` credential reference points at, if it is one. */\nexport function credentialEnvVarName(entry: AIProviderEntry): string | undefined {\n const ref = entry.credential?.ref;\n return ref?.startsWith(\"env:\") ? ref.slice(4) : undefined;\n}\n\n/** Build the `--preset custom` entry from the three literals the user gave. */\nfunction customEntry(\n answers: { surface: AIProviderSurface; baseUrl: string; credentialRef: string },\n opts: AddOptions,\n): AIProviderEntry {\n const kind = (opts.kind ?? \"llm\") as AIProviderEntry[\"kind\"];\n // Anthropic- and Google-shaped surfaces read a dedicated API-key header;\n // everything else is a bearer token. `set <id> credential.kind …` adjusts.\n const credentialKind =\n kind === \"stt\" ||\n kind === \"tts\" ||\n answers.surface === \"anthropic-messages\" ||\n answers.surface === \"google-generative-ai\" ||\n answers.surface === \"azure-openai-responses\"\n ? \"api_key_header\"\n : \"bearer\";\n if (kind === \"stt\" || kind === \"tts\") {\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n };\n }\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n surface: answers.surface,\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n } as AIProviderLlmEntry;\n}\n\nasync function runAdd(idArg: string | undefined, opts: AddOptions): Promise<void> {\n const presetId = opts.preset;\n if (!presetId) {\n logErr(\n `--preset is required. Run ${S.cmd(\"skaile providers list\")} for the catalog, ` +\n `or use ${S.cmd(\"--preset custom\")}.`,\n );\n process.exit(1);\n }\n const id = idArg ?? presetId;\n if (id === CUSTOM_PRESET && !idArg) {\n logErr(\"--preset custom needs an entry id: skaile providers add <id> --preset custom\");\n process.exit(1);\n }\n\n const entry =\n presetId === CUSTOM_PRESET ? customEntry(await promptCustomEntry(id, opts), opts) : undefined;\n\n let added: AddedProviderEntry;\n try {\n added = addProviderEntry({\n id,\n ...(entry ? { entry } : { presetId }),\n credentialRef: opts.credential,\n baseUrl: opts.baseUrl,\n surface: opts.surface as AIProviderSurface | undefined,\n label: opts.label,\n params: parseParams(opts.param),\n projectDir: opts.projectDir,\n workspace: opts.workspace,\n force: opts.force,\n });\n } catch (error) {\n logErr(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n\n logOk(`Added ${S.bold(id)} (${presetId}) to the ${added.layer} registry`);\n console.log(S.dim(` → ${added.path}`));\n const name = credentialEnvVarName(added.entry);\n if (name) {\n console.log(\n ` ${S.dim(\"The secret itself never goes in this file — export it:\")} ${S.cmd(`export ${name}=…`)}`,\n );\n }\n console.log(` ${S.dim(\"Verify with:\")} ${S.cmd(`skaile providers test ${id}`)}`);\n}\n\n// ── set / rm ───────────────────────────────────────────────────────────────\n\n/** Coerce a CLI string into the type the schema expects at `key`. */\nfunction coerceValue(key: string, value: string): unknown {\n const leaf = key.split(\".\").pop() ?? key;\n if (leaf === \"enabled\" || leaf === \"locked\" || leaf === \"tools\" || leaf === \"images\") {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n logErr(`'${key}' takes true or false (got '${value}')`);\n process.exit(1);\n }\n if (leaf === \"context_window\" || leaf === \"thinking_max\") {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n logErr(`'${key}' takes a number (got '${value}')`);\n process.exit(1);\n }\n return parsed;\n }\n return value;\n}\n\n/** Write `value` at a dotted path, creating intermediate maps. */\nfunction setDotted(entry: Record<string, unknown>, key: string, value: unknown): void {\n const segments = key.split(\".\");\n let cursor = entry;\n for (const segment of segments.slice(0, -1)) {\n const next = cursor[segment];\n if (typeof next !== \"object\" || next === null || Array.isArray(next)) {\n cursor[segment] = {};\n }\n cursor = cursor[segment] as Record<string, unknown>;\n }\n cursor[segments[segments.length - 1]] = value;\n}\n\nfunction runSet(id: string, key: string, value: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files, key);\n\n const document = readTargetDocument(target, view.files);\n const existing = document.providers[id];\n const inherited = view.merged.providers[id];\n if (!existing && !inherited) {\n logErr(\n `No provider '${id}'. Add it with ${S.cmd(`skaile providers add ${id} --preset <preset>`)}`,\n );\n process.exit(1);\n }\n\n // Writing a field into a layer that has no entry yet leaves a one-field\n // override: the layers below keep supplying the rest (§1.5), so copying\n // their `kind` down here would pin a value this layer does not own.\n const base = (existing ? structuredClone(existing) : {}) as unknown as Record<string, unknown>;\n setDotted(base, key, coerceValue(key, value));\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: base as unknown as AIProviderEntry },\n };\n validateOrExit(next, target);\n saveProviderRegistryFile(target.path, next);\n\n logOk(`Set ${S.bold(`${id}.${key}`)} = ${value} in the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n}\n\nfunction runRemove(id: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files);\n\n const document = readTargetDocument(target, view.files);\n if (!document.providers[id]) {\n logErr(`No provider '${id}' in ${target.path}`);\n process.exit(1);\n }\n const providers = { ...document.providers };\n delete providers[id];\n saveProviderRegistryFile(target.path, { version: 1, providers });\n\n logOk(`Removed ${S.bold(id)} from the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n if (\n view.merged.providers[id] &&\n view.files.some((f) => f.path !== target.path && f.document.providers[id])\n ) {\n logInfo(`'${id}' is still defined in another layer — run 'skaile providers list' to see it.`);\n }\n}\n\n// ── test ───────────────────────────────────────────────────────────────────\n\nasync function runTest(id: string, opts: ScopeOptions): Promise<void> {\n const view = loadRegistryView(opts);\n const entry = view.merged.providers[id];\n if (!entry) {\n logErr(`No provider '${id}'. Run ${S.cmd(\"skaile providers list\")} to see what is configured.`);\n process.exit(1);\n }\n\n const credential = resolveCredential(entry);\n console.log();\n console.log(` ${S.heading(id)} ${S.dim(`(${view.merged.origin[id]} layer)`)}`);\n console.log(` ${S.label(\"endpoint \")} ${resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\")}`);\n console.log(\n ` ${S.label(\"credential\")} ${credentialSummary(entry)} ${\n credential.error\n ? S.err(`— ${credential.error}`)\n : S.dim(`— resolved from ${credential.source}`)\n }`,\n );\n\n if (credential.error) {\n console.log();\n logErr(`${id} is not usable yet: ${credential.error}`);\n process.exit(1);\n }\n\n const result = await probeProviderEntry(entry, { secret: credential.value });\n if (result.url) console.log(` ${S.label(\"probe \")} GET ${result.url}`);\n console.log();\n if (result.ok) {\n logOk(`${id}: ${result.detail}${result.status ? ` (HTTP ${result.status})` : \"\"}`);\n return;\n }\n if (!result.probed) {\n logWarn(`${id}: ${result.detail}`);\n return;\n }\n logErr(`${id}: ${result.detail}`);\n process.exit(1);\n}\n\n// ── command ────────────────────────────────────────────────────────────────\n\n/**\n * Create the `skaile providers` command group.\n *\n * `list` shows the catalog and what is configured; `add` writes an entry from\n * a preset (or from three literals with `--preset custom`); `set` and `rm`\n * edit one layer; `test` sends one read-only request and reports what came\n * back, never the credential.\n *\n * @returns Configured {@link Command} ready for `program.addCommand()`.\n */\nexport function makeProvidersCommand(): Command {\n const cmd = new Command(\"providers\").description(\n \"Manage AI provider endpoints (~/.skaile/providers.yml)\",\n );\n\n cmd\n .command(\"list\")\n .description(\"List catalog presets and configured providers\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--json\", \"Machine-readable output\")\n .action((opts) => {\n const view = loadRegistryView(opts);\n if (opts.json) {\n console.log(\n JSON.stringify(\n {\n presets: listProviderPresets().map((preset) => ({\n id: preset.id,\n kind: preset.kind,\n surface: preset.surface,\n transport: preset.transport ?? (preset.surface ? \"direct\" : undefined),\n base_url: presetBaseUrl(preset),\n credential: preset.credential,\n required_params: preset.required_params,\n })),\n providers: view.merged.order.map((id) => ({\n id,\n layer: view.merged.origin[id],\n entry: view.merged.providers[id],\n base_url: resolveEntryBaseUrl(view.merged.providers[id]),\n })),\n },\n null,\n 2,\n ),\n );\n return;\n }\n reportDiagnostics(view.diagnostics);\n printPresets();\n printConfigured(view);\n });\n\n cmd\n .command(\"add [id]\")\n .description(\"Add a provider from a catalog preset (id defaults to the preset name)\")\n .requiredOption(\"--preset <preset>\", `Catalog preset, or '${CUSTOM_PRESET}'`)\n .option(\"--credential <ref>\", \"Credential reference (env:NAME, cmd:…, platform:…, keyring:…)\")\n .option(\"--base-url <url>\", \"Override the preset endpoint\")\n .option(\"--surface <surface>\", `Wire surface (${AI_PROVIDER_SURFACES.join(\", \")})`)\n .option(\"--kind <kind>\", \"Entry kind for --preset custom (llm, embed, stt, tts)\", \"llm\")\n .option(\"--label <text>\", \"Display label\")\n .option(\n \"--param <key=value>\",\n \"Transport parameter (repeatable): region, project, location, resource, deployment, api_version\",\n (value: string, previous: string[]) => [...previous, value],\n [] as string[],\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--force\", \"Overwrite an existing entry in the target file\")\n .action((id: string | undefined, opts: AddOptions) => runAdd(id, opts));\n\n cmd\n .command(\"set <id> <key> <value>\")\n .description(\n \"Set one field (base_url, enabled, credential.ref, headers.<name>, model_map.<id>…)\",\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, key: string, value: string, opts: ScopeOptions) =>\n runSet(id, key, value, opts),\n );\n\n cmd\n .command(\"rm <id>\")\n .description(\"Remove a provider from one layer\")\n .option(\"--workspace\", \"Edit <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runRemove(id, opts));\n\n cmd\n .command(\"test <id>\")\n .description(\"Send one read-only request to a provider and report the result\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runTest(id, opts));\n\n return cmd;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/commands/providers.ts"],"names":[],"mappings":";;;;;;;;;AAkDA,IAAM,aAAA,GAAgB,QAAA;AAStB,SAAS,WAAW,IAAA,EAAmE;AACrF,E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esContent":["/**\n * `skaile providers` — manage the AI provider registry.\n *\n * Endpoints are defined once, in `~/.skaile/providers.yml`, optionally\n * overridden per project in `<workspace>/.skaile/providers.yml` (gitignored by\n * `skaile init`). Every subcommand writes exactly one of those two files and\n * validates the result before it lands — a literal secret never reaches disk.\n *\n * @see PROVIDER-CONFIG-PLAN.md §1, §2.5\n */\n\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport {\n catalogLayer,\n expandPreset,\n getProviderPreset,\n listProviderPresets,\n presetBaseUrl,\n probeProviderEntry,\n} from \"@skaile/workspaces/bridge\";\nimport {\n AI_PROVIDER_LAYERS,\n AI_PROVIDER_SURFACES,\n type AIProviderDiagnostic,\n type AIProviderEntry,\n type AIProviderLayerId,\n type AIProviderLlmEntry,\n type AIProviderRegistryDocument,\n type AIProviderSurface,\n entryTransport,\n isEntryEnabled,\n isSafeProviderId,\n loadProviderRegistry,\n type MergedAIProviderRegistry,\n mergeRegistries,\n parseCredentialRef,\n type ProviderRegistryFile,\n resolveCredential,\n resolveEntryBaseUrl,\n saveProviderRegistryFile,\n userProviderRegistryPath,\n validateMergedRegistry,\n validateRegistry,\n workspaceProviderRegistryPath,\n} from \"@skaile/workspaces/core\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\n\n/** Preset id that means \"no preset — I will supply the three literals\". */\nconst CUSTOM_PRESET = \"custom\";\n\n/** Which of the two registry files a command reads or writes. */\nexport interface ScopeOptions {\n projectDir?: string;\n workspace?: boolean;\n}\n\n/** The file a mutating subcommand writes: the workspace layer or the user one. */\nfunction targetFile(opts: ScopeOptions): { layer: \"user\" | \"workspace\"; path: string } {\n if (opts.workspace) {\n return { layer: \"workspace\", path: workspaceProviderRegistryPath(resolveProjectDir(opts)) };\n }\n return { layer: \"user\", path: userProviderRegistryPath() };\n}\n\n/** Project directory a subcommand operates on — `--project-dir` or the cwd. */\nfunction resolveProjectDir(opts: ScopeOptions): string {\n return opts.projectDir ? path.resolve(opts.projectDir) : process.cwd();\n}\n\n/** Both file layers plus the catalog, merged — what every reader sees. */\nexport interface RegistryView {\n merged: MergedAIProviderRegistry;\n files: ProviderRegistryFile[];\n diagnostics: AIProviderDiagnostic[];\n}\n\n/**\n * Load both file layers and merge them with the catalog layer the configured\n * `preset:` keys pull in, then gate the result. Read once, merged twice — the\n * catalog layer can only be built after the configured entries are known,\n * and it is built from the **pre-gate** merge: an entry that leaves `kind` or\n * its transport `params` to the preset fails the first gate by design.\n *\n * The gate is on the merged view, not per file: a workspace entry that sets\n * one field of an entry the user file defines is an override (§1.5), so it is\n * only here that an entry can be judged complete.\n */\nexport function loadRegistryView(opts: ScopeOptions): RegistryView {\n const loaded = loadProviderRegistry({ projectDir: resolveProjectDir(opts) });\n const fileLayers = loaded.files.map((file) => ({\n layer: file.layer as AIProviderLayerId,\n providers: file.document.providers,\n }));\n const catalog = catalogLayer(loaded.patches);\n const { registry, diagnostics } = validateMergedRegistry(\n mergeRegistries([...fileLayers, catalog]),\n {\n sources: [\n ...loaded.files.map((file) => ({ label: file.path, providers: file.document.providers })),\n ],\n },\n );\n return {\n merged: registry,\n files: loaded.files,\n // `loaded.diagnostics` already carries the merge notes for the file layers\n // alone; this second merge adds the catalog, so its notes replace them.\n diagnostics: [...loaded.files.flatMap((file) => file.diagnostics), ...diagnostics],\n };\n}\n\n/** Print diagnostics; returns how many were errors. */\nfunction reportDiagnostics(diagnostics: AIProviderDiagnostic[]): number {\n let errors = 0;\n for (const diagnostic of diagnostics) {\n const where = diagnostic.path ? `${diagnostic.path}: ` : \"\";\n if (diagnostic.severity === \"error\") {\n errors++;\n logErr(`${where}${diagnostic.message}`);\n } else {\n logWarn(`${where}${diagnostic.message}`);\n }\n }\n return errors;\n}\n\n/** Highest layer that pins an entry with `locked: true`. */\nfunction lockOwner(id: string, files: ProviderRegistryFile[]): AIProviderLayerId | undefined {\n let owner: AIProviderLayerId | undefined;\n for (const file of files) {\n if (file.document.providers[id]?.locked) {\n const layer = file.layer as AIProviderLayerId;\n if (!owner || AI_PROVIDER_LAYERS.indexOf(layer) > AI_PROVIDER_LAYERS.indexOf(owner)) {\n owner = layer;\n }\n }\n }\n return owner;\n}\n\n/**\n * The message for an edit a lock forbids, or `undefined` when it is allowed.\n * The merge ignores a lower layer silently; the CLI must not, or the operator\n * would watch an accepted edit have no effect.\n *\n * `set <id> locked <value>` stays legal at the locking layer itself —\n * otherwise a lock could never be lifted without hand-editing the file.\n */\nfunction lockConflict(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): string | undefined {\n const owner = lockOwner(id, files);\n if (!owner) return undefined;\n const ownerRank = AI_PROVIDER_LAYERS.indexOf(owner);\n const targetRank = AI_PROVIDER_LAYERS.indexOf(target.layer);\n if (ownerRank === targetRank && key === \"locked\") return undefined;\n if (ownerRank < targetRank) return undefined;\n return (\n `'${id}' is locked by the ${owner} layer and cannot be changed from ${target.layer}.\\n` +\n (ownerRank === targetRank\n ? ` Unlock it first: skaile providers set ${id} locked false`\n : ` A higher layer owns this entry — change it there.`)\n );\n}\n\n/** Refuse loudly when a locked entry would be edited. */\nfunction exitIfLocked(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): void {\n const message = lockConflict(id, target, files, key);\n if (!message) return;\n logErr(message);\n process.exit(1);\n}\n\n/** Read the target file, or an empty document when it does not exist yet. */\nfunction readTargetDocument(\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n): AIProviderRegistryDocument {\n const file = files.find((f) => f.path === target.path);\n return file?.document ?? { version: 1, providers: {} };\n}\n\n/**\n * Validate the file that is about to be written; exits non-zero on errors.\n *\n * Validated as the layer it is, so `set` may leave a one-field override in the\n * workspace file (§1.5). Completeness is the merged registry's business, and\n * `loadRegistryView` reports it on the next read.\n */\nfunction validateOrExit(\n document: AIProviderRegistryDocument,\n target: { layer: \"user\" | \"workspace\"; path: string },\n): void {\n const { diagnostics } = validateRegistry(\n { version: 1, providers: document.providers },\n { source: target.path, layer: target.layer },\n );\n if (reportDiagnostics(diagnostics) > 0) process.exit(1);\n}\n\n// ── list ───────────────────────────────────────────────────────────────────\n\nfunction pad(value: string, width: number): string {\n return value.length >= width ? value : value + \" \".repeat(width - value.length);\n}\n\nfunction credentialSummary(entry: AIProviderEntry): string {\n const credential = entry.credential;\n if (!credential || credential.kind === \"none\") return \"none\";\n return credential.ref ? `${credential.kind} ${credential.ref}` : credential.kind;\n}\n\nfunction printPresets(): void {\n const presets = listProviderPresets();\n console.log();\n console.log(` ${S.heading(\"Catalog presets\")}`);\n const idWidth = Math.max(...presets.map((x) => x.id.length)) + 2;\n const surfaceWidth = Math.max(...AI_PROVIDER_SURFACES.map((s) => s.length)) + 2;\n const header = `${pad(\"preset\", idWidth)}${pad(\"kind\", 7)}${pad(\"surface\", surfaceWidth)}${pad(\"transport\", 14)}default base URL`;\n console.log(` ${S.dim(header)}`);\n for (const preset of presets) {\n const row =\n pad(preset.id, idWidth) +\n pad(preset.kind, 7) +\n pad(preset.surface ?? \"—\", surfaceWidth) +\n pad(\n preset.kind === \"llm\" || preset.kind === \"embed\" ? (preset.transport ?? \"direct\") : \"—\",\n 14,\n ) +\n (presetBaseUrl(preset) ?? \"—\");\n console.log(` ${row}`);\n }\n}\n\nfunction printConfigured(view: RegistryView): void {\n const ids = view.merged.order;\n console.log();\n console.log(` ${S.heading(\"Configured providers\")}`);\n if (ids.length === 0) {\n console.log(\n ` ${S.dim(\"none — add one with\")} ${S.cmd(\"skaile providers add --preset <preset>\")}`,\n );\n console.log();\n return;\n }\n const idWidth = Math.max(...ids.map((id) => id.length)) + 2;\n const header = `${pad(\"id\", idWidth)}${pad(\"layer\", 11)}${pad(\"surface\", 26)}${pad(\"transport\", 14)}endpoint`;\n console.log(` ${S.dim(header)}`);\n for (const id of ids) {\n const entry = view.merged.providers[id];\n const surface = (entry as AIProviderLlmEntry).surface ?? \"—\";\n const transport = entryTransport(entry) ?? \"—\";\n const url = resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\");\n const flags = [\n isEntryEnabled(entry) ? \"\" : S.warn(\"disabled\"),\n entry.locked ? S.warn(\"locked\") : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n console.log(\n ` ${pad(id, idWidth)}${pad(view.merged.origin[id], 11)}${pad(surface, 26)}${pad(transport, 14)}${url} ${flags}`.trimEnd(),\n );\n console.log(` ${S.dim(`${pad(\"\", idWidth)}${credentialSummary(entry)}`)}`);\n }\n console.log();\n}\n\n// ── add ────────────────────────────────────────────────────────────────────\n\ninterface AddOptions extends ScopeOptions {\n preset?: string;\n credential?: string;\n baseUrl?: string;\n surface?: string;\n label?: string;\n kind?: string;\n param: string[];\n force?: boolean;\n}\n\nfunction parseParams(pairs: string[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const pair of pairs) {\n const eq = pair.indexOf(\"=\");\n if (eq <= 0) {\n logErr(`--param expects <key>=<value> (got '${pair}')`);\n process.exit(1);\n }\n out[pair.slice(0, eq)] = pair.slice(eq + 1);\n }\n return out;\n}\n\n/** Ask for the three literals a custom endpoint needs. Nothing else. */\nasync function promptCustomEntry(\n id: string,\n opts: AddOptions,\n): Promise<{ surface: AIProviderSurface; baseUrl: string; credentialRef: string }> {\n const interactive = process.stdin.isTTY === true;\n let surface = opts.surface as AIProviderSurface | undefined;\n let baseUrl = opts.baseUrl;\n let credentialRef = opts.credential;\n\n if (!interactive && (!surface || !baseUrl || !credentialRef)) {\n logErr(\n \"--preset custom needs --surface, --base-url and --credential when there is no terminal to prompt on\",\n );\n process.exit(1);\n }\n\n if (!surface) {\n const answer = await p.select({\n message: \"Wire surface:\",\n options: AI_PROVIDER_SURFACES.map((value) => ({ value, label: value })),\n initialValue: \"openai-completions\" as AIProviderSurface,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n surface = answer as AIProviderSurface;\n }\n if (!baseUrl) {\n const answer = await p.text({\n message: \"Base URL:\",\n placeholder: \"https://api.example.com/v1\",\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n baseUrl = answer as string;\n }\n if (!credentialRef) {\n const answer = await p.text({\n message: \"Credential reference (env:NAME, cmd:<shell>, platform:<id>, keyring:<svc>/<acct>):\",\n initialValue: `env:${id.toUpperCase().replace(/[^A-Z0-9]/g, \"_\")}_API_KEY`,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n credentialRef = answer as string;\n }\n return { surface, baseUrl, credentialRef };\n}\n\n/** A rejected registry write. The message is already CLI-ready. */\nexport class ProviderRegistryWriteError extends Error {}\n\n/** What {@link addProviderEntry} writes. */\nexport interface AddProviderEntryInput extends ScopeOptions {\n /** Registry entry id — `[a-z0-9][a-z0-9_-]*`. */\n id: string;\n /** Catalog preset to expand. Mutually exclusive with `entry`. */\n presetId?: string;\n /** A fully-built entry (the `--preset custom` path, which needs prompts). */\n entry?: AIProviderEntry;\n /** `env:NAME` / `cmd:…` / `platform:…` / `keyring:…` — never a literal. */\n credentialRef?: string;\n baseUrl?: string;\n surface?: AIProviderSurface;\n label?: string;\n params?: Record<string, string>;\n /** Overwrite an entry that already exists in the target file. */\n force?: boolean;\n}\n\n/** Result of {@link addProviderEntry}. */\nexport interface AddedProviderEntry {\n id: string;\n layer: \"user\" | \"workspace\";\n path: string;\n entry: AIProviderEntry;\n /** True when an existing entry in the target file was overwritten. */\n replaced: boolean;\n}\n\n/**\n * Write one entry into a registry file — the single write path behind\n * `skaile providers add` and the `skaile setup` wizard.\n *\n * Throws {@link ProviderRegistryWriteError} instead of exiting, so a wizard\n * can report the failure in its own idiom. Every rejection a caller can\n * provoke (bad id, unknown preset, missing transport parameter, locked entry,\n * a literal secret) lands here, and the document is validated before it is\n * written — a secret cannot reach disk through this function.\n */\nexport function addProviderEntry(input: AddProviderEntryInput): AddedProviderEntry {\n const { id } = input;\n if (!isSafeProviderId(id)) {\n throw new ProviderRegistryWriteError(\n `'${id}' is not a valid entry id — use [a-z0-9][a-z0-9_-]*`,\n );\n }\n if (input.credentialRef && !parseCredentialRef(input.credentialRef)) {\n throw new ProviderRegistryWriteError(\n \"the credential must be a reference, not a secret: \" +\n \"env:NAME, cmd:<shell>, platform:<configId> or keyring:<service>/<account>\",\n );\n }\n\n const view = loadRegistryView(input);\n const target = targetFile(input);\n const locked = lockConflict(id, target, view.files);\n if (locked) throw new ProviderRegistryWriteError(locked);\n\n const document = readTargetDocument(target, view.files);\n const replaced = document.providers[id] !== undefined;\n if (replaced && !input.force) {\n throw new ProviderRegistryWriteError(\n `'${id}' already exists in ${target.path} — pass --force to overwrite it.`,\n );\n }\n\n let entry: AIProviderEntry;\n if (input.entry) {\n entry = input.entry;\n } else {\n const preset = input.presetId ? getProviderPreset(input.presetId) : undefined;\n if (!preset) {\n throw new ProviderRegistryWriteError(\n `Unknown preset '${input.presetId}'. Run \\`skaile providers list\\` to see the catalog, ` +\n \"or use `--preset custom`.\",\n );\n }\n entry = expandPreset(preset, {\n credentialRef: input.credentialRef,\n baseUrl: input.baseUrl,\n surface: input.surface,\n label: input.label,\n params: input.params,\n });\n const missing = (preset.required_params ?? []).filter(\n (key) => !(key in ((entry as AIProviderLlmEntry).params ?? {})),\n );\n if (missing.length > 0) {\n throw new ProviderRegistryWriteError(\n `Preset '${preset.id}' needs ${missing.map((m) => `--param ${m}=<value>`).join(\" \")}`,\n );\n }\n }\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: entry },\n };\n const { diagnostics } = validateRegistry(\n { version: 1, providers: next.providers },\n { source: target.path },\n );\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n if (errors.length > 0) {\n throw new ProviderRegistryWriteError(\n errors.map((d) => (d.path ? `${d.path}: ${d.message}` : d.message)).join(\"\\n\"),\n );\n }\n saveProviderRegistryFile(target.path, next);\n\n return { id, layer: target.layer, path: target.path, entry, replaced };\n}\n\n/** The env var an `env:` credential reference points at, if it is one. */\nexport function credentialEnvVarName(entry: AIProviderEntry): string | undefined {\n const ref = entry.credential?.ref;\n return ref?.startsWith(\"env:\") ? ref.slice(4) : undefined;\n}\n\n/** Build the `--preset custom` entry from the three literals the user gave. */\nfunction customEntry(\n answers: { surface: AIProviderSurface; baseUrl: string; credentialRef: string },\n opts: AddOptions,\n): AIProviderEntry {\n const kind = (opts.kind ?? \"llm\") as AIProviderEntry[\"kind\"];\n // Anthropic- and Google-shaped surfaces read a dedicated API-key header;\n // everything else is a bearer token. `set <id> credential.kind …` adjusts.\n const credentialKind =\n kind === \"stt\" ||\n kind === \"tts\" ||\n answers.surface === \"anthropic-messages\" ||\n answers.surface === \"google-generative-ai\" ||\n answers.surface === \"azure-openai-responses\"\n ? \"api_key_header\"\n : \"bearer\";\n if (kind === \"stt\" || kind === \"tts\") {\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n };\n }\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n surface: answers.surface,\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n } as AIProviderLlmEntry;\n}\n\nasync function runAdd(idArg: string | undefined, opts: AddOptions): Promise<void> {\n const presetId = opts.preset;\n if (!presetId) {\n logErr(\n `--preset is required. Run ${S.cmd(\"skaile providers list\")} for the catalog, ` +\n `or use ${S.cmd(\"--preset custom\")}.`,\n );\n process.exit(1);\n }\n const id = idArg ?? presetId;\n if (id === CUSTOM_PRESET && !idArg) {\n logErr(\"--preset custom needs an entry id: skaile providers add <id> --preset custom\");\n process.exit(1);\n }\n\n const entry =\n presetId === CUSTOM_PRESET ? customEntry(await promptCustomEntry(id, opts), opts) : undefined;\n\n let added: AddedProviderEntry;\n try {\n added = addProviderEntry({\n id,\n ...(entry ? { entry } : { presetId }),\n credentialRef: opts.credential,\n baseUrl: opts.baseUrl,\n surface: opts.surface as AIProviderSurface | undefined,\n label: opts.label,\n params: parseParams(opts.param),\n projectDir: opts.projectDir,\n workspace: opts.workspace,\n force: opts.force,\n });\n } catch (error) {\n logErr(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n\n logOk(`Added ${S.bold(id)} (${presetId}) to the ${added.layer} registry`);\n console.log(S.dim(` → ${added.path}`));\n const name = credentialEnvVarName(added.entry);\n if (name) {\n console.log(\n ` ${S.dim(\"The secret itself never goes in this file — export it:\")} ${S.cmd(`export ${name}=…`)}`,\n );\n }\n console.log(` ${S.dim(\"Verify with:\")} ${S.cmd(`skaile providers test ${id}`)}`);\n}\n\n// ── set / rm ───────────────────────────────────────────────────────────────\n\n/** Coerce a CLI string into the type the schema expects at `key`. */\nfunction coerceValue(key: string, value: string): unknown {\n const leaf = key.split(\".\").pop() ?? key;\n if (leaf === \"enabled\" || leaf === \"locked\" || leaf === \"tools\" || leaf === \"images\") {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n logErr(`'${key}' takes true or false (got '${value}')`);\n process.exit(1);\n }\n if (leaf === \"context_window\" || leaf === \"thinking_max\") {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n logErr(`'${key}' takes a number (got '${value}')`);\n process.exit(1);\n }\n return parsed;\n }\n return value;\n}\n\n/** Write `value` at a dotted path, creating intermediate maps. */\nfunction setDotted(entry: Record<string, unknown>, key: string, value: unknown): void {\n const segments = key.split(\".\");\n let cursor = entry;\n for (const segment of segments.slice(0, -1)) {\n const next = cursor[segment];\n if (typeof next !== \"object\" || next === null || Array.isArray(next)) {\n cursor[segment] = {};\n }\n cursor = cursor[segment] as Record<string, unknown>;\n }\n cursor[segments[segments.length - 1]] = value;\n}\n\nfunction runSet(id: string, key: string, value: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files, key);\n\n const document = readTargetDocument(target, view.files);\n const existing = document.providers[id];\n const inherited = view.merged.providers[id];\n if (!existing && !inherited) {\n logErr(\n `No provider '${id}'. Add it with ${S.cmd(`skaile providers add ${id} --preset <preset>`)}`,\n );\n process.exit(1);\n }\n\n // Writing a field into a layer that has no entry yet leaves a one-field\n // override: the layers below keep supplying the rest (§1.5), so copying\n // their `kind` down here would pin a value this layer does not own.\n const base = (existing ? structuredClone(existing) : {}) as unknown as Record<string, unknown>;\n setDotted(base, key, coerceValue(key, value));\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: base as unknown as AIProviderEntry },\n };\n validateOrExit(next, target);\n saveProviderRegistryFile(target.path, next);\n\n logOk(`Set ${S.bold(`${id}.${key}`)} = ${value} in the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n}\n\nfunction runRemove(id: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files);\n\n const document = readTargetDocument(target, view.files);\n if (!document.providers[id]) {\n logErr(`No provider '${id}' in ${target.path}`);\n process.exit(1);\n }\n const providers = { ...document.providers };\n delete providers[id];\n saveProviderRegistryFile(target.path, { version: 1, providers });\n\n logOk(`Removed ${S.bold(id)} from the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n if (\n view.merged.providers[id] &&\n view.files.some((f) => f.path !== target.path && f.document.providers[id])\n ) {\n logInfo(`'${id}' is still defined in another layer — run 'skaile providers list' to see it.`);\n }\n}\n\n// ── test ───────────────────────────────────────────────────────────────────\n\nasync function runTest(id: string, opts: ScopeOptions): Promise<void> {\n const view = loadRegistryView(opts);\n const entry = view.merged.providers[id];\n if (!entry) {\n logErr(`No provider '${id}'. Run ${S.cmd(\"skaile providers list\")} to see what is configured.`);\n process.exit(1);\n }\n\n const credential = resolveCredential(entry);\n console.log();\n console.log(` ${S.heading(id)} ${S.dim(`(${view.merged.origin[id]} layer)`)}`);\n console.log(` ${S.label(\"endpoint \")} ${resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\")}`);\n console.log(\n ` ${S.label(\"credential\")} ${credentialSummary(entry)} ${\n credential.error\n ? S.err(`— ${credential.error}`)\n : S.dim(`— resolved from ${credential.source}`)\n }`,\n );\n\n if (credential.error) {\n console.log();\n logErr(`${id} is not usable yet: ${credential.error}`);\n process.exit(1);\n }\n\n const result = await probeProviderEntry(entry, { secret: credential.value });\n if (result.url) console.log(` ${S.label(\"probe \")} GET ${result.url}`);\n console.log();\n if (result.ok) {\n logOk(`${id}: ${result.detail}${result.status ? ` (HTTP ${result.status})` : \"\"}`);\n return;\n }\n if (!result.probed) {\n logWarn(`${id}: ${result.detail}`);\n return;\n }\n logErr(`${id}: ${result.detail}`);\n process.exit(1);\n}\n\n// ── command ────────────────────────────────────────────────────────────────\n\n/**\n * Create the `skaile providers` command group.\n *\n * `list` shows the catalog and what is configured; `add` writes an entry from\n * a preset (or from three literals with `--preset custom`); `set` and `rm`\n * edit one layer; `test` sends one read-only request and reports what came\n * back, never the credential.\n *\n * @returns Configured {@link Command} ready for `program.addCommand()`.\n */\nexport function makeProvidersCommand(): Command {\n const cmd = new Command(\"providers\").description(\n \"Manage AI provider endpoints (~/.skaile/providers.yml)\",\n );\n\n cmd\n .command(\"list\")\n .description(\"List catalog presets and configured providers\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--json\", \"Machine-readable output\")\n .action((opts) => {\n const view = loadRegistryView(opts);\n if (opts.json) {\n console.log(\n JSON.stringify(\n {\n presets: listProviderPresets().map((preset) => ({\n id: preset.id,\n kind: preset.kind,\n surface: preset.surface,\n transport: preset.transport ?? (preset.surface ? \"direct\" : undefined),\n base_url: presetBaseUrl(preset),\n credential: preset.credential,\n required_params: preset.required_params,\n })),\n providers: view.merged.order.map((id) => ({\n id,\n layer: view.merged.origin[id],\n entry: view.merged.providers[id],\n base_url: resolveEntryBaseUrl(view.merged.providers[id]),\n })),\n },\n null,\n 2,\n ),\n );\n return;\n }\n reportDiagnostics(view.diagnostics);\n printPresets();\n printConfigured(view);\n });\n\n cmd\n .command(\"add [id]\")\n .description(\"Add a provider from a catalog preset (id defaults to the preset name)\")\n .requiredOption(\"--preset <preset>\", `Catalog preset, or '${CUSTOM_PRESET}'`)\n .option(\"--credential <ref>\", \"Credential reference (env:NAME, cmd:…, platform:…, keyring:…)\")\n .option(\"--base-url <url>\", \"Override the preset endpoint\")\n .option(\"--surface <surface>\", `Wire surface (${AI_PROVIDER_SURFACES.join(\", \")})`)\n .option(\"--kind <kind>\", \"Entry kind for --preset custom (llm, embed, stt, tts)\", \"llm\")\n .option(\"--label <text>\", \"Display label\")\n .option(\n \"--param <key=value>\",\n \"Transport parameter (repeatable): region, project, location, resource, deployment, api_version\",\n (value: string, previous: string[]) => [...previous, value],\n [] as string[],\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--force\", \"Overwrite an existing entry in the target file\")\n .action((id: string | undefined, opts: AddOptions) => runAdd(id, opts));\n\n cmd\n .command(\"set <id> <key> <value>\")\n .description(\n \"Set one field (base_url, enabled, credential.ref, headers.<name>, model_map.<id>…)\",\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, key: string, value: string, opts: ScopeOptions) =>\n runSet(id, key, value, opts),\n );\n\n cmd\n .command(\"rm <id>\")\n .description(\"Remove a provider from one layer\")\n .option(\"--workspace\", \"Edit <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runRemove(id, opts));\n\n cmd\n .command(\"test <id>\")\n .description(\"Send one read-only request to a provider and report the result\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runTest(id, opts));\n\n return cmd;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logErr } from './chunk-
|
|
1
|
+
import { logErr } from './chunk-5366G4XM.js';
|
|
2
2
|
import { flowKindProvider } from './chunk-KTCMBEEB.js';
|
|
3
3
|
import { knowledgeKindProvider } from './chunk-UFWADBG6.js';
|
|
4
4
|
import { createDefaultRegistry } from './chunk-HGPSZXZP.js';
|
|
@@ -103,5 +103,5 @@ async function openLibraryManager() {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export { LocalCatalogDisabledError, createFullRegistry, openCatalogSource, openLibrary, openLibraryManager, resolveCatalogSource };
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-XUQDVTB5.js.map
|
|
107
|
+
//# sourceMappingURL=chunk-XUQDVTB5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/open-registry.ts","../cli/src/open-library.ts"],"names":["source"],"mappings":";;;;;;AA2BO,SAAS,kBAAA,GAAwC;AACtD,EAAA,MAAM,WAAW,qBAAA,EAAsB;AACvC,EAAA,QAAA,CAAS,SAAS,gBAAgB,CAAA;AAClC,EAAA,QAAA,CAAS,SAAS,qBAAqB,CAAA;AACvC,EAAA,OAAO,QAAA;AACT;;;ACfO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EACnD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EACd;AACF;AASA,eAAsB,WAAA,GAAc;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,UAAA,EAAW,GAAI,MAAM,OAAO,oBAA4B,CAAA;AAChE,IAAA,OAAO,IAAI,UAAA,CAAW,EAAE,YAAA,EAAc,kBAAA,IAAsB,CAAA;AAAA,EAC9D,SAAS,GAAA,EAAK;AACZ,IAAA,MAAA,CAAO,CAAA,2BAAA,EAA8B,eAAe,KAAA,GAAQ,GAAA,CAAI,UAAU,MAAA,CAAO,GAAG,CAAC,CAAA,CAAE,CAAA;AAC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D,SAAS,GAAA,EAAK;AAGZ,MAAA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,OAAA,CAAQ,SAAA,GAAY,GAAA;AAC3C,EAAA,MAAM,SACJ,GAAA,CAAI,OAAA,CAAQ,OAAA,KAAY,MAAA,GACpB,IAAI,iBAAA,CAAkB,EAAE,OAAA,EAAS,UAAA,EAAY,CAAA,GAC7C,IAAI,oBAAoB,EAAE,OAAA,EAAS,YAAY,CAAA;AACrD,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,MAAM;AAAA,EAAC,CAAA,EAAE;AACnC;AASA,eAAsB,kBAAA,GAInB;AACD,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,oBAA4B,CAAA;AACpE,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,EAAY;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-7B362FO3.js","sourcesContent":["/**\n * open-registry.ts — shared helper to create a full AssetKindRegistry.\n *\n * Bootstraps the registry with all built-in providers (9 core + preset)\n * from @skaile/discovery, plus the extension kind providers (flow from\n * @skaile/workspaces/factory-assets/connectors/flow/engine, knowledge from @skaile/library).\n *\n * This is the single registration point for the CLI. All code paths\n * that need a registry (source sync, lib-status, etc.) should use this.\n */\n\nimport type { AssetKindRegistry } from \"@skaile/workspaces/discovery\";\nimport { createDefaultRegistry } from \"@skaile/workspaces/discovery\";\nimport { flowKindProvider } from \"@skaile/workspaces/factory-assets/connectors/flow/engine\";\nimport { knowledgeKindProvider } from \"@skaile/workspaces/library\";\n\n/**\n * Create a fully-configured AssetKindRegistry with all known providers.\n *\n * Registers:\n * - 9 core kinds (skill, agent, connector, mount, mcp-server, contract, prompt, persona, ruleset)\n * - preset (composition entity)\n * - flow (extension, from @skaile/workspaces/factory-assets/connectors/flow/engine)\n * - knowledge (extension, from @skaile/library)\n *\n * @returns An unfrozen registry (auto-freezes on first read)\n */\nexport function createFullRegistry(): AssetKindRegistry {\n const registry = createDefaultRegistry();\n registry.register(flowKindProvider);\n registry.register(knowledgeKindProvider);\n return registry;\n}\n","/**\n * open-library.ts — shared helpers to open the LocalIndex and the configured\n * Catalog source.\n *\n * Lazy-loads the `@skaile/workspaces/library` subpath and returns the\n * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun).\n * The catalog-source helper reads\n * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given)\n * to decide between {@link RemoteCatalogSource} (default — points at\n * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most\n * recent local library registered via `skaile source add`.\n */\n\nimport { logErr } from \"./helpers.ts\";\nimport { createFullRegistry } from \"./open-registry.ts\";\n\n/** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */\nexport class LocalCatalogDisabledError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LocalCatalogDisabledError\";\n }\n}\n\n/**\n * Open the LocalIndex with the full kind registry. Exits with code 1\n * if the library directory cannot be created.\n *\n * @returns A `LocalIndex` instance ready for use.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibrary() {\n try {\n const { LocalIndex } = await import(\"@skaile/workspaces/library\");\n return new LocalIndex({ kindRegistry: createFullRegistry() });\n } catch (err) {\n logErr(`Could not open LocalIndex: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Resolve the configured **remote** Catalog source for the CLI.\n *\n * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and\n * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default:\n * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source\n * into air-gapped mode: network reads are disabled, only `skaile update`\n * performs refreshes.\n *\n * **Local-mode rejection.** If the resolved config has `catalog.url: local`\n * this helper throws — callers wanting the dispatched local-or-remote source\n * must use {@link resolveCatalogSource}. Remote-only consumers like\n * `skaile update --catalog-only` rely on this strict behaviour.\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A configured {@link RemoteCatalogSource}.\n * @throws When `catalog.url` is the `local` sentinel.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<\n | import(\"@skaile/workspaces/library\").RemoteCatalogSource\n | import(\"@skaile/workspaces/library\").RestCatalogSource\n> {\n const { resolveConfig, RemoteCatalogSource, RestCatalogSource, isLocalCatalogUrl } = await import(\n \"@skaile/workspaces/library\"\n );\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n if (isLocalCatalogUrl(baseUrl)) {\n throw new LocalCatalogDisabledError(\n \"catalog.url is set to 'local' — remote catalog is disabled. \" +\n \"Use `skaile source add <path>` + `skaile source sync` for local sources, \" +\n \"or set `catalog.url: https://skaile.store` in ~/.skaile/config.yaml.\",\n );\n }\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n if (cfg.catalog.framing === \"rest\") {\n return new RestCatalogSource({ baseUrl, cacheTtlMs });\n }\n return new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n}\n\n/**\n * Resolved catalog source plus a close handle for releasing any underlying\n * resources (e.g. the `LocalIndex` SQLite connection in local mode).\n *\n * Callers MUST invoke `close()` when done — typically in a `finally` block.\n * For remote-mode sources `close()` is a no-op, but the contract is uniform\n * so consumers don't have to branch.\n *\n * @docLink cli/dev-guide#open-library\n */\nexport interface ResolvedCatalogSource {\n /** The {@link ICatalogSource} ready for use. */\n source: import(\"@skaile/workspaces/library\").ICatalogSource;\n /** Release any underlying resources (SQLite handle in local mode). */\n close(): void;\n}\n\n/**\n * Resolve the configured Catalog source — local or remote — based on\n * `~/.skaile/config.yaml`.\n *\n * Dispatch:\n * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently\n * registered local library whose `path` still exists on disk, and returns a\n * {@link LocalCatalogSource} bound to that library. Throws if no usable\n * local library is registered.\n * - any URL → returns {@link RemoteCatalogSource} (same as\n * {@link openCatalogSource}).\n *\n * The returned `close()` releases the underlying `LocalIndex` SQLite handle\n * in local mode (no-op in remote mode). Callers MUST invoke it — typically in\n * a `finally` block — to satisfy `library/CLAUDE.md` § \"Notes for Consumers\".\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A `ResolvedCatalogSource` carrying the source and a close handle.\n * @throws When `local` is configured but no usable local library is registered.\n * @docLink cli/dev-guide#open-library\n */\nexport async function resolveCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<ResolvedCatalogSource> {\n const {\n resolveConfig,\n RemoteCatalogSource,\n RestCatalogSource,\n LocalCatalogSource,\n isLocalCatalogUrl,\n } = await import(\"@skaile/workspaces/library\");\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n\n if (isLocalCatalogUrl(baseUrl)) {\n const fs = await import(\"node:fs\");\n const library = await openLibrary();\n try {\n const sources = await library.listSources();\n type LibraryRow = (typeof sources)[number];\n // Type-narrow: `path` is required for local libraries after the filter.\n const usable = sources\n .filter(\n (s): s is LibraryRow & { path: string } =>\n s.backend === \"local\" && typeof s.path === \"string\" && s.path.length > 0,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());\n\n if (usable.length === 0) {\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile source add <path>` first, then `skaile source sync`.\",\n );\n }\n\n // Prefer the most recently added library whose path still exists.\n const present = usable.find((s) => fs.existsSync(s.path));\n if (!present) {\n const head = usable[0];\n throw new Error(\n `catalog.url is set to 'local' but every registered local library has a missing path on disk. ` +\n `Most recent: ${head.path} (library ${head.id}). ` +\n `Re-register with \\`skaile source add <existing-path>\\` or run \\`skaile source list\\` to inspect.`,\n );\n }\n\n const source = new LocalCatalogSource(\n library,\n present.id,\n present.path,\n createFullRegistry(),\n );\n return { source, close: () => library.close() };\n } catch (err) {\n // Release the handle on any failure during dispatch — otherwise the\n // SQLite WAL state leaks for the lifetime of the process.\n library.close();\n throw err;\n }\n }\n\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n const source =\n cfg.catalog.framing === \"rest\"\n ? new RestCatalogSource({ baseUrl, cacheTtlMs })\n : new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n return { source, close: () => {} };\n}\n\n/**\n * Open the LibraryManager bound to the active LocalIndex.\n * Caller owns lifetime — must call `close()` (returned helper closes the\n * underlying LocalIndex).\n *\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibraryManager(): Promise<{\n manager: import(\"@skaile/workspaces/library\").LibraryManager;\n library: import(\"@skaile/workspaces/library\").LocalIndex;\n close: () => void;\n}> {\n const { LibraryManager } = await import(\"@skaile/workspaces/library\");\n const library = await openLibrary();\n const manager = new LibraryManager(library);\n return { manager, library, close: () => library.close() };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/open-registry.ts","../cli/src/open-library.ts"],"names":["source"],"mappings":";;;;;;AA2BO,SAAS,kBAAA,GAAwC;AACtD,EAAA,MAAM,WAAW,qBAAA,EAAsB;AACvC,EAAA,QAAA,CAAS,SAAS,gBAAgB,CAAA;AAClC,EAAA,QAAA,CAAS,SAAS,qBAAqB,CAAA;AACvC,EAAA,OAAO,QAAA;AACT;;;ACfO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EACnD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAA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KAAA;AAAA,UACR,CAAA,0GAAA,EACkB,IAAA,CAAK,IAAI,CAAA,UAAA,EAAa,KAAK,EAAE,CAAA,mGAAA;AAAA,SAEjD;AAAA,MACF;AAEA,MAAA,MAAMA,UAAS,IAAI,kBAAA;AAAA,QACjB,OAAA;AAAA,QACA,OAAA,CAAQ,EAAA;AAAA,QACR,OAAA,CAAQ,IAAA;AAAA,QACR,kBAAA;AAAmB,OACrB;AACA,MAAA,OAAO,EAAE,MAAA,EAAAA,OAAAA,EAAQ,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAAA,IAChD,SAAS,GAAA,EAAK;AAGZ,MAAA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,OAAA,CAAQ,SAAA,GAAY,GAAA;AAC3C,EAAA,MAAM,SACJ,GAAA,CAAI,OAAA,CAAQ,OAAA,KAAY,MAAA,GACpB,IAAI,iBAAA,CAAkB,EAAE,OAAA,EAAS,UAAA,EAAY,CAAA,GAC7C,IAAI,oBAAoB,EAAE,OAAA,EAAS,YAAY,CAAA;AACrD,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,MAAM;AAAA,EAAC,CAAA,EAAE;AACnC;AASA,eAAsB,kBAAA,GAInB;AACD,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,oBAA4B,CAAA;AACpE,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,EAAY;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-XUQDVTB5.js","sourcesContent":["/**\n * open-registry.ts — shared helper to create a full AssetKindRegistry.\n *\n * Bootstraps the registry with all built-in providers (9 core + preset)\n * from @skaile/discovery, plus the extension kind providers (flow from\n * @skaile/workspaces/factory-assets/connectors/flow/engine, knowledge from @skaile/library).\n *\n * This is the single registration point for the CLI. All code paths\n * that need a registry (source sync, lib-status, etc.) should use this.\n */\n\nimport type { AssetKindRegistry } from \"@skaile/workspaces/discovery\";\nimport { createDefaultRegistry } from \"@skaile/workspaces/discovery\";\nimport { flowKindProvider } from \"@skaile/workspaces/factory-assets/connectors/flow/engine\";\nimport { knowledgeKindProvider } from \"@skaile/workspaces/library\";\n\n/**\n * Create a fully-configured AssetKindRegistry with all known providers.\n *\n * Registers:\n * - 9 core kinds (skill, agent, connector, mount, mcp-server, contract, prompt, persona, ruleset)\n * - preset (composition entity)\n * - flow (extension, from @skaile/workspaces/factory-assets/connectors/flow/engine)\n * - knowledge (extension, from @skaile/library)\n *\n * @returns An unfrozen registry (auto-freezes on first read)\n */\nexport function createFullRegistry(): AssetKindRegistry {\n const registry = createDefaultRegistry();\n registry.register(flowKindProvider);\n registry.register(knowledgeKindProvider);\n return registry;\n}\n","/**\n * open-library.ts — shared helpers to open the LocalIndex and the configured\n * Catalog source.\n *\n * Lazy-loads the `@skaile/workspaces/library` subpath and returns the\n * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun).\n * The catalog-source helper reads\n * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given)\n * to decide between {@link RemoteCatalogSource} (default — points at\n * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most\n * recent local library registered via `skaile source add`.\n */\n\nimport { logErr } from \"./helpers.ts\";\nimport { createFullRegistry } from \"./open-registry.ts\";\n\n/** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */\nexport class LocalCatalogDisabledError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LocalCatalogDisabledError\";\n }\n}\n\n/**\n * Open the LocalIndex with the full kind registry. Exits with code 1\n * if the library directory cannot be created.\n *\n * @returns A `LocalIndex` instance ready for use.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibrary() {\n try {\n const { LocalIndex } = await import(\"@skaile/workspaces/library\");\n return new LocalIndex({ kindRegistry: createFullRegistry() });\n } catch (err) {\n logErr(`Could not open LocalIndex: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Resolve the configured **remote** Catalog source for the CLI.\n *\n * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and\n * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default:\n * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source\n * into air-gapped mode: network reads are disabled, only `skaile update`\n * performs refreshes.\n *\n * **Local-mode rejection.** If the resolved config has `catalog.url: local`\n * this helper throws — callers wanting the dispatched local-or-remote source\n * must use {@link resolveCatalogSource}. Remote-only consumers like\n * `skaile update --catalog-only` rely on this strict behaviour.\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A configured {@link RemoteCatalogSource}.\n * @throws When `catalog.url` is the `local` sentinel.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<\n | import(\"@skaile/workspaces/library\").RemoteCatalogSource\n | import(\"@skaile/workspaces/library\").RestCatalogSource\n> {\n const { resolveConfig, RemoteCatalogSource, RestCatalogSource, isLocalCatalogUrl } = await import(\n \"@skaile/workspaces/library\"\n );\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n if (isLocalCatalogUrl(baseUrl)) {\n throw new LocalCatalogDisabledError(\n \"catalog.url is set to 'local' — remote catalog is disabled. \" +\n \"Use `skaile source add <path>` + `skaile source sync` for local sources, \" +\n \"or set `catalog.url: https://skaile.store` in ~/.skaile/config.yaml.\",\n );\n }\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n if (cfg.catalog.framing === \"rest\") {\n return new RestCatalogSource({ baseUrl, cacheTtlMs });\n }\n return new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n}\n\n/**\n * Resolved catalog source plus a close handle for releasing any underlying\n * resources (e.g. the `LocalIndex` SQLite connection in local mode).\n *\n * Callers MUST invoke `close()` when done — typically in a `finally` block.\n * For remote-mode sources `close()` is a no-op, but the contract is uniform\n * so consumers don't have to branch.\n *\n * @docLink cli/dev-guide#open-library\n */\nexport interface ResolvedCatalogSource {\n /** The {@link ICatalogSource} ready for use. */\n source: import(\"@skaile/workspaces/library\").ICatalogSource;\n /** Release any underlying resources (SQLite handle in local mode). */\n close(): void;\n}\n\n/**\n * Resolve the configured Catalog source — local or remote — based on\n * `~/.skaile/config.yaml`.\n *\n * Dispatch:\n * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently\n * registered local library whose `path` still exists on disk, and returns a\n * {@link LocalCatalogSource} bound to that library. Throws if no usable\n * local library is registered.\n * - any URL → returns {@link RemoteCatalogSource} (same as\n * {@link openCatalogSource}).\n *\n * The returned `close()` releases the underlying `LocalIndex` SQLite handle\n * in local mode (no-op in remote mode). Callers MUST invoke it — typically in\n * a `finally` block — to satisfy `library/CLAUDE.md` § \"Notes for Consumers\".\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A `ResolvedCatalogSource` carrying the source and a close handle.\n * @throws When `local` is configured but no usable local library is registered.\n * @docLink cli/dev-guide#open-library\n */\nexport async function resolveCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<ResolvedCatalogSource> {\n const {\n resolveConfig,\n RemoteCatalogSource,\n RestCatalogSource,\n LocalCatalogSource,\n isLocalCatalogUrl,\n } = await import(\"@skaile/workspaces/library\");\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n\n if (isLocalCatalogUrl(baseUrl)) {\n const fs = await import(\"node:fs\");\n const library = await openLibrary();\n try {\n const sources = await library.listSources();\n type LibraryRow = (typeof sources)[number];\n // Type-narrow: `path` is required for local libraries after the filter.\n const usable = sources\n .filter(\n (s): s is LibraryRow & { path: string } =>\n s.backend === \"local\" && typeof s.path === \"string\" && s.path.length > 0,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());\n\n if (usable.length === 0) {\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile source add <path>` first, then `skaile source sync`.\",\n );\n }\n\n // Prefer the most recently added library whose path still exists.\n const present = usable.find((s) => fs.existsSync(s.path));\n if (!present) {\n const head = usable[0];\n throw new Error(\n `catalog.url is set to 'local' but every registered local library has a missing path on disk. ` +\n `Most recent: ${head.path} (library ${head.id}). ` +\n `Re-register with \\`skaile source add <existing-path>\\` or run \\`skaile source list\\` to inspect.`,\n );\n }\n\n const source = new LocalCatalogSource(\n library,\n present.id,\n present.path,\n createFullRegistry(),\n );\n return { source, close: () => library.close() };\n } catch (err) {\n // Release the handle on any failure during dispatch — otherwise the\n // SQLite WAL state leaks for the lifetime of the process.\n library.close();\n throw err;\n }\n }\n\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n const source =\n cfg.catalog.framing === \"rest\"\n ? new RestCatalogSource({ baseUrl, cacheTtlMs })\n : new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n return { source, close: () => {} };\n}\n\n/**\n * Open the LibraryManager bound to the active LocalIndex.\n * Caller owns lifetime — must call `close()` (returned helper closes the\n * underlying LocalIndex).\n *\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibraryManager(): Promise<{\n manager: import(\"@skaile/workspaces/library\").LibraryManager;\n library: import(\"@skaile/workspaces/library\").LocalIndex;\n close: () => void;\n}> {\n const { LibraryManager } = await import(\"@skaile/workspaces/library\");\n const library = await openLibrary();\n const manager = new LibraryManager(library);\n return { manager, library, close: () => library.close() };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { openLibraryManager, createFullRegistry } from './chunk-
|
|
2
|
-
import { logErr, logInfo, logWarn, logOk, S } from './chunk-
|
|
1
|
+
import { openLibraryManager, createFullRegistry } from './chunk-XUQDVTB5.js';
|
|
2
|
+
import { logErr, logInfo, logWarn, logOk, S } from './chunk-5366G4XM.js';
|
|
3
3
|
import { getStoreManifestsDir, LocalCatalogSource, writeCuratedManifest } from './chunk-UFWADBG6.js';
|
|
4
4
|
import { computeDeterministicHash, discoverAssetsInTree } from './chunk-HGPSZXZP.js';
|
|
5
5
|
import { WorkspaceYamlEditor } from './chunk-UWU572Q6.js';
|
|
@@ -313,12 +313,12 @@ function addSourceManifestCommands(src) {
|
|
|
313
313
|
).option("-C, --project-dir <dir>", "Project directory", process.cwd()).option("--publisher <name>", "Override the publisher (--overwrite only)").option("--dev", "Include assets under the source's dev_paths", false).option("--overwrite", "Discard curation and re-scan the full inventory", false).action((arg, opts) => runRebuild(arg, opts));
|
|
314
314
|
manifest.command("verify <src>").description("Verify hashes, deps, and schema (read-only)").option("-C, --project-dir <dir>", "Project directory", process.cwd()).option("--strict", "Fail on advisory checks (warnings force a nonzero exit)", false).action((arg, opts) => runVerify(arg, opts));
|
|
315
315
|
manifest.command("publish <src>").description("Push the curated sidecar manifest and publish it to the store").option("-C, --project-dir <dir>", "Project directory", process.cwd()).option("--as <namespace>", "Publisher namespace (default: your store username)").option("--sidecar-repo <url>", "Public GitHub repo you own to hold the curated manifest").option("--ref <gitref>", "Foreign source ref to ingest (branch/sha; default: main)").option("--dry-run", "Print the publish plan without pushing or calling the store", false).action(async (arg, opts) => {
|
|
316
|
-
const { runPublish } = await import('./source-manifest-publish-
|
|
316
|
+
const { runPublish } = await import('./source-manifest-publish-S4OT5B63.js');
|
|
317
317
|
await runPublish(arg, opts);
|
|
318
318
|
});
|
|
319
319
|
manifest.command("propose <src>").description("Open a PR to upstream with the sidecar manifest").action(() => notWired("propose"));
|
|
320
320
|
manifest.command("yank <src>").description("Retract the source's published assets from the store").option("-C, --project-dir <dir>", "Project directory", process.cwd()).option("--asset <ref>", "Yank only the asset matching this ref/name").action(async (arg, opts) => {
|
|
321
|
-
const { runYank } = await import('./source-manifest-publish-
|
|
321
|
+
const { runYank } = await import('./source-manifest-publish-S4OT5B63.js');
|
|
322
322
|
await runYank(arg, opts);
|
|
323
323
|
});
|
|
324
324
|
}
|
|
@@ -684,5 +684,5 @@ function makeSourceCommand() {
|
|
|
684
684
|
}
|
|
685
685
|
|
|
686
686
|
export { autoSyncForSearch, ensureClone, findCacheKeyCollision, indexingHadFailures, legacySourceConfigHint, makeSourceCommand, normalizeSourceUrl, readProjectSources, resolveSourceArg, sourceClonePath, sourceMatchesKey, syncProjectSources };
|
|
687
|
-
//# sourceMappingURL=chunk-
|
|
688
|
-
//# sourceMappingURL=chunk-
|
|
687
|
+
//# sourceMappingURL=chunk-ZFCY74KO.js.map
|
|
688
|
+
//# sourceMappingURL=chunk-ZFCY74KO.js.map
|