@w6w/embed 0.2.11 → 0.2.20

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 (133) hide show
  1. package/README.md +22 -5
  2. package/dist/ConfirmModal-Pv2-A_3U.js +186 -0
  3. package/dist/ConfirmModal-Pv2-A_3U.js.map +1 -0
  4. package/dist/{CreateFunctionModal-D6CQLpa_.js → CreateFunctionModal-DScxp_LN.js} +2 -2
  5. package/dist/{CreateFunctionModal-D6CQLpa_.js.map → CreateFunctionModal-DScxp_LN.js.map} +1 -1
  6. package/dist/{DocumentFormModal-YauVdolr.js → DocumentFormModal-Br4s8wmi.js} +3 -3
  7. package/dist/{DocumentFormModal-YauVdolr.js.map → DocumentFormModal-Br4s8wmi.js.map} +1 -1
  8. package/dist/ImportSpecModal-Cpzp8ndt.js +251 -0
  9. package/dist/ImportSpecModal-Cpzp8ndt.js.map +1 -0
  10. package/dist/{ModelRoutesManager-BGESQahw.js → ModelRoutesManager-1Ac5wcas.js} +3 -3
  11. package/dist/{ModelRoutesManager-BGESQahw.js.map → ModelRoutesManager-1Ac5wcas.js.map} +1 -1
  12. package/dist/WorkflowEditor-CmhXHRxi.js +1109 -0
  13. package/dist/WorkflowEditor-CmhXHRxi.js.map +1 -0
  14. package/dist/apps-ItBvnWX3.js +92 -0
  15. package/dist/apps-ItBvnWX3.js.map +1 -0
  16. package/dist/chrome/DangerZone.d.ts +4 -3
  17. package/dist/chrome/ExecutionProfileHeader.d.ts +3 -3
  18. package/dist/chrome/JsonToggle.d.ts +29 -20
  19. package/dist/chrome/Modal.d.ts +3 -1
  20. package/dist/chrome/RightRail.d.ts +6 -1
  21. package/dist/chrome/VersionHistoryModal.d.ts +2 -0
  22. package/dist/chrome/index.d.ts +1 -0
  23. package/dist/chrome/workspace.d.ts +32 -1
  24. package/dist/{coerce-input-DttlcSdO.js → coerce-input-DFJ4n_wc.js} +68 -69
  25. package/dist/coerce-input-DFJ4n_wc.js.map +1 -0
  26. package/dist/{connections-D7cgXhDS.js → connections-CzsCyIxY.js} +10 -10
  27. package/dist/{connections-D7cgXhDS.js.map → connections-CzsCyIxY.js.map} +1 -1
  28. package/dist/{credentials-DaQU3Ca_.js → credentials-Cn92LGhJ.js} +4 -4
  29. package/dist/{credentials-DaQU3Ca_.js.map → credentials-Cn92LGhJ.js.map} +1 -1
  30. package/dist/data-stores-UeQvwVCa.js +170 -0
  31. package/dist/data-stores-UeQvwVCa.js.map +1 -0
  32. package/dist/document-sources-DNmBojx6.js +169 -0
  33. package/dist/document-sources-DNmBojx6.js.map +1 -0
  34. package/dist/draft/use-workflow-draft.d.ts +2 -0
  35. package/dist/draft.mjs +2 -2
  36. package/dist/editor/PublishTooltip.d.ts +7 -0
  37. package/dist/editor/SetupIncompleteBanner.d.ts +12 -0
  38. package/dist/editor/StartingStateModal.d.ts +14 -0
  39. package/dist/editor/WorkflowSettingsModal.d.ts +6 -1
  40. package/dist/editor/WorkflowVariablesEditor.d.ts +6 -0
  41. package/dist/editor/definition.d.ts +4 -0
  42. package/dist/editor/json-apply.d.ts +29 -0
  43. package/dist/editor/step-problems-feed.d.ts +5 -0
  44. package/dist/editor/types.d.ts +2 -2
  45. package/dist/editor-apps-DkkC7wOQ.js +152 -0
  46. package/dist/editor-apps-DkkC7wOQ.js.map +1 -0
  47. package/dist/editor-tools-BR27RGto.js +1683 -0
  48. package/dist/editor-tools-BR27RGto.js.map +1 -0
  49. package/dist/editor.mjs +1 -1
  50. package/dist/editors.mjs +536 -478
  51. package/dist/editors.mjs.map +1 -1
  52. package/dist/forms.mjs +3 -3
  53. package/dist/{rail-settings-XYGToh00.js → import-bindings-EUtxZ9Ti.js} +90 -24
  54. package/dist/import-bindings-EUtxZ9Ti.js.map +1 -0
  55. package/dist/index.mjs +138 -108
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/lib/binding-problems.d.ts +5 -1
  58. package/dist/lib/history-query.d.ts +45 -0
  59. package/dist/lib/import-bindings.d.ts +89 -0
  60. package/dist/lib/index.d.ts +3 -0
  61. package/dist/lib/rail-settings.d.ts +1 -1
  62. package/dist/lib/setup-incomplete.d.ts +22 -0
  63. package/dist/lib/starting-data.d.ts +31 -0
  64. package/dist/lib/state-panel.d.ts +29 -0
  65. package/dist/lib/target-fields.d.ts +3 -15
  66. package/dist/lib/workflow-live-run.d.ts +84 -6
  67. package/dist/lib/workflow-validity.d.ts +64 -16
  68. package/dist/lib/workflow-variables.d.ts +1 -1
  69. package/dist/lib/workflow-version.d.ts +2 -0
  70. package/dist/lib.mjs +87 -72
  71. package/dist/lists/DataStoreList.d.ts +17 -0
  72. package/dist/lists/DataStoreView.d.ts +19 -0
  73. package/dist/lists/Logs.d.ts +19 -0
  74. package/dist/lists.d.ts +6 -0
  75. package/dist/lists.mjs +1255 -816
  76. package/dist/lists.mjs.map +1 -1
  77. package/dist/rail/ConnectionsTool.d.ts +2 -0
  78. package/dist/rail/HistoryTool.d.ts +2 -0
  79. package/dist/rail/StartingStateTool.d.ts +2 -0
  80. package/dist/rail/settings-sections.d.ts +4 -1
  81. package/dist/rail.mjs +1 -1
  82. package/dist/repos/connections.d.ts +1 -0
  83. package/dist/repos/constants.d.ts +12 -0
  84. package/dist/repos/data-stores.d.ts +84 -0
  85. package/dist/repos/history.d.ts +9 -0
  86. package/dist/repos/index.d.ts +2 -0
  87. package/dist/repos/spec-export.d.ts +3 -3
  88. package/dist/repos/spec-import.d.ts +30 -1
  89. package/dist/repos/step-tests.d.ts +2 -0
  90. package/dist/repos/webhook-listen.d.ts +35 -0
  91. package/dist/repos/workflows.d.ts +105 -2
  92. package/dist/repos.mjs +370 -328
  93. package/dist/repos.mjs.map +1 -1
  94. package/dist/setup-incomplete-BHs3Lpfy.js +199 -0
  95. package/dist/setup-incomplete-BHs3Lpfy.js.map +1 -0
  96. package/dist/{spec-export-CBbloO_n.js → spec-export-DGy5ijps.js} +72 -59
  97. package/dist/spec-export-DGy5ijps.js.map +1 -0
  98. package/dist/spec-import-SWOonsNr.js +116 -0
  99. package/dist/spec-import-SWOonsNr.js.map +1 -0
  100. package/dist/{step-tests-CivICmTq.js → step-tests-B4E4W3ly.js} +8 -7
  101. package/dist/step-tests-B4E4W3ly.js.map +1 -0
  102. package/dist/{use-callable-draft-DsALnSfF.js → use-callable-draft-DCauHt5o.js} +2 -2
  103. package/dist/{use-callable-draft-DsALnSfF.js.map → use-callable-draft-DCauHt5o.js.map} +1 -1
  104. package/dist/use-workflow-draft-l3P5KZzw.js +338 -0
  105. package/dist/use-workflow-draft-l3P5KZzw.js.map +1 -0
  106. package/dist/workflows-BZN4Hyz1.js +623 -0
  107. package/dist/workflows-BZN4Hyz1.js.map +1 -0
  108. package/package.json +4 -3
  109. package/src/styles.css +153 -1
  110. package/dist/ConfirmModal-BE-SdX-O.js +0 -185
  111. package/dist/ConfirmModal-BE-SdX-O.js.map +0 -1
  112. package/dist/ImportSpecModal-B7qd1Km2.js +0 -136
  113. package/dist/ImportSpecModal-B7qd1Km2.js.map +0 -1
  114. package/dist/WorkflowEditor-CwvmAGp2.js +0 -925
  115. package/dist/WorkflowEditor-CwvmAGp2.js.map +0 -1
  116. package/dist/apps-CboASBKr.js +0 -77
  117. package/dist/apps-CboASBKr.js.map +0 -1
  118. package/dist/coerce-input-DttlcSdO.js.map +0 -1
  119. package/dist/document-sources-UCwe8x77.js +0 -91
  120. package/dist/document-sources-UCwe8x77.js.map +0 -1
  121. package/dist/editor-apps-BUZWld-m.js +0 -95
  122. package/dist/editor-apps-BUZWld-m.js.map +0 -1
  123. package/dist/editor-tools-B_Lfx3kw.js +0 -1279
  124. package/dist/editor-tools-B_Lfx3kw.js.map +0 -1
  125. package/dist/rail-settings-XYGToh00.js.map +0 -1
  126. package/dist/spec-export-CBbloO_n.js.map +0 -1
  127. package/dist/spec-import-CW6R_Wk1.js +0 -469
  128. package/dist/spec-import-CW6R_Wk1.js.map +0 -1
  129. package/dist/step-tests-CivICmTq.js.map +0 -1
  130. package/dist/trigger-preview-DKxfjzUY.js +0 -145
  131. package/dist/trigger-preview-DKxfjzUY.js.map +0 -1
  132. package/dist/use-workflow-draft-DzAyUeA6.js +0 -316
  133. package/dist/use-workflow-draft-DzAyUeA6.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"repos.mjs","sources":["../src/repos/agents-studio-agents.ts","../src/repos/agents-studio-assets.ts"],"sourcesContent":["/**\n * The Agents Studio repo — agent drafts, ready-only skill/context pickers, model routes,\n * agent settings and storage bindings over `@w6w/sdk` (`agents.*`, `skills.*`, `context.*`,\n * `console.storage.*`). Query-key factory + react-query hooks, mirroring `documents.ts`.\n *\n * Agents are DRAFTS: `runnable` is always `false` (A22). A save sends the body `revision` and\n * the precondition header from the loaded `updatedAt`; a 409 is surfaced as a typed\n * {@linkcode AgentConflictError} and is never retried or overwritten (A18).\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n type Agent,\n ApiError,\n type ContextEntry,\n type ContextPin,\n type CreateAgentInput,\n type SkillPin,\n type SkillVersion,\n type UpdateAgentInput,\n type W6WClient,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { listModelRoutes } from \"./models.ts\";\n\nexport type {\n Agent,\n ContextEntry,\n ContextPin,\n CreateAgentInput,\n SkillPin,\n SkillVersion,\n UpdateAgentInput,\n};\n\n/** Thrown by {@linkcode updateAgent} on a 409: the draft changed elsewhere. Never overwrites. */\nexport class AgentConflictError extends Error {\n readonly kind = \"conflict\" as const;\n /** The server's current revision, when the error body carried one. */\n readonly currentRevision: number | null;\n readonly cause: ApiError;\n constructor(cause: ApiError) {\n super(\"This agent changed elsewhere — reload to see the latest version.\");\n this.name = \"AgentConflictError\";\n this.cause = cause;\n this.currentRevision = currentRevisionOf(cause.raw);\n }\n}\n\nfunction currentRevisionOf(raw: unknown): number | null {\n const o = raw as {\n revision?: unknown;\n error?: { revision?: unknown; details?: { revision?: unknown } };\n } | null;\n const v = o?.revision ?? o?.error?.revision ?? o?.error?.details?.revision;\n return typeof v === \"number\" ? v : null;\n}\n\n/** True for a {@linkcode AgentConflictError}. */\nexport function isAgentConflict(e: unknown): e is AgentConflictError {\n return e instanceof AgentConflictError;\n}\n\nexport const agentsKey = (includeArchived = false) => [\"agents\", { includeArchived }] as const;\nexport const agentKey = (id: string) => [\"agents\", \"detail\", id] as const;\nexport const agentSkillVersionsKey = (skillId: string) =>\n [\"agents\", \"skill-versions\", skillId] as const;\nexport const agentSkillsKey = () => [\"agents\", \"skills\"] as const;\nexport const agentContextKey = () => [\"agents\", \"context\"] as const;\nexport const agentContextEntriesKey = (collectionId: string) =>\n [\"agents\", \"context-entries\", collectionId] as const;\nexport const agentAllContextEntriesKey = () => [\"agents\", \"context-entries-all\"] as const;\nexport const agentModelRoutesKey = (projectId?: string) =>\n [\"agents\", \"model-routes\", projectId] as const;\nexport const agentSettingsKey = () => [\"agent-settings\"] as const;\nexport const storageBindingsKey = () => [\"agent-settings\", \"storage-bindings\"] as const;\n\n/** Save an agent: `revision` in the body, `updatedAt` as the precondition header; 409 → conflict. */\nexport async function updateAgent(\n client: W6WClient,\n id: string,\n patch: Omit<UpdateAgentInput, \"revision\">,\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">,\n): Promise<Agent> {\n try {\n return await client.agents.update(\n id,\n { ...patch, revision: loaded.revision },\n { ifUnmodifiedSince: loaded.updatedAt },\n );\n } catch (e) {\n if (e instanceof ApiError && e.status === 409) throw new AgentConflictError(e);\n throw e;\n }\n}\n\n/** Readiness of a pin against the ready-only picker lists. */\nexport type PinState = \"ready\" | \"unavailable\";\n\n/** A skill pin is `ready` only when its version is among the ready versions of its skill. */\nexport function skillPinState(\n pin: SkillPin,\n readyVersions: readonly SkillVersion[] | undefined,\n): PinState {\n return readyVersions?.some((v) => v.id === pin.skillVersionId && v.skillId === pin.skillId)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** A context pin is `ready` only when its entry is listed, unarchived, at the pinned version. */\nexport function contextPinState(\n pin: ContextPin,\n entries: readonly ContextEntry[] | undefined,\n): PinState {\n return entries?.some((e) => e.assetVersionId === pin.assetVersionId && e.archivedAt == null)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** Picker options: ready (listed, unarchived) context entries only. */\nexport function readyContextEntries(entries: readonly ContextEntry[]): ContextEntry[] {\n return entries.filter((e) => e.archivedAt == null);\n}\n\nexport function useAgentsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentsKey(includeArchived),\n queryFn: () => client.agents.list({ includeArchived }),\n });\n}\n\nexport function useAgentQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentKey(id ?? \"\"),\n enabled: !!id,\n queryFn: () => client.agents.get(id as string),\n });\n}\n\nexport function useCreateAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateAgentInput) => client.agents.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useUpdateAgent(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n patch: Omit<UpdateAgentInput, \"revision\">;\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">;\n }) => updateAgent(client, id, v.patch, v.loaded),\n onSuccess: (agent) => {\n qc.setQueryData(agentKey(id), agent);\n return qc.invalidateQueries({ queryKey: [\"agents\"] });\n },\n });\n}\n\nexport function useArchiveAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.agents.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useAgentSkillsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentSkillsKey(), queryFn: () => client.skills.list() });\n}\n\nexport function useAgentSkillVersionsQuery(skillId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSkillVersionsKey(skillId ?? \"\"),\n enabled: !!skillId,\n queryFn: () => client.skills.versions(skillId as string),\n });\n}\n\nexport function useAgentContextCollectionsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentContextKey(), queryFn: () => client.context.list() });\n}\n\nexport function useAgentContextEntriesQuery(collectionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentContextEntriesKey(collectionId ?? \"\"),\n enabled: !!collectionId,\n queryFn: () => client.context.entries.list(collectionId as string),\n });\n}\n\n/** Every doc visible to the caller (collection-less included) — the pin picker's source. */\nexport function useAgentAllContextEntriesQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentAllContextEntriesKey(),\n queryFn: () => client.contextEntries.list({}),\n });\n}\n\nexport function useAgentModelRoutesQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentModelRoutesKey(projectId),\n enabled: projectId != null,\n queryFn: () => listModelRoutes(client, projectId as string),\n });\n}\n\nexport function useAgentSettingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSettingsKey(),\n queryFn: () => client.console.storage.settings.get(),\n });\n}\n\nexport function usePatchAgentSettings() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (patch: Parameters<W6WClient[\"console\"][\"storage\"][\"settings\"][\"patch\"]>[0]) =>\n client.console.storage.settings.patch(patch),\n onSuccess: (s) => {\n qc.setQueryData(agentSettingsKey(), s);\n },\n });\n}\n\nexport function useStorageBindingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: storageBindingsKey(),\n queryFn: () => client.console.storage.bindings.list(),\n });\n}\n","/**\n * Agents Studio asset hooks — skills, context collections/entries and stored asset files over\n * `W6WClient`'s `skills.*`, `context.*` and `assets.*` (react-query, same shape as `vars.ts`).\n *\n * These are tenant/account-scoped (no `project` is sent). Uploads are byte-mode: the caller\n * hashes and PUTs the same bytes (see Studio's `agents-studio/upload.ts`); this module only\n * wraps the single-call operations.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n AssetUploadCreateInput,\n CreateContextCollectionInput,\n CreateStandaloneContextEntryInput,\n UpdateContextEntryInput,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport const skillsKey = (includeArchived = false) => [\"skills\", { includeArchived }] as const;\nexport const skillKey = (id: string) => [\"skills\", id] as const;\nexport const skillVersionsKey = (id: string) => [\"skills\", id, \"versions\"] as const;\nexport const contextCollectionsKey = (includeArchived = false) =>\n [\"context-collections\", { includeArchived }] as const;\nexport const contextCollectionKey = (id: string) => [\"context-collections\", id] as const;\nexport const contextEntriesKey = (id: string, includeArchived = false) =>\n [\"context-collections\", id, \"entries\", { includeArchived }] as const;\nexport const allContextEntriesKey = (includeArchived = false) =>\n [\"context-entries\", { includeArchived }] as const;\nexport const assetVersionsKey = (id: string) => [\"assets\", id, \"versions\"] as const;\nexport const assetFilesKey = (id: string, versionId: string) =>\n [\"assets\", id, \"versions\", versionId, \"files\"] as const;\n\n// ── Skills ──────────────────────────────────────────────────────────────────────────────────\n\nexport function useSkillsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillsKey(includeArchived),\n queryFn: () => client.skills.list({ includeArchived }),\n });\n}\n\nexport function useSkillQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.get(id as string),\n });\n}\n\nexport function useSkillVersionsQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillVersionsKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.versions(id as string),\n });\n}\n\nexport function useArchiveSkillMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.skills.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"skills\"] }),\n });\n}\n\n// ── Context collections + entries ───────────────────────────────────────────────────────────\n\nexport function useContextCollectionsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionsKey(includeArchived),\n queryFn: () => client.context.list({ includeArchived }),\n });\n}\n\nexport function useContextCollectionQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.context.get(id as string),\n });\n}\n\nexport function useCreateContextCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateContextCollectionInput) => client.context.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"context-collections\"] }),\n });\n}\n\nexport function useContextEntriesQuery(collectionId: string | undefined, includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextEntriesKey(collectionId ?? \"\", includeArchived),\n enabled: collectionId != null,\n queryFn: () => client.context.entries.list(collectionId as string, { includeArchived }),\n });\n}\n\n/** Edit-as-new-version: `PUT` creates the next version; `ifUnmodifiedSince` guards a stale edit. */\nexport function useUpdateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n collectionId: string;\n entryId: string;\n input: UpdateContextEntryInput;\n ifUnmodifiedSince?: string;\n }) =>\n client.context.entries.update(v.collectionId, v.entryId, v.input, {\n ifUnmodifiedSince: v.ifUnmodifiedSince,\n }),\n onSuccess: (_r, v) => {\n qc.invalidateQueries({ queryKey: [\"context-collections\", v.collectionId] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\n// ── Collection-independent entries (`client.contextEntries.*`) ──────────────────────────────\n\n/** Every doc visible to the caller, whether or not it is in a collection. */\nexport function useAllContextEntriesQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: allContextEntriesKey(includeArchived),\n queryFn: () => client.contextEntries.list({ includeArchived }),\n });\n}\n\n/** Invalidate the all-docs list and, per affected collection, its entries list. */\nfunction invalidateEntries(qc: ReturnType<typeof useQueryClient>, collectionIds: string[] = []) {\n qc.invalidateQueries({ queryKey: [\"context-entries\"] });\n for (const id of collectionIds) qc.invalidateQueries({ queryKey: contextEntriesKey(id) });\n}\n\n/** Create a text doc, private unless `collectionIds` / `visibility` say otherwise. */\nexport function useCreateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateStandaloneContextEntryInput) => client.contextEntries.create(input),\n onSuccess: (_r, v) => invalidateEntries(qc, v.collectionIds),\n });\n}\n\nexport function useAddEntryToCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.addToCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\nexport function useRemoveEntryFromCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.removeFromCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\n// ── Asset versions, files, downloads ────────────────────────────────────────────────────────\n\nexport function useAssetVersionsQuery(assetId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetVersionsKey(assetId ?? \"\"),\n enabled: assetId != null,\n queryFn: () => client.assets.versions(assetId as string),\n });\n}\n\nexport function useAssetFilesQuery(assetId: string | undefined, versionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetFilesKey(assetId ?? \"\", versionId ?? \"\"),\n enabled: assetId != null && versionId != null,\n queryFn: () => client.assets.files(assetId as string, versionId as string),\n });\n}\n\n/** Exact bytes of one file. A mutation (not a query): downloads are user-triggered, never cached. */\nexport function useDownloadAssetFileMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string; fileId: string }) =>\n client.assets.content(v.assetId, v.versionId, v.fileId),\n });\n}\n\n/** One version as a store-only ZIP. */\nexport function useDownloadAssetArchiveMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string }) =>\n client.assets.archiveDownload(v.assetId, v.versionId),\n });\n}\n\nexport function useArchiveAssetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.assets.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"assets\"] }),\n });\n}\n\n// ── Upload (resumable, byte-mode) ───────────────────────────────────────────────────────────\n\nexport function useCreateAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (input: AssetUploadCreateInput) => client.assets.uploads.create(input),\n });\n}\n\nexport function usePutAssetUploadEntryMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { uploadId: string; index: number; bytes: Uint8Array }) =>\n client.assets.uploads.putEntry(v.uploadId, v.index, v.bytes),\n });\n}\n\n/** Publishing a version changes skills, context and assets alike — invalidate all three. */\nexport function useFinalizeAssetUploadMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (uploadId: string) => client.assets.uploads.finalize(uploadId),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: [\"skills\"] });\n qc.invalidateQueries({ queryKey: [\"context-collections\"] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\nexport function useAbortAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({ mutationFn: (uploadId: string) => client.assets.uploads.abort(uploadId) });\n}\n"],"names":["AgentConflictError","cause","__publicField","currentRevisionOf","raw","o","v","_a","_c","_b","isAgentConflict","agentsKey","includeArchived","agentKey","id","agentSkillVersionsKey","skillId","agentSkillsKey","agentContextKey","agentContextEntriesKey","collectionId","agentAllContextEntriesKey","agentModelRoutesKey","projectId","agentSettingsKey","storageBindingsKey","updateAgent","client","patch","loaded","e","ApiError","skillPinState","pin","readyVersions","contextPinState","entries","readyContextEntries","useAgentsQuery","useEmbedClient","useQuery","useAgentQuery","useCreateAgent","qc","useQueryClient","useMutation","input","useUpdateAgent","agent","useArchiveAgent","useAgentSkillsQuery","useAgentSkillVersionsQuery","useAgentContextCollectionsQuery","useAgentContextEntriesQuery","useAgentAllContextEntriesQuery","useAgentModelRoutesQuery","listModelRoutes","useAgentSettingsQuery","usePatchAgentSettings","useStorageBindingsQuery","skillsKey","skillKey","skillVersionsKey","contextCollectionsKey","contextCollectionKey","contextEntriesKey","allContextEntriesKey","assetVersionsKey","assetFilesKey","versionId","useSkillsQuery","useSkillQuery","useSkillVersionsQuery","useArchiveSkillMutation","useContextCollectionsQuery","useContextCollectionQuery","useCreateContextCollectionMutation","useContextEntriesQuery","useUpdateContextEntryMutation","_r","useAllContextEntriesQuery","invalidateEntries","collectionIds","useCreateContextEntryMutation","useAddEntryToCollectionMutation","useRemoveEntryFromCollectionMutation","useAssetVersionsQuery","assetId","useAssetFilesQuery","useDownloadAssetFileMutation","useDownloadAssetArchiveMutation","useArchiveAssetMutation","useCreateAssetUploadMutation","usePutAssetUploadEntryMutation","useFinalizeAssetUploadMutation","uploadId","useAbortAssetUploadMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,UAA2B,MAAM;AAAA,EAK5C,YAAYC,GAAiB;AAC3B,UAAM,kEAAkE;AALjE,IAAAC,EAAA,cAAO;AAEP;AAAA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAGP,SAAK,OAAO,sBACZ,KAAK,QAAQD,GACb,KAAK,kBAAkBE,EAAkBF,EAAM,GAAG;AAAA,EACpD;AACF;AAEA,SAASE,EAAkBC,GAA6B;;AACtD,QAAMC,IAAID,GAIJE,KAAID,KAAA,gBAAAA,EAAG,eAAYE,IAAAF,KAAA,gBAAAA,EAAG,UAAH,gBAAAE,EAAU,eAAYC,KAAAC,IAAAJ,KAAA,gBAAAA,EAAG,UAAH,gBAAAI,EAAU,YAAV,gBAAAD,EAAmB;AAClE,SAAO,OAAOF,KAAM,WAAWA,IAAI;AACrC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,QAAQ,GAAG,GAC7CA,EAAG,kBAAkB,EAAE,UAAU,CAAC,qBAAqB,GAAG,GAC1DA,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;AAEO,SAASqD,KAA8B;AAC5C,QAAMrE,IAASY,EAAA;AACf,SAAOM,EAAY,EAAE,YAAY,CAACkD,MAAqBpE,EAAO,OAAO,QAAQ,MAAMoE,CAAQ,GAAG;AAChG;"}
1
+ {"version":3,"file":"repos.mjs","sources":["../src/repos/agents-studio-agents.ts","../src/repos/agents-studio-assets.ts"],"sourcesContent":["/**\n * The Agents Studio repo — agent drafts, ready-only skill/context pickers, model routes,\n * agent settings and storage bindings over `@w6w/sdk` (`agents.*`, `skills.*`, `context.*`,\n * `console.storage.*`). Query-key factory + react-query hooks, mirroring `documents.ts`.\n *\n * Agents are DRAFTS: `runnable` is always `false` (A22). A save sends the body `revision` and\n * the precondition header from the loaded `updatedAt`; a 409 is surfaced as a typed\n * {@linkcode AgentConflictError} and is never retried or overwritten (A18).\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n type Agent,\n ApiError,\n type ContextEntry,\n type ContextPin,\n type CreateAgentInput,\n type SkillPin,\n type SkillVersion,\n type UpdateAgentInput,\n type W6WClient,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\nimport { listModelRoutes } from \"./models.ts\";\n\nexport type {\n Agent,\n ContextEntry,\n ContextPin,\n CreateAgentInput,\n SkillPin,\n SkillVersion,\n UpdateAgentInput,\n};\n\n/** Thrown by {@linkcode updateAgent} on a 409: the draft changed elsewhere. Never overwrites. */\nexport class AgentConflictError extends Error {\n readonly kind = \"conflict\" as const;\n /** The server's current revision, when the error body carried one. */\n readonly currentRevision: number | null;\n readonly cause: ApiError;\n constructor(cause: ApiError) {\n super(\"This agent changed elsewhere — reload to see the latest version.\");\n this.name = \"AgentConflictError\";\n this.cause = cause;\n this.currentRevision = currentRevisionOf(cause.raw);\n }\n}\n\nfunction currentRevisionOf(raw: unknown): number | null {\n const o = raw as {\n revision?: unknown;\n error?: { revision?: unknown; details?: { revision?: unknown } };\n } | null;\n const v = o?.revision ?? o?.error?.revision ?? o?.error?.details?.revision;\n return typeof v === \"number\" ? v : null;\n}\n\n/** True for a {@linkcode AgentConflictError}. */\nexport function isAgentConflict(e: unknown): e is AgentConflictError {\n return e instanceof AgentConflictError;\n}\n\nexport const agentsKey = (includeArchived = false) => [\"agents\", { includeArchived }] as const;\nexport const agentKey = (id: string) => [\"agents\", \"detail\", id] as const;\nexport const agentSkillVersionsKey = (skillId: string) =>\n [\"agents\", \"skill-versions\", skillId] as const;\nexport const agentSkillsKey = () => [\"agents\", \"skills\"] as const;\nexport const agentContextKey = () => [\"agents\", \"context\"] as const;\nexport const agentContextEntriesKey = (collectionId: string) =>\n [\"agents\", \"context-entries\", collectionId] as const;\nexport const agentAllContextEntriesKey = () => [\"agents\", \"context-entries-all\"] as const;\nexport const agentModelRoutesKey = (projectId?: string) =>\n [\"agents\", \"model-routes\", projectId] as const;\nexport const agentSettingsKey = () => [\"agent-settings\"] as const;\nexport const storageBindingsKey = () => [\"agent-settings\", \"storage-bindings\"] as const;\n\n/** Save an agent: `revision` in the body, `updatedAt` as the precondition header; 409 → conflict. */\nexport async function updateAgent(\n client: W6WClient,\n id: string,\n patch: Omit<UpdateAgentInput, \"revision\">,\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">,\n): Promise<Agent> {\n try {\n return await client.agents.update(\n id,\n { ...patch, revision: loaded.revision },\n { ifUnmodifiedSince: loaded.updatedAt },\n );\n } catch (e) {\n if (e instanceof ApiError && e.status === 409) throw new AgentConflictError(e);\n throw e;\n }\n}\n\n/** Readiness of a pin against the ready-only picker lists. */\nexport type PinState = \"ready\" | \"unavailable\";\n\n/** A skill pin is `ready` only when its version is among the ready versions of its skill. */\nexport function skillPinState(\n pin: SkillPin,\n readyVersions: readonly SkillVersion[] | undefined,\n): PinState {\n return readyVersions?.some((v) => v.id === pin.skillVersionId && v.skillId === pin.skillId)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** A context pin is `ready` only when its entry is listed, unarchived, at the pinned version. */\nexport function contextPinState(\n pin: ContextPin,\n entries: readonly ContextEntry[] | undefined,\n): PinState {\n return entries?.some((e) => e.assetVersionId === pin.assetVersionId && e.archivedAt == null)\n ? \"ready\"\n : \"unavailable\";\n}\n\n/** Picker options: ready (listed, unarchived) context entries only. */\nexport function readyContextEntries(entries: readonly ContextEntry[]): ContextEntry[] {\n return entries.filter((e) => e.archivedAt == null);\n}\n\nexport function useAgentsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentsKey(includeArchived),\n queryFn: () => client.agents.list({ includeArchived }),\n });\n}\n\nexport function useAgentQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentKey(id ?? \"\"),\n enabled: !!id,\n queryFn: () => client.agents.get(id as string),\n });\n}\n\nexport function useCreateAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateAgentInput) => client.agents.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useUpdateAgent(id: string) {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n patch: Omit<UpdateAgentInput, \"revision\">;\n loaded: Pick<Agent, \"revision\" | \"updatedAt\">;\n }) => updateAgent(client, id, v.patch, v.loaded),\n onSuccess: (agent) => {\n qc.setQueryData(agentKey(id), agent);\n return qc.invalidateQueries({ queryKey: [\"agents\"] });\n },\n });\n}\n\nexport function useArchiveAgent() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.agents.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"agents\"] }),\n });\n}\n\nexport function useAgentSkillsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentSkillsKey(), queryFn: () => client.skills.list() });\n}\n\nexport function useAgentSkillVersionsQuery(skillId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSkillVersionsKey(skillId ?? \"\"),\n enabled: !!skillId,\n queryFn: () => client.skills.versions(skillId as string),\n });\n}\n\nexport function useAgentContextCollectionsQuery() {\n const client = useEmbedClient();\n return useQuery({ queryKey: agentContextKey(), queryFn: () => client.context.list() });\n}\n\nexport function useAgentContextEntriesQuery(collectionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentContextEntriesKey(collectionId ?? \"\"),\n enabled: !!collectionId,\n queryFn: () => client.context.entries.list(collectionId as string),\n });\n}\n\n/** Every doc visible to the caller (collection-less included) — the pin picker's source. */\nexport function useAgentAllContextEntriesQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentAllContextEntriesKey(),\n queryFn: () => client.contextEntries.list({}),\n });\n}\n\nexport function useAgentModelRoutesQuery(projectId?: string) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentModelRoutesKey(projectId),\n enabled: projectId != null,\n queryFn: () => listModelRoutes(client, projectId as string),\n });\n}\n\nexport function useAgentSettingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: agentSettingsKey(),\n queryFn: () => client.console.storage.settings.get(),\n });\n}\n\nexport function usePatchAgentSettings() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (patch: Parameters<W6WClient[\"console\"][\"storage\"][\"settings\"][\"patch\"]>[0]) =>\n client.console.storage.settings.patch(patch),\n onSuccess: (s) => {\n qc.setQueryData(agentSettingsKey(), s);\n },\n });\n}\n\nexport function useStorageBindingsQuery() {\n const client = useEmbedClient();\n return useQuery({\n queryKey: storageBindingsKey(),\n queryFn: () => client.console.storage.bindings.list(),\n });\n}\n","/**\n * Agents Studio asset hooks — skills, context collections/entries and stored asset files over\n * `W6WClient`'s `skills.*`, `context.*` and `assets.*` (react-query, same shape as `vars.ts`).\n *\n * These are tenant/account-scoped (no `project` is sent). Uploads are byte-mode: the caller\n * hashes and PUTs the same bytes (see Studio's `agents-studio/upload.ts`); this module only\n * wraps the single-call operations.\n */\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n AssetUploadCreateInput,\n CreateContextCollectionInput,\n CreateStandaloneContextEntryInput,\n UpdateContextEntryInput,\n} from \"@w6w/sdk\";\nimport { useEmbedClient } from \"../draft/client-context.ts\";\n\nexport const skillsKey = (includeArchived = false) => [\"skills\", { includeArchived }] as const;\nexport const skillKey = (id: string) => [\"skills\", id] as const;\nexport const skillVersionsKey = (id: string) => [\"skills\", id, \"versions\"] as const;\nexport const contextCollectionsKey = (includeArchived = false) =>\n [\"context-collections\", { includeArchived }] as const;\nexport const contextCollectionKey = (id: string) => [\"context-collections\", id] as const;\nexport const contextEntriesKey = (id: string, includeArchived = false) =>\n [\"context-collections\", id, \"entries\", { includeArchived }] as const;\nexport const allContextEntriesKey = (includeArchived = false) =>\n [\"context-entries\", { includeArchived }] as const;\nexport const assetVersionsKey = (id: string) => [\"assets\", id, \"versions\"] as const;\nexport const assetFilesKey = (id: string, versionId: string) =>\n [\"assets\", id, \"versions\", versionId, \"files\"] as const;\n\n// ── Skills ──────────────────────────────────────────────────────────────────────────────────\n\nexport function useSkillsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillsKey(includeArchived),\n queryFn: () => client.skills.list({ includeArchived }),\n });\n}\n\nexport function useSkillQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.get(id as string),\n });\n}\n\nexport function useSkillVersionsQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: skillVersionsKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.skills.versions(id as string),\n });\n}\n\nexport function useArchiveSkillMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.skills.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"skills\"] }),\n });\n}\n\n// ── Context collections + entries ───────────────────────────────────────────────────────────\n\nexport function useContextCollectionsQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionsKey(includeArchived),\n queryFn: () => client.context.list({ includeArchived }),\n });\n}\n\nexport function useContextCollectionQuery(id: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextCollectionKey(id ?? \"\"),\n enabled: id != null,\n queryFn: () => client.context.get(id as string),\n });\n}\n\nexport function useCreateContextCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateContextCollectionInput) => client.context.create(input),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"context-collections\"] }),\n });\n}\n\nexport function useContextEntriesQuery(collectionId: string | undefined, includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: contextEntriesKey(collectionId ?? \"\", includeArchived),\n enabled: collectionId != null,\n queryFn: () => client.context.entries.list(collectionId as string, { includeArchived }),\n });\n}\n\n/** Edit-as-new-version: `PUT` creates the next version; `ifUnmodifiedSince` guards a stale edit. */\nexport function useUpdateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: {\n collectionId: string;\n entryId: string;\n input: UpdateContextEntryInput;\n ifUnmodifiedSince?: string;\n }) =>\n client.context.entries.update(v.collectionId, v.entryId, v.input, {\n ifUnmodifiedSince: v.ifUnmodifiedSince,\n }),\n onSuccess: (_r, v) => {\n qc.invalidateQueries({ queryKey: [\"context-collections\", v.collectionId] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\n// ── Collection-independent entries (`client.contextEntries.*`) ──────────────────────────────\n\n/** Every doc visible to the caller, whether or not it is in a collection. */\nexport function useAllContextEntriesQuery(includeArchived = false) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: allContextEntriesKey(includeArchived),\n queryFn: () => client.contextEntries.list({ includeArchived }),\n });\n}\n\n/** Invalidate the all-docs list and, per affected collection, its entries list. */\nfunction invalidateEntries(qc: ReturnType<typeof useQueryClient>, collectionIds: string[] = []) {\n qc.invalidateQueries({ queryKey: [\"context-entries\"] });\n for (const id of collectionIds) qc.invalidateQueries({ queryKey: contextEntriesKey(id) });\n}\n\n/** Create a text doc, private unless `collectionIds` / `visibility` say otherwise. */\nexport function useCreateContextEntryMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (input: CreateStandaloneContextEntryInput) => client.contextEntries.create(input),\n onSuccess: (_r, v) => invalidateEntries(qc, v.collectionIds),\n });\n}\n\nexport function useAddEntryToCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.addToCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\nexport function useRemoveEntryFromCollectionMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (v: { entryId: string; collectionId: string }) =>\n client.contextEntries.removeFromCollection(v.entryId, v.collectionId),\n onSuccess: (_r, v) => invalidateEntries(qc, [v.collectionId]),\n });\n}\n\n// ── Asset versions, files, downloads ────────────────────────────────────────────────────────\n\nexport function useAssetVersionsQuery(assetId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetVersionsKey(assetId ?? \"\"),\n enabled: assetId != null,\n queryFn: () => client.assets.versions(assetId as string),\n });\n}\n\nexport function useAssetFilesQuery(assetId: string | undefined, versionId: string | undefined) {\n const client = useEmbedClient();\n return useQuery({\n queryKey: assetFilesKey(assetId ?? \"\", versionId ?? \"\"),\n enabled: assetId != null && versionId != null,\n queryFn: () => client.assets.files(assetId as string, versionId as string),\n });\n}\n\n/** Exact bytes of one file. A mutation (not a query): downloads are user-triggered, never cached. */\nexport function useDownloadAssetFileMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string; fileId: string }) =>\n client.assets.content(v.assetId, v.versionId, v.fileId),\n });\n}\n\n/** One version as a store-only ZIP. */\nexport function useDownloadAssetArchiveMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { assetId: string; versionId: string }) =>\n client.assets.archiveDownload(v.assetId, v.versionId),\n });\n}\n\nexport function useArchiveAssetMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (id: string) => client.assets.archive(id),\n onSuccess: () => qc.invalidateQueries({ queryKey: [\"assets\"] }),\n });\n}\n\n// ── Upload (resumable, byte-mode) ───────────────────────────────────────────────────────────\n\nexport function useCreateAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (input: AssetUploadCreateInput) => client.assets.uploads.create(input),\n });\n}\n\nexport function usePutAssetUploadEntryMutation() {\n const client = useEmbedClient();\n return useMutation({\n mutationFn: (v: { uploadId: string; index: number; bytes: Uint8Array }) =>\n client.assets.uploads.putEntry(v.uploadId, v.index, v.bytes),\n });\n}\n\n/** Publishing a version changes skills, context and assets alike — invalidate all three. */\nexport function useFinalizeAssetUploadMutation() {\n const client = useEmbedClient();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: (uploadId: string) => client.assets.uploads.finalize(uploadId),\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: [\"skills\"] });\n qc.invalidateQueries({ queryKey: [\"context-collections\"] });\n qc.invalidateQueries({ queryKey: [\"assets\"] });\n },\n });\n}\n\nexport function useAbortAssetUploadMutation() {\n const client = useEmbedClient();\n return useMutation({ mutationFn: (uploadId: string) => client.assets.uploads.abort(uploadId) });\n}\n"],"names":["AgentConflictError","cause","__publicField","currentRevisionOf","raw","o","v","_a","_c","_b","isAgentConflict","agentsKey","includeArchived","agentKey","id","agentSkillVersionsKey","skillId","agentSkillsKey","agentContextKey","agentContextEntriesKey","collectionId","agentAllContextEntriesKey","agentModelRoutesKey","projectId","agentSettingsKey","storageBindingsKey","updateAgent","client","patch","loaded","e","ApiError","skillPinState","pin","readyVersions","contextPinState","entries","readyContextEntries","useAgentsQuery","useEmbedClient","useQuery","useAgentQuery","useCreateAgent","qc","useQueryClient","useMutation","input","useUpdateAgent","agent","useArchiveAgent","useAgentSkillsQuery","useAgentSkillVersionsQuery","useAgentContextCollectionsQuery","useAgentContextEntriesQuery","useAgentAllContextEntriesQuery","useAgentModelRoutesQuery","listModelRoutes","useAgentSettingsQuery","usePatchAgentSettings","useStorageBindingsQuery","skillsKey","skillKey","skillVersionsKey","contextCollectionsKey","contextCollectionKey","contextEntriesKey","allContextEntriesKey","assetVersionsKey","assetFilesKey","versionId","useSkillsQuery","useSkillQuery","useSkillVersionsQuery","useArchiveSkillMutation","useContextCollectionsQuery","useContextCollectionQuery","useCreateContextCollectionMutation","useContextEntriesQuery","useUpdateContextEntryMutation","_r","useAllContextEntriesQuery","invalidateEntries","collectionIds","useCreateContextEntryMutation","useAddEntryToCollectionMutation","useRemoveEntryFromCollectionMutation","useAssetVersionsQuery","assetId","useAssetFilesQuery","useDownloadAssetFileMutation","useDownloadAssetArchiveMutation","useArchiveAssetMutation","useCreateAssetUploadMutation","usePutAssetUploadEntryMutation","useFinalizeAssetUploadMutation","uploadId","useAbortAssetUploadMutation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,UAA2B,MAAM;AAAA,EAK5C,YAAYC,GAAiB;AAC3B,UAAM,kEAAkE;AALjE,IAAAC,EAAA,cAAO;AAEP;AAAA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAGP,SAAK,OAAO,sBACZ,KAAK,QAAQD,GACb,KAAK,kBAAkBE,EAAkBF,EAAM,GAAG;AAAA,EACpD;AACF;AAEA,SAASE,EAAkBC,GAA6B;;AACtD,QAAMC,IAAID,GAIJE,KAAID,KAAA,gBAAAA,EAAG,eAAYE,IAAAF,KAAA,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KC,EAAA;AACX,SAAOC,EAAY;AAAA,IACjB,YAAY,CAACkD,MAAqBpE,EAAO,OAAO,QAAQ,SAASoE,CAAQ;AAAA,IACzE,WAAW,MAAM;AACf,MAAApD,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG,GAC7CA,EAAG,kBAAkB,EAAE,UAAU,CAAC,qBAAqB,GAAG,GAC1DA,EAAG,kBAAkB,EAAE,UAAU,CAAC,QAAQ,GAAG;AAAA,IAC/C;AAAA,EAAA,CACD;AACH;AAEO,SAASqD,KAA8B;AAC5C,QAAMrE,IAASY,EAAA;AACf,SAAOM,EAAY,EAAE,YAAY,CAACkD,MAAqBpE,EAAO,OAAO,QAAQ,MAAMoE,CAAQ,GAAG;AAChG;"}
@@ -0,0 +1,199 @@
1
+ import { parseTemplate as O } from "@w6w/expr";
2
+ function T(n, t, e) {
3
+ var o, c, f;
4
+ const s = [];
5
+ for (const l of n) {
6
+ const r = (o = l.uses) == null ? void 0 : o.app, a = (c = l.uses) == null ? void 0 : c.connectionRef, d = a && e && Object.hasOwn(e, a) ? e[a] : void 0, h = a === void 0 ? (f = l.uses) == null ? void 0 : f.connection : d && d.app === r ? d.connection : void 0;
7
+ if (typeof r != "string" || r === "" || typeof h != "string" || h === "") continue;
8
+ const u = t(r);
9
+ (u == null ? void 0 : u.state) === "ready" && (u.ids.has(h) || s.push({ siteId: l.id, app: r, connection: h, code: "unknown_connection" }));
10
+ }
11
+ return s;
12
+ }
13
+ function F(n) {
14
+ const t = n.enabled === !1 && (n.problemCount > 0 || n.hadProblems);
15
+ return {
16
+ show: t,
17
+ canEnable: t && n.problemCount === 0 && !n.dirty,
18
+ problemCount: n.problemCount
19
+ };
20
+ }
21
+ function y(n) {
22
+ return (n == null ? void 0 : n.nodes) ?? (n == null ? void 0 : n.steps) ?? [];
23
+ }
24
+ function b(n, t) {
25
+ const e = n.uses;
26
+ if (e != null && e.function) return null;
27
+ if (!(e != null && e.app) || !(e != null && e.action)) return "target missing";
28
+ const s = t.actionParamsByKey[`${e.app}::${e.action}`] ?? [], o = n.with ?? {};
29
+ return t.requiredParamsFilled(s, o) ? null : "required params";
30
+ }
31
+ function P(n, t) {
32
+ return b(n, t) === null;
33
+ }
34
+ function _(n, t) {
35
+ const e = y(n);
36
+ return e.length > 0 && e.every((s) => P(s, t));
37
+ }
38
+ function B(n, t) {
39
+ const e = y(n);
40
+ if (e.length === 0) return "no steps";
41
+ for (const s of e) {
42
+ const o = b(s, t);
43
+ if (o) return `${s.id}: ${o}`;
44
+ }
45
+ return null;
46
+ }
47
+ const S = {
48
+ "target missing": "has no action or function chosen. Open it and pick what it runs.",
49
+ "required params": "has required fields left empty. Open it and fill them in."
50
+ };
51
+ function q(n, t) {
52
+ const e = y(n);
53
+ if (e.length === 0)
54
+ return [
55
+ {
56
+ stepId: null,
57
+ check: "no steps",
58
+ message: "The workflow has no nodes. Add a trigger or a step."
59
+ }
60
+ ];
61
+ const s = [];
62
+ for (const o of e) {
63
+ const c = b(o, t);
64
+ c && s.push({ stepId: o.id, check: c, message: `${o.id} ${S[c]}` });
65
+ }
66
+ return s;
67
+ }
68
+ function X(n) {
69
+ return n.publishing ? "Publishing…" : n.projectMissing ? "Can't publish: no project is selected." : n.saveBlockedReason ? `Can't publish: ${n.saveBlockedReason}` : n.loading ? "Can't publish yet: the workflow is still loading or saving." : n.catalogLoading ? "Can't publish yet: the node catalog is still loading." : n.problems.length === 0 ? null : [n.problems.length === 1 ? "Can't publish — fix this first:" : `Can't publish — fix these ${n.problems.length} problems first:`, ...n.problems.map((e) => `• ${e.message}`)].join(`
70
+ `);
71
+ }
72
+ function N(n) {
73
+ return n === "active" || n === "archived" ? n : "draft";
74
+ }
75
+ function V(n) {
76
+ const t = n;
77
+ return {
78
+ autoSave: (t == null ? void 0 : t.autoSave) !== !1,
79
+ savePosition: (t == null ? void 0 : t.savePosition) !== !1
80
+ };
81
+ }
82
+ function x(n, t, e) {
83
+ const o = { ...typeof n == "object" && n !== null && !Array.isArray(n) ? n : void 0 };
84
+ return e ? delete o[t] : o[t] = !1, Object.keys(o).length === 0 ? void 0 : o;
85
+ }
86
+ function D(n, t) {
87
+ var o, c;
88
+ const e = y(n), s = [];
89
+ for (const f of e) {
90
+ const l = (o = f.uses) == null ? void 0 : o.app;
91
+ if (!l || !t.isManualTrigger(l)) continue;
92
+ const r = t.asFieldDefs((c = f.with) == null ? void 0 : c.fields).filter((a) => typeof a.key == "string" && a.key.trim() !== "");
93
+ s.push({ id: f.id, label: f.displayName ?? f.id, fields: r });
94
+ }
95
+ return s;
96
+ }
97
+ function M(n) {
98
+ const t = {};
99
+ for (const e of (n == null ? void 0 : n.fields) ?? [])
100
+ if (!(typeof e.key != "string" || e.key.trim() === "")) {
101
+ if (e.default !== void 0) {
102
+ t[e.key] = e.default;
103
+ continue;
104
+ }
105
+ t[e.key] = e.type === "number" ? 0 : e.type === "boolean" ? !1 : "";
106
+ }
107
+ return t;
108
+ }
109
+ const $ = ["var.", "vars."], j = ["const.", "constants."], C = "@w6w/store";
110
+ function p(n) {
111
+ return typeof n == "object" && n !== null && !Array.isArray(n);
112
+ }
113
+ function A(n, t) {
114
+ for (const e of t)
115
+ if (n.startsWith(e)) {
116
+ const s = n.slice(e.length).split(".")[0].trim();
117
+ return s === "" ? void 0 : s;
118
+ }
119
+ }
120
+ function R(n) {
121
+ const t = n.trim(), e = A(t, $);
122
+ if (e) return { category: "var", name: e };
123
+ const s = A(t, j);
124
+ if (s) return { category: "const", name: s };
125
+ }
126
+ function m(n, t) {
127
+ if (Array.isArray(n))
128
+ for (const e of n) m(e, t);
129
+ else if (p(n))
130
+ for (const [e, s] of Object.entries(n))
131
+ if (e === "var" && typeof s == "string") {
132
+ const o = R(s);
133
+ o && t.push(o);
134
+ } else m(s, t);
135
+ }
136
+ function I(n, t) {
137
+ if (n.includes("{{"))
138
+ for (const e of O(n))
139
+ if (e.kind === "var" && typeof e.ref == "string") {
140
+ const s = R(e.ref);
141
+ s && t.push(s);
142
+ } else if (e.kind === "secret" && typeof e.ref == "string") {
143
+ const s = e.ref.trim().split(".")[0];
144
+ s && t.push({ category: "secret", name: s });
145
+ } else e.kind === "expr" && m(e.expr, t);
146
+ }
147
+ function g(n, t) {
148
+ if (typeof n == "string") I(n, t);
149
+ else if (Array.isArray(n)) for (const e of n) g(e, t);
150
+ else if (p(n)) for (const e of Object.values(n)) g(e, t);
151
+ }
152
+ function W(n) {
153
+ const t = p(n.workflow) ? n.workflow : {}, e = Array.isArray(t.nodes) ? t.nodes : Array.isArray(t.steps) ? t.steps : [], s = p(t.connections) ? t.connections : {}, o = /* @__PURE__ */ new Set();
154
+ if (Array.isArray(t.variables))
155
+ for (const r of t.variables)
156
+ p(r) && typeof r.key == "string" && o.add(r.key);
157
+ const c = {
158
+ var: n.lists.vars,
159
+ const: n.lists.constants,
160
+ secret: n.lists.secrets
161
+ }, f = { var: "var", const: "const", secret: "secret" }, l = {};
162
+ for (const r of e) {
163
+ if (!p(r) || typeof r.id != "string") continue;
164
+ const a = [], d = (i) => {
165
+ a.includes(i) || a.push(i);
166
+ }, h = p(r.uses) ? r.uses : {}, u = h.connectionRef;
167
+ if (typeof u == "string" && u !== "" && Object.hasOwn(s, u)) {
168
+ const i = s[u];
169
+ p(i) && (i.connection === null || i.connection === "") && d(`connection "${u}"`);
170
+ }
171
+ const v = p(r.with) ? r.with : {};
172
+ h.app === C && v.store === "" && d("store");
173
+ const w = [];
174
+ g(v, w);
175
+ for (const i of w) {
176
+ const k = c[i.category];
177
+ k.ready && (i.category === "var" && o.has(i.name) || i.category === "const" && i.name === "account_id" || k.names.includes(i.name) || d(`${f[i.category]}.${i.name}`));
178
+ }
179
+ a.length > 0 && (l[r.id] = a);
180
+ }
181
+ return l;
182
+ }
183
+ export {
184
+ W as a,
185
+ q as b,
186
+ N as c,
187
+ F as d,
188
+ D as e,
189
+ T as f,
190
+ x as g,
191
+ y as h,
192
+ B as i,
193
+ X as p,
194
+ V as r,
195
+ P as s,
196
+ M as t,
197
+ _ as w
198
+ };
199
+ //# sourceMappingURL=setup-incomplete-BHs3Lpfy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-incomplete-BHs3Lpfy.js","sources":["../src/lib/binding-problems.ts","../src/lib/workflow-nodes.ts","../src/lib/workflow-validity.ts","../src/lib/workflow-settings.ts","../src/lib/trigger-preview.ts","../src/lib/setup-incomplete.ts"],"sourcesContent":["// Pure detection of dangling connection bindings (R5). No React, no I/O: call sites gather the\n// inputs (per-app connection lists, the callable's enabled flag, draft dirtiness) and render.\n\nexport type AppConnections =\n | { state: \"loading\" }\n | { state: \"error\" }\n | { state: \"ready\"; ids: ReadonlySet<string> };\n\nexport interface BindingSite {\n id: string;\n uses?: { app?: string; connection?: string | null; connectionRef?: string };\n}\n\nexport interface BindingProblem {\n siteId: string;\n app: string;\n connection: string;\n code: \"unknown_connection\";\n}\n\n/** A problem iff app + connection are non-empty and the app's list is `ready` without the id.\n * `loading`, `error` and `undefined` (internal app / not fetched) never report — no false red. */\nexport function findBindingProblems(\n sites: readonly BindingSite[],\n byApp: (app: string) => AppConnections | undefined,\n connections?: Record<string, { app: string; connection: string | null }>,\n): BindingProblem[] {\n const out: BindingProblem[] = [];\n for (const site of sites) {\n const app = site.uses?.app;\n const ref = site.uses?.connectionRef;\n const binding =\n ref && connections && Object.hasOwn(connections, ref) ? connections[ref] : undefined;\n const connection =\n ref === undefined\n ? site.uses?.connection\n : binding && binding.app === app\n ? binding.connection\n : undefined;\n if (typeof app !== \"string\" || app === \"\") continue;\n if (typeof connection !== \"string\" || connection === \"\") continue;\n const conns = byApp(app);\n if (conns?.state !== \"ready\") continue;\n if (conns.ids.has(connection)) continue;\n out.push({ siteId: site.id, app, connection, code: \"unknown_connection\" });\n }\n return out;\n}\n\nexport interface DisabledBannerInput {\n enabled: boolean | undefined;\n problemCount: number;\n dirty: boolean;\n hadProblems: boolean;\n}\n\nexport interface DisabledBannerState {\n show: boolean;\n canEnable: boolean;\n problemCount: number;\n}\n\n/** Show iff disabled AND (problems now OR problems seen this mount). Enable only once every\n * binding is fixed AND saved. `enabled` undefined (versions not loaded) never shows. */\nexport function disabledBannerState(input: DisabledBannerInput): DisabledBannerState {\n const show = input.enabled === false && (input.problemCount > 0 || input.hadProblems);\n return {\n show,\n canEnable: show && input.problemCount === 0 && !input.dirty,\n problemCount: input.problemCount,\n };\n}\n","/** The vertex array of a workflow definition, in either shape — `nodes` wins, `steps` is the legacy name. */\nexport function workflowNodes<T = unknown>(\n def: { nodes?: T[]; steps?: T[] } | null | undefined,\n): T[] {\n return def?.nodes ?? def?.steps ?? [];\n}\n","import { workflowNodes } from \"./workflow-nodes.ts\";\n\n/**\n * The publish-time validity gate (`logs/decisions.jsonl` row 9, verbatim):\n *\n * > a step is valid iff (app+action set, or function id set) and all its\n * > required params are filled (reuse `requiredParamsFilled`,\n * > `StepBuilderModal.tsx:577-590`) and, where `testRequired` is set for the\n * > app, its saved test has passed. The workflow is valid iff a trigger exists\n * > and every step is valid. Graph well-formedness (orphaned/unreachable\n * > nodes, dangling edges) is explicitly OUT of scope for this project.\n *\n * **Amended 2026-10-29: no trigger NODE is required.** A workflow without one is\n * a manual workflow (`rfcs/workflow.md:114`): it already runs from the editor's\n * Run button and from code, and the server publishes it, so gating Publish on a\n * trigger node only blocked a workflow that works. The workflow is now valid iff\n * it has at least one step and every step is valid.\n *\n * **Amended 2026-11-01: an app trigger node is never test-gated.** A node with\n * `uses.trigger: true` runs when its app reports the event; its Test tab has\n * nothing to run by hand (\"Publish the workflow to start listening\",\n * `AppTriggerTestNote` in `@w6w/ui`), so it can never hold a saved passing\n * test. Gating it on one made every app-triggered workflow unpublishable.\n *\n * **Amended 2026-11-02: tests never gate publishing.** Successful runs and saved\n * test records can disagree, and users may publish without testing. Only the\n * target and required configuration are checked; test history is advisory.\n *\n * Pure and testable by design: `WorkflowsPage.tsx` is JSX, which Node 24's\n * type-stripping cannot parse, so nothing in it can be loaded by `node --test`\n * (same shape as `src/lib/workflow-save.ts` + its `.test.ts`). This module\n * cannot import `@w6w/ui`/`@w6w/ui/flow` either way: `@w6w/ui`'s\n * `package.json` `exports[\".\"]` resolves to raw `./src/index.ts`, which\n * re-exports `StepBuilderModal.tsx` — a `.tsx` file — so `node --test` throws\n * `ERR_UNKNOWN_FILE_EXTENSION` the moment anything here imports it. Instead,\n * the two functions the pinned predicate reuses\n * (`requiredParamsFilled`/`isTestRequired`) are **caller-injected** on\n * `ValidityContext` — `WorkflowsPage.tsx` (unaffected by the JSX constraint)\n * imports the real ones from `@w6w/ui` and passes them in.\n *\n * `ActionParamLike`/`WorkflowStepLike`/`WorkflowLike` below are this file's\n * own minimal local types (see `rfcs/workflow.md` §\"Step\" for the real shape,\n * `rfcs/function.md` for the `uses.function` arm).\n */\n\n/** A declared action/internal-node param, just enough of it for this gate. */\nexport interface ActionParamLike {\n key: string;\n type: string;\n required?: boolean;\n default?: unknown;\n children?: ActionParamLike[];\n}\n\n/** A workflow graph step, just enough of it for this gate. */\nexport interface WorkflowStepLike {\n id: string;\n uses?: {\n app?: string;\n action?: string;\n connection?: string | null;\n connectionRef?: string;\n /** The \"or a function id\" arm (`rfcs/function.md:49,260`) — `Step.uses.function`. */\n function?: string;\n /** An app trigger node (`uses.trigger: true`): never gated on a saved test. */\n trigger?: boolean;\n };\n with?: Record<string, unknown>;\n}\n\n/** A workflow definition, just enough of it for this gate. */\nexport interface WorkflowLike {\n nodes?: WorkflowStepLike[];\n steps?: WorkflowStepLike[];\n /**\n * Present on real definitions, never read here — graph well-formedness\n * (orphaned/unreachable nodes, dangling edges) is explicitly out of scope\n * for the publish gate (`logs/decisions.jsonl` row 9).\n */\n edges?: unknown;\n}\n\n/**\n * Everything `stepValid`/`workflowValid`/`invalidReason` need that this pure\n * module cannot compute or import itself — see the module docstring for why\n * each field is caller-built rather than derived in here.\n */\nexport interface ValidityContext {\n /** Declared params for a step's target, keyed `` `${app}::${action}` ``. */\n actionParamsByKey: Record<string, ActionParamLike[]>;\n /** @deprecated Kept for caller compatibility; app test policy does not gate publishing. */\n appsById: Record<string, unknown>;\n /** @deprecated Kept for caller compatibility; test results do not gate publishing. */\n testStatus: Record<string, boolean>;\n /** `@w6w/ui`'s `requiredParamsFilled`, injected (see module docstring). */\n requiredParamsFilled: (params: ActionParamLike[], values: Record<string, unknown>) => boolean;\n /** @deprecated Kept for caller compatibility; never consulted for publishing. */\n isTestRequired: (app: unknown) => boolean;\n}\n\n/** Which of the pinned predicate's checks a step fails, or `null` when it's valid. */\ntype StepFailure = \"target missing\" | \"required params\";\n\n/**\n * The single place the pinned predicate's branching lives — `stepValid` and\n * `invalidReason` both read this rather than re-deriving the same checks.\n */\nfunction stepFailure(step: WorkflowStepLike, ctx: ValidityContext): StepFailure | null {\n const uses = step.uses;\n // A function-targeted step is valid on presence alone (T5.1.1 owns a\n // Function's own runnability separately — not duplicated here).\n if (uses?.function) return null;\n if (!uses?.app || !uses?.action) return \"target missing\";\n const params = ctx.actionParamsByKey[`${uses.app}::${uses.action}`] ?? [];\n const values = step.with ?? {};\n if (!ctx.requiredParamsFilled(params, values)) return \"required params\";\n return null;\n}\n\n/** Is this one step valid, per the pinned predicate? */\nexport function stepValid(step: WorkflowStepLike, ctx: ValidityContext): boolean {\n return stepFailure(step, ctx) === null;\n}\n\n/**\n * Is the whole workflow valid? It must have at least one step and every step\n * must be individually valid — a trigger node is not required, and nothing\n * about graph well-formedness is checked (this never reads `workflow.edges`).\n */\nexport function workflowValid(workflow: WorkflowLike, ctx: ValidityContext): boolean {\n const steps = workflowNodes(workflow);\n return steps.length > 0 && steps.every((step) => stepValid(step, ctx));\n}\n\n/**\n * `null` when the workflow is valid; otherwise names the cause — `\"no steps\"`,\n * or the id of the first invalid step in declared order plus which check it\n * fails.\n */\nexport function invalidReason(workflow: WorkflowLike, ctx: ValidityContext): string | null {\n const steps = workflowNodes(workflow);\n if (steps.length === 0) return \"no steps\";\n for (const step of steps) {\n const failure = stepFailure(step, ctx);\n if (failure) return `${step.id}: ${failure}`;\n }\n return null;\n}\n\n/** One reason the workflow cannot be published: the node it is about and how to fix it. */\nexport interface PublishProblem {\n /** The node's id, or `null` for a workflow-wide problem (`\"no steps\"`). */\n stepId: string | null;\n check: StepFailure | \"no steps\";\n /** Names the node and says how to fix it — shown verbatim in the tooltip and the list. */\n message: string;\n}\n\nconst FIX_TEXT: Record<StepFailure, string> = {\n \"target missing\": \"has no action or function chosen. Open it and pick what it runs.\",\n \"required params\": \"has required fields left empty. Open it and fill them in.\",\n};\n\n/**\n * Every publish problem, in declared node order — the full list `invalidReason`\n * stops at the first of. Empty iff `workflowValid`.\n */\nexport function publishProblems(workflow: WorkflowLike, ctx: ValidityContext): PublishProblem[] {\n const steps = workflowNodes(workflow);\n if (steps.length === 0) {\n return [\n {\n stepId: null,\n check: \"no steps\",\n message: \"The workflow has no nodes. Add a trigger or a step.\",\n },\n ];\n }\n const out: PublishProblem[] = [];\n for (const step of steps) {\n const failure = stepFailure(step, ctx);\n if (failure) {\n out.push({ stepId: step.id, check: failure, message: `${step.id} ${FIX_TEXT[failure]}` });\n }\n }\n return out;\n}\n\n/** What the header Publish button's `disabled` reads, each cause kept apart for its reason. */\nexport interface PublishGate {\n /** No project to publish into. */\n projectMissing: boolean;\n /** The draft has not loaded, is saving, or is switching context. */\n loading: boolean;\n /** The draft refuses to save (and so to publish): its reason, verbatim. */\n saveBlockedReason: string | null;\n /** The node catalog the validity gate needs has not arrived yet. */\n catalogLoading: boolean;\n problems: readonly PublishProblem[];\n publishing: boolean;\n}\n\n/**\n * Why Publish is disabled, or `null` when it is enabled. Every disabled state\n * has a reason, so the button never greys out silently.\n */\nexport function publishDisabledReason(g: PublishGate): string | null {\n if (g.publishing) return \"Publishing…\";\n if (g.projectMissing) return \"Can't publish: no project is selected.\";\n if (g.saveBlockedReason) return `Can't publish: ${g.saveBlockedReason}`;\n if (g.loading) return \"Can't publish yet: the workflow is still loading or saving.\";\n if (g.catalogLoading) return \"Can't publish yet: the node catalog is still loading.\";\n if (g.problems.length === 0) return null;\n const head =\n g.problems.length === 1\n ? \"Can't publish — fix this first:\"\n : `Can't publish — fix these ${g.problems.length} problems first:`;\n return [head, ...g.problems.map((p) => `• ${p.message}`)].join(\"\\n\");\n}\n","/**\n * The two pure decisions behind a workflow's authoring settings\n * (`rfcs/workflow.md` — \"Amendment — 2026-07-29: authoring presentation\").\n *\n * `settings` rides inside the workflow **definition** — the same JSON document\n * that already carries `steps` — so there is no column, no migration and no\n * server change behind it. What needs pinning is not the storage but the two\n * readings that can silently corrupt a definition, and both live here rather\n * than in `WorkflowsPage.tsx` so they are executable: that file is JSX, which\n * Node 24's type-stripping cannot parse, so nothing in it can be loaded by\n * `node --test`. Same shape as `src/lib/workflow-save.ts` + its `.test.ts`.\n */\nimport type { WorkflowStatus } from \"@w6w/sdk\";\n\n/**\n * Read a workflow definition's `status` field as the real three-state value.\n *\n * `WorkflowsPage.tsx` used to coerce this with `status === \"active\" ? \"active\" :\n * \"draft\"` — a two-way ternary that silently collapsed a freshly-archived\n * workflow back down to `\"draft\"`, which would have reproduced the same bug one\n * layer up in the archive/delete button-swap (an archived workflow would render\n * Archive again instead of Delete). `unknown` because the source is parsed JSON,\n * not a validated value — anything that isn't exactly `\"active\"` or `\"archived\"`\n * reads as `\"draft\"`, same fallback the old coercion used for a missing/garbage\n * status.\n */\nexport function readWorkflowStatus(status: unknown): WorkflowStatus {\n if (status === \"active\" || status === \"archived\") return status;\n return \"draft\";\n}\n\n/** Authoring presentation for one workflow. Declarative only — the engine ignores it. */\nexport type WorkflowSettings = {\n /** Persist edits without an explicit save. Omitted ⇒ **true**. */\n autoSave?: boolean;\n /** Persist step coordinates and `viewport` on save. Omitted ⇒ **true**. */\n savePosition?: boolean;\n /** The canvas camera, written by the editor — never by the settings modal. */\n viewport?: { x: number; y: number; zoom: number };\n};\n\n/** Both flags resolved against their defaults. */\nexport type EffectiveWorkflowSettings = {\n autoSave: boolean;\n savePosition: boolean;\n};\n\n/**\n * The effective flags for a workflow, applying the **true-by-default** rule.\n *\n * ⚠️ Both flags are `true` when omitted. That is deliberately *unlike* the house\n * convention `ports` and `onError` follow, where an absent field reproduces\n * prior behaviour: here the product requires both features on by default, so an\n * absent `settings` object means auto-save **on** and positions **persisted**.\n * The RFC states it three ways and names `?? false` as a contradiction. Only an\n * explicit `false` turns a feature off — hence `!== false`, which also refuses\n * to read `null`, `0` or `\"false\"` out of a hand-edited definition as \"off\".\n *\n * Takes `unknown` because the caller's source is parsed JSON, not a validated\n * value; every non-object reads as \"no flags set\", i.e. both on.\n */\nexport function readSettings(settings: unknown): EffectiveWorkflowSettings {\n const s = settings as WorkflowSettings | undefined;\n return {\n autoSave: s?.autoSave !== false,\n savePosition: s?.savePosition !== false,\n };\n}\n\n/**\n * Set one flag, returning the `settings` object to store.\n *\n * Two rules, both about *not* writing more than was asked:\n *\n * 1. **The default is written as absent.** `true` deletes the key instead of\n * storing `autoSave: true` (the same idiom as an omitted `onError: \"fail\"`).\n * Otherwise merely opening this modal on a legacy workflow and toggling\n * something back would rewrite the definition of every workflow ever\n * authored — and with auto-save on, that write happens by itself.\n * 2. **Everything else survives verbatim**, `viewport` above all: it is the\n * author's saved camera, written by the editor, and a whole-object replace\n * here would silently discard it on the next toggle.\n *\n * Returns `undefined` when nothing is left to store, so the caller drops the\n * key entirely rather than persisting an empty object.\n *\n * The input is `unknown` for the same reason `readSettings`' is — it comes straight\n * out of `JSON.parse`, and the `</>` editor in the very same header lets an author\n * write `\"settings\": \"hello\"`. Spreading that would persist `{\"0\":\"h\",\"1\":\"e\",…}`,\n * and with auto-save on the rewrite would repeat on a debounce, without anyone\n * clicking anything. So anything that is not a plain object reads as \"no flags\n * set\", exactly as it does in `readSettings`.\n */\nexport function writeSetting(\n settings: unknown,\n key: \"autoSave\" | \"savePosition\",\n value: boolean,\n): WorkflowSettings | undefined {\n const prev: WorkflowSettings | undefined =\n typeof settings === \"object\" && settings !== null && !Array.isArray(settings)\n ? (settings as WorkflowSettings)\n : undefined;\n // The copy is load-bearing: a debounced saver keeps payloads across ticks, so a\n // function that mutated `prev` in place would leave a \"has this actually changed?\"\n // comparison looking at one object twice. Never simplify this to `prev ?? {}`.\n const next: WorkflowSettings = { ...prev };\n if (value) delete next[key];\n else next[key] = false;\n return Object.keys(next).length === 0 ? undefined : next;\n}\n","import { workflowNodes } from \"./workflow-nodes.ts\";\n\n/**\n * \"Call from code\" trigger preview (T2.2.1, HITL-2/HITL-4 pinned):\n *\n * > one tab per MANUAL (`@w6w/trigger`) trigger step, in declared order,\n * > labelled `step.displayName ?? step.id`. Webhook/scheduler steps are\n * > excluded — they declare named params, never a generic `fields` array.\n *\n * Pure and testable by design, same shape as `workflow-validity.ts`:\n * `WorkflowDetailPage.tsx`/`WorkflowsPage.tsx` are JSX, which Node 24's\n * type-stripping cannot parse, so nothing in it can be loaded by\n * `node --test`. This module cannot import `@w6w/ui`/`@w6w/ui/flow` either\n * way (`ERR_UNKNOWN_FILE_EXTENSION` — see `workflow-validity.ts`'s docstring).\n * Instead, \"is this step a MANUAL trigger\" and \"read a trigger's declared\n * `fields`\" are **caller-injected** on `TriggerPreviewContext` —\n * `WorkflowsPage.tsx`/`WorkflowDetailPage.tsx` import the real\n * `TRIGGER_APP`/`asFieldDefs` from `@w6w/ui/flow` and pass them in. This file\n * contains no `@w6w/*` app-id string literal.\n *\n * Deliberately narrower than `@w6w/ui/flow`'s own `isTriggerApp`, which also\n * matches `@w6w/webhook`/`@w6w/scheduler` (all three are \"entry nodes\" for the\n * canvas). Those two kinds declare named params, not a generic `fields`\n * array, so they cannot be previewed the same way — the injected predicate a\n * caller supplies here is expected to be the MANUAL-only check\n * (`app === TRIGGER_APP`), not the broader `isTriggerApp`.\n */\n\n/** One field a trigger declares — just enough of `@w6w/ui/flow`'s\n * `TriggerFieldDef` for this preview (structurally compatible, not imported). */\nexport interface TriggerPreviewFieldDef {\n key?: string;\n type?: string;\n required?: boolean;\n default?: unknown;\n}\n\n/** A workflow graph step, just enough of it for this preview. */\nexport interface WorkflowStepLike {\n id: string;\n /** Human-facing step name, when the author set one. Falls back to `id`. */\n displayName?: string;\n uses?: { app?: string; action?: string };\n with?: Record<string, unknown>;\n}\n\n/** A workflow definition, just enough of it for this preview. */\nexport interface WorkflowLike {\n nodes?: WorkflowStepLike[];\n steps?: WorkflowStepLike[];\n}\n\n/**\n * Everything `triggerPreviews` needs that this pure module cannot compute or\n * import itself — see the module docstring for why each field is\n * caller-injected rather than derived in here.\n */\nexport interface TriggerPreviewContext {\n /** Is this step's `uses.app` a MANUAL trigger (`@w6w/trigger`)? Webhook and\n * scheduler steps must answer `false` here even though they are also\n * \"entry nodes\" — they have no generic `fields` array to preview. */\n isManualTrigger: (app: string) => boolean;\n /** `@w6w/ui/flow`'s `asFieldDefs`, injected — reads a step's `with.fields`\n * param value as an array of field definitions. */\n asFieldDefs: (fields: unknown) => TriggerPreviewFieldDef[];\n}\n\n/** One manual trigger's declared fields, ready for the modal's picker. */\nexport interface TriggerPreview {\n id: string;\n /** `step.displayName ?? step.id`. */\n label: string;\n fields: TriggerPreviewFieldDef[];\n}\n\n/**\n * One `TriggerPreview` per manual trigger step in `workflow.steps`, in\n * declared order. Non-manual steps (including webhook/scheduler entry nodes)\n * are excluded. A field with a missing/blank `key` is dropped — mirrors\n * `@w6w/ui/flow`'s `fieldsToParams`, which does the same before turning\n * `TriggerFieldDef[]` into a fillable form.\n */\nexport function triggerPreviews(\n workflow: WorkflowLike,\n ctx: TriggerPreviewContext,\n): TriggerPreview[] {\n const steps = workflowNodes(workflow);\n const previews: TriggerPreview[] = [];\n for (const step of steps) {\n const app = step.uses?.app;\n if (!app || !ctx.isManualTrigger(app)) continue;\n const fields = ctx\n .asFieldDefs(step.with?.fields)\n .filter((f) => typeof f.key === \"string\" && f.key.trim() !== \"\");\n previews.push({ id: step.id, label: step.displayName ?? step.id, fields });\n }\n return previews;\n}\n\n/**\n * A start-payload skeleton for one manual trigger — every declared field at its\n * declared default, so the Run panel opens with the shape the workflow actually\n * expects instead of an empty object the author has to reconstruct by hand.\n *\n * Mirrors `@w6w/ui/flow`'s `seedValues` (which this module cannot import — see\n * the header): an explicit `default` wins; otherwise the empty value for the\n * declared type. Unknown types fall to `\"\"`, matching that function.\n *\n * `undefined` in → `{}`, so a caller can pass a still-loading preview.\n */\nexport function triggerInputSeed(preview: TriggerPreview | undefined): Record<string, unknown> {\n const seed: Record<string, unknown> = {};\n for (const f of preview?.fields ?? []) {\n if (typeof f.key !== \"string\" || f.key.trim() === \"\") continue;\n if (f.default !== undefined) {\n seed[f.key] = f.default;\n continue;\n }\n seed[f.key] = f.type === \"number\" ? 0 : f.type === \"boolean\" ? false : \"\";\n }\n return seed;\n}\n","import { parseTemplate } from \"@w6w/expr\";\n\n// Pure detector for a saved workflow's incomplete setup (plan IF-1 unconfigured shape).\n// No React, no I/O, no @w6w/ui value imports. S2/S3 implement the body; the contract is here.\n\n/** A name list for one category; `ready:false` (loading/errored) means that category is never flagged. */\nexport interface SetupNameList {\n names: string[];\n ready: boolean;\n}\n\nexport interface SetupIncompleteInput {\n /** The parsed saved workflow (nodes, connections, variables, …). */\n workflow: unknown;\n lists: {\n vars: SetupNameList;\n secrets: SetupNameList;\n constants: SetupNameList;\n stores: SetupNameList;\n };\n}\n\n/** Node id -> human labels of what is missing at that node (e.g. `connection \"gmail\"`, `var.x`). */\nexport type SetupIncompleteResult = Record<string, string[]>;\n\nconst VAR_PREFIXES = [\"var.\", \"vars.\"];\nconst CONST_PREFIXES = [\"const.\", \"constants.\"];\nconst STORE_APP = \"@w6w/store\";\n\ntype Category = \"var\" | \"const\" | \"secret\";\ninterface Ref {\n category: Category;\n name: string;\n}\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction nameOf(path: string, prefixes: string[]): string | undefined {\n for (const p of prefixes) {\n if (path.startsWith(p)) {\n const name = path.slice(p.length).split(\".\")[0].trim();\n return name === \"\" ? undefined : name;\n }\n }\n return undefined;\n}\n\nfunction pathRef(path: string): Ref | undefined {\n const t = path.trim();\n const v = nameOf(t, VAR_PREFIXES);\n if (v) return { category: \"var\", name: v };\n const c = nameOf(t, CONST_PREFIXES);\n if (c) return { category: \"const\", name: c };\n return undefined;\n}\n\n/** `{ var: \"<path>\" }` operands inside a parsed expr (chains and `{{= … }}` JSONLogic). */\nfunction exprRefs(expr: unknown, out: Ref[]): void {\n if (Array.isArray(expr)) {\n for (const e of expr) exprRefs(e, out);\n } else if (isRecord(expr)) {\n for (const [k, v] of Object.entries(expr)) {\n if (k === \"var\" && typeof v === \"string\") {\n const r = pathRef(v);\n if (r) out.push(r);\n } else exprRefs(v, out);\n }\n }\n}\n\n/** Refs in one string, via the template parser (text outside `{{ }}` never yields a part). */\nfunction stringRefs(s: string, out: Ref[]): void {\n if (!s.includes(\"{{\")) return;\n for (const part of parseTemplate(s)) {\n if (part.kind === \"var\" && typeof part.ref === \"string\") {\n const r = pathRef(part.ref);\n if (r) out.push(r);\n } else if (part.kind === \"secret\" && typeof part.ref === \"string\") {\n const name = part.ref.trim().split(\".\")[0];\n if (name) out.push({ category: \"secret\", name });\n } else if (part.kind === \"expr\") exprRefs(part.expr, out);\n }\n}\n\nfunction walk(v: unknown, out: Ref[]): void {\n if (typeof v === \"string\") stringRefs(v, out);\n else if (Array.isArray(v)) for (const e of v) walk(e, out);\n else if (isRecord(v)) for (const e of Object.values(v)) walk(e, out);\n}\n\n/**\n * Derive what is unconfigured in a saved workflow (plan IF-1 shape), keyed by node id.\n * A category whose list is not `ready` is never flagged.\n */\nexport function findSetupIncomplete(input: SetupIncompleteInput): SetupIncompleteResult {\n const wf = isRecord(input.workflow) ? input.workflow : {};\n const nodes = Array.isArray(wf.nodes) ? wf.nodes : Array.isArray(wf.steps) ? wf.steps : [];\n const conns = isRecord(wf.connections) ? wf.connections : {};\n const local = new Set<string>();\n if (Array.isArray(wf.variables)) {\n for (const v of wf.variables) {\n if (isRecord(v) && typeof v.key === \"string\") local.add(v.key);\n }\n }\n const known = {\n var: input.lists.vars,\n const: input.lists.constants,\n secret: input.lists.secrets,\n };\n const label = { var: \"var\", const: \"const\", secret: \"secret\" } as const;\n const result: SetupIncompleteResult = {};\n for (const node of nodes) {\n if (!isRecord(node) || typeof node.id !== \"string\") continue;\n const items: string[] = [];\n const add = (s: string) => {\n if (!items.includes(s)) items.push(s);\n };\n const uses = isRecord(node.uses) ? node.uses : {};\n const ref = uses.connectionRef;\n if (typeof ref === \"string\" && ref !== \"\" && Object.hasOwn(conns, ref)) {\n const c = conns[ref];\n if (isRecord(c) && (c.connection === null || c.connection === \"\")) {\n add(`connection \"${ref}\"`);\n }\n }\n const withObj = isRecord(node.with) ? node.with : {};\n if (uses.app === STORE_APP && withObj.store === \"\") add(\"store\");\n const refs: Ref[] = [];\n walk(withObj, refs);\n for (const r of refs) {\n const list = known[r.category];\n if (!list.ready) continue;\n if (r.category === \"var\" && local.has(r.name)) continue;\n if (r.category === \"const\" && r.name === \"account_id\") continue;\n if (!list.names.includes(r.name)) add(`${label[r.category]}.${r.name}`);\n }\n if (items.length > 0) result[node.id] = items;\n }\n return result;\n}\n"],"names":["findBindingProblems","sites","byApp","connections","out","site","app","_a","ref","_b","binding","connection","_c","conns","disabledBannerState","input","show","workflowNodes","def","stepFailure","step","ctx","uses","params","values","stepValid","workflowValid","workflow","steps","invalidReason","failure","FIX_TEXT","publishProblems","publishDisabledReason","g","p","readWorkflowStatus","status","readSettings","settings","s","writeSetting","key","value","next","triggerPreviews","previews","fields","f","triggerInputSeed","preview","seed","VAR_PREFIXES","CONST_PREFIXES","STORE_APP","isRecord","v","nameOf","path","prefixes","name","pathRef","c","exprRefs","expr","k","r","stringRefs","part","parseTemplate","walk","findSetupIncomplete","wf","nodes","local","known","label","result","node","items","add","withObj","refs","list"],"mappings":";AAsBO,SAASA,EACdC,GACAC,GACAC,GACkB;;AAClB,QAAMC,IAAwB,CAAA;AAC9B,aAAWC,KAAQJ,GAAO;AACxB,UAAMK,KAAMC,IAAAF,EAAK,SAAL,gBAAAE,EA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