@powerhousedao/workflow 6.2.3-dev.88 → 6.2.3-dev.89

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 (108) hide show
  1. package/dist/browser/{BlockSelector-BKAJwJ4Y.js → BlockSelector-DFzzAWXh.js} +65 -7
  2. package/dist/browser/BlockSelector-DFzzAWXh.js.map +1 -0
  3. package/dist/browser/{connection-form-DltdMa8F.js → connection-form-B6zpGmAm.js} +3 -3
  4. package/dist/browser/{connection-form-DltdMa8F.js.map → connection-form-B6zpGmAm.js.map} +1 -1
  5. package/dist/browser/{data-tree-DAw8e0j8.js → data-tree-DKS0EQys.js} +2 -2
  6. package/dist/browser/{data-tree-DAw8e0j8.js.map → data-tree-DKS0EQys.js.map} +1 -1
  7. package/dist/browser/{editor-Dl6lzxkM.js → editor-Yt-_V04R.js} +207 -58
  8. package/dist/browser/editor-Yt-_V04R.js.map +1 -0
  9. package/dist/browser/{editor-CZLe6CAF.js → editor-bHCkW_XB.js} +4 -4
  10. package/dist/browser/{editor-CZLe6CAF.js.map → editor-bHCkW_XB.js.map} +1 -1
  11. package/dist/browser/{editor--J61vLSC.js → editor-gCkAwv09.js} +64 -132
  12. package/dist/browser/editor-gCkAwv09.js.map +1 -0
  13. package/dist/browser/editors/connection-editor/module.js +1 -1
  14. package/dist/browser/editors/runtime/index.js +1 -1
  15. package/dist/browser/editors/workflow-editor/module.js +1 -1
  16. package/dist/browser/editors/workflow-studio/module.js +1 -1
  17. package/dist/browser/index.js +2 -1
  18. package/dist/browser/index.js.map +1 -1
  19. package/dist/browser/{runtime-queries-D81Ghpok.js → runtime-queries-C5bqAgQy.js} +84 -13
  20. package/dist/browser/runtime-queries-C5bqAgQy.js.map +1 -0
  21. package/dist/browser/{trigger-text-BSVi5oGZ.js → trigger-text-BfIu-QcC.js} +176 -11
  22. package/dist/browser/trigger-text-BfIu-QcC.js.map +1 -0
  23. package/dist/node/{BlockSelector-DnTRF-C7.mjs → BlockSelector-Cia1Rpwz.mjs} +64 -6
  24. package/dist/node/BlockSelector-Cia1Rpwz.mjs.map +1 -0
  25. package/dist/node/{connection-form-DwSHfIRw.mjs → connection-form-CJFKPwfg.mjs} +3 -3
  26. package/dist/node/{connection-form-DwSHfIRw.mjs.map → connection-form-CJFKPwfg.mjs.map} +1 -1
  27. package/dist/node/{data-tree-uSJU9Ost.mjs → data-tree-D9jdFsaX.mjs} +2 -2
  28. package/dist/node/{data-tree-uSJU9Ost.mjs.map → data-tree-D9jdFsaX.mjs.map} +1 -1
  29. package/dist/node/{editor-B4ZwM3pR.mjs → editor-CwOjO82y.mjs} +63 -131
  30. package/dist/node/editor-CwOjO82y.mjs.map +1 -0
  31. package/dist/node/{editor-_4XHbqGl.mjs → editor-NMRVprgI.mjs} +206 -57
  32. package/dist/node/editor-NMRVprgI.mjs.map +1 -0
  33. package/dist/node/{editor-cXi5dIsd.mjs → editor-_c6UDRAN.mjs} +4 -4
  34. package/dist/node/{editor-cXi5dIsd.mjs.map → editor-_c6UDRAN.mjs.map} +1 -1
  35. package/dist/node/editors/connection-editor/module.mjs +1 -1
  36. package/dist/node/editors/runtime/index.mjs +1 -1
  37. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  38. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  39. package/dist/node/index.mjs +2 -1
  40. package/dist/node/index.mjs.map +1 -1
  41. package/dist/node/pieces/ai/descriptor.json +70 -1
  42. package/dist/node/pieces/ai/index.mjs +125 -125
  43. package/dist/node/pieces/ai/package.json +1 -1
  44. package/dist/node/pieces/reactor/descriptor.json +35 -1
  45. package/dist/node/pieces/reactor/index.mjs +39 -39
  46. package/dist/node/pieces/reactor/package.json +1 -1
  47. package/dist/node/{runtime-queries-VXJsWno5.mjs → runtime-queries-Ck5OoWdy.mjs} +137 -12
  48. package/dist/node/runtime-queries-Ck5OoWdy.mjs.map +1 -0
  49. package/dist/node/{trigger-text-BBP7QVLj.mjs → trigger-text-T2D0a2Br.mjs} +175 -10
  50. package/dist/node/trigger-text-T2D0a2Br.mjs.map +1 -0
  51. package/dist/powerhouse.manifest.json +2 -2
  52. package/dist/style.css +1 -1
  53. package/dist/types/ai/workflow-tools.d.ts.map +1 -1
  54. package/dist/types/editors/shared/icons.d.ts +4 -0
  55. package/dist/types/editors/shared/icons.d.ts.map +1 -1
  56. package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
  57. package/dist/types/editors/workflow-editor/runtime-client.d.ts +5 -1
  58. package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
  59. package/dist/types/editors/workflow-editor/ui/BlockSelector.d.ts.map +1 -1
  60. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +1 -0
  61. package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
  62. package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
  63. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts +1 -0
  64. package/dist/types/editors/workflow-editor/ui/ap-edge.d.ts.map +1 -1
  65. package/dist/types/editors/workflow-editor/ui/ap-layout.d.ts.map +1 -1
  66. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts +4 -0
  67. package/dist/types/editors/workflow-editor/ui/ap-nodes.d.ts.map +1 -1
  68. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts +3 -0
  69. package/dist/types/editors/workflow-editor/ui/block-meta.d.ts.map +1 -1
  70. package/dist/types/editors/workflow-editor/ui/blocks.d.ts +8 -0
  71. package/dist/types/editors/workflow-editor/ui/blocks.d.ts.map +1 -1
  72. package/dist/types/editors/workflow-editor/ui/canvas-menu.d.ts.map +1 -1
  73. package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts +2 -0
  74. package/dist/types/editors/workflow-editor/ui/flow-control.test.d.ts.map +1 -0
  75. package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts +1 -0
  76. package/dist/types/editors/workflow-editor/ui/prop-layout.d.ts.map +1 -1
  77. package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts +2 -0
  78. package/dist/types/editors/workflow-editor/ui/prop-layout.test.d.ts.map +1 -0
  79. package/dist/types/editors/workflow-editor/ui/trigger-text.d.ts.map +1 -1
  80. package/dist/types/editors/workflow-editor/ui/use-validity.d.ts.map +1 -1
  81. package/dist/types/editors/workflow-editor/ui/validation.d.ts +4 -1
  82. package/dist/types/editors/workflow-editor/ui/validation.d.ts.map +1 -1
  83. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts +4 -1
  84. package/dist/types/editors/workflow-studio/components/RunsTable.d.ts.map +1 -1
  85. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts +9 -1
  86. package/dist/types/editors/workflow-studio/components/Waitpoints.d.ts.map +1 -1
  87. package/dist/types/editors/workflow-studio/components/WorkflowGraph.d.ts.map +1 -1
  88. package/dist/types/editors/workflow-studio/components/graph-layout.d.ts +1 -0
  89. package/dist/types/editors/workflow-studio/components/graph-layout.d.ts.map +1 -1
  90. package/dist/types/editors/workflow-studio/components/tips.d.ts.map +1 -1
  91. package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts.map +1 -1
  92. package/dist/types/pieces/ai/lib/actions/extract.d.ts.map +1 -1
  93. package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts.map +1 -1
  94. package/dist/types/pieces/ai/lib/actions/summarize.d.ts.map +1 -1
  95. package/dist/types/pieces/reactor/lib/actions/document-find.d.ts.map +1 -1
  96. package/dist/types/test/ui/flow-control.spec.d.ts +2 -0
  97. package/dist/types/test/ui/flow-control.spec.d.ts.map +1 -0
  98. package/package.json +9 -9
  99. package/dist/browser/BlockSelector-BKAJwJ4Y.js.map +0 -1
  100. package/dist/browser/editor--J61vLSC.js.map +0 -1
  101. package/dist/browser/editor-Dl6lzxkM.js.map +0 -1
  102. package/dist/browser/runtime-queries-D81Ghpok.js.map +0 -1
  103. package/dist/browser/trigger-text-BSVi5oGZ.js.map +0 -1
  104. package/dist/node/BlockSelector-DnTRF-C7.mjs.map +0 -1
  105. package/dist/node/editor-B4ZwM3pR.mjs.map +0 -1
  106. package/dist/node/editor-_4XHbqGl.mjs.map +0 -1
  107. package/dist/node/runtime-queries-VXJsWno5.mjs.map +0 -1
  108. package/dist/node/trigger-text-BBP7QVLj.mjs.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { v as isReactorConnectorId, y as parseReactorConnectionConfig } from "./module-BEEASith.mjs";
2
2
  import { i as useSelectedConnectionDocument } from "./connection-BZxipUlb.mjs";
3
3
  import { s as packageFromConnectorId } from "./piece-auth-C0u0XTO8.mjs";
4
- import { dt as stepBlock, g as blockRefKey, pt as triggerBlock } from "./runtime-queries-VXJsWno5.mjs";
5
- import { A as formatWhen, Ht as Icon, Ot as Button, R as DesignTimeProvider, St as useRuntimeActions, V as useBlockForms, Wt as DocumentErrorBoundary, _t as usePieceCatalog, mt as WorkflowRuntimeProvider, t as BlockLogo, xt as useRuntime } from "./BlockSelector-DnTRF-C7.mjs";
4
+ import { g as blockRefKey, gt as stepBlock, vt as triggerBlock } from "./runtime-queries-Ck5OoWdy.mjs";
5
+ import { At as Button, B as DesignTimeProvider, Ct as useRuntime, Kt as DocumentErrorBoundary, M as formatWhen, U as useBlockForms, Wt as Icon, gt as WorkflowRuntimeProvider, t as BlockLogo, wt as useRuntimeActions, yt as usePieceCatalog } from "./BlockSelector-Cia1Rpwz.mjs";
6
6
  import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-BgURVzdc.mjs";
7
- import { a as useSignInGate, c as accessMismatch, d as CONNECTION_STATUS_STYLES, f as connectionCallbacks, m as UndoRedo, n as SignInPrompt, p as BackButton, t as ConnectionForm, u as CONNECTION_STATUS_LABEL } from "./connection-form-DwSHfIRw.mjs";
7
+ import { a as useSignInGate, c as accessMismatch, d as CONNECTION_STATUS_STYLES, f as connectionCallbacks, m as UndoRedo, n as SignInPrompt, p as BackButton, t as ConnectionForm, u as CONNECTION_STATUS_LABEL } from "./connection-form-CJFKPwfg.mjs";
8
8
  import { showDeleteNodeModal, useSetSelectedNode } from "@powerhousedao/reactor-browser";
9
9
  import { useMemo, useState } from "react";
10
10
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -367,4 +367,4 @@ function Editor({ document }) {
367
367
  //#endregion
368
368
  export { Editor as default };
369
369
 
370
- //# sourceMappingURL=editor-cXi5dIsd.mjs.map
370
+ //# sourceMappingURL=editor-_c6UDRAN.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-cXi5dIsd.mjs","names":[],"sources":["../../editors/connection-editor/connection-usage.ts","../../editors/connection-editor/ConnectionToolbar.tsx","../../editors/connection-editor/ReactorBindings.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 connectionId?: string | null;\n reactorConnectionId?: string | null;\n}\n\nexport interface UsageTrigger {\n id?: string;\n pieceName?: string;\n pieceVersion?: string;\n triggerName?: string;\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n}\n\nexport interface UsageWorkflow {\n id: string;\n name: string;\n status: string;\n trigger?: UsageTrigger | null;\n steps: readonly UsageStep[];\n}\n\nexport interface ConnectionUsage {\n workflow: UsageWorkflow;\n // The trigger binds this connection, as its connection or reactor connection.\n trigger: boolean;\n steps: UsageStep[];\n // The subset bound as a reactor connection.\n reactorTrigger: boolean;\n reactorSteps: UsageStep[];\n}\n\nfunction binds(\n block: { connectionId?: string | null; reactorConnectionId?: string | null },\n connectionId: string,\n): boolean {\n return (\n block.connectionId === connectionId ||\n block.reactorConnectionId === connectionId\n );\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 = Boolean(\n workflow.trigger && binds(workflow.trigger, connectionId),\n );\n const steps = workflow.steps.filter((step) => binds(step, connectionId));\n if (!trigger && steps.length === 0) continue;\n usage.push({\n workflow,\n trigger,\n steps,\n reactorTrigger: workflow.trigger?.reactorConnectionId === connectionId,\n reactorSteps: steps.filter(\n (step) => step.reactorConnectionId === connectionId,\n ),\n });\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 {\n isReactorConnectorId,\n type ConnectionState,\n} from \"document-models/connection\";\nimport { useSignInGate } from \"../workflow-editor/reactor-hooks.js\";\nimport { SignInPrompt } from \"../workflow-editor/ui/SignInPrompt.js\";\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 const reactor = isReactorConnectorId(state.connectorId);\n const gate = useSignInGate();\n const signInFirst = reactor && gate.required;\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 {reactor && state.status === \"OK\"\n ? \"Checked\"\n : CONNECTION_STATUS_LABEL[state.status]}\n </span>\n <span>\n {reactor\n ? \"Powerhouse documents\"\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 || signInFirst}\n onClick={test}\n >\n <Icon name=\"check\" className=\"h-3.5 w-3.5\" />\n {reactor\n ? testing\n ? \"Checking…\"\n : \"Check connection\"\n : testing\n ? \"Testing…\"\n : \"Test connection\"}\n </Button>\n </div>\n {signInFirst ? (\n <div className=\"w-full\">\n <SignInPrompt\n gate={gate}\n reason=\"Sign in to check this connection.\"\n />\n </div>\n ) : null}\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 ? reactor\n ? result.detail\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 steps and triggers that bind a reactor connection, and what each declares.\nimport { parseReactorConnectionConfig } from \"document-models/connection\";\nimport { BlockLogo } from \"../workflow-editor/ui/BlockSelector.js\";\nimport {\n stepBlock,\n triggerBlock,\n type BlockRef,\n} from \"../workflow-editor/ui/blocks.js\";\nimport { useBlockForms } from \"../workflow-editor/ui/design-time.js\";\nimport { blockRefKey } from \"../workflow-editor/ui/query-keys.js\";\nimport { accessMismatch } from \"../workflow-editor/ui/reactor-access.js\";\nimport type { ConnectionUsage } from \"./connection-usage.js\";\n\ninterface Binding {\n workflowId: string;\n workflowName: string;\n stepId: string;\n label: string;\n block: BlockRef;\n}\n\nfunction bindingsOf(usage: readonly ConnectionUsage[]): Binding[] {\n return usage.flatMap((entry) => {\n const { workflow } = entry;\n const trigger = workflow.trigger;\n const triggerBinding: Binding[] =\n entry.reactorTrigger &&\n trigger?.id &&\n trigger.pieceName &&\n trigger.pieceVersion &&\n trigger.triggerName\n ? [\n {\n workflowId: workflow.id,\n workflowName: workflow.name,\n stepId: trigger.id,\n label: \"Trigger\",\n block: triggerBlock({\n pieceName: trigger.pieceName,\n pieceVersion: trigger.pieceVersion,\n triggerName: trigger.triggerName,\n }),\n },\n ]\n : [];\n return [\n ...triggerBinding,\n ...entry.reactorSteps.map((step) => ({\n workflowId: workflow.id,\n workflowName: workflow.name,\n stepId: step.id,\n label: step.name || step.key,\n block: stepBlock(step),\n })),\n ];\n });\n}\n\nconst DECLARED_LABEL = {\n read: \"Reads\",\n write: \"Reads and writes\",\n} as const;\n\nfunction BindingRow(props: {\n binding: Binding;\n declared: \"read\" | \"write\" | null | undefined;\n access: \"read\" | undefined;\n}) {\n const { binding } = props;\n const mismatch = accessMismatch(props.declared, props.access);\n return (\n <li className=\"flex flex-col gap-2 py-2.5\">\n <div className=\"flex items-center gap-2.5 text-[13px]\">\n <BlockLogo block={binding.block} size={16} bare />\n <span className=\"min-w-0 flex-1 truncate\">\n <span className=\"font-medium text-foreground\">\n {binding.workflowName}\n </span>\n <span className=\"text-muted-foreground\"> · {binding.label}</span>\n </span>\n <span\n className=\"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground\"\n aria-label={`${binding.label} declares`}\n >\n {props.declared === undefined\n ? \"…\"\n : props.declared\n ? DECLARED_LABEL[props.declared]\n : \"Declares no access\"}\n </span>\n </div>\n {mismatch ? <p className=\"text-xs text-wf-warn\">{mismatch}</p> : null}\n </li>\n );\n}\n\nexport function ReactorBindings(props: {\n config: unknown;\n usage: readonly ConnectionUsage[];\n}) {\n const bindings = bindingsOf(props.usage);\n const forms = useBlockForms(bindings.map((binding) => binding.block));\n const parsed = parseReactorConnectionConfig(props.config);\n const access = parsed.ok ? parsed.config.access : undefined;\n return (\n <section\n aria-label=\"Steps that use this connection\"\n className=\"mt-8 border-t border-solid border-foreground/10 pt-5\"\n >\n <h3 className=\"text-[13px] font-semibold text-foreground\">\n What the steps declare\n </h3>\n {bindings.length === 0 ? (\n <p className=\"mt-1 text-xs text-muted-foreground\">\n No step binds this connection yet. Pick it as a step&apos;s reactor\n connection in a workflow&apos;s editor.\n </p>\n ) : (\n <ul className=\"mt-1 divide-y divide-solid divide-foreground/10\">\n {bindings.map((binding) => {\n const form = forms.get(blockRefKey(binding.block));\n return (\n <BindingRow\n key={`${binding.workflowId}:${binding.stepId}`}\n binding={binding}\n declared={\n form === \"loading\"\n ? undefined\n : (form?.requireReactor ?? null)\n }\n access={access}\n />\n );\n })}\n </ul>\n )}\n </section>\n );\n}\n","// The workflows that depend on this connection, and through which steps, so\n// nobody revokes or deletes it blind.\nimport { useSetSelectedNode } 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 const setSelectedNode = useSetSelectedNode();\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 { showDeleteNodeModal } from \"@powerhousedao/reactor-browser\";\nimport type { EditorProps } from \"document-model\";\nimport type {\n ConnectionAction,\n ConnectionDocument,\n} from \"document-models/connection\";\nimport {\n isReactorConnectorId,\n useSelectedConnectionDocument,\n} from \"document-models/connection\";\nimport { useMemo } from \"react\";\nimport { DocumentErrorBoundary } from \"../shared/DocumentErrorBoundary.js\";\nimport { BackButton, UndoRedo } from \"../shared/editor-chrome.js\";\nimport {\n useRuntime,\n WorkflowRuntimeProvider,\n} from \"../workflow-editor/runtime-context.js\";\nimport { DesignTimeProvider } from \"../workflow-editor/ui/design-time.js\";\nimport type { DesignTimeService } from \"../workflow-editor/ui/forms.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 { ReactorBindings } from \"./ReactorBindings.js\";\nimport { UsedBy, useConnectionUsage } from \"./UsedBy.js\";\n\nfunction ConnectionEditor() {\n const [document, dispatch] = useSelectedConnectionDocument();\n const state = document.state.global;\n const { client, queryClient } = useRuntime();\n // Block forms, for what each step that binds a reactor connection declares.\n const designTime = useMemo<DesignTimeService>(\n () => ({\n getBlockForm: (block) => client.getBlockForm(block),\n loadOptions: (...args) => client.loadBlockOptions(...args),\n }),\n [client],\n );\n\n const callbacks = connectionCallbacks(state, dispatch);\n const usage = useConnectionUsage(document.header.id);\n const reactor = isReactorConnectorId(state.connectorId);\n\n return (\n <DesignTimeProvider\n service={designTime}\n queryClient={queryClient}\n scope={client.url}\n >\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 documentId={document.header.id} />\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 {reactor ? (\n <ReactorBindings config={state.config} usage={usage} />\n ) : null}\n <UsedBy usage={usage} />\n </div>\n </div>\n </div>\n </DesignTimeProvider>\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 document,\n}: EditorProps<ConnectionDocument, ConnectionAction>) {\n return (\n <DocumentErrorBoundary documentId={document.header.id}>\n <WorkflowRuntimeProvider>\n <ConnectionEditor />\n </WorkflowRuntimeProvider>\n </DocumentErrorBoundary>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyCA,SAAS,MACP,OACA,cACS;CACT,OACE,MAAM,iBAAiB,gBACvB,MAAM,wBAAwB;AAElC;AAEA,SAAgB,gBACd,cACA,WACmB;CACnB,MAAM,QAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,QACd,SAAS,WAAW,MAAM,SAAS,SAAS,YAAY,CAC1D;EACA,MAAM,QAAQ,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,YAAY,CAAC;EACvE,IAAI,CAAC,WAAW,MAAM,WAAW,GAAG;EACpC,MAAM,KAAK;GACT;GACA;GACA;GACA,gBAAgB,SAAS,SAAS,wBAAwB;GAC1D,cAAc,MAAM,QACjB,SAAS,KAAK,wBAAwB,YACzC;EACF,CAAC;CACH;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;;;AC1DA,SAAS,kBAAkB,cAAsB;CAC/C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,QAAQ,aAAa,SAAuC,IA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ACpD,OACE,oBAAC,uBAAD;EAAuB,YAAY,SAAS,OAAO;EACjD,UAAA,oBAAC,yBAAD,EAAA,UACE,oBAAC,kBAAD,CAAmB,CAAA,EACI,CAAA;CACJ,CAAA;AAE3B"}
1
+ {"version":3,"file":"editor-_c6UDRAN.mjs","names":[],"sources":["../../editors/connection-editor/connection-usage.ts","../../editors/connection-editor/ConnectionToolbar.tsx","../../editors/connection-editor/ReactorBindings.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 connectionId?: string | null;\n reactorConnectionId?: string | null;\n}\n\nexport interface UsageTrigger {\n id?: string;\n pieceName?: string;\n pieceVersion?: string;\n triggerName?: string;\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n}\n\nexport interface UsageWorkflow {\n id: string;\n name: string;\n status: string;\n trigger?: UsageTrigger | null;\n steps: readonly UsageStep[];\n}\n\nexport interface ConnectionUsage {\n workflow: UsageWorkflow;\n // The trigger binds this connection, as its connection or reactor connection.\n trigger: boolean;\n steps: UsageStep[];\n // The subset bound as a reactor connection.\n reactorTrigger: boolean;\n reactorSteps: UsageStep[];\n}\n\nfunction binds(\n block: { connectionId?: string | null; reactorConnectionId?: string | null },\n connectionId: string,\n): boolean {\n return (\n block.connectionId === connectionId ||\n block.reactorConnectionId === connectionId\n );\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 = Boolean(\n workflow.trigger && binds(workflow.trigger, connectionId),\n );\n const steps = workflow.steps.filter((step) => binds(step, connectionId));\n if (!trigger && steps.length === 0) continue;\n usage.push({\n workflow,\n trigger,\n steps,\n reactorTrigger: workflow.trigger?.reactorConnectionId === connectionId,\n reactorSteps: steps.filter(\n (step) => step.reactorConnectionId === connectionId,\n ),\n });\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 {\n isReactorConnectorId,\n type ConnectionState,\n} from \"document-models/connection\";\nimport { useSignInGate } from \"../workflow-editor/reactor-hooks.js\";\nimport { SignInPrompt } from \"../workflow-editor/ui/SignInPrompt.js\";\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 const reactor = isReactorConnectorId(state.connectorId);\n const gate = useSignInGate();\n const signInFirst = reactor && gate.required;\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 {reactor && state.status === \"OK\"\n ? \"Checked\"\n : CONNECTION_STATUS_LABEL[state.status]}\n </span>\n <span>\n {reactor\n ? \"Powerhouse documents\"\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 || signInFirst}\n onClick={test}\n >\n <Icon name=\"check\" className=\"h-3.5 w-3.5\" />\n {reactor\n ? testing\n ? \"Checking…\"\n : \"Check connection\"\n : testing\n ? \"Testing…\"\n : \"Test connection\"}\n </Button>\n </div>\n {signInFirst ? (\n <div className=\"w-full\">\n <SignInPrompt\n gate={gate}\n reason=\"Sign in to check this connection.\"\n />\n </div>\n ) : null}\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 ? reactor\n ? result.detail\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 steps and triggers that bind a reactor connection, and what each declares.\nimport { parseReactorConnectionConfig } from \"document-models/connection\";\nimport { BlockLogo } from \"../workflow-editor/ui/BlockSelector.js\";\nimport {\n stepBlock,\n triggerBlock,\n type BlockRef,\n} from \"../workflow-editor/ui/blocks.js\";\nimport { useBlockForms } from \"../workflow-editor/ui/design-time.js\";\nimport { blockRefKey } from \"../workflow-editor/ui/query-keys.js\";\nimport { accessMismatch } from \"../workflow-editor/ui/reactor-access.js\";\nimport type { ConnectionUsage } from \"./connection-usage.js\";\n\ninterface Binding {\n workflowId: string;\n workflowName: string;\n stepId: string;\n label: string;\n block: BlockRef;\n}\n\nfunction bindingsOf(usage: readonly ConnectionUsage[]): Binding[] {\n return usage.flatMap((entry) => {\n const { workflow } = entry;\n const trigger = workflow.trigger;\n const triggerBinding: Binding[] =\n entry.reactorTrigger &&\n trigger?.id &&\n trigger.pieceName &&\n trigger.pieceVersion &&\n trigger.triggerName\n ? [\n {\n workflowId: workflow.id,\n workflowName: workflow.name,\n stepId: trigger.id,\n label: \"Trigger\",\n block: triggerBlock({\n pieceName: trigger.pieceName,\n pieceVersion: trigger.pieceVersion,\n triggerName: trigger.triggerName,\n }),\n },\n ]\n : [];\n return [\n ...triggerBinding,\n ...entry.reactorSteps.map((step) => ({\n workflowId: workflow.id,\n workflowName: workflow.name,\n stepId: step.id,\n label: step.name || step.key,\n block: stepBlock(step),\n })),\n ];\n });\n}\n\nconst DECLARED_LABEL = {\n read: \"Reads\",\n write: \"Reads and writes\",\n} as const;\n\nfunction BindingRow(props: {\n binding: Binding;\n declared: \"read\" | \"write\" | null | undefined;\n access: \"read\" | undefined;\n}) {\n const { binding } = props;\n const mismatch = accessMismatch(props.declared, props.access);\n return (\n <li className=\"flex flex-col gap-2 py-2.5\">\n <div className=\"flex items-center gap-2.5 text-[13px]\">\n <BlockLogo block={binding.block} size={16} bare />\n <span className=\"min-w-0 flex-1 truncate\">\n <span className=\"font-medium text-foreground\">\n {binding.workflowName}\n </span>\n <span className=\"text-muted-foreground\"> · {binding.label}</span>\n </span>\n <span\n className=\"shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground\"\n aria-label={`${binding.label} declares`}\n >\n {props.declared === undefined\n ? \"…\"\n : props.declared\n ? DECLARED_LABEL[props.declared]\n : \"Declares no access\"}\n </span>\n </div>\n {mismatch ? <p className=\"text-xs text-wf-warn\">{mismatch}</p> : null}\n </li>\n );\n}\n\nexport function ReactorBindings(props: {\n config: unknown;\n usage: readonly ConnectionUsage[];\n}) {\n const bindings = bindingsOf(props.usage);\n const forms = useBlockForms(bindings.map((binding) => binding.block));\n const parsed = parseReactorConnectionConfig(props.config);\n const access = parsed.ok ? parsed.config.access : undefined;\n return (\n <section\n aria-label=\"Steps that use this connection\"\n className=\"mt-8 border-t border-solid border-foreground/10 pt-5\"\n >\n <h3 className=\"text-[13px] font-semibold text-foreground\">\n What the steps declare\n </h3>\n {bindings.length === 0 ? (\n <p className=\"mt-1 text-xs text-muted-foreground\">\n No step binds this connection yet. Pick it as a step&apos;s reactor\n connection in a workflow&apos;s editor.\n </p>\n ) : (\n <ul className=\"mt-1 divide-y divide-solid divide-foreground/10\">\n {bindings.map((binding) => {\n const form = forms.get(blockRefKey(binding.block));\n return (\n <BindingRow\n key={`${binding.workflowId}:${binding.stepId}`}\n binding={binding}\n declared={\n form === \"loading\"\n ? undefined\n : (form?.requireReactor ?? null)\n }\n access={access}\n />\n );\n })}\n </ul>\n )}\n </section>\n );\n}\n","// The workflows that depend on this connection, and through which steps, so\n// nobody revokes or deletes it blind.\nimport { useSetSelectedNode } 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 const setSelectedNode = useSetSelectedNode();\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 { showDeleteNodeModal } from \"@powerhousedao/reactor-browser\";\nimport type { EditorProps } from \"document-model\";\nimport type {\n ConnectionAction,\n ConnectionDocument,\n} from \"document-models/connection\";\nimport {\n isReactorConnectorId,\n useSelectedConnectionDocument,\n} from \"document-models/connection\";\nimport { useMemo } from \"react\";\nimport { DocumentErrorBoundary } from \"../shared/DocumentErrorBoundary.js\";\nimport { BackButton, UndoRedo } from \"../shared/editor-chrome.js\";\nimport {\n useRuntime,\n WorkflowRuntimeProvider,\n} from \"../workflow-editor/runtime-context.js\";\nimport { DesignTimeProvider } from \"../workflow-editor/ui/design-time.js\";\nimport type { DesignTimeService } from \"../workflow-editor/ui/forms.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 { ReactorBindings } from \"./ReactorBindings.js\";\nimport { UsedBy, useConnectionUsage } from \"./UsedBy.js\";\n\nfunction ConnectionEditor() {\n const [document, dispatch] = useSelectedConnectionDocument();\n const state = document.state.global;\n const { client, queryClient } = useRuntime();\n // Block forms, for what each step that binds a reactor connection declares.\n const designTime = useMemo<DesignTimeService>(\n () => ({\n getBlockForm: (block) => client.getBlockForm(block),\n loadOptions: (...args) => client.loadBlockOptions(...args),\n }),\n [client],\n );\n\n const callbacks = connectionCallbacks(state, dispatch);\n const usage = useConnectionUsage(document.header.id);\n const reactor = isReactorConnectorId(state.connectorId);\n\n return (\n <DesignTimeProvider\n service={designTime}\n queryClient={queryClient}\n scope={client.url}\n >\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 documentId={document.header.id} />\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 {reactor ? (\n <ReactorBindings config={state.config} usage={usage} />\n ) : null}\n <UsedBy usage={usage} />\n </div>\n </div>\n </div>\n </DesignTimeProvider>\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 document,\n}: EditorProps<ConnectionDocument, ConnectionAction>) {\n return (\n <DocumentErrorBoundary documentId={document.header.id}>\n <WorkflowRuntimeProvider>\n <ConnectionEditor />\n </WorkflowRuntimeProvider>\n </DocumentErrorBoundary>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyCA,SAAS,MACP,OACA,cACS;CACT,OACE,MAAM,iBAAiB,gBACvB,MAAM,wBAAwB;AAElC;AAEA,SAAgB,gBACd,cACA,WACmB;CACnB,MAAM,QAA2B,CAAC;CAClC,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,QACd,SAAS,WAAW,MAAM,SAAS,SAAS,YAAY,CAC1D;EACA,MAAM,QAAQ,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,YAAY,CAAC;EACvE,IAAI,CAAC,WAAW,MAAM,WAAW,GAAG;EACpC,MAAM,KAAK;GACT;GACA;GACA;GACA,gBAAgB,SAAS,SAAS,wBAAwB;GAC1D,cAAc,MAAM,QACjB,SAAS,KAAK,wBAAwB,YACzC;EACF,CAAC;CACH;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;;;AC1DA,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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B"}
@@ -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-cXi5dIsd.mjs")),
5
+ Component: lazy(() => import("../../editor-_c6UDRAN.mjs")),
6
6
  documentTypes: ["powerhouse/connection"],
7
7
  config: {
8
8
  id: "connection-editor",
@@ -1,2 +1,2 @@
1
- import { G as fetchRun, J as isSyncingError, K as fetchRuns, U as RuntimeRequestError, W as createRuntimeClient, c as runQuery, l as runsOfPages, q as fetchRunsPage, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery } from "../../runtime-queries-VXJsWno5.mjs";
1
+ import { G as fetchRun, J as isSyncingError, K as fetchRuns, U as RuntimeRequestError, W as createRuntimeClient, c as runQuery, l as runsOfPages, q as fetchRunsPage, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery } from "../../runtime-queries-Ck5OoWdy.mjs";
2
2
  export { RuntimeRequestError, createRuntimeClient, createRuntimeQueryClient, fetchRun, fetchRuns, fetchRunsPage, isSyncingError, runPagesQuery, runQuery, runsOfPages, runsQuery };
@@ -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-_4XHbqGl.mjs")),
5
+ Component: lazy(() => import("../../editor-NMRVprgI.mjs")),
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-B4ZwM3pR.mjs")),
5
+ Component: lazy(() => import("../../editor-CwOjO82y.mjs")),
6
6
  documentTypes: ["powerhouse/document-drive"],
7
7
  config: {
8
8
  id: "workflow-studio",
@@ -1,6 +1,6 @@
1
1
  import { h as REACTOR_CONNECTOR_ID, t as Connection } from "./module-BEEASith.mjs";
2
2
  import { i as connectorIdForPiece, l as planFromAuth, o as isConfigValueMissing, s as packageFromConnectorId } from "./piece-auth-C0u0XTO8.mjs";
3
- import { Ct as flowPorts, H as DEFAULT_RUNTIME_URL, Q as CORE_PIECE, W as createRuntimeClient, n as catalogQuery, r as createRuntimeQueryClient, t as blockFormQuery, tt as REACTOR_PIECE } from "./runtime-queries-VXJsWno5.mjs";
3
+ import { H as DEFAULT_RUNTIME_URL, W as createRuntimeClient, et as CORE_PIECE, it as REACTOR_PIECE, kt as flowPorts, n as catalogQuery, r as createRuntimeQueryClient, t as blockFormQuery } from "./runtime-queries-Ck5OoWdy.mjs";
4
4
  import { t as Workflow } from "./module-CuTg45ct.mjs";
5
5
  import { t as upgradeManifests } from "./upgrade-manifests-BA5OaR4H.mjs";
6
6
  import { ConnectionEditor } from "./editors/connection-editor/module.mjs";
@@ -236,6 +236,7 @@ const GRAPH_RULES = [
236
236
  "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.",
237
237
  "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.",
238
238
  `The built-in blocks (manual, schedule and webhook triggers, branch and assert) belong to the piece ${CORE_PIECE}.`,
239
+ "The core router's ports follow its config: 'branch_1' … 'branch_N', one per entry of its branches list in order, then 'otherwise'. The core loop leaves on 'each' into its body, which runs once per item and must not lead out of the body, and on 'next' after the last item; body steps read {{steps.<loop key>.output.item}} and .index.",
239
240
  "Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).",
240
241
  `Every step and trigger whose block reports requireReactor (getWorkflowBlockConfig) must set reactorConnectionId to a powerhouse/connection document with authType REACTOR and connectorId ${REACTOR_CONNECTOR_ID} (see getConnections); the ${REACTOR_PIECE} blocks all do. Without one the block gets no reactor access and fails. The connection's config { endpoint: "local", access?: "read", filter?: { documentType?, documentId?, driveId?, actionType? } } limits which documents it reads and writes. connectionId stays for credentials; a document block normally needs none.`,
241
242
  "Runs execute the published snapshot, not the draft. PUBLISH_WORKFLOW only snapshots the draft, so publish again after every edit that should run.",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["READ_ONLY","runConnectionCheck","ConnectionV1","WorkflowV1","manifestJson"],"sources":["../../powerhouse.manifest.json","../../editors/workflow-editor/runtime-api.ts","../../ai/runtime-url.ts","../../ai/workflow-tools.ts","../../ai/tools.ts","../../document-models/document-models.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 searchPieces = (\n query: string,\n filter: Parameters<RuntimeClient[\"searchPieces\"]>[1],\n) => ambient.searchPieces(query, filter);\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 { getPHStore } from \"@powerhousedao/reactor-browser\";\nimport { resolveDriveSwitchboard } from \"@powerhousedao/reactor-browser/ai\";\nimport {\n DEFAULT_RUNTIME_URL,\n setRuntimeUrl,\n} from \"../editors/workflow-editor/runtime-api.js\";\n\nconst warnedDrives = new Set<string>();\n\nexport function syncRuntimeUrl(): void {\n if (typeof window === \"undefined\") return;\n const driveId = getPHStore()?.selectedDriveId;\n const switchboard = resolveDriveSwitchboard(driveId);\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 if (!switchboard && driveId && !warnedDrives.has(driveId)) {\n // A Workflows drive has to be attached as a REMOTE of the switchboard\n // that runs the workflow runtime; a local copy renders the studio against\n // whatever answers at the default URL.\n warnedDrives.add(driveId);\n console.warn(\n `[workflow] Drive \"${driveId}\" is not synced from a switchboard, so Workflow Studio falls back to ${DEFAULT_RUNTIME_URL}. ` +\n \"Attach the switchboard's Workflows drive (its /d/<slug> URL) instead of a local drive.\",\n );\n }\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 { REACTOR_CONNECTOR_ID } from \"../document-models/connection/v1/src/reactor-connection.js\";\nimport {\n CORE_PIECE,\n REACTOR_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 \"The reactor piece's document-create and document-dispatch output a reference { documentId, documentType, branch, revision }, e.g. {{steps.create.output.documentId}}; read the document with document-get to use its state. document-get outputs the document as { header, state }, e.g. {{steps.get.output.state.global.name}} or {{steps.get.output.header.id}}. document-find outputs { results, nextCursor }: each result has a header (and state with includeState), and nextCursor, present while more match, goes in a later find's cursor.\",\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 `Every step and trigger whose block reports requireReactor (getWorkflowBlockConfig) must set reactorConnectionId to a powerhouse/connection document with authType REACTOR and connectorId ${REACTOR_CONNECTOR_ID} (see getConnections); the ${REACTOR_PIECE} blocks all do. Without one the block gets no reactor access and fails. The connection's config { endpoint: \"local\", access?: \"read\", filter?: { documentType?, documentId?, driveId?, actionType? } } limits which documents it reads and writes. connectionId stays for credentials; a document block normally needs none.`,\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, whether a connection is needed, and requireReactor (read | write) when it needs a reactor connection. 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 // read | write: the block needs a reactorConnectionId granting this.\n requireReactor: form.requireReactor ?? null,\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 { getPHStore } from \"@powerhousedao/reactor-browser\";\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 searchPieces,\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// Pieces the runtime's search ranks for the query, actions' and triggers'\n// rankings interleaved; null while its index builds, where it has none, or\n// when it ranks nothing (a package name, say).\nasync function rankedPieces(\n catalog: PieceSummary[],\n query: string,\n): Promise<PieceSummary[] | null> {\n let results;\n try {\n results = await Promise.all(\n ([\"action\", \"trigger\"] as const).map((kind) =>\n searchPieces(query, { kind, limit: 50 }),\n ),\n );\n } catch {\n return null;\n }\n if (results.some((result) => result.status !== \"ready\")) return null;\n const byName = new Map(catalog.map((piece) => [piece.name, piece]));\n const ranked = new Map<string, PieceSummary>();\n const longest = Math.max(...results.map((result) => result.pieces.length));\n for (let rank = 0; rank < longest; rank++) {\n for (const result of results) {\n const name = result.pieces.at(rank)?.pieceName;\n const piece = name === undefined ? undefined : byName.get(name);\n if (piece && !ranked.has(piece.name)) ranked.set(piece.name, piece);\n }\n }\n return ranked.size > 0 ? [...ranked.values()] : null;\n}\n\n/**\n * Stage one of connector discovery: the catalog, optionally narrowed by the\n * runtime's piece search (a substring match while its index builds), capped\n * at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is fetched only\n * 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 // A package name is an answer, not a search.\n const exact = catalog.filter((piece) => piece.name.toLowerCase() === needle);\n const matches = !needle\n ? [...catalog]\n : exact.length > 0\n ? exact\n : ((await rankedPieces(catalog, needle)) ??\n catalog.filter((piece) =>\n [piece.name, piece.displayName, piece.description].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n ));\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 = getPHStore()?.reactorClient;\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 (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, best match first: words can name the piece or what it does (e.g. \"slack send message\"), in any order, and small typos are tolerated. 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. A connection with authType REACTOR is bound through a step's or trigger's reactorConnectionId, never connectionId.\",\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","import { Connection as ConnectionV1 } from \"document-models/connection/v1\";\nimport { Workflow as WorkflowV1 } from \"document-models/workflow/v1\";\n\n/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\n\nexport const documentModels = [ConnectionV1, WorkflowV1] as const;\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkBA,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,gBACX,OACA,WACG,QAAQ,aAAa,OAAO,MAAM;AACvC,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;;;AClC1C,MAAM,+BAAe,IAAI,IAAY;AAErC,SAAgB,iBAAuB;CACrC,IAAI,OAAO,WAAW,aAAa;CACnC,MAAM,UAAU,WAAW,CAAC,EAAE;CAC9B,MAAM,cAAc,wBAAwB,OAAO;CAGnD,IAAI,CAAC,eAAe,WAA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manifestJson"],"sources":["../../powerhouse.manifest.json","../../editors/workflow-editor/runtime-api.ts","../../ai/runtime-url.ts","../../ai/workflow-tools.ts","../../ai/tools.ts","../../document-models/document-models.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 searchPieces = (\n query: string,\n filter: Parameters<RuntimeClient[\"searchPieces\"]>[1],\n) => ambient.searchPieces(query, filter);\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 { getPHStore } from \"@powerhousedao/reactor-browser\";\nimport { resolveDriveSwitchboard } from \"@powerhousedao/reactor-browser/ai\";\nimport {\n DEFAULT_RUNTIME_URL,\n setRuntimeUrl,\n} from \"../editors/workflow-editor/runtime-api.js\";\n\nconst warnedDrives = new Set<string>();\n\nexport function syncRuntimeUrl(): void {\n if (typeof window === \"undefined\") return;\n const driveId = getPHStore()?.selectedDriveId;\n const switchboard = resolveDriveSwitchboard(driveId);\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 if (!switchboard && driveId && !warnedDrives.has(driveId)) {\n // A Workflows drive has to be attached as a REMOTE of the switchboard\n // that runs the workflow runtime; a local copy renders the studio against\n // whatever answers at the default URL.\n warnedDrives.add(driveId);\n console.warn(\n `[workflow] Drive \"${driveId}\" is not synced from a switchboard, so Workflow Studio falls back to ${DEFAULT_RUNTIME_URL}. ` +\n \"Attach the switchboard's Workflows drive (its /d/<slug> URL) instead of a local drive.\",\n );\n }\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 { REACTOR_CONNECTOR_ID } from \"../document-models/connection/v1/src/reactor-connection.js\";\nimport {\n CORE_PIECE,\n REACTOR_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 \"The reactor piece's document-create and document-dispatch output a reference { documentId, documentType, branch, revision }, e.g. {{steps.create.output.documentId}}; read the document with document-get to use its state. document-get outputs the document as { header, state }, e.g. {{steps.get.output.state.global.name}} or {{steps.get.output.header.id}}. document-find outputs { results, nextCursor }: each result has a header (and state with includeState), and nextCursor, present while more match, goes in a later find's cursor.\",\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 \"The core router's ports follow its config: 'branch_1' … 'branch_N', one per entry of its branches list in order, then 'otherwise'. The core loop leaves on 'each' into its body, which runs once per item and must not lead out of the body, and on 'next' after the last item; body steps read {{steps.<loop key>.output.item}} and .index.\",\n \"Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).\",\n `Every step and trigger whose block reports requireReactor (getWorkflowBlockConfig) must set reactorConnectionId to a powerhouse/connection document with authType REACTOR and connectorId ${REACTOR_CONNECTOR_ID} (see getConnections); the ${REACTOR_PIECE} blocks all do. Without one the block gets no reactor access and fails. The connection's config { endpoint: \"local\", access?: \"read\", filter?: { documentType?, documentId?, driveId?, actionType? } } limits which documents it reads and writes. connectionId stays for credentials; a document block normally needs none.`,\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, whether a connection is needed, and requireReactor (read | write) when it needs a reactor connection. 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 // read | write: the block needs a reactorConnectionId granting this.\n requireReactor: form.requireReactor ?? null,\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 { getPHStore } from \"@powerhousedao/reactor-browser\";\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 searchPieces,\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// Pieces the runtime's search ranks for the query, actions' and triggers'\n// rankings interleaved; null while its index builds, where it has none, or\n// when it ranks nothing (a package name, say).\nasync function rankedPieces(\n catalog: PieceSummary[],\n query: string,\n): Promise<PieceSummary[] | null> {\n let results;\n try {\n results = await Promise.all(\n ([\"action\", \"trigger\"] as const).map((kind) =>\n searchPieces(query, { kind, limit: 50 }),\n ),\n );\n } catch {\n return null;\n }\n if (results.some((result) => result.status !== \"ready\")) return null;\n const byName = new Map(catalog.map((piece) => [piece.name, piece]));\n const ranked = new Map<string, PieceSummary>();\n const longest = Math.max(...results.map((result) => result.pieces.length));\n for (let rank = 0; rank < longest; rank++) {\n for (const result of results) {\n const name = result.pieces.at(rank)?.pieceName;\n const piece = name === undefined ? undefined : byName.get(name);\n if (piece && !ranked.has(piece.name)) ranked.set(piece.name, piece);\n }\n }\n return ranked.size > 0 ? [...ranked.values()] : null;\n}\n\n/**\n * Stage one of connector discovery: the catalog, optionally narrowed by the\n * runtime's piece search (a substring match while its index builds), capped\n * at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is fetched only\n * 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 // A package name is an answer, not a search.\n const exact = catalog.filter((piece) => piece.name.toLowerCase() === needle);\n const matches = !needle\n ? [...catalog]\n : exact.length > 0\n ? exact\n : ((await rankedPieces(catalog, needle)) ??\n catalog.filter((piece) =>\n [piece.name, piece.displayName, piece.description].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n ));\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 = getPHStore()?.reactorClient;\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 (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, best match first: words can name the piece or what it does (e.g. \"slack send message\"), in any order, and small typos are tolerated. 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. A connection with authType REACTOR is bound through a step's or trigger's reactorConnectionId, never connectionId.\",\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","import { Connection as ConnectionV1 } from \"document-models/connection/v1\";\nimport { Workflow as WorkflowV1 } from \"document-models/workflow/v1\";\n\n/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\n\nexport const documentModels = [ConnectionV1, WorkflowV1] as const;\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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,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;;;;;;;ACtQA,MAAa,iBAAiB,CAACC,YAAcC,QAAU;;;ACCvD,MAAa,UAA0B;CACrC;CACA;CACA;AACF;;;ACNA,MAAa,WAAWC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/piece-ai",
3
- "version": "6.2.3-dev.88",
3
+ "version": "6.2.3-dev.89",
4
4
  "displayName": "AI",
5
5
  "logoUrl": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20114%20114%22%3E%3Cpath%20fill%3D%22%23161616%22%20fill-rule%3D%22evenodd%22%20d%3D%22M15.2%200H98.8C107.195%200%20114%206.805%20114%2015.2V98.8C114%20107.195%20107.195%20114%2098.8%20114H15.2C6.805%20114%200%20107.195%200%2098.8V15.2C0%206.805%206.805%200%2015.2%200ZM25.5%2082L42%2032H53L69.5%2082H58.5L55%2071H40L36.5%2082ZM43%2061H52L47.5%2046.5ZM77.5%2032H88.5V82H77.5Z%22%2F%3E%3C%2Fsvg%3E",
6
6
  "actions": {
@@ -220,6 +220,19 @@
220
220
  "type": "NUMBER"
221
221
  }
222
222
  },
223
+ "propertyGroups": [
224
+ {
225
+ "key": "fields",
226
+ "display": "section",
227
+ "label": "What to extract",
228
+ "icon": "braces",
229
+ "props": [
230
+ "prompt",
231
+ "mode",
232
+ "schema"
233
+ ]
234
+ }
235
+ ],
223
236
  "requireAuth": true,
224
237
  "errorHandlingOptions": {
225
238
  "continueOnFailure": {
@@ -337,6 +350,18 @@
337
350
  "type": "NUMBER"
338
351
  }
339
352
  },
353
+ "propertyGroups": [
354
+ {
355
+ "key": "summary",
356
+ "display": "section",
357
+ "label": "Summary",
358
+ "icon": "sliders",
359
+ "props": [
360
+ "length",
361
+ "instructions"
362
+ ]
363
+ }
364
+ ],
340
365
  "requireAuth": true,
341
366
  "errorHandlingOptions": {
342
367
  "continueOnFailure": {
@@ -603,6 +628,28 @@
603
628
  "type": "DROPDOWN"
604
629
  }
605
630
  },
631
+ "propertyGroups": [
632
+ {
633
+ "key": "documents",
634
+ "display": "section",
635
+ "label": "Documents",
636
+ "icon": "list",
637
+ "props": [
638
+ "documents",
639
+ "filter"
640
+ ]
641
+ },
642
+ {
643
+ "key": "decision",
644
+ "display": "section",
645
+ "label": "Decision",
646
+ "icon": "branch",
647
+ "props": [
648
+ "input",
649
+ "questions"
650
+ ]
651
+ }
652
+ ],
606
653
  "requireAuth": true,
607
654
  "errorHandlingOptions": {
608
655
  "continueOnFailure": {
@@ -709,6 +756,28 @@
709
756
  "type": "DROPDOWN"
710
757
  }
711
758
  },
759
+ "propertyGroups": [
760
+ {
761
+ "key": "documents",
762
+ "display": "section",
763
+ "label": "Documents",
764
+ "icon": "list",
765
+ "props": [
766
+ "documentId",
767
+ "documents"
768
+ ]
769
+ },
770
+ {
771
+ "key": "request",
772
+ "display": "section",
773
+ "label": "Request",
774
+ "icon": "pencil",
775
+ "props": [
776
+ "instruction",
777
+ "allowedActionTypes"
778
+ ]
779
+ }
780
+ ],
712
781
  "requireAuth": true,
713
782
  "errorHandlingOptions": {
714
783
  "continueOnFailure": {