@w6w/embed 0.2.28 → 0.2.30

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 (48) hide show
  1. package/dist/{ConfirmModal-Pv2-A_3U.js → ConfirmModal-WqBfWftD.js} +100 -83
  2. package/dist/{ConfirmModal-Pv2-A_3U.js.map → ConfirmModal-WqBfWftD.js.map} +1 -1
  3. package/dist/{CreateFunctionModal-B3LpcuI9.js → CreateFunctionModal-CCYi9deY.js} +2 -2
  4. package/dist/{CreateFunctionModal-B3LpcuI9.js.map → CreateFunctionModal-CCYi9deY.js.map} +1 -1
  5. package/dist/{DocumentFormModal-DieWYFi4.js → DocumentFormModal-B3VudaLb.js} +3 -3
  6. package/dist/{DocumentFormModal-DieWYFi4.js.map → DocumentFormModal-B3VudaLb.js.map} +1 -1
  7. package/dist/{ImportSpecModal-xwTzj4KB.js → ImportSpecModal-C-B8Jwxk.js} +3 -3
  8. package/dist/{ImportSpecModal-xwTzj4KB.js.map → ImportSpecModal-C-B8Jwxk.js.map} +1 -1
  9. package/dist/{ModelRoutesManager-DtByS4mE.js → ModelRoutesManager-DqeY1mdP.js} +110 -106
  10. package/dist/ModelRoutesManager-DqeY1mdP.js.map +1 -0
  11. package/dist/WorkflowEditor-8NAcpjO_.js +1140 -0
  12. package/dist/WorkflowEditor-8NAcpjO_.js.map +1 -0
  13. package/dist/chrome/CallFromCodeButton.d.ts +12 -0
  14. package/dist/chrome/index.d.ts +1 -1
  15. package/dist/{editor-tools-CVYTsVFN.js → editor-tools-BIAW-wzt.js} +53 -53
  16. package/dist/{editor-tools-CVYTsVFN.js.map → editor-tools-BIAW-wzt.js.map} +1 -1
  17. package/dist/editor.mjs +1 -1
  18. package/dist/editors.mjs +51 -52
  19. package/dist/editors.mjs.map +1 -1
  20. package/dist/forms.mjs +321 -297
  21. package/dist/forms.mjs.map +1 -1
  22. package/dist/lib/recent-activity.d.ts +2 -2
  23. package/dist/lib/workflow-version.d.ts +19 -2
  24. package/dist/lists/AiKeyCreate.d.ts +20 -0
  25. package/dist/lists/CallableKindList.d.ts +17 -1
  26. package/dist/lists/CallableRowParts.d.ts +33 -0
  27. package/dist/lists/CredentialCreate.d.ts +17 -17
  28. package/dist/lists/CredentialFields.d.ts +18 -0
  29. package/dist/lists/CredentialList.d.ts +35 -3
  30. package/dist/lists.d.ts +2 -0
  31. package/dist/lists.mjs +2038 -1517
  32. package/dist/lists.mjs.map +1 -1
  33. package/dist/rail.mjs +1 -1
  34. package/dist/repos/connections.d.ts +1 -0
  35. package/dist/repos.mjs +59 -59
  36. package/dist/spec-export-BtnoV0ex.js +33 -0
  37. package/dist/spec-export-BtnoV0ex.js.map +1 -0
  38. package/dist/spec-import-FygyV8sy.js +272 -0
  39. package/dist/spec-import-FygyV8sy.js.map +1 -0
  40. package/package.json +5 -5
  41. package/src/styles.css +56 -0
  42. package/dist/ModelRoutesManager-DtByS4mE.js.map +0 -1
  43. package/dist/WorkflowEditor-CvWkVmFn.js +0 -1117
  44. package/dist/WorkflowEditor-CvWkVmFn.js.map +0 -1
  45. package/dist/spec-export-DMMET5VM.js +0 -189
  46. package/dist/spec-export-DMMET5VM.js.map +0 -1
  47. package/dist/spec-import-0B6oUewa.js +0 -116
  48. package/dist/spec-import-0B6oUewa.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-import-FygyV8sy.js","sources":["../src/repos/versions.ts","../src/repos/documents.ts","../src/repos/spec-import.ts"],"sourcesContent":["/**\n * The `/<collection>/:id/{publish,versions,enable,disable}` repo (T3.1.1) — the Settings rail's\n * read-only version-history browser plus Publish and Enable/Disable. A NEW file, mirroring\n * `src/repos/spec-export.ts` in full: kept out of `repos/functions.ts` / `repos/workflows.ts` /\n * `repos/endpoints.ts` so this node never collides with any of them on the same file, exactly the\n * reason `spec-export.ts`'s own docblock gives for the sibling `/spec` route.\n *\n * **Workflow and Function arms go through the public `@w6w/sdk` methods** (`listVersions`,\n * `getVersion`, `publish`, `revert`, `enable`, `disable`, and `workflows.runVersion`), never\n * `apiClient.console.*`. Each hook dispatches with an explicit per-kind `switch` over LITERAL\n * receivers (`apiClient.workflows.publish(id)`, `apiClient.functions.publish(id)`) and no `default:`\n * — the same reasoning `COLLECTION_PATH` and `useRevertMutation` give against derived dispatch.\n *\n * **Two arms deliberately stay on `W6WClient.request<T>()`:** the ENDPOINT arm of every hook\n * (R-5: endpoint versions have no SDK method — intentionally excluded from the public surface),\n * and the FUNCTION arm of {@link useInvokeVersionMutation} (F-P4: `VersionHistoryModal` renders the\n * raw invocation frame, but `functions.runVersion` unwraps the output like `functions.run`, so the\n * SDK method would drop the frame; follow-up F-6).\n *\n * Every query below is gated on the CALLER'S OWN `enabled` flag, ANDed with `kind !== null` and\n * `id !== \"\"` — never on mount alone (`packages/studio/.ai/PLANNER.md` fact 11): a hook that fires\n * unconditionally against an unresolved `null`/`\"\"` argument 404s once and, because `main.tsx`\n * sets `retry: false` and an unchanged query key never re-fetches, never self-corrects. Opening\n * the Settings panel must issue ZERO `/versions` requests; only opening its History section (or\n * `WorkflowsPage.tsx`'s own editor, a separate call site with its own gate) flips `enabled`.\n *\n * T5.3.1 (project.md Phase 2, Amendments #5/#6): a version can now be reverted to and invoked\n * directly, superseding the earlier \"read-only history, restore out of scope\" pin. `useRevertMutation`\n * overwrites the LIVE resource's `definition` with the archived version's content — never its\n * `key`/address (HITL-4's pinned default) — and does post a `definition` back, by design.\n * `useInvokeVersionMutation` runs that ARCHIVED version's own definition, not the live one, which is\n * exactly why it exists as a separate call from the live invoke/run routes `functions.ts`/\n * `endpoints.ts`/`workflows.ts` already expose.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { callableKey } from \"../lib/callable-kind.ts\";\nimport { historyKeys } from \"../lib/history-query.ts\";\nimport { invalidateSavedCallable } from \"../lib/save-invalidation.ts\";\nimport { workflowKey } from \"./workflows.ts\";\n\n/** The Endpoint / Function single-resource keys the revert arm invalidates: the same\n * `callableKey(\"<kind>\", id)` Studio's `repos/endpoints.ts` / `repos/functions.ts` export as\n * `endpointKey` / `functionKey` (byte-identical `[\"endpoint\", id]` / `[\"function\", id]`). */\nconst endpointKey = (id: string) => callableKey(\"endpoint\", id);\nconst functionKey = (id: string) => callableKey(\"function\", id);\n\n/** The three kinds the wire contract's version-history routes exist for — `connection` has none\n * (see `hasVersionHistory`, `../lib/rail-settings.ts`). */\nexport type VersionsKind = \"function\" | \"workflow\" | \"endpoint\";\n\n/** `<coll>` — the wire contract's own path segment for each kind, every one of the three arms\n * named explicitly (never derived by string pluralization), mirroring `specCollectionForKind`'s\n * own reasoning (`../lib/rail-settings.ts:69`): a typo'd suffix rule would silently send one\n * kind's requests at another kind's collection. */\nconst COLLECTION_PATH: Record<VersionsKind, \"functions\" | \"workflows\" | \"endpoints\"> = {\n function: \"functions\",\n workflow: \"workflows\",\n endpoint: \"endpoints\",\n};\n\n/** One row of `GET /<coll>/:id/versions`'s `versions` array — newest first, per the wire contract. */\nexport interface VersionSummary {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n}\n\n/** `GET /<coll>/:id/versions`'s full 200 body. */\nexport interface VersionsEnvelope {\n enabled: boolean;\n currentPublishedVersion: number | null;\n versions: VersionSummary[];\n}\n\n/** `GET /<coll>/:id/versions/:n`'s `version` field — `definition` is the redacted stored\n * definition for THIS query; {@link useRevertMutation} is what posts a version's definition\n * back onto the live resource, and {@link useInvokeVersionMutation} is what runs it. */\nexport interface VersionDetail {\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n isCurrentPublished: boolean;\n definition: Record<string, unknown>;\n}\n\n/** `POST /<coll>/:id/publish`'s 200 body. */\nexport interface PublishResult {\n version: {\n kind: string;\n callableId: string;\n versionNumber: number;\n createdAt: string;\n createdBy: string | null;\n };\n currentPublishedVersion: number;\n}\n\n/** `POST /<coll>/:id/versions/:n/revert`'s 200 body. */\nexport interface RevertResult {\n reverted: {\n kind: string;\n callableId: string;\n versionNumber: number;\n };\n}\n\n/** `<coll>` per kind ends its live invoke/run route in `/invoke` (Function, Endpoint) or `/run`\n * (Workflow, matching that kind's existing unversioned route) — every arm named explicitly\n * (never derived by suffix rule), mirroring `COLLECTION_PATH`'s own reasoning above: a derived\n * rule would silently send one kind's requests at the wrong verb. */\nconst VERSION_INVOKE_VERB: Record<VersionsKind, \"invoke\" | \"run\"> = {\n function: \"invoke\",\n endpoint: \"invoke\",\n workflow: \"run\",\n};\n\nexport function versionsKey(kind: VersionsKind | null, id: string) {\n return [\"versions\", kind, id] as const;\n}\n\nexport function versionKey(kind: VersionsKind | null, id: string, versionNumber: number | null) {\n return [\"version\", kind, id, versionNumber] as const;\n}\n\n/**\n * `GET /<collection>/:id/versions`. Never fires on mount — `enabled` is the caller's own flag\n * (the Settings panel's History-open state, or `WorkflowsPage.tsx`'s own editor-open gate), ANDed\n * with `kind !== null` and `id !== \"\"`, exactly `useSpecQuery`'s shape (`spec-export.ts:45-57`).\n */\nexport function useVersionsQuery(kind: VersionsKind | null, id: string, enabled: boolean) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionsKey(kind, id),\n queryFn: async (): Promise<VersionsEnvelope> => {\n switch (kind as VersionsKind) {\n case \"workflow\":\n return await apiClient.workflows.listVersions(id);\n case \"function\":\n return await apiClient.functions.listVersions(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<VersionsEnvelope>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions`,\n });\n return res.body;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\",\n });\n}\n\n/**\n * `GET /<collection>/:id/versions/:n`. Same gating shape as {@link useVersionsQuery}, plus\n * `versionNumber !== null` — the modal opens this only once a row has been clicked.\n */\nexport function useVersionQuery(\n kind: VersionsKind | null,\n id: string,\n versionNumber: number | null,\n enabled: boolean,\n) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: versionKey(kind, id, versionNumber),\n queryFn: async (): Promise<VersionDetail> => {\n // The SDK's `getVersion` already unwraps the `{ version }` envelope.\n const n = versionNumber as number;\n switch (kind as VersionsKind) {\n case \"workflow\":\n return (await apiClient.workflows.getVersion(id, n)) as VersionDetail;\n case \"function\":\n return (await apiClient.functions.getVersion(id, n)) as VersionDetail;\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ version: VersionDetail }>({\n method: \"GET\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/versions/${String(n)}`,\n });\n return res.body.version;\n }\n }\n },\n enabled: enabled && kind !== null && id !== \"\" && versionNumber !== null,\n });\n}\n\n/**\n * `POST /<collection>/:id/publish`. `kind` is fixed per hook instance — the caller already knows\n * which kind it is publishing (the rail's `ctx.kind`, or `WorkflowsPage.tsx`'s hardcoded\n * `\"workflow\"`) — and `mutate(id)` supplies the resource. `onSuccess` invalidates the SAME\n * `[\"versions\", kind, id]` key {@link useVersionsQuery} reads, so the panel's published pointer\n * and version list are fresh without a reload (A3), mirroring `useSaveFunctionMutation`'s\n * `onSuccess` shape (`./functions.ts`).\n */\nexport function usePublishMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string): Promise<PublishResult> => {\n switch (kind) {\n case \"workflow\":\n return await apiClient.workflows.publish(id);\n case \"function\":\n return await apiClient.functions.publish(id);\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<PublishResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${id}/publish`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, id) => {\n return qc.invalidateQueries({ queryKey: versionsKey(kind, id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/{enable,disable}`. One mutation for both — the wire contract is two\n * routes distinguished only by which one is called, so `vars.enabled` picks the path segment\n * rather than this module carrying two near-identical mutations. `onSuccess` invalidates the same\n * key {@link usePublishMutation} does, for the same reason.\n */\nexport function useSetEnabledMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; enabled: boolean }): Promise<{ enabled: boolean }> => {\n // The SDK's `enable`/`disable` return void; the hook's result stays `{ enabled }`.\n switch (kind) {\n case \"workflow\":\n if (vars.enabled) await apiClient.workflows.enable(vars.id);\n else await apiClient.workflows.disable(vars.id);\n return { enabled: vars.enabled };\n case \"function\":\n if (vars.enabled) await apiClient.functions.enable(vars.id);\n else await apiClient.functions.disable(vars.id);\n return { enabled: vars.enabled };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<{ enabled: boolean }>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/${vars.enabled ? \"enable\" : \"disable\"}`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n qc.invalidateQueries({ queryKey: versionsKey(kind, vars.id) });\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/revert`, no body — overwrites the LIVE resource's\n * `definition` with the archived version's content, preserving its `key`/address (HITL-4's\n * pinned default; see the module docblock). This is the first mutation in this family that\n * changes `definition` rather than merely appending to or flipping a flag on the version history\n * (`usePublishMutation`/`useSetEnabledMutation` above do neither), so `onSuccess` invalidates\n * BOTH `versionsKey(kind, id)` (the same key those two invalidate) AND the kind's own\n * definition-edit key — via the shared `invalidateSavedCallable` helper\n * `useSaveFunctionMutation`/`useSaveEndpointMutation` already route through\n * (`../lib/save-invalidation.ts`) — or the page a user reverted FROM keeps showing the\n * pre-revert draft until a manual reload. The definition key is picked by a `switch` naming all\n * three arms explicitly, with no `default:` — the same reasoning `COLLECTION_PATH`'s own docblock\n * gives: a derived rule would silently send one kind at another kind's key.\n */\nexport function useRevertMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; versionNumber: number }): Promise<RevertResult> => {\n // The SDK's `revert` unwraps `{ reverted }`; the hook re-wraps it to keep its result shape.\n switch (kind) {\n case \"workflow\":\n return { reverted: await apiClient.workflows.revert(vars.id, vars.versionNumber) };\n case \"function\":\n return { reverted: await apiClient.functions.revert(vars.id, vars.versionNumber) };\n case \"endpoint\": {\n // R-5: no SDK method for endpoint versions.\n const res = await apiClient.request<RevertResult>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH.endpoint}/${vars.id}/versions/${String(vars.versionNumber)}/revert`,\n });\n return res.body;\n }\n }\n },\n onSuccess: (_result, vars) => {\n let definitionKey: readonly unknown[];\n switch (kind) {\n case \"function\":\n definitionKey = functionKey(vars.id);\n break;\n case \"workflow\":\n definitionKey = workflowKey(vars.id);\n break;\n case \"endpoint\":\n definitionKey = endpointKey(vars.id);\n break;\n }\n invalidateSavedCallable(qc, versionsKey(kind, vars.id), definitionKey);\n },\n });\n}\n\n/**\n * `POST /<collection>/:id/versions/:n/{invoke,run}`, an EMPTY JSON body — identical to that\n * kind's unversioned invoke/run route's success body, except the requested version's OWN\n * `impl`/definition runs instead of the live one (T5.3.1's wire contract table). Unlike\n * {@link useRevertMutation}, invoking changes no resource state, so it invalidates History ONLY\n * (`onSettled`, `historyKeys.root` — a version run is a run, failed ones included, like every other\n * run path) and no resource query — the caller (`VersionHistoryModal`) renders the mutation's own `data`/`error` state\n * directly, and that state is naturally cleared whenever the modal remounts for a different\n * version (`SettingsTool.tsx`'s `openVersion` gate fully unmounts/remounts it, never leaves it\n * mounted across a prop change).\n */\nexport function useInvokeVersionMutation(kind: VersionsKind) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n versionNumber: number;\n }): Promise<Record<string, unknown>> => {\n // The workflow arm moves to `workflows.runVersion`. The FUNCTION arm (F-P4 / F-6) and the\n // ENDPOINT arm (R-5) stay on `request()`: this hook's caller renders the raw invocation\n // frame, and `functions.runVersion` unwraps the output like `functions.run` — it would drop\n // the frame. The workflow arm returns only `{ runId, status }`, as the raw body did.\n if (kind === \"workflow\") {\n const run = await apiClient.workflows.runVersion(vars.id, vars.versionNumber, {});\n // Project back to the server's own run-start body: the SDK adds `steps`/`terminal`/\n // `httpStatus`, and `VersionHistoryModal` prints this value verbatim as JSON.\n return { runId: run.runId, status: run.status };\n }\n const res = await apiClient.request<Record<string, unknown>>({\n method: \"POST\",\n path: path`/${COLLECTION_PATH[kind]}/${vars.id}/versions/${String(vars.versionNumber)}/${VERSION_INVOKE_VERB[kind]}`,\n body: {},\n });\n return res.body;\n },\n onSettled: () => qc.invalidateQueries({ queryKey: historyKeys.root }),\n });\n}\n","/**\n * The `documents` domain repo — wraps `@w6w/sdk`'s `client.documents.*` in\n * react-query (HITL-6). `QueryClientProvider` (`main.tsx`) stays the actual\n * cache; this module only centralizes the query-key factory and the\n * `queryFn`/`mutationFn` pairs so every page reads documents the same way.\n *\n * Documents are project-scoped (`documents.ts`'s `DocumentOptions.project`);\n * every mutation here invalidates the unscoped `[\"documents\"]` key, which\n * prefix-matches every project-scoped query key produced by\n * {@linkcode documentsKey} — the same invalidation shape `DocumentsPage.tsx`\n * used before this migration.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { path, type Doc, type DocumentCreateInput, type DocumentPatch } from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\n/**\n * T1.1.1's wire shape for one document, pinned here ahead of that node\n * merging (this node is dispatched speculatively against it — see this\n * task's contract). `shared` and the six `source*`/`syncedAt` fields are all\n * additive over the SDK's own `Doc`, so a locally-created document simply\n * carries them as `null` (or `false` for `shared`) rather than omitting\n * them. Do not rename a field — the server produces these names verbatim.\n */\nexport interface DocWithProvenance extends Doc {\n shared: boolean;\n /** \"owner/name\" of the bound repository this document was pulled from. */\n sourceRepo: string | null;\n /** Repo-relative file path the document was pulled from. */\n sourcePath: string | null;\n /** The pulled file's content hash — NOT a commit SHA. */\n sourceSha: string | null;\n /** The repository's HEAD commit SHA at pull time — NOT a content hash. */\n sourceRefSha: string | null;\n /** Web link to the file; may be absent even when the rest of provenance is set. */\n sourceUrl: string | null;\n /** ISO-8601. Stamped at the document's last actual change, not at every sync. */\n syncedAt: string | null;\n}\n\n/**\n * Which provenance state `DocumentDetailPage.tsx`'s \"Source\" card should\n * render for `doc`. `shared` (not `sourceRepo`) is the gate: a shared\n * document whose provenance columns haven't been stamped yet (any document\n * synced before this feature shipped, until its next real-content sync —\n * tier-1 \"unchanged\" syncs never restamp provenance) is still shared, and\n * must say so, distinct from a genuinely private document.\n *\n * - `\"private\"` — `doc.shared` is false. No card.\n * - `\"pending\"` — shared, but `sourceRepo` hasn't been stamped yet.\n * - `\"synced\"` — shared, with full provenance available.\n */\nexport function documentProvenanceState(doc: DocWithProvenance): \"private\" | \"pending\" | \"synced\" {\n if (!doc.shared) return \"private\";\n return doc.sourceRepo == null ? \"pending\" : \"synced\";\n}\n\n/** Query key for a documents list, optionally scoped to a project. */\nexport function documentsKey(projectId?: string) {\n return [\"documents\", projectId] as const;\n}\n\n/**\n * Query key for a single document, scoped to a project (mirrors\n * {@linkcode useDocumentsQuery}'s fix at :72-79/:80-87 below — `projectId`\n * belongs in the key itself, not just the `queryFn`, so a render where the\n * key was cached under `projectId === undefined` genuinely changes key once\n * `ProjectContext` resolves the real one, instead of reusing the same cache\n * entry — and its `retry: false` wrong-project 404 — forever). Still sits\n * under the bare `[\"documents\"]` prefix every mutation below invalidates, so\n * an edit/delete refreshes this page too — `\"detail\"` keeps it from\n * colliding with {@linkcode documentsKey}'s own `[\"documents\", projectId]`\n * shape.\n */\nexport function documentKey(id: string, projectId?: string) {\n return [\"documents\", \"detail\", id, projectId] as const;\n}\n\n/**\n * A single document by id, cast to {@link DocWithProvenance} (D-5): the SDK's\n * `Doc` doesn't model T1.1.1's provenance fields yet, and this repo is not\n * the place to fork or extend `@w6w/sdk` (D-4). The `project` option is\n * passed exactly as {@linkcode useDocumentsQuery} passes it — a document in a\n * non-default project 404s without it. `enabled` defaults `true` to preserve\n * that unscoped fallback for a caller that genuinely wants it — same as\n * {@linkcode useDocumentsQuery}'s own `enabled` doc comment below — a\n * project-scoped page should instead pass `enabled: projectId != null` so it\n * never queries (and never renders) against the wrong project while\n * `ProjectContext`'s own project list is still resolving.\n */\nexport function useDocumentQuery(id: string, projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentKey(id, projectId),\n queryFn: async () =>\n (await apiClient.documents.get(id, { project: projectId })) as DocWithProvenance,\n enabled,\n });\n}\n\n/**\n * The current project's documents (or the tenant default when unscoped).\n * `enabled` defaults `true` to preserve that unscoped fallback for a caller\n * that genuinely wants it — a project-scoped page should instead pass\n * `enabled: projectId != null` so it never queries (and never renders)\n * against the wrong project while `ProjectContext`'s own project list is\n * still resolving.\n */\nexport function useDocumentsQuery(projectId?: string, enabled = true) {\n const apiClient = useEmbedClient();\n return useQuery({\n queryKey: documentsKey(projectId),\n // Cast to DocWithProvenance[], same as useDocumentQuery above: the wire\n // response already carries `shared`/`source*`/`syncedAt` (repo.list()\n // serializes every document the same way repo.get() does), but the SDK's\n // own `Doc` type doesn't declare them yet (D-5). Without this cast,\n // DocumentsPage.tsx's list rows have no type-visible way to branch on\n // `d.shared` the way DocumentDetailPage.tsx already does.\n queryFn: async () =>\n (await apiClient.documents.list({ project: projectId })) as DocWithProvenance[],\n enabled,\n });\n}\n\nexport function useCreateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { input: DocumentCreateInput; project?: string }) =>\n apiClient.documents.create(vars.input, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useUpdateDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; patch: DocumentPatch; project?: string }) =>\n apiClient.documents.update(vars.id, vars.patch, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\nexport function useDeleteDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.documents.delete(vars.id, { project: vars.project }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n\n/**\n * Re-pulls a shared document from its bound repository (\"Sync\" button, T2.1.4)\n * — `POST /documents/:id/sync` (T3.1.1). No SDK method exists for this route\n * yet (D-4/D-5), so this goes through `apiClient.request()` directly, same\n * escape hatch `repo-sync.ts`'s `useSyncRepoNowMutation` uses. The document\n * routes are project-scoped by QUERY param, not a path segment (unlike\n * `repo-binding`'s `/projects/:id/...` shape), so `project` travels in\n * `query`, mirroring {@linkcode useDocumentQuery}'s own `{ project: … }` use.\n */\nexport function useSyncDocumentMutation() {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (vars: { id: string; project?: string }) =>\n apiClient.request<{ document: DocWithProvenance }>({\n method: \"POST\",\n path: path`/documents/${vars.id}/sync`,\n query: { project: vars.project },\n }),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"documents\"] }),\n });\n}\n","/**\n * The `/spec/import` repo (T3.2.1). A NEW file, deliberately kept out of\n * `repos/functions.ts` / `repos/endpoints.ts` (T3.1.1 owns both) so the two\n * nodes never collide on the same file.\n *\n * **Every operation here goes through `W6WClient.request<T>()`, never\n * `apiClient.console.*`.** `T2.1.2`'s `inputs.touch` has no\n * `packages/wrappers` entry — there is no SDK method for this route — so\n * `request()` is the client's public escape hatch, exactly as\n * `repos/vars.ts`'s own docblock explains for the same reason.\n *\n * The posted `document` is forwarded to the server as-is (spread, never edited):\n * this module adds only `project` (and, on import, `selections`) beside it, validates nothing, and — this is the mechanism pin note 1\n * of the contract states from the side a wrong implementation must break —\n * never falls back to the sibling whole-definition save mutation\n * `FunctionIdentityModal.tsx` uses, on any response. `/spec/import` is where\n * the server-side sealed-secret walker lives (T2.1.2 §B runs\n * `assertNoSecretEnvelopes` over the WHOLE supplied body before any write);\n * a \"helpful\" fallback to that other write path would route a pasted\n * document straight around that check.\n *\n * T1.2.1 generalizes this over all three kinds: `onSuccess` invalidates the\n * ONE list key the imported document's own kind reads (`result.kind`, which\n * the server always echoes), never an unconditional `functionsKey`. The\n * decision of which key that is lives in `../lib/spec-import-invalidation.ts`\n * (a pure, `node --test`-loadable module). The three list keys are INJECTED by the host\n * (`listKeys`): Studio's `functionsKey`/`endpointsKey` live in its own `repos/callables`.\n */\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport type { PreviewDependency, Selection, SpecDependency } from \"../lib/import-bindings.ts\";\nimport {\n type SpecImportListKeys,\n invalidateImportedCallable,\n} from \"../lib/spec-import-invalidation.ts\";\n\n/**\n * Mirrors `T2.1.1`'s `SpecDocument` (`T2.1.1.contract.md:134-141`): the\n * portable document a `GET /<kind>/:id/spec` export produces and this\n * route consumes. Not a bare `FunctionDef` — connection/var references ride\n * as re-bindable `rebind` entries, never live ids.\n */\nexport interface SpecImportDocument {\n specVersion: string;\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: Record<string, unknown>;\n rebind: unknown[];\n}\n\n/** One reference site's outcome (T2.1.2 §E's `SpecImportReferenceReport`). */\nexport interface SpecImportReferenceReport {\n path: string;\n kind: string;\n resolved: boolean;\n /** Present only when `resolved` is `true`. */\n boundTo?: string;\n /** Present only when `resolved` is `false`. */\n reason?: string;\n}\n\n/** The `201` body `POST /spec/import` returns (T2.1.2 §E). */\nexport interface SpecImportResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n callable: { id: string; key?: string; name?: string };\n references: SpecImportReferenceReport[];\n dependencies?: ImportDependencyStatus[];\n}\n\n/** IF-1 `POST /spec/preview` result: one entry per dependency, with server options + suggestion. */\nexport interface PreviewResult {\n kind: \"function\" | \"endpoint\" | \"workflow\";\n dependencies: PreviewDependency[];\n references?: SpecImportReferenceReport[];\n}\n\n/** One dependency's outcome in the import result (IF-1 `dependencies` status[]). */\nexport interface ImportDependencyStatus {\n key: string;\n kind?: SpecDependency[\"kind\"];\n name?: string;\n status: \"bound\" | \"created\" | \"unconfigured\" | string;\n boundTo?: string;\n reason?: string;\n}\n\n/** The preview request body: the document plus the host project, sent explicitly. */\nexport function buildPreviewBody(\n document: Record<string, unknown>,\n project: string | undefined,\n): Record<string, unknown> {\n return { ...document, project };\n}\n\n/** The import request body: the preview body plus the FULL selections map (`unconfigured` included). */\nexport function buildImportBody(\n document: Record<string, unknown>,\n project: string | undefined,\n selections: Record<string, Selection>,\n): Record<string, unknown> {\n return { ...buildPreviewBody(document, project), selections };\n}\n\n/**\n * `POST /spec/preview` (IF-1). Read-only on the server; a failure rejects the mutation and the\n * caller blocks Create — there is NO fallback to posting the document verbatim to `/spec/import`.\n */\nexport function useSpecPreviewMutation(project: string | undefined) {\n const apiClient = useEmbedClient();\n return useMutation({\n mutationFn: async (document: Record<string, unknown>) => {\n const res = await apiClient.request<PreviewResult>({\n method: \"POST\",\n path: \"/spec/preview\",\n body: buildPreviewBody(document, project),\n });\n return res.body;\n },\n });\n}\n\n/**\n * `POST /spec/import`. Success is always `201` — including a partially\n * resolved import (T2.1.2 §E: \"report, never fail silently\"). This mutation\n * resolves on ANY `201`; branching on `references.every(r => r.resolved)` is\n * the caller's job (A5), never this repo's.\n *\n * `project` is the caller's current project — only the workflow arm reads it\n * (`listKeys.workflowsKey(project)`), but every caller passes it uniformly rather than branching on kind itself; see\n * `../lib/spec-import-invalidation.ts` for why the key differs by kind.\n */\nexport function useImportSpecMutation(project: string | undefined, listKeys: SpecImportListKeys) {\n const apiClient = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: {\n document: Record<string, unknown>;\n selections: Record<string, Selection>;\n }) => {\n const res = await apiClient.request<SpecImportResult>({\n method: \"POST\",\n path: \"/spec/import\",\n body: buildImportBody(input.document, project, input.selections),\n });\n return res.body;\n },\n // A row exists in every `201` outcome (T2.1.2 §E creates it even when\n // some references stayed unresolved), so the list is stale either way —\n // but ONLY the list the imported kind actually belongs to (AC-3): the\n // unconditional `functionsKey` this used to invalidate left an imported\n // Endpoint or Workflow's own list stale while pointlessly invalidating\n // Functions.\n onSuccess: (result) => invalidateImportedCallable(qc, result.kind, listKeys, project),\n });\n}\n"],"names":["endpointKey","id","callableKey","functionKey","COLLECTION_PATH","VERSION_INVOKE_VERB","versionsKey","kind","versionKey","versionNumber","useVersionsQuery","enabled","apiClient","useEmbedClient","useQuery","path","useVersionQuery","n","usePublishMutation","qc","useQueryClient","useMutation","_result","useSetEnabledMutation","vars","useRevertMutation","definitionKey","workflowKey","invalidateSavedCallable","useInvokeVersionMutation","run","historyKeys","documentProvenanceState","doc","documentsKey","projectId","documentKey","useDocumentQuery","useDocumentsQuery","useCreateDocumentMutation","useUpdateDocumentMutation","useDeleteDocumentMutation","useSyncDocumentMutation","buildPreviewBody","document","project","buildImportBody","selections","useSpecPreviewMutation","useImportSpecMutation","listKeys","input","result","invalidateImportedCallable"],"mappings":";;;;;;AA6CA,MAAMA,IAAc,CAACC,MAAeC,EAAY,YAAYD,CAAE,GACxDE,IAAc,CAACF,MAAeC,EAAY,YAAYD,CAAE,GAUxDG,IAAiF;AAAA,EACrF,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,GAqDMC,IAA8D;AAAA,EAClE,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAEO,SAASC,EAAYC,GAA2BN,GAAY;AACjE,SAAO,CAAC,YAAYM,GAAMN,CAAE;AAC9B;AAEO,SAASO,EAAWD,GAA2BN,GAAYQ,GAA8B;AAC9F,SAAO,CAAC,WAAWF,GAAMN,GAAIQ,CAAa;AAC5C;AAOO,SAASC,EAAiBH,GAA2BN,GAAYU,GAAkB;AACxF,QAAMC,IAAYC,EAAA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,GAAUC,CAAO,GAAG,YAAAE,EAAA;AACnD;AAMO,SAASC,EAAuBH,GAA6B;AAClE,QAAMjC,IAAYC,EAAA;AAClB,SAAOQ,EAAY;AAAA,IACjB,YAAY,OAAOuB,OACL,MAAMhC,EAAU,QAAuB;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAM+B,EAAiBC,GAAUC,CAAO;AAAA,IAAA,CACzC,GACU;AAAA,EACb,CACD;AACH;AAYO,SAASI,EAAsBJ,GAA6BK,GAA8B;AAC/F,QAAMtC,IAAYC,EAAA,GACZM,IAAKC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,OAAO8B,OAIL,MAAMvC,EAAU,QAA0B;AAAA,MACpD,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAMkC,EAAgBK,EAAM,UAAUN,GAASM,EAAM,UAAU;AAAA,IAAA,CAChE,GACU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQb,WAAW,CAACC,MAAWC,EAA2BlC,GAAIiC,EAAO,MAAMF,GAAUL,CAAO;AAAA,EAAA,CACrF;AACH;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w6w/embed",
3
- "version": "0.2.28",
3
+ "version": "0.2.30",
4
4
  "description": "Embed w6w's managed editor and providers in a host React app.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "repository": {
@@ -73,10 +73,10 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@tanstack/react-query": "^5.62.7",
76
- "@w6w/react": "^0.10.0",
77
- "@w6w/sdk": "^0.10.0",
78
- "@w6w/expr": "^0.1.4",
79
- "@w6w/ui": "^0.2.64",
76
+ "@w6w/react": "^0.12.1",
77
+ "@w6w/sdk": "^0.12.1",
78
+ "@w6w/expr": "^0.1.5",
79
+ "@w6w/ui": "^0.2.66",
80
80
  "yaml": "^2.4.2"
81
81
  },
82
82
  "peerDependencies": {
package/src/styles.css CHANGED
@@ -1064,6 +1064,62 @@
1064
1064
  background: var(--panel-2);
1065
1065
  }
1066
1066
 
1067
+ /* CredentialList: one row per credential, the apps that use it beside it. */
1068
+ .w6w-embed-root .w6w-embed-cred-open {
1069
+ background: transparent;
1070
+ border: 0;
1071
+ color: inherit;
1072
+ cursor: pointer;
1073
+ display: flex;
1074
+ flex-direction: column;
1075
+ font: inherit;
1076
+ gap: 2px;
1077
+ padding: 0;
1078
+ text-align: left;
1079
+ }
1080
+
1081
+ .w6w-embed-root .w6w-embed-cred-title {
1082
+ align-items: center;
1083
+ display: inline-flex;
1084
+ flex-wrap: wrap;
1085
+ gap: var(--w6w-sp-2);
1086
+ }
1087
+
1088
+ .w6w-embed-root .w6w-embed-cred-uses {
1089
+ align-items: center;
1090
+ display: flex;
1091
+ flex-wrap: wrap;
1092
+ gap: var(--w6w-sp-1) var(--w6w-sp-3);
1093
+ }
1094
+
1095
+ .w6w-embed-root .w6w-embed-cred-app {
1096
+ align-items: center;
1097
+ display: inline-flex;
1098
+ gap: var(--w6w-sp-1);
1099
+ white-space: nowrap;
1100
+ }
1101
+
1102
+ .w6w-embed-root .w6w-embed-cred-default {
1103
+ border-color: var(--accent);
1104
+ color: var(--accent);
1105
+ }
1106
+
1107
+ .w6w-embed-root .w6w-embed-cred-menu {
1108
+ display: flex;
1109
+ justify-content: flex-end;
1110
+ }
1111
+
1112
+ /* CredentialCreate, "One app": the chosen app's icon and name, then "← Apps" at the far end. */
1113
+ .w6w-embed-root .w6w-embed-cred-app-head {
1114
+ align-items: center;
1115
+ display: flex;
1116
+ gap: var(--w6w-sp-2);
1117
+ }
1118
+
1119
+ .w6w-embed-root .w6w-embed-cred-app-head > button {
1120
+ margin-left: auto;
1121
+ }
1122
+
1067
1123
  .w6w-embed-root .w6w-embed-conn-filter {
1068
1124
  margin-bottom: var(--w6w-sp-2);
1069
1125
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelRoutesManager-DtByS4mE.js","sources":["../src/forms/ModelRoutesManager.tsx"],"sourcesContent":["/**\n * `<ModelRoutesManager>` — list, add, edit and delete the project's model routes. A route is the\n * name callers ask for; it resolves to one model reached through one connection, plus optional\n * fallbacks. `broken` marks a route whose connection stopped working, so it stays visible (and\n * editable) instead of silently disappearing from the list.\n *\n * The project comes from `useEditorProject(projectId)`: omitted defers to `<W6WEmbedProvider\n * project>`; `null` or `\"\"` REFUSES — the list query is disabled, no `/model-routes` request is\n * sent and \"Add\" is disabled. Every write names the resolved project, never `undefined`.\n *\n * A route reaches its model one of two ways: through one fixed account connection, or through\n * \"each person's own key\" (`invoking_user`) — the caller's personal key for the provider. The mode\n * control appears only when the deployment allows personal keys (or the route already uses them).\n * An own-key route is checked per caller (`/readiness`); when the caller has no usable key and the\n * host passed `onSetupAiKey`, the row offers a way to add one. A host that reuses ONE\n * `QueryClient` across different people must clear it when the person changes.\n *\n * `initialEditRouteId` (with `initialConnection`) opens that route's editor on mount, prefilled:\n * the connection dependents view's reconnect affordance lands here, naming the replacement\n * connection. Both are read ONCE — remount to reopen the editor.\n */\nimport { ApiError } from \"@w6w/sdk\";\nimport {\n DataTable,\n type DataTableColumn,\n DeleteButton,\n EditButton,\n EmptyState,\n useEnterSubmit,\n} from \"@w6w/ui\";\nimport { type ReactNode, useState } from \"react\";\nimport { ConfirmModal } from \"../chrome/ConfirmModal.tsx\";\nimport { Modal } from \"../chrome/Modal.tsx\";\nimport { useEditorProject } from \"../project-context.ts\";\nimport { useUserScopedCredentialsEnabled } from \"../repos/ai-keys.ts\";\nimport { useConnectionsQuery } from \"../repos/connections.ts\";\nimport {\n type ConnectionChoice,\n type Model,\n type ModelFallback,\n type ModelRoute,\n type ModelRouteCredentialMode,\n connectionChoices,\n routeTarget,\n useAllModelCatalogQuery,\n useCreateModelRouteMutation,\n useDeleteModelRouteMutation,\n useModelProvidersQuery,\n useModelRouteReadinessQuery,\n useModelRoutesQuery,\n useUpdateModelRouteMutation,\n} from \"../repos/models.ts\";\n\n/**\n * Actionable copy for the route write failures the server names by code. `invalid_route_name` is\n * a 400 the NAME field caused, so it states the rule instead of only echoing the server's\n * sentence; any other error falls back to its own message.\n */\nconst COPY: Record<string, string> = {\n invalid_route_name:\n \"That route name is not valid. Use lowercase letters, digits and dashes (e.g. gpt-4o-fast): 3 to 39 characters, starting with a letter, no double dashes, not ending in a dash.\",\n credential_scope_mismatch:\n \"This route mixes account connections with each person's own key. Use one or the other for the whole route, including its fallbacks.\",\n};\n\n/** Fixed copy per readiness issue code; the server's own `message` is never shown. */\nconst READINESS_COPY: Record<string, string> = {\n personal_key_required: \"You have not added a key for this provider yet.\",\n personal_key_unavailable: \"Your key for this provider is disabled or can no longer be used.\",\n user_context_required: \"This route needs a signed-in person; it cannot run on its own.\",\n ai_credential_policy_denied: \"Your account's AI key policy does not allow this kind of key.\",\n};\nconst READINESS_GENERIC = \"This route is not ready for you to use.\";\n\nconst OWN_KEY_COPY = \"Each person uses their own key\";\n\nexport function modelRouteErrorCopy(e: unknown): string {\n if (e instanceof ApiError) {\n if (Object.hasOwn(COPY, e.code)) return COPY[e.code];\n return e.message;\n }\n return e instanceof Error ? e.message : String(e);\n}\n\nexport interface ModelRoutesManagerProps {\n /**\n * The project whose routes are managed. Omitted: the `<W6WEmbedProvider project>`. `null` or\n * `\"\"`: no project — nothing is requested and nothing can be written.\n */\n projectId?: string | null;\n /** Open this route's editor on mount (read once). The dependents view's reconnect passes it. */\n initialEditRouteId?: string;\n /** Prefill the editor's connection — a reconnect names the connection that should replace it. */\n initialConnection?: string;\n /**\n * Host callback to add a personal key for a provider. Embed never imports a router: the host\n * navigates (Studio opens My AI keys). Without it no setup control is shown.\n */\n onSetupAiKey?: (target: { providerAppId?: string; modelId?: string }) => void;\n}\n\n/** Which route the editor has open: `routeId: null` is the create form. */\ninterface EditorState {\n routeId: string | null;\n connection?: string;\n}\n\n/** One-line summary of a route's resolution, safe against long ids. */\nfunction routeSummary(r: ModelRoute): string {\n const fallbacks = r.fallbacks.length;\n const tail = fallbacks === 0 ? \"\" : ` · ${fallbacks} fallback${fallbacks === 1 ? \"\" : \"s\"}`;\n const head =\n r.credentialMode === \"invoking_user\"\n ? `${r.modelId} · ${OWN_KEY_COPY}`\n : `${r.modelId} via ${r.connectionId}`;\n return `${head}${tail}`;\n}\n\n/** Per-caller readiness of one own-key route: code-specific copy, plus the host's setup link. */\nfunction RouteReadiness(props: {\n project: string;\n route: ModelRoute;\n onSetupAiKey?: ModelRoutesManagerProps[\"onSetupAiKey\"];\n}) {\n const { route } = props;\n const q = useModelRouteReadinessQuery(props.project, route.name);\n const r = q.data;\n if (!r) return null;\n const setup = r.setup;\n return (\n <div className=\"muted small\" data-testid={`model-route-readiness-${route.name}`}>\n {r.ready ? (\n \"Ready for you\"\n ) : (\n <>\n {(r.issues.length > 0 ? r.issues : [{ code: \"\" }]).map((i) => (\n <div key={i.code}>\n {Object.hasOwn(READINESS_COPY, i.code) ? READINESS_COPY[i.code] : READINESS_GENERIC}\n </div>\n ))}\n </>\n )}\n {r.ready === false && setup != null && props.onSetupAiKey != null && (\n <button\n type=\"button\"\n className=\"btn ghost\"\n onClick={() =>\n props.onSetupAiKey?.({ providerAppId: setup.providerAppId, modelId: setup.modelId })\n }\n data-testid={`model-route-setup-${route.name}`}\n >\n Add your key\n </button>\n )}\n </div>\n );\n}\n\nexport function ModelRoutesManager(props: ModelRoutesManagerProps): ReactNode {\n const project = useEditorProject(props.projectId);\n const [editor, setEditor] = useState<EditorState | null>(() =>\n props.initialEditRouteId\n ? { routeId: props.initialEditRouteId, connection: props.initialConnection }\n : null,\n );\n const [pending, setPending] = useState<ModelRoute | null>(null);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n\n const routesQuery = useModelRoutesQuery(project ?? undefined);\n const deleteMut = useDeleteModelRouteMutation();\n const routes = routesQuery.data ?? [];\n const canCreate = project != null;\n // The reconnect flow names a route by id; the row itself arrives with the list.\n const editing = editor?.routeId == null ? undefined : routes.find((r) => r.id === editor.routeId);\n const editorReady = editor != null && (editor.routeId == null || editing != null);\n\n const columns: DataTableColumn<ModelRoute>[] = [\n {\n key: \"name\",\n header: \"Route\",\n render: (r) => (\n <div className=\"list-main\" style={{ maxWidth: 0, minWidth: \"100%\" }}>\n <strong className=\"list-name\" title={r.name}>\n {r.name}\n </strong>{\" \"}\n <span className={r.status === \"broken\" ? \"tag warn\" : \"tag\"}>{r.status}</span>\n <div className=\"muted small list-preview\" title={routeSummary(r)}>\n {routeSummary(r)}\n </div>\n {r.credentialMode === \"invoking_user\" && project != null && (\n <RouteReadiness project={project} route={r} onSetupAiKey={props.onSetupAiKey} />\n )}\n </div>\n ),\n },\n {\n key: \"connection\",\n header: \"Connection\",\n render: (r) =>\n r.credentialMode === \"invoking_user\" ? (\n <span>{OWN_KEY_COPY}</span>\n ) : (\n <code>{r.connectionId}</code>\n ),\n },\n {\n key: \"actions\",\n header: \"\",\n align: \"right\",\n link: false,\n actions: true,\n render: (r) => (\n <div style={{ display: \"flex\", gap: \"var(--w6w-sp-1-5)\" }}>\n <EditButton\n label=\"Edit\"\n onClick={() => setEditor({ routeId: r.id })}\n data-testid={`model-route-edit-${r.name}`}\n />\n <DeleteButton\n label=\"Delete\"\n onClick={() => setPending(r)}\n disabled={deleteMut.isPending}\n data-testid={`model-route-delete-${r.name}`}\n />\n </div>\n ),\n },\n ];\n\n return (\n <div className=\"w6w-embed-root\">\n <section className=\"section\">\n <div className=\"section-head\">\n <div>\n <h3>Model routes</h3>\n <p className=\"muted small\">\n Give a model a name your workflows can use, such as “support-assistant”. Each route\n pairs a model with an integration. You can add fallback models if a call fails.\n </p>\n </div>\n <button\n type=\"button\"\n className=\"btn\"\n disabled={!canCreate}\n onClick={() => setEditor({ routeId: null })}\n data-testid=\"model-route-add\"\n >\n + Add route\n </button>\n </div>\n\n {deleteError && (\n <div className=\"result error\" role=\"alert\" data-testid=\"model-route-delete-error\">\n {deleteError}\n </div>\n )}\n\n <div>\n {routesQuery.isLoading && <p className=\"muted\">Loading…</p>}\n {routesQuery.data?.length === 0 && (\n <EmptyState testId=\"model-routes-empty\">\n No model routes yet. Add one to give callers a stable name for a model.\n </EmptyState>\n )}\n {routes.length > 0 && (\n <DataTable\n columns={columns}\n rows={routes}\n rowKey={(r) => r.id}\n testId=\"model-routes-table\"\n />\n )}\n </div>\n\n {editorReady && project != null && editor != null && (\n <RouteModal\n project={project}\n initial={editing}\n initialConnection={editor.connection}\n onSetupAiKey={props.onSetupAiKey}\n onClose={() => setEditor(null)}\n onSaved={() => setEditor(null)}\n />\n )}\n\n {pending != null && project != null && (\n <ConfirmModal\n title=\"Delete model route\"\n message={`Delete the model route \"${pending.name}\"? Calls that name it will fail until another route covers the model.`}\n confirmLabel=\"Delete\"\n onConfirm={() => {\n const name = pending.name;\n setDeleteError(null);\n deleteMut.mutate(\n { project, name },\n {\n onError: (e: unknown) =>\n setDeleteError(`Could not delete \"${name}\": ${modelRouteErrorCopy(e)}`),\n },\n );\n setPending(null);\n }}\n onClose={() => setPending(null)}\n />\n )}\n </section>\n </div>\n );\n}\n\n/**\n * Create/edit modal. The name is the route's address, so it is fixed once created (the server\n * patches by name); model and connection stay editable — a reconnect is exactly a connection\n * change.\n */\nfunction RouteModal(props: {\n project: string;\n initial?: ModelRoute;\n initialConnection?: string;\n onSetupAiKey?: ModelRoutesManagerProps[\"onSetupAiKey\"];\n onClose: () => void;\n onSaved: () => void;\n}) {\n const isEdit = !!props.initial;\n const userKeysEnabled = useUserScopedCredentialsEnabled();\n const [mode, setMode] = useState<ModelRouteCredentialMode>(\n props.initial?.credentialMode ?? \"account\",\n );\n const ownKey = mode === \"invoking_user\";\n const showModeControl = userKeysEnabled || props.initial?.credentialMode === \"invoking_user\";\n const [name, setName] = useState(props.initial?.name ?? \"\");\n const [model, setModel] = useState(props.initial?.modelId ?? \"\");\n const [connection, setConnection] = useState(\n props.initialConnection ?? props.initial?.connectionId ?? \"\",\n );\n const [fallbacks, setFallbacks] = useState<ModelFallback[]>(props.initial?.fallbacks ?? []);\n const [error, setError] = useState<string | null>(null);\n\n const catalog = useAllModelCatalogQuery({ status: \"active\" });\n const connectionsQuery = useConnectionsQuery();\n const models = catalog.data?.models ?? [];\n const providersQuery = useModelProvidersQuery();\n // Descriptor-driven: only designated providers, disabled with a reason when `complete` is not\n // supported. Never an app id or category guess.\n const connections = connectionChoices(\n connectionsQuery.data ?? [],\n providersQuery.data ?? [],\n \"complete\",\n );\n const catalogEmpty = catalog.isSuccess && models.length === 0;\n\n const createMut = useCreateModelRouteMutation();\n const updateMut = useUpdateModelRouteMutation();\n const saving = createMut.isPending || updateMut.isPending;\n const canSave =\n !!name &&\n !!model &&\n (ownKey || !!connection) &&\n fallbacks.every((f) => !!f.model && (ownKey || !!f.connection)) &&\n !saving;\n\n function save() {\n setError(null);\n const onSettled = {\n onSuccess: () => props.onSaved(),\n onError: (e: unknown) => setError(modelRouteErrorCopy(e)),\n };\n if (props.initial) {\n updateMut.mutate(\n {\n project: props.project,\n name: props.initial.name,\n patch: {\n ...routeTarget(mode, { model, connection }),\n fallbacks: fallbacks.map((f) => routeTarget(mode, f)),\n },\n },\n onSettled,\n );\n return;\n }\n createMut.mutate(\n {\n project: props.project,\n input: {\n name,\n ...routeTarget(mode, { model, connection }),\n ...(fallbacks.length > 0\n ? { fallbacks: fallbacks.map((f) => routeTarget(mode, f)) }\n : {}),\n },\n },\n onSettled,\n );\n }\n\n const enterSubmit = useEnterSubmit(save, { enabled: canSave });\n\n return (\n <Modal\n title={props.initial ? `Edit ${props.initial.name}` : \"Add model route\"}\n onClose={props.onClose}\n >\n <div className=\"modal-body\">\n <label className=\"field\">\n <span>Name</span>\n <input\n type=\"text\"\n value={name}\n disabled={isEdit}\n onChange={(e) => setName(e.target.value)}\n placeholder=\"e.g. gpt-4o-fast\"\n maxLength={64}\n data-testid=\"model-route-name\"\n {...enterSubmit}\n />\n {!isEdit && (\n <span className=\"hint\">\n 3 to 39 characters: lowercase letters, digits and dashes, starting with a letter, no\n double dashes, not ending in a dash. Callers use this name; it cannot be renamed\n later.\n </span>\n )}\n </label>\n\n {catalogEmpty && (\n <EmptyState testId=\"model-route-catalog-empty\">\n The model catalog is empty. Open the Catalog tab to discover models; until then you can\n type ids by hand.\n </EmptyState>\n )}\n\n {showModeControl && (\n <label className=\"field\">\n <span>Credentials</span>\n <select\n value={mode}\n onChange={(e) => setMode(e.target.value as ModelRouteCredentialMode)}\n data-testid=\"model-route-mode\"\n >\n <option value=\"account\">One account connection</option>\n <option value=\"invoking_user\">Each person's own key</option>\n </select>\n </label>\n )}\n\n <PairFields\n label=\"\"\n model={model}\n connection={connection}\n onModel={setModel}\n onConnection={setConnection}\n models={models}\n connections={connections}\n catalogEmpty={catalogEmpty}\n hideConnection={ownKey}\n testIdPrefix=\"model-route\"\n enterSubmit={enterSubmit}\n />\n {ownKey ? (\n <div className=\"hint\" data-testid=\"model-route-own-key\">\n {OWN_KEY_COPY}.{\" \"}\n {props.onSetupAiKey != null && (\n <button\n type=\"button\"\n className=\"btn ghost\"\n onClick={() =>\n props.onSetupAiKey?.({\n providerAppId: models.find((m) => m.id === model)?.providerAppId,\n modelId: model || undefined,\n })\n }\n data-testid=\"model-route-manage-keys\"\n >\n Manage your AI keys\n </button>\n )}\n </div>\n ) : (\n <span className=\"hint\">\n The connection holds the credentials for the model. Changing it fixes a broken route.\n </span>\n )}\n\n <div className=\"field\">\n <span>Fallbacks</span>\n {fallbacks.map((f, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: rows have no identity beyond position\n <div key={i} style={{ display: \"flex\", gap: \"var(--w6w-sp-1-5)\" }}>\n <PairFields\n label={`Fallback ${i + 1} `}\n model={f.model}\n connection={f.connection}\n onModel={(v) =>\n setFallbacks((fs) => fs.map((x, j) => (j === i ? { ...x, model: v } : x)))\n }\n onConnection={(v) =>\n setFallbacks((fs) => fs.map((x, j) => (j === i ? { ...x, connection: v } : x)))\n }\n models={models}\n connections={connections}\n catalogEmpty={catalogEmpty}\n hideConnection={ownKey}\n testIdPrefix={`model-route-fallback-${i}`}\n enterSubmit={enterSubmit}\n />\n <button\n type=\"button\"\n className=\"btn ghost\"\n onClick={() => setFallbacks((fs) => fs.filter((_, j) => j !== i))}\n data-testid={`model-route-fallback-${i}-remove`}\n >\n Remove\n </button>\n </div>\n ))}\n <button\n type=\"button\"\n className=\"btn ghost\"\n onClick={() => setFallbacks((fs) => [...fs, { model: \"\", connection: \"\" }])}\n data-testid=\"model-route-fallback-add\"\n >\n + Add fallback\n </button>\n </div>\n\n {error && (\n <div className=\"result error\" data-testid=\"model-route-error\">\n {error}\n </div>\n )}\n </div>\n <div className=\"modal-actions\">\n <button type=\"button\" className=\"btn ghost\" onClick={props.onClose}>\n Cancel\n </button>\n <button\n type=\"button\"\n className=\"btn\"\n disabled={!canSave}\n onClick={save}\n data-testid=\"model-route-save\"\n >\n {saving ? \"Saving…\" : isEdit ? \"Save changes\" : \"Save route\"}\n </button>\n </div>\n </Modal>\n );\n}\n\ninterface PairFieldsProps {\n label: string;\n model: string;\n connection: string;\n onModel: (v: string) => void;\n onConnection: (v: string) => void;\n models: Model[];\n connections: ConnectionChoice[];\n catalogEmpty: boolean;\n /** Own-key mode: the route has no fixed connection, so no connection select at all. */\n hideConnection?: boolean;\n testIdPrefix: string;\n enterSubmit: Record<string, unknown>;\n}\n\n/**\n * A model + connection pair as selects fed by the catalog and the connections list. Connections\n * narrow to the chosen model's provider app; if none match, all are listed (labelled) so the\n * route can still be saved. An empty catalog falls back to free text.\n */\nfunction PairFields(p: PairFieldsProps) {\n const picked = p.models.find((m) => m.id === p.model);\n const matching = picked\n ? p.connections.filter((c) => c.appId === picked.providerAppId)\n : p.connections;\n const narrowed = picked != null && matching.length > 0;\n const options = narrowed ? matching : p.connections;\n const connHas = options.some((c) => c.id === p.connection);\n const modelHas = p.models.some((m) => m.id === p.model);\n return (\n <>\n <div className=\"field\">\n <span>{p.label}Model</span>\n {p.catalogEmpty ? (\n <input\n type=\"text\"\n value={p.model}\n onChange={(e) => p.onModel(e.target.value)}\n placeholder=\"model id\"\n aria-label={`${p.label}Model`}\n data-testid={`${p.testIdPrefix}-model`}\n {...p.enterSubmit}\n />\n ) : (\n <select\n value={p.model}\n onChange={(e) => p.onModel(e.target.value)}\n aria-label={`${p.label}Model`}\n data-testid={`${p.testIdPrefix}-model`}\n >\n <option value=\"\">Select a model…</option>\n {p.model && !modelHas && <option value={p.model}>{p.model}</option>}\n {p.models.map((m) => (\n <option key={m.id} value={m.id}>\n {m.displayName} ({m.provider})\n </option>\n ))}\n </select>\n )}\n </div>\n {!p.hideConnection && (\n <div className=\"field\">\n <span>{p.label}Connection</span>\n {p.catalogEmpty && p.connections.length === 0 ? (\n <input\n type=\"text\"\n value={p.connection}\n onChange={(e) => p.onConnection(e.target.value)}\n placeholder=\"connection id\"\n aria-label={`${p.label}Connection`}\n data-testid={`${p.testIdPrefix}-connection`}\n {...p.enterSubmit}\n />\n ) : (\n <select\n value={p.connection}\n onChange={(e) => p.onConnection(e.target.value)}\n aria-label={`${p.label}Connection`}\n data-testid={`${p.testIdPrefix}-connection`}\n >\n <option value=\"\">Select a connection…</option>\n {p.connection && !connHas && <option value={p.connection}>{p.connection}</option>}\n {options.map((c) => (\n <option key={c.id} value={c.id} disabled={c.disabledReason != null}>\n {c.displayName}\n {narrowed ? \"\" : ` (${c.appId})`}\n {c.disabledReason != null ? ` — ${c.disabledReason}` : \"\"}\n </option>\n ))}\n </select>\n )}\n </div>\n )}\n </>\n );\n}\n"],"names":["COPY","READINESS_COPY","READINESS_GENERIC","OWN_KEY_COPY","modelRouteErrorCopy","ApiError","routeSummary","r","fallbacks","tail","RouteReadiness","props","route","useModelRouteReadinessQuery","setup","jsxs","jsx","Fragment","i","_a","ModelRoutesManager","project","useEditorProject","editor","setEditor","useState","pending","setPending","deleteError","setDeleteError","routesQuery","useModelRoutesQuery","deleteMut","useDeleteModelRouteMutation","routes","canCreate","editing","editorReady","columns","EditButton","DeleteButton","EmptyState","DataTable","RouteModal","ConfirmModal","name","e","isEdit","userKeysEnabled","useUserScopedCredentialsEnabled","mode","setMode","ownKey","showModeControl","_b","setName","_c","model","setModel","_d","connection","setConnection","_e","setFallbacks","_f","error","setError","catalog","useAllModelCatalogQuery","connectionsQuery","useConnectionsQuery","models","_g","providersQuery","useModelProvidersQuery","connections","connectionChoices","catalogEmpty","createMut","useCreateModelRouteMutation","updateMut","useUpdateModelRouteMutation","saving","canSave","f","save","onSettled","routeTarget","enterSubmit","useEnterSubmit","Modal","PairFields","m","v","fs","x","j","_","p","picked","matching","c","narrowed","options","connHas","modelHas"],"mappings":";;;;;;;;;AA0DA,MAAMA,IAA+B;AAAA,EACnC,oBACE;AAAA,EACF,2BACE;AACJ,GAGMC,IAAyC;AAAA,EAC7C,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,uBAAuB;AAAA,EACvB,6BAA6B;AAC/B,GACMC,KAAoB,2CAEpBC,IAAe;AAEd,SAASC,EAAoB,GAAoB;AACtD,SAAI,aAAaC,KACX,OAAO,OAAOL,GAAM,EAAE,IAAI,IAAUA,EAAK,EAAE,IAAI,IAC5C,EAAE,UAEJ,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AAClD;AA0BA,SAASM,EAAaC,GAAuB;AAC3C,QAAMC,IAAYD,EAAE,UAAU,QACxBE,IAAOD,MAAc,IAAI,KAAK,MAAMA,CAAS,YAAYA,MAAc,IAAI,KAAK,GAAG;AAKzF,SAAO,GAHLD,EAAE,mBAAmB,kBACjB,GAAGA,EAAE,OAAO,MAAMJ,CAAY,KAC9B,GAAGI,EAAE,OAAO,QAAQA,EAAE,YAAY,EAC1B,GAAGE,CAAI;AACvB;AAGA,SAASC,GAAeC,GAIrB;AACD,QAAM,EAAE,OAAAC,MAAUD,GAEZJ,IADIM,GAA4BF,EAAM,SAASC,EAAM,IAAI,EACnD;AACZ,MAAI,CAACL,EAAG,QAAO;AACf,QAAMO,IAAQP,EAAE;AAChB,SACE,gBAAAQ,EAAC,SAAI,WAAU,eAAc,eAAa,yBAAyBH,EAAM,IAAI,IAC1E,UAAA;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