@skaile/workspaces 4.3.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/app-sdk/index.js +1 -1
  3. package/dist/{asset-feeds-SUK47KWR.js → asset-feeds-7QRZ4RAY.js} +4 -4
  4. package/dist/{asset-feeds-SUK47KWR.js.map → asset-feeds-7QRZ4RAY.js.map} +1 -1
  5. package/dist/asset-manager/index.js +1 -1
  6. package/dist/bridge/drivers/claude-sdk.js +30 -4
  7. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  8. package/dist/bridge/drivers/codex.js +2 -2
  9. package/dist/bridge/drivers/continue.js +2 -2
  10. package/dist/bridge/drivers/echo.js +3 -3
  11. package/dist/bridge/drivers/gemini.js +4 -4
  12. package/dist/bridge/drivers/goose.js +2 -2
  13. package/dist/bridge/drivers/omp.js +1 -1
  14. package/dist/bridge/drivers/opencode.js +2 -2
  15. package/dist/bridge/drivers/qwen.js +4 -4
  16. package/dist/bridge/index.js +5 -5
  17. package/dist/bridge/src/drivers/claude-sdk.d.ts +12 -0
  18. package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
  19. package/dist/bridge/src/normalizer.d.ts.map +1 -1
  20. package/dist/bridge/src/types.d.ts +10 -0
  21. package/dist/bridge/src/types.d.ts.map +1 -1
  22. package/dist/channels/index.js +25 -1
  23. package/dist/channels/index.js.map +1 -1
  24. package/dist/channels/src/egress/output-mirror.d.ts +6 -0
  25. package/dist/channels/src/egress/output-mirror.d.ts.map +1 -1
  26. package/dist/channels/src/engine.d.ts.map +1 -1
  27. package/dist/{chunk-GB2CMJ3R.js → chunk-2KLW6K7T.js} +194 -38
  28. package/dist/chunk-2KLW6K7T.js.map +1 -0
  29. package/dist/{chunk-GMKNGIIB.js → chunk-3OLCTLTH.js} +46 -5
  30. package/dist/chunk-3OLCTLTH.js.map +1 -0
  31. package/dist/{chunk-ZKIVYTU6.js → chunk-3PXHN5B5.js} +6 -6
  32. package/dist/{chunk-ZKIVYTU6.js.map → chunk-3PXHN5B5.js.map} +1 -1
  33. package/dist/{chunk-6CMMJFPV.js → chunk-4XHZE73P.js} +4 -4
  34. package/dist/{chunk-6CMMJFPV.js.map → chunk-4XHZE73P.js.map} +1 -1
  35. package/dist/{chunk-T3LXTYWS.js → chunk-AR6ODUDD.js} +6 -6
  36. package/dist/{chunk-T3LXTYWS.js.map → chunk-AR6ODUDD.js.map} +1 -1
  37. package/dist/{chunk-PX5M5WDS.js → chunk-BGROQFRC.js} +11 -6
  38. package/dist/chunk-BGROQFRC.js.map +1 -0
  39. package/dist/{chunk-OJ4GNQO5.js → chunk-C7OPE7R5.js} +2 -2
  40. package/dist/{chunk-OJ4GNQO5.js.map → chunk-C7OPE7R5.js.map} +1 -1
  41. package/dist/{chunk-O552FCP7.js → chunk-CNYIITSZ.js} +15 -3
  42. package/dist/chunk-CNYIITSZ.js.map +1 -0
  43. package/dist/{chunk-643F3GNV.js → chunk-FA6OZDCB.js} +3 -3
  44. package/dist/{chunk-643F3GNV.js.map → chunk-FA6OZDCB.js.map} +1 -1
  45. package/dist/{chunk-IXQC4ADP.js → chunk-HFRNPPHK.js} +3 -3
  46. package/dist/{chunk-IXQC4ADP.js.map → chunk-HFRNPPHK.js.map} +1 -1
  47. package/dist/{chunk-2EDBRUFS.js → chunk-II6OMNH2.js} +5 -5
  48. package/dist/{chunk-2EDBRUFS.js.map → chunk-II6OMNH2.js.map} +1 -1
  49. package/dist/{chunk-V7VHX7MK.js → chunk-JHCWUG4L.js} +2 -2
  50. package/dist/{chunk-V7VHX7MK.js.map → chunk-JHCWUG4L.js.map} +1 -1
  51. package/dist/{chunk-TZUAFEYN.js → chunk-L4JEPRKE.js} +3 -3
  52. package/dist/{chunk-TZUAFEYN.js.map → chunk-L4JEPRKE.js.map} +1 -1
  53. package/dist/{chunk-7YNBVDGL.js → chunk-NOH5UDO7.js} +3 -3
  54. package/dist/{chunk-7YNBVDGL.js.map → chunk-NOH5UDO7.js.map} +1 -1
  55. package/dist/{chunk-2CDYYL6T.js → chunk-QTTAATBK.js} +3 -3
  56. package/dist/{chunk-2CDYYL6T.js.map → chunk-QTTAATBK.js.map} +1 -1
  57. package/dist/{chunk-7J3FBC6T.js → chunk-SPNVXXUN.js} +2 -2
  58. package/dist/{chunk-7J3FBC6T.js.map → chunk-SPNVXXUN.js.map} +1 -1
  59. package/dist/{chunk-DY3R7FYY.js → chunk-U4AA7MOV.js} +4 -4
  60. package/dist/chunk-U4AA7MOV.js.map +1 -0
  61. package/dist/{chunk-67IZGZI2.js → chunk-UY3RIH5D.js} +3 -3
  62. package/dist/{chunk-67IZGZI2.js.map → chunk-UY3RIH5D.js.map} +1 -1
  63. package/dist/{chunk-6SBTX44S.js → chunk-VG226ZI5.js} +7 -4
  64. package/dist/chunk-VG226ZI5.js.map +1 -0
  65. package/dist/{chunk-3VUCSJBJ.js → chunk-WHZR3276.js} +3 -3
  66. package/dist/{chunk-3VUCSJBJ.js.map → chunk-WHZR3276.js.map} +1 -1
  67. package/dist/{chunk-HKLCMOK4.js → chunk-YVQZQGVW.js} +3 -3
  68. package/dist/{chunk-HKLCMOK4.js.map → chunk-YVQZQGVW.js.map} +1 -1
  69. package/dist/cli/index.js +37 -34
  70. package/dist/cli/index.js.map +1 -1
  71. package/dist/cli/src/commands/connect.d.ts.map +1 -1
  72. package/dist/cli/src/commands/run.d.ts.map +1 -1
  73. package/dist/connectors/index.js +6 -6
  74. package/dist/{ensure-sources-V62XWSYD.js → ensure-sources-537FIFGO.js} +4 -4
  75. package/dist/{ensure-sources-V62XWSYD.js.map → ensure-sources-537FIFGO.js.map} +1 -1
  76. package/dist/factory-assets/connectors/box.js +6 -6
  77. package/dist/factory-assets/connectors/deploy.js +6 -6
  78. package/dist/factory-assets/connectors/devserver.js +6 -6
  79. package/dist/factory-assets/connectors/flow/adapter.js +6 -6
  80. package/dist/factory-assets/connectors/flow/run-flow.js +7 -7
  81. package/dist/factory-assets/connectors/flow.js +6 -6
  82. package/dist/factory-assets/connectors/git.js +6 -6
  83. package/dist/factory-assets/connectors/gmail.js +6 -6
  84. package/dist/factory-assets/connectors/googledrive.js +6 -6
  85. package/dist/factory-assets/connectors/local.js +6 -6
  86. package/dist/factory-assets/connectors/mattermost.js +6 -6
  87. package/dist/factory-assets/connectors/memory.js +6 -6
  88. package/dist/factory-assets/connectors/minio.js +6 -6
  89. package/dist/factory-assets/connectors/postgres.js +6 -6
  90. package/dist/factory-assets/connectors/s3.js +6 -6
  91. package/dist/factory-assets/connectors/sharepoint.js +6 -6
  92. package/dist/factory-assets/connectors/sqlite.js +6 -6
  93. package/dist/factory-assets/connectors/static-server.js +6 -6
  94. package/dist/factory-assets/connectors/tunnel.js +6 -6
  95. package/dist/factory-assets/connectors/webdav.js +6 -6
  96. package/dist/factory-assets/connectors/xstate-store.js +6 -6
  97. package/dist/factory-assets/connectors/xstate.js +6 -6
  98. package/dist/{helpers-ZXSNIPEH.js → helpers-H3NGF3GO.js} +4 -4
  99. package/dist/{helpers-ZXSNIPEH.js.map → helpers-H3NGF3GO.js.map} +1 -1
  100. package/dist/{library-publish-OHNV7TCD.js → library-publish-JULNH5AJ.js} +6 -6
  101. package/dist/{library-publish-OHNV7TCD.js.map → library-publish-JULNH5AJ.js.map} +1 -1
  102. package/dist/{open-library-VXKQ4KNY.js → open-library-NMKPLBSD.js} +5 -5
  103. package/dist/{open-library-VXKQ4KNY.js.map → open-library-NMKPLBSD.js.map} +1 -1
  104. package/dist/{project-GOQYIOKG.js → project-LCIRUACP.js} +5 -5
  105. package/dist/{project-GOQYIOKG.js.map → project-LCIRUACP.js.map} +1 -1
  106. package/dist/runner/index.js +10 -10
  107. package/dist/runner/src/agent.d.ts.map +1 -1
  108. package/dist/runner/src/compaction/orchestrator.d.ts.map +1 -1
  109. package/dist/runner/src/markdown-stream.d.ts +6 -0
  110. package/dist/runner/src/markdown-stream.d.ts.map +1 -1
  111. package/dist/runner/src/resource-handler.d.ts +40 -1
  112. package/dist/runner/src/resource-handler.d.ts.map +1 -1
  113. package/dist/sdk/asset-manager.js +1 -1
  114. package/dist/sdk/bridge.js +5 -5
  115. package/dist/sdk/index.js +27 -10
  116. package/dist/sdk/index.js.map +1 -1
  117. package/dist/sdk/runner.js +10 -10
  118. package/dist/sdk/session.js +2 -2
  119. package/dist/sdk/src/agent-session.d.ts +5 -0
  120. package/dist/sdk/src/agent-session.d.ts.map +1 -1
  121. package/dist/sdk/store.js +1 -1
  122. package/dist/sdk/types.js +1 -1
  123. package/dist/session/index.js +2 -2
  124. package/dist/session/src/dispatcher.d.ts.map +1 -1
  125. package/dist/{setup-7DVYP3TP.js → setup-ZEAG3PKZ.js} +10 -10
  126. package/dist/{setup-7DVYP3TP.js.map → setup-ZEAG3PKZ.js.map} +1 -1
  127. package/dist/{source-4SAPYPNW.js → source-YOCTM4XQ.js} +6 -6
  128. package/dist/{source-4SAPYPNW.js.map → source-YOCTM4XQ.js.map} +1 -1
  129. package/dist/{source-manifest-publish-UEMPQCE5.js → source-manifest-publish-FIJO6TFQ.js} +7 -7
  130. package/dist/{source-manifest-publish-UEMPQCE5.js.map → source-manifest-publish-FIJO6TFQ.js.map} +1 -1
  131. package/dist/store/index.js +1 -1
  132. package/dist/store/src/index.d.ts +1 -1
  133. package/dist/store/src/index.d.ts.map +1 -1
  134. package/dist/store/src/resource-client.d.ts +32 -2
  135. package/dist/store/src/resource-client.d.ts.map +1 -1
  136. package/dist/store/src/store.d.ts.map +1 -1
  137. package/dist/tui/index.js +18 -10
  138. package/dist/tui/index.js.map +1 -1
  139. package/dist/tui/src/repl-session.d.ts.map +1 -1
  140. package/dist/types/index.js +1 -1
  141. package/dist/types/src/events.d.ts +117 -2
  142. package/dist/types/src/events.d.ts.map +1 -1
  143. package/dist/types/src/index.d.ts +1 -1
  144. package/dist/types/src/index.d.ts.map +1 -1
  145. package/dist/types/src/protocol.d.ts +3 -3
  146. package/dist/types/src/protocol.d.ts.map +1 -1
  147. package/dist/types/src/version.d.ts +18 -1
  148. package/dist/types/src/version.d.ts.map +1 -1
  149. package/dist/workspace-plugin/adapters/mcp.js +2 -2
  150. package/dist/workspace-plugin/index.js +1 -1
  151. package/package.json +1 -1
  152. package/dist/chunk-6SBTX44S.js.map +0 -1
  153. package/dist/chunk-DY3R7FYY.js.map +0 -1
  154. package/dist/chunk-GB2CMJ3R.js.map +0 -1
  155. package/dist/chunk-GMKNGIIB.js.map +0 -1
  156. package/dist/chunk-O552FCP7.js.map +0 -1
  157. package/dist/chunk-PX5M5WDS.js.map +0 -1
@@ -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,C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AAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,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-TZUAFEYN.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,I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CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,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-L4JEPRKE.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 { declaresActivityLabel, stripActivityLabel } from './chunk-DY3R7FYY.js';
1
+ import { declaresActivityLabel, stripActivityLabel } from './chunk-U4AA7MOV.js';
2
2
 
3
3
  // bridge/src/capability-dispatch.ts
4
4
  async function dispatchCapability(hooks, callId, name, input, onBackgroundError = () => {
@@ -51,5 +51,5 @@ function filterRenderCapabilities(caps) {
51
51
  }
52
52
 
53
53
  export { dispatchCapability, filterRenderCapabilities, renderFallback };
54
- //# sourceMappingURL=chunk-7YNBVDGL.js.map
55
- //# sourceMappingURL=chunk-7YNBVDGL.js.map
54
+ //# sourceMappingURL=chunk-NOH5UDO7.js.map
55
+ //# sourceMappingURL=chunk-NOH5UDO7.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../bridge/src/capability-dispatch.ts"],"names":[],"mappings":";;;AAmEA,eAAsB,mBACpB,KAAA,EACA,MAAA,EACA,IAAA,EACA,KAAA,EACA,oBAA4C,MAAM;AAAC,CAAA,EACnD,MAAA,EACmC;AACnC,EAAA,MAAA,EAAQ,cAAA,EAAe;AACvB,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA;AAI9B,EAAA,IAAI,CAAC,qBAAA,CAAs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AS,KAAA,EAAO,IAAI,CAAA;AAClC,IAAA,OAAO,UAAU,MAAA,IAAa,KAAA,KAAU,IAAA,GAAO,EAAA,GAAK,OAAO,KAAK,CAAA;AAAA,EAClE,CAAC,CAAA;AACH;AAEA,SAAS,QAAA,CAAS,KAA8B,IAAA,EAAuB;AACrE,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,EAAA,IAAI,OAAA,GAAmB,GAAA;AACvB,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,YAAY,IAAA,IAAQ,OAAA,KAAY,MAAA,IAAa,OAAO,YAAY,QAAA,EAAU;AAC5E,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,OAAA,GAAW,QAAoC,IAAI,CAAA;AAAA,EACrD;AACA,EAAA,OAAO,OAAA;AACT;AAYO,SAAS,yBAAyB,IAAA,EAAkC;AACzE,EAAA,OAAO,KAAK,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,WAAW,MAAS,CAAA;AAClD","file":"chunk-7YNBVDGL.js","sourcesContent":["/**\n * Capability dispatch helpers for bridge drivers.\n *\n * The runner builds a {@link BridgeCapabilityHooks} bundle from its\n * `CapabilityRegistry` and threads it through `AgentConfig.capabilities`.\n * Drivers consume the bundle via these helpers without taking a runtime\n * dependency on `@skaile/workspaces/runner` (which would create a circular dep).\n *\n * Three behaviours are layered into a single dispatch path:\n *\n * 1. **Standard tool call** — the LLM invokes a capability; the bridge calls\n * `hooks.invoke()`, awaits the result, and returns it to the LLM.\n * 2. **Fire-and-forget** — when the resolved Capability has `fireAndForget`\n * set, the bridge resolves to `{}` immediately and runs the handler in\n * the background. Background errors are logged but never surfaced to the\n * LLM since the call is already settled.\n * 3. **Render capability** — when the resolved Capability has a non-undefined\n * `render`, the bridge emits `RenderInvokedEvent` to the runner via\n * `hooks.emitRender` and (when `render.fallback` is set) a parallel text\n * event via `hooks.emitText` with simple `{{prop}}` substitution. The\n * placeholder convention follows the v2 spec — top-level keys of `props`\n * only, with optional dotted-path traversal (`{{user.name}}`). The legacy\n * AAP `{{props.x}}` form was retired in Phase 6.\n *\n * @category Capabilities\n * @since 2.0.0\n */\nimport {\n type Capability,\n declaresActivityLabel,\n stripActivityLabel,\n} from \"@skaile/workspaces/types\";\nimport type { BridgeCapabilityHooks } from \"./types.js\";\n\n/**\n * Result of a capability dispatch returned by {@link dispatchCapability}.\n *\n * The bridge feeds `{ result }` back to the LLM tool-use response. For\n * fire-and-forget capabilities `result` is always `{}` and `background` is `true`.\n *\n * @docLink packages/bridge/concepts#capability-dispatch-result\n */\nexport interface CapabilityDispatchResult {\n /** Value returned to the LLM. `{}` for fire-and-forget capabilities. */\n result: unknown;\n /** True when the handler is still running in the background (fire-and-forget). */\n background: boolean;\n}\n\n/**\n * Run a capability invocation through the runner-provided hooks, applying\n * render-event emission and fire-and-forget short-circuit.\n *\n * The result is always shaped for direct return to the LLM. For\n * fire-and-forget capabilities the background promise is fired and any error\n * is logged through `onBackgroundError` (defaulting to a no-op). For all\n * other capabilities the handler is awaited; errors propagate as a rejection\n * so the driver can surface them as tool errors.\n *\n * @param hooks - Capability dispatch bundle from `AgentConfig.capabilities`.\n * @param callId - Correlation ID for the tool-use invocation (used in render events).\n * @param name - Registered capability name.\n * @param input - Raw tool input from the LLM.\n * @param onBackgroundError - Optional error handler for fire-and-forget failures.\n * @returns Resolved dispatch result with the LLM-facing value and background flag.\n * @docLink packages/bridge/concepts#dispatch-capability\n */\nexport async function dispatchCapability(\n hooks: BridgeCapabilityHooks,\n callId: string,\n name: string,\n input: unknown,\n onBackgroundError: (err: unknown) => void = () => {},\n signal?: AbortSignal,\n): Promise<CapabilityDispatchResult> {\n signal?.throwIfAborted();\n const cap = hooks.resolve(name);\n // The advertised `activity_label` is for the UI only. Strip it before render\n // props and the handler: strict inputs would reject it and external MCP\n // passthrough would forward it. Kept when the capability declares it itself.\n if (!declaresActivityLabel(cap?.inputSchema)) input = stripActivityLabel(input);\n\n // Render emission happens before invocation so clients see the props the\n // LLM passed in even if the handler errors. The runner's gateway forwards\n // the event over the transport.\n if (cap?.render && hooks.emitRender) {\n hooks.emitRender({\n type: \"render_invoked\",\n capabilityName: name,\n props: input,\n callId,\n });\n if (cap.render.fallback && hooks.emitText) {\n const fallback = renderFallback(cap.render.fallback, input);\n hooks.emitText(fallback);\n }\n }\n\n if (cap?.fireAndForget) {\n // Resolve immediately; run handler in background.\n void hooks.invoke(name, input, signal).catch(onBackgroundError);\n return { result: {}, background: true };\n }\n\n const result = await hooks.invoke(name, input, signal);\n return { result, background: false };\n}\n\n/**\n * Substitute `{{prop}}` placeholders inside a fallback template using the\n * input record. Top-level keys of `props` resolve directly\n * (`{{name}}` → `props.name`); dotted paths traverse nested records\n * (`{{user.name}}` → `props.user.name`). Missing keys collapse to an empty\n * string; non-record inputs collapse all placeholders.\n *\n * The convention is fixed by the v2 spec (§1, `RenderSpec.fallback`). The\n * legacy AAP form `{{props.x}}` is no longer accepted — author fallbacks\n * with bare keys.\n *\n * Intentionally minimal — full template engines belong in the platform's\n * render layer, not the bridge.\n *\n * @param template - Fallback string from `RenderSpec.fallback` with `{{key}}` placeholders.\n * @param input - LLM tool input object; non-object values collapse all placeholders.\n * @returns Template with all resolvable placeholders replaced.\n * @docLink packages/bridge/concepts#render-fallback\n */\nexport function renderFallback(template: string, input: unknown): string {\n if (!input || typeof input !== \"object\") {\n return template.replace(/\\{\\{\\s*[\\w$.]+\\s*\\}\\}/g, \"\");\n }\n const props = input as Record<string, unknown>;\n return template.replace(/\\{\\{\\s*([\\w$.]+)\\s*\\}\\}/g, (_match, path: string) => {\n const value = readPath(props, path);\n return value === undefined || value === null ? \"\" : String(value);\n });\n}\n\nfunction readPath(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\n/**\n * Filter a capability list to those marked as render-capable (having a `render` spec).\n *\n * Used by drivers that emit a separate render manifest at registration time.\n * Currently unused in production drivers; reserved for future phases.\n *\n * @param caps - Full capability list to filter.\n * @returns Subset of capabilities with a non-undefined `render` property.\n * @docLink packages/bridge/concepts#filter-render-capabilities\n */\nexport function filterRenderCapabilities(caps: Capability[]): Capability[] {\n return caps.filter((c) => c.render !== undefined);\n}\n"]}
1
+ {"version":3,"sources":["../bridge/src/capability-dispatch.ts"],"names":[],"mappings":";;;AAmEA,eAAsB,mBACpB,KAAA,EACA,MAAA,EACA,IAAA,EACA,KAAA,EACA,oBAA4C,MAAM;AAAC,CAAA,EACnD,MAAA,EACmC;AACnC,EAAA,MAAA,EAAQ,cAAA,EAAe;AACvB,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA;AAI9B,EAAA,IAAI,CAAC,qBAAA,CAAsB,GAAA,EAAK,WAAW,CAAA,EAAG,KAAA,GAAQ,mBAAmB,KAAK,CAAA;AAK9E,EAAA,IAAI,GAAA,EAAK,MAAA,IAAU,KAAA,CAAM,UAAA,EAAY;AACnC,IAAA,KAAA,CAAM,UAAA,CAAW;AAAA,MACf,IAAA,EAAM,gBAAA;AAAA,MACN,cAAA,EAAgB,IAAA;AAAA,MAChB,KAAA,EAAO,KAAA;AAAA,MACP;AAAA,KACD,CAAA;AACD,IAAA,IAAI,GAAA,CAAI,MAAA,CAAO,QAAA,IAAY,KAAA,CAAM,QAAA,EAAU;AACzC,MAAA,MAAM,QAAA,GAAW,cAAA,CAAe,GAAA,CAAI,MAAA,CAAO,UAAU,KAAK,CAAA;AAC1D,MAAA,KAAA,CAAM,SAAS,QAAQ,CAAA;AAAA,IACzB;AAAA,EACF;AAEA,EAAA,IAAI,KAAK,aAAA,EAAe;AAEtB,IAAA,KAAK,MAAM,MAAA,CAAO,IAAA,EAAM,OAAO,MAAM,CAAA,CAAE,MAAM,iBAAiB,CAAA;AAC9D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AS,CAAA;AAClD","file":"chunk-NOH5UDO7.js","sourcesContent":["/**\n * Capability dispatch helpers for bridge drivers.\n *\n * The runner builds a {@link BridgeCapabilityHooks} bundle from its\n * `CapabilityRegistry` and threads it through `AgentConfig.capabilities`.\n * Drivers consume the bundle via these helpers without taking a runtime\n * dependency on `@skaile/workspaces/runner` (which would create a circular dep).\n *\n * Three behaviours are layered into a single dispatch path:\n *\n * 1. **Standard tool call** — the LLM invokes a capability; the bridge calls\n * `hooks.invoke()`, awaits the result, and returns it to the LLM.\n * 2. **Fire-and-forget** — when the resolved Capability has `fireAndForget`\n * set, the bridge resolves to `{}` immediately and runs the handler in\n * the background. Background errors are logged but never surfaced to the\n * LLM since the call is already settled.\n * 3. **Render capability** — when the resolved Capability has a non-undefined\n * `render`, the bridge emits `RenderInvokedEvent` to the runner via\n * `hooks.emitRender` and (when `render.fallback` is set) a parallel text\n * event via `hooks.emitText` with simple `{{prop}}` substitution. The\n * placeholder convention follows the v2 spec — top-level keys of `props`\n * only, with optional dotted-path traversal (`{{user.name}}`). The legacy\n * AAP `{{props.x}}` form was retired in Phase 6.\n *\n * @category Capabilities\n * @since 2.0.0\n */\nimport {\n type Capability,\n declaresActivityLabel,\n stripActivityLabel,\n} from \"@skaile/workspaces/types\";\nimport type { BridgeCapabilityHooks } from \"./types.js\";\n\n/**\n * Result of a capability dispatch returned by {@link dispatchCapability}.\n *\n * The bridge feeds `{ result }` back to the LLM tool-use response. For\n * fire-and-forget capabilities `result` is always `{}` and `background` is `true`.\n *\n * @docLink packages/bridge/concepts#capability-dispatch-result\n */\nexport interface CapabilityDispatchResult {\n /** Value returned to the LLM. `{}` for fire-and-forget capabilities. */\n result: unknown;\n /** True when the handler is still running in the background (fire-and-forget). */\n background: boolean;\n}\n\n/**\n * Run a capability invocation through the runner-provided hooks, applying\n * render-event emission and fire-and-forget short-circuit.\n *\n * The result is always shaped for direct return to the LLM. For\n * fire-and-forget capabilities the background promise is fired and any error\n * is logged through `onBackgroundError` (defaulting to a no-op). For all\n * other capabilities the handler is awaited; errors propagate as a rejection\n * so the driver can surface them as tool errors.\n *\n * @param hooks - Capability dispatch bundle from `AgentConfig.capabilities`.\n * @param callId - Correlation ID for the tool-use invocation (used in render events).\n * @param name - Registered capability name.\n * @param input - Raw tool input from the LLM.\n * @param onBackgroundError - Optional error handler for fire-and-forget failures.\n * @returns Resolved dispatch result with the LLM-facing value and background flag.\n * @docLink packages/bridge/concepts#dispatch-capability\n */\nexport async function dispatchCapability(\n hooks: BridgeCapabilityHooks,\n callId: string,\n name: string,\n input: unknown,\n onBackgroundError: (err: unknown) => void = () => {},\n signal?: AbortSignal,\n): Promise<CapabilityDispatchResult> {\n signal?.throwIfAborted();\n const cap = hooks.resolve(name);\n // The advertised `activity_label` is for the UI only. Strip it before render\n // props and the handler: strict inputs would reject it and external MCP\n // passthrough would forward it. Kept when the capability declares it itself.\n if (!declaresActivityLabel(cap?.inputSchema)) input = stripActivityLabel(input);\n\n // Render emission happens before invocation so clients see the props the\n // LLM passed in even if the handler errors. The runner's gateway forwards\n // the event over the transport.\n if (cap?.render && hooks.emitRender) {\n hooks.emitRender({\n type: \"render_invoked\",\n capabilityName: name,\n props: input,\n callId,\n });\n if (cap.render.fallback && hooks.emitText) {\n const fallback = renderFallback(cap.render.fallback, input);\n hooks.emitText(fallback);\n }\n }\n\n if (cap?.fireAndForget) {\n // Resolve immediately; run handler in background.\n void hooks.invoke(name, input, signal).catch(onBackgroundError);\n return { result: {}, background: true };\n }\n\n const result = await hooks.invoke(name, input, signal);\n return { result, background: false };\n}\n\n/**\n * Substitute `{{prop}}` placeholders inside a fallback template using the\n * input record. Top-level keys of `props` resolve directly\n * (`{{name}}` → `props.name`); dotted paths traverse nested records\n * (`{{user.name}}` → `props.user.name`). Missing keys collapse to an empty\n * string; non-record inputs collapse all placeholders.\n *\n * The convention is fixed by the v2 spec (§1, `RenderSpec.fallback`). The\n * legacy AAP form `{{props.x}}` is no longer accepted — author fallbacks\n * with bare keys.\n *\n * Intentionally minimal — full template engines belong in the platform's\n * render layer, not the bridge.\n *\n * @param template - Fallback string from `RenderSpec.fallback` with `{{key}}` placeholders.\n * @param input - LLM tool input object; non-object values collapse all placeholders.\n * @returns Template with all resolvable placeholders replaced.\n * @docLink packages/bridge/concepts#render-fallback\n */\nexport function renderFallback(template: string, input: unknown): string {\n if (!input || typeof input !== \"object\") {\n return template.replace(/\\{\\{\\s*[\\w$.]+\\s*\\}\\}/g, \"\");\n }\n const props = input as Record<string, unknown>;\n return template.replace(/\\{\\{\\s*([\\w$.]+)\\s*\\}\\}/g, (_match, path: string) => {\n const value = readPath(props, path);\n return value === undefined || value === null ? \"\" : String(value);\n });\n}\n\nfunction readPath(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\n/**\n * Filter a capability list to those marked as render-capable (having a `render` spec).\n *\n * Used by drivers that emit a separate render manifest at registration time.\n * Currently unused in production drivers; reserved for future phases.\n *\n * @param caps - Full capability list to filter.\n * @returns Subset of capabilities with a non-undefined `render` property.\n * @docLink packages/bridge/concepts#filter-render-capabilities\n */\nexport function filterRenderCapabilities(caps: Capability[]): Capability[] {\n return caps.filter((c) => c.render !== undefined);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { getProviderPreset, resolvePresetBaseUrl, expandPreset, resolveProbeUrl, buildCredentialHeaders, presetBaseUrl } from './chunk-7J3FBC6T.js';
1
+ import { getProviderPreset, resolvePresetBaseUrl, expandPreset, resolveProbeUrl, buildCredentialHeaders, presetBaseUrl } from './chunk-SPNVXXUN.js';
2
2
  import { resolveEntryBaseUrl, entryTransport, parseModelRef, registryEntries } from './chunk-ILG4BXYE.js';
3
3
  import { modelIdSchemaForTarget } from './chunk-N7B3LZ7V.js';
4
4
 
@@ -323,5 +323,5 @@ function resolveModelTier(tier, sessionModel, options = {}) {
323
323
  }
324
324
 
325
325
  export { ModelTierResolutionError, PROVIDER_MODEL_TIERS, STATIC_MODELS, fetchProviderModels, getModels, getStaticModels, modelIdTargetForEntry, resolveManifestModel, resolveModelCapabilities, resolveModelTier };
326
- //# sourceMappingURL=chunk-2CDYYL6T.js.map
327
- //# sourceMappingURL=chunk-2CDYYL6T.js.map
326
+ //# sourceMappingURL=chunk-QTTAATBK.js.map
327
+ //# sourceMappingURL=chunk-QTTAATBK.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../bridge/src/models.ts"],"names":[],"mappings":";;;;;AAmDA,SAAS,SAAS,EAAA,EAAoB;AACpC,EAAA,OAAO,EAAA,CACJ,OAAA,CAAQ,4BAAA,EAA8B,EAAE,EACxC,OAAA,CAAQ,OAAA,EAAS,GAAG,CAAA,CACpB,QAAQ,OAAA,EAAS,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAC5C;AAMA,SAAS,kBAAkB,EAAA,EAAqB;AAC9C,EAAA,MAAM,IAAA,GAAO,gEAAA;AACb,EAAA,OAAO,CAAC,IAAA,CAAK,IAAA,CAAK,EAAE,CAAA;AACtB;AAKA,IAAM,gBAAA,GAAgD;AAAA,EACpD,SAAA,EAAW,CAAC,IAAA,KAAS;AACnB,IAAA,MAAM,MAAA,GAAS,IAAA,EAAM,IAAA,IAAQ,EAAC;AAC9B,IAAA,OAAO,MAAA,CACJ,MAAA,CAAO,CAAC,CAAA,KAAW,EAAE,EAAA,IAAM,CAAC,CAAA,CAAE,EAAA,CAAG,SAAS,OAAO,CAAC,CAAA,CAClD,GAAA,CAAI,CAAC,CAAA,MAAY;AAAA,MAChB,IAAI,CAAA,CAAE,EAAA;AAAA,MACN,IAAA,EAAM,CAAA,CAAE,YAAA,IAAgB,QAAA,CAAS,EAAE,EAAE;AAAA,KACvC,CAAE,CAAA;AAAA,EACN,CAAA;AAAA,EACA,MAAA,EAAQ,CAAC,IAAA,KAAS;AAChB,IAAA,MAAM,MAAA,GAA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AA,EAAU,MAAM,IAAI,wBAAA,CAAyB,IAAA,EAAM,QAAQ,QAAQ,CAAA;AACxE,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OACE,OAAA,CAAQ,WAAW,OAAA,IACnB,YAAA,IACA,2BAA2B,SAAA,EAAW,OAAO,KAC7C,OAAA,EAAS,OAAA;AAEb","file":"chunk-2CDYYL6T.js","sourcesContent":["/**\n * Model catalog — static fallback + live provider API fetching.\n *\n * Provides `fetchProviderModels(provider, apiKey)` for live model lists and\n * `getStaticModels(provider)` as an offline fallback.\n * OMP model listing is handled by `OmpDriver.listModels()` in the bridge driver.\n */\n\nimport {\n type AIProviderCapabilities,\n type AIProviderLlmEntry,\n type AIProviderRegistry,\n entryTransport,\n type MergedAIProviderRegistry,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport { type ModelIdTarget, modelIdSchemaForTarget } from \"@skaile/workspaces/types/manifests\";\nimport {\n buildCredentialHeaders,\n expandPreset,\n getProviderPreset,\n presetBaseUrl,\n resolvePresetBaseUrl,\n resolveProbeUrl,\n} from \"./provider-catalog.js\";\n\n/**\n * A single LLM model entry returned by the model catalog.\n *\n * Used by `getModels`, `getStaticModels`, and `fetchProviderModels` to represent\n * an available model for a provider.\n *\n * @docLink packages/bridge/api-reference#models\n */\nexport interface ModelEntry {\n /** Provider-specific model identifier used in API calls (e.g. `\"claude-sonnet-4-5\"`). */\n id: string;\n /** Human-readable display name for UIs and logs (e.g. `\"Claude Sonnet 4.5\"`). */\n name: string;\n}\n\n// ---------------------------------------------------------------------------\n// Provider API configs (for fetching model lists)\n// ---------------------------------------------------------------------------\n\n/** Extract ModelEntry[] from a provider's parsed models-list JSON response. */\ntype ParseModels = (body: any) => ModelEntry[];\n\n/** Humanize a model ID into a display name (e.g. \"claude-sonnet-4-6\" → \"Claude Sonnet 4 6\") */\nfunction humanize(id: string): string {\n return id\n .replace(/^accounts\\/[^/]+\\/models\\//, \"\")\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (c) => c.toUpperCase());\n}\n\n/**\n * Filter function used by providers that return the OpenAI-style /v1/models list.\n * Keeps only chat/completion models, skips embeddings, moderation, tts, whisper, dall-e, etc.\n */\nfunction isLikelyChatModel(id: string): boolean {\n const skip = /embed|moderat|tts|whisper|dall-e|davinci|babbage|ada-00|text-/i;\n return !skip.test(id);\n}\n\n// Per-provider response parsers. The endpoint URL and the credential header\n// come from the catalog preset (provider-catalog.ts), joined in\n// fetchProviderModels.\nconst PROVIDER_PARSERS: Record<string, ParseModels> = {\n anthropic: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && !m.id.includes(\"embed\"))\n .map((m: any) => ({\n id: m.id,\n name: m.display_name ?? humanize(m.id),\n }));\n },\n openai: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n openrouter: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id)\n .map((m: any) => ({ id: m.id, name: m.name ?? humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n mistral: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n groq: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n deepseek: (body) => {\n const models = body?.data ?? [];\n return models\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n xai: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n together: (body) => {\n const models = body?.data ?? body ?? [];\n const arr = Array.isArray(models) ? models : [];\n return arr\n .filter((m: any) => m.id && m.type === \"chat\")\n .map((m: any) => ({ id: m.id, name: m.display_name ?? humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n fireworks: (body) => {\n const models = body?.data ?? [];\n return models\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n google: (body) => {\n const models = body?.models ?? [];\n return models\n .filter((m: any) => m.supportedGenerationMethods?.includes(\"generateContent\"))\n .map((m: any) => ({\n id: (m.name ?? \"\").replace(/^models\\//, \"\"),\n name: m.displayName ?? humanize(m.name ?? \"\"),\n }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n};\n\n// ---------------------------------------------------------------------------\n// Live fetch\n// ---------------------------------------------------------------------------\n\n/**\n * Result of a model-list fetch operation, with source attribution.\n *\n * Returned by {@link fetchProviderModels} and {@link getModels}. When `ok` is `false`,\n * `models` is empty and `error` describes the failure. The `source` field indicates\n * whether the list came from a live API call or the offline static catalog.\n *\n * @docLink packages/bridge/api-reference#models\n */\nexport interface FetchModelsResult {\n /** `true` when the fetch succeeded and `models` is populated. */\n ok: boolean;\n /** Fetched model list; empty on failure. */\n models: ModelEntry[];\n /** Human-readable error description when `ok` is `false`. */\n error?: string;\n /** Whether the result came from a live API call or the static fallback. */\n source: \"api\" | \"static\";\n}\n\n/**\n * Options controlling where a model-list fetch is addressed.\n *\n * @since 1.5.0\n */\nexport interface FetchModelsOptions {\n /**\n * Base URL to resolve the provider's models endpoint against — e.g. the\n * gateway a session already routes completions through. Overrides the\n * provider's `baseUrlEnv` value.\n */\n baseUrl?: string;\n /**\n * Environment consulted for the provider's base-URL env var\n * (`ANTHROPIC_BASE_URL` for `anthropic`). Defaults to `process.env`; pass an\n * explicit record to keep a call hermetic.\n */\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Fetch the model list from a provider's REST API.\n *\n * Returns `{ ok: true, models, source: 'api' }` on success, or\n * `{ ok: false, models: [], error }` on any HTTP or network failure — the\n * caller should fall back to {@link getStaticModels} in that case.\n *\n * The endpoint, the credential header and the response path all come from the\n * catalog preset named by `provider` ({@link resolvePresetBaseUrl},\n * {@link resolveProbeUrl}, {@link buildCredentialHeaders}), so discovery hits\n * the same host dispatch does — including a gateway named by `baseUrl` or by\n * the vendor's own `*_BASE_URL` variable.\n *\n * @param provider - Catalog preset id (e.g. `\"anthropic\"`, `\"openai\"`, `\"google\"`).\n * @param apiKey - API key presented in the preset's credential header.\n * @param options - Optional base-URL / environment overrides.\n * @returns Resolved model list with source attribution.\n * @docLink packages/bridge/api-reference#models\n */\nexport async function fetchProviderModels(\n provider: string,\n apiKey: string,\n options: FetchModelsOptions = {},\n): Promise<FetchModelsResult> {\n const preset = getProviderPreset(provider);\n const parse = PROVIDER_PARSERS[provider];\n if (!preset || !parse) {\n return {\n ok: false,\n models: [],\n error: `No API config for provider: ${provider}`,\n source: \"static\",\n };\n }\n\n const baseUrl = resolvePresetBaseUrl(preset, {\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n env: options.env ?? process.env,\n });\n const entry = expandPreset(preset, baseUrl ? { baseUrl } : {});\n const url = resolveProbeUrl(entry);\n if (!url) {\n return {\n ok: false,\n models: [],\n error: `Provider ${provider} exposes no models endpoint`,\n source: \"static\",\n };\n }\n // Static non-secret headers (Anthropic's `anthropic-version`) plus the\n // credential carrier the preset's `auth_header` names.\n const headers = { ...entry.headers, ...buildCredentialHeaders(entry, apiKey) };\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 10_000);\n\n const response = await fetch(url, {\n method: \"GET\",\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeout);\n\n if (!response.ok) {\n return {\n ok: false,\n models: [],\n error: `API returned HTTP ${response.status}`,\n source: \"static\",\n };\n }\n\n const body = await response.json();\n const models = parse(body);\n\n return { ok: true, models, source: \"api\" };\n } catch (err: any) {\n const msg =\n err.name === \"AbortError\" ? \"Request timed out (10s)\" : (err.message ?? \"Network error\");\n return { ok: false, models: [], error: msg, source: \"static\" };\n }\n}\n\n/**\n * Get models for a provider, trying the live API first and falling back to the static catalog.\n *\n * When no `apiKey` is provided the static catalog is returned immediately without\n * a network call. When the live API fails or returns an empty list, the static\n * catalog is used as a fallback — the result's `source` field indicates which was used.\n *\n * @param provider - Provider name (e.g. `\"anthropic\"`, `\"openai\"`, `\"google\"`).\n * @param apiKey - Optional API key; omit to skip the live fetch and use the static catalog.\n * @param options - Optional base-URL / environment overrides (see {@link FetchModelsOptions}).\n * @returns Resolved model list with source attribution.\n * @docLink packages/bridge/api-reference#models\n */\nexport async function getModels(\n provider: string,\n apiKey?: string,\n options: FetchModelsOptions = {},\n): Promise<FetchModelsResult> {\n if (!apiKey) {\n const models = getStaticModels(provider);\n return { ok: true, models, source: \"static\" };\n }\n\n const result = await fetchProviderModels(provider, apiKey, options);\n if (result.ok && result.models.length > 0) {\n return result;\n }\n\n // Fall back to static\n const staticModels = getStaticModels(provider);\n if (staticModels.length > 0) {\n return { ok: true, models: staticModels, source: \"static\", error: result.error };\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Static catalog (offline fallback)\n// ---------------------------------------------------------------------------\n\n/**\n * Offline model catalog keyed by provider name.\n *\n * Used as a fallback by {@link getModels} when the live provider API is unreachable or\n * returns an empty list. Covers Anthropic, OpenAI, Google, Mistral, Groq, DeepSeek,\n * xAI, Together, Fireworks, and OpenRouter. Update this list when providers add new\n * models and a live fetch is not available.\n *\n * @docLink packages/bridge/api-reference#models\n */\nexport const STATIC_MODELS: Record<string, ModelEntry[]> = {\n anthropic: [\n { id: \"claude-opus-4-6\", name: \"Claude Opus 4.6\" },\n { id: \"claude-sonnet-4-6\", name: \"Claude Sonnet 4.6\" },\n { id: \"claude-haiku-4-5-20251001\", name: \"Claude Haiku 4.5\" },\n { id: \"claude-opus-4-5\", name: \"Claude Opus 4.5\" },\n { id: \"claude-sonnet-4-5\", name: \"Claude Sonnet 4.5\" },\n ],\n openai: [\n { id: \"gpt-4o\", name: \"GPT-4o\" },\n { id: \"gpt-4o-mini\", name: \"GPT-4o Mini\" },\n { id: \"gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"o3\", name: \"o3\" },\n { id: \"o4-mini\", name: \"o4-mini\" },\n ],\n google: [\n { id: \"gemini-2.5-pro\", name: \"Gemini 2.5 Pro\" },\n { id: \"gemini-2.5-flash\", name: \"Gemini 2.5 Flash\" },\n { id: \"gemini-2.0-flash\", name: \"Gemini 2.0 Flash\" },\n ],\n mistral: [\n { id: \"mistral-large-latest\", name: \"Mistral Large\" },\n { id: \"mistral-small-latest\", name: \"Mistral Small\" },\n { id: \"codestral-latest\", name: \"Codestral\" },\n ],\n groq: [\n { id: \"llama-3.3-70b-versatile\", name: \"Llama 3.3 70B\" },\n { id: \"llama-3.1-8b-instant\", name: \"Llama 3.1 8B\" },\n { id: \"mixtral-8x7b-32768\", name: \"Mixtral 8x7B\" },\n ],\n deepseek: [\n { id: \"deepseek-chat\", name: \"DeepSeek Chat\" },\n { id: \"deepseek-reasoner\", name: \"DeepSeek Reasoner\" },\n ],\n xai: [\n { id: \"grok-3\", name: \"Grok 3\" },\n { id: \"grok-3-mini\", name: \"Grok 3 Mini\" },\n ],\n together: [\n { id: \"meta-llama/Llama-3.3-70B-Instruct-Turbo\", name: \"Llama 3.3 70B Turbo\" },\n { id: \"mistralai/Mixtral-8x7B-Instruct-v0.1\", name: \"Mixtral 8x7B\" },\n ],\n fireworks: [\n { id: \"accounts/fireworks/models/llama-v3p3-70b-instruct\", name: \"Llama 3.3 70B\" },\n { id: \"accounts/fireworks/models/deepseek-v3\", name: \"DeepSeek v3\" },\n ],\n openrouter: [\n { id: \"anthropic/claude-sonnet-4.6\", name: \"Claude Sonnet 4.6\" },\n { id: \"anthropic/claude-opus-4.6\", name: \"Claude Opus 4.6\" },\n { id: \"anthropic/claude-haiku-4.5\", name: \"Claude Haiku 4.5\" },\n { id: \"anthropic/claude-sonnet-4.5\", name: \"Claude Sonnet 4.5\" },\n { id: \"anthropic/claude-3.7-sonnet\", name: \"Claude 3.7 Sonnet\" },\n { id: \"openai/gpt-4o\", name: \"GPT-4o\" },\n { id: \"openai/gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"openai/gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"google/gemini-2.5-pro\", name: \"Gemini 2.5 Pro\" },\n { id: \"google/gemini-2.5-flash\", name: \"Gemini 2.5 Flash\" },\n { id: \"meta-llama/llama-4-maverick\", name: \"Llama 4 Maverick\" },\n { id: \"meta-llama/llama-3.3-70b-instruct\", name: \"Llama 3.3 70B\" },\n { id: \"deepseek/deepseek-chat-v3-0324\", name: \"DeepSeek v3\" },\n { id: \"deepseek/deepseek-r1\", name: \"DeepSeek R1\" },\n { id: \"mistralai/mistral-large-2411\", name: \"Mistral Large 2\" },\n ],\n};\n\n/**\n * Get models for a specific provider from the static catalog, or empty array if unknown.\n *\n * Pure synchronous lookup — no network call. Use when the provider API is unavailable\n * or when a fast offline fallback is needed (e.g. in the UI before credentials are configured).\n *\n * @param provider - Provider name matching a key in {@link STATIC_MODELS}.\n * @returns Offline model list, or `[]` for unknown providers.\n * @docLink packages/bridge/api-reference#models\n */\nexport function getStaticModels(provider: string): ModelEntry[] {\n return STATIC_MODELS[provider] ?? [];\n}\n\n// ---------------------------------------------------------------------------\n// Registry-backed model identity (§2.4)\n// ---------------------------------------------------------------------------\n\n/** A registry in either of the two shapes consumers hold. */\nexport type ProviderRegistryView = AIProviderRegistry | MergedAIProviderRegistry;\n\n/**\n * Where a model selector is resolved. `registry` absent means no registry is\n * configured at all — every resolver here then returns `undefined` and the\n * caller keeps its pre-registry behaviour.\n */\nexport interface ModelRegistryContext {\n /** The merged registry (`mergeRegistries`), or a single layer. */\n registry?: ProviderRegistryView;\n /** `skaile.yaml` `roles`: role name → model selector (`smol` → `groq/llama-3.1-8b`). */\n roles?: Record<string, string>;\n /**\n * Entry the session already runs on. Scopes `model_map` lookups to it;\n * absent lets the selector pick in registry order.\n */\n providerId?: string;\n}\n\n/** The `llm`/`embed` entry registered under `id`, if any. */\nfunction llmEntry(registry: ProviderRegistryView, id: string): AIProviderLlmEntry | undefined {\n const entry = registryEntries(registry).find(([entryId]) => entryId === id)?.[1];\n if (!entry || (entry.kind !== \"llm\" && entry.kind !== \"embed\")) return undefined;\n return entry;\n}\n\n/**\n * The wire facts that decide which model-id vocabulary an entry enforces\n * (`modelIdSchemaForTarget`).\n *\n * `surface` and `base_url` fall back to the entry's preset: an entry written as\n * `{kind: llm, preset: anthropic}` carries neither of its own until the catalog\n * merge layer expands it, and validation must not depend on having been handed\n * a merged registry.\n */\nexport function modelIdTargetForEntry(entry: AIProviderLlmEntry): ModelIdTarget {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n const surface = entry.surface ?? preset?.surface;\n const base_url = resolveEntryBaseUrl(entry) ?? (preset ? presetBaseUrl(preset) : undefined);\n return {\n ...(surface ? { surface } : {}),\n ...(entryTransport(entry) ? { transport: entryTransport(entry) } : {}),\n ...(base_url ? { base_url } : {}),\n };\n}\n\n/** A manifest model preference resolved against the registry. */\nexport interface ResolvedManifestModel {\n /** Entry the preference routes to. */\n providerId: string;\n /** Logical id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side id — what goes on the wire: `model_map[modelId] ?? modelId`. */\n providerModelId?: string;\n /** Role name, when the preference was `@role`. */\n role?: string;\n /** The wire target `providerModelId` was checked against. */\n target: ModelIdTarget;\n /** Non-fatal notes: a dangling role, a disabled provider, a stale preset. */\n warnings: string[];\n /**\n * Set when `providerModelId` is not a legal id for `target` — in practice,\n * a non-Anthropic id on the first-party Anthropic Messages API. Never\n * thrown: the caller decides whether a manifest that names a model its\n * endpoint cannot serve is a warning or a failure.\n */\n error?: string;\n}\n\n/**\n * Resolve an agent manifest's `model.preferred` (or any single entry of\n * `model.fallback`) against the provider registry, then check the id it\n * produces against the selected entry's own vocabulary.\n *\n * The three selector forms — `@role`, `<providerId>/<modelId>`, bare id — are\n * resolved by `parseModelRef` (`@skaile/workspaces/core/provider-registry`),\n * which owns that grammar; this adds the per-surface id check on top.\n *\n * Returns `undefined` when there is nothing to resolve: no preference, or no\n * registry that can serve one.\n */\nexport function resolveManifestModel(\n preference: string | undefined,\n context: ModelRegistryContext = {},\n): ResolvedManifestModel | undefined {\n if (!preference || !context.registry) return undefined;\n const ref = parseModelRef(preference, context.registry, context.roles);\n if (!ref) return undefined;\n\n const entry = llmEntry(context.registry, ref.providerId);\n const target = entry ? modelIdTargetForEntry(entry) : {};\n const resolved: ResolvedManifestModel = {\n providerId: ref.providerId,\n ...(ref.modelId !== undefined ? { modelId: ref.modelId } : {}),\n ...(ref.providerModelId !== undefined ? { providerModelId: ref.providerModelId } : {}),\n ...(ref.role !== undefined ? { role: ref.role } : {}),\n target,\n warnings: [...ref.warnings],\n };\n if (ref.providerModelId === undefined) return resolved;\n\n const check = modelIdSchemaForTarget(target).safeParse(ref.providerModelId);\n if (!check.success) {\n resolved.error =\n `model \"${ref.providerModelId}\" is not valid for provider \"${ref.providerId}\" ` +\n `(surface ${target.surface ?? \"unknown\"}, transport ${target.transport ?? \"direct\"}` +\n `${target.base_url ? `, ${target.base_url}` : \"\"}): ` +\n (check.error.issues[0]?.message ?? \"invalid model id\");\n }\n return resolved;\n}\n\n/**\n * Resolve a model's capability facts — context window, thinking ceiling, tool\n * and image support — from the registry entry that serves it.\n *\n * `capabilities` is keyed by the *logical* id (the `model_map` key), so a\n * selector is resolved first and the record is read under both the logical and\n * the provider-side id. `fallback` is the caller's own per-model table (the\n * compaction window defaults, the platform's thinking limits); the entry wins\n * field by field, and a field the entry does not state falls through.\n *\n * Returns `undefined` when neither source knows anything about the model.\n */\nexport function resolveModelCapabilities(\n selector: string | undefined,\n context: ModelRegistryContext & {\n /** Per-model-id capability table consulted for fields the entry omits. */\n fallback?: Record<string, AIProviderCapabilities>;\n } = {},\n): AIProviderCapabilities | undefined {\n if (!selector) return undefined;\n const ref = context.registry\n ? parseModelRef(selector, context.registry, context.roles)\n : undefined;\n const entry = ref && context.registry ? llmEntry(context.registry, ref.providerId) : undefined;\n const ids = [ref?.modelId, ref?.providerModelId, selector].filter(\n (id): id is string => id !== undefined,\n );\n const entryCaps = ids.map((id) => entry?.capabilities?.[id]).find((caps) => caps !== undefined);\n const fallbackCaps = ids.map((id) => context.fallback?.[id]).find((caps) => caps !== undefined);\n\n const context_window = entryCaps?.context_window ?? fallbackCaps?.context_window;\n const thinking_max = entryCaps?.thinking_max ?? fallbackCaps?.thinking_max;\n const tools = entryCaps?.tools ?? fallbackCaps?.tools;\n const images = entryCaps?.images ?? fallbackCaps?.images;\n if (\n context_window === undefined &&\n thinking_max === undefined &&\n tools === undefined &&\n images === undefined\n ) {\n return undefined;\n }\n return {\n ...(context_window !== undefined ? { context_window } : {}),\n ...(thinking_max !== undefined ? { thinking_max } : {}),\n ...(tools !== undefined ? { tools } : {}),\n ...(images !== undefined ? { images } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Model tier resolution (Flow v2 `run.model`)\n// ---------------------------------------------------------------------------\n\n/** Per-tier concrete model ids for one provider. */\nexport interface ModelTierOverrides {\n small?: string;\n default?: string;\n deep?: string;\n}\n\n/**\n * Tier→model mapping per provider, for deployments with **no provider\n * registry**. This is the point of the closed `small | default | deep`\n * vocabulary: an authored flow names an intent and the runtime owns which\n * concrete model serves it, so flows stay portable across model-lineup changes.\n *\n * It is no longer the source of truth for what a tier means. Where a registry\n * exists, a tier resolves through `roles` and the selected entry's `model_map`\n * (see {@link resolveModelTier}) — which works for every provider, names the\n * ids that deployment actually serves, and is editable without a release. This\n * table survives only for the pre-registry path, where nothing else can answer\n * the question; a vendor missing from it there is a `ModelTierResolutionError`,\n * not a guess.\n *\n * These are **direct provider-API ids**. A gateway transport (Bedrock, Vertex,\n * Azure) addresses the same models by different ids — Bedrock prefixes\n * `us.anthropic.`, for instance — and that translation belongs to whoever owns\n * the deployment, not here. {@link resolveModelTier} therefore consults this\n * table only on the direct API and demands an explicit override otherwise,\n * rather than handing a gateway an id it cannot serve.\n *\n * Every id here must also appear in {@link STATIC_MODELS} — a test asserts it,\n * so the two cannot drift into naming a model the catalog disowns. That check\n * proves internal consistency only; it cannot tell you an id is still current\n * with a provider's live lineup.\n *\n * Where a provider's lineup has no genuinely distinct model for a tier, the\n * entry deliberately repeats the neighbouring one. That is a reviewable\n * property of that lineup, unlike inheriting whatever model the session\n * happened to start with — which is how `small` could silently mean Opus.\n */\nexport const PROVIDER_MODEL_TIERS: Record<string, Required<ModelTierOverrides>> = {\n anthropic: {\n small: \"claude-haiku-4-5-20251001\",\n default: \"claude-sonnet-4-6\",\n deep: \"claude-opus-4-6\",\n },\n openai: { small: \"gpt-4o-mini\", default: \"gpt-4.1\", deep: \"o3\" },\n google: { small: \"gemini-2.0-flash\", default: \"gemini-2.5-flash\", deep: \"gemini-2.5-pro\" },\n mistral: {\n small: \"mistral-small-latest\",\n default: \"mistral-large-latest\",\n deep: \"mistral-large-latest\",\n },\n groq: {\n small: \"llama-3.1-8b-instant\",\n default: \"llama-3.3-70b-versatile\",\n deep: \"llama-3.3-70b-versatile\",\n },\n deepseek: { small: \"deepseek-chat\", default: \"deepseek-chat\", deep: \"deepseek-reasoner\" },\n xai: { small: \"grok-3-mini\", default: \"grok-3\", deep: \"grok-3\" },\n together: {\n small: \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n default: \"meta-llama/Llama-3.3-70B-Instruct-Turbo\",\n deep: \"meta-llama/Llama-3.3-70B-Instruct-Turbo\",\n },\n fireworks: {\n small: \"accounts/fireworks/models/llama-v3p3-70b-instruct\",\n default: \"accounts/fireworks/models/llama-v3p3-70b-instruct\",\n deep: \"accounts/fireworks/models/deepseek-v3\",\n },\n openrouter: {\n small: \"anthropic/claude-haiku-4.5\",\n default: \"anthropic/claude-sonnet-4.6\",\n deep: \"anthropic/claude-opus-4.6\",\n },\n};\n\n/** Raised when a tier names an intent this provider cannot serve. */\nexport class ModelTierResolutionError extends Error {\n constructor(\n readonly tier: \"small\" | \"deep\",\n readonly provider: string | undefined,\n ) {\n super(\n `cannot resolve model tier \"${tier}\" for provider \"${provider ?? \"(none)\"}\": no built-in mapping and no configured override. ` +\n `Configure a \"${tier}\" model override for this provider, or author the node as model: \"default\" to inherit the session model.`,\n );\n this.name = \"ModelTierResolutionError\";\n }\n}\n\n/**\n * Resolve a tier for a deployment that has a registry: through `roles[tier]`\n * first, then the selected entry's `model_map[tier]`.\n *\n * A `model_map` **miss is a miss**. `parseModelRef` falls back to the literal\n * selector when nothing maps it, and no provider serves a model called\n * `\"small\"` — so only a genuine mapping counts, and an unmapped tier is left\n * for the caller to fail on.\n */\nfunction resolveTierThroughRegistry(\n tier: keyof ModelTierOverrides,\n options: ModelRegistryContext,\n): string | undefined {\n const { registry, roles, providerId } = options;\n if (!registry) return undefined;\n if (roles?.[tier] !== undefined) {\n const viaRole = parseModelRef(`@${tier}`, registry, roles);\n if (viaRole?.providerModelId) return viaRole.providerModelId;\n }\n const ref = parseModelRef(providerId ? `${providerId}/${tier}` : tier, registry, roles);\n if (!ref?.modelId) return undefined;\n return llmEntry(registry, ref.providerId)?.model_map?.[ref.modelId];\n}\n\n/** Options {@link resolveModelTier} reads. */\nexport interface ResolveModelTierOptions extends ModelRegistryContext {\n /** Legacy provider id, keying {@link PROVIDER_MODEL_TIERS}. */\n provider?: string;\n /** Legacy cloud transport; anything but `default` disables the built-in table. */\n cloud?: string;\n /** Per-tier ids configured for this deployment. Wins over everything. */\n overrides?: ModelTierOverrides;\n}\n\n/**\n * Resolve a Flow v2 `run.model` tier to a concrete model id.\n *\n * Precedence, highest first: a configured `overrides` entry; the registry —\n * `roles[tier]`, then the selected entry's `model_map[tier]`, which is how a\n * tier is defined for *any* provider; and finally, **only when no registry is\n * configured**, {@link PROVIDER_MODEL_TIERS} on the direct provider API.\n *\n * `\"default\"` and an absent tier **inherit `sessionModel` first**. The session\n * model is the one id known to work for this deployment — it already carries\n * whatever provider, lineup and gateway translation the host configured — so\n * preferring any table over it would silently downgrade a configured model\n * and, on a gateway transport, substitute an id that provider cannot serve.\n *\n * `\"small\"` and `\"deep\"` never fall back to `sessionModel`; when nothing above\n * resolves them they throw {@link ModelTierResolutionError}. Inheriting there\n * would run an arbitrary model behind an author's explicit request for a cheap\n * or a strong one — a cost or quality surprise that shows up only in the bill\n * or the output. Failing names it at the node instead.\n *\n * Pure: no I/O, no environment reads.\n */\nexport function resolveModelTier(\n tier: \"small\" | \"default\" | \"deep\" | undefined,\n sessionModel: string | undefined,\n options: ResolveModelTierOptions = {},\n): string | undefined {\n // Built-in ids address the provider's own API; a gateway renames them. And a\n // registry answers the question properly, so the table is its fallback only.\n const directApi = !options.cloud || options.cloud === \"default\";\n const builtIn =\n !options.registry && directApi && options.provider\n ? PROVIDER_MODEL_TIERS[options.provider]\n : undefined;\n if (tier === \"small\" || tier === \"deep\") {\n const resolved =\n options.overrides?.[tier] ?? resolveTierThroughRegistry(tier, options) ?? builtIn?.[tier];\n if (!resolved) throw new ModelTierResolutionError(tier, options.provider);\n return resolved;\n }\n return (\n options.overrides?.default ??\n sessionModel ??\n resolveTierThroughRegistry(\"default\", options) ??\n builtIn?.default\n );\n}\n"]}
1
+ {"version":3,"sources":["../bridge/src/models.ts"],"names":[],"mappings":";;;;;AAmDA,SAAS,SAAS,EAAA,EAAoB;AACpC,EAAA,OAAO,EAAA,CACJ,OAAA,CAAQ,4BAAA,EAA8B,EAAE,EACxC,OAAA,CAAQ,OAAA,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,CAAA,GAAK,IAAA,EAAM,QAAA,EAAU,KAAK,CAAA;AACtF,EAAA,IAAI,CAAC,GAAA,EAAK,OAAA,EAAS,OAAO,MAAA;AAC1B,EAAA,OAAO,SAAS,QAAA,EAAU,GAAA,CAAI,UAAU,CAAA,EAAG,SAAA,GAAY,IAAI,OAAO,CAAA;AACpE;AAkCO,SAAS,gBAAA,CACd,IAAA,EACA,YAAA,EACA,OAAA,GAAmC,EAAC,EAChB;AAGpB,EAAA,MAAM,SAAA,GAAY,CAAC,OAAA,CAAQ,KAAA,IAAS,QAAQ,KAAA,KAAU,SAAA;AACtD,EAAA,MAAM,OAAA,GACJ,CAAC,OAAA,CAAQ,QAAA,IAAY,SAAA,IAAa,QAAQ,QAAA,GACtC,oBAAA,CAAqB,OAAA,CAAQ,QAAQ,CAAA,GACrC,MAAA;AACN,EAAA,IAAI,IAAA,KAAS,OAAA,IAAW,IAAA,KAAS,MAAA,EAAQ;AACvC,IAAA,MAAM,QAAA,GACJ,OAAA,CAAQ,SAAA,GAAY,IAAI,CAAA,IAAK,2BAA2B,IAAA,EAAM,OAAO,CAAA,IAAK,OAAA,GAAU,IAAI,CAAA;AAC1F,IAAA,IAAI,CAAC,QAAA,EAAU,MAAM,IAAI,wBAAA,CAAyB,IAAA,EAAM,QAAQ,QAAQ,CAAA;AACxE,IAAA,OAAO,QAAA;AAAA,EACT;AACA,EAAA,OACE,OAAA,CAAQ,WAAW,OAAA,IACnB,YAAA,IACA,2BAA2B,SAAA,EAAW,OAAO,KAC7C,OAAA,EAAS,OAAA;AAEb","file":"chunk-QTTAATBK.js","sourcesContent":["/**\n * Model catalog — static fallback + live provider API fetching.\n *\n * Provides `fetchProviderModels(provider, apiKey)` for live model lists and\n * `getStaticModels(provider)` as an offline fallback.\n * OMP model listing is handled by `OmpDriver.listModels()` in the bridge driver.\n */\n\nimport {\n type AIProviderCapabilities,\n type AIProviderLlmEntry,\n type AIProviderRegistry,\n entryTransport,\n type MergedAIProviderRegistry,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport { type ModelIdTarget, modelIdSchemaForTarget } from \"@skaile/workspaces/types/manifests\";\nimport {\n buildCredentialHeaders,\n expandPreset,\n getProviderPreset,\n presetBaseUrl,\n resolvePresetBaseUrl,\n resolveProbeUrl,\n} from \"./provider-catalog.js\";\n\n/**\n * A single LLM model entry returned by the model catalog.\n *\n * Used by `getModels`, `getStaticModels`, and `fetchProviderModels` to represent\n * an available model for a provider.\n *\n * @docLink packages/bridge/api-reference#models\n */\nexport interface ModelEntry {\n /** Provider-specific model identifier used in API calls (e.g. `\"claude-sonnet-4-5\"`). */\n id: string;\n /** Human-readable display name for UIs and logs (e.g. `\"Claude Sonnet 4.5\"`). */\n name: string;\n}\n\n// ---------------------------------------------------------------------------\n// Provider API configs (for fetching model lists)\n// ---------------------------------------------------------------------------\n\n/** Extract ModelEntry[] from a provider's parsed models-list JSON response. */\ntype ParseModels = (body: any) => ModelEntry[];\n\n/** Humanize a model ID into a display name (e.g. \"claude-sonnet-4-6\" → \"Claude Sonnet 4 6\") */\nfunction humanize(id: string): string {\n return id\n .replace(/^accounts\\/[^/]+\\/models\\//, \"\")\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (c) => c.toUpperCase());\n}\n\n/**\n * Filter function used by providers that return the OpenAI-style /v1/models list.\n * Keeps only chat/completion models, skips embeddings, moderation, tts, whisper, dall-e, etc.\n */\nfunction isLikelyChatModel(id: string): boolean {\n const skip = /embed|moderat|tts|whisper|dall-e|davinci|babbage|ada-00|text-/i;\n return !skip.test(id);\n}\n\n// Per-provider response parsers. The endpoint URL and the credential header\n// come from the catalog preset (provider-catalog.ts), joined in\n// fetchProviderModels.\nconst PROVIDER_PARSERS: Record<string, ParseModels> = {\n anthropic: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && !m.id.includes(\"embed\"))\n .map((m: any) => ({\n id: m.id,\n name: m.display_name ?? humanize(m.id),\n }));\n },\n openai: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n openrouter: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id)\n .map((m: any) => ({ id: m.id, name: m.name ?? humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n mistral: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n groq: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n deepseek: (body) => {\n const models = body?.data ?? [];\n return models\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n xai: (body) => {\n const models = body?.data ?? [];\n return models\n .filter((m: any) => m.id && isLikelyChatModel(m.id))\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n together: (body) => {\n const models = body?.data ?? body ?? [];\n const arr = Array.isArray(models) ? models : [];\n return arr\n .filter((m: any) => m.id && m.type === \"chat\")\n .map((m: any) => ({ id: m.id, name: m.display_name ?? humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n fireworks: (body) => {\n const models = body?.data ?? [];\n return models\n .map((m: any) => ({ id: m.id, name: humanize(m.id) }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n google: (body) => {\n const models = body?.models ?? [];\n return models\n .filter((m: any) => m.supportedGenerationMethods?.includes(\"generateContent\"))\n .map((m: any) => ({\n id: (m.name ?? \"\").replace(/^models\\//, \"\"),\n name: m.displayName ?? humanize(m.name ?? \"\"),\n }))\n .sort((a: ModelEntry, b: ModelEntry) => a.id.localeCompare(b.id));\n },\n};\n\n// ---------------------------------------------------------------------------\n// Live fetch\n// ---------------------------------------------------------------------------\n\n/**\n * Result of a model-list fetch operation, with source attribution.\n *\n * Returned by {@link fetchProviderModels} and {@link getModels}. When `ok` is `false`,\n * `models` is empty and `error` describes the failure. The `source` field indicates\n * whether the list came from a live API call or the offline static catalog.\n *\n * @docLink packages/bridge/api-reference#models\n */\nexport interface FetchModelsResult {\n /** `true` when the fetch succeeded and `models` is populated. */\n ok: boolean;\n /** Fetched model list; empty on failure. */\n models: ModelEntry[];\n /** Human-readable error description when `ok` is `false`. */\n error?: string;\n /** Whether the result came from a live API call or the static fallback. */\n source: \"api\" | \"static\";\n}\n\n/**\n * Options controlling where a model-list fetch is addressed.\n *\n * @since 1.5.0\n */\nexport interface FetchModelsOptions {\n /**\n * Base URL to resolve the provider's models endpoint against — e.g. the\n * gateway a session already routes completions through. Overrides the\n * provider's `baseUrlEnv` value.\n */\n baseUrl?: string;\n /**\n * Environment consulted for the provider's base-URL env var\n * (`ANTHROPIC_BASE_URL` for `anthropic`). Defaults to `process.env`; pass an\n * explicit record to keep a call hermetic.\n */\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Fetch the model list from a provider's REST API.\n *\n * Returns `{ ok: true, models, source: 'api' }` on success, or\n * `{ ok: false, models: [], error }` on any HTTP or network failure — the\n * caller should fall back to {@link getStaticModels} in that case.\n *\n * The endpoint, the credential header and the response path all come from the\n * catalog preset named by `provider` ({@link resolvePresetBaseUrl},\n * {@link resolveProbeUrl}, {@link buildCredentialHeaders}), so discovery hits\n * the same host dispatch does — including a gateway named by `baseUrl` or by\n * the vendor's own `*_BASE_URL` variable.\n *\n * @param provider - Catalog preset id (e.g. `\"anthropic\"`, `\"openai\"`, `\"google\"`).\n * @param apiKey - API key presented in the preset's credential header.\n * @param options - Optional base-URL / environment overrides.\n * @returns Resolved model list with source attribution.\n * @docLink packages/bridge/api-reference#models\n */\nexport async function fetchProviderModels(\n provider: string,\n apiKey: string,\n options: FetchModelsOptions = {},\n): Promise<FetchModelsResult> {\n const preset = getProviderPreset(provider);\n const parse = PROVIDER_PARSERS[provider];\n if (!preset || !parse) {\n return {\n ok: false,\n models: [],\n error: `No API config for provider: ${provider}`,\n source: \"static\",\n };\n }\n\n const baseUrl = resolvePresetBaseUrl(preset, {\n ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),\n env: options.env ?? process.env,\n });\n const entry = expandPreset(preset, baseUrl ? { baseUrl } : {});\n const url = resolveProbeUrl(entry);\n if (!url) {\n return {\n ok: false,\n models: [],\n error: `Provider ${provider} exposes no models endpoint`,\n source: \"static\",\n };\n }\n // Static non-secret headers (Anthropic's `anthropic-version`) plus the\n // credential carrier the preset's `auth_header` names.\n const headers = { ...entry.headers, ...buildCredentialHeaders(entry, apiKey) };\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 10_000);\n\n const response = await fetch(url, {\n method: \"GET\",\n headers,\n signal: controller.signal,\n });\n\n clearTimeout(timeout);\n\n if (!response.ok) {\n return {\n ok: false,\n models: [],\n error: `API returned HTTP ${response.status}`,\n source: \"static\",\n };\n }\n\n const body = await response.json();\n const models = parse(body);\n\n return { ok: true, models, source: \"api\" };\n } catch (err: any) {\n const msg =\n err.name === \"AbortError\" ? \"Request timed out (10s)\" : (err.message ?? \"Network error\");\n return { ok: false, models: [], error: msg, source: \"static\" };\n }\n}\n\n/**\n * Get models for a provider, trying the live API first and falling back to the static catalog.\n *\n * When no `apiKey` is provided the static catalog is returned immediately without\n * a network call. When the live API fails or returns an empty list, the static\n * catalog is used as a fallback — the result's `source` field indicates which was used.\n *\n * @param provider - Provider name (e.g. `\"anthropic\"`, `\"openai\"`, `\"google\"`).\n * @param apiKey - Optional API key; omit to skip the live fetch and use the static catalog.\n * @param options - Optional base-URL / environment overrides (see {@link FetchModelsOptions}).\n * @returns Resolved model list with source attribution.\n * @docLink packages/bridge/api-reference#models\n */\nexport async function getModels(\n provider: string,\n apiKey?: string,\n options: FetchModelsOptions = {},\n): Promise<FetchModelsResult> {\n if (!apiKey) {\n const models = getStaticModels(provider);\n return { ok: true, models, source: \"static\" };\n }\n\n const result = await fetchProviderModels(provider, apiKey, options);\n if (result.ok && result.models.length > 0) {\n return result;\n }\n\n // Fall back to static\n const staticModels = getStaticModels(provider);\n if (staticModels.length > 0) {\n return { ok: true, models: staticModels, source: \"static\", error: result.error };\n }\n\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Static catalog (offline fallback)\n// ---------------------------------------------------------------------------\n\n/**\n * Offline model catalog keyed by provider name.\n *\n * Used as a fallback by {@link getModels} when the live provider API is unreachable or\n * returns an empty list. Covers Anthropic, OpenAI, Google, Mistral, Groq, DeepSeek,\n * xAI, Together, Fireworks, and OpenRouter. Update this list when providers add new\n * models and a live fetch is not available.\n *\n * @docLink packages/bridge/api-reference#models\n */\nexport const STATIC_MODELS: Record<string, ModelEntry[]> = {\n anthropic: [\n { id: \"claude-opus-4-6\", name: \"Claude Opus 4.6\" },\n { id: \"claude-sonnet-4-6\", name: \"Claude Sonnet 4.6\" },\n { id: \"claude-haiku-4-5-20251001\", name: \"Claude Haiku 4.5\" },\n { id: \"claude-opus-4-5\", name: \"Claude Opus 4.5\" },\n { id: \"claude-sonnet-4-5\", name: \"Claude Sonnet 4.5\" },\n ],\n openai: [\n { id: \"gpt-4o\", name: \"GPT-4o\" },\n { id: \"gpt-4o-mini\", name: \"GPT-4o Mini\" },\n { id: \"gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"o3\", name: \"o3\" },\n { id: \"o4-mini\", name: \"o4-mini\" },\n ],\n google: [\n { id: \"gemini-2.5-pro\", name: \"Gemini 2.5 Pro\" },\n { id: \"gemini-2.5-flash\", name: \"Gemini 2.5 Flash\" },\n { id: \"gemini-2.0-flash\", name: \"Gemini 2.0 Flash\" },\n ],\n mistral: [\n { id: \"mistral-large-latest\", name: \"Mistral Large\" },\n { id: \"mistral-small-latest\", name: \"Mistral Small\" },\n { id: \"codestral-latest\", name: \"Codestral\" },\n ],\n groq: [\n { id: \"llama-3.3-70b-versatile\", name: \"Llama 3.3 70B\" },\n { id: \"llama-3.1-8b-instant\", name: \"Llama 3.1 8B\" },\n { id: \"mixtral-8x7b-32768\", name: \"Mixtral 8x7B\" },\n ],\n deepseek: [\n { id: \"deepseek-chat\", name: \"DeepSeek Chat\" },\n { id: \"deepseek-reasoner\", name: \"DeepSeek Reasoner\" },\n ],\n xai: [\n { id: \"grok-3\", name: \"Grok 3\" },\n { id: \"grok-3-mini\", name: \"Grok 3 Mini\" },\n ],\n together: [\n { id: \"meta-llama/Llama-3.3-70B-Instruct-Turbo\", name: \"Llama 3.3 70B Turbo\" },\n { id: \"mistralai/Mixtral-8x7B-Instruct-v0.1\", name: \"Mixtral 8x7B\" },\n ],\n fireworks: [\n { id: \"accounts/fireworks/models/llama-v3p3-70b-instruct\", name: \"Llama 3.3 70B\" },\n { id: \"accounts/fireworks/models/deepseek-v3\", name: \"DeepSeek v3\" },\n ],\n openrouter: [\n { id: \"anthropic/claude-sonnet-4.6\", name: \"Claude Sonnet 4.6\" },\n { id: \"anthropic/claude-opus-4.6\", name: \"Claude Opus 4.6\" },\n { id: \"anthropic/claude-haiku-4.5\", name: \"Claude Haiku 4.5\" },\n { id: \"anthropic/claude-sonnet-4.5\", name: \"Claude Sonnet 4.5\" },\n { id: \"anthropic/claude-3.7-sonnet\", name: \"Claude 3.7 Sonnet\" },\n { id: \"openai/gpt-4o\", name: \"GPT-4o\" },\n { id: \"openai/gpt-4.1\", name: \"GPT-4.1\" },\n { id: \"openai/gpt-4.1-mini\", name: \"GPT-4.1 Mini\" },\n { id: \"google/gemini-2.5-pro\", name: \"Gemini 2.5 Pro\" },\n { id: \"google/gemini-2.5-flash\", name: \"Gemini 2.5 Flash\" },\n { id: \"meta-llama/llama-4-maverick\", name: \"Llama 4 Maverick\" },\n { id: \"meta-llama/llama-3.3-70b-instruct\", name: \"Llama 3.3 70B\" },\n { id: \"deepseek/deepseek-chat-v3-0324\", name: \"DeepSeek v3\" },\n { id: \"deepseek/deepseek-r1\", name: \"DeepSeek R1\" },\n { id: \"mistralai/mistral-large-2411\", name: \"Mistral Large 2\" },\n ],\n};\n\n/**\n * Get models for a specific provider from the static catalog, or empty array if unknown.\n *\n * Pure synchronous lookup — no network call. Use when the provider API is unavailable\n * or when a fast offline fallback is needed (e.g. in the UI before credentials are configured).\n *\n * @param provider - Provider name matching a key in {@link STATIC_MODELS}.\n * @returns Offline model list, or `[]` for unknown providers.\n * @docLink packages/bridge/api-reference#models\n */\nexport function getStaticModels(provider: string): ModelEntry[] {\n return STATIC_MODELS[provider] ?? [];\n}\n\n// ---------------------------------------------------------------------------\n// Registry-backed model identity (§2.4)\n// ---------------------------------------------------------------------------\n\n/** A registry in either of the two shapes consumers hold. */\nexport type ProviderRegistryView = AIProviderRegistry | MergedAIProviderRegistry;\n\n/**\n * Where a model selector is resolved. `registry` absent means no registry is\n * configured at all — every resolver here then returns `undefined` and the\n * caller keeps its pre-registry behaviour.\n */\nexport interface ModelRegistryContext {\n /** The merged registry (`mergeRegistries`), or a single layer. */\n registry?: ProviderRegistryView;\n /** `skaile.yaml` `roles`: role name → model selector (`smol` → `groq/llama-3.1-8b`). */\n roles?: Record<string, string>;\n /**\n * Entry the session already runs on. Scopes `model_map` lookups to it;\n * absent lets the selector pick in registry order.\n */\n providerId?: string;\n}\n\n/** The `llm`/`embed` entry registered under `id`, if any. */\nfunction llmEntry(registry: ProviderRegistryView, id: string): AIProviderLlmEntry | undefined {\n const entry = registryEntries(registry).find(([entryId]) => entryId === id)?.[1];\n if (!entry || (entry.kind !== \"llm\" && entry.kind !== \"embed\")) return undefined;\n return entry;\n}\n\n/**\n * The wire facts that decide which model-id vocabulary an entry enforces\n * (`modelIdSchemaForTarget`).\n *\n * `surface` and `base_url` fall back to the entry's preset: an entry written as\n * `{kind: llm, preset: anthropic}` carries neither of its own until the catalog\n * merge layer expands it, and validation must not depend on having been handed\n * a merged registry.\n */\nexport function modelIdTargetForEntry(entry: AIProviderLlmEntry): ModelIdTarget {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n const surface = entry.surface ?? preset?.surface;\n const base_url = resolveEntryBaseUrl(entry) ?? (preset ? presetBaseUrl(preset) : undefined);\n return {\n ...(surface ? { surface } : {}),\n ...(entryTransport(entry) ? { transport: entryTransport(entry) } : {}),\n ...(base_url ? { base_url } : {}),\n };\n}\n\n/** A manifest model preference resolved against the registry. */\nexport interface ResolvedManifestModel {\n /** Entry the preference routes to. */\n providerId: string;\n /** Logical id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side id — what goes on the wire: `model_map[modelId] ?? modelId`. */\n providerModelId?: string;\n /** Role name, when the preference was `@role`. */\n role?: string;\n /** The wire target `providerModelId` was checked against. */\n target: ModelIdTarget;\n /** Non-fatal notes: a dangling role, a disabled provider, a stale preset. */\n warnings: string[];\n /**\n * Set when `providerModelId` is not a legal id for `target` — in practice,\n * a non-Anthropic id on the first-party Anthropic Messages API. Never\n * thrown: the caller decides whether a manifest that names a model its\n * endpoint cannot serve is a warning or a failure.\n */\n error?: string;\n}\n\n/**\n * Resolve an agent manifest's `model.preferred` (or any single entry of\n * `model.fallback`) against the provider registry, then check the id it\n * produces against the selected entry's own vocabulary.\n *\n * The three selector forms — `@role`, `<providerId>/<modelId>`, bare id — are\n * resolved by `parseModelRef` (`@skaile/workspaces/core/provider-registry`),\n * which owns that grammar; this adds the per-surface id check on top.\n *\n * Returns `undefined` when there is nothing to resolve: no preference, or no\n * registry that can serve one.\n */\nexport function resolveManifestModel(\n preference: string | undefined,\n context: ModelRegistryContext = {},\n): ResolvedManifestModel | undefined {\n if (!preference || !context.registry) return undefined;\n const ref = parseModelRef(preference, context.registry, context.roles);\n if (!ref) return undefined;\n\n const entry = llmEntry(context.registry, ref.providerId);\n const target = entry ? modelIdTargetForEntry(entry) : {};\n const resolved: ResolvedManifestModel = {\n providerId: ref.providerId,\n ...(ref.modelId !== undefined ? { modelId: ref.modelId } : {}),\n ...(ref.providerModelId !== undefined ? { providerModelId: ref.providerModelId } : {}),\n ...(ref.role !== undefined ? { role: ref.role } : {}),\n target,\n warnings: [...ref.warnings],\n };\n if (ref.providerModelId === undefined) return resolved;\n\n const check = modelIdSchemaForTarget(target).safeParse(ref.providerModelId);\n if (!check.success) {\n resolved.error =\n `model \"${ref.providerModelId}\" is not valid for provider \"${ref.providerId}\" ` +\n `(surface ${target.surface ?? \"unknown\"}, transport ${target.transport ?? \"direct\"}` +\n `${target.base_url ? `, ${target.base_url}` : \"\"}): ` +\n (check.error.issues[0]?.message ?? \"invalid model id\");\n }\n return resolved;\n}\n\n/**\n * Resolve a model's capability facts — context window, thinking ceiling, tool\n * and image support — from the registry entry that serves it.\n *\n * `capabilities` is keyed by the *logical* id (the `model_map` key), so a\n * selector is resolved first and the record is read under both the logical and\n * the provider-side id. `fallback` is the caller's own per-model table (the\n * compaction window defaults, the platform's thinking limits); the entry wins\n * field by field, and a field the entry does not state falls through.\n *\n * Returns `undefined` when neither source knows anything about the model.\n */\nexport function resolveModelCapabilities(\n selector: string | undefined,\n context: ModelRegistryContext & {\n /** Per-model-id capability table consulted for fields the entry omits. */\n fallback?: Record<string, AIProviderCapabilities>;\n } = {},\n): AIProviderCapabilities | undefined {\n if (!selector) return undefined;\n const ref = context.registry\n ? parseModelRef(selector, context.registry, context.roles)\n : undefined;\n const entry = ref && context.registry ? llmEntry(context.registry, ref.providerId) : undefined;\n const ids = [ref?.modelId, ref?.providerModelId, selector].filter(\n (id): id is string => id !== undefined,\n );\n const entryCaps = ids.map((id) => entry?.capabilities?.[id]).find((caps) => caps !== undefined);\n const fallbackCaps = ids.map((id) => context.fallback?.[id]).find((caps) => caps !== undefined);\n\n const context_window = entryCaps?.context_window ?? fallbackCaps?.context_window;\n const thinking_max = entryCaps?.thinking_max ?? fallbackCaps?.thinking_max;\n const tools = entryCaps?.tools ?? fallbackCaps?.tools;\n const images = entryCaps?.images ?? fallbackCaps?.images;\n if (\n context_window === undefined &&\n thinking_max === undefined &&\n tools === undefined &&\n images === undefined\n ) {\n return undefined;\n }\n return {\n ...(context_window !== undefined ? { context_window } : {}),\n ...(thinking_max !== undefined ? { thinking_max } : {}),\n ...(tools !== undefined ? { tools } : {}),\n ...(images !== undefined ? { images } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Model tier resolution (Flow v2 `run.model`)\n// ---------------------------------------------------------------------------\n\n/** Per-tier concrete model ids for one provider. */\nexport interface ModelTierOverrides {\n small?: string;\n default?: string;\n deep?: string;\n}\n\n/**\n * Tier→model mapping per provider, for deployments with **no provider\n * registry**. This is the point of the closed `small | default | deep`\n * vocabulary: an authored flow names an intent and the runtime owns which\n * concrete model serves it, so flows stay portable across model-lineup changes.\n *\n * It is no longer the source of truth for what a tier means. Where a registry\n * exists, a tier resolves through `roles` and the selected entry's `model_map`\n * (see {@link resolveModelTier}) — which works for every provider, names the\n * ids that deployment actually serves, and is editable without a release. This\n * table survives only for the pre-registry path, where nothing else can answer\n * the question; a vendor missing from it there is a `ModelTierResolutionError`,\n * not a guess.\n *\n * These are **direct provider-API ids**. A gateway transport (Bedrock, Vertex,\n * Azure) addresses the same models by different ids — Bedrock prefixes\n * `us.anthropic.`, for instance — and that translation belongs to whoever owns\n * the deployment, not here. {@link resolveModelTier} therefore consults this\n * table only on the direct API and demands an explicit override otherwise,\n * rather than handing a gateway an id it cannot serve.\n *\n * Every id here must also appear in {@link STATIC_MODELS} — a test asserts it,\n * so the two cannot drift into naming a model the catalog disowns. That check\n * proves internal consistency only; it cannot tell you an id is still current\n * with a provider's live lineup.\n *\n * Where a provider's lineup has no genuinely distinct model for a tier, the\n * entry deliberately repeats the neighbouring one. That is a reviewable\n * property of that lineup, unlike inheriting whatever model the session\n * happened to start with — which is how `small` could silently mean Opus.\n */\nexport const PROVIDER_MODEL_TIERS: Record<string, Required<ModelTierOverrides>> = {\n anthropic: {\n small: \"claude-haiku-4-5-20251001\",\n default: \"claude-sonnet-4-6\",\n deep: \"claude-opus-4-6\",\n },\n openai: { small: \"gpt-4o-mini\", default: \"gpt-4.1\", deep: \"o3\" },\n google: { small: \"gemini-2.0-flash\", default: \"gemini-2.5-flash\", deep: \"gemini-2.5-pro\" },\n mistral: {\n small: \"mistral-small-latest\",\n default: \"mistral-large-latest\",\n deep: \"mistral-large-latest\",\n },\n groq: {\n small: \"llama-3.1-8b-instant\",\n default: \"llama-3.3-70b-versatile\",\n deep: \"llama-3.3-70b-versatile\",\n },\n deepseek: { small: \"deepseek-chat\", default: \"deepseek-chat\", deep: \"deepseek-reasoner\" },\n xai: { small: \"grok-3-mini\", default: \"grok-3\", deep: \"grok-3\" },\n together: {\n small: \"mistralai/Mixtral-8x7B-Instruct-v0.1\",\n default: \"meta-llama/Llama-3.3-70B-Instruct-Turbo\",\n deep: \"meta-llama/Llama-3.3-70B-Instruct-Turbo\",\n },\n fireworks: {\n small: \"accounts/fireworks/models/llama-v3p3-70b-instruct\",\n default: \"accounts/fireworks/models/llama-v3p3-70b-instruct\",\n deep: \"accounts/fireworks/models/deepseek-v3\",\n },\n openrouter: {\n small: \"anthropic/claude-haiku-4.5\",\n default: \"anthropic/claude-sonnet-4.6\",\n deep: \"anthropic/claude-opus-4.6\",\n },\n};\n\n/** Raised when a tier names an intent this provider cannot serve. */\nexport class ModelTierResolutionError extends Error {\n constructor(\n readonly tier: \"small\" | \"deep\",\n readonly provider: string | undefined,\n ) {\n super(\n `cannot resolve model tier \"${tier}\" for provider \"${provider ?? \"(none)\"}\": no built-in mapping and no configured override. ` +\n `Configure a \"${tier}\" model override for this provider, or author the node as model: \"default\" to inherit the session model.`,\n );\n this.name = \"ModelTierResolutionError\";\n }\n}\n\n/**\n * Resolve a tier for a deployment that has a registry: through `roles[tier]`\n * first, then the selected entry's `model_map[tier]`.\n *\n * A `model_map` **miss is a miss**. `parseModelRef` falls back to the literal\n * selector when nothing maps it, and no provider serves a model called\n * `\"small\"` — so only a genuine mapping counts, and an unmapped tier is left\n * for the caller to fail on.\n */\nfunction resolveTierThroughRegistry(\n tier: keyof ModelTierOverrides,\n options: ModelRegistryContext,\n): string | undefined {\n const { registry, roles, providerId } = options;\n if (!registry) return undefined;\n if (roles?.[tier] !== undefined) {\n const viaRole = parseModelRef(`@${tier}`, registry, roles);\n if (viaRole?.providerModelId) return viaRole.providerModelId;\n }\n const ref = parseModelRef(providerId ? `${providerId}/${tier}` : tier, registry, roles);\n if (!ref?.modelId) return undefined;\n return llmEntry(registry, ref.providerId)?.model_map?.[ref.modelId];\n}\n\n/** Options {@link resolveModelTier} reads. */\nexport interface ResolveModelTierOptions extends ModelRegistryContext {\n /** Legacy provider id, keying {@link PROVIDER_MODEL_TIERS}. */\n provider?: string;\n /** Legacy cloud transport; anything but `default` disables the built-in table. */\n cloud?: string;\n /** Per-tier ids configured for this deployment. Wins over everything. */\n overrides?: ModelTierOverrides;\n}\n\n/**\n * Resolve a Flow v2 `run.model` tier to a concrete model id.\n *\n * Precedence, highest first: a configured `overrides` entry; the registry —\n * `roles[tier]`, then the selected entry's `model_map[tier]`, which is how a\n * tier is defined for *any* provider; and finally, **only when no registry is\n * configured**, {@link PROVIDER_MODEL_TIERS} on the direct provider API.\n *\n * `\"default\"` and an absent tier **inherit `sessionModel` first**. The session\n * model is the one id known to work for this deployment — it already carries\n * whatever provider, lineup and gateway translation the host configured — so\n * preferring any table over it would silently downgrade a configured model\n * and, on a gateway transport, substitute an id that provider cannot serve.\n *\n * `\"small\"` and `\"deep\"` never fall back to `sessionModel`; when nothing above\n * resolves them they throw {@link ModelTierResolutionError}. Inheriting there\n * would run an arbitrary model behind an author's explicit request for a cheap\n * or a strong one — a cost or quality surprise that shows up only in the bill\n * or the output. Failing names it at the node instead.\n *\n * Pure: no I/O, no environment reads.\n */\nexport function resolveModelTier(\n tier: \"small\" | \"default\" | \"deep\" | undefined,\n sessionModel: string | undefined,\n options: ResolveModelTierOptions = {},\n): string | undefined {\n // Built-in ids address the provider's own API; a gateway renames them. And a\n // registry answers the question properly, so the table is its fallback only.\n const directApi = !options.cloud || options.cloud === \"default\";\n const builtIn =\n !options.registry && directApi && options.provider\n ? PROVIDER_MODEL_TIERS[options.provider]\n : undefined;\n if (tier === \"small\" || tier === \"deep\") {\n const resolved =\n options.overrides?.[tier] ?? resolveTierThroughRegistry(tier, options) ?? builtIn?.[tier];\n if (!resolved) throw new ModelTierResolutionError(tier, options.provider);\n return resolved;\n }\n return (\n options.overrides?.default ??\n sessionModel ??\n resolveTierThroughRegistry(\"default\", options) ??\n builtIn?.default\n );\n}\n"]}
@@ -791,5 +791,5 @@ async function listModelsForDriver(driverId, registry, options) {
791
791
  }
792
792
 
793
793
  export { AI_PROVIDER_PRESETS, AgentDriver, BUILTIN_DRIVER_CATALOG, DRIVER_CATALOG, PROVIDER_CREDENTIAL_ENV_PREFIX, PROVIDER_CREDENTIAL_ENV_SUFFIX, buildCredentialHeaders, catalogLayer, conventionalCredentialEnvName, createDriver, entryCredentialEnv, entryCredentialValue, expandPreset, getBridgeLogger, getProviderPreset, listDrivers, listModelsForDriver, listProviderPresets, presetBaseUrl, probeProviderEntry, providerCredentialEnvName, registerBuiltinDrivers, registryCredentialEnv, registryDriverConfig, resolveEntryCredential, resolvePresetBaseUrl, resolveProbeUrl, toMergedRegistry };
794
- //# sourceMappingURL=chunk-7J3FBC6T.js.map
795
- //# sourceMappingURL=chunk-7J3FBC6T.js.map
794
+ //# sourceMappingURL=chunk-SPNVXXUN.js.map
795
+ //# sourceMappingURL=chunk-SPNVXXUN.js.map