@powerhousedao/workflow 6.2.3-dev.95 → 6.2.3-dev.97
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.
- package/dist/browser/{BlockSelector-DFzzAWXh.js → BlockSelector-CEdYUqjx.js} +38 -37
- package/dist/browser/BlockSelector-CEdYUqjx.js.map +1 -0
- package/dist/browser/{connection-form-O02M1hkC.js → connection-form-Biksq2jW.js} +4 -4
- package/dist/browser/{connection-form-O02M1hkC.js.map → connection-form-Biksq2jW.js.map} +1 -1
- package/dist/browser/{connection-PaKXHYz9.js → connection-ilYFCRUK.js} +2 -2
- package/dist/browser/{connection-PaKXHYz9.js.map → connection-ilYFCRUK.js.map} +1 -1
- package/dist/browser/{data-tree-DKS0EQys.js → data-tree-Cq-s6bJp.js} +2 -2
- package/dist/browser/{data-tree-DKS0EQys.js.map → data-tree-Cq-s6bJp.js.map} +1 -1
- package/dist/browser/document-models/connection/index.js +1 -1
- package/dist/browser/document-models/workflow/index.js +1 -1
- package/dist/browser/{editor-gCkAwv09.js → editor-CIqKi7XK.js} +6 -6
- package/dist/browser/{editor-gCkAwv09.js.map → editor-CIqKi7XK.js.map} +1 -1
- package/dist/browser/{editor-BPF_SXdt.js → editor-DYjoPfta.js} +8 -8
- package/dist/browser/{editor-BPF_SXdt.js.map → editor-DYjoPfta.js.map} +1 -1
- package/dist/browser/{editor-xBTKbbNO.js → editor-GeRXGdie.js} +6 -6
- package/dist/browser/{editor-xBTKbbNO.js.map → editor-GeRXGdie.js.map} +1 -1
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/runtime/index.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/index.js +127 -87
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{runtime-queries-C5bqAgQy.js → runtime-queries-FmEzElOY.js} +39 -20
- package/dist/browser/runtime-queries-FmEzElOY.js.map +1 -0
- package/dist/browser/{trigger-text-BfIu-QcC.js → trigger-text-DH6HIeoa.js} +4 -4
- package/dist/browser/{trigger-text-BfIu-QcC.js.map → trigger-text-DH6HIeoa.js.map} +1 -1
- package/dist/browser/{workflow-BFdnSGRD.js → workflow-2gR2JXUS.js} +2 -2
- package/dist/browser/{workflow-BFdnSGRD.js.map → workflow-2gR2JXUS.js.map} +1 -1
- package/dist/node/pieces/ai/descriptor.json +1 -1
- package/dist/node/pieces/ai/index.mjs +16 -16
- package/dist/node/pieces/ai/package.json +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/index.mjs +7 -7
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/powerhouse.manifest.json +2 -2
- package/dist/types/ai/runtime.d.ts +13 -0
- package/dist/types/ai/runtime.d.ts.map +1 -0
- package/dist/types/ai/tools.d.ts +6 -2
- package/dist/types/ai/tools.d.ts.map +1 -1
- package/dist/types/ai/workflow-tools.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-api.d.ts +13 -12
- package/dist/types/editors/workflow-editor/runtime-api.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts +8 -2
- package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/use-workflow-runtime.d.ts +13 -0
- package/dist/types/editors/workflow-editor/use-workflow-runtime.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/use-workflow-runtime.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/use-workflow-runtime.test.d.ts.map +1 -0
- package/dist/types/pieces/reactor/lib/documents.d.ts +1 -0
- package/dist/types/pieces/reactor/lib/documents.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/input-props.d.ts.map +1 -1
- package/dist/types/scripts/ui-stack.d.ts.map +1 -1
- package/dist/types/test/switchboards.d.ts +20 -0
- package/dist/types/test/switchboards.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/browser/BlockSelector-DFzzAWXh.js.map +0 -1
- package/dist/browser/runtime-queries-C5bqAgQy.js.map +0 -1
- package/dist/types/ai/runtime-url.d.ts +0 -2
- package/dist/types/ai/runtime-url.d.ts.map +0 -1
- package/dist/types/ai/runtime-url.test.d.ts +0 -2
- package/dist/types/ai/runtime-url.test.d.ts.map +0 -1
- package/dist/types/editors/workflow-editor/use-runtime-url.d.ts +0 -2
- package/dist/types/editors/workflow-editor/use-runtime-url.d.ts.map +0 -1
- package/dist/types/test/drive-window.d.ts +0 -6
- package/dist/types/test/drive-window.d.ts.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { m as reducer, v as isReactorConnectorId, y as parseReactorConnectionConfig } from "./module-DJz6oTX0.js";
|
|
2
|
-
import { i as useSelectedConnectionDocument } from "./connection-
|
|
2
|
+
import { i as useSelectedConnectionDocument } from "./connection-ilYFCRUK.js";
|
|
3
3
|
import { s as packageFromConnectorId } from "./piece-auth-63iuNFTs.js";
|
|
4
|
-
import { Q as triggerBlock, X as stepBlock, g as blockRefKey } from "./runtime-queries-
|
|
5
|
-
import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-
|
|
6
|
-
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-
|
|
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-
|
|
4
|
+
import { Q as triggerBlock, X as stepBlock, g as blockRefKey } from "./runtime-queries-FmEzElOY.js";
|
|
5
|
+
import { r as useWorkflowDocumentsInSelectedDrive } from "./workflow-2gR2JXUS.js";
|
|
6
|
+
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-CEdYUqjx.js";
|
|
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-Biksq2jW.js";
|
|
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";
|
|
@@ -370,4 +370,4 @@ function Editor({ document }) {
|
|
|
370
370
|
//#endregion
|
|
371
371
|
export { Editor as default };
|
|
372
372
|
|
|
373
|
-
//# sourceMappingURL=editor-
|
|
373
|
+
//# sourceMappingURL=editor-GeRXGdie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-xBTKbbNO.js","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's reactor\n connection in a workflow'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 reducer,\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} reducer={reducer} />\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,KAA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AK,WAAU;KAAf,UAAA;MACE,oBAAC,mBAAD;OACE,cAAc,SAAS,OAAO;OAC9B,mBAAmB,kBAAkB,KAAK;OACnC;OACP,UAAU,UAAU;OACpB,aAAa,UAAU;OACvB,gBAAgB,oBAAoB,SAAS,OAAO,EAAE;MACvD,CAAA;MACD,oBAAC,gBAAD;OACS;OACI;OACX,cAAc,SAAS,OAAO;MAC/B,CAAA;MACA,UACC,oBAAC,iBAAD;OAAiB,QAAQ,MAAM;OAAe;MAAQ,CAAA,IACpD;MACJ,oBAAC,QAAD,EAAe,MAAQ,CAAA;KACpB;;GACF,CAAA,CACF;;CACa,CAAA;AAExB;AAIA,SAAwB,OAAO,EAC7B,YACoD;CACpD,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-GeRXGdie.js","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's reactor\n connection in a workflow'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 reducer,\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} reducer={reducer} />\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,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aAAa,UAAU;OACvB,gBAAgB,oBAAoB,SAAS,OAAO,EAAE;MACvD,CAAA;MACD,oBAAC,gBAAD;OACS;OACI;OACX,cAAc,SAAS,OAAO;MAC/B,CAAA;MACA,UACC,oBAAC,iBAAD;OAAiB,QAAQ,MAAM;OAAe;MAAQ,CAAA,IACpD;MACJ,oBAAC,QAAD,EAAe,MAAQ,CAAA;KACpB;;GACF,CAAA,CACF;;CACa,CAAA;AAExB;AAIA,SAAwB,OAAO,EAC7B,YACoD;CACpD,OACE,oBAAC,uBAAD;EAAuB,YAAY,SAAS,OAAO;EACjD,UAAA,oBAAC,yBAAD,EAAA,UACE,oBAAC,kBAAD,CAAmB,CAAA,EACI,CAAA;CACJ,CAAA;AAE3B"}
|
|
@@ -2,7 +2,7 @@ import { lazy } from "react";
|
|
|
2
2
|
//#region editors/connection-editor/module.ts
|
|
3
3
|
/** Document editor module for the "powerhouse/connection" document type */
|
|
4
4
|
const ConnectionEditor = {
|
|
5
|
-
Component: lazy(() => import("../../editor-
|
|
5
|
+
Component: lazy(() => import("../../editor-GeRXGdie.js")),
|
|
6
6
|
documentTypes: ["powerhouse/connection"],
|
|
7
7
|
config: {
|
|
8
8
|
id: "connection-editor",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as fetchRun, E as isSyncingError, S as createRuntimeClient, T as fetchRunsPage, c as runQuery, l as runsOfPages, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery, w as fetchRuns, x as RuntimeRequestError } from "../../runtime-queries-FmEzElOY.js";
|
|
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-
|
|
5
|
+
Component: lazy(() => import("../../editor-DYjoPfta.js")),
|
|
6
6
|
documentTypes: ["powerhouse/workflow"],
|
|
7
7
|
config: {
|
|
8
8
|
id: "workflow-editor",
|
|
@@ -2,7 +2,7 @@ import { lazy } from "react";
|
|
|
2
2
|
//#region editors/workflow-studio/module.ts
|
|
3
3
|
/** Document editor module for the "powerhouse/document-drive" document type */
|
|
4
4
|
const WorkflowStudio = {
|
|
5
|
-
Component: lazy(() => import("../../editor-
|
|
5
|
+
Component: lazy(() => import("../../editor-CIqKi7XK.js")),
|
|
6
6
|
documentTypes: ["powerhouse/document-drive"],
|
|
7
7
|
config: {
|
|
8
8
|
id: "workflow-studio",
|
package/dist/browser/index.js
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { n as powerhouse_manifest_default, t as documentModels } from "./document-models-C2SAP1SX.js";
|
|
2
2
|
import { h as REACTOR_CONNECTOR_ID } from "./module-DJz6oTX0.js";
|
|
3
3
|
import { i as connectorIdForPiece, l as planFromAuth, o as isConfigValueMissing, s as packageFromConnectorId } from "./piece-auth-63iuNFTs.js";
|
|
4
|
-
import {
|
|
4
|
+
import { D as workflowRuntimeUrl, L as REACTOR_PIECE, N as CORE_PIECE, S as createRuntimeClient, n as catalogQuery, r as createRuntimeQueryClient, t as blockFormQuery } from "./runtime-queries-FmEzElOY.js";
|
|
5
5
|
import { t as upgradeManifests } from "./upgrade-manifests-C2Qa6myy.js";
|
|
6
6
|
import { ConnectionEditor } from "./editors/connection-editor/module.js";
|
|
7
7
|
import { WorkflowEditor } from "./editors/workflow-editor/module.js";
|
|
8
8
|
import { WorkflowStudio } from "./editors/workflow-studio/module.js";
|
|
9
|
-
import { getPHStore } from "@powerhousedao/reactor-browser";
|
|
10
9
|
import { z } from "zod";
|
|
10
|
+
import { resolveSwitchboard } from "@powerhousedao/reactor-browser";
|
|
11
11
|
import { flowPorts } from "@powerhousedao/pieces-framework/workflow";
|
|
12
|
-
import { resolveDriveSwitchboard } from "@powerhousedao/reactor-browser/ai";
|
|
13
12
|
//#region editors/workflow-editor/runtime-api.ts
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const queries = createRuntimeQueryClient();
|
|
14
|
+
function fetchBlockForm(client, block) {
|
|
15
|
+
return queries.fetchQuery(blockFormQuery(client, block));
|
|
16
|
+
}
|
|
17
|
+
function fetchCatalog(client) {
|
|
18
|
+
return queries.fetchQuery(catalogQuery(client));
|
|
19
|
+
}
|
|
20
|
+
/** The runtime of `switchboard`; the catalog and block forms are cached per URL. */
|
|
21
|
+
function runtimeAt(switchboard, options = {}) {
|
|
22
|
+
const client = createRuntimeClient(workflowRuntimeUrl(switchboard), options);
|
|
23
|
+
return {
|
|
24
|
+
switchboard,
|
|
25
|
+
client,
|
|
26
|
+
getBlockForm: (block) => fetchBlockForm(client, block),
|
|
27
|
+
fetchPieceCatalog: () => fetchCatalog(client)
|
|
28
|
+
};
|
|
18
29
|
}
|
|
19
|
-
const getBlockForm = (block) => ambientQueries.fetchQuery(blockFormQuery(ambient, block));
|
|
20
|
-
const fetchPieceCatalog = () => ambientQueries.fetchQuery(catalogQuery(ambient));
|
|
21
|
-
const fetchPieceActions = (packageName) => ambient.fetchPieceActions(packageName);
|
|
22
|
-
const fetchPieceTriggers = (packageName) => ambient.fetchPieceTriggers(packageName);
|
|
23
|
-
const searchPieces = (query, filter) => ambient.searchPieces(query, filter);
|
|
24
|
-
const fetchConnections = () => ambient.fetchConnections();
|
|
25
|
-
const checkConnection = (connectionId) => ambient.checkConnection(connectionId);
|
|
26
|
-
const fetchRuns = (scope) => ambient.fetchRuns(scope);
|
|
27
|
-
const fireWorkflow = (workflowId, payload) => ambient.fireWorkflow(workflowId, payload);
|
|
28
30
|
//#endregion
|
|
29
|
-
//#region ai/runtime
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
//#region ai/runtime.ts
|
|
32
|
+
/** The `switchboard` input every workflow tool takes. */
|
|
33
|
+
const switchboardInput = z.string().optional().describe("The switchboard to ask: a name or URL from listSwitchboards. Omit when only one switchboard runs workflows.");
|
|
34
|
+
/** The workflow runtime a tool call goes to; throws when none can be picked. */
|
|
35
|
+
async function runtimeFor(context, request = {}) {
|
|
36
|
+
const { switchboards, signal } = context ?? {};
|
|
37
|
+
return runtimeAt(await resolveSwitchboard(switchboards, {
|
|
38
|
+
switchboard: request.switchboard,
|
|
39
|
+
documentId: request.documentId,
|
|
40
|
+
need: "workflows",
|
|
41
|
+
signal
|
|
42
|
+
}), { signal });
|
|
40
43
|
}
|
|
41
44
|
//#endregion
|
|
42
45
|
//#region ai/workflow-tools.ts
|
|
@@ -96,15 +99,19 @@ const workflowTools = [
|
|
|
96
99
|
{
|
|
97
100
|
name: "getWorkflowPieceBlocks",
|
|
98
101
|
description: "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.",
|
|
99
|
-
inputSchema: {
|
|
102
|
+
inputSchema: {
|
|
103
|
+
packageName: z.string().describe("Piece package name, e.g. @activepieces/piece-http."),
|
|
104
|
+
switchboard: switchboardInput
|
|
105
|
+
},
|
|
100
106
|
annotations: {
|
|
101
107
|
title: "Get Workflow Piece Blocks",
|
|
102
108
|
...READ_ONLY$1
|
|
103
109
|
},
|
|
104
|
-
callback: async (args) => {
|
|
105
|
-
|
|
106
|
-
const [actions, triggers] = await Promise.all([fetchPieceActions(args.packageName), fetchPieceTriggers(args.packageName)]);
|
|
110
|
+
callback: async (args, context) => {
|
|
111
|
+
const { client, switchboard } = await runtimeFor(context, { switchboard: args.switchboard });
|
|
112
|
+
const [actions, triggers] = await Promise.all([client.fetchPieceActions(args.packageName), client.fetchPieceTriggers(args.packageName)]);
|
|
107
113
|
return {
|
|
114
|
+
switchboard: switchboard.name,
|
|
108
115
|
packageName: args.packageName,
|
|
109
116
|
actions: actions.map((action) => ({
|
|
110
117
|
pieceName: action.pieceName,
|
|
@@ -131,26 +138,29 @@ const workflowTools = [
|
|
|
131
138
|
pieceName: z.string().describe(`Piece package name, e.g. ${CORE_PIECE} or @activepieces/piece-http.`),
|
|
132
139
|
pieceVersion: z.string().describe("Exact semver of the piece."),
|
|
133
140
|
name: z.string().describe("Action or trigger name, e.g. branch or send_request."),
|
|
134
|
-
kind: z.enum(["action", "trigger"]).describe("action or trigger.")
|
|
141
|
+
kind: z.enum(["action", "trigger"]).describe("action or trigger."),
|
|
142
|
+
switchboard: switchboardInput
|
|
135
143
|
},
|
|
136
144
|
annotations: {
|
|
137
145
|
title: "Get Workflow Block Config",
|
|
138
146
|
...READ_ONLY$1
|
|
139
147
|
},
|
|
140
|
-
callback: async (args) => {
|
|
148
|
+
callback: async (args, context) => {
|
|
141
149
|
const block = {
|
|
142
150
|
pieceName: args.pieceName,
|
|
143
151
|
pieceVersion: args.pieceVersion,
|
|
144
152
|
name: args.name,
|
|
145
153
|
kind: args.kind
|
|
146
154
|
};
|
|
147
|
-
|
|
148
|
-
const form = await getBlockForm(block);
|
|
155
|
+
const runtime = await runtimeFor(context, { switchboard: args.switchboard });
|
|
156
|
+
const form = await runtime.getBlockForm(block);
|
|
149
157
|
if (!form) return {
|
|
158
|
+
switchboard: runtime.switchboard.name,
|
|
150
159
|
...blockFields(block),
|
|
151
160
|
error: "Unknown block. Use getConnectors and getWorkflowPieceBlocks to find valid blocks (documents live in @powerhousedao/piece-reactor), or listWorkflowCoreBlocks for built-ins."
|
|
152
161
|
};
|
|
153
162
|
return {
|
|
163
|
+
switchboard: runtime.switchboard.name,
|
|
154
164
|
...blockFields(block),
|
|
155
165
|
title: form.title,
|
|
156
166
|
kind: kindOf(block),
|
|
@@ -164,14 +174,14 @@ const workflowTools = [
|
|
|
164
174
|
{
|
|
165
175
|
name: "listWorkflowCoreBlocks",
|
|
166
176
|
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.`,
|
|
167
|
-
inputSchema: {},
|
|
177
|
+
inputSchema: { switchboard: switchboardInput },
|
|
168
178
|
annotations: {
|
|
169
179
|
title: "List Workflow Core Blocks",
|
|
170
180
|
...READ_ONLY$1
|
|
171
181
|
},
|
|
172
|
-
callback: async () => {
|
|
173
|
-
|
|
174
|
-
const [actions, triggers] = await Promise.all([fetchPieceActions(CORE_PIECE), fetchPieceTriggers(CORE_PIECE)]);
|
|
182
|
+
callback: async (args, context) => {
|
|
183
|
+
const runtime = await runtimeFor(context, { switchboard: args.switchboard });
|
|
184
|
+
const [actions, triggers] = await Promise.all([runtime.client.fetchPieceActions(CORE_PIECE), runtime.client.fetchPieceTriggers(CORE_PIECE)]);
|
|
175
185
|
const blocks = [...triggers.map((entry) => ({
|
|
176
186
|
...entry,
|
|
177
187
|
kind: "trigger"
|
|
@@ -184,8 +194,9 @@ const workflowTools = [
|
|
|
184
194
|
name: entry.name,
|
|
185
195
|
kind: entry.kind
|
|
186
196
|
}));
|
|
187
|
-
const forms = await Promise.all(blocks.map(getBlockForm));
|
|
197
|
+
const forms = await Promise.all(blocks.map((block) => runtime.getBlockForm(block)));
|
|
188
198
|
return {
|
|
199
|
+
switchboard: runtime.switchboard.name,
|
|
189
200
|
blocks: blocks.flatMap((block, index) => {
|
|
190
201
|
const form = forms[index];
|
|
191
202
|
if (!form) return [];
|
|
@@ -208,33 +219,41 @@ const workflowTools = [
|
|
|
208
219
|
inputSchema: {
|
|
209
220
|
workflowId: z.string().optional().describe("Workflow document id to filter by."),
|
|
210
221
|
driveId: z.string().optional().describe("Drive id to filter by (all workflows in that drive)."),
|
|
211
|
-
limit: z.number().int().min(1).max(100).optional().describe("Maximum runs to return (default 10).")
|
|
222
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum runs to return (default 10)."),
|
|
223
|
+
switchboard: switchboardInput
|
|
212
224
|
},
|
|
213
225
|
annotations: {
|
|
214
226
|
title: "List Workflow Runs",
|
|
215
227
|
...READ_ONLY$1
|
|
216
228
|
},
|
|
217
|
-
callback: async (args) => {
|
|
218
|
-
|
|
219
|
-
|
|
229
|
+
callback: async (args, context) => {
|
|
230
|
+
const { client, switchboard } = await runtimeFor(context, {
|
|
231
|
+
switchboard: args.switchboard,
|
|
232
|
+
documentId: args.workflowId ?? args.driveId
|
|
233
|
+
});
|
|
234
|
+
const runs = await client.fetchRuns({
|
|
220
235
|
workflowId: args.workflowId,
|
|
221
236
|
driveId: args.driveId,
|
|
222
237
|
limit: args.limit ?? 10
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
switchboard: switchboard.name,
|
|
241
|
+
runs: runs.map((run) => ({
|
|
242
|
+
id: run.id,
|
|
243
|
+
workflowId: run.workflowId,
|
|
244
|
+
workflowName: run.workflowName,
|
|
245
|
+
status: run.status,
|
|
246
|
+
error: run.error,
|
|
247
|
+
triggerKind: run.triggerKind,
|
|
248
|
+
startedAt: run.startedAt,
|
|
249
|
+
endedAt: run.endedAt,
|
|
250
|
+
steps: run.steps.map((step) => ({
|
|
251
|
+
key: step.stepKey,
|
|
252
|
+
status: step.status,
|
|
253
|
+
error: step.error
|
|
254
|
+
}))
|
|
236
255
|
}))
|
|
237
|
-
}
|
|
256
|
+
};
|
|
238
257
|
}
|
|
239
258
|
},
|
|
240
259
|
{
|
|
@@ -242,7 +261,8 @@ const workflowTools = [
|
|
|
242
261
|
description: "Fires an ENABLED workflow whose trigger is the core manual trigger and runs its published snapshot to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.",
|
|
243
262
|
inputSchema: {
|
|
244
263
|
workflowId: z.string().describe("Workflow document id."),
|
|
245
|
-
payload: z.record(z.string(), z.unknown()).optional().describe("Trigger payload object.")
|
|
264
|
+
payload: z.record(z.string(), z.unknown()).optional().describe("Trigger payload object."),
|
|
265
|
+
switchboard: switchboardInput
|
|
246
266
|
},
|
|
247
267
|
annotations: {
|
|
248
268
|
title: "Fire Workflow",
|
|
@@ -251,9 +271,15 @@ const workflowTools = [
|
|
|
251
271
|
idempotentHint: false,
|
|
252
272
|
openWorldHint: false
|
|
253
273
|
},
|
|
254
|
-
callback: (args) => {
|
|
255
|
-
|
|
256
|
-
|
|
274
|
+
callback: async (args, context) => {
|
|
275
|
+
const { client, switchboard } = await runtimeFor(context, {
|
|
276
|
+
switchboard: args.switchboard,
|
|
277
|
+
documentId: args.workflowId
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
switchboard: switchboard.name,
|
|
281
|
+
...await client.fireWorkflow(args.workflowId, args.payload ?? {})
|
|
282
|
+
};
|
|
257
283
|
}
|
|
258
284
|
}
|
|
259
285
|
];
|
|
@@ -269,9 +295,9 @@ function toField(field, secret) {
|
|
|
269
295
|
secret
|
|
270
296
|
};
|
|
271
297
|
}
|
|
272
|
-
async function connectorDetail(piece) {
|
|
298
|
+
async function connectorDetail(runtime, piece) {
|
|
273
299
|
const plan = planFromAuth(piece.auth);
|
|
274
|
-
const [actions, triggers] = await Promise.all([fetchPieceActions(piece.name), fetchPieceTriggers(piece.name)]);
|
|
300
|
+
const [actions, triggers] = await Promise.all([runtime.client.fetchPieceActions(piece.name), runtime.client.fetchPieceTriggers(piece.name)]);
|
|
275
301
|
return {
|
|
276
302
|
connectorId: connectorIdForPiece(piece.name),
|
|
277
303
|
pieceName: piece.name,
|
|
@@ -286,10 +312,10 @@ async function connectorDetail(piece) {
|
|
|
286
312
|
triggers: triggers.map((trigger) => trigger.name)
|
|
287
313
|
};
|
|
288
314
|
}
|
|
289
|
-
async function rankedPieces(catalog, query) {
|
|
315
|
+
async function rankedPieces(runtime, catalog, query) {
|
|
290
316
|
let results;
|
|
291
317
|
try {
|
|
292
|
-
results = await Promise.all(["action", "trigger"].map((kind) => searchPieces(query, {
|
|
318
|
+
results = await Promise.all(["action", "trigger"].map((kind) => runtime.client.searchPieces(query, {
|
|
293
319
|
kind,
|
|
294
320
|
limit: 50
|
|
295
321
|
})));
|
|
@@ -313,19 +339,19 @@ async function rankedPieces(catalog, query) {
|
|
|
313
339
|
* at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is fetched only
|
|
314
340
|
* for the surviving entries (stage two).
|
|
315
341
|
*/
|
|
316
|
-
async function getConnectors(query) {
|
|
317
|
-
|
|
318
|
-
const catalog = await fetchPieceCatalog();
|
|
342
|
+
async function getConnectors(runtime, query) {
|
|
343
|
+
const catalog = await runtime.fetchPieceCatalog();
|
|
319
344
|
const needle = query?.trim().toLowerCase();
|
|
320
345
|
const exact = catalog.filter((piece) => piece.name.toLowerCase() === needle);
|
|
321
|
-
const matches = !needle ? [...catalog] : exact.length > 0 ? exact : await rankedPieces(catalog, needle) ?? catalog.filter((piece) => [
|
|
346
|
+
const matches = !needle ? [...catalog] : exact.length > 0 ? exact : await rankedPieces(runtime, catalog, needle) ?? catalog.filter((piece) => [
|
|
322
347
|
piece.name,
|
|
323
348
|
piece.displayName,
|
|
324
349
|
piece.description
|
|
325
350
|
].some((field) => field.toLowerCase().includes(needle)));
|
|
326
351
|
const page = matches.slice(0, MAX_CONNECTORS);
|
|
327
|
-
const connectors = await Promise.all(page.map(connectorDetail));
|
|
352
|
+
const connectors = await Promise.all(page.map((piece) => connectorDetail(runtime, piece)));
|
|
328
353
|
return {
|
|
354
|
+
switchboard: runtime.switchboard.name,
|
|
329
355
|
total: catalog.length,
|
|
330
356
|
matches: matches.length,
|
|
331
357
|
truncated: matches.length > page.length,
|
|
@@ -337,16 +363,14 @@ async function getConnectors(query) {
|
|
|
337
363
|
* piece's auth plan. Only field names and opaque refs are surfaced; secret
|
|
338
364
|
* values never do.
|
|
339
365
|
*/
|
|
340
|
-
async function getConnections() {
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
const client = getPHStore()?.reactorClient;
|
|
344
|
-
return { connections: await Promise.all(summaries.map(async (summary) => {
|
|
366
|
+
async function getConnections(runtime, reactor) {
|
|
367
|
+
const [catalog, summaries] = await Promise.all([runtime.fetchPieceCatalog(), runtime.client.fetchConnections()]);
|
|
368
|
+
const connections = await Promise.all(summaries.map(async (summary) => {
|
|
345
369
|
const piece = catalog.find((entry) => entry.name === packageFromConnectorId(summary.connectorId));
|
|
346
370
|
const plan = planFromAuth(piece?.auth ?? null);
|
|
347
371
|
let state;
|
|
348
|
-
if (
|
|
349
|
-
state = (await
|
|
372
|
+
if (reactor) try {
|
|
373
|
+
state = (await reactor.read.get(summary.id)).state.global;
|
|
350
374
|
} catch {
|
|
351
375
|
state = void 0;
|
|
352
376
|
}
|
|
@@ -362,7 +386,11 @@ async function getConnections() {
|
|
|
362
386
|
missingSecrets: plan.secretFields.filter((field) => field.required && !refNames.has(field.name)).map((field) => field.name),
|
|
363
387
|
missingConfig: plan.configFields.filter((field) => field.required && isConfigValueMissing(config[field.name])).map((field) => field.name)
|
|
364
388
|
};
|
|
365
|
-
}))
|
|
389
|
+
}));
|
|
390
|
+
return {
|
|
391
|
+
switchboard: runtime.switchboard.name,
|
|
392
|
+
connections
|
|
393
|
+
};
|
|
366
394
|
}
|
|
367
395
|
const READ_ONLY = {
|
|
368
396
|
readOnlyHint: true,
|
|
@@ -375,34 +403,46 @@ const aiTools = [
|
|
|
375
403
|
{
|
|
376
404
|
name: "getConnectors",
|
|
377
405
|
description: "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.",
|
|
378
|
-
inputSchema: {
|
|
406
|
+
inputSchema: {
|
|
407
|
+
query: z.string().optional(),
|
|
408
|
+
switchboard: switchboardInput
|
|
409
|
+
},
|
|
379
410
|
annotations: {
|
|
380
411
|
title: "Get Connectors",
|
|
381
412
|
...READ_ONLY
|
|
382
413
|
},
|
|
383
|
-
callback: (args) => getConnectors(args.query)
|
|
414
|
+
callback: async (args, context) => getConnectors(await runtimeFor(context, { switchboard: args.switchboard }), args.query)
|
|
384
415
|
},
|
|
385
416
|
{
|
|
386
417
|
name: "getConnections",
|
|
387
418
|
description: "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.",
|
|
388
|
-
inputSchema: {},
|
|
419
|
+
inputSchema: { switchboard: switchboardInput },
|
|
389
420
|
annotations: {
|
|
390
421
|
title: "Get Connections",
|
|
391
422
|
...READ_ONLY
|
|
392
423
|
},
|
|
393
|
-
callback: () => getConnections()
|
|
424
|
+
callback: async (args, context) => getConnections(await runtimeFor(context, { switchboard: args.switchboard }), context?.reactor)
|
|
394
425
|
},
|
|
395
426
|
{
|
|
396
427
|
name: "checkConnection",
|
|
397
428
|
description: "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.",
|
|
398
|
-
inputSchema: {
|
|
429
|
+
inputSchema: {
|
|
430
|
+
connectionId: z.string(),
|
|
431
|
+
switchboard: switchboardInput
|
|
432
|
+
},
|
|
399
433
|
annotations: {
|
|
400
434
|
title: "Check Connection",
|
|
401
435
|
...READ_ONLY
|
|
402
436
|
},
|
|
403
|
-
callback: (args) => {
|
|
404
|
-
|
|
405
|
-
|
|
437
|
+
callback: async (args, context) => {
|
|
438
|
+
const runtime = await runtimeFor(context, {
|
|
439
|
+
switchboard: args.switchboard,
|
|
440
|
+
documentId: args.connectionId
|
|
441
|
+
});
|
|
442
|
+
return {
|
|
443
|
+
switchboard: runtime.switchboard.name,
|
|
444
|
+
...await runtime.client.checkConnection(args.connectionId)
|
|
445
|
+
};
|
|
406
446
|
}
|
|
407
447
|
},
|
|
408
448
|
...workflowTools
|