@powerhousedao/workflow 6.2.3-dev.70 → 6.2.3-dev.72

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 (26) hide show
  1. package/dist/browser/index.js +7 -1
  2. package/dist/browser/index.js.map +1 -1
  3. package/dist/node/{BlockSelector-CF4xOFNG.mjs → BlockSelector-DxXYdr5t.mjs} +2 -2
  4. package/dist/node/{BlockSelector-CF4xOFNG.mjs.map → BlockSelector-DxXYdr5t.mjs.map} +1 -1
  5. package/dist/node/{connection-form-CYlSCGTK.mjs → connection-form-DTSc53AN.mjs} +2 -2
  6. package/dist/node/{connection-form-CYlSCGTK.mjs.map → connection-form-DTSc53AN.mjs.map} +1 -1
  7. package/dist/node/{data-tree-DmhiI_Jk.mjs → data-tree-ipZxT505.mjs} +2 -2
  8. package/dist/node/{data-tree-DmhiI_Jk.mjs.map → data-tree-ipZxT505.mjs.map} +1 -1
  9. package/dist/node/{editor-k8zOuO2n.mjs → editor-CJQMkSY2.mjs} +3 -3
  10. package/dist/node/{editor-k8zOuO2n.mjs.map → editor-CJQMkSY2.mjs.map} +1 -1
  11. package/dist/node/{editor-C6B1IKNB.mjs → editor-CLxEQeXA.mjs} +3 -3
  12. package/dist/node/{editor-C6B1IKNB.mjs.map → editor-CLxEQeXA.mjs.map} +1 -1
  13. package/dist/node/{editor-B653s9Xv.mjs → editor-QA6dGrRt.mjs} +4 -4
  14. package/dist/node/{editor-B653s9Xv.mjs.map → editor-QA6dGrRt.mjs.map} +1 -1
  15. package/dist/node/editors/connection-editor/module.mjs +1 -1
  16. package/dist/node/editors/workflow-editor/module.mjs +1 -1
  17. package/dist/node/editors/workflow-studio/module.mjs +1 -1
  18. package/dist/node/index.mjs +7 -1
  19. package/dist/node/index.mjs.map +1 -1
  20. package/dist/node/pieces/reactor/descriptor.json +1 -1
  21. package/dist/node/pieces/reactor/package.json +1 -1
  22. package/dist/node/{trigger-text-D98Ip9qF.mjs → trigger-text-B8n6hc1C.mjs} +3 -3
  23. package/dist/node/{trigger-text-D98Ip9qF.mjs.map → trigger-text-B8n6hc1C.mjs.map} +1 -1
  24. package/dist/powerhouse.manifest.json +1 -1
  25. package/dist/types/ai/runtime-url.d.ts.map +1 -1
  26. package/package.json +8 -8
@@ -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-C6B1IKNB.mjs")),
5
+ Component: lazy(() => import("../../editor-CLxEQeXA.mjs")),
6
6
  documentTypes: ["powerhouse/connection"],
7
7
  config: {
8
8
  id: "connection-editor",
@@ -2,7 +2,7 @@ import { lazy } from "react";
2
2
  //#region editors/workflow-editor/module.ts
3
3
  /** Document editor module for the "powerhouse/workflow" document type */
4
4
  const WorkflowEditor = {
5
- Component: lazy(() => import("../../editor-B653s9Xv.mjs")),
5
+ Component: lazy(() => import("../../editor-QA6dGrRt.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-k8zOuO2n.mjs")),
5
+ Component: lazy(() => import("../../editor-CJQMkSY2.mjs")),
6
6
  documentTypes: ["powerhouse/document-drive"],
7
7
  config: {
8
8
  id: "workflow-studio",
@@ -175,9 +175,15 @@ const fetchRuns = (scope) => ambient.fetchRuns(scope);
175
175
  const fireWorkflow = (workflowId, payload) => ambient.fireWorkflow(workflowId, payload);
176
176
  //#endregion
177
177
  //#region ai/runtime-url.ts
178
+ const warnedDrives = /* @__PURE__ */ new Set();
178
179
  function syncRuntimeUrl() {
179
180
  if (typeof window === "undefined") return;
180
- const switchboard = resolveDriveSwitchboard(getPHStore()?.selectedDriveId);
181
+ const driveId = getPHStore()?.selectedDriveId;
182
+ const switchboard = resolveDriveSwitchboard(driveId);
183
+ if (!switchboard && driveId && !warnedDrives.has(driveId)) {
184
+ warnedDrives.add(driveId);
185
+ console.warn(`[workflow] Drive "${driveId}" is not synced from a switchboard, so Workflow Studio falls back to ${DEFAULT_RUNTIME_URL}. Attach the switchboard's Workflows drive (its /d/<slug> URL) instead of a local drive.`);
186
+ }
181
187
  setRuntimeUrl(switchboard ? `${switchboard.graphqlUrl}/workflow-runtime` : DEFAULT_RUNTIME_URL);
182
188
  }
183
189
  //#endregion
@@ -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\nexport function syncRuntimeUrl(): void {\n if (typeof window === \"undefined\") return;\n const switchboard = resolveDriveSwitchboard(getPHStore()?.selectedDriveId);\n // No resolvable switchboard (no selection, or a local/unsynced drive):\n // reset to the default rather than leaving a prior drive's URL attached.\n setRuntimeUrl(\n switchboard\n ? `${switchboard.graphqlUrl}/workflow-runtime`\n : DEFAULT_RUNTIME_URL,\n );\n}\n","// AI tool descriptors for authoring and running workflows: the pinned blocks\n// a piece offers, a block's config props, the built-in core blocks with\n// the expression syntax, run history and manual firing. Complements the\n// connector/connection tools in tools.ts, which cover the catalog and auth.\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n fetchPieceActions,\n fetchPieceTriggers,\n fetchRuns,\n fireWorkflow,\n getBlockForm,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport type { BlockFormProp } from \"../editors/workflow-editor/ui/forms.js\";\nimport { 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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ACF,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
+ {"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,sBAAs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AC;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-reactor",
3
- "version": "6.2.3-dev.70",
3
+ "version": "6.2.3-dev.72",
4
4
  "displayName": "Powerhouse Reactor",
5
5
  "logoUrl": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMTQgMTE0IiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbD0iIzE2MTYxNiIgZD0iTTcxLjI5MTkgMEwyNC4zNDE1IDM4Ljg3NzJDMTcuNDU0OCA0NC41Nzk4IDE2Ljk1MzkgNTQuOTY1OSAyMy4yNiA2MS4zMDQ3TDM5LjUwMjggNzcuNjMxOEM0NC4yNjg0IDgyLjQyMjEgNDUuMjk5NiA4OS43ODM0IDQyLjAzMzUgOTUuNjk4OEwzMS45MjkgMTE0SDE1LjJDNi44MDUyNyAxMTQgMCAxMDcuMTk1IDAgOTguOFYxNS4yQzAgNi44MDUyNyA2LjgwNTI3IDAgMTUuMiAwSDcxLjI5MTlaTTgwLjExMSAwTDcxLjM0MTIgMTUuOTc1OEM2OC4xMDc4IDIxLjg2NiA2OS4xMjU1IDI5LjE4MDQgNzMuODQ0MSAzMy45NjQxTDkxLjA3NTEgNTEuNDMzMUM5Ny4zNjc0IDU3LjgxMjQgOTYuODA0NCA2OC4yMjI3IDg5Ljg2MDcgNzMuODg2MUw0MC42NzgyIDExNEg5OC44QzEwNy4xOTUgMTE0IDExNCAxMDcuMTk1IDExNCA5OC44VjE1LjJDMTE0IDYuODA1MjcgMTA3LjE5NSAwIDk4LjggMEg4MC4xMTFaIi8+PC9zdmc+",
6
6
  "actions": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/piece-reactor",
3
- "version": "6.2.3-dev.70",
3
+ "version": "6.2.3-dev.72",
4
4
  "description": "Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state and schemas, and fire on document events.",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
@@ -1,6 +1,6 @@
1
1
  import { $ as SCHEDULE_TRIGGER, Z as MANUAL_TRIGGER, _t as isDocumentRefMarker, dt as DOCUMENT_REF_KEY, mt as documentRefsIn, nt as WEBHOOK_TRIGGER, yt as parseScheduleConfig } from "./runtime-queries-CJSpbsBq.mjs";
2
2
  import { t as blockKey } from "./block-type-kX-27vVt.mjs";
3
- import { At as IconButton, Et as Button, Ft as Toggle, It as Tooltip, f as blockMeta } from "./BlockSelector-CF4xOFNG.mjs";
3
+ import { At as IconButton, Et as Button, Ft as Toggle, It as Tooltip, f as blockMeta } from "./BlockSelector-DxXYdr5t.mjs";
4
4
  import { useSetSelectedNode } from "@powerhousedao/reactor-browser";
5
5
  import { Suspense, lazy, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -270,7 +270,7 @@ function DocumentRefs(props) {
270
270
  }
271
271
  //#endregion
272
272
  //#region editors/shared/data-viewer.tsx
273
- const DataTree = lazy(() => import("./data-tree-DmhiI_Jk.mjs"));
273
+ const DataTree = lazy(() => import("./data-tree-ipZxT505.mjs"));
274
274
  function stringify(value) {
275
275
  try {
276
276
  return JSON.stringify(value, null, 2) ?? "";
@@ -489,4 +489,4 @@ function describeTrigger(trigger) {
489
489
  //#endregion
490
490
  export { StepError as a, PublishState as c, StatusToggle as d, usePublish as f, uniqueStepKey as g, hasDraftChanges as h, DataViewer as i, PublishedMissingNote as l, VARIABLES_VIEW as m, describeSchedule as n, DraftBanner as o, STEP_PARAM as p, describeTrigger as r, PublishButton as s, describeCron as t, ReactorDenialNote as u };
491
491
 
492
- //# sourceMappingURL=trigger-text-D98Ip9qF.mjs.map
492
+ //# sourceMappingURL=trigger-text-B8n6hc1C.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger-text-D98Ip9qF.mjs","names":[],"sources":["../../editors/workflow-editor/ui/model.ts","../../editors/workflow-editor/ui/PublishControls.tsx","../../editors/workflow-editor/ui/StepError.tsx","../../editors/shared/document-ref.tsx","../../editors/shared/data-viewer.tsx","../../editors/workflow-editor/ui/trigger-text.ts"],"sourcesContent":["// Plain view model + callbacks; no document-model imports so the UI layer\n// stays independent of Powerhouse document plumbing.\nimport type { AddedBlock } from \"./add-follow-up.js\";\nimport type { BlockForm } from \"./forms.js\";\n\nexport type WorkflowStatusValue = \"DRAFT\" | \"ENABLED\" | \"DISABLED\" | \"ARCHIVED\";\n\nexport interface PointModel {\n x: number;\n y: number;\n}\n\nexport type PropertyModeValue = \"MANUAL\" | \"EXPRESSION\";\n\nexport interface PropertySettingModel {\n prop: string;\n mode: PropertyModeValue;\n // A DYNAMIC prop's resolved children, options stripped.\n schema?: unknown;\n}\n\nexport interface TestRecordModel {\n runId: string;\n testedAt: string;\n}\n\n// Editor bookkeeping on a step or the trigger; absent on older documents.\nexport interface BlockStateModel {\n propertySettings?: PropertySettingModel[] | null;\n lastTest?: TestRecordModel | null;\n updatedAt?: string | null;\n}\n\nexport interface TriggerModel extends BlockStateModel {\n id: string;\n pieceName: string;\n pieceVersion: string;\n triggerName: string;\n config: unknown;\n connectionId: string | null;\n // A REACTOR connection, for a trigger that declares requireReactor.\n reactorConnectionId?: string | null;\n}\n\nexport type BackoffKindValue = \"FIXED\" | \"EXPONENTIAL\";\n\nexport interface RetryPolicyModel {\n maxAttempts: number;\n backoff: BackoffKindValue;\n initialDelaySeconds: number;\n maxDelaySeconds: number;\n retryOn: string[];\n}\n\nexport interface StepModel extends BlockStateModel {\n id: string;\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n connectionId: string | null;\n // A REACTOR connection, for an action that declares requireReactor.\n reactorConnectionId?: string | null;\n config: unknown;\n retry: RetryPolicyModel | null;\n timeoutSeconds: number | null;\n idempotencyKeyExpression: string | null;\n position: PointModel | null;\n skip?: boolean;\n}\n\nexport interface EdgeModel {\n id: string;\n from: string;\n to: string;\n port: string;\n condition: string | null;\n}\n\nexport type VariableTypeValue =\n | \"TEXT\"\n | \"NUMBER\"\n | \"BOOLEAN\"\n | \"JSON\"\n | \"SECRET\";\n\nexport interface VariableModel {\n id: string;\n key: string;\n value: unknown;\n description: string | null;\n // Null means untyped: the type is inferred from the value.\n type?: VariableTypeValue | null;\n}\n\nexport interface PublishedBlockModel {\n id: string;\n // The step's name, or \"Trigger\".\n label: string;\n pieceName: string;\n pieceVersion: string;\n kind: \"action\" | \"trigger\";\n name: string;\n reactorConnectionId: string | null;\n}\n\nexport interface PublishedModel {\n version: number;\n publishedAt: string;\n // The snapshot's blocks, trigger first; what actually runs.\n blocks?: PublishedBlockModel[];\n}\n\nexport interface WorkflowModel {\n name: string;\n description?: string | null;\n status: WorkflowStatusValue;\n version: number;\n trigger: TriggerModel | null;\n steps: StepModel[];\n edges: EdgeModel[];\n variables: VariableModel[];\n published?: PublishedModel | null;\n // Writes nothing, bookkeeping included.\n readOnly?: boolean;\n}\n\n// The side panel's id for the variables editor, beside step and trigger ids.\nexport const VARIABLES_VIEW = \"__variables\";\n\n/** Query params of the editor's view: the open panel and its tab. */\nexport const STEP_PARAM = \"step\";\nexport const TAB_PARAM = \"tab\";\n\n// Unpublished changes: never published, or edited since.\nexport function hasDraftChanges(\n model: Pick<WorkflowModel, \"version\" | \"published\">,\n): boolean {\n return !model.published || model.published.version !== model.version;\n}\n\nexport interface AddStepInputModel {\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n config: unknown;\n position?: PointModel;\n}\n\nexport interface UpdateStepInputModel {\n id: string;\n key?: string;\n name?: string;\n // \"Update to vZ\" edits only pieceVersion.\n pieceName?: string;\n pieceVersion?: string;\n actionName?: string;\n // null clears the step's connection.\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n config?: unknown;\n // null clears each of these; undefined leaves them unchanged.\n retry?: RetryPolicyModel | null;\n timeoutSeconds?: number | null;\n idempotencyKeyExpression?: string | null;\n position?: PointModel;\n skip?: boolean;\n}\n\n// Field modes and DYNAMIC schemas ride along with the config edit they\n// belong to; undefined leaves them as they are.\nexport interface ConfigExtras {\n propertySettings?: PropertySettingModel[];\n}\n\nexport interface WorkflowEditorCallbacks {\n setName: (name: string) => void;\n setDescription: (description: string) => void;\n setStatus: (status: WorkflowStatusValue) => void;\n setTrigger: (\n input: {\n pieceName: string;\n pieceVersion: string;\n triggerName: string;\n config: unknown;\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n } & ConfigExtras,\n ) => AddedBlock;\n // Field-level trigger edits: each leaves the trigger's other fields alone.\n setTriggerConfig: (config: unknown, extras?: ConfigExtras) => void;\n // null clears a connection; undefined leaves it unchanged.\n setTriggerConnection: (input: {\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n }) => void;\n setTriggerPieceVersion: (pieceVersion: string) => void;\n clearTrigger: () => void;\n addStep: (input: AddStepInputModel) => AddedBlock;\n updateStep: (input: UpdateStepInputModel) => void;\n setStepConfig: (id: string, config: unknown, extras?: ConfigExtras) => void;\n // Snapshots the draft and turns the workflow on; resolves once applied.\n publish: () => Promise<void>;\n discardChanges: () => void;\n removeStep: (id: string) => void;\n addEdge: (input: {\n from: string;\n to: string;\n port: string;\n condition?: string;\n }) => void;\n removeEdge: (id: string) => void;\n // Upserts by id; no id adds a variable. Keys are unique.\n setVariable: (input: {\n id?: string;\n key: string;\n value: unknown;\n description?: string;\n // Undefined leaves the type as is; null clears it.\n type?: VariableTypeValue | null;\n }) => void;\n removeVariable: (id: string) => void;\n // Composite operations backing the canvas add buttons.\n // `port` is the inserted block's own port the old edge's target hangs off.\n insertStepOnEdge: (\n edgeId: string,\n input: AddStepInputModel,\n port: string,\n ) => AddedBlock | undefined;\n appendStep: (\n fromId: string,\n port: string,\n input: AddStepInputModel,\n ) => AddedBlock;\n // Completes a block added before its form loaded: the defaults still unset\n // and the port it continues on. Nothing when the block is gone.\n completeBlock: (added: AddedBlock, form: BlockForm) => void;\n // Copies a step with its config and advanced settings, detached from the\n // graph so no port ends up with two edges.\n duplicateStep: (id: string) => void;\n // Re-parents a step onto a port, keeping whatever follows it.\n moveStep: (move: {\n stepId: string;\n toParentId: string;\n port: string;\n }) => void;\n}\n\n// Slugified step key derived from a label, suffixed until it is free.\nexport function uniqueStepKey(taken: string[], label: string): string {\n const base =\n label\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/g, \"_\")\n .replaceAll(/^_+|_+$/g, \"\") || \"step\";\n const keys = new Set(taken);\n let key = base;\n let suffix = 2;\n while (keys.has(key)) key = `${base}_${suffix++}`;\n return key;\n}\n","// Publishing, the Activepieces way: a draft that is always editable, a\n// Publish that snapshots it, and an on/off switch for the published flow.\nimport { useState } from \"react\";\nimport { Button, Toggle, Tooltip } from \"../../shared/controls.js\";\nimport {\n hasDraftChanges,\n type WorkflowEditorCallbacks,\n type WorkflowModel,\n type WorkflowStatusValue,\n} from \"./model.js\";\nimport type { WorkflowReadiness } from \"./validation.js\";\n\n// Under enforcement a publish must be signed, or its runs reach no documents.\nexport interface PublishSignIn {\n required: boolean;\n pending: boolean;\n login: () => void;\n}\n\nfunction blockedReason(readiness: WorkflowReadiness): string {\n if (!readiness.hasTrigger) return \"Add a trigger first\";\n if (readiness.firstIncomplete) return \"You have incomplete steps\";\n return \"Checking the steps…\";\n}\n\nexport function usePublish(callbacks: WorkflowEditorCallbacks) {\n const [publishing, setPublishing] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const publish = () => {\n if (publishing) return;\n setPublishing(true);\n setError(null);\n callbacks\n .publish()\n .catch((cause: unknown) =>\n setError(cause instanceof Error ? cause.message : String(cause)),\n )\n .finally(() => setPublishing(false));\n };\n return { publishing, error, publish };\n}\n\nexport function PublishButton(props: {\n model: WorkflowModel;\n readiness: WorkflowReadiness;\n publishing: boolean;\n onPublish: () => void;\n onSelect: (id: string) => void;\n size?: \"sm\" | \"md\";\n signIn?: PublishSignIn;\n}) {\n const { model, readiness } = props;\n if (props.signIn?.required) {\n return (\n <Tooltip content=\"This Switchboard enforces document permissions, so a publish must be signed\">\n <Button\n size={props.size ?? \"sm\"}\n variant=\"primary\"\n disabled={props.signIn.pending}\n onClick={props.signIn.login}\n >\n Sign in to publish\n </Button>\n </Tooltip>\n );\n }\n const incomplete = !readiness.ready;\n const changes = hasDraftChanges(model);\n const target = readiness.firstIncomplete;\n const select = () => {\n if (target) props.onSelect(target);\n };\n return (\n <Tooltip\n enabled={incomplete}\n content={\n <button\n type=\"button\"\n className=\"font-medium text-wf-warn hover:underline\"\n onClick={select}\n >\n {blockedReason(readiness)}\n </button>\n }\n >\n {/* The disabled button passes clicks through to this wrapper. */}\n <span className=\"inline-flex\" onClick={incomplete ? select : undefined}>\n <Button\n size={props.size ?? \"sm\"}\n variant=\"primary\"\n disabled={incomplete || !changes || props.publishing}\n title={!changes && !incomplete ? \"No unpublished changes\" : undefined}\n onClick={props.onPublish}\n >\n {props.publishing ? \"Publishing…\" : \"Publish\"}\n </Button>\n </span>\n </Tooltip>\n );\n}\n\n// A dot and a word: Draft until first published, then Published, or\n// Unpublished changes once the draft moves on.\nexport function PublishState(props: {\n model: Pick<WorkflowModel, \"version\" | \"published\">;\n}) {\n const draft = hasDraftChanges(props.model);\n return (\n <span\n className=\"flex shrink-0 items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\"\n title={\n props.model.published\n ? `Published ${new Date(props.model.published.publishedAt).toLocaleString()}`\n : \"Never published\"\n }\n >\n <span\n aria-hidden\n className={`h-2 w-2 rounded-full ${draft ? \"bg-wf-warn\" : \"bg-wf-ok\"}`}\n />\n <span>\n {!props.model.published\n ? \"Draft\"\n : draft\n ? \"Unpublished changes\"\n : \"Published\"}\n </span>\n {props.model.published && draft ? (\n <span className=\"text-muted-foreground/80\">\n · v{props.model.published.version} live\n </span>\n ) : null}\n </span>\n );\n}\n\nexport function StatusToggle(props: {\n published: boolean;\n status: WorkflowStatusValue;\n onChange: (status: WorkflowStatusValue) => void;\n tooltipSide?: \"below\" | \"left\";\n}) {\n // Nothing runs until the first publish.\n const allowed = props.published;\n const on = props.status === \"ENABLED\";\n return (\n <Tooltip\n enabled={!allowed}\n content=\"Publish the workflow first\"\n align=\"end\"\n side={props.tooltipSide}\n >\n <span className=\"flex items-center gap-2 text-xs text-muted-foreground\">\n <Toggle\n checked={on}\n disabled={!allowed}\n label={on ? \"Turn the workflow off\" : \"Turn the workflow on\"}\n onChange={(checked) =>\n props.onChange(checked ? \"ENABLED\" : \"DISABLED\")\n }\n />\n <span className=\"w-6\">{on ? \"On\" : \"Off\"}</span>\n </span>\n </Tooltip>\n );\n}\n\n// The live snapshot's blocks that need a reactor connection and bind none.\nexport function PublishedMissingNote(props: { missing: readonly string[] }) {\n if (props.missing.length === 0) return null;\n return (\n <span\n role=\"alert\"\n aria-label=\"Published version incomplete\"\n className=\"shrink-0 whitespace-nowrap rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn\"\n title={`The published version is missing a reactor connection on: ${props.missing.join(\", \")}`}\n >\n Live version incomplete\n </span>\n );\n}\n\n// Why the runtime won't give the published workflow reactor access.\nexport function ReactorDenialNote(props: { denial: string | null }) {\n if (!props.denial) return null;\n return (\n <span\n role=\"alert\"\n aria-label=\"Reactor access denied\"\n className=\"max-w-80 truncate rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn\"\n title={props.denial}\n >\n No reactor access: {props.denial}\n </span>\n );\n}\n\nexport function DraftBanner(props: {\n model: WorkflowModel;\n readiness: WorkflowReadiness;\n publishing: boolean;\n error: string | null;\n onPublish: () => void;\n onDiscard: () => void;\n onSelect: (id: string) => void;\n signIn?: PublishSignIn;\n}) {\n if (!hasDraftChanges(props.model)) return null;\n const { readiness } = props;\n const target = readiness.firstIncomplete;\n return (\n <div\n role=\"status\"\n className=\"pointer-events-auto flex items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card py-1.5 pl-3 pr-1.5 text-[13px] shadow-sm\"\n >\n <span className=\"h-2 w-2 shrink-0 rounded-full bg-wf-warn\" aria-hidden />\n <span className=\"text-foreground\">You have unpublished changes</span>\n {props.error ? (\n <span className=\"text-xs text-wf-fail\">{props.error}</span>\n ) : null}\n {!readiness.hasTrigger || target ? (\n <span className=\"flex items-center gap-1.5 text-xs text-wf-warn\">\n <span>{target ? \"Incomplete steps\" : \"No trigger yet\"}</span>\n {target ? (\n <button\n type=\"button\"\n className=\"font-medium underline underline-offset-2 hover:no-underline\"\n onClick={() => props.onSelect(target)}\n >\n Show\n </button>\n ) : null}\n </span>\n ) : null}\n <span className=\"flex items-center gap-1\">\n {props.model.published ? (\n <Button size=\"sm\" variant=\"ghost\" onClick={props.onDiscard}>\n Discard changes\n </Button>\n ) : null}\n <PublishButton\n model={props.model}\n readiness={readiness}\n publishing={props.publishing}\n onPublish={props.onPublish}\n onSelect={props.onSelect}\n signIn={props.signIn}\n />\n </span>\n </div>\n );\n}\n","// A step's error from a run.\nexport function StepError(props: { error: string }) {\n return (\n <pre className=\"overflow-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail\">\n {props.error}\n </pre>\n );\n}\n","// The documents a run's data references: the run journal keeps a reference\n// (id, type, branch, revision) in place of a document's state.\nimport type { DocumentReference } from \"@powerhousedao/pieces-framework/workflow\";\nimport { useSetSelectedNode } from \"@powerhousedao/reactor-browser\";\nimport { Button } from \"./controls.js\";\n\n// Beyond this many, the rest are counted.\nconst SHOWN = 3;\n\nfunction shortId(id: string): string {\n return id.length > 16 ? `${id.slice(0, 6)}…${id.slice(-6)}` : id;\n}\n\nfunction revisionText(reference: DocumentReference): string {\n const scopes = Object.entries(reference.revision)\n .map(([scope, count]) => `${scope} ${count}`)\n .join(\" · \");\n return reference.branch === \"main\"\n ? scopes\n : `${reference.branch}: ${scopes}`;\n}\n\nfunction DocumentRefRow(props: { reference: DocumentReference }) {\n const { reference } = props;\n const setSelectedNode = useSetSelectedNode();\n return (\n <li\n aria-label={`Document ${reference.documentId}`}\n className=\"flex items-center gap-2\"\n >\n <div className=\"min-w-0 flex-1 text-xs\">\n <div className=\"flex min-w-0 items-baseline gap-1.5\">\n <span className=\"truncate font-medium text-foreground\">\n {reference.documentType}\n </span>\n <span\n className=\"shrink-0 font-mono text-[11px] text-muted-foreground\"\n title={reference.documentId}\n >\n {shortId(reference.documentId)}\n </span>\n </div>\n <div className=\"truncate text-[11px] text-muted-foreground\">\n Revision {revisionText(reference)}\n </div>\n </div>\n <Button\n size=\"sm\"\n onClick={() => setSelectedNode(reference.documentId)}\n aria-label={`Open document ${reference.documentId}`}\n >\n Open document\n </Button>\n </li>\n );\n}\n\nexport function DocumentRefs(props: { references: DocumentReference[] }) {\n const { references } = props;\n const hidden = references.length - SHOWN;\n return (\n <div\n role=\"group\"\n aria-label=\"Document references\"\n className=\"flex flex-col gap-1.5\"\n >\n <ul className=\"m-0 flex list-none flex-col gap-1.5 p-0\">\n {references.slice(0, SHOWN).map((reference, index) => (\n <DocumentRefRow\n key={`${reference.documentId}-${index}`}\n reference={reference}\n />\n ))}\n </ul>\n {hidden > 0 ? (\n <p className=\"text-[11px] text-muted-foreground\">\n and {hidden} more in the data below\n </p>\n ) : null}\n <p className=\"text-[11px] text-muted-foreground\">\n The run kept a reference, not the state. Opening shows the document as\n it is now: past revisions can&apos;t be read yet (#3179).\n </p>\n </div>\n );\n}\n","// A run's data (a step's input or output, a trigger payload) as a foldable\n// tree, with a raw JSON view and, given a root, per-key {{references}}.\nimport {\n DOCUMENT_REF_KEY,\n documentRefsIn,\n isDocumentRefMarker,\n} from \"@powerhousedao/pieces-framework/workflow\";\nimport { lazy, Suspense, useState } from \"react\";\nimport { IconButton } from \"./controls.js\";\nimport { DocumentRefs } from \"./document-ref.js\";\n\nconst DataTree = lazy(() => import(\"./data-tree.js\"));\n\nfunction stringify(value: unknown): string {\n try {\n // undefined for functions and symbols, despite the typing.\n return (JSON.stringify(value, null, 2) as string | undefined) ?? \"\";\n } catch {\n return String(value as string);\n }\n}\n\nfunction isEmpty(value: unknown): boolean {\n if (value === undefined || value === null) return true;\n if (typeof value === \"object\") return Object.keys(value).length === 0;\n return false;\n}\n\nfunction RawJson(props: { text: string }) {\n return (\n <pre className=\"max-h-72 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-foreground\">\n {props.text}\n </pre>\n );\n}\n\n// Stands in while the tree's chunk loads.\nfunction TreeSkeleton() {\n return (\n <div\n role=\"status\"\n aria-label=\"Loading data\"\n className=\"flex animate-pulse flex-col gap-2 py-1\"\n >\n {[\"w-2/5\", \"w-3/5\", \"w-1/2\", \"w-1/3\"].map((width, index) => (\n <span\n key={width}\n className={`h-2.5 rounded bg-muted ${width}`}\n style={{ marginLeft: index === 0 ? 0 : 16 }}\n />\n ))}\n </div>\n );\n}\n\nexport function DataViewer(props: {\n label: string;\n value: unknown;\n // Expression prefix for this value, e.g. \"steps.fetch.output\".\n root?: string;\n emptyText?: string;\n}) {\n const [raw, setRaw] = useState(false);\n const [copied, setCopied] = useState(false);\n const empty = isEmpty(props.value);\n const text = stringify(props.value);\n const tree = typeof props.value === \"object\" && props.value !== null;\n const references = tree ? documentRefsIn(props.value) : [];\n // A whole value that is a reference shows as one; its other keys stay a tree.\n const treeValue = isDocumentRefMarker(props.value)\n ? Object.fromEntries(\n Object.entries(props.value).filter(([key]) => key !== DOCUMENT_REF_KEY),\n )\n : props.value;\n\n return (\n <section\n aria-label={props.label}\n className=\"min-w-0 rounded-md border border-solid border-border bg-card\"\n >\n <header className=\"flex h-8 items-center gap-1 border-b border-solid border-border pl-3 pr-1\">\n <h4 className=\"mr-auto text-xs font-medium text-foreground\">\n {props.label}\n </h4>\n {!empty && tree ? (\n <button\n type=\"button\"\n aria-pressed={raw}\n className=\"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40\"\n onClick={() => setRaw((value) => !value)}\n >\n {raw ? \"Tree\" : \"JSON\"}\n </button>\n ) : null}\n {!empty ? (\n <IconButton\n icon={copied ? \"check\" : \"copy\"}\n label={`Copy ${props.label.toLowerCase()} as JSON`}\n onClick={() => {\n void navigator.clipboard.writeText(text).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1500);\n });\n }}\n />\n ) : null}\n </header>\n <div className=\"px-3 py-2\">\n {empty ? (\n <p className=\"text-xs text-muted-foreground\">\n {props.emptyText ?? \"Nothing\"}\n </p>\n ) : !tree ? (\n <p className=\"break-words font-mono text-xs text-foreground\">\n {text}\n </p>\n ) : raw ? (\n <RawJson text={text} />\n ) : (\n <div className=\"flex flex-col gap-2\">\n {references.length > 0 ? (\n <DocumentRefs references={references} />\n ) : null}\n {isEmpty(treeValue) ? null : (\n <div className=\"max-h-72 overflow-auto\">\n <Suspense fallback={<TreeSkeleton />}>\n <DataTree value={treeValue as object} root={props.root} />\n </Suspense>\n </div>\n )}\n </div>\n )}\n </div>\n </section>\n );\n}\n","// Plain-language descriptions of when a workflow starts: \"Every day at\n// 08:00 UTC\" rather than \"0 8 * * *\". Unknown shapes fall back to the raw text.\nimport { blockKey } from \"@powerhousedao/pieces-framework/block-type\";\nimport { blockMeta } from \"./block-meta.js\";\nimport {\n MANUAL_TRIGGER,\n REACTOR_PIECE,\n SCHEDULE_TRIGGER,\n WEBHOOK_TRIGGER,\n} from \"./blocks.js\";\nimport { parseScheduleConfig } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst WEEKDAYS = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\",\n];\n\nconst UNIT_LABEL: Record<string, [string, string]> = {\n minutes: [\"minute\", \"minutes\"],\n hours: [\"hour\", \"hours\"],\n days: [\"day\", \"days\"],\n};\n\nfunction isInt(field: string): boolean {\n return /^\\d+$/.test(field);\n}\n\nfunction clock(hour: string, minute: string): string {\n return `${hour.padStart(2, \"0\")}:${minute.padStart(2, \"0\")}`;\n}\n\nfunction dayList(field: string): string | undefined {\n if (field === \"1-5\") return \"on weekdays\";\n if (field === \"0,6\" || field === \"6,0\") return \"at weekends\";\n const days = field.split(\",\");\n if (!days.every((day) => isInt(day) && Number(day) <= 7)) return undefined;\n const names = days.map((day) => WEEKDAYS[Number(day) % 7]);\n if (names.length === 1) return `every ${names[0]}`;\n return `on ${names.slice(0, -1).join(\", \")} and ${names[names.length - 1]}`;\n}\n\n/** Describes a five-field cron expression, or returns undefined. */\nexport function describeCron(cron: string): string | undefined {\n const fields = cron.trim().split(/\\s+/);\n if (fields.length !== 5) return undefined;\n const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;\n if (month !== \"*\") return undefined;\n\n const everyMinutes = /^\\*\\/(\\d+)$/.exec(minute);\n if (everyMinutes && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\") {\n const n = Number(everyMinutes[1]);\n return n === 1 ? \"Every minute\" : `Every ${n} minutes`;\n }\n if (minute === \"*\" && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\")\n return \"Every minute\";\n if (isInt(minute) && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\")\n return minute === \"0\"\n ? \"Every hour, on the hour\"\n : `Every hour at ${minute.padStart(2, \"0\")} past`;\n\n const everyHours = /^\\*\\/(\\d+)$/.exec(hour);\n if (isInt(minute) && everyHours && dayOfMonth === \"*\" && dayOfWeek === \"*\") {\n return `Every ${everyHours[1]} hours`;\n }\n if (!isInt(minute) || !isInt(hour)) return undefined;\n const at = clock(hour, minute);\n\n if (dayOfMonth === \"*\" && dayOfWeek === \"*\") return `Every day at ${at}`;\n if (dayOfMonth === \"*\") {\n const days = dayList(dayOfWeek);\n return days\n ? `${days.charAt(0).toUpperCase()}${days.slice(1)} at ${at}`\n : undefined;\n }\n if (isInt(dayOfMonth) && dayOfWeek === \"*\") {\n return `Every month on day ${dayOfMonth} at ${at}`;\n }\n return undefined;\n}\n\nexport function describeSchedule(config: unknown): string {\n let schedule;\n try {\n schedule = parseScheduleConfig(config);\n } catch {\n return \"On a schedule that does not parse\";\n }\n if (schedule.mode === \"interval\") {\n const unit = UNIT_LABEL[schedule.unit];\n return schedule.every === 1\n ? `Every ${unit[0]}`\n : `Every ${schedule.every} ${unit[1]}`;\n }\n const described = describeCron(schedule.cron);\n return described\n ? `${described} ${schedule.timezone}`\n : `On schedule ${schedule.cron}`;\n}\n\n// A literal config value; an expression or a blank says nothing to show.\nfunction literal(config: unknown, key: string): string | undefined {\n if (!config || typeof config !== \"object\") return undefined;\n const value = (config as Record<string, unknown>)[key];\n if (typeof value !== \"string\") return undefined;\n const text = value.trim();\n return text && !text.includes(\"{{\") ? text : undefined;\n}\n\n// \"umh/production-ledger\" reads as \"Production Ledger\".\nfunction documentTypeLabel(documentType: string): string {\n const name = documentType.split(\"/\").pop() ?? documentType;\n return name\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\" \");\n}\n\n// \"APPROVE_ORDER\" reads as \"Approve order\".\nfunction actionTypeLabel(actionType: string): string {\n const words = actionType\n .toLowerCase()\n .split(/[_\\s]+/)\n .filter(Boolean);\n const text = words.join(\" \");\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n/** Describes a reactor document trigger by what it filters on. */\nexport function describeDocumentTrigger(\n triggerName: string,\n config: unknown,\n): string | undefined {\n const documentType = literal(config, \"documentType\");\n const label = documentType ? documentTypeLabel(documentType) : \"\";\n const subject = label\n ? `${/^[AEIOU]/.test(label) ? \"an\" : \"a\"} ${label}`\n : literal(config, \"documentId\")\n ? \"its document\"\n : \"a document\";\n switch (triggerName) {\n case \"document-event\": {\n const actionType = literal(config, \"actionType\");\n return actionType\n ? `When ${actionTypeLabel(actionType)} runs on ${subject}`\n : `When ${subject} changes`;\n }\n case \"document-created\":\n return `When ${subject} is created`;\n case \"document-deleted\":\n return `When ${subject} is deleted`;\n default:\n return undefined;\n }\n}\n\n/** When a workflow starts, from its trigger. */\nexport function describeTrigger(\n trigger:\n | { pieceName: string; triggerName: string; config: unknown }\n | null\n | undefined,\n): string {\n if (!trigger) return \"Never starts: no trigger\";\n const block = {\n pieceName: trigger.pieceName,\n kind: \"trigger\" as const,\n name: trigger.triggerName,\n };\n switch (blockKey(block)) {\n case blockKey(MANUAL_TRIGGER):\n return \"Manual\";\n case blockKey(WEBHOOK_TRIGGER):\n return \"When its webhook is called\";\n case blockKey(SCHEDULE_TRIGGER):\n return describeSchedule(trigger.config);\n default: {\n if (trigger.pieceName === REACTOR_PIECE) {\n const described = describeDocumentTrigger(\n trigger.triggerName,\n trigger.config,\n );\n if (described) return described;\n }\n const meta = blockMeta(block);\n const piece = meta.subtitle.replace(/ · Trigger$/, \"\");\n return `${meta.displayName} in ${piece}`;\n }\n }\n}\n"],"mappings":";;;;;;;AAiIA,MAAa,iBAAiB;;AAG9B,MAAa,aAAa;AAI1B,SAAgB,gBACd,OACS;CACT,OAAO,CAAC,MAAM,aAAa,MAAM,UAAU,YAAY,MAAM;AAC/D;AAgHA,SAAgB,cAAc,OAAiB,OAAuB;CACpE,MAAM,OACJ,MACG,YAAY,CAAC,CACb,WAAW,eAAe,GAAG,CAAC,CAC9B,WAAW,YAAY,EAAE,KAAK;CACnC,MAAM,OAAO,IAAI,IAAI,KAAK;CAC1B,IAAI,MAAM;CACV,IAAI,SAAS;CACb,OAAO,KAAK,IAAI,GAAG,GAA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,MAAM,QAAQ;CAChB;CACA,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,SAAS,cAAc,GAC1B,OAAO;EACT,KAAK,SAAS,eAAe,GAC3B,OAAO;EACT,KAAK,SAAS,gBAAgB,GAC5B,OAAO,iBAAiB,QAAQ,MAAM;EACxC,SAAS;GACP,IAAI,QAAQ,cAAA,gCAA6B;IACvC,MAAM,YAAY,wBAChB,QAAQ,aACR,QAAQ,MACV;IACA,IAAI,WAAW,OAAO;GACxB;GACA,MAAM,OAAO,UAAU,KAAK;GAC5B,MAAM,QAAQ,KAAK,SAAS,QAAQ,eAAe,EAAE;GACrD,OAAO,GAAG,KAAK,YAAY,MAAM;EACnC;CACF;AACF"}
1
+ {"version":3,"file":"trigger-text-B8n6hc1C.mjs","names":[],"sources":["../../editors/workflow-editor/ui/model.ts","../../editors/workflow-editor/ui/PublishControls.tsx","../../editors/workflow-editor/ui/StepError.tsx","../../editors/shared/document-ref.tsx","../../editors/shared/data-viewer.tsx","../../editors/workflow-editor/ui/trigger-text.ts"],"sourcesContent":["// Plain view model + callbacks; no document-model imports so the UI layer\n// stays independent of Powerhouse document plumbing.\nimport type { AddedBlock } from \"./add-follow-up.js\";\nimport type { BlockForm } from \"./forms.js\";\n\nexport type WorkflowStatusValue = \"DRAFT\" | \"ENABLED\" | \"DISABLED\" | \"ARCHIVED\";\n\nexport interface PointModel {\n x: number;\n y: number;\n}\n\nexport type PropertyModeValue = \"MANUAL\" | \"EXPRESSION\";\n\nexport interface PropertySettingModel {\n prop: string;\n mode: PropertyModeValue;\n // A DYNAMIC prop's resolved children, options stripped.\n schema?: unknown;\n}\n\nexport interface TestRecordModel {\n runId: string;\n testedAt: string;\n}\n\n// Editor bookkeeping on a step or the trigger; absent on older documents.\nexport interface BlockStateModel {\n propertySettings?: PropertySettingModel[] | null;\n lastTest?: TestRecordModel | null;\n updatedAt?: string | null;\n}\n\nexport interface TriggerModel extends BlockStateModel {\n id: string;\n pieceName: string;\n pieceVersion: string;\n triggerName: string;\n config: unknown;\n connectionId: string | null;\n // A REACTOR connection, for a trigger that declares requireReactor.\n reactorConnectionId?: string | null;\n}\n\nexport type BackoffKindValue = \"FIXED\" | \"EXPONENTIAL\";\n\nexport interface RetryPolicyModel {\n maxAttempts: number;\n backoff: BackoffKindValue;\n initialDelaySeconds: number;\n maxDelaySeconds: number;\n retryOn: string[];\n}\n\nexport interface StepModel extends BlockStateModel {\n id: string;\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n connectionId: string | null;\n // A REACTOR connection, for an action that declares requireReactor.\n reactorConnectionId?: string | null;\n config: unknown;\n retry: RetryPolicyModel | null;\n timeoutSeconds: number | null;\n idempotencyKeyExpression: string | null;\n position: PointModel | null;\n skip?: boolean;\n}\n\nexport interface EdgeModel {\n id: string;\n from: string;\n to: string;\n port: string;\n condition: string | null;\n}\n\nexport type VariableTypeValue =\n | \"TEXT\"\n | \"NUMBER\"\n | \"BOOLEAN\"\n | \"JSON\"\n | \"SECRET\";\n\nexport interface VariableModel {\n id: string;\n key: string;\n value: unknown;\n description: string | null;\n // Null means untyped: the type is inferred from the value.\n type?: VariableTypeValue | null;\n}\n\nexport interface PublishedBlockModel {\n id: string;\n // The step's name, or \"Trigger\".\n label: string;\n pieceName: string;\n pieceVersion: string;\n kind: \"action\" | \"trigger\";\n name: string;\n reactorConnectionId: string | null;\n}\n\nexport interface PublishedModel {\n version: number;\n publishedAt: string;\n // The snapshot's blocks, trigger first; what actually runs.\n blocks?: PublishedBlockModel[];\n}\n\nexport interface WorkflowModel {\n name: string;\n description?: string | null;\n status: WorkflowStatusValue;\n version: number;\n trigger: TriggerModel | null;\n steps: StepModel[];\n edges: EdgeModel[];\n variables: VariableModel[];\n published?: PublishedModel | null;\n // Writes nothing, bookkeeping included.\n readOnly?: boolean;\n}\n\n// The side panel's id for the variables editor, beside step and trigger ids.\nexport const VARIABLES_VIEW = \"__variables\";\n\n/** Query params of the editor's view: the open panel and its tab. */\nexport const STEP_PARAM = \"step\";\nexport const TAB_PARAM = \"tab\";\n\n// Unpublished changes: never published, or edited since.\nexport function hasDraftChanges(\n model: Pick<WorkflowModel, \"version\" | \"published\">,\n): boolean {\n return !model.published || model.published.version !== model.version;\n}\n\nexport interface AddStepInputModel {\n key: string;\n name: string;\n pieceName: string;\n pieceVersion: string;\n actionName: string;\n config: unknown;\n position?: PointModel;\n}\n\nexport interface UpdateStepInputModel {\n id: string;\n key?: string;\n name?: string;\n // \"Update to vZ\" edits only pieceVersion.\n pieceName?: string;\n pieceVersion?: string;\n actionName?: string;\n // null clears the step's connection.\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n config?: unknown;\n // null clears each of these; undefined leaves them unchanged.\n retry?: RetryPolicyModel | null;\n timeoutSeconds?: number | null;\n idempotencyKeyExpression?: string | null;\n position?: PointModel;\n skip?: boolean;\n}\n\n// Field modes and DYNAMIC schemas ride along with the config edit they\n// belong to; undefined leaves them as they are.\nexport interface ConfigExtras {\n propertySettings?: PropertySettingModel[];\n}\n\nexport interface WorkflowEditorCallbacks {\n setName: (name: string) => void;\n setDescription: (description: string) => void;\n setStatus: (status: WorkflowStatusValue) => void;\n setTrigger: (\n input: {\n pieceName: string;\n pieceVersion: string;\n triggerName: string;\n config: unknown;\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n } & ConfigExtras,\n ) => AddedBlock;\n // Field-level trigger edits: each leaves the trigger's other fields alone.\n setTriggerConfig: (config: unknown, extras?: ConfigExtras) => void;\n // null clears a connection; undefined leaves it unchanged.\n setTriggerConnection: (input: {\n connectionId?: string | null;\n reactorConnectionId?: string | null;\n }) => void;\n setTriggerPieceVersion: (pieceVersion: string) => void;\n clearTrigger: () => void;\n addStep: (input: AddStepInputModel) => AddedBlock;\n updateStep: (input: UpdateStepInputModel) => void;\n setStepConfig: (id: string, config: unknown, extras?: ConfigExtras) => void;\n // Snapshots the draft and turns the workflow on; resolves once applied.\n publish: () => Promise<void>;\n discardChanges: () => void;\n removeStep: (id: string) => void;\n addEdge: (input: {\n from: string;\n to: string;\n port: string;\n condition?: string;\n }) => void;\n removeEdge: (id: string) => void;\n // Upserts by id; no id adds a variable. Keys are unique.\n setVariable: (input: {\n id?: string;\n key: string;\n value: unknown;\n description?: string;\n // Undefined leaves the type as is; null clears it.\n type?: VariableTypeValue | null;\n }) => void;\n removeVariable: (id: string) => void;\n // Composite operations backing the canvas add buttons.\n // `port` is the inserted block's own port the old edge's target hangs off.\n insertStepOnEdge: (\n edgeId: string,\n input: AddStepInputModel,\n port: string,\n ) => AddedBlock | undefined;\n appendStep: (\n fromId: string,\n port: string,\n input: AddStepInputModel,\n ) => AddedBlock;\n // Completes a block added before its form loaded: the defaults still unset\n // and the port it continues on. Nothing when the block is gone.\n completeBlock: (added: AddedBlock, form: BlockForm) => void;\n // Copies a step with its config and advanced settings, detached from the\n // graph so no port ends up with two edges.\n duplicateStep: (id: string) => void;\n // Re-parents a step onto a port, keeping whatever follows it.\n moveStep: (move: {\n stepId: string;\n toParentId: string;\n port: string;\n }) => void;\n}\n\n// Slugified step key derived from a label, suffixed until it is free.\nexport function uniqueStepKey(taken: string[], label: string): string {\n const base =\n label\n .toLowerCase()\n .replaceAll(/[^a-z0-9]+/g, \"_\")\n .replaceAll(/^_+|_+$/g, \"\") || \"step\";\n const keys = new Set(taken);\n let key = base;\n let suffix = 2;\n while (keys.has(key)) key = `${base}_${suffix++}`;\n return key;\n}\n","// Publishing, the Activepieces way: a draft that is always editable, a\n// Publish that snapshots it, and an on/off switch for the published flow.\nimport { useState } from \"react\";\nimport { Button, Toggle, Tooltip } from \"../../shared/controls.js\";\nimport {\n hasDraftChanges,\n type WorkflowEditorCallbacks,\n type WorkflowModel,\n type WorkflowStatusValue,\n} from \"./model.js\";\nimport type { WorkflowReadiness } from \"./validation.js\";\n\n// Under enforcement a publish must be signed, or its runs reach no documents.\nexport interface PublishSignIn {\n required: boolean;\n pending: boolean;\n login: () => void;\n}\n\nfunction blockedReason(readiness: WorkflowReadiness): string {\n if (!readiness.hasTrigger) return \"Add a trigger first\";\n if (readiness.firstIncomplete) return \"You have incomplete steps\";\n return \"Checking the steps…\";\n}\n\nexport function usePublish(callbacks: WorkflowEditorCallbacks) {\n const [publishing, setPublishing] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const publish = () => {\n if (publishing) return;\n setPublishing(true);\n setError(null);\n callbacks\n .publish()\n .catch((cause: unknown) =>\n setError(cause instanceof Error ? cause.message : String(cause)),\n )\n .finally(() => setPublishing(false));\n };\n return { publishing, error, publish };\n}\n\nexport function PublishButton(props: {\n model: WorkflowModel;\n readiness: WorkflowReadiness;\n publishing: boolean;\n onPublish: () => void;\n onSelect: (id: string) => void;\n size?: \"sm\" | \"md\";\n signIn?: PublishSignIn;\n}) {\n const { model, readiness } = props;\n if (props.signIn?.required) {\n return (\n <Tooltip content=\"This Switchboard enforces document permissions, so a publish must be signed\">\n <Button\n size={props.size ?? \"sm\"}\n variant=\"primary\"\n disabled={props.signIn.pending}\n onClick={props.signIn.login}\n >\n Sign in to publish\n </Button>\n </Tooltip>\n );\n }\n const incomplete = !readiness.ready;\n const changes = hasDraftChanges(model);\n const target = readiness.firstIncomplete;\n const select = () => {\n if (target) props.onSelect(target);\n };\n return (\n <Tooltip\n enabled={incomplete}\n content={\n <button\n type=\"button\"\n className=\"font-medium text-wf-warn hover:underline\"\n onClick={select}\n >\n {blockedReason(readiness)}\n </button>\n }\n >\n {/* The disabled button passes clicks through to this wrapper. */}\n <span className=\"inline-flex\" onClick={incomplete ? select : undefined}>\n <Button\n size={props.size ?? \"sm\"}\n variant=\"primary\"\n disabled={incomplete || !changes || props.publishing}\n title={!changes && !incomplete ? \"No unpublished changes\" : undefined}\n onClick={props.onPublish}\n >\n {props.publishing ? \"Publishing…\" : \"Publish\"}\n </Button>\n </span>\n </Tooltip>\n );\n}\n\n// A dot and a word: Draft until first published, then Published, or\n// Unpublished changes once the draft moves on.\nexport function PublishState(props: {\n model: Pick<WorkflowModel, \"version\" | \"published\">;\n}) {\n const draft = hasDraftChanges(props.model);\n return (\n <span\n className=\"flex shrink-0 items-center gap-1.5 whitespace-nowrap text-xs text-muted-foreground\"\n title={\n props.model.published\n ? `Published ${new Date(props.model.published.publishedAt).toLocaleString()}`\n : \"Never published\"\n }\n >\n <span\n aria-hidden\n className={`h-2 w-2 rounded-full ${draft ? \"bg-wf-warn\" : \"bg-wf-ok\"}`}\n />\n <span>\n {!props.model.published\n ? \"Draft\"\n : draft\n ? \"Unpublished changes\"\n : \"Published\"}\n </span>\n {props.model.published && draft ? (\n <span className=\"text-muted-foreground/80\">\n · v{props.model.published.version} live\n </span>\n ) : null}\n </span>\n );\n}\n\nexport function StatusToggle(props: {\n published: boolean;\n status: WorkflowStatusValue;\n onChange: (status: WorkflowStatusValue) => void;\n tooltipSide?: \"below\" | \"left\";\n}) {\n // Nothing runs until the first publish.\n const allowed = props.published;\n const on = props.status === \"ENABLED\";\n return (\n <Tooltip\n enabled={!allowed}\n content=\"Publish the workflow first\"\n align=\"end\"\n side={props.tooltipSide}\n >\n <span className=\"flex items-center gap-2 text-xs text-muted-foreground\">\n <Toggle\n checked={on}\n disabled={!allowed}\n label={on ? \"Turn the workflow off\" : \"Turn the workflow on\"}\n onChange={(checked) =>\n props.onChange(checked ? \"ENABLED\" : \"DISABLED\")\n }\n />\n <span className=\"w-6\">{on ? \"On\" : \"Off\"}</span>\n </span>\n </Tooltip>\n );\n}\n\n// The live snapshot's blocks that need a reactor connection and bind none.\nexport function PublishedMissingNote(props: { missing: readonly string[] }) {\n if (props.missing.length === 0) return null;\n return (\n <span\n role=\"alert\"\n aria-label=\"Published version incomplete\"\n className=\"shrink-0 whitespace-nowrap rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn\"\n title={`The published version is missing a reactor connection on: ${props.missing.join(\", \")}`}\n >\n Live version incomplete\n </span>\n );\n}\n\n// Why the runtime won't give the published workflow reactor access.\nexport function ReactorDenialNote(props: { denial: string | null }) {\n if (!props.denial) return null;\n return (\n <span\n role=\"alert\"\n aria-label=\"Reactor access denied\"\n className=\"max-w-80 truncate rounded-full bg-wf-warn/12 px-2 py-0.5 text-xs text-wf-warn\"\n title={props.denial}\n >\n No reactor access: {props.denial}\n </span>\n );\n}\n\nexport function DraftBanner(props: {\n model: WorkflowModel;\n readiness: WorkflowReadiness;\n publishing: boolean;\n error: string | null;\n onPublish: () => void;\n onDiscard: () => void;\n onSelect: (id: string) => void;\n signIn?: PublishSignIn;\n}) {\n if (!hasDraftChanges(props.model)) return null;\n const { readiness } = props;\n const target = readiness.firstIncomplete;\n return (\n <div\n role=\"status\"\n className=\"pointer-events-auto flex items-center gap-3 rounded-lg border border-solid border-foreground/10 bg-card py-1.5 pl-3 pr-1.5 text-[13px] shadow-sm\"\n >\n <span className=\"h-2 w-2 shrink-0 rounded-full bg-wf-warn\" aria-hidden />\n <span className=\"text-foreground\">You have unpublished changes</span>\n {props.error ? (\n <span className=\"text-xs text-wf-fail\">{props.error}</span>\n ) : null}\n {!readiness.hasTrigger || target ? (\n <span className=\"flex items-center gap-1.5 text-xs text-wf-warn\">\n <span>{target ? \"Incomplete steps\" : \"No trigger yet\"}</span>\n {target ? (\n <button\n type=\"button\"\n className=\"font-medium underline underline-offset-2 hover:no-underline\"\n onClick={() => props.onSelect(target)}\n >\n Show\n </button>\n ) : null}\n </span>\n ) : null}\n <span className=\"flex items-center gap-1\">\n {props.model.published ? (\n <Button size=\"sm\" variant=\"ghost\" onClick={props.onDiscard}>\n Discard changes\n </Button>\n ) : null}\n <PublishButton\n model={props.model}\n readiness={readiness}\n publishing={props.publishing}\n onPublish={props.onPublish}\n onSelect={props.onSelect}\n signIn={props.signIn}\n />\n </span>\n </div>\n );\n}\n","// A step's error from a run.\nexport function StepError(props: { error: string }) {\n return (\n <pre className=\"overflow-auto whitespace-pre-wrap rounded-md bg-wf-fail/10 p-2.5 text-xs text-wf-fail\">\n {props.error}\n </pre>\n );\n}\n","// The documents a run's data references: the run journal keeps a reference\n// (id, type, branch, revision) in place of a document's state.\nimport type { DocumentReference } from \"@powerhousedao/pieces-framework/workflow\";\nimport { useSetSelectedNode } from \"@powerhousedao/reactor-browser\";\nimport { Button } from \"./controls.js\";\n\n// Beyond this many, the rest are counted.\nconst SHOWN = 3;\n\nfunction shortId(id: string): string {\n return id.length > 16 ? `${id.slice(0, 6)}…${id.slice(-6)}` : id;\n}\n\nfunction revisionText(reference: DocumentReference): string {\n const scopes = Object.entries(reference.revision)\n .map(([scope, count]) => `${scope} ${count}`)\n .join(\" · \");\n return reference.branch === \"main\"\n ? scopes\n : `${reference.branch}: ${scopes}`;\n}\n\nfunction DocumentRefRow(props: { reference: DocumentReference }) {\n const { reference } = props;\n const setSelectedNode = useSetSelectedNode();\n return (\n <li\n aria-label={`Document ${reference.documentId}`}\n className=\"flex items-center gap-2\"\n >\n <div className=\"min-w-0 flex-1 text-xs\">\n <div className=\"flex min-w-0 items-baseline gap-1.5\">\n <span className=\"truncate font-medium text-foreground\">\n {reference.documentType}\n </span>\n <span\n className=\"shrink-0 font-mono text-[11px] text-muted-foreground\"\n title={reference.documentId}\n >\n {shortId(reference.documentId)}\n </span>\n </div>\n <div className=\"truncate text-[11px] text-muted-foreground\">\n Revision {revisionText(reference)}\n </div>\n </div>\n <Button\n size=\"sm\"\n onClick={() => setSelectedNode(reference.documentId)}\n aria-label={`Open document ${reference.documentId}`}\n >\n Open document\n </Button>\n </li>\n );\n}\n\nexport function DocumentRefs(props: { references: DocumentReference[] }) {\n const { references } = props;\n const hidden = references.length - SHOWN;\n return (\n <div\n role=\"group\"\n aria-label=\"Document references\"\n className=\"flex flex-col gap-1.5\"\n >\n <ul className=\"m-0 flex list-none flex-col gap-1.5 p-0\">\n {references.slice(0, SHOWN).map((reference, index) => (\n <DocumentRefRow\n key={`${reference.documentId}-${index}`}\n reference={reference}\n />\n ))}\n </ul>\n {hidden > 0 ? (\n <p className=\"text-[11px] text-muted-foreground\">\n and {hidden} more in the data below\n </p>\n ) : null}\n <p className=\"text-[11px] text-muted-foreground\">\n The run kept a reference, not the state. Opening shows the document as\n it is now: past revisions can&apos;t be read yet (#3179).\n </p>\n </div>\n );\n}\n","// A run's data (a step's input or output, a trigger payload) as a foldable\n// tree, with a raw JSON view and, given a root, per-key {{references}}.\nimport {\n DOCUMENT_REF_KEY,\n documentRefsIn,\n isDocumentRefMarker,\n} from \"@powerhousedao/pieces-framework/workflow\";\nimport { lazy, Suspense, useState } from \"react\";\nimport { IconButton } from \"./controls.js\";\nimport { DocumentRefs } from \"./document-ref.js\";\n\nconst DataTree = lazy(() => import(\"./data-tree.js\"));\n\nfunction stringify(value: unknown): string {\n try {\n // undefined for functions and symbols, despite the typing.\n return (JSON.stringify(value, null, 2) as string | undefined) ?? \"\";\n } catch {\n return String(value as string);\n }\n}\n\nfunction isEmpty(value: unknown): boolean {\n if (value === undefined || value === null) return true;\n if (typeof value === \"object\") return Object.keys(value).length === 0;\n return false;\n}\n\nfunction RawJson(props: { text: string }) {\n return (\n <pre className=\"max-h-72 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-foreground\">\n {props.text}\n </pre>\n );\n}\n\n// Stands in while the tree's chunk loads.\nfunction TreeSkeleton() {\n return (\n <div\n role=\"status\"\n aria-label=\"Loading data\"\n className=\"flex animate-pulse flex-col gap-2 py-1\"\n >\n {[\"w-2/5\", \"w-3/5\", \"w-1/2\", \"w-1/3\"].map((width, index) => (\n <span\n key={width}\n className={`h-2.5 rounded bg-muted ${width}`}\n style={{ marginLeft: index === 0 ? 0 : 16 }}\n />\n ))}\n </div>\n );\n}\n\nexport function DataViewer(props: {\n label: string;\n value: unknown;\n // Expression prefix for this value, e.g. \"steps.fetch.output\".\n root?: string;\n emptyText?: string;\n}) {\n const [raw, setRaw] = useState(false);\n const [copied, setCopied] = useState(false);\n const empty = isEmpty(props.value);\n const text = stringify(props.value);\n const tree = typeof props.value === \"object\" && props.value !== null;\n const references = tree ? documentRefsIn(props.value) : [];\n // A whole value that is a reference shows as one; its other keys stay a tree.\n const treeValue = isDocumentRefMarker(props.value)\n ? Object.fromEntries(\n Object.entries(props.value).filter(([key]) => key !== DOCUMENT_REF_KEY),\n )\n : props.value;\n\n return (\n <section\n aria-label={props.label}\n className=\"min-w-0 rounded-md border border-solid border-border bg-card\"\n >\n <header className=\"flex h-8 items-center gap-1 border-b border-solid border-border pl-3 pr-1\">\n <h4 className=\"mr-auto text-xs font-medium text-foreground\">\n {props.label}\n </h4>\n {!empty && tree ? (\n <button\n type=\"button\"\n aria-pressed={raw}\n className=\"rounded px-1.5 py-0.5 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40\"\n onClick={() => setRaw((value) => !value)}\n >\n {raw ? \"Tree\" : \"JSON\"}\n </button>\n ) : null}\n {!empty ? (\n <IconButton\n icon={copied ? \"check\" : \"copy\"}\n label={`Copy ${props.label.toLowerCase()} as JSON`}\n onClick={() => {\n void navigator.clipboard.writeText(text).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1500);\n });\n }}\n />\n ) : null}\n </header>\n <div className=\"px-3 py-2\">\n {empty ? (\n <p className=\"text-xs text-muted-foreground\">\n {props.emptyText ?? \"Nothing\"}\n </p>\n ) : !tree ? (\n <p className=\"break-words font-mono text-xs text-foreground\">\n {text}\n </p>\n ) : raw ? (\n <RawJson text={text} />\n ) : (\n <div className=\"flex flex-col gap-2\">\n {references.length > 0 ? (\n <DocumentRefs references={references} />\n ) : null}\n {isEmpty(treeValue) ? null : (\n <div className=\"max-h-72 overflow-auto\">\n <Suspense fallback={<TreeSkeleton />}>\n <DataTree value={treeValue as object} root={props.root} />\n </Suspense>\n </div>\n )}\n </div>\n )}\n </div>\n </section>\n );\n}\n","// Plain-language descriptions of when a workflow starts: \"Every day at\n// 08:00 UTC\" rather than \"0 8 * * *\". Unknown shapes fall back to the raw text.\nimport { blockKey } from \"@powerhousedao/pieces-framework/block-type\";\nimport { blockMeta } from \"./block-meta.js\";\nimport {\n MANUAL_TRIGGER,\n REACTOR_PIECE,\n SCHEDULE_TRIGGER,\n WEBHOOK_TRIGGER,\n} from \"./blocks.js\";\nimport { parseScheduleConfig } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst WEEKDAYS = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\",\n];\n\nconst UNIT_LABEL: Record<string, [string, string]> = {\n minutes: [\"minute\", \"minutes\"],\n hours: [\"hour\", \"hours\"],\n days: [\"day\", \"days\"],\n};\n\nfunction isInt(field: string): boolean {\n return /^\\d+$/.test(field);\n}\n\nfunction clock(hour: string, minute: string): string {\n return `${hour.padStart(2, \"0\")}:${minute.padStart(2, \"0\")}`;\n}\n\nfunction dayList(field: string): string | undefined {\n if (field === \"1-5\") return \"on weekdays\";\n if (field === \"0,6\" || field === \"6,0\") return \"at weekends\";\n const days = field.split(\",\");\n if (!days.every((day) => isInt(day) && Number(day) <= 7)) return undefined;\n const names = days.map((day) => WEEKDAYS[Number(day) % 7]);\n if (names.length === 1) return `every ${names[0]}`;\n return `on ${names.slice(0, -1).join(\", \")} and ${names[names.length - 1]}`;\n}\n\n/** Describes a five-field cron expression, or returns undefined. */\nexport function describeCron(cron: string): string | undefined {\n const fields = cron.trim().split(/\\s+/);\n if (fields.length !== 5) return undefined;\n const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;\n if (month !== \"*\") return undefined;\n\n const everyMinutes = /^\\*\\/(\\d+)$/.exec(minute);\n if (everyMinutes && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\") {\n const n = Number(everyMinutes[1]);\n return n === 1 ? \"Every minute\" : `Every ${n} minutes`;\n }\n if (minute === \"*\" && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\")\n return \"Every minute\";\n if (isInt(minute) && hour === \"*\" && dayOfMonth === \"*\" && dayOfWeek === \"*\")\n return minute === \"0\"\n ? \"Every hour, on the hour\"\n : `Every hour at ${minute.padStart(2, \"0\")} past`;\n\n const everyHours = /^\\*\\/(\\d+)$/.exec(hour);\n if (isInt(minute) && everyHours && dayOfMonth === \"*\" && dayOfWeek === \"*\") {\n return `Every ${everyHours[1]} hours`;\n }\n if (!isInt(minute) || !isInt(hour)) return undefined;\n const at = clock(hour, minute);\n\n if (dayOfMonth === \"*\" && dayOfWeek === \"*\") return `Every day at ${at}`;\n if (dayOfMonth === \"*\") {\n const days = dayList(dayOfWeek);\n return days\n ? `${days.charAt(0).toUpperCase()}${days.slice(1)} at ${at}`\n : undefined;\n }\n if (isInt(dayOfMonth) && dayOfWeek === \"*\") {\n return `Every month on day ${dayOfMonth} at ${at}`;\n }\n return undefined;\n}\n\nexport function describeSchedule(config: unknown): string {\n let schedule;\n try {\n schedule = parseScheduleConfig(config);\n } catch {\n return \"On a schedule that does not parse\";\n }\n if (schedule.mode === \"interval\") {\n const unit = UNIT_LABEL[schedule.unit];\n return schedule.every === 1\n ? `Every ${unit[0]}`\n : `Every ${schedule.every} ${unit[1]}`;\n }\n const described = describeCron(schedule.cron);\n return described\n ? `${described} ${schedule.timezone}`\n : `On schedule ${schedule.cron}`;\n}\n\n// A literal config value; an expression or a blank says nothing to show.\nfunction literal(config: unknown, key: string): string | undefined {\n if (!config || typeof config !== \"object\") return undefined;\n const value = (config as Record<string, unknown>)[key];\n if (typeof value !== \"string\") return undefined;\n const text = value.trim();\n return text && !text.includes(\"{{\") ? text : undefined;\n}\n\n// \"umh/production-ledger\" reads as \"Production Ledger\".\nfunction documentTypeLabel(documentType: string): string {\n const name = documentType.split(\"/\").pop() ?? documentType;\n return name\n .split(/[-_\\s]+/)\n .filter(Boolean)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(\" \");\n}\n\n// \"APPROVE_ORDER\" reads as \"Approve order\".\nfunction actionTypeLabel(actionType: string): string {\n const words = actionType\n .toLowerCase()\n .split(/[_\\s]+/)\n .filter(Boolean);\n const text = words.join(\" \");\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n/** Describes a reactor document trigger by what it filters on. */\nexport function describeDocumentTrigger(\n triggerName: string,\n config: unknown,\n): string | undefined {\n const documentType = literal(config, \"documentType\");\n const label = documentType ? documentTypeLabel(documentType) : \"\";\n const subject = label\n ? `${/^[AEIOU]/.test(label) ? \"an\" : \"a\"} ${label}`\n : literal(config, \"documentId\")\n ? \"its document\"\n : \"a document\";\n switch (triggerName) {\n case \"document-event\": {\n const actionType = literal(config, \"actionType\");\n return actionType\n ? `When ${actionTypeLabel(actionType)} runs on ${subject}`\n : `When ${subject} changes`;\n }\n case \"document-created\":\n return `When ${subject} is created`;\n case \"document-deleted\":\n return `When ${subject} is deleted`;\n default:\n return undefined;\n }\n}\n\n/** When a workflow starts, from its trigger. */\nexport function describeTrigger(\n trigger:\n | { pieceName: string; triggerName: string; config: unknown }\n | null\n | undefined,\n): string {\n if (!trigger) return \"Never starts: no trigger\";\n const block = {\n pieceName: trigger.pieceName,\n kind: \"trigger\" as const,\n name: trigger.triggerName,\n };\n switch (blockKey(block)) {\n case blockKey(MANUAL_TRIGGER):\n return \"Manual\";\n case blockKey(WEBHOOK_TRIGGER):\n return \"When its webhook is called\";\n case blockKey(SCHEDULE_TRIGGER):\n return describeSchedule(trigger.config);\n default: {\n if (trigger.pieceName === REACTOR_PIECE) {\n const described = describeDocumentTrigger(\n trigger.triggerName,\n trigger.config,\n );\n if (described) return described;\n }\n const meta = blockMeta(block);\n const piece = meta.subtitle.replace(/ · Trigger$/, \"\");\n return `${meta.displayName} in ${piece}`;\n }\n }\n}\n"],"mappings":";;;;;;;AAiIA,MAAa,iBAAiB;;AAG9B,MAAa,aAAa;AAI1B,SAAgB,gBACd,OACS;CACT,OAAO,CAAC,MAAM,aAAa,MAAM,UAAU,YAAY,MAAM;AAC/D;AAgHA,SAAgB,cAAc,OAAiB,OAAuB;CACpE,MAAM,OACJ,MACG,YAAY,CAAC,CACb,WAAW,eAAe,GAAG,CAAC,CAC9B,WAAW,YAAY,EAAE,KAA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GA,SAAgB,gBACd,SAIQ;CACR,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,QAAQ;EACZ,WAAW,QAAQ;EACnB,MAAM;EACN,MAAM,QAAQ;CAChB;CACA,QAAQ,SAAS,KAAK,GAAtB;EACE,KAAK,SAAS,cAAc,GAC1B,OAAO;EACT,KAAK,SAAS,eAAe,GAC3B,OAAO;EACT,KAAK,SAAS,gBAAgB,GAC5B,OAAO,iBAAiB,QAAQ,MAAM;EACxC,SAAS;GACP,IAAI,QAAQ,cAAA,gCAA6B;IACvC,MAAM,YAAY,wBAChB,QAAQ,aACR,QAAQ,MACV;IACA,IAAI,WAAW,OAAO;GACxB;GACA,MAAM,OAAO,UAAU,KAAK;GAC5B,MAAM,QAAQ,KAAK,SAAS,QAAQ,eAAe,EAAE;GACrD,OAAO,GAAG,KAAK,YAAY,MAAM;EACnC;CACF;AACF"}
@@ -45,7 +45,7 @@
45
45
  {
46
46
  "id": "@powerhousedao/piece-reactor",
47
47
  "name": "Powerhouse Reactor",
48
- "version": "6.2.3-dev.70",
48
+ "version": "6.2.3-dev.72",
49
49
  "description": "Read and write Powerhouse documents on the reactor this workflow runs in: create documents, dispatch actions, read state and schemas, and fire on document events.",
50
50
  "bundle": "dist/node/pieces/reactor",
51
51
  "descriptor": "dist/node/pieces/reactor/descriptor.json"
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-url.d.ts","sourceRoot":"","sources":["../../../ai/runtime-url.ts"],"names":[],"mappings":"AASA,wBAAgB,cAAc,IAAI,IAAI,CAUrC"}
1
+ {"version":3,"file":"runtime-url.d.ts","sourceRoot":"","sources":["../../../ai/runtime-url.ts"],"names":[],"mappings":"AAWA,wBAAgB,cAAc,IAAI,IAAI,CAqBrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/workflow",
3
- "version": "6.2.3-dev.70",
3
+ "version": "6.2.3-dev.72",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -70,15 +70,15 @@
70
70
  "./package.json": "./package.json"
71
71
  },
72
72
  "dependencies": {
73
- "@powerhousedao/design-system": "6.2.3-dev.70",
74
- "@powerhousedao/pieces-framework": "6.2.3-dev.70",
75
- "@powerhousedao/reactor": "6.2.3-dev.70",
76
- "@powerhousedao/reactor-browser": "6.2.3-dev.70",
77
- "@powerhousedao/shared": "6.2.3-dev.70",
73
+ "@powerhousedao/design-system": "6.2.3-dev.72",
74
+ "@powerhousedao/pieces-framework": "6.2.3-dev.72",
75
+ "@powerhousedao/reactor": "6.2.3-dev.72",
76
+ "@powerhousedao/reactor-browser": "6.2.3-dev.72",
77
+ "@powerhousedao/shared": "6.2.3-dev.72",
78
78
  "@tanstack/react-query": "^5.49.2",
79
79
  "@uiw/react-json-view": "2.0.0-alpha.42",
80
80
  "@xyflow/react": "12.11.6",
81
- "document-model": "6.2.3-dev.70",
81
+ "document-model": "6.2.3-dev.72",
82
82
  "graphql": "^16",
83
83
  "react": "19.2.6",
84
84
  "react-dom": "19.2.6",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "devDependencies": {
90
90
  "@playwright/test": "^1.60.0",
91
- "@powerhousedao/powerhouse-vetra-packages": "6.2.3-dev.70",
91
+ "@powerhousedao/powerhouse-vetra-packages": "6.2.3-dev.72",
92
92
  "@tailwindcss/cli": "4.2.2",
93
93
  "@testing-library/react": "^16.0.1",
94
94
  "@types/node": "25.2.3",