@powerhousedao/workflow 6.2.3-dev.33 → 6.2.3-dev.35

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 (63) hide show
  1. package/dist/browser/BlockSelector-M4p5MOwM.js +7611 -0
  2. package/dist/browser/BlockSelector-M4p5MOwM.js.map +1 -0
  3. package/dist/browser/assets/{entry-D62sYiFV.js → entry-DPGDRzne.js} +5 -2
  4. package/dist/browser/assets/{projection-entry-BGcu_9-p.js → projection-entry-EcOymKPg.js} +42 -6
  5. package/dist/browser/{connection-form-Br-IM_CW.js → connection-form-Bh7ONQxz.js} +20 -21
  6. package/dist/browser/connection-form-Bh7ONQxz.js.map +1 -0
  7. package/dist/browser/{data-tree-CZZkfzSH.js → data-tree-Bicz9eW6.js} +2 -2
  8. package/dist/browser/{data-tree-CZZkfzSH.js.map → data-tree-Bicz9eW6.js.map} +1 -1
  9. package/dist/browser/{editor-DjSMG-EP.js → editor-B0YlNGFs.js} +3 -3
  10. package/dist/browser/{editor-DjSMG-EP.js.map → editor-B0YlNGFs.js.map} +1 -1
  11. package/dist/browser/{editor-p9gVC4FY.js → editor-CYKLDgER.js} +26 -11
  12. package/dist/browser/editor-CYKLDgER.js.map +1 -0
  13. package/dist/browser/{editor-CtErqBMO.js → editor-DgCrC5jt.js} +3 -3
  14. package/dist/browser/{editor-CtErqBMO.js.map → editor-DgCrC5jt.js.map} +1 -1
  15. package/dist/browser/editors/connection-editor/module.js +1 -1
  16. package/dist/browser/editors/workflow-editor/module.js +1 -1
  17. package/dist/browser/editors/workflow-studio/module.js +1 -1
  18. package/dist/browser/index.js +3 -2
  19. package/dist/browser/index.js.map +1 -1
  20. package/dist/browser/{trigger-text-D-Sh6ZaI.js → trigger-text-DEN9d_Np.js} +4 -4
  21. package/dist/browser/{trigger-text-D-Sh6ZaI.js.map → trigger-text-DEN9d_Np.js.map} +1 -1
  22. package/dist/node/BlockSelector-oFCoEF5-.mjs +7615 -0
  23. package/dist/node/BlockSelector-oFCoEF5-.mjs.map +1 -0
  24. package/dist/node/{connection-form-Dzn4yM2g.mjs → connection-form-BpEzDxCH.mjs} +20 -21
  25. package/dist/node/connection-form-BpEzDxCH.mjs.map +1 -0
  26. package/dist/node/{data-tree-CGfeCLr7.mjs → data-tree-B7JQu1SB.mjs} +2 -2
  27. package/dist/node/{data-tree-CGfeCLr7.mjs.map → data-tree-B7JQu1SB.mjs.map} +1 -1
  28. package/dist/node/{editor-CcbIharn.mjs → editor-BM7pThg7.mjs} +3 -3
  29. package/dist/node/{editor-CcbIharn.mjs.map → editor-BM7pThg7.mjs.map} +1 -1
  30. package/dist/node/{editor-DWzOzXQC.mjs → editor-CzKE95pe.mjs} +26 -11
  31. package/dist/node/editor-CzKE95pe.mjs.map +1 -0
  32. package/dist/node/{editor-Cv2Vn_A-.mjs → editor-UKph34A9.mjs} +3 -3
  33. package/dist/node/{editor-Cv2Vn_A-.mjs.map → editor-UKph34A9.mjs.map} +1 -1
  34. package/dist/node/editors/connection-editor/module.mjs +1 -1
  35. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  36. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  37. package/dist/node/index.mjs +3 -2
  38. package/dist/node/index.mjs.map +1 -1
  39. package/dist/node/pieces/reactor/descriptor.json +1 -1
  40. package/dist/node/pieces/reactor/package.json +1 -1
  41. package/dist/node/{trigger-text-CZEtYmPw.mjs → trigger-text-5wi1Ve6Z.mjs} +4 -4
  42. package/dist/node/{trigger-text-CZEtYmPw.mjs.map → trigger-text-5wi1Ve6Z.mjs.map} +1 -1
  43. package/dist/powerhouse.manifest.json +1 -1
  44. package/dist/types/ai/workflow-tools.d.ts.map +1 -1
  45. package/dist/types/editors/shared/editor-chrome.d.ts.map +1 -1
  46. package/dist/types/editors/shared/undo-plan.d.ts +1 -1
  47. package/dist/types/editors/shared/undo-plan.d.ts.map +1 -1
  48. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  49. package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
  50. package/dist/types/editors/workflow-editor/undo-policy.d.ts +3 -0
  51. package/dist/types/editors/workflow-editor/undo-policy.d.ts.map +1 -0
  52. package/dist/types/editors/workflow-editor/undo-policy.test.d.ts +2 -0
  53. package/dist/types/editors/workflow-editor/undo-policy.test.d.ts.map +1 -0
  54. package/dist/types/scripts/ui-stack.d.ts.map +1 -1
  55. package/package.json +8 -8
  56. package/dist/browser/BlockSelector-BQDqIbRZ.js +0 -3053
  57. package/dist/browser/BlockSelector-BQDqIbRZ.js.map +0 -1
  58. package/dist/browser/connection-form-Br-IM_CW.js.map +0 -1
  59. package/dist/browser/editor-p9gVC4FY.js.map +0 -1
  60. package/dist/node/BlockSelector-C3XYZfPY.mjs +0 -3057
  61. package/dist/node/BlockSelector-C3XYZfPY.mjs.map +0 -1
  62. package/dist/node/connection-form-Dzn4yM2g.mjs.map +0 -1
  63. package/dist/node/editor-DWzOzXQC.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { o as packageFromConnectorId } from "./piece-auth-BS5CtQOG.js";
2
2
  import { tt as stepBlock } from "./runtime-queries-Ds2kk-Ow.js";
3
- import { It as DocumentErrorBoundary, Pt as Icon, bt as Button, nt as formatWhen, pt as usePieceCatalog, t as BlockLogo, ut as WorkflowRuntimeProvider, vt as useRuntimeActions } from "./BlockSelector-BQDqIbRZ.js";
3
+ import { It as DocumentErrorBoundary, Pt as Icon, bt as Button, nt as formatWhen, pt as usePieceCatalog, t as BlockLogo, ut as WorkflowRuntimeProvider, vt as useRuntimeActions } from "./BlockSelector-M4p5MOwM.js";
4
4
  import { i as useSelectedConnectionDocument } from "./connection-BUum0hJI.js";
5
5
  import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-BxShRhVy.js";
6
- import { a as BackButton, i as connectionCallbacks, n as CONNECTION_STATUS_LABEL, o as UndoRedo, r as CONNECTION_STATUS_STYLES, t as ConnectionForm } from "./connection-form-Br-IM_CW.js";
6
+ import { a as BackButton, i as connectionCallbacks, n as CONNECTION_STATUS_LABEL, o as UndoRedo, r as CONNECTION_STATUS_STYLES, t as ConnectionForm } from "./connection-form-Bh7ONQxz.js";
7
7
  import { useState } from "react";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { setSelectedNode, showDeleteNodeModal, useSelectedDocumentId } from "@powerhousedao/reactor-browser";
@@ -244,4 +244,4 @@ function Editor() {
244
244
  //#endregion
245
245
  export { Editor as default };
246
246
 
247
- //# sourceMappingURL=editor-CtErqBMO.js.map
247
+ //# sourceMappingURL=editor-DgCrC5jt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-CtErqBMO.js","names":[],"sources":["../../editors/connection-editor/connection-usage.ts","../../editors/connection-editor/ConnectionToolbar.tsx","../../editors/connection-editor/UsedBy.tsx","../../editors/connection-editor/editor.tsx"],"sourcesContent":["// Which workflows depend on a connection, and where. Answers the question a\n// connection page has to answer before anyone dares revoke or delete it.\n\nexport interface UsageStep {\n id: string;\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n}\n\nexport interface UsageWorkflow {\n id: string;\n name: string;\n status: string;\n trigger?: { connectionId?: string | null } | null;\n steps: readonly UsageStep[];\n}\n\nexport interface ConnectionUsage {\n workflow: UsageWorkflow;\n // The trigger binds this connection.\n trigger: boolean;\n steps: UsageStep[];\n}\n\nexport function connectionUsage(\n connectionId: string,\n workflows: readonly UsageWorkflow[],\n): ConnectionUsage[] {\n const usage: ConnectionUsage[] = [];\n for (const workflow of workflows) {\n const trigger = workflow.trigger?.connectionId === connectionId;\n const steps = workflow.steps.filter(\n (step) =>\n (step as { connectionId?: string | null }).connectionId ===\n connectionId,\n );\n if (trigger || steps.length > 0) usage.push({ workflow, trigger, steps });\n }\n return usage.sort((a, b) => a.workflow.name.localeCompare(b.workflow.name));\n}\n\n// An enabled workflow that depends on this connection breaks the moment it is\n// revoked, so the UI warns before that happens.\nexport function enabledDependents(usage: ConnectionUsage[]): number {\n return usage.filter((entry) => entry.workflow.status === \"ENABLED\").length;\n}\n","// Connection identity and state, in the same shape as the workflow editor's\n// toolbar: name, connector, status, and the one destructive action.\nimport { useState } from \"react\";\nimport type { ConnectionState } from \"document-models/connection\";\nimport type { ConnectionCheckResult } from \"../workflow-editor/runtime-client.js\";\nimport {\n usePieceCatalog,\n useRuntimeActions,\n} from \"../workflow-editor/runtime-context.js\";\nimport { packageFromConnectorId } from \"./piece-auth.js\";\nimport { Button } from \"../shared/controls.js\";\nimport { Icon } from \"../shared/icons.js\";\nimport { formatWhen } from \"../workflow-studio/components/run-format.js\";\nimport { CONNECTION_STATUS_LABEL, CONNECTION_STATUS_STYLES } from \"./status.js\";\n\n// Runs the piece's own check server-side; the outcome lands on the document.\nfunction useConnectionTest(connectionId: string) {\n const [testing, setTesting] = useState(false);\n const [result, setResult] = useState<ConnectionCheckResult | null>(null);\n const { checkConnection } = useRuntimeActions();\n const test = () => {\n setTesting(true);\n setResult(null);\n checkConnection(connectionId)\n .then(setResult)\n .catch((error: unknown) =>\n setResult({\n ok: false,\n detail: error instanceof Error ? error.message : String(error),\n accountLabel: null,\n }),\n )\n .finally(() => setTesting(false));\n };\n return { testing, result, test };\n}\n\nexport function ConnectionToolbar(props: {\n connectionId: string;\n // Enabled workflows that stop working if this is revoked.\n enabledDependents: number;\n state: ConnectionState;\n onRename: (name: string) => void;\n onSetStatus: (status: \"OK\" | \"REVOKED\") => void;\n onDelete: () => void;\n}) {\n const { state } = props;\n // Shared with the form below through the editor's query cache.\n const catalog = usePieceCatalog().data;\n\n const packageName = packageFromConnectorId(state.connectorId);\n const piece = catalog?.find((entry) => entry.name === packageName);\n const revoked = state.status === \"REVOKED\";\n const { testing, result, test } = useConnectionTest(props.connectionId);\n\n return (\n <header className=\"mb-8 flex flex-wrap items-start gap-4\">\n <div className=\"flex h-14 w-14 shrink-0 items-center justify-center rounded-xl border border-solid border-foreground/10 bg-white\">\n {piece?.logoUrl ? (\n <img src={piece.logoUrl} alt=\"\" className=\"h-8 w-8 object-contain\" />\n ) : (\n <Icon name=\"link\" className=\"h-6 w-6 text-neutral-500\" />\n )}\n </div>\n <div className=\"min-w-0 flex-1\">\n <input\n key={state.name}\n className=\"-mx-1.5 w-full max-w-md rounded-md border border-solid border-transparent bg-transparent px-1.5 text-xl font-semibold tracking-tight text-foreground hover:border-foreground/15 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25\"\n defaultValue={state.name}\n placeholder=\"Untitled connection\"\n spellCheck={false}\n aria-label=\"Connection name\"\n onKeyDown={(event) => {\n if (event.key === \"Enter\") event.currentTarget.blur();\n }}\n onBlur={(event) => {\n const name = event.target.value.trim();\n if (name && name !== state.name) props.onRename(name);\n }}\n />\n <p className=\"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-muted-foreground\">\n <span\n className={`rounded-full px-2 py-0.5 text-xs font-medium ${CONNECTION_STATUS_STYLES[state.status]}`}\n >\n {CONNECTION_STATUS_LABEL[state.status]}\n </span>\n <span>\n {piece?.displayName ?? (packageName || \"No service picked\")}\n {state.accountLabel ? (\n <>\n {\" \"}\n as{\" \"}\n <span className=\"font-medium text-foreground\">\n {state.accountLabel}\n </span>\n </>\n ) : null}\n </span>\n </p>\n <p\n className=\"mt-1 text-xs text-muted-foreground\"\n title={\n state.lastCheckedAt\n ? new Date(state.lastCheckedAt).toLocaleString()\n : undefined\n }\n >\n {state.lastCheckedAt\n ? `Last checked ${formatWhen(state.lastCheckedAt)}`\n : \"Never checked\"}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n <Button size=\"sm\" variant=\"danger\" onClick={props.onDelete}>\n Delete\n </Button>\n <Button\n size=\"sm\"\n title={\n !revoked && props.enabledDependents > 0\n ? `${props.enabledDependents} enabled ${props.enabledDependents === 1 ? \"workflow stops\" : \"workflows stop\"} working while it's revoked`\n : undefined\n }\n onClick={() => props.onSetStatus(revoked ? \"OK\" : \"REVOKED\")}\n >\n {revoked ? \"Reactivate\" : \"Revoke\"}\n </Button>\n <Button\n size=\"sm\"\n variant=\"primary\"\n disabled={testing || revoked || !packageName}\n onClick={test}\n >\n <Icon name=\"check\" className=\"h-3.5 w-3.5\" />\n {testing ? \"Testing…\" : \"Test connection\"}\n </Button>\n </div>\n {result ? (\n <p\n role=\"status\"\n className={`flex w-full items-start gap-2 rounded-md px-3 py-2 text-xs ${\n result.ok ? \"bg-wf-ok/10 text-wf-ok\" : \"bg-wf-fail/10 text-wf-fail\"\n }`}\n >\n <Icon\n name={result.ok ? \"check\" : \"alert\"}\n className=\"mt-px h-3.5 w-3.5\"\n />\n <span className=\"min-w-0 break-words\">\n {result.ok\n ? `It works${result.accountLabel ? `, signed in as ${result.accountLabel}` : \"\"}.`\n : result.detail}\n </span>\n </p>\n ) : null}\n </header>\n );\n}\n","// The workflows that depend on this connection, and through which steps, so\n// nobody revokes or deletes it blind.\nimport { setSelectedNode } from \"@powerhousedao/reactor-browser\";\nimport { useWorkflowDocumentsInSelectedDrive } from \"document-models/workflow\";\nimport { BlockLogo } from \"../workflow-editor/ui/BlockSelector.js\";\nimport { stepBlock } from \"../workflow-editor/ui/blocks.js\";\nimport {\n connectionUsage,\n type ConnectionUsage,\n type UsageWorkflow,\n} from \"./connection-usage.js\";\n\nexport function useConnectionUsage(connectionId: string) {\n const workflows = useWorkflowDocumentsInSelectedDrive() ?? [];\n return connectionUsage(\n connectionId,\n workflows.map((workflow): UsageWorkflow => ({\n id: workflow.header.id,\n name: workflow.state.global.name || workflow.header.name || \"Untitled\",\n status: workflow.state.global.status,\n trigger: workflow.state.global.trigger,\n steps: workflow.state.global.steps,\n })),\n );\n}\n\nexport function UsedBy(props: { usage: ConnectionUsage[] }) {\n const { usage } = props;\n return (\n <section className=\"mt-8 border-t border-solid border-foreground/10 pt-5\">\n <h3 className=\"text-[13px] font-semibold text-foreground\">Used by</h3>\n {usage.length === 0 ? (\n <p className=\"mt-1 text-xs text-muted-foreground\">\n No workflow uses this connection yet. Pick it on a step in a\n workflow's editor.\n </p>\n ) : (\n <ul className=\"-mx-2 mt-2 flex flex-col\">\n {usage.map((entry) => (\n <li key={entry.workflow.id}>\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-[13px] hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n onClick={() => setSelectedNode(entry.workflow.id)}\n >\n <span className=\"shrink-0 font-medium text-foreground\">\n {entry.workflow.name}\n </span>\n {entry.workflow.status !== \"ENABLED\" ? (\n <span className=\"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground\">\n {entry.workflow.status.charAt(0) +\n entry.workflow.status.slice(1).toLowerCase()}\n </span>\n ) : null}\n <span className=\"flex min-w-0 items-center gap-1.5 truncate text-xs text-muted-foreground\">\n {entry.steps.map((step) => (\n <span\n key={step.id}\n className=\"inline-flex items-center gap-1\"\n >\n <BlockLogo block={stepBlock(step)} size={14} bare />\n {step.name || step.key}\n </span>\n ))}\n {entry.trigger ? <span>Trigger</span> : null}\n </span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </section>\n );\n}\n","import {\n showDeleteNodeModal,\n useSelectedDocumentId,\n} from \"@powerhousedao/reactor-browser\";\nimport { useSelectedConnectionDocument } from \"document-models/connection\";\nimport { DocumentErrorBoundary } from \"../shared/DocumentErrorBoundary.js\";\nimport { BackButton, UndoRedo } from \"../shared/editor-chrome.js\";\nimport { WorkflowRuntimeProvider } from \"../workflow-editor/runtime-context.js\";\nimport { connectionCallbacks } from \"./connection-callbacks.js\";\nimport { ConnectionForm } from \"./connection-form.js\";\nimport { enabledDependents } from \"./connection-usage.js\";\nimport { ConnectionToolbar } from \"./ConnectionToolbar.js\";\nimport { UsedBy, useConnectionUsage } from \"./UsedBy.js\";\n\nfunction ConnectionEditor() {\n const [document, dispatch] = useSelectedConnectionDocument();\n const state = document.state.global;\n\n const callbacks = connectionCallbacks(state, dispatch);\n const usage = useConnectionUsage(document.header.id);\n\n return (\n <div className=\"flex h-full min-h-0 flex-col bg-background\">\n <div className=\"flex items-center justify-between border-b border-solid border-foreground/10 px-4 py-2\">\n <BackButton />\n <UndoRedo documentId={document.header.id} />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto\">\n <div className=\"mx-auto w-full max-w-2xl px-6 py-10\">\n <ConnectionToolbar\n connectionId={document.header.id}\n enabledDependents={enabledDependents(usage)}\n state={state}\n onRename={callbacks.setName}\n onSetStatus={callbacks.setStatus}\n onDelete={() => showDeleteNodeModal(document.header.id)}\n />\n <ConnectionForm\n state={state}\n callbacks={callbacks}\n connectionId={document.header.id}\n />\n <UsedBy usage={usage} />\n </div>\n </div>\n </div>\n );\n}\n\n// A drive node can point at a document the reactor cannot serve; the document\n// hooks throw for it. The boundary keeps that failure inside the editor pane.\nexport default function Editor() {\n const documentId = useSelectedDocumentId();\n return (\n <DocumentErrorBoundary documentId={documentId}>\n <WorkflowRuntimeProvider>\n <ConnectionEditor />\n </WorkflowRuntimeProvider>\n </DocumentErrorBoundary>\n );\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,gBACd,cACA,WACmB;CACnB,MAAM,QAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,SAAS,SAAS,iBAAiB;EACnD,MAAM,QAAQ,SAAS,MAAM,QAC1B,SACE,KAA0C,iBAC3C,YACJ;EACA,IAAI,WAAW,MAAM,SAAS,GAAG,MAAM,KAAK;GAAE;GAAU;GAAS;EAAM,CAAC;CAC1E;CACA,OAAO,MAAM,MAAM,GAAG,MAAM,EAAE,SAAS,KAAK,cAAc,EAAE,SAAS,IAAI,CAAC;AAC5E;AAIA,SAAgB,kBAAkB,OAAkC;CAClE,OAAO,MAAM,QAAQ,UAAU,MAAM,SAAS,WAAW,SAAS,CAAC,CAAC;AACtE;;;AChCA,SAAS,kBAAkB,cAAsB;CAC/C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C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[],"sources":["../../editors/connection-editor/connection-usage.ts","../../editors/connection-editor/ConnectionToolbar.tsx","../../editors/connection-editor/UsedBy.tsx","../../editors/connection-editor/editor.tsx"],"sourcesContent":["// Which workflows depend on a connection, and where. Answers the question a\n// connection page has to answer before anyone dares revoke or delete it.\n\nexport interface UsageStep {\n id: string;\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n}\n\nexport interface UsageWorkflow {\n id: string;\n name: string;\n status: string;\n trigger?: { connectionId?: string | null } | null;\n steps: readonly UsageStep[];\n}\n\nexport interface ConnectionUsage {\n workflow: UsageWorkflow;\n // The trigger binds this connection.\n trigger: boolean;\n steps: UsageStep[];\n}\n\nexport function connectionUsage(\n connectionId: string,\n workflows: readonly UsageWorkflow[],\n): ConnectionUsage[] {\n const usage: ConnectionUsage[] = [];\n for (const workflow of workflows) {\n const trigger = workflow.trigger?.connectionId === connectionId;\n const steps = workflow.steps.filter(\n (step) =>\n (step as { connectionId?: string | null }).connectionId ===\n connectionId,\n );\n if (trigger || steps.length > 0) usage.push({ workflow, trigger, steps });\n }\n return usage.sort((a, b) => a.workflow.name.localeCompare(b.workflow.name));\n}\n\n// An enabled workflow that depends on this connection breaks the moment it is\n// revoked, so the UI warns before that happens.\nexport function enabledDependents(usage: ConnectionUsage[]): number {\n return usage.filter((entry) => entry.workflow.status === \"ENABLED\").length;\n}\n","// Connection identity and state, in the same shape as the workflow editor's\n// toolbar: name, connector, status, and the one destructive action.\nimport { useState } from \"react\";\nimport type { ConnectionState } from \"document-models/connection\";\nimport type { ConnectionCheckResult } from \"../workflow-editor/runtime-client.js\";\nimport {\n usePieceCatalog,\n useRuntimeActions,\n} from \"../workflow-editor/runtime-context.js\";\nimport { packageFromConnectorId } from \"./piece-auth.js\";\nimport { Button } from \"../shared/controls.js\";\nimport { Icon } from \"../shared/icons.js\";\nimport { formatWhen } from \"../workflow-studio/components/run-format.js\";\nimport { CONNECTION_STATUS_LABEL, CONNECTION_STATUS_STYLES } from \"./status.js\";\n\n// Runs the piece's own check server-side; the outcome lands on the document.\nfunction useConnectionTest(connectionId: string) {\n const [testing, setTesting] = useState(false);\n const [result, setResult] = useState<ConnectionCheckResult | null>(null);\n const { checkConnection } = useRuntimeActions();\n const test = () => {\n setTesting(true);\n setResult(null);\n checkConnection(connectionId)\n .then(setResult)\n .catch((error: unknown) =>\n setResult({\n ok: false,\n detail: error instanceof Error ? error.message : String(error),\n accountLabel: null,\n }),\n )\n .finally(() => setTesting(false));\n };\n return { testing, result, test };\n}\n\nexport function ConnectionToolbar(props: {\n connectionId: string;\n // Enabled workflows that stop working if this is revoked.\n enabledDependents: number;\n state: ConnectionState;\n onRename: (name: string) => void;\n onSetStatus: (status: \"OK\" | \"REVOKED\") => void;\n onDelete: () => void;\n}) {\n const { state } = props;\n // Shared with the form below through the editor's query cache.\n const catalog = usePieceCatalog().data;\n\n const packageName = packageFromConnectorId(state.connectorId);\n const piece = catalog?.find((entry) => entry.name === packageName);\n const revoked = state.status === \"REVOKED\";\n const { testing, result, test } = useConnectionTest(props.connectionId);\n\n return (\n <header className=\"mb-8 flex flex-wrap items-start gap-4\">\n <div className=\"flex h-14 w-14 shrink-0 items-center justify-center rounded-xl border border-solid border-foreground/10 bg-white\">\n {piece?.logoUrl ? (\n <img src={piece.logoUrl} alt=\"\" className=\"h-8 w-8 object-contain\" />\n ) : (\n <Icon name=\"link\" className=\"h-6 w-6 text-neutral-500\" />\n )}\n </div>\n <div className=\"min-w-0 flex-1\">\n <input\n key={state.name}\n className=\"-mx-1.5 w-full max-w-md rounded-md border border-solid border-transparent bg-transparent px-1.5 text-xl font-semibold tracking-tight text-foreground hover:border-foreground/15 focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/25\"\n defaultValue={state.name}\n placeholder=\"Untitled connection\"\n spellCheck={false}\n aria-label=\"Connection name\"\n onKeyDown={(event) => {\n if (event.key === \"Enter\") event.currentTarget.blur();\n }}\n onBlur={(event) => {\n const name = event.target.value.trim();\n if (name && name !== state.name) props.onRename(name);\n }}\n />\n <p className=\"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-muted-foreground\">\n <span\n className={`rounded-full px-2 py-0.5 text-xs font-medium ${CONNECTION_STATUS_STYLES[state.status]}`}\n >\n {CONNECTION_STATUS_LABEL[state.status]}\n </span>\n <span>\n {piece?.displayName ?? (packageName || \"No service picked\")}\n {state.accountLabel ? (\n <>\n {\" \"}\n as{\" \"}\n <span className=\"font-medium text-foreground\">\n {state.accountLabel}\n </span>\n </>\n ) : null}\n </span>\n </p>\n <p\n className=\"mt-1 text-xs text-muted-foreground\"\n title={\n state.lastCheckedAt\n ? new Date(state.lastCheckedAt).toLocaleString()\n : undefined\n }\n >\n {state.lastCheckedAt\n ? `Last checked ${formatWhen(state.lastCheckedAt)}`\n : \"Never checked\"}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n <Button size=\"sm\" variant=\"danger\" onClick={props.onDelete}>\n Delete\n </Button>\n <Button\n size=\"sm\"\n title={\n !revoked && props.enabledDependents > 0\n ? `${props.enabledDependents} enabled ${props.enabledDependents === 1 ? \"workflow stops\" : \"workflows stop\"} working while it's revoked`\n : undefined\n }\n onClick={() => props.onSetStatus(revoked ? \"OK\" : \"REVOKED\")}\n >\n {revoked ? \"Reactivate\" : \"Revoke\"}\n </Button>\n <Button\n size=\"sm\"\n variant=\"primary\"\n disabled={testing || revoked || !packageName}\n onClick={test}\n >\n <Icon name=\"check\" className=\"h-3.5 w-3.5\" />\n {testing ? \"Testing…\" : \"Test connection\"}\n </Button>\n </div>\n {result ? (\n <p\n role=\"status\"\n className={`flex w-full items-start gap-2 rounded-md px-3 py-2 text-xs ${\n result.ok ? \"bg-wf-ok/10 text-wf-ok\" : \"bg-wf-fail/10 text-wf-fail\"\n }`}\n >\n <Icon\n name={result.ok ? \"check\" : \"alert\"}\n className=\"mt-px h-3.5 w-3.5\"\n />\n <span className=\"min-w-0 break-words\">\n {result.ok\n ? `It works${result.accountLabel ? `, signed in as ${result.accountLabel}` : \"\"}.`\n : result.detail}\n </span>\n </p>\n ) : null}\n </header>\n );\n}\n","// The workflows that depend on this connection, and through which steps, so\n// nobody revokes or deletes it blind.\nimport { setSelectedNode } from \"@powerhousedao/reactor-browser\";\nimport { useWorkflowDocumentsInSelectedDrive } from \"document-models/workflow\";\nimport { BlockLogo } from \"../workflow-editor/ui/BlockSelector.js\";\nimport { stepBlock } from \"../workflow-editor/ui/blocks.js\";\nimport {\n connectionUsage,\n type ConnectionUsage,\n type UsageWorkflow,\n} from \"./connection-usage.js\";\n\nexport function useConnectionUsage(connectionId: string) {\n const workflows = useWorkflowDocumentsInSelectedDrive() ?? [];\n return connectionUsage(\n connectionId,\n workflows.map((workflow): UsageWorkflow => ({\n id: workflow.header.id,\n name: workflow.state.global.name || workflow.header.name || \"Untitled\",\n status: workflow.state.global.status,\n trigger: workflow.state.global.trigger,\n steps: workflow.state.global.steps,\n })),\n );\n}\n\nexport function UsedBy(props: { usage: ConnectionUsage[] }) {\n const { usage } = props;\n return (\n <section className=\"mt-8 border-t border-solid border-foreground/10 pt-5\">\n <h3 className=\"text-[13px] font-semibold text-foreground\">Used by</h3>\n {usage.length === 0 ? (\n <p className=\"mt-1 text-xs text-muted-foreground\">\n No workflow uses this connection yet. Pick it on a step in a\n workflow's editor.\n </p>\n ) : (\n <ul className=\"-mx-2 mt-2 flex flex-col\">\n {usage.map((entry) => (\n <li key={entry.workflow.id}>\n <button\n type=\"button\"\n className=\"flex w-full items-center gap-3 rounded-md px-2 py-2 text-left text-[13px] hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n onClick={() => setSelectedNode(entry.workflow.id)}\n >\n <span className=\"shrink-0 font-medium text-foreground\">\n {entry.workflow.name}\n </span>\n {entry.workflow.status !== \"ENABLED\" ? (\n <span className=\"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground\">\n {entry.workflow.status.charAt(0) +\n entry.workflow.status.slice(1).toLowerCase()}\n </span>\n ) : null}\n <span className=\"flex min-w-0 items-center gap-1.5 truncate text-xs text-muted-foreground\">\n {entry.steps.map((step) => (\n <span\n key={step.id}\n className=\"inline-flex items-center gap-1\"\n >\n <BlockLogo block={stepBlock(step)} size={14} bare />\n {step.name || step.key}\n </span>\n ))}\n {entry.trigger ? <span>Trigger</span> : null}\n </span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </section>\n );\n}\n","import {\n showDeleteNodeModal,\n useSelectedDocumentId,\n} from \"@powerhousedao/reactor-browser\";\nimport { useSelectedConnectionDocument } from \"document-models/connection\";\nimport { DocumentErrorBoundary } from \"../shared/DocumentErrorBoundary.js\";\nimport { BackButton, UndoRedo } from \"../shared/editor-chrome.js\";\nimport { WorkflowRuntimeProvider } from \"../workflow-editor/runtime-context.js\";\nimport { connectionCallbacks } from \"./connection-callbacks.js\";\nimport { ConnectionForm } from \"./connection-form.js\";\nimport { enabledDependents } from \"./connection-usage.js\";\nimport { ConnectionToolbar } from \"./ConnectionToolbar.js\";\nimport { UsedBy, useConnectionUsage } from \"./UsedBy.js\";\n\nfunction ConnectionEditor() {\n const [document, dispatch] = useSelectedConnectionDocument();\n const state = document.state.global;\n\n const callbacks = connectionCallbacks(state, dispatch);\n const usage = useConnectionUsage(document.header.id);\n\n return (\n <div className=\"flex h-full min-h-0 flex-col bg-background\">\n <div className=\"flex items-center justify-between border-b border-solid border-foreground/10 px-4 py-2\">\n <BackButton />\n <UndoRedo documentId={document.header.id} />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto\">\n <div className=\"mx-auto w-full max-w-2xl px-6 py-10\">\n <ConnectionToolbar\n connectionId={document.header.id}\n enabledDependents={enabledDependents(usage)}\n state={state}\n onRename={callbacks.setName}\n onSetStatus={callbacks.setStatus}\n onDelete={() => showDeleteNodeModal(document.header.id)}\n />\n <ConnectionForm\n state={state}\n callbacks={callbacks}\n connectionId={document.header.id}\n />\n <UsedBy usage={usage} />\n </div>\n </div>\n </div>\n );\n}\n\n// A drive node can point at a document the reactor cannot serve; the document\n// hooks throw for it. The boundary keeps that failure inside the editor pane.\nexport default function Editor() {\n const documentId = useSelectedDocumentId();\n return (\n <DocumentErrorBoundary documentId={documentId}>\n <WorkflowRuntimeProvider>\n <ConnectionEditor />\n </WorkflowRuntimeProvider>\n </DocumentErrorBoundary>\n );\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,gBACd,cACA,WACmB;CACnB,MAAM,QAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,SAAS,SAAS,iBAAiB;EACnD,MAAM,QAAQ,SAAS,MAAM,QAC1B,SACE,KAA0C,iBAC3C,YACJ;EACA,IAAI,WAAW,MAAM,SAAS,GAAG,MAAM,KAAK;GAAE;GAAU;GAAS;EAAM,CAAC;CAC1E;CACA,OAAO,MAAM,MAAM,GAAG,MAAM,EAAE,SAAS,KAAK,cAAc,EAAE,SAAS,IAAI,CAAC;AAC5E;AAIA,SAAgB,kBAAkB,OAAkC;CAClE,OAAO,MAAM,QAAQ,UAAU,MAAM,SAAS,WAAW,SAAS,CAAC,CAAC;AACtE;;;AChCA,SAAS,kBAAkB,cAAsB;CAC/C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAuC,IAAI;CACvE,MAAM,EAAE,oBAAoB,kBAAkB;CAC9C,MAAM,aAAa;EACjB,WAAW,IAAI;EACf,UAAU,IAAI;EACd,gBAAgB,YAAY,CAAC,CAC1B,KAAK,SAAS,CAAC,CACf,OAAO,UACN,UAAU;GACR,IAAI;GACJ,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAC7D,cAAc;EAChB,CAAC,CACH,CAAC,CACA,cAAc,WAAW,KAAK,CAAC;CACpC;CACA,OAAO;EAAE;EAAS;EAAQ;CAAK;AACjC;AAEA,SAAgB,kBAAkB,OAQ/B;CACD,MAAM,EAAE,UAAU;CAElB,MAAM,UAAU,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;CAEnD,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,YAAD,CAAa,CAAA,GACb,oBAAC,UAAD,EAAU,YAAY,SAAS,OAAO,GAAK,CAAA,CACxC;EACL,CAAA,GAAA,oBAAC,OAAD;GAAK,WAAU;GACb,UAAA,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,mBAAD;MACE,cAAc,SAAS,OAAO;MAC9B,mBAAmB,kBAAkB,KAAK;MACnC;MACP,UAAU,UAAU;MACpB,aAAa,UAAU;MACvB,gBAAgB,oBAAoB,SAAS,OAAO,EAAE;KACvD,CAAA;KACD,oBAAC,gBAAD;MACS;MACI;MACX,cAAc,SAAS,OAAO;KAC/B,CAAA;KACD,oBAAC,QAAD,EAAe,MAAQ,CAAA;IACpB;;EACF,CAAA,CACF;;AAET;AAIA,SAAwB,SAAS;CAC/B,MAAM,aAAa,sBAAsB;CACzC,OACE,oBAAC,uBAAD;EAAmC;EACjC,UAAA,oBAAC,yBAAD,EAAA,UACE,oBAAC,kBAAD,CAAmB,CAAA,EACI,CAAA;CACJ,CAAA;AAE3B"}
@@ -2,7 +2,7 @@ import { lazy } from "react";
2
2
  //#region editors/connection-editor/module.ts
3
3
  /** Document editor module for the "powerhouse/connection" document type */
4
4
  const ConnectionEditor = {
5
- Component: lazy(() => import("../../editor-CtErqBMO.js")),
5
+ Component: lazy(() => import("../../editor-DgCrC5jt.js")),
6
6
  documentTypes: ["powerhouse/connection"],
7
7
  config: {
8
8
  id: "connection-editor",
@@ -2,7 +2,7 @@ import { lazy } from "react";
2
2
  //#region editors/workflow-editor/module.ts
3
3
  /** Document editor module for the "powerhouse/workflow" document type */
4
4
  const WorkflowEditor = {
5
- Component: lazy(() => import("../../editor-p9gVC4FY.js")),
5
+ Component: lazy(() => import("../../editor-CYKLDgER.js")),
6
6
  documentTypes: ["powerhouse/workflow"],
7
7
  config: {
8
8
  id: "workflow-editor",
@@ -2,7 +2,7 @@ import { lazy } from "react";
2
2
  //#region editors/workflow-studio/module.ts
3
3
  /** Document editor module for the "powerhouse/document-drive" document type */
4
4
  const WorkflowStudio = {
5
- Component: lazy(() => import("../../editor-DjSMG-EP.js")),
5
+ Component: lazy(() => import("../../editor-B0YlNGFs.js")),
6
6
  documentTypes: ["powerhouse/document-drive"],
7
7
  config: {
8
8
  id: "workflow-studio",
@@ -75,7 +75,8 @@ const GRAPH_RULES = [
75
75
  "A step names its block with pieceName, pieceVersion and actionName; the trigger with pieceName, pieceVersion and triggerName. pieceVersion is an exact semver: copy the fields getWorkflowPieceBlocks or listWorkflowCoreBlocks return.",
76
76
  `The built-in blocks (manual, schedule and webhook triggers, branch and assert) belong to the piece ${CORE_PIECE}.`,
77
77
  "Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).",
78
- "Only ENABLED workflows get trigger instances and can be fired. PUBLISH_WORKFLOW snapshots the draft and enables it; SET_WORKFLOW_STATUS ENABLED is refused until the workflow has been published once."
78
+ "Runs execute the published snapshot, not the draft. PUBLISH_WORKFLOW only snapshots the draft, so publish again after every edit that should run.",
79
+ "Only ENABLED workflows get trigger instances and can be fired. PUBLISH_WORKFLOW does not enable: to turn a workflow on, dispatch SET_WORKFLOW_STATUS ENABLED after PUBLISH_WORKFLOW (the same batch works). SET_WORKFLOW_STATUS ENABLED is refused until the workflow has been published once."
79
80
  ];
80
81
  /** Workflow authoring and run tools, merged into `aiTools` in tools.ts. */
81
82
  const workflowTools = [
@@ -224,7 +225,7 @@ const workflowTools = [
224
225
  },
225
226
  {
226
227
  name: "fireWorkflow",
227
- description: "Fires an ENABLED workflow whose trigger is the core manual trigger and runs it to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.",
228
+ description: "Fires an ENABLED workflow whose trigger is the core manual trigger and runs its published snapshot to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.",
228
229
  inputSchema: {
229
230
  workflowId: z.string().describe("Workflow document id."),
230
231
  payload: z.record(z.string(), z.unknown()).optional().describe("Trigger payload object.")
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["READ_ONLY","runConnectionCheck","manifestJson"],"sources":["../../editors/workflow-editor/runtime-api.ts","../../ai/runtime-url.ts","../../ai/workflow-tools.ts","../../ai/tools.ts","../../editors/editors.ts","../../index.ts"],"sourcesContent":["// Ambient runtime client for the AI tools, which run outside any editor.\n// Editors never import this: each one gets its own client from RuntimeProvider.\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\nimport {\n createRuntimeClient,\n DEFAULT_RUNTIME_URL,\n type RunsScope,\n type RuntimeClient,\n} from \"./runtime-client.js\";\nimport {\n blockFormQuery,\n catalogQuery,\n createRuntimeQueryClient,\n} from \"./runtime-queries.js\";\n\nexport type * from \"./runtime-client.js\";\nexport { DEFAULT_RUNTIME_URL };\n\nlet ambient: RuntimeClient = createRuntimeClient(DEFAULT_RUNTIME_URL);\n// Keys start with the URL, so switching runtimes needs no cache reset.\nconst ambientQueries = createRuntimeQueryClient();\n\nexport function setRuntimeUrl(url: string): void {\n if (url !== ambient.url) ambient = createRuntimeClient(url);\n}\n\nexport const getBlockForm = (block: BlockRef) =>\n ambientQueries.fetchQuery(blockFormQuery(ambient, block));\nexport const fetchPieceCatalog = () =>\n ambientQueries.fetchQuery(catalogQuery(ambient));\nexport const fetchPieceActions = (packageName: string) =>\n ambient.fetchPieceActions(packageName);\nexport const fetchPieceTriggers = (packageName: string) =>\n ambient.fetchPieceTriggers(packageName);\nexport const fetchConnections = () => ambient.fetchConnections();\nexport const checkConnection = (connectionId: string) =>\n ambient.checkConnection(connectionId);\nexport const fetchRuns = (scope?: RunsScope) => ambient.fetchRuns(scope);\nexport const fireWorkflow = (workflowId: string, payload?: unknown) =>\n ambient.fireWorkflow(workflowId, payload);\n","// Points the module-level runtime client at the selected drive's\n// workflow-runtime subgraph before an AI tool talks to it.\nimport { resolveDriveSwitchboard } from \"@powerhousedao/reactor-browser/ai\";\nimport {\n DEFAULT_RUNTIME_URL,\n setRuntimeUrl,\n} from \"../editors/workflow-editor/runtime-api.js\";\n\nexport function syncRuntimeUrl(): void {\n if (typeof window === \"undefined\") return;\n const switchboard = resolveDriveSwitchboard(window.ph?.selectedDriveId);\n // No resolvable switchboard (no selection, or a local/unsynced drive):\n // reset to the default rather than leaving a prior drive's URL attached.\n setRuntimeUrl(\n switchboard\n ? `${switchboard.graphqlUrl}/workflow-runtime`\n : DEFAULT_RUNTIME_URL,\n );\n}\n","// AI tool descriptors for authoring and running workflows: the pinned blocks\n// a piece offers, a block's config props, the built-in core blocks with\n// the expression syntax, run history and manual firing. Complements the\n// connector/connection tools in tools.ts, which cover the catalog and auth.\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n fetchPieceActions,\n fetchPieceTriggers,\n fetchRuns,\n fireWorkflow,\n getBlockForm,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport type { BlockFormProp } from \"../editors/workflow-editor/ui/forms.js\";\nimport {\n CORE_PIECE,\n type BlockRef,\n} from \"../editors/workflow-editor/ui/blocks.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { flowPorts } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nfunction kindOf(block: BlockRef): \"trigger\" | \"step\" {\n return block.kind === \"trigger\" ? \"trigger\" : \"step\";\n}\n\n// The fields ADD_STEP or SET_TRIGGER takes for the block.\nfunction blockFields(block: BlockRef) {\n return {\n pieceName: block.pieceName,\n pieceVersion: block.pieceVersion,\n ...(block.kind === \"trigger\"\n ? { triggerName: block.name }\n : { actionName: block.name }),\n };\n}\n\n// The onward ports the block's descriptor declares; \"error\" is a failure route.\nfunction portsFor(form: { ports?: readonly string[] }): string[] {\n return flowPorts(form.ports ?? []);\n}\n\nfunction describeProp(prop: BlockFormProp) {\n return {\n name: prop.name,\n label: prop.displayName,\n type: prop.type,\n required: prop.required,\n ...(prop.description ? { description: prop.description } : {}),\n ...(prop.defaultValue !== undefined ? { default: prop.defaultValue } : {}),\n ...(prop.staticOptions\n ? { options: prop.staticOptions.map((option) => option.value) }\n : {}),\n ...(prop.hasDynamicResolver ? { dynamicOptions: true } : {}),\n };\n}\n\nconst EXPRESSIONS = [\n \"Step configs and edge conditions may contain expressions in double braces.\",\n \"{{trigger.payload.<field>}} reads the trigger payload: for the core manual trigger the payload passed to fireWorkflow; for the reactor piece's document triggers it carries documentId, documentType, driveId and name.\",\n \"{{steps.<key>.output.<path>}} reads an upstream step's output by that step's key, e.g. {{steps.fetch.output.body.title}}.\",\n \"{{variables.<key>}} reads a workflow variable.\",\n \"'a' || 'b' picks the first non-empty value, e.g. {{trigger.payload.url || 'https://example.com'}}.\",\n \"A whole-string expression yields the raw value; text around expressions is interpolated.\",\n];\n\nconst GRAPH_RULES = [\n \"A workflow is a powerhouse/workflow document. Build it with SET_TRIGGER once, ADD_STEP per step (each with a unique id and key), and ADD_EDGE from the trigger id to the first step and between steps.\",\n \"An edge must leave on a port its source declares (getWorkflowBlockConfig lists them): 'next' for the trigger and ordinary steps, 'true' and 'false' for the core branch action, 'error' to route a failure. An edge on any other port is never taken, and the run is flagged with a warning.\",\n \"A step names its block with pieceName, pieceVersion and actionName; the trigger with pieceName, pieceVersion and triggerName. pieceVersion is an exact semver: copy the fields getWorkflowPieceBlocks or listWorkflowCoreBlocks return.\",\n `The built-in blocks (manual, schedule and webhook triggers, branch and assert) belong to the piece ${CORE_PIECE}.`,\n \"Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).\",\n \"Only ENABLED workflows get trigger instances and can be fired. PUBLISH_WORKFLOW snapshots the draft and enables it; SET_WORKFLOW_STATUS ENABLED is refused until the workflow has been published once.\",\n];\n\nexport const getWorkflowPieceBlocksTool: PhAiToolDescriptor = {\n name: \"getWorkflowPieceBlocks\",\n description:\n \"Lists the actions and triggers of one piece, each with the pieceName, pieceVersion and actionName or triggerName to use in ADD_STEP or SET_TRIGGER. Takes the piece package name from getConnectors. Call getWorkflowBlockConfig next for a block's config props.\",\n inputSchema: {\n packageName: z\n .string()\n .describe(\"Piece package name, e.g. @activepieces/piece-http.\"),\n },\n annotations: { title: \"Get Workflow Piece Blocks\", ...READ_ONLY },\n callback: async (args: { packageName: string }) => {\n syncRuntimeUrl();\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(args.packageName),\n fetchPieceTriggers(args.packageName),\n ]);\n return {\n packageName: args.packageName,\n actions: actions.map((action) => ({\n pieceName: action.pieceName,\n pieceVersion: action.pieceVersion,\n actionName: action.name,\n displayName: action.displayName,\n description: action.description,\n })),\n triggers: triggers.map((trigger) => ({\n pieceName: trigger.pieceName,\n pieceVersion: trigger.pieceVersion,\n triggerName: trigger.name,\n displayName: trigger.displayName,\n description: trigger.description,\n strategy: trigger.strategy,\n })),\n };\n },\n};\n\nexport const getWorkflowBlockConfigTool: PhAiToolDescriptor = {\n name: \"getWorkflowBlockConfig\",\n description:\n \"Describes the config of one block (a core block or a piece's action or trigger): prop names, types, whether required, allowed options, the output ports, and whether a connection is needed. Use it before writing a step or trigger config.\",\n inputSchema: {\n pieceName: z\n .string()\n .describe(\n `Piece package name, e.g. ${CORE_PIECE} or @activepieces/piece-http.`,\n ),\n pieceVersion: z.string().describe(\"Exact semver of the piece.\"),\n name: z\n .string()\n .describe(\"Action or trigger name, e.g. branch or send_request.\"),\n kind: z.enum([\"action\", \"trigger\"]).describe(\"action or trigger.\"),\n },\n annotations: { title: \"Get Workflow Block Config\", ...READ_ONLY },\n callback: async (args: BlockRef) => {\n const block: BlockRef = {\n pieceName: args.pieceName,\n pieceVersion: args.pieceVersion,\n name: args.name,\n kind: args.kind,\n };\n syncRuntimeUrl();\n const form = await getBlockForm(block);\n if (!form) {\n return {\n ...blockFields(block),\n error:\n \"Unknown block. Use getConnectors and getWorkflowPieceBlocks to find valid blocks (documents live in @powerhousedao/piece-reactor), or listWorkflowCoreBlocks for built-ins.\",\n };\n }\n return {\n ...blockFields(block),\n title: form.title,\n kind: kindOf(block),\n requiresConnection: form.auth === \"required\",\n props: form.props.map(describeProp),\n ports: portsFor(form),\n };\n },\n};\n\nexport const listWorkflowCoreBlocksTool: PhAiToolDescriptor = {\n name: \"listWorkflowCoreBlocks\",\n description: `Lists the built-in blocks of the ${CORE_PIECE} piece (manual, schedule and webhook triggers, branch and assert) with their pinned fields and config props, plus the expression syntax and the rules for building a powerhouse/workflow document. Documents are read and written by the @powerhousedao/piece-reactor blocks; list those with getWorkflowPieceBlocks.`,\n inputSchema: {},\n annotations: { title: \"List Workflow Core Blocks\", ...READ_ONLY },\n callback: async () => {\n syncRuntimeUrl();\n // The reactor serves the core piece's descriptors, as it does any piece's.\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(CORE_PIECE),\n fetchPieceTriggers(CORE_PIECE),\n ]);\n const blocks: BlockRef[] = [\n ...triggers.map((entry) => ({ ...entry, kind: \"trigger\" as const })),\n ...actions.map((entry) => ({ ...entry, kind: \"action\" as const })),\n ].map((entry) => ({\n pieceName: entry.pieceName,\n pieceVersion: entry.pieceVersion,\n name: entry.name,\n kind: entry.kind,\n }));\n const forms = await Promise.all(blocks.map(getBlockForm));\n return {\n blocks: blocks.flatMap((block, index) => {\n const form = forms[index];\n if (!form) return [];\n return [\n {\n ...blockFields(block),\n title: form.title,\n kind: kindOf(block),\n props: form.props.map(describeProp),\n ports: portsFor(form),\n },\n ];\n }),\n expressions: EXPRESSIONS,\n rules: GRAPH_RULES,\n };\n },\n};\n\nexport const listWorkflowRunsTool: PhAiToolDescriptor = {\n name: \"listWorkflowRuns\",\n description:\n \"Lists recent workflow runs, newest first, with status, error and each step's outcome. Filter by workflowId to inspect one workflow, or by driveId for every workflow in a drive.\",\n inputSchema: {\n workflowId: z\n .string()\n .optional()\n .describe(\"Workflow document id to filter by.\"),\n driveId: z\n .string()\n .optional()\n .describe(\"Drive id to filter by (all workflows in that drive).\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe(\"Maximum runs to return (default 10).\"),\n },\n annotations: { title: \"List Workflow Runs\", ...READ_ONLY },\n callback: async (args: {\n workflowId?: string;\n driveId?: string;\n limit?: number;\n }) => {\n syncRuntimeUrl();\n const runs = await fetchRuns({\n workflowId: args.workflowId,\n driveId: args.driveId,\n limit: args.limit ?? 10,\n });\n return {\n runs: runs.map((run) => ({\n id: run.id,\n workflowId: run.workflowId,\n workflowName: run.workflowName,\n status: run.status,\n error: run.error,\n triggerKind: run.triggerKind,\n startedAt: run.startedAt,\n endedAt: run.endedAt,\n steps: run.steps.map((step) => ({\n key: step.stepKey,\n status: step.status,\n error: step.error,\n })),\n })),\n };\n },\n};\n\nexport const fireWorkflowTool: PhAiToolDescriptor = {\n name: \"fireWorkflow\",\n description:\n \"Fires an ENABLED workflow whose trigger is the core manual trigger and runs it to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.\",\n inputSchema: {\n workflowId: z.string().describe(\"Workflow document id.\"),\n payload: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Trigger payload object.\"),\n },\n annotations: {\n title: \"Fire Workflow\",\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n },\n callback: (args: {\n workflowId: string;\n payload?: Record<string, unknown>;\n }) => {\n syncRuntimeUrl();\n return fireWorkflow(args.workflowId, args.payload ?? {});\n },\n};\n\n/** Workflow authoring and run tools, merged into `aiTools` in tools.ts. */\nexport const workflowTools: PhAiToolDescriptor[] = [\n getWorkflowPieceBlocksTool,\n getWorkflowBlockConfigTool,\n listWorkflowCoreBlocksTool,\n listWorkflowRunsTool,\n fireWorkflowTool,\n];\n","// Read-only AI tool descriptors for the Connect assistant: the project's\n// piece catalog, connection documents, and connection health. The `aiTools`\n// export is how the host app discovers this package's tools (the line in the\n// project index is synced by `ph generate`).\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n connectorIdForPiece,\n isConfigValueMissing,\n packageFromConnectorId,\n planFromAuth,\n type AuthField,\n} from \"../editors/connection-editor/piece-auth.js\";\nimport {\n checkConnection as runConnectionCheck,\n fetchConnections,\n fetchPieceActions,\n fetchPieceCatalog,\n fetchPieceTriggers,\n type PieceSummary,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { workflowTools } from \"./workflow-tools.js\";\n\nconst MAX_CONNECTORS = 20;\n\nexport interface ConnectorField {\n name: string;\n label: string;\n required: boolean;\n description?: string;\n secret: boolean;\n}\n\nexport interface ConnectorDetail {\n connectorId: string;\n pieceName: string;\n displayName: string;\n description: string;\n version: string;\n authType: string;\n /** False for auth kinds the runtime cannot execute yet (OIDC). */\n supported: boolean;\n /** OAUTH2: a person finishes it by signing in from the connection editor. */\n signIn?: \"oauth2\";\n fields: ConnectorField[];\n actions: string[];\n triggers: string[];\n}\n\nfunction toField(field: AuthField, secret: boolean): ConnectorField {\n return {\n name: field.name,\n label: field.displayName,\n required: field.required,\n description: field.description,\n secret,\n };\n}\n\nasync function connectorDetail(piece: PieceSummary): Promise<ConnectorDetail> {\n const plan = planFromAuth(piece.auth);\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(piece.name),\n fetchPieceTriggers(piece.name),\n ]);\n return {\n connectorId: connectorIdForPiece(piece.name),\n pieceName: piece.name,\n displayName: piece.displayName,\n description: piece.description,\n version: piece.version,\n authType: plan.authType,\n supported: plan.supported,\n ...(plan.oauth2 ? { signIn: \"oauth2\" as const } : {}),\n fields: [\n ...plan.configFields.map((field) => toField(field, false)),\n ...plan.secretFields.map((field) => toField(field, true)),\n ],\n actions: actions.map((action) => action.name),\n triggers: triggers.map((trigger) => trigger.name),\n };\n}\n\n/**\n * Stage one of connector discovery: the catalog, optionally narrowed to a\n * case-insensitive substring match on name, display name, or description,\n * capped at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is\n * fetched only for the surviving entries (stage two).\n */\nexport async function getConnectors(query?: string): Promise<{\n total: number;\n matches: number;\n truncated: boolean;\n connectors: ConnectorDetail[];\n}> {\n syncRuntimeUrl();\n const catalog = await fetchPieceCatalog();\n const needle = query?.trim().toLowerCase();\n const matches = needle\n ? catalog.filter((piece) =>\n [piece.name, piece.displayName, piece.description].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n )\n : [...catalog];\n const page = matches.slice(0, MAX_CONNECTORS);\n const connectors = await Promise.all(page.map(connectorDetail));\n return {\n total: catalog.length,\n matches: matches.length,\n truncated: matches.length > page.length,\n connectors,\n };\n}\n\ninterface ConnectionState {\n config?: unknown;\n secretRefs?: { name: string }[];\n}\n\nexport interface ConnectionDetail {\n id: string;\n name: string;\n connectorId: string;\n authType: string;\n status: string;\n accountLabel: string | null;\n /** Required secret fields with no stored ref, by auth property name. */\n missingSecrets: string[];\n /** Required config fields with no value, by auth property name. */\n missingConfig: string[];\n}\n\n/**\n * Every connection document with its credential state compared against the\n * piece's auth plan. Only field names and opaque refs are surfaced; secret\n * values never do.\n */\nexport async function getConnections(): Promise<{\n connections: ConnectionDetail[];\n}> {\n syncRuntimeUrl();\n const [catalog, summaries] = await Promise.all([\n fetchPieceCatalog(),\n fetchConnections(),\n ]);\n const client =\n typeof window !== \"undefined\" ? window.ph?.reactorClient : undefined;\n const connections = await Promise.all(\n summaries.map(async (summary) => {\n const piece = catalog.find(\n (entry) => entry.name === packageFromConnectorId(summary.connectorId),\n );\n const plan = planFromAuth(piece?.auth ?? null);\n let state: ConnectionState | undefined;\n if (client) {\n try {\n const document = await client.get(summary.id);\n state = (document.state as { global?: ConnectionState }).global;\n } catch {\n state = undefined;\n }\n }\n const refNames = new Set(\n (state?.secretRefs ?? []).map((ref) => ref.name),\n );\n const config = (state?.config ?? {}) as Record<string, unknown>;\n return {\n id: summary.id,\n name: summary.name,\n connectorId: summary.connectorId,\n authType: summary.authType,\n status: summary.status,\n accountLabel: summary.accountLabel,\n missingSecrets: plan.secretFields\n .filter((field) => field.required && !refNames.has(field.name))\n .map((field) => field.name),\n missingConfig: plan.configFields\n .filter(\n (field) =>\n field.required && isConfigValueMissing(config[field.name]),\n )\n .map((field) => field.name),\n };\n }),\n );\n return { connections };\n}\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport const getConnectorsTool: PhAiToolDescriptor = {\n name: \"getConnectors\",\n description:\n \"Lists the connectors (Activepieces pieces) available to the workflow runtime with their auth fields, actions, and triggers. Without a query it returns up to 20 connectors; pass `query` to search by name or description. Secret fields are listed by name only, never by value.\",\n inputSchema: { query: z.string().optional() },\n annotations: { title: \"Get Connectors\", ...READ_ONLY },\n callback: (args: { query?: string }) => getConnectors(args.query),\n};\n\nexport const getConnectionsTool: PhAiToolDescriptor = {\n name: \"getConnections\",\n description:\n \"Lists the project's connection documents with their credential status: which required secrets and config values are still missing, and the last account label. Secret values are never included.\",\n inputSchema: {},\n annotations: { title: \"Get Connections\", ...READ_ONLY },\n callback: () => getConnections(),\n};\n\nexport const checkConnectionTool: PhAiToolDescriptor = {\n name: \"checkConnection\",\n description:\n \"Runs a connection's own check against its stored credentials to verify they work. Takes a connection id (from getConnections) and reports success, the failure detail, and the account label when the provider returns one.\",\n inputSchema: { connectionId: z.string() },\n annotations: { title: \"Check Connection\", ...READ_ONLY },\n callback: (args: { connectionId: string }) => {\n syncRuntimeUrl();\n return runConnectionCheck(args.connectionId);\n },\n};\n\n/** Tool descriptors the host app offers the AI assistant. */\nexport const aiTools: PhAiToolDescriptor[] = [\n getConnectorsTool,\n getConnectionsTool,\n checkConnectionTool,\n ...workflowTools,\n];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { EditorModule } from \"document-model\";\nimport { ConnectionEditor } from \"./connection-editor/module.js\";\nimport { WorkflowEditor } from \"./workflow-editor/module.js\";\nimport { WorkflowStudio } from \"./workflow-studio/module.js\";\n\nexport const editors: EditorModule[] = [\n ConnectionEditor,\n WorkflowEditor,\n WorkflowStudio,\n];\n","import type { Manifest } from \"document-model\";\nimport manifestJson from \"./powerhouse.manifest.json\" with { type: \"json\" };\n\nexport { aiTools } from \"./ai/tools.js\";\nexport { documentModels } from \"./document-models/document-models.js\";\nexport { upgradeManifests } from \"./document-models/upgrade-manifests.js\";\nexport { editors } from \"./editors/editors.js\";\nexport const manifest = manifestJson as Manifest;\n"],"mappings":";;;;;;;;;;AAkBA,IAAI,UAAyB,oBAAoB,mBAAmB;AAEpE,MAAM,iBAAiB,yBAAyB;AAEhD,SAAgB,cAAc,KAAmB;CAC/C,IAAI,QAAQ,QAAQ,KAAK,UAAU,oBAAoB,GAAG;AAC5D;AAEA,MAAa,gBAAgB,UAC3B,eAAe,WAAW,eAAe,SAAS,KAAK,CAAC;AAC1D,MAAa,0BACX,eAAe,WAAW,aAAa,OAAO,CAAC;AACjD,MAAa,qBAAqB,gBAChC,QAAQ,kBAAkB,WAAW;AACvC,MAAa,sBAAsB,gBACjC,QAAQ,mBAAmB,WAAW;AACxC,MAAa,yBAAyB,QAAQ,iBAAiB;AAC/D,MAAa,mBAAmB,iBAC9B,QAAQ,gBAAgB,YAAY;AACtC,MAAa,aAAa,UAAsB,QAAQ,UAAU,KAAK;AACvE,MAAa,gBAAgB,YAAoB,YAC/C,QAAQ,aAAa,YAAY,OAAO;;;AC/B1C,SAAgB,iBAAuB;CACrC,IAAI,OAAO,WAAW,aAAa;CACnC,MAAM,cAAc,wBAAwB,OAAO,IAAI,eAAe;CAGtE,cACE,cACI,GAAG,YAAY,WAAW,qBAC1B,mBACN;AACF;;;ACGA,MAAMA,cAAY;CAChB,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;AACjB;AAEA,SAAS,OAAO,OAAqC;CACnD,OAAO,MAAM,SAAS,YAAY,YAAY;AAChD;AAGA,SAAS,YAAY,OAAiB;CACpC,OAAO;EACL,WAAW,MAAM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B,QAAQ,QAAQ;GAChB,cAAc,QAAQ;GACtB,gBAAgB,KAAK,aAClB,QAAQ,UAAU,MAAM,YAAY,CAAC,SAAS,IAAI,MAAM,IAAI,CAAC,CAAC,CAC9D,KAAK,UAAU,MAAM,IAAI;GAC5B,eAAe,KAAK,aACjB,QACE,UACC,MAAM,YAAY,qBAAqB,OAAO,MAAM,KAAK,CAC7D,CAAC,CACA,KAAK,UAAU,MAAM,IAAI;EAC9B;CACF,CAAC,CACH,EACqB;AACvB;AAEA,MAAM,YAAY;CAChB,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;AACjB;;AAiCA,MAAa,UAAgC;CAC3C;EA/BA,MAAM;EACN,aACE;EACF,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE;EAC5C,aAAa;GAAE,OAAO;GAAkB,GAAG;EAAU;EACrD,WAAW,SAA6B,cAAc,KAAK,KAAK;CA0BhE;CACA;EAvBA,MAAM;EACN,aACE;EACF,aAAa,CAAC;EACd,aAAa;GAAE,OAAO;GAAmB,GAAG;EAAU;EACtD,gBAAgB,eAAe;CAkB/B;CACA;EAfA,MAAM;EACN,aACE;EACF,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE;EACxC,aAAa;GAAE,OAAO;GAAoB,GAAG;EAAU;EACvD,WAAW,SAAmC;GAC5C,eAAe;GACf,OAAOC,gBAAmB,KAAK,YAAY;EAC7C;CAOA;CACA,GAAG;AACL;;;AChOA,MAAa,UAA0B;CACrC;CACA;CACA;AACF;;;ACNA,MAAa,WAAWC"}
1
+ {"version":3,"file":"index.js","names":["READ_ONLY","runConnectionCheck","manifestJson"],"sources":["../../editors/workflow-editor/runtime-api.ts","../../ai/runtime-url.ts","../../ai/workflow-tools.ts","../../ai/tools.ts","../../editors/editors.ts","../../index.ts"],"sourcesContent":["// Ambient runtime client for the AI tools, which run outside any editor.\n// Editors never import this: each one gets its own client from RuntimeProvider.\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\nimport {\n createRuntimeClient,\n DEFAULT_RUNTIME_URL,\n type RunsScope,\n type RuntimeClient,\n} from \"./runtime-client.js\";\nimport {\n blockFormQuery,\n catalogQuery,\n createRuntimeQueryClient,\n} from \"./runtime-queries.js\";\n\nexport type * from \"./runtime-client.js\";\nexport { DEFAULT_RUNTIME_URL };\n\nlet ambient: RuntimeClient = createRuntimeClient(DEFAULT_RUNTIME_URL);\n// Keys start with the URL, so switching runtimes needs no cache reset.\nconst ambientQueries = createRuntimeQueryClient();\n\nexport function setRuntimeUrl(url: string): void {\n if (url !== ambient.url) ambient = createRuntimeClient(url);\n}\n\nexport const getBlockForm = (block: BlockRef) =>\n ambientQueries.fetchQuery(blockFormQuery(ambient, block));\nexport const fetchPieceCatalog = () =>\n ambientQueries.fetchQuery(catalogQuery(ambient));\nexport const fetchPieceActions = (packageName: string) =>\n ambient.fetchPieceActions(packageName);\nexport const fetchPieceTriggers = (packageName: string) =>\n ambient.fetchPieceTriggers(packageName);\nexport const fetchConnections = () => ambient.fetchConnections();\nexport const checkConnection = (connectionId: string) =>\n ambient.checkConnection(connectionId);\nexport const fetchRuns = (scope?: RunsScope) => ambient.fetchRuns(scope);\nexport const fireWorkflow = (workflowId: string, payload?: unknown) =>\n ambient.fireWorkflow(workflowId, payload);\n","// Points the module-level runtime client at the selected drive's\n// workflow-runtime subgraph before an AI tool talks to it.\nimport { resolveDriveSwitchboard } from \"@powerhousedao/reactor-browser/ai\";\nimport {\n DEFAULT_RUNTIME_URL,\n setRuntimeUrl,\n} from \"../editors/workflow-editor/runtime-api.js\";\n\nexport function syncRuntimeUrl(): void {\n if (typeof window === \"undefined\") return;\n const switchboard = resolveDriveSwitchboard(window.ph?.selectedDriveId);\n // No resolvable switchboard (no selection, or a local/unsynced drive):\n // reset to the default rather than leaving a prior drive's URL attached.\n setRuntimeUrl(\n switchboard\n ? `${switchboard.graphqlUrl}/workflow-runtime`\n : DEFAULT_RUNTIME_URL,\n );\n}\n","// AI tool descriptors for authoring and running workflows: the pinned blocks\n// a piece offers, a block's config props, the built-in core blocks with\n// the expression syntax, run history and manual firing. Complements the\n// connector/connection tools in tools.ts, which cover the catalog and auth.\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n fetchPieceActions,\n fetchPieceTriggers,\n fetchRuns,\n fireWorkflow,\n getBlockForm,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport type { BlockFormProp } from \"../editors/workflow-editor/ui/forms.js\";\nimport {\n CORE_PIECE,\n type BlockRef,\n} from \"../editors/workflow-editor/ui/blocks.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { flowPorts } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nfunction kindOf(block: BlockRef): \"trigger\" | \"step\" {\n return block.kind === \"trigger\" ? \"trigger\" : \"step\";\n}\n\n// The fields ADD_STEP or SET_TRIGGER takes for the block.\nfunction blockFields(block: BlockRef) {\n return {\n pieceName: block.pieceName,\n pieceVersion: block.pieceVersion,\n ...(block.kind === \"trigger\"\n ? { triggerName: block.name }\n : { actionName: block.name }),\n };\n}\n\n// The onward ports the block's descriptor declares; \"error\" is a failure route.\nfunction portsFor(form: { ports?: readonly string[] }): string[] {\n return flowPorts(form.ports ?? []);\n}\n\nfunction describeProp(prop: BlockFormProp) {\n return {\n name: prop.name,\n label: prop.displayName,\n type: prop.type,\n required: prop.required,\n ...(prop.description ? { description: prop.description } : {}),\n ...(prop.defaultValue !== undefined ? { default: prop.defaultValue } : {}),\n ...(prop.staticOptions\n ? { options: prop.staticOptions.map((option) => option.value) }\n : {}),\n ...(prop.hasDynamicResolver ? { dynamicOptions: true } : {}),\n };\n}\n\nconst EXPRESSIONS = [\n \"Step configs and edge conditions may contain expressions in double braces.\",\n \"{{trigger.payload.<field>}} reads the trigger payload: for the core manual trigger the payload passed to fireWorkflow; for the reactor piece's document triggers it carries documentId, documentType, driveId and name.\",\n \"{{steps.<key>.output.<path>}} reads an upstream step's output by that step's key, e.g. {{steps.fetch.output.body.title}}.\",\n \"{{variables.<key>}} reads a workflow variable.\",\n \"'a' || 'b' picks the first non-empty value, e.g. {{trigger.payload.url || 'https://example.com'}}.\",\n \"A whole-string expression yields the raw value; text around expressions is interpolated.\",\n];\n\nconst GRAPH_RULES = [\n \"A workflow is a powerhouse/workflow document. Build it with SET_TRIGGER once, ADD_STEP per step (each with a unique id and key), and ADD_EDGE from the trigger id to the first step and between steps.\",\n \"An edge must leave on a port its source declares (getWorkflowBlockConfig lists them): 'next' for the trigger and ordinary steps, 'true' and 'false' for the core branch action, 'error' to route a failure. An edge on any other port is never taken, and the run is flagged with a warning.\",\n \"A step names its block with pieceName, pieceVersion and actionName; the trigger with pieceName, pieceVersion and triggerName. pieceVersion is an exact semver: copy the fields getWorkflowPieceBlocks or listWorkflowCoreBlocks return.\",\n `The built-in blocks (manual, schedule and webhook triggers, branch and assert) belong to the piece ${CORE_PIECE}.`,\n \"Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).\",\n \"Runs execute the published snapshot, not the draft. PUBLISH_WORKFLOW only snapshots the draft, so publish again after every edit that should run.\",\n \"Only ENABLED workflows get trigger instances and can be fired. PUBLISH_WORKFLOW does not enable: to turn a workflow on, dispatch SET_WORKFLOW_STATUS ENABLED after PUBLISH_WORKFLOW (the same batch works). SET_WORKFLOW_STATUS ENABLED is refused until the workflow has been published once.\",\n];\n\nexport const getWorkflowPieceBlocksTool: PhAiToolDescriptor = {\n name: \"getWorkflowPieceBlocks\",\n description:\n \"Lists the actions and triggers of one piece, each with the pieceName, pieceVersion and actionName or triggerName to use in ADD_STEP or SET_TRIGGER. Takes the piece package name from getConnectors. Call getWorkflowBlockConfig next for a block's config props.\",\n inputSchema: {\n packageName: z\n .string()\n .describe(\"Piece package name, e.g. @activepieces/piece-http.\"),\n },\n annotations: { title: \"Get Workflow Piece Blocks\", ...READ_ONLY },\n callback: async (args: { packageName: string }) => {\n syncRuntimeUrl();\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(args.packageName),\n fetchPieceTriggers(args.packageName),\n ]);\n return {\n packageName: args.packageName,\n actions: actions.map((action) => ({\n pieceName: action.pieceName,\n pieceVersion: action.pieceVersion,\n actionName: action.name,\n displayName: action.displayName,\n description: action.description,\n })),\n triggers: triggers.map((trigger) => ({\n pieceName: trigger.pieceName,\n pieceVersion: trigger.pieceVersion,\n triggerName: trigger.name,\n displayName: trigger.displayName,\n description: trigger.description,\n strategy: trigger.strategy,\n })),\n };\n },\n};\n\nexport const getWorkflowBlockConfigTool: PhAiToolDescriptor = {\n name: \"getWorkflowBlockConfig\",\n description:\n \"Describes the config of one block (a core block or a piece's action or trigger): prop names, types, whether required, allowed options, the output ports, and whether a connection is needed. Use it before writing a step or trigger config.\",\n inputSchema: {\n pieceName: z\n .string()\n .describe(\n `Piece package name, e.g. ${CORE_PIECE} or @activepieces/piece-http.`,\n ),\n pieceVersion: z.string().describe(\"Exact semver of the piece.\"),\n name: z\n .string()\n .describe(\"Action or trigger name, e.g. branch or send_request.\"),\n kind: z.enum([\"action\", \"trigger\"]).describe(\"action or trigger.\"),\n },\n annotations: { title: \"Get Workflow Block Config\", ...READ_ONLY },\n callback: async (args: BlockRef) => {\n const block: BlockRef = {\n pieceName: args.pieceName,\n pieceVersion: args.pieceVersion,\n name: args.name,\n kind: args.kind,\n };\n syncRuntimeUrl();\n const form = await getBlockForm(block);\n if (!form) {\n return {\n ...blockFields(block),\n error:\n \"Unknown block. Use getConnectors and getWorkflowPieceBlocks to find valid blocks (documents live in @powerhousedao/piece-reactor), or listWorkflowCoreBlocks for built-ins.\",\n };\n }\n return {\n ...blockFields(block),\n title: form.title,\n kind: kindOf(block),\n requiresConnection: form.auth === \"required\",\n props: form.props.map(describeProp),\n ports: portsFor(form),\n };\n },\n};\n\nexport const listWorkflowCoreBlocksTool: PhAiToolDescriptor = {\n name: \"listWorkflowCoreBlocks\",\n description: `Lists the built-in blocks of the ${CORE_PIECE} piece (manual, schedule and webhook triggers, branch and assert) with their pinned fields and config props, plus the expression syntax and the rules for building a powerhouse/workflow document. Documents are read and written by the @powerhousedao/piece-reactor blocks; list those with getWorkflowPieceBlocks.`,\n inputSchema: {},\n annotations: { title: \"List Workflow Core Blocks\", ...READ_ONLY },\n callback: async () => {\n syncRuntimeUrl();\n // The reactor serves the core piece's descriptors, as it does any piece's.\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(CORE_PIECE),\n fetchPieceTriggers(CORE_PIECE),\n ]);\n const blocks: BlockRef[] = [\n ...triggers.map((entry) => ({ ...entry, kind: \"trigger\" as const })),\n ...actions.map((entry) => ({ ...entry, kind: \"action\" as const })),\n ].map((entry) => ({\n pieceName: entry.pieceName,\n pieceVersion: entry.pieceVersion,\n name: entry.name,\n kind: entry.kind,\n }));\n const forms = await Promise.all(blocks.map(getBlockForm));\n return {\n blocks: blocks.flatMap((block, index) => {\n const form = forms[index];\n if (!form) return [];\n return [\n {\n ...blockFields(block),\n title: form.title,\n kind: kindOf(block),\n props: form.props.map(describeProp),\n ports: portsFor(form),\n },\n ];\n }),\n expressions: EXPRESSIONS,\n rules: GRAPH_RULES,\n };\n },\n};\n\nexport const listWorkflowRunsTool: PhAiToolDescriptor = {\n name: \"listWorkflowRuns\",\n description:\n \"Lists recent workflow runs, newest first, with status, error and each step's outcome. Filter by workflowId to inspect one workflow, or by driveId for every workflow in a drive.\",\n inputSchema: {\n workflowId: z\n .string()\n .optional()\n .describe(\"Workflow document id to filter by.\"),\n driveId: z\n .string()\n .optional()\n .describe(\"Drive id to filter by (all workflows in that drive).\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe(\"Maximum runs to return (default 10).\"),\n },\n annotations: { title: \"List Workflow Runs\", ...READ_ONLY },\n callback: async (args: {\n workflowId?: string;\n driveId?: string;\n limit?: number;\n }) => {\n syncRuntimeUrl();\n const runs = await fetchRuns({\n workflowId: args.workflowId,\n driveId: args.driveId,\n limit: args.limit ?? 10,\n });\n return {\n runs: runs.map((run) => ({\n id: run.id,\n workflowId: run.workflowId,\n workflowName: run.workflowName,\n status: run.status,\n error: run.error,\n triggerKind: run.triggerKind,\n startedAt: run.startedAt,\n endedAt: run.endedAt,\n steps: run.steps.map((step) => ({\n key: step.stepKey,\n status: step.status,\n error: step.error,\n })),\n })),\n };\n },\n};\n\nexport const fireWorkflowTool: PhAiToolDescriptor = {\n name: \"fireWorkflow\",\n description:\n \"Fires an ENABLED workflow whose trigger is the core manual trigger and runs its published snapshot to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.\",\n inputSchema: {\n workflowId: z.string().describe(\"Workflow document id.\"),\n payload: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Trigger payload object.\"),\n },\n annotations: {\n title: \"Fire Workflow\",\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n },\n callback: (args: {\n workflowId: string;\n payload?: Record<string, unknown>;\n }) => {\n syncRuntimeUrl();\n return fireWorkflow(args.workflowId, args.payload ?? {});\n },\n};\n\n/** Workflow authoring and run tools, merged into `aiTools` in tools.ts. */\nexport const workflowTools: PhAiToolDescriptor[] = [\n getWorkflowPieceBlocksTool,\n getWorkflowBlockConfigTool,\n listWorkflowCoreBlocksTool,\n listWorkflowRunsTool,\n fireWorkflowTool,\n];\n","// Read-only AI tool descriptors for the Connect assistant: the project's\n// piece catalog, connection documents, and connection health. The `aiTools`\n// export is how the host app discovers this package's tools (the line in the\n// project index is synced by `ph generate`).\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n connectorIdForPiece,\n isConfigValueMissing,\n packageFromConnectorId,\n planFromAuth,\n type AuthField,\n} from \"../editors/connection-editor/piece-auth.js\";\nimport {\n checkConnection as runConnectionCheck,\n fetchConnections,\n fetchPieceActions,\n fetchPieceCatalog,\n fetchPieceTriggers,\n type PieceSummary,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { workflowTools } from \"./workflow-tools.js\";\n\nconst MAX_CONNECTORS = 20;\n\nexport interface ConnectorField {\n name: string;\n label: string;\n required: boolean;\n description?: string;\n secret: boolean;\n}\n\nexport interface ConnectorDetail {\n connectorId: string;\n pieceName: string;\n displayName: string;\n description: string;\n version: string;\n authType: string;\n /** False for auth kinds the runtime cannot execute yet (OIDC). */\n supported: boolean;\n /** OAUTH2: a person finishes it by signing in from the connection editor. */\n signIn?: \"oauth2\";\n fields: ConnectorField[];\n actions: string[];\n triggers: string[];\n}\n\nfunction toField(field: AuthField, secret: boolean): ConnectorField {\n return {\n name: field.name,\n label: field.displayName,\n required: field.required,\n description: field.description,\n secret,\n };\n}\n\nasync function connectorDetail(piece: PieceSummary): Promise<ConnectorDetail> {\n const plan = planFromAuth(piece.auth);\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(piece.name),\n fetchPieceTriggers(piece.name),\n ]);\n return {\n connectorId: connectorIdForPiece(piece.name),\n pieceName: piece.name,\n displayName: piece.displayName,\n description: piece.description,\n version: piece.version,\n authType: plan.authType,\n supported: plan.supported,\n ...(plan.oauth2 ? { signIn: \"oauth2\" as const } : {}),\n fields: [\n ...plan.configFields.map((field) => toField(field, false)),\n ...plan.secretFields.map((field) => toField(field, true)),\n ],\n actions: actions.map((action) => action.name),\n triggers: triggers.map((trigger) => trigger.name),\n };\n}\n\n/**\n * Stage one of connector discovery: the catalog, optionally narrowed to a\n * case-insensitive substring match on name, display name, or description,\n * capped at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is\n * fetched only for the surviving entries (stage two).\n */\nexport async function getConnectors(query?: string): Promise<{\n total: number;\n matches: number;\n truncated: boolean;\n connectors: ConnectorDetail[];\n}> {\n syncRuntimeUrl();\n const catalog = await fetchPieceCatalog();\n const needle = query?.trim().toLowerCase();\n const matches = needle\n ? catalog.filter((piece) =>\n [piece.name, piece.displayName, piece.description].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n )\n : [...catalog];\n const page = matches.slice(0, MAX_CONNECTORS);\n const connectors = await Promise.all(page.map(connectorDetail));\n return {\n total: catalog.length,\n matches: matches.length,\n truncated: matches.length > page.length,\n connectors,\n };\n}\n\ninterface ConnectionState {\n config?: unknown;\n secretRefs?: { name: string }[];\n}\n\nexport interface ConnectionDetail {\n id: string;\n name: string;\n connectorId: string;\n authType: string;\n status: string;\n accountLabel: string | null;\n /** Required secret fields with no stored ref, by auth property name. */\n missingSecrets: string[];\n /** Required config fields with no value, by auth property name. */\n missingConfig: string[];\n}\n\n/**\n * Every connection document with its credential state compared against the\n * piece's auth plan. Only field names and opaque refs are surfaced; secret\n * values never do.\n */\nexport async function getConnections(): Promise<{\n connections: ConnectionDetail[];\n}> {\n syncRuntimeUrl();\n const [catalog, summaries] = await Promise.all([\n fetchPieceCatalog(),\n fetchConnections(),\n ]);\n const client =\n typeof window !== \"undefined\" ? window.ph?.reactorClient : undefined;\n const connections = await Promise.all(\n summaries.map(async (summary) => {\n const piece = catalog.find(\n (entry) => entry.name === packageFromConnectorId(summary.connectorId),\n );\n const plan = planFromAuth(piece?.auth ?? null);\n let state: ConnectionState | undefined;\n if (client) {\n try {\n const document = await client.get(summary.id);\n state = (document.state as { global?: ConnectionState }).global;\n } catch {\n state = undefined;\n }\n }\n const refNames = new Set(\n (state?.secretRefs ?? []).map((ref) => ref.name),\n );\n const config = (state?.config ?? {}) as Record<string, unknown>;\n return {\n id: summary.id,\n name: summary.name,\n connectorId: summary.connectorId,\n authType: summary.authType,\n status: summary.status,\n accountLabel: summary.accountLabel,\n missingSecrets: plan.secretFields\n .filter((field) => field.required && !refNames.has(field.name))\n .map((field) => field.name),\n missingConfig: plan.configFields\n .filter(\n (field) =>\n field.required && isConfigValueMissing(config[field.name]),\n )\n .map((field) => field.name),\n };\n }),\n );\n return { connections };\n}\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport const getConnectorsTool: PhAiToolDescriptor = {\n name: \"getConnectors\",\n description:\n \"Lists the connectors (Activepieces pieces) available to the workflow runtime with their auth fields, actions, and triggers. Without a query it returns up to 20 connectors; pass `query` to search by name or description. Secret fields are listed by name only, never by value.\",\n inputSchema: { query: z.string().optional() },\n annotations: { title: \"Get Connectors\", ...READ_ONLY },\n callback: (args: { query?: string }) => getConnectors(args.query),\n};\n\nexport const getConnectionsTool: PhAiToolDescriptor = {\n name: \"getConnections\",\n description:\n \"Lists the project's connection documents with their credential status: which required secrets and config values are still missing, and the last account label. Secret values are never included.\",\n inputSchema: {},\n annotations: { title: \"Get Connections\", ...READ_ONLY },\n callback: () => getConnections(),\n};\n\nexport const checkConnectionTool: PhAiToolDescriptor = {\n name: \"checkConnection\",\n description:\n \"Runs a connection's own check against its stored credentials to verify they work. Takes a connection id (from getConnections) and reports success, the failure detail, and the account label when the provider returns one.\",\n inputSchema: { connectionId: z.string() },\n annotations: { title: \"Check Connection\", ...READ_ONLY },\n callback: (args: { connectionId: string }) => {\n syncRuntimeUrl();\n return runConnectionCheck(args.connectionId);\n },\n};\n\n/** Tool descriptors the host app offers the AI assistant. */\nexport const aiTools: PhAiToolDescriptor[] = [\n getConnectorsTool,\n getConnectionsTool,\n checkConnectionTool,\n ...workflowTools,\n];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { EditorModule } from \"document-model\";\nimport { ConnectionEditor } from \"./connection-editor/module.js\";\nimport { WorkflowEditor } from \"./workflow-editor/module.js\";\nimport { WorkflowStudio } from \"./workflow-studio/module.js\";\n\nexport const editors: EditorModule[] = [\n ConnectionEditor,\n WorkflowEditor,\n WorkflowStudio,\n];\n","import type { Manifest } from \"document-model\";\nimport manifestJson from \"./powerhouse.manifest.json\" with { type: \"json\" };\n\nexport { aiTools } from \"./ai/tools.js\";\nexport { documentModels } from \"./document-models/document-models.js\";\nexport { upgradeManifests } from \"./document-models/upgrade-manifests.js\";\nexport { editors } from \"./editors/editors.js\";\nexport const manifest = manifestJson as Manifest;\n"],"mappings":";;;;;;;;;;AAkBA,IAAI,UAAyB,oBAAoB,mBAAmB;AAEpE,MAAM,iBAAiB,yBAAyB;AAEhD,SAAgB,cAAc,KAAmB;CAC/C,IAAI,QAAQ,QAAQ,KAAK,UAAU,oBAAoB,GAAG;AAC5D;AAEA,MAAa,gBAAgB,UAC3B,eAAe,WAAW,eAAe,SAAS,KAAK,CAAC;AAC1D,MAAa,0BACX,eAAe,WAAW,aAAa,OAAO,CAAC;AACjD,MAAa,qBAAqB,gBAChC,QAAQ,kBAAkB,WAAW;AACvC,MAAa,sBAAsB,gBACjC,QAAQ,mBAAmB,WAAW;AACxC,MAAa,yBAAyB,QAAQ,iBAAiB;AAC/D,MAAa,mBAAmB,iBAC9B,QAAQ,gBAAgB,YAAY;AACtC,MAAa,aAAa,UAAsB,QAAQ,UAAU,KAAK;AACvE,MAAa,gBAAgB,YAAoB,YAC/C,QAAQ,aAAa,YAAY,OAAO;;;AC/B1C,SAAgB,iBAAuB;CACrC,IAAI,OAAO,WAAW,aAAa;CACnC,MAAM,cAAc,wBAAwB,OAAO,IAAI,eAAe;CAGtE,cACE,cACI,GAAG,YAAY,WAAW,qBAC1B,mBACN;AACF;;;ACGA,MAAMA,cAAY;CAChB,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;AACjB;AAEA,SAAS,OAAO,OAAqC;CACnD,OAAO,MAAM,SAAS,YAAY,YAAY;AAChD;AAGA,SAAS,YAAY,OAAiB;CACpC,OAAO;EACL,WAAW,MAAM;EACjB,cAAc,MAAM;EACpB,GAAI,MAAM,SAAS,YACf,EAAE,aAAa,MAAM,KAAK,IAC1B,EAAE,YAAY,MAAM,KAAK;CAC/B;AACF;AAGA,SAAS,SAAS,MAA+C;CAC/D,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC;AACnC;AA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ACE,UACC,MAAM,YAAY,qBAAqB,OAAO,MAAM,KAAK,CAC7D,CAAC,CACA,KAAK,UAAU,MAAM,IAAI;EAC9B;CACF,CAAC,CACH,EACqB;AACvB;AAEA,MAAM,YAAY;CAChB,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;AACjB;;AAiCA,MAAa,UAAgC;CAC3C;EA/BA,MAAM;EACN,aACE;EACF,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE;EAC5C,aAAa;GAAE,OAAO;GAAkB,GAAG;EAAU;EACrD,WAAW,SAA6B,cAAc,KAAK,KAAK;CA0BhE;CACA;EAvBA,MAAM;EACN,aACE;EACF,aAAa,CAAC;EACd,aAAa;GAAE,OAAO;GAAmB,GAAG;EAAU;EACtD,gBAAgB,eAAe;CAkB/B;CACA;EAfA,MAAM;EACN,aACE;EACF,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE;EACxC,aAAa;GAAE,OAAO;GAAoB,GAAG;EAAU;EACvD,WAAW,SAAmC;GAC5C,eAAe;GACf,OAAOC,gBAAmB,KAAK,YAAY;EAC7C;CAOA;CACA,GAAG;AACL;;;AChOA,MAAa,UAA0B;CACrC;CACA;CACA;AACF;;;ACNA,MAAa,WAAWC"}
@@ -1,6 +1,6 @@
1
1
  import { J as SCHEDULE_TRIGGER, Z as WEBHOOK_TRIGGER, q as MANUAL_TRIGGER, ut as parseScheduleConfig } from "./runtime-queries-Ds2kk-Ow.js";
2
2
  import { Rt as blockKey } from "./module-DU2vb3FH.js";
3
- import { At as Tooltip, B as blockMeta, bt as Button, kt as Toggle, wt as IconButton } from "./BlockSelector-BQDqIbRZ.js";
3
+ import { At as Tooltip, B as blockMeta, bt as Button, kt as Toggle, wt as IconButton } from "./BlockSelector-M4p5MOwM.js";
4
4
  import * as React$1 from "react";
5
5
  import { Suspense, lazy, useState } from "react";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -5385,7 +5385,7 @@ function Modal(props) {
5385
5385
  }
5386
5386
  //#endregion
5387
5387
  //#region editors/shared/data-viewer.tsx
5388
- const DataTree = lazy(() => import("./data-tree-CZZkfzSH.js"));
5388
+ const DataTree = lazy(() => import("./data-tree-Bicz9eW6.js"));
5389
5389
  function stringify(value) {
5390
5390
  try {
5391
5391
  return JSON.stringify(value, null, 2) ?? "";
@@ -5564,6 +5564,6 @@ function describeTrigger(trigger) {
5564
5564
  }
5565
5565
  }
5566
5566
  //#endregion
5567
- export { Modal as a, PublishState as c, VARIABLES_VIEW as d, uniqueStepKey as f, DataViewer as i, StatusToggle as l, describeSchedule as n, DraftBanner as o, describeTrigger as r, PublishButton as s, describeCron as t, usePublish as u };
5567
+ export { Modal as a, PublishState as c, VARIABLES_VIEW as d, hasDraftChanges as f, DataViewer as i, StatusToggle as l, describeSchedule as n, DraftBanner as o, uniqueStepKey as p, describeTrigger as r, PublishButton as s, describeCron as t, usePublish as u };
5568
5568
 
5569
- //# sourceMappingURL=trigger-text-D-Sh6ZaI.js.map
5569
+ //# sourceMappingURL=trigger-text-DEN9d_Np.js.map