@powerhousedao/workflow 6.2.3-dev.80 → 6.2.3-dev.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{BlockSelector-DFX-DZHl.js → BlockSelector-DHVzUGjW.js} +3 -3
- package/dist/browser/BlockSelector-DHVzUGjW.js.map +1 -0
- package/dist/browser/{connection-Ci_pI3kD.js → connection-PaKXHYz9.js} +2 -2
- package/dist/browser/{connection-Ci_pI3kD.js.map → connection-PaKXHYz9.js.map} +1 -1
- package/dist/browser/{connection-form-BuW6qOAF.js → connection-form-D2qAEHsl.js} +33 -13
- package/dist/browser/connection-form-D2qAEHsl.js.map +1 -0
- package/dist/browser/{data-tree-BLn565V5.js → data-tree-BOuPR-2J.js} +2 -2
- package/dist/browser/{data-tree-BLn565V5.js.map → data-tree-BOuPR-2J.js.map} +1 -1
- package/dist/browser/document-models/connection/index.js +2 -2
- package/dist/browser/document-models/index.js +3 -3
- package/dist/browser/document-models/workflow/index.js +2 -2
- package/dist/browser/{document-models-DUSvG-I2.js → document-models-DSK5cn8B.js} +6 -3
- package/dist/browser/{document-models-DUSvG-I2.js.map → document-models-DSK5cn8B.js.map} +1 -1
- package/dist/browser/{editor-NLSJ5rWx.js → editor--59WtNaj.js} +265 -84
- package/dist/browser/editor--59WtNaj.js.map +1 -0
- package/dist/browser/{editor-BhHN0OWh.js → editor-0XPrGeLT.js} +8 -8
- package/dist/browser/{editor-BhHN0OWh.js.map → editor-0XPrGeLT.js.map} +1 -1
- package/dist/browser/{editor-CnW8q20z.js → editor-BD-5ClkW.js} +6 -6
- package/dist/browser/{editor-CnW8q20z.js.map → editor-BD-5ClkW.js.map} +1 -1
- package/dist/browser/editors/connection-editor/module.js +1 -1
- package/dist/browser/editors/runtime/index.js +1 -1
- package/dist/browser/editors/workflow-editor/module.js +1 -1
- package/dist/browser/editors/workflow-studio/module.js +1 -1
- package/dist/browser/index.js +5 -5
- package/dist/browser/{module-FuSfFXPT.js → module-DJz6oTX0.js} +56 -56
- package/dist/browser/module-DJz6oTX0.js.map +1 -0
- package/dist/browser/{module-DxRdnkW2.js → module-eOpxJVIl.js} +2 -2
- package/dist/browser/{module-DxRdnkW2.js.map → module-eOpxJVIl.js.map} +1 -1
- package/dist/{node/piece-auth-BS5CtQOG.mjs → browser/piece-auth-63iuNFTs.js} +11 -3
- package/dist/browser/piece-auth-63iuNFTs.js.map +1 -0
- package/dist/browser/reactor/index.js +2 -2
- package/dist/browser/{runtime-queries-C9SoXGm2.js → runtime-queries-LAcyniYz.js} +18 -7
- package/dist/browser/runtime-queries-LAcyniYz.js.map +1 -0
- package/dist/browser/{trigger-text-BIeZ9W1H.js → trigger-text-Co-dn9x-.js} +4 -4
- package/dist/browser/trigger-text-Co-dn9x-.js.map +1 -0
- package/dist/browser/upgrade-manifests-CLYUPqBs.js +8 -0
- package/dist/browser/{upgrade-manifests-bahiFXsr.js.map → upgrade-manifests-CLYUPqBs.js.map} +1 -1
- package/dist/browser/{workflow-DZt1eS1f.js → workflow-Cn1UP-eJ.js} +2 -2
- package/dist/browser/{workflow-DZt1eS1f.js.map → workflow-Cn1UP-eJ.js.map} +1 -1
- package/dist/node/{BlockSelector-DosVPXzD.mjs → BlockSelector-D2UAnFpN.mjs} +3 -3
- package/dist/node/{BlockSelector-DosVPXzD.mjs.map → BlockSelector-D2UAnFpN.mjs.map} +1 -1
- package/dist/node/{connection-i6ISRY0F.mjs → connection-BZxipUlb.mjs} +2 -2
- package/dist/node/{connection-i6ISRY0F.mjs.map → connection-BZxipUlb.mjs.map} +1 -1
- package/dist/node/{connection-form-Z-pLxxrT.mjs → connection-form-Btmejfyn.mjs} +33 -13
- package/dist/node/connection-form-Btmejfyn.mjs.map +1 -0
- package/dist/node/{data-tree-CqBvXMpm.mjs → data-tree-rZiK2Ev-.mjs} +2 -2
- package/dist/node/{data-tree-CqBvXMpm.mjs.map → data-tree-rZiK2Ev-.mjs.map} +1 -1
- package/dist/node/document-models/connection/index.mjs +2 -2
- package/dist/node/document-models/index.mjs +2 -2
- package/dist/node/{editor-D9S3pWvR.mjs → editor-C_eWGGi8.mjs} +5 -5
- package/dist/node/{editor-D9S3pWvR.mjs.map → editor-C_eWGGi8.mjs.map} +1 -1
- package/dist/node/{editor-D4-ZHfHJ.mjs → editor-ChJMxbeM.mjs} +7 -7
- package/dist/node/{editor-D4-ZHfHJ.mjs.map → editor-ChJMxbeM.mjs.map} +1 -1
- package/dist/node/{editor-C3OhQ_xs.mjs → editor-U6trS0QO.mjs} +263 -82
- package/dist/node/editor-U6trS0QO.mjs.map +1 -0
- package/dist/node/editors/connection-editor/module.mjs +1 -1
- package/dist/node/editors/runtime/index.mjs +1 -1
- package/dist/node/editors/workflow-editor/module.mjs +1 -1
- package/dist/node/editors/workflow-studio/module.mjs +1 -1
- package/dist/node/index.mjs +7 -4
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{module-weVJEMpP.mjs → module-BEEASith.mjs} +56 -56
- package/dist/node/module-BEEASith.mjs.map +1 -0
- package/dist/{browser/piece-auth-BS5CtQOG.js → node/piece-auth-C0u0XTO8.mjs} +11 -3
- package/dist/node/piece-auth-C0u0XTO8.mjs.map +1 -0
- package/dist/node/pieces/ai/descriptor.json +788 -0
- package/dist/node/pieces/ai/index.mjs +401 -0
- package/dist/node/pieces/ai/package.json +9 -0
- package/dist/node/pieces/index.mjs +3 -0
- package/dist/node/pieces/index.mjs.map +1 -1
- package/dist/node/pieces/reactor/descriptor.json +1 -1
- package/dist/node/pieces/reactor/index.mjs +39 -250
- package/dist/node/pieces/reactor/package.json +1 -1
- package/dist/node/{runtime-queries-CJSpbsBq.mjs → runtime-queries-CmrHBPRw.mjs} +18 -7
- package/dist/node/runtime-queries-CmrHBPRw.mjs.map +1 -0
- package/dist/node/{trigger-text-CmYejeFN.mjs → trigger-text-CAiRCG2X.mjs} +4 -4
- package/dist/node/trigger-text-CAiRCG2X.mjs.map +1 -0
- package/dist/node/{upgrade-manifests-VF8Jt_YR.mjs → upgrade-manifests-C4akaA_X.mjs} +2 -2
- package/dist/node/{upgrade-manifests-VF8Jt_YR.mjs.map → upgrade-manifests-C4akaA_X.mjs.map} +1 -1
- package/dist/powerhouse.manifest.json +9 -1
- package/dist/style.css +1 -1
- package/dist/types/editors/connection-editor/connection-form.d.ts.map +1 -1
- package/dist/types/editors/connection-editor/piece-auth.d.ts +6 -1
- package/dist/types/editors/connection-editor/piece-auth.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/document/useWorkflowModel.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/editor.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts +3 -1
- package/dist/types/editors/workflow-editor/runtime-client.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts +1 -1
- package/dist/types/editors/workflow-editor/runtime-context.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/PanelResizer.d.ts +12 -0
- package/dist/types/editors/workflow-editor/ui/PanelResizer.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts +1 -0
- package/dist/types/editors/workflow-editor/ui/PropertyForm.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/StepPanel.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/WorkflowEditorApp.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/forms.d.ts +5 -0
- package/dist/types/editors/workflow-editor/ui/forms.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/item-summary.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/item-summary.test.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/model.d.ts +1 -0
- package/dist/types/editors/workflow-editor/ui/model.d.ts.map +1 -1
- package/dist/types/editors/workflow-editor/ui/retry-policy.d.ts +8 -0
- package/dist/types/editors/workflow-editor/ui/retry-policy.d.ts.map +1 -0
- package/dist/types/editors/workflow-editor/ui/retry-policy.test.d.ts +2 -0
- package/dist/types/editors/workflow-editor/ui/retry-policy.test.d.ts.map +1 -0
- package/dist/types/pieces/ai/ai-actions.test.d.ts +2 -0
- package/dist/types/pieces/ai/ai-actions.test.d.ts.map +1 -0
- package/dist/types/pieces/ai/ai-documents.test.d.ts +2 -0
- package/dist/types/pieces/ai/ai-documents.test.d.ts.map +1 -0
- package/dist/types/pieces/ai/ai.test.d.ts +2 -0
- package/dist/types/pieces/ai/ai.test.d.ts.map +1 -0
- package/dist/types/pieces/ai/index.d.ts +7 -0
- package/dist/types/pieces/ai/index.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/action-schema.d.ts +11 -0
- package/dist/types/pieces/ai/lib/action-schema.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/actions/ask-ai.d.ts +38 -0
- package/dist/types/pieces/ai/lib/actions/ask-ai.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts +45 -0
- package/dist/types/pieces/ai/lib/actions/decide-on-documents.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/actions/decide.d.ts +39 -0
- package/dist/types/pieces/ai/lib/actions/decide.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/actions/extract.d.ts +41 -0
- package/dist/types/pieces/ai/lib/actions/extract.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts +55 -0
- package/dist/types/pieces/ai/lib/actions/propose-actions.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/actions/summarize.d.ts +38 -0
- package/dist/types/pieces/ai/lib/actions/summarize.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/auth.d.ts +16 -0
- package/dist/types/pieces/ai/lib/auth.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/decision-model.d.ts +17 -0
- package/dist/types/pieces/ai/lib/decision-model.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/documents.d.ts +11 -0
- package/dist/types/pieces/ai/lib/documents.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/model-list.d.ts +8 -0
- package/dist/types/pieces/ai/lib/model-list.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/models.d.ts +19 -0
- package/dist/types/pieces/ai/lib/models.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/props.d.ts +16 -0
- package/dist/types/pieces/ai/lib/props.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/providers.d.ts +9 -0
- package/dist/types/pieces/ai/lib/providers.d.ts.map +1 -0
- package/dist/types/pieces/ai/lib/questions.d.ts +7 -0
- package/dist/types/pieces/ai/lib/questions.d.ts.map +1 -0
- package/dist/types/pieces/index.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-create.d.ts +4 -2
- package/dist/types/pieces/reactor/lib/actions/document-create.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts +4 -2
- package/dist/types/pieces/reactor/lib/actions/document-dispatch.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-find.d.ts +4 -2
- package/dist/types/pieces/reactor/lib/actions/document-find.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-get.d.ts +4 -2
- package/dist/types/pieces/reactor/lib/actions/document-get.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-schema.d.ts +4 -2
- package/dist/types/pieces/reactor/lib/actions/document-schema.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/document-types.d.ts +3 -1
- package/dist/types/pieces/reactor/lib/actions/document-types.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/actions/index-query.d.ts +4 -2
- package/dist/types/pieces/reactor/lib/actions/index-query.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/input-schema.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/reactor.d.ts +12 -0
- package/dist/types/pieces/reactor/lib/reactor.d.ts.map +1 -1
- package/dist/types/pieces/reactor/lib/writes.d.ts +7 -0
- package/dist/types/pieces/reactor/lib/writes.d.ts.map +1 -0
- package/dist/types/scripts/ui-stack.d.ts +8 -2
- package/dist/types/scripts/ui-stack.d.ts.map +1 -1
- package/package.json +15 -8
- package/dist/browser/BlockSelector-DFX-DZHl.js.map +0 -1
- package/dist/browser/connection-form-BuW6qOAF.js.map +0 -1
- package/dist/browser/editor-NLSJ5rWx.js.map +0 -1
- package/dist/browser/module-FuSfFXPT.js.map +0 -1
- package/dist/browser/piece-auth-BS5CtQOG.js.map +0 -1
- package/dist/browser/runtime-queries-C9SoXGm2.js.map +0 -1
- package/dist/browser/trigger-text-BIeZ9W1H.js.map +0 -1
- package/dist/browser/upgrade-manifests-bahiFXsr.js +0 -8
- package/dist/node/connection-form-Z-pLxxrT.mjs.map +0 -1
- package/dist/node/editor-C3OhQ_xs.mjs.map +0 -1
- package/dist/node/module-weVJEMpP.mjs.map +0 -1
- package/dist/node/piece-auth-BS5CtQOG.mjs.map +0 -1
- package/dist/node/runtime-queries-CJSpbsBq.mjs.map +0 -1
- package/dist/node/trigger-text-CmYejeFN.mjs.map +0 -1
|
@@ -2,7 +2,7 @@ import { lazy } from "react";
|
|
|
2
2
|
//#region editors/connection-editor/module.ts
|
|
3
3
|
/** Document editor module for the "powerhouse/connection" document type */
|
|
4
4
|
const ConnectionEditor = {
|
|
5
|
-
Component: lazy(() => import("../../editor-
|
|
5
|
+
Component: lazy(() => import("../../editor-ChJMxbeM.mjs")),
|
|
6
6
|
documentTypes: ["powerhouse/connection"],
|
|
7
7
|
config: {
|
|
8
8
|
id: "connection-editor",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { G as fetchRuns, H as RuntimeRequestError, K as fetchRunsPage, U as createRuntimeClient, W as fetchRun, c as runQuery, l as runsOfPages, q as isSyncingError, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery } from "../../runtime-queries-
|
|
1
|
+
import { G as fetchRuns, H as RuntimeRequestError, K as fetchRunsPage, U as createRuntimeClient, W as fetchRun, c as runQuery, l as runsOfPages, q as isSyncingError, r as createRuntimeQueryClient, s as runPagesQuery, u as runsQuery } from "../../runtime-queries-CmrHBPRw.mjs";
|
|
2
2
|
export { RuntimeRequestError, createRuntimeClient, createRuntimeQueryClient, fetchRun, fetchRuns, fetchRunsPage, isSyncingError, runPagesQuery, runQuery, runsOfPages, runsQuery };
|
|
@@ -2,7 +2,7 @@ import { lazy } from "react";
|
|
|
2
2
|
//#region editors/workflow-editor/module.ts
|
|
3
3
|
/** Document editor module for the "powerhouse/workflow" document type */
|
|
4
4
|
const WorkflowEditor = {
|
|
5
|
-
Component: lazy(() => import("../../editor-
|
|
5
|
+
Component: lazy(() => import("../../editor-U6trS0QO.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-
|
|
5
|
+
Component: lazy(() => import("../../editor-C_eWGGi8.mjs")),
|
|
6
6
|
documentTypes: ["powerhouse/document-drive"],
|
|
7
7
|
config: {
|
|
8
8
|
id: "workflow-studio",
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { h as REACTOR_CONNECTOR_ID, t as Connection } from "./module-BEEASith.mjs";
|
|
2
|
+
import { i as connectorIdForPiece, l as planFromAuth, o as isConfigValueMissing, s as packageFromConnectorId } from "./piece-auth-C0u0XTO8.mjs";
|
|
3
|
+
import { Q as REACTOR_PIECE, U as createRuntimeClient, V as DEFAULT_RUNTIME_URL, X as CORE_PIECE, gt as flowPorts, n as catalogQuery, r as createRuntimeQueryClient, t as blockFormQuery } from "./runtime-queries-CmrHBPRw.mjs";
|
|
4
4
|
import { t as Workflow } from "./module-D9Zx5Zow.mjs";
|
|
5
|
-
import { t as upgradeManifests } from "./upgrade-manifests-
|
|
5
|
+
import { t as upgradeManifests } from "./upgrade-manifests-C4akaA_X.mjs";
|
|
6
6
|
import { ConnectionEditor } from "./editors/connection-editor/module.mjs";
|
|
7
7
|
import { WorkflowEditor } from "./editors/workflow-editor/module.mjs";
|
|
8
8
|
import { WorkflowStudio } from "./editors/workflow-studio/module.mjs";
|
|
@@ -40,6 +40,9 @@ var powerhouse_manifest_default = {
|
|
|
40
40
|
"documentTypes": ["powerhouse/connection"]
|
|
41
41
|
}],
|
|
42
42
|
pieces: [{
|
|
43
|
+
"id": "@powerhousedao/piece-ai",
|
|
44
|
+
"name": "AI"
|
|
45
|
+
}, {
|
|
43
46
|
"id": "@powerhousedao/piece-reactor",
|
|
44
47
|
"name": "Powerhouse Reactor"
|
|
45
48
|
}],
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["READ_ONLY","runConnectionCheck","ConnectionV1","WorkflowV1","manifestJson"],"sources":["../../powerhouse.manifest.json","../../editors/workflow-editor/runtime-api.ts","../../ai/runtime-url.ts","../../ai/workflow-tools.ts","../../ai/tools.ts","../../document-models/document-models.ts","../../editors/editors.ts","../../index.ts"],"sourcesContent":["","// Ambient runtime client for the AI tools, which run outside any editor.\n// Editors never import this: each one gets its own client from RuntimeProvider.\nimport type { BlockRef } from \"@powerhousedao/pieces-framework/block-type\";\nimport {\n createRuntimeClient,\n DEFAULT_RUNTIME_URL,\n type RunsScope,\n type RuntimeClient,\n} from \"./runtime-client.js\";\nimport {\n blockFormQuery,\n catalogQuery,\n createRuntimeQueryClient,\n} from \"./runtime-queries.js\";\n\nexport type * from \"./runtime-client.js\";\nexport { DEFAULT_RUNTIME_URL };\n\nlet ambient: RuntimeClient = createRuntimeClient(DEFAULT_RUNTIME_URL);\n// Keys start with the URL, so switching runtimes needs no cache reset.\nconst ambientQueries = createRuntimeQueryClient();\n\nexport function setRuntimeUrl(url: string): void {\n if (url !== ambient.url) ambient = createRuntimeClient(url);\n}\n\nexport const getBlockForm = (block: BlockRef) =>\n ambientQueries.fetchQuery(blockFormQuery(ambient, block));\nexport const fetchPieceCatalog = () =>\n ambientQueries.fetchQuery(catalogQuery(ambient));\nexport const fetchPieceActions = (packageName: string) =>\n ambient.fetchPieceActions(packageName);\nexport const fetchPieceTriggers = (packageName: string) =>\n ambient.fetchPieceTriggers(packageName);\nexport const searchPieces = (\n query: string,\n filter: Parameters<RuntimeClient[\"searchPieces\"]>[1],\n) => ambient.searchPieces(query, filter);\nexport const fetchConnections = () => ambient.fetchConnections();\nexport const checkConnection = (connectionId: string) =>\n ambient.checkConnection(connectionId);\nexport const fetchRuns = (scope?: RunsScope) => ambient.fetchRuns(scope);\nexport const fireWorkflow = (workflowId: string, payload?: unknown) =>\n ambient.fireWorkflow(workflowId, payload);\n","// Points the module-level runtime client at the selected drive's\n// workflow-runtime subgraph before an AI tool talks to it.\nimport { getPHStore } from \"@powerhousedao/reactor-browser\";\nimport { resolveDriveSwitchboard } from \"@powerhousedao/reactor-browser/ai\";\nimport {\n DEFAULT_RUNTIME_URL,\n setRuntimeUrl,\n} from \"../editors/workflow-editor/runtime-api.js\";\n\nconst warnedDrives = new Set<string>();\n\nexport function syncRuntimeUrl(): void {\n if (typeof window === \"undefined\") return;\n const driveId = getPHStore()?.selectedDriveId;\n const switchboard = resolveDriveSwitchboard(driveId);\n // No resolvable switchboard (no selection, or a local/unsynced drive):\n // reset to the default rather than leaving a prior drive's URL attached.\n if (!switchboard && driveId && !warnedDrives.has(driveId)) {\n // A Workflows drive has to be attached as a REMOTE of the switchboard\n // that runs the workflow runtime; a local copy renders the studio against\n // whatever answers at the default URL.\n warnedDrives.add(driveId);\n console.warn(\n `[workflow] Drive \"${driveId}\" is not synced from a switchboard, so Workflow Studio falls back to ${DEFAULT_RUNTIME_URL}. ` +\n \"Attach the switchboard's Workflows drive (its /d/<slug> URL) instead of a local drive.\",\n );\n }\n setRuntimeUrl(\n switchboard\n ? `${switchboard.graphqlUrl}/workflow-runtime`\n : DEFAULT_RUNTIME_URL,\n );\n}\n","// AI tool descriptors for authoring and running workflows: the pinned blocks\n// a piece offers, a block's config props, the built-in core blocks with\n// the expression syntax, run history and manual firing. Complements the\n// connector/connection tools in tools.ts, which cover the catalog and auth.\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n fetchPieceActions,\n fetchPieceTriggers,\n fetchRuns,\n fireWorkflow,\n getBlockForm,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport type { BlockFormProp } from \"../editors/workflow-editor/ui/forms.js\";\nimport { REACTOR_CONNECTOR_ID } from \"../document-models/connection/v1/src/reactor-connection.js\";\nimport {\n CORE_PIECE,\n REACTOR_PIECE,\n type BlockRef,\n} from \"../editors/workflow-editor/ui/blocks.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { flowPorts } from \"@powerhousedao/pieces-framework/workflow\";\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nfunction kindOf(block: BlockRef): \"trigger\" | \"step\" {\n return block.kind === \"trigger\" ? \"trigger\" : \"step\";\n}\n\n// The fields ADD_STEP or SET_TRIGGER takes for the block.\nfunction blockFields(block: BlockRef) {\n return {\n pieceName: block.pieceName,\n pieceVersion: block.pieceVersion,\n ...(block.kind === \"trigger\"\n ? { triggerName: block.name }\n : { actionName: block.name }),\n };\n}\n\n// The onward ports the block's descriptor declares; \"error\" is a failure route.\nfunction portsFor(form: { ports?: readonly string[] }): string[] {\n return flowPorts(form.ports ?? []);\n}\n\nfunction describeProp(prop: BlockFormProp) {\n return {\n name: prop.name,\n label: prop.displayName,\n type: prop.type,\n required: prop.required,\n ...(prop.description ? { description: prop.description } : {}),\n ...(prop.defaultValue !== undefined ? { default: prop.defaultValue } : {}),\n ...(prop.staticOptions\n ? { options: prop.staticOptions.map((option) => option.value) }\n : {}),\n ...(prop.hasDynamicResolver ? { dynamicOptions: true } : {}),\n };\n}\n\nconst EXPRESSIONS = [\n \"Step configs and edge conditions may contain expressions in double braces.\",\n \"{{trigger.payload.<field>}} reads the trigger payload: for the core manual trigger the payload passed to fireWorkflow; for the reactor piece's document triggers it carries documentId, documentType, driveId and name.\",\n \"{{steps.<key>.output.<path>}} reads an upstream step's output by that step's key, e.g. {{steps.fetch.output.body.title}}.\",\n \"The reactor piece's document-create and document-dispatch output a reference { documentId, documentType, branch, revision }, e.g. {{steps.create.output.documentId}}; read the document with document-get to use its state. document-get outputs the document as { header, state }, e.g. {{steps.get.output.state.global.name}} or {{steps.get.output.header.id}}. document-find outputs { results, nextCursor }: each result has a header (and state with includeState), and nextCursor, present while more match, goes in a later find's cursor.\",\n \"{{variables.<key>}} reads a workflow variable.\",\n \"'a' || 'b' picks the first non-empty value, e.g. {{trigger.payload.url || 'https://example.com'}}.\",\n \"A whole-string expression yields the raw value; text around expressions is interpolated.\",\n];\n\nconst GRAPH_RULES = [\n \"A workflow is a powerhouse/workflow document. Build it with SET_TRIGGER once, ADD_STEP per step (each with a unique id and key), and ADD_EDGE from the trigger id to the first step and between steps.\",\n \"An edge must leave on a port its source declares (getWorkflowBlockConfig lists them): 'next' for the trigger and ordinary steps, 'true' and 'false' for the core branch action, 'error' to route a failure. An edge on any other port is never taken, and the run is flagged with a warning.\",\n \"A step names its block with pieceName, pieceVersion and actionName; the trigger with pieceName, pieceVersion and triggerName. pieceVersion is an exact semver: copy the fields getWorkflowPieceBlocks or listWorkflowCoreBlocks return.\",\n `The built-in blocks (manual, schedule and webhook triggers, branch and assert) belong to the piece ${CORE_PIECE}.`,\n \"Steps whose piece needs a connection must set connectionId to a powerhouse/connection document id (see getConnections).\",\n `Every step and trigger whose block reports requireReactor (getWorkflowBlockConfig) must set reactorConnectionId to a powerhouse/connection document with authType REACTOR and connectorId ${REACTOR_CONNECTOR_ID} (see getConnections); the ${REACTOR_PIECE} blocks all do. Without one the block gets no reactor access and fails. The connection's config { endpoint: \"local\", access?: \"read\", filter?: { documentType?, documentId?, driveId?, actionType? } } limits which documents it reads and writes. connectionId stays for credentials; a document block normally needs none.`,\n \"Runs execute the published snapshot, not the draft. PUBLISH_WORKFLOW only snapshots the draft, so publish again after every edit that should run.\",\n \"Only ENABLED workflows get trigger instances and can be fired. PUBLISH_WORKFLOW does not enable: to turn a workflow on, dispatch SET_WORKFLOW_STATUS ENABLED after PUBLISH_WORKFLOW (the same batch works). SET_WORKFLOW_STATUS ENABLED is refused until the workflow has been published once.\",\n];\n\nexport const getWorkflowPieceBlocksTool: PhAiToolDescriptor = {\n name: \"getWorkflowPieceBlocks\",\n description:\n \"Lists the actions and triggers of one piece, each with the pieceName, pieceVersion and actionName or triggerName to use in ADD_STEP or SET_TRIGGER. Takes the piece package name from getConnectors. Call getWorkflowBlockConfig next for a block's config props.\",\n inputSchema: {\n packageName: z\n .string()\n .describe(\"Piece package name, e.g. @activepieces/piece-http.\"),\n },\n annotations: { title: \"Get Workflow Piece Blocks\", ...READ_ONLY },\n callback: async (args: { packageName: string }) => {\n syncRuntimeUrl();\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(args.packageName),\n fetchPieceTriggers(args.packageName),\n ]);\n return {\n packageName: args.packageName,\n actions: actions.map((action) => ({\n pieceName: action.pieceName,\n pieceVersion: action.pieceVersion,\n actionName: action.name,\n displayName: action.displayName,\n description: action.description,\n })),\n triggers: triggers.map((trigger) => ({\n pieceName: trigger.pieceName,\n pieceVersion: trigger.pieceVersion,\n triggerName: trigger.name,\n displayName: trigger.displayName,\n description: trigger.description,\n strategy: trigger.strategy,\n })),\n };\n },\n};\n\nexport const getWorkflowBlockConfigTool: PhAiToolDescriptor = {\n name: \"getWorkflowBlockConfig\",\n description:\n \"Describes the config of one block (a core block or a piece's action or trigger): prop names, types, whether required, allowed options, the output ports, whether a connection is needed, and requireReactor (read | write) when it needs a reactor connection. Use it before writing a step or trigger config.\",\n inputSchema: {\n pieceName: z\n .string()\n .describe(\n `Piece package name, e.g. ${CORE_PIECE} or @activepieces/piece-http.`,\n ),\n pieceVersion: z.string().describe(\"Exact semver of the piece.\"),\n name: z\n .string()\n .describe(\"Action or trigger name, e.g. branch or send_request.\"),\n kind: z.enum([\"action\", \"trigger\"]).describe(\"action or trigger.\"),\n },\n annotations: { title: \"Get Workflow Block Config\", ...READ_ONLY },\n callback: async (args: BlockRef) => {\n const block: BlockRef = {\n pieceName: args.pieceName,\n pieceVersion: args.pieceVersion,\n name: args.name,\n kind: args.kind,\n };\n syncRuntimeUrl();\n const form = await getBlockForm(block);\n if (!form) {\n return {\n ...blockFields(block),\n error:\n \"Unknown block. Use getConnectors and getWorkflowPieceBlocks to find valid blocks (documents live in @powerhousedao/piece-reactor), or listWorkflowCoreBlocks for built-ins.\",\n };\n }\n return {\n ...blockFields(block),\n title: form.title,\n kind: kindOf(block),\n requiresConnection: form.auth === \"required\",\n // read | write: the block needs a reactorConnectionId granting this.\n requireReactor: form.requireReactor ?? null,\n props: form.props.map(describeProp),\n ports: portsFor(form),\n };\n },\n};\n\nexport const listWorkflowCoreBlocksTool: PhAiToolDescriptor = {\n name: \"listWorkflowCoreBlocks\",\n description: `Lists the built-in blocks of the ${CORE_PIECE} piece (manual, schedule and webhook triggers, branch and assert) with their pinned fields and config props, plus the expression syntax and the rules for building a powerhouse/workflow document. Documents are read and written by the @powerhousedao/piece-reactor blocks; list those with getWorkflowPieceBlocks.`,\n inputSchema: {},\n annotations: { title: \"List Workflow Core Blocks\", ...READ_ONLY },\n callback: async () => {\n syncRuntimeUrl();\n // The reactor serves the core piece's descriptors, as it does any piece's.\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(CORE_PIECE),\n fetchPieceTriggers(CORE_PIECE),\n ]);\n const blocks: BlockRef[] = [\n ...triggers.map((entry) => ({ ...entry, kind: \"trigger\" as const })),\n ...actions.map((entry) => ({ ...entry, kind: \"action\" as const })),\n ].map((entry) => ({\n pieceName: entry.pieceName,\n pieceVersion: entry.pieceVersion,\n name: entry.name,\n kind: entry.kind,\n }));\n const forms = await Promise.all(blocks.map(getBlockForm));\n return {\n blocks: blocks.flatMap((block, index) => {\n const form = forms[index];\n if (!form) return [];\n return [\n {\n ...blockFields(block),\n title: form.title,\n kind: kindOf(block),\n props: form.props.map(describeProp),\n ports: portsFor(form),\n },\n ];\n }),\n expressions: EXPRESSIONS,\n rules: GRAPH_RULES,\n };\n },\n};\n\nexport const listWorkflowRunsTool: PhAiToolDescriptor = {\n name: \"listWorkflowRuns\",\n description:\n \"Lists recent workflow runs, newest first, with status, error and each step's outcome. Filter by workflowId to inspect one workflow, or by driveId for every workflow in a drive.\",\n inputSchema: {\n workflowId: z\n .string()\n .optional()\n .describe(\"Workflow document id to filter by.\"),\n driveId: z\n .string()\n .optional()\n .describe(\"Drive id to filter by (all workflows in that drive).\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .optional()\n .describe(\"Maximum runs to return (default 10).\"),\n },\n annotations: { title: \"List Workflow Runs\", ...READ_ONLY },\n callback: async (args: {\n workflowId?: string;\n driveId?: string;\n limit?: number;\n }) => {\n syncRuntimeUrl();\n const runs = await fetchRuns({\n workflowId: args.workflowId,\n driveId: args.driveId,\n limit: args.limit ?? 10,\n });\n return {\n runs: runs.map((run) => ({\n id: run.id,\n workflowId: run.workflowId,\n workflowName: run.workflowName,\n status: run.status,\n error: run.error,\n triggerKind: run.triggerKind,\n startedAt: run.startedAt,\n endedAt: run.endedAt,\n steps: run.steps.map((step) => ({\n key: step.stepKey,\n status: step.status,\n error: step.error,\n })),\n })),\n };\n },\n};\n\nexport const fireWorkflowTool: PhAiToolDescriptor = {\n name: \"fireWorkflow\",\n description:\n \"Fires an ENABLED workflow whose trigger is the core manual trigger and runs its published snapshot to completion. The payload becomes {{trigger.payload}}. Returns the run id and final status.\",\n inputSchema: {\n workflowId: z.string().describe(\"Workflow document id.\"),\n payload: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\"Trigger payload object.\"),\n },\n annotations: {\n title: \"Fire Workflow\",\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n },\n callback: (args: {\n workflowId: string;\n payload?: Record<string, unknown>;\n }) => {\n syncRuntimeUrl();\n return fireWorkflow(args.workflowId, args.payload ?? {});\n },\n};\n\n/** Workflow authoring and run tools, merged into `aiTools` in tools.ts. */\nexport const workflowTools: PhAiToolDescriptor[] = [\n getWorkflowPieceBlocksTool,\n getWorkflowBlockConfigTool,\n listWorkflowCoreBlocksTool,\n listWorkflowRunsTool,\n fireWorkflowTool,\n];\n","// Read-only AI tool descriptors for the Connect assistant: the project's\n// piece catalog, connection documents, and connection health. The `aiTools`\n// export is how the host app discovers this package's tools (the line in the\n// project index is synced by `ph generate`).\nimport { getPHStore } from \"@powerhousedao/reactor-browser\";\nimport type { PhAiToolDescriptor } from \"@powerhousedao/shared/document-model\";\nimport { z } from \"zod\";\nimport {\n connectorIdForPiece,\n isConfigValueMissing,\n packageFromConnectorId,\n planFromAuth,\n type AuthField,\n} from \"../editors/connection-editor/piece-auth.js\";\nimport {\n checkConnection as runConnectionCheck,\n fetchConnections,\n fetchPieceActions,\n fetchPieceCatalog,\n fetchPieceTriggers,\n searchPieces,\n type PieceSummary,\n} from \"../editors/workflow-editor/runtime-api.js\";\nimport { syncRuntimeUrl } from \"./runtime-url.js\";\nimport { workflowTools } from \"./workflow-tools.js\";\n\nconst MAX_CONNECTORS = 20;\n\nexport interface ConnectorField {\n name: string;\n label: string;\n required: boolean;\n description?: string;\n secret: boolean;\n}\n\nexport interface ConnectorDetail {\n connectorId: string;\n pieceName: string;\n displayName: string;\n description: string;\n version: string;\n authType: string;\n /** False for auth kinds the runtime cannot execute yet (OIDC). */\n supported: boolean;\n /** OAUTH2: a person finishes it by signing in from the connection editor. */\n signIn?: \"oauth2\";\n fields: ConnectorField[];\n actions: string[];\n triggers: string[];\n}\n\nfunction toField(field: AuthField, secret: boolean): ConnectorField {\n return {\n name: field.name,\n label: field.displayName,\n required: field.required,\n description: field.description,\n secret,\n };\n}\n\nasync function connectorDetail(piece: PieceSummary): Promise<ConnectorDetail> {\n const plan = planFromAuth(piece.auth);\n const [actions, triggers] = await Promise.all([\n fetchPieceActions(piece.name),\n fetchPieceTriggers(piece.name),\n ]);\n return {\n connectorId: connectorIdForPiece(piece.name),\n pieceName: piece.name,\n displayName: piece.displayName,\n description: piece.description,\n version: piece.version,\n authType: plan.authType,\n supported: plan.supported,\n ...(plan.oauth2 ? { signIn: \"oauth2\" as const } : {}),\n fields: [\n ...plan.configFields.map((field) => toField(field, false)),\n ...plan.secretFields.map((field) => toField(field, true)),\n ],\n actions: actions.map((action) => action.name),\n triggers: triggers.map((trigger) => trigger.name),\n };\n}\n\n// Pieces the runtime's search ranks for the query, actions' and triggers'\n// rankings interleaved; null while its index builds, where it has none, or\n// when it ranks nothing (a package name, say).\nasync function rankedPieces(\n catalog: PieceSummary[],\n query: string,\n): Promise<PieceSummary[] | null> {\n let results;\n try {\n results = await Promise.all(\n ([\"action\", \"trigger\"] as const).map((kind) =>\n searchPieces(query, { kind, limit: 50 }),\n ),\n );\n } catch {\n return null;\n }\n if (results.some((result) => result.status !== \"ready\")) return null;\n const byName = new Map(catalog.map((piece) => [piece.name, piece]));\n const ranked = new Map<string, PieceSummary>();\n const longest = Math.max(...results.map((result) => result.pieces.length));\n for (let rank = 0; rank < longest; rank++) {\n for (const result of results) {\n const name = result.pieces.at(rank)?.pieceName;\n const piece = name === undefined ? undefined : byName.get(name);\n if (piece && !ranked.has(piece.name)) ranked.set(piece.name, piece);\n }\n }\n return ranked.size > 0 ? [...ranked.values()] : null;\n}\n\n/**\n * Stage one of connector discovery: the catalog, optionally narrowed by the\n * runtime's piece search (a substring match while its index builds), capped\n * at {@link MAX_CONNECTORS}. Full auth/action/trigger detail is fetched only\n * for the surviving entries (stage two).\n */\nexport async function getConnectors(query?: string): Promise<{\n total: number;\n matches: number;\n truncated: boolean;\n connectors: ConnectorDetail[];\n}> {\n syncRuntimeUrl();\n const catalog = await fetchPieceCatalog();\n const needle = query?.trim().toLowerCase();\n // A package name is an answer, not a search.\n const exact = catalog.filter((piece) => piece.name.toLowerCase() === needle);\n const matches = !needle\n ? [...catalog]\n : exact.length > 0\n ? exact\n : ((await rankedPieces(catalog, needle)) ??\n catalog.filter((piece) =>\n [piece.name, piece.displayName, piece.description].some((field) =>\n field.toLowerCase().includes(needle),\n ),\n ));\n const page = matches.slice(0, MAX_CONNECTORS);\n const connectors = await Promise.all(page.map(connectorDetail));\n return {\n total: catalog.length,\n matches: matches.length,\n truncated: matches.length > page.length,\n connectors,\n };\n}\n\ninterface ConnectionState {\n config?: unknown;\n secretRefs?: { name: string }[];\n}\n\nexport interface ConnectionDetail {\n id: string;\n name: string;\n connectorId: string;\n authType: string;\n status: string;\n accountLabel: string | null;\n /** Required secret fields with no stored ref, by auth property name. */\n missingSecrets: string[];\n /** Required config fields with no value, by auth property name. */\n missingConfig: string[];\n}\n\n/**\n * Every connection document with its credential state compared against the\n * piece's auth plan. Only field names and opaque refs are surfaced; secret\n * values never do.\n */\nexport async function getConnections(): Promise<{\n connections: ConnectionDetail[];\n}> {\n syncRuntimeUrl();\n const [catalog, summaries] = await Promise.all([\n fetchPieceCatalog(),\n fetchConnections(),\n ]);\n const client = getPHStore()?.reactorClient;\n const connections = await Promise.all(\n summaries.map(async (summary) => {\n const piece = catalog.find(\n (entry) => entry.name === packageFromConnectorId(summary.connectorId),\n );\n const plan = planFromAuth(piece?.auth ?? null);\n let state: ConnectionState | undefined;\n if (client) {\n try {\n const document = await client.get(summary.id);\n state = (document.state as { global?: ConnectionState }).global;\n } catch {\n state = undefined;\n }\n }\n const refNames = new Set(\n (state?.secretRefs ?? []).map((ref) => ref.name),\n );\n const config = (state?.config ?? {}) as Record<string, unknown>;\n return {\n id: summary.id,\n name: summary.name,\n connectorId: summary.connectorId,\n authType: summary.authType,\n status: summary.status,\n accountLabel: summary.accountLabel,\n missingSecrets: plan.secretFields\n .filter((field) => field.required && !refNames.has(field.name))\n .map((field) => field.name),\n missingConfig: plan.configFields\n .filter(\n (field) =>\n field.required && isConfigValueMissing(config[field.name]),\n )\n .map((field) => field.name),\n };\n }),\n );\n return { connections };\n}\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n} as const;\n\nexport const getConnectorsTool: PhAiToolDescriptor = {\n name: \"getConnectors\",\n description:\n 'Lists the connectors (pieces) available to the workflow runtime with their auth fields, actions, and triggers. Without a query it returns up to 20 connectors; pass `query` to search, best match first: words can name the piece or what it does (e.g. \"slack send message\"), in any order, and small typos are tolerated. Secret fields are listed by name only, never by value.',\n inputSchema: { query: z.string().optional() },\n annotations: { title: \"Get Connectors\", ...READ_ONLY },\n callback: (args: { query?: string }) => getConnectors(args.query),\n};\n\nexport const getConnectionsTool: PhAiToolDescriptor = {\n name: \"getConnections\",\n description:\n \"Lists the project's connection documents with their credential status: which required secrets and config values are still missing, and the last account label. Secret values are never included. A connection with authType REACTOR is bound through a step's or trigger's reactorConnectionId, never connectionId.\",\n inputSchema: {},\n annotations: { title: \"Get Connections\", ...READ_ONLY },\n callback: () => getConnections(),\n};\n\nexport const checkConnectionTool: PhAiToolDescriptor = {\n name: \"checkConnection\",\n description:\n \"Runs a connection's own check against its stored credentials to verify they work. Takes a connection id (from getConnections) and reports success, the failure detail, and the account label when the provider returns one.\",\n inputSchema: { connectionId: z.string() },\n annotations: { title: \"Check Connection\", ...READ_ONLY },\n callback: (args: { connectionId: string }) => {\n syncRuntimeUrl();\n return runConnectionCheck(args.connectionId);\n },\n};\n\n/** Tool descriptors the host app offers the AI assistant. */\nexport const aiTools: PhAiToolDescriptor[] = [\n getConnectorsTool,\n getConnectionsTool,\n checkConnectionTool,\n ...workflowTools,\n];\n","import { Connection as ConnectionV1 } from \"document-models/connection/v1\";\nimport { Workflow as WorkflowV1 } from \"document-models/workflow/v1\";\n\n/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\n\nexport const documentModels = [ConnectionV1, WorkflowV1] as const;\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { EditorModule } from \"document-model\";\nimport { ConnectionEditor } from \"./connection-editor/module.js\";\nimport { WorkflowEditor } from \"./workflow-editor/module.js\";\nimport { WorkflowStudio } from \"./workflow-studio/module.js\";\n\nexport const editors: EditorModule[] = [\n ConnectionEditor,\n WorkflowEditor,\n WorkflowStudio,\n];\n","import type { Manifest } from \"document-model\";\nimport manifestJson from \"./powerhouse.manifest.json\" with { type: \"json\" };\n\nexport { aiTools } from \"./ai/tools.js\";\nexport { documentModels } from \"./document-models/document-models.js\";\nexport { upgradeManifests } from \"./document-models/upgrade-manifests.js\";\nexport { editors } from \"./editors/editors.js\";\nexport const manifest = manifestJson as Manifest;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACkBA,IAAI,UAAyB,oBAAoB,mBAAmB;AAEpE,MAAM,iBAAiB,yBAAyB;AAEhD,SAAgB,cAAc,KAAmB;CAC/C,IAAI,QAAQ,QAAQ,KAAK,UAAU,oBAAoB,GAAG;AAC5D;AAEA,MAAa,gBAAgB,UAC3B,eAAe,WAAW,eAAe,SAAS,KAAK,CAAC;AAC1D,MAAa,0BACX,eAAe,WAAW,aAAa,OAAO,CAAC;AACjD,MAAa,qBAAqB,gBAChC,QAAQ,kBAAkB,WAAW;AACvC,MAAa,sBAAsB,gBACjC,QAAQ,mBAAmB,WAAW;AACxC,MAAa,gBACX,OACA,WACG,QAAQ,aAAa,OAAO,MAAM;AACvC,MAAa,yBAAyB,QAAQ,iBAAiB;AAC/D,MAAa,mBAAmB,iBAC9B,QAAQ,gBAAg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O;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,sBAAsB,gBACjC,QAAQ,mBAAmB,WAAW;AACxC,MAAa,gBACX,OACA,WACG,QAAQ,aAAa,OAAO,MAAM;AACvC,MAAa,yBAAyB,QAAQ,iBAAiB;AAC/D,MAAa,mBAAmB,iBAC9B,QAAQ,gBAAgB,YAAY;AACtC,MAAa,aAAa,UAAsB,QAAQ,UAAU,KAAK;AACvE,MAAa,gBAAgB,YAAoB,YAC/C,QAAQ,aAAa,YAAY,OAAO;;;AClC1C,MAAM,+BAAe,IAAI,IAAY;AAErC,SAAgB,iBAAuB;CACrC,IAAI,OAAO,WAAW,aAAa;CACnC,MAAM,UAAU,WAAW,CAAC,EAAE;CAC9B,MAAM,cAAc,wBAAwB,OAAO;CAGnD,IAAI,CAAC,eAAe,WAAW,CAAC,aAAa,IAAI,OAAO,GAAG;EA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3
3
|
import { z } from "zod";
|
|
4
4
|
import { BaseDocumentHeaderSchema, BaseDocumentStateSchema, baseActions, baseCreateDocument, baseLoadFromInputVersioned, baseSaveToFileHandle, createAction, createBaseState, createReducer, createState, defaultBaseState, isDocumentAction } from "document-model";
|
|
5
|
+
//#region document-models/connection/upgrades/versions.ts
|
|
6
|
+
const supportedVersions = [1];
|
|
7
|
+
const latestVersion = supportedVersions[0];
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region document-models/connection/upgrades/upgrade-manifest.ts
|
|
10
|
+
const connectionUpgradeManifest = {
|
|
11
|
+
documentType: "powerhouse/connection",
|
|
12
|
+
latestVersion,
|
|
13
|
+
supportedVersions,
|
|
14
|
+
upgrades: {}
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
5
17
|
//#region document-models/connection/v1/gen/schema/zod.ts
|
|
6
18
|
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
7
19
|
const definedNonNullAnySchema = z$1.any().refine((v) => isDefinedNonNullAny(v));
|
|
@@ -91,48 +103,6 @@ function SetSecretRefInputSchema() {
|
|
|
91
103
|
});
|
|
92
104
|
}
|
|
93
105
|
//#endregion
|
|
94
|
-
//#region document-models/connection/v1/src/reactor-connection.ts
|
|
95
|
-
const REACTOR_CONNECTOR_ID = "@powerhousedao/reactor#reactor";
|
|
96
|
-
const REACTOR_LOCAL_ENDPOINT = "local";
|
|
97
|
-
const CONFIG_KEYS = /* @__PURE__ */ new Set(["endpoint", "access"]);
|
|
98
|
-
function isReactorConnectorId(connectorId) {
|
|
99
|
-
return connectorId === REACTOR_CONNECTOR_ID;
|
|
100
|
-
}
|
|
101
|
-
function defaultReactorConnectionConfig() {
|
|
102
|
-
return { endpoint: REACTOR_LOCAL_ENDPOINT };
|
|
103
|
-
}
|
|
104
|
-
function parseReactorConnectionConfig(config) {
|
|
105
|
-
if (config === null || typeof config !== "object" || Array.isArray(config)) return {
|
|
106
|
-
ok: false,
|
|
107
|
-
error: "A reactor connection config must be an object"
|
|
108
|
-
};
|
|
109
|
-
const unknownKey = Object.keys(config).find((key) => !CONFIG_KEYS.has(key));
|
|
110
|
-
if (unknownKey) return {
|
|
111
|
-
ok: false,
|
|
112
|
-
error: `Unknown reactor connection field "${unknownKey}"`
|
|
113
|
-
};
|
|
114
|
-
const parsed = ReactorConnectionConfigSchema().safeParse(config);
|
|
115
|
-
if (!parsed.success) return {
|
|
116
|
-
ok: false,
|
|
117
|
-
error: parsed.error.issues[0]?.message ?? "Invalid"
|
|
118
|
-
};
|
|
119
|
-
const { endpoint, access } = parsed.data;
|
|
120
|
-
if (endpoint !== "local") return {
|
|
121
|
-
ok: false,
|
|
122
|
-
error: `Reactor endpoint must be "${REACTOR_LOCAL_ENDPOINT}"`
|
|
123
|
-
};
|
|
124
|
-
if (access !== void 0 && access !== null && access !== "read") return {
|
|
125
|
-
ok: false,
|
|
126
|
-
error: `Reactor access must be "read" or absent`
|
|
127
|
-
};
|
|
128
|
-
const value = { endpoint };
|
|
129
|
-
if (access === "read") value.access = access;
|
|
130
|
-
return {
|
|
131
|
-
ok: true,
|
|
132
|
-
config: value
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
//#endregion
|
|
136
106
|
//#region document-models/connection/v1/gen/config/creators.ts
|
|
137
107
|
/**
|
|
138
108
|
* WARNING: DO NOT EDIT
|
|
@@ -402,6 +372,48 @@ var SecretRefNotFoundError = class extends Error {
|
|
|
402
372
|
}
|
|
403
373
|
};
|
|
404
374
|
//#endregion
|
|
375
|
+
//#region document-models/connection/v1/src/reactor-connection.ts
|
|
376
|
+
const REACTOR_CONNECTOR_ID = "@powerhousedao/reactor#reactor";
|
|
377
|
+
const REACTOR_LOCAL_ENDPOINT = "local";
|
|
378
|
+
const CONFIG_KEYS = /* @__PURE__ */ new Set(["endpoint", "access"]);
|
|
379
|
+
function isReactorConnectorId(connectorId) {
|
|
380
|
+
return connectorId === REACTOR_CONNECTOR_ID;
|
|
381
|
+
}
|
|
382
|
+
function defaultReactorConnectionConfig() {
|
|
383
|
+
return { endpoint: REACTOR_LOCAL_ENDPOINT };
|
|
384
|
+
}
|
|
385
|
+
function parseReactorConnectionConfig(config) {
|
|
386
|
+
if (config === null || typeof config !== "object" || Array.isArray(config)) return {
|
|
387
|
+
ok: false,
|
|
388
|
+
error: "A reactor connection config must be an object"
|
|
389
|
+
};
|
|
390
|
+
const unknownKey = Object.keys(config).find((key) => !CONFIG_KEYS.has(key));
|
|
391
|
+
if (unknownKey) return {
|
|
392
|
+
ok: false,
|
|
393
|
+
error: `Unknown reactor connection field "${unknownKey}"`
|
|
394
|
+
};
|
|
395
|
+
const parsed = ReactorConnectionConfigSchema().safeParse(config);
|
|
396
|
+
if (!parsed.success) return {
|
|
397
|
+
ok: false,
|
|
398
|
+
error: parsed.error.issues[0]?.message ?? "Invalid"
|
|
399
|
+
};
|
|
400
|
+
const { endpoint, access } = parsed.data;
|
|
401
|
+
if (endpoint !== "local") return {
|
|
402
|
+
ok: false,
|
|
403
|
+
error: `Reactor endpoint must be "${REACTOR_LOCAL_ENDPOINT}"`
|
|
404
|
+
};
|
|
405
|
+
if (access !== void 0 && access !== null && access !== "read") return {
|
|
406
|
+
ok: false,
|
|
407
|
+
error: `Reactor access must be "read" or absent`
|
|
408
|
+
};
|
|
409
|
+
const value = { endpoint };
|
|
410
|
+
if (access === "read") value.access = access;
|
|
411
|
+
return {
|
|
412
|
+
ok: true,
|
|
413
|
+
config: value
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
//#endregion
|
|
405
417
|
//#region document-models/connection/v1/src/reducers/config.ts
|
|
406
418
|
const connectionConfigOperations = {
|
|
407
419
|
setConfigOperation(state, action) {
|
|
@@ -552,18 +564,6 @@ const stateReducer = (state, action, dispatch) => {
|
|
|
552
564
|
};
|
|
553
565
|
const reducer = createReducer(stateReducer);
|
|
554
566
|
//#endregion
|
|
555
|
-
//#region document-models/connection/upgrades/versions.ts
|
|
556
|
-
const supportedVersions = [1];
|
|
557
|
-
const latestVersion = supportedVersions[0];
|
|
558
|
-
//#endregion
|
|
559
|
-
//#region document-models/connection/upgrades/upgrade-manifest.ts
|
|
560
|
-
const connectionUpgradeManifest = {
|
|
561
|
-
documentType: "powerhouse/connection",
|
|
562
|
-
latestVersion,
|
|
563
|
-
supportedVersions,
|
|
564
|
-
upgrades: {}
|
|
565
|
-
};
|
|
566
|
-
//#endregion
|
|
567
567
|
//#region document-models/connection/v1/gen/document-type.ts
|
|
568
568
|
/**
|
|
569
569
|
* WARNING: DO NOT EDIT
|
|
@@ -685,6 +685,6 @@ const Connection = {
|
|
|
685
685
|
documentModel: createState(defaultBaseState(), documentModel)
|
|
686
686
|
};
|
|
687
687
|
//#endregion
|
|
688
|
-
export {
|
|
688
|
+
export { removeSecretRef as A, RemoveSecretRefInputSchema as B, recordCheckResult as C, setConnector as D, setConnectionName as E, ConnectionStateSchema as F, SetConnectionNameInputSchema as G, SetAccountLabelInputSchema as H, ConnectionStatusSchema as I, definedNonNullAnySchema as J, SetConnectorInputSchema as K, ReactorConnectionConfigSchema as L, setConfigValue as M, setSecretRef as N, creators_exports$2 as O, ConnectionAuthTypeSchema as P, supportedVersions as Q, RecordCheckResultInputSchema as R, creators_exports as S, setAccountLabel as T, SetConfigInputSchema as U, SecretRefSchema as V, SetConfigValueInputSchema as W, connectionUpgradeManifest as X, isDefinedNonNullAny as Y, latestVersion as Z, defaultReactorConnectionConfig as _, utils$1 as a, documentModel as b, ConnectionPHStateSchema as c, isConnectionDocument as d, isConnectionState as f, REACTOR_LOCAL_ENDPOINT as g, REACTOR_CONNECTOR_ID as h, initialLocalState as i, setConfig as j, removeConfigValue as k, assertIsConnectionDocument as l, reducer as m, utils as n, ConnectionDocumentHeaderSchema as o, connectionDocumentType as p, SetSecretRefInputSchema as q, initialGlobalState as r, ConnectionDocumentSchema as s, Connection as t, assertIsConnectionState as u, isReactorConnectorId as v, creators_exports$1 as w, actions as x, parseReactorConnectionConfig as y, RemoveConfigValueInputSchema as z };
|
|
689
689
|
|
|
690
|
-
//# sourceMappingURL=module-
|
|
690
|
+
//# sourceMappingURL=module-BEEASith.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-BEEASith.mjs","names":["z","connectionConnectionActions","connectionConfigActions","connectionHealthActions","utils","genUtils","customUtils"],"sources":["../../document-models/connection/upgrades/versions.ts","../../document-models/connection/upgrades/upgrade-manifest.ts","../../document-models/connection/v1/gen/schema/zod.ts","../../document-models/connection/v1/gen/config/creators.ts","../../document-models/connection/v1/gen/connection/creators.ts","../../document-models/connection/v1/gen/health/creators.ts","../../document-models/connection/v1/actions.ts","../../document-models/connection/v1/gen/document-model.ts","../../document-models/connection/v1/gen/config/error.ts","../../document-models/connection/v1/src/reactor-connection.ts","../../document-models/connection/v1/src/reducers/config.ts","../../document-models/connection/v1/gen/connection/error.ts","../../document-models/connection/v1/src/reducers/connection.ts","../../document-models/connection/v1/src/reducers/health.ts","../../document-models/connection/v1/gen/reducer.ts","../../document-models/connection/v1/gen/document-type.ts","../../document-models/connection/v1/gen/document-schema.ts","../../document-models/connection/v1/gen/utils.ts","../../document-models/connection/v1/src/utils.ts","../../document-models/connection/v1/utils.ts","../../document-models/connection/v1/module.ts"],"sourcesContent":["export const supportedVersions = [1] as const;\n\nexport const latestVersion = supportedVersions[0];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { latestVersion, supportedVersions } from \"./versions.js\";\n\nexport const connectionUpgradeManifest: UpgradeManifest<\n typeof supportedVersions\n> = {\n documentType: \"powerhouse/connection\",\n latestVersion,\n supportedVersions,\n upgrades: {},\n};\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport * as z from \"zod\";\nimport type {\n ConnectionAuthType,\n ConnectionState,\n ConnectionStatus,\n ReactorConnectionConfig,\n RecordCheckResultInput,\n RemoveConfigValueInput,\n RemoveSecretRefInput,\n SecretRef,\n SetAccountLabelInput,\n SetConfigInput,\n SetConfigValueInput,\n SetConnectionNameInput,\n SetConnectorInput,\n SetSecretRefInput,\n} from \"./types.js\";\n\ntype Properties<T> = Required<{\n [K in keyof T]: z.ZodType<T[K]>;\n}>;\n\ntype definedNonNullAny = {};\n\nexport const isDefinedNonNullAny = (v: any): v is definedNonNullAny =>\n v !== undefined && v !== null;\n\nexport const definedNonNullAnySchema = z\n .any()\n .refine((v) => isDefinedNonNullAny(v));\n\nexport const ConnectionAuthTypeSchema = z.enum([\n \"BASIC_AUTH\",\n \"CUSTOM_AUTH\",\n \"NONE\",\n \"OAUTH2\",\n \"OIDC\",\n \"REACTOR\",\n \"SECRET_TEXT\",\n]);\n\nexport const ConnectionStatusSchema = z.enum([\n \"ERROR\",\n \"OK\",\n \"REVOKED\",\n \"UNCONFIGURED\",\n]);\n\nexport function ConnectionStateSchema(): z.ZodObject<\n Properties<ConnectionState>\n> {\n return z.object({\n __typename: z.literal(\"ConnectionState\").optional(),\n accountLabel: z.string().nullish(),\n authType: ConnectionAuthTypeSchema,\n config: z.unknown(),\n connectorId: z.string(),\n lastCheckedAt: z.iso.datetime().nullish(),\n lastError: z.string().nullish(),\n name: z.string(),\n secretRefs: z.array(z.lazy(() => SecretRefSchema())),\n status: ConnectionStatusSchema,\n });\n}\n\nexport function ReactorConnectionConfigSchema(): z.ZodObject<\n Properties<ReactorConnectionConfig>\n> {\n return z.object({\n __typename: z.literal(\"ReactorConnectionConfig\").optional(),\n access: z.string().nullish(),\n endpoint: z.string(),\n });\n}\n\nexport function RecordCheckResultInputSchema(): z.ZodObject<\n Properties<RecordCheckResultInput>\n> {\n return z.object({\n checkedAt: z.iso.datetime(),\n error: z.string().nullish(),\n status: ConnectionStatusSchema,\n });\n}\n\nexport function RemoveConfigValueInputSchema(): z.ZodObject<\n Properties<RemoveConfigValueInput>\n> {\n return z.object({\n name: z.string(),\n });\n}\n\nexport function RemoveSecretRefInputSchema(): z.ZodObject<\n Properties<RemoveSecretRefInput>\n> {\n return z.object({\n id: z.string(),\n });\n}\n\nexport function SecretRefSchema(): z.ZodObject<Properties<SecretRef>> {\n return z.object({\n __typename: z.literal(\"SecretRef\").optional(),\n id: z.string(),\n name: z.string(),\n ref: z.string(),\n });\n}\n\nexport function SetAccountLabelInputSchema(): z.ZodObject<\n Properties<SetAccountLabelInput>\n> {\n return z.object({\n accountLabel: z.string().nullish(),\n });\n}\n\nexport function SetConfigInputSchema(): z.ZodObject<\n Properties<SetConfigInput>\n> {\n return z.object({\n config: z.unknown(),\n });\n}\n\nexport function SetConfigValueInputSchema(): z.ZodObject<\n Properties<SetConfigValueInput>\n> {\n return z.object({\n name: z.string(),\n value: z.unknown(),\n });\n}\n\nexport function SetConnectionNameInputSchema(): z.ZodObject<\n Properties<SetConnectionNameInput>\n> {\n return z.object({\n name: z.string(),\n });\n}\n\nexport function SetConnectorInputSchema(): z.ZodObject<\n Properties<SetConnectorInput>\n> {\n return z.object({\n authType: ConnectionAuthTypeSchema,\n connectorId: z.string(),\n });\n}\n\nexport function SetSecretRefInputSchema(): z.ZodObject<\n Properties<SetSecretRefInput>\n> {\n return z.object({\n id: z.string(),\n name: z.string(),\n ref: z.string(),\n });\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { createAction } from \"document-model\";\nimport {\n RemoveConfigValueInputSchema,\n RemoveSecretRefInputSchema,\n SetConfigInputSchema,\n SetConfigValueInputSchema,\n SetSecretRefInputSchema,\n} from \"../schema/zod.js\";\nimport type {\n RemoveConfigValueInput,\n RemoveSecretRefInput,\n SetConfigInput,\n SetConfigValueInput,\n SetSecretRefInput,\n} from \"../types.js\";\nimport type {\n RemoveConfigValueAction,\n RemoveSecretRefAction,\n SetConfigAction,\n SetConfigValueAction,\n SetSecretRefAction,\n} from \"./actions.js\";\n\nexport const setConfig = (input: SetConfigInput) =>\n createAction<SetConfigAction>(\n \"SET_CONFIG\",\n { ...input },\n undefined,\n SetConfigInputSchema,\n \"global\",\n );\n\nexport const setConfigValue = (input: SetConfigValueInput) =>\n createAction<SetConfigValueAction>(\n \"SET_CONFIG_VALUE\",\n { ...input },\n undefined,\n SetConfigValueInputSchema,\n \"global\",\n );\n\nexport const removeConfigValue = (input: RemoveConfigValueInput) =>\n createAction<RemoveConfigValueAction>(\n \"REMOVE_CONFIG_VALUE\",\n { ...input },\n undefined,\n RemoveConfigValueInputSchema,\n \"global\",\n );\n\nexport const setSecretRef = (input: SetSecretRefInput) =>\n createAction<SetSecretRefAction>(\n \"SET_SECRET_REF\",\n { ...input },\n undefined,\n SetSecretRefInputSchema,\n \"global\",\n );\n\nexport const removeSecretRef = (input: RemoveSecretRefInput) =>\n createAction<RemoveSecretRefAction>(\n \"REMOVE_SECRET_REF\",\n { ...input },\n undefined,\n RemoveSecretRefInputSchema,\n \"global\",\n );\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { createAction } from \"document-model\";\nimport {\n SetAccountLabelInputSchema,\n SetConnectionNameInputSchema,\n SetConnectorInputSchema,\n} from \"../schema/zod.js\";\nimport type {\n SetAccountLabelInput,\n SetConnectionNameInput,\n SetConnectorInput,\n} from \"../types.js\";\nimport type {\n SetAccountLabelAction,\n SetConnectionNameAction,\n SetConnectorAction,\n} from \"./actions.js\";\n\nexport const setConnectionName = (input: SetConnectionNameInput) =>\n createAction<SetConnectionNameAction>(\n \"SET_CONNECTION_NAME\",\n { ...input },\n undefined,\n SetConnectionNameInputSchema,\n \"global\",\n );\n\nexport const setConnector = (input: SetConnectorInput) =>\n createAction<SetConnectorAction>(\n \"SET_CONNECTOR\",\n { ...input },\n undefined,\n SetConnectorInputSchema,\n \"global\",\n );\n\nexport const setAccountLabel = (input: SetAccountLabelInput) =>\n createAction<SetAccountLabelAction>(\n \"SET_ACCOUNT_LABEL\",\n { ...input },\n undefined,\n SetAccountLabelInputSchema,\n \"global\",\n );\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { createAction } from \"document-model\";\nimport { RecordCheckResultInputSchema } from \"../schema/zod.js\";\nimport type { RecordCheckResultInput } from \"../types.js\";\nimport type { RecordCheckResultAction } from \"./actions.js\";\n\nexport const recordCheckResult = (input: RecordCheckResultInput) =>\n createAction<RecordCheckResultAction>(\n \"RECORD_CHECK_RESULT\",\n { ...input },\n undefined,\n RecordCheckResultInputSchema,\n \"global\",\n );\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { baseActions } from \"document-model\";\nimport {\n connectionConfigActions,\n connectionConnectionActions,\n connectionHealthActions,\n} from \"./gen/creators.js\";\n\n/** Actions for the Connection document model */\n\nexport const actions = {\n ...baseActions,\n ...connectionConnectionActions,\n ...connectionConfigActions,\n ...connectionHealthActions,\n};\n","import type { DocumentModelGlobalState } from \"document-model\";\n\nexport const documentModel: DocumentModelGlobalState = {\n id: \"powerhouse/connection\",\n name: \"Connection\",\n author: {\n name: \"Powerhouse\",\n website: \"https://www.powerhouse.inc\",\n },\n extension: \".conn\",\n description:\n \"A configured connector instance: auth kind, non-secret config and secret handles, shared by many workflows.\",\n specifications: [\n {\n state: {\n local: {\n schema: \"\",\n examples: [],\n initialValue: \"\",\n },\n global: {\n schema:\n 'enum ConnectionAuthType {\\n SECRET_TEXT\\n BASIC_AUTH\\n CUSTOM_AUTH\\n OAUTH2\\n OIDC\\n NONE\\n \"Reactor access for a piece\\'s ctx.reactor; any piece may bind it.\"\\n REACTOR\\n}\\n\\nenum ConnectionStatus {\\n UNCONFIGURED\\n OK\\n ERROR\\n REVOKED\\n}\\n\\ntype SecretRef {\\n id: OID!\\n \"Matches an auth property name in the connector\\'s config schema.\"\\n name: String!\\n \"Opaque handle into the host secret provider. Not the secret.\"\\n ref: String!\\n}\\n\\n\"Config of a REACTOR connection. It holds no secrets.\"\\ntype ReactorConnectionConfig {\\n \"Which reactor the connection reaches; \\'local\\' is the only value.\"\\n endpoint: String!\\n \"\\'read\\' limits the connection to reads; absent allows what the step declares.\"\\n access: String\\n}\\n\\ntype ConnectionState {\\n name: String!\\n \"Fully-qualified connector id: \\'@acme/connector-imap#imap\\'.\"\\n connectorId: String!\\n \"Activepieces auth kind, so a piece\\'s PieceAuth maps directly.\"\\n authType: ConnectionAuthType!\\n \"Non-secret configuration, validated against the connector\\'s auth schema; a ReactorConnectionConfig for REACTOR.\"\\n config: Unknown!\\n \"Secret handles; values never appear in state, operations, or the run journal.\"\\n secretRefs: [SecretRef!]!\\n status: ConnectionStatus!\\n lastCheckedAt: DateTime\\n lastError: String\\n \"Populated by the connector\\'s own metadata call. Display only.\"\\n accountLabel: String\\n}',\n examples: [],\n initialValue:\n '{\\n \"name\": \"\",\\n \"connectorId\": \"\",\\n \"authType\": \"NONE\",\\n \"config\": {},\\n \"secretRefs\": [],\\n \"status\": \"UNCONFIGURED\",\\n \"lastCheckedAt\": null,\\n \"lastError\": null,\\n \"accountLabel\": null\\n}',\n },\n },\n modules: [\n {\n id: \"d723a91b-329c-46c3-acbf-85533c47b5a4\",\n name: \"connection\",\n description: \"Connection identity and connector binding.\",\n operations: [\n {\n id: \"ece5a33d-0bc1-46ff-87f4-c763d298cb3a\",\n name: \"SET_CONNECTION_NAME\",\n description: \"Sets the connection's display name.\",\n schema: \"input SetConnectionNameInput {\\n name: String!\\n}\",\n template: \"Sets the connection's display name.\",\n reducer: \"state.name = action.input.name;\",\n errors: [],\n examples: [],\n scope: \"global\",\n },\n {\n id: \"e668be97-82c8-433e-8af7-1644cfa25723\",\n name: \"SET_CONNECTOR\",\n description:\n \"Binds the connection to a connector and auth kind; resets status to UNCONFIGURED. REACTOR goes only with the reserved reactor connector id.\",\n schema:\n \"input SetConnectorInput {\\n connectorId: String!\\n authType: ConnectionAuthType!\\n}\",\n template:\n \"Binds the connection to a connector and auth kind; resets status to UNCONFIGURED.\",\n reducer:\n 'state.connectorId = action.input.connectorId;\\nstate.authType = action.input.authType;\\nstate.status = \"UNCONFIGURED\";',\n errors: [\n {\n id: \"6e550820-9d17-447d-9378-a17d38262bc8\",\n name: \"ReservedConnectorError\",\n code: \"RESERVED_CONNECTOR\",\n description:\n \"The reserved reactor connector id goes only with authType REACTOR, and REACTOR only with it.\",\n template: \"\",\n },\n ],\n examples: [],\n scope: \"global\",\n },\n {\n id: \"01a28e56-4406-4160-9547-f6239e728afd\",\n name: \"SET_ACCOUNT_LABEL\",\n description: \"Sets or clears the display-only account label.\",\n schema:\n \"input SetAccountLabelInput {\\n accountLabel: String\\n}\",\n template: \"Sets or clears the display-only account label.\",\n reducer:\n \"state.accountLabel = action.input.accountLabel || null;\",\n errors: [],\n examples: [],\n scope: \"global\",\n },\n ],\n },\n {\n id: \"728ec59f-db15-4c52-aa9d-fbe1a6d6a6f9\",\n name: \"config\",\n description: \"Non-secret configuration and secret handles.\",\n operations: [\n {\n id: \"c26f7cd8-c280-4e85-be65-83c3c1217358\",\n name: \"SET_CONFIG\",\n description: \"Replaces the non-secret configuration.\",\n schema: \"input SetConfigInput {\\n config: Unknown!\\n}\",\n template: \"Replaces the non-secret configuration.\",\n reducer: \"state.config = action.input.config;\",\n errors: [\n {\n id: \"b9911ea4-4168-4080-b05e-8687928dc309\",\n name: \"InvalidReactorConfigError\",\n code: \"INVALID_REACTOR_CONFIG\",\n description:\n \"A REACTOR connection's config is not a valid ReactorConnectionConfig.\",\n template: \"\",\n },\n ],\n examples: [],\n scope: \"global\",\n },\n {\n id: \"32f1c6e9-1bba-4c99-bd20-311b16f95fa9\",\n name: \"SET_CONFIG_VALUE\",\n description:\n \"Sets one non-secret config field, leaving the others as they are.\",\n schema:\n \"input SetConfigValueInput {\\n name: String!\\n value: Unknown!\\n}\",\n template:\n \"Sets one non-secret config field, leaving the others as they are.\",\n reducer: \"\",\n errors: [\n {\n id: \"6db3a25a-a3b2-4751-9470-3c122ff9abcd\",\n name: \"InvalidReactorConfigValueError\",\n code: \"INVALID_REACTOR_CONFIG_VALUE\",\n description:\n \"The field would leave a REACTOR connection's config invalid.\",\n template: \"\",\n },\n ],\n examples: [],\n scope: \"global\",\n },\n {\n id: \"bcb390f6-f8fc-4a09-99e6-1d84b272d7b6\",\n name: \"REMOVE_CONFIG_VALUE\",\n description:\n \"Removes one non-secret config field. Removing an absent field changes nothing.\",\n schema: \"input RemoveConfigValueInput {\\n name: String!\\n}\",\n template:\n \"Removes one non-secret config field. Removing an absent field changes nothing.\",\n reducer: \"\",\n errors: [\n {\n id: \"24496230-4088-4994-a6d5-b7651c718f63\",\n name: \"InvalidReactorConfigRemovalError\",\n code: \"INVALID_REACTOR_CONFIG_REMOVAL\",\n description:\n \"The removal would leave a REACTOR connection's config invalid.\",\n template: \"\",\n },\n ],\n examples: [],\n scope: \"global\",\n },\n {\n id: \"1a90e020-6dc5-49e0-9be1-732028dd10d3\",\n name: \"SET_SECRET_REF\",\n description:\n \"Creates or updates a secret handle, keyed by its auth property name.\",\n schema:\n \"input SetSecretRefInput {\\n id: OID!\\n name: String!\\n ref: String!\\n}\",\n template:\n \"Creates or updates a secret handle, keyed by its auth property name.\",\n reducer:\n \"const existing = state.secretRefs.find(\\n (secretRef) => secretRef.name === action.input.name,\\n);\\nif (existing) {\\n existing.ref = action.input.ref;\\n} else {\\n state.secretRefs.push({\\n id: action.input.id,\\n name: action.input.name,\\n ref: action.input.ref,\\n });\\n}\",\n errors: [\n {\n id: \"e3c42e5b-80c6-4020-8cfd-2ccc797d82b7\",\n name: \"ReactorSecretRefError\",\n code: \"REACTOR_SECRET_REF\",\n description: \"A REACTOR connection holds no secrets.\",\n template: \"\",\n },\n ],\n examples: [],\n scope: \"global\",\n },\n {\n id: \"0c7214b1-0494-49d8-913f-39ad59ca2a3b\",\n name: \"REMOVE_SECRET_REF\",\n description: \"Removes a secret handle.\",\n schema: \"input RemoveSecretRefInput {\\n id: OID!\\n}\",\n template: \"Removes a secret handle.\",\n reducer:\n 'const index = state.secretRefs.findIndex(\\n (secretRef) => secretRef.id === action.input.id,\\n);\\nif (index === -1) {\\n throw new SecretRefNotFoundError(\"Secret ref not found\");\\n}\\nstate.secretRefs.splice(index, 1);',\n errors: [\n {\n id: \"0c5d799d-d71d-4a75-ab0e-136ea72f1a3b\",\n name: \"SecretRefNotFoundError\",\n code: \"SECRET_REF_NOT_FOUND\",\n description: \"No secret ref exists with the given id.\",\n template: \"\",\n },\n ],\n examples: [],\n scope: \"global\",\n },\n ],\n },\n {\n id: \"3b02be29-0e8b-400d-ba05-1305e28c86b5\",\n name: \"health\",\n description: \"Connection health, written by connector checks.\",\n operations: [\n {\n id: \"2e8e9df7-3939-425c-9e28-7c8fa5de7d3f\",\n name: \"RECORD_CHECK_RESULT\",\n description:\n \"Records the outcome of a connection check, including revocation.\",\n schema:\n \"input RecordCheckResultInput {\\n status: ConnectionStatus!\\n checkedAt: DateTime!\\n error: String\\n}\",\n template:\n \"Records the outcome of a connection check, including revocation.\",\n reducer:\n \"state.status = action.input.status;\\nstate.lastCheckedAt = action.input.checkedAt;\\nstate.lastError = action.input.error || null;\",\n errors: [],\n examples: [],\n scope: \"global\",\n },\n ],\n },\n ],\n version: 1,\n changeLog: [],\n },\n ],\n};\n","export type ErrorCode =\n | \"InvalidReactorConfigError\"\n | \"InvalidReactorConfigValueError\"\n | \"InvalidReactorConfigRemovalError\"\n | \"ReactorSecretRefError\"\n | \"SecretRefNotFoundError\";\n\nexport interface ReducerError {\n errorCode: ErrorCode;\n}\n\nexport class InvalidReactorConfigError extends Error implements ReducerError {\n errorCode = \"InvalidReactorConfigError\" as ErrorCode;\n constructor(message = \"InvalidReactorConfigError\") {\n super(message);\n }\n}\n\nexport class InvalidReactorConfigValueError\n extends Error\n implements ReducerError\n{\n errorCode = \"InvalidReactorConfigValueError\" as ErrorCode;\n constructor(message = \"InvalidReactorConfigValueError\") {\n super(message);\n }\n}\n\nexport class InvalidReactorConfigRemovalError\n extends Error\n implements ReducerError\n{\n errorCode = \"InvalidReactorConfigRemovalError\" as ErrorCode;\n constructor(message = \"InvalidReactorConfigRemovalError\") {\n super(message);\n }\n}\n\nexport class ReactorSecretRefError extends Error implements ReducerError {\n errorCode = \"ReactorSecretRefError\" as ErrorCode;\n constructor(message = \"ReactorSecretRefError\") {\n super(message);\n }\n}\n\nexport class SecretRefNotFoundError extends Error implements ReducerError {\n errorCode = \"SecretRefNotFoundError\" as ErrorCode;\n constructor(message = \"SecretRefNotFoundError\") {\n super(message);\n }\n}\n\nexport const errors = {\n SetConfig: { InvalidReactorConfigError },\n\n SetConfigValue: { InvalidReactorConfigValueError },\n\n RemoveConfigValue: { InvalidReactorConfigRemovalError },\n\n SetSecretRef: { ReactorSecretRefError },\n\n RemoveSecretRef: { SecretRefNotFoundError },\n};\n","import { ReactorConnectionConfigSchema } from \"../gen/schema/zod.js\";\n\n// Reserved for REACTOR connections; any piece may bind it.\nexport const REACTOR_CONNECTOR_ID = \"@powerhousedao/reactor#reactor\";\nexport const REACTOR_LOCAL_ENDPOINT = \"local\";\n\n// A REACTOR connection's config with absent fields left out.\nexport interface ReactorConnectionConfigValue {\n endpoint: typeof REACTOR_LOCAL_ENDPOINT;\n access?: \"read\";\n}\n\nexport type ReactorConnectionConfigResult =\n | { ok: true; config: ReactorConnectionConfigValue }\n | { ok: false; error: string };\n\nconst CONFIG_KEYS = new Set([\"endpoint\", \"access\"]);\n\nexport function isReactorConnectorId(connectorId: string): boolean {\n return connectorId === REACTOR_CONNECTOR_ID;\n}\n\nexport function defaultReactorConnectionConfig(): ReactorConnectionConfigValue {\n return { endpoint: REACTOR_LOCAL_ENDPOINT };\n}\n\n// Unknown keys are refused, so a misspelt field is never ignored.\nexport function parseReactorConnectionConfig(\n config: unknown,\n): ReactorConnectionConfigResult {\n if (config === null || typeof config !== \"object\" || Array.isArray(config)) {\n return {\n ok: false,\n error: \"A reactor connection config must be an object\",\n };\n }\n const unknownKey = Object.keys(config).find((key) => !CONFIG_KEYS.has(key));\n if (unknownKey) {\n return {\n ok: false,\n error: `Unknown reactor connection field \"${unknownKey}\"`,\n };\n }\n const parsed = ReactorConnectionConfigSchema().safeParse(config);\n if (!parsed.success) {\n return { ok: false, error: parsed.error.issues[0]?.message ?? \"Invalid\" };\n }\n const { endpoint, access } = parsed.data;\n if (endpoint !== REACTOR_LOCAL_ENDPOINT) {\n return {\n ok: false,\n error: `Reactor endpoint must be \"${REACTOR_LOCAL_ENDPOINT}\"`,\n };\n }\n if (access !== undefined && access !== null && access !== \"read\") {\n return { ok: false, error: `Reactor access must be \"read\" or absent` };\n }\n const value: ReactorConnectionConfigValue = { endpoint };\n if (access === \"read\") value.access = access;\n return { ok: true, config: value };\n}\n","import type { ConnectionConfigOperations } from \"document-models/connection/v1\";\nimport {\n InvalidReactorConfigError,\n InvalidReactorConfigRemovalError,\n InvalidReactorConfigValueError,\n ReactorSecretRefError,\n SecretRefNotFoundError,\n} from \"../../gen/config/error.js\";\nimport { parseReactorConnectionConfig } from \"../reactor-connection.js\";\n\nexport const connectionConfigOperations: ConnectionConfigOperations = {\n setConfigOperation(state, action) {\n if (state.authType !== \"REACTOR\") {\n state.config = action.input.config;\n return;\n }\n const parsed = parseReactorConnectionConfig(action.input.config);\n if (!parsed.ok) throw new InvalidReactorConfigError(parsed.error);\n state.config = parsed.config;\n },\n setSecretRefOperation(state, action) {\n if (state.authType === \"REACTOR\") {\n throw new ReactorSecretRefError(\"A reactor connection holds no secrets\");\n }\n const existing = state.secretRefs.find(\n (secretRef) => secretRef.name === action.input.name,\n );\n if (existing) {\n existing.ref = action.input.ref;\n } else {\n state.secretRefs.push({\n id: action.input.id,\n name: action.input.name,\n ref: action.input.ref,\n });\n }\n },\n removeSecretRefOperation(state, action) {\n const index = state.secretRefs.findIndex(\n (secretRef) => secretRef.id === action.input.id,\n );\n if (index === -1) {\n throw new SecretRefNotFoundError(\"Secret ref not found\");\n }\n state.secretRefs.splice(index, 1);\n },\n setConfigValueOperation(state, action) {\n const { name, value } = action.input;\n const config = { ...configRecord(state.config) };\n if (value === undefined) delete config[name];\n else config[name] = value;\n if (state.authType !== \"REACTOR\") {\n state.config = config;\n return;\n }\n const parsed = parseReactorConnectionConfig(config);\n if (!parsed.ok) throw new InvalidReactorConfigValueError(parsed.error);\n state.config = parsed.config;\n },\n removeConfigValueOperation(state, action) {\n const current = configRecord(state.config);\n if (!(action.input.name in current)) return;\n const { [action.input.name]: _removed, ...config } = current;\n if (state.authType !== \"REACTOR\") {\n state.config = config;\n return;\n }\n const parsed = parseReactorConnectionConfig(config);\n if (!parsed.ok) throw new InvalidReactorConfigRemovalError(parsed.error);\n state.config = parsed.config;\n },\n};\n\n// A config that is not an object holds no fields to keep.\nfunction configRecord(config: unknown): Record<string, unknown> {\n return config !== null && typeof config === \"object\" && !Array.isArray(config)\n ? (config as Record<string, unknown>)\n : {};\n}\n","export type ErrorCode = \"ReservedConnectorError\";\n\nexport interface ReducerError {\n errorCode: ErrorCode;\n}\n\nexport class ReservedConnectorError extends Error implements ReducerError {\n errorCode = \"ReservedConnectorError\" as ErrorCode;\n constructor(message = \"ReservedConnectorError\") {\n super(message);\n }\n}\n\nexport const errors = {\n SetConnector: { ReservedConnectorError },\n};\n","import type { ConnectionConnectionOperations } from \"document-models/connection/v1\";\nimport { ReservedConnectorError } from \"../../gen/connection/error.js\";\nimport {\n defaultReactorConnectionConfig,\n isReactorConnectorId,\n} from \"../reactor-connection.js\";\n\nexport const connectionConnectionOperations: ConnectionConnectionOperations = {\n setConnectionNameOperation(state, action) {\n state.name = action.input.name;\n },\n setConnectorOperation(state, action) {\n const reactor = action.input.authType === \"REACTOR\";\n if (reactor !== isReactorConnectorId(action.input.connectorId)) {\n throw new ReservedConnectorError(\n \"The reactor connector id goes only with authType REACTOR\",\n );\n }\n const rebinding = action.input.connectorId !== state.connectorId;\n state.connectorId = action.input.connectorId;\n state.authType = action.input.authType;\n state.status = \"UNCONFIGURED\";\n // A different connector invalidates the old one's config/secrets/health;\n // a same-connector call (e.g. re-declaring authType) leaves them alone.\n if (rebinding) {\n state.config = reactor ? defaultReactorConnectionConfig() : {};\n state.secretRefs = [];\n state.accountLabel = null;\n state.lastCheckedAt = null;\n state.lastError = null;\n }\n },\n setAccountLabelOperation(state, action) {\n state.accountLabel = action.input.accountLabel || null;\n },\n};\n","import type { ConnectionHealthOperations } from \"document-models/connection/v1\";\n\nexport const connectionHealthOperations: ConnectionHealthOperations = {\n recordCheckResultOperation(state, action) {\n state.status = action.input.status;\n state.lastCheckedAt = action.input.checkedAt;\n state.lastError = action.input.error || null;\n },\n};\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport type { Reducer, StateReducer } from \"document-model\";\nimport { createReducer, isDocumentAction } from \"document-model\";\nimport type { ConnectionPHState } from \"document-models/connection/v1\";\n\nimport { connectionConfigOperations } from \"../src/reducers/config.js\";\nimport { connectionConnectionOperations } from \"../src/reducers/connection.js\";\nimport { connectionHealthOperations } from \"../src/reducers/health.js\";\n\nimport {\n RecordCheckResultInputSchema,\n RemoveConfigValueInputSchema,\n RemoveSecretRefInputSchema,\n SetAccountLabelInputSchema,\n SetConfigInputSchema,\n SetConfigValueInputSchema,\n SetConnectionNameInputSchema,\n SetConnectorInputSchema,\n SetSecretRefInputSchema,\n} from \"./schema/zod.js\";\n\nconst schemaMemo = new Map<() => unknown, unknown>();\n\nfunction memoizedSchema<T>(makeSchema: () => T): T {\n let schema = schemaMemo.get(makeSchema) as T | undefined;\n if (schema === undefined) {\n schema = makeSchema();\n schemaMemo.set(makeSchema, schema);\n }\n return schema;\n}\n\nconst stateReducer: StateReducer<ConnectionPHState> = (\n state,\n action,\n dispatch,\n) => {\n if (isDocumentAction(action)) {\n return state;\n }\n switch (action.type) {\n case \"SET_CONNECTION_NAME\": {\n memoizedSchema(SetConnectionNameInputSchema).parse(action.input);\n\n connectionConnectionOperations.setConnectionNameOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_CONNECTOR\": {\n memoizedSchema(SetConnectorInputSchema).parse(action.input);\n\n connectionConnectionOperations.setConnectorOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_ACCOUNT_LABEL\": {\n memoizedSchema(SetAccountLabelInputSchema).parse(action.input);\n\n connectionConnectionOperations.setAccountLabelOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_CONFIG\": {\n memoizedSchema(SetConfigInputSchema).parse(action.input);\n\n connectionConfigOperations.setConfigOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_CONFIG_VALUE\": {\n memoizedSchema(SetConfigValueInputSchema).parse(action.input);\n\n connectionConfigOperations.setConfigValueOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"REMOVE_CONFIG_VALUE\": {\n memoizedSchema(RemoveConfigValueInputSchema).parse(action.input);\n\n connectionConfigOperations.removeConfigValueOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_SECRET_REF\": {\n memoizedSchema(SetSecretRefInputSchema).parse(action.input);\n\n connectionConfigOperations.setSecretRefOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"REMOVE_SECRET_REF\": {\n memoizedSchema(RemoveSecretRefInputSchema).parse(action.input);\n\n connectionConfigOperations.removeSecretRefOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"RECORD_CHECK_RESULT\": {\n memoizedSchema(RecordCheckResultInputSchema).parse(action.input);\n\n connectionHealthOperations.recordCheckResultOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n default:\n return state;\n }\n};\n\nexport const reducer: Reducer<ConnectionPHState> = createReducer(stateReducer);\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nexport const connectionDocumentType = \"powerhouse/connection\";\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport {\n BaseDocumentHeaderSchema,\n BaseDocumentStateSchema,\n} from \"document-model\";\nimport { z } from \"zod\";\nimport { connectionDocumentType } from \"./document-type.js\";\nimport { ConnectionStateSchema } from \"./schema/zod.js\";\nimport type { ConnectionDocument, ConnectionPHState } from \"./types.js\";\n\n/** Schema for validating the header object of a Connection document */\nexport const ConnectionDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({\n documentType: z.literal(connectionDocumentType),\n});\n\n/** Schema for validating the state object of a Connection document */\nexport const ConnectionPHStateSchema = BaseDocumentStateSchema.extend({\n global: ConnectionStateSchema(),\n});\n\nexport const ConnectionDocumentSchema = z.object({\n header: ConnectionDocumentHeaderSchema,\n state: ConnectionPHStateSchema,\n initialState: ConnectionPHStateSchema,\n});\n\n/** Simple helper function to check if a state object is a Connection document state object */\nexport function isConnectionState(state: unknown): state is ConnectionPHState {\n return ConnectionPHStateSchema.safeParse(state).success;\n}\n\n/** Simple helper function to assert that a document state object is a Connection document state object */\nexport function assertIsConnectionState(\n state: unknown,\n): asserts state is ConnectionPHState {\n ConnectionPHStateSchema.parse(state);\n}\n\n/** Simple helper function to check if a document is a Connection document */\nexport function isConnectionDocument(\n document: unknown,\n): document is ConnectionDocument {\n return ConnectionDocumentSchema.safeParse(document).success;\n}\n\n/** Simple helper function to assert that a document is a Connection document */\nexport function assertIsConnectionDocument(\n document: unknown,\n): asserts document is ConnectionDocument {\n ConnectionDocumentSchema.parse(document);\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { DocumentModelUtils, PHBaseState, Reducer } from \"document-model\";\nimport {\n baseCreateDocument,\n baseLoadFromInputVersioned,\n baseSaveToFileHandle,\n createBaseState,\n} from \"document-model\";\nimport { connectionUpgradeManifest } from \"../../upgrades/upgrade-manifest.js\";\nimport {\n assertIsConnectionDocument,\n assertIsConnectionState,\n isConnectionDocument,\n isConnectionState,\n} from \"./document-schema.js\";\nimport { connectionDocumentType } from \"./document-type.js\";\nimport { reducer } from \"./reducer.js\";\nimport type {\n ConnectionGlobalState,\n ConnectionLocalState,\n ConnectionPHState,\n} from \"./types.js\";\n\nexport const initialGlobalState: ConnectionGlobalState = {\n name: \"\",\n connectorId: \"\",\n authType: \"NONE\",\n config: {},\n secretRefs: [],\n status: \"UNCONFIGURED\",\n lastCheckedAt: null,\n lastError: null,\n accountLabel: null,\n};\nexport const initialLocalState: ConnectionLocalState = {};\n\nexport const utils: DocumentModelUtils<ConnectionPHState> = {\n fileExtension: \".conn\",\n createState(state) {\n return {\n ...createBaseState(state?.auth, { version: 1, ...state?.document }),\n global: { ...initialGlobalState, ...state?.global },\n local: { ...initialLocalState, ...state?.local },\n };\n },\n createDocument(state) {\n return baseCreateDocument(utils.createState, state, connectionDocumentType);\n },\n saveToFileHandle(document, input) {\n return baseSaveToFileHandle(document, input);\n },\n loadFromInput(input) {\n return baseLoadFromInputVersioned(input, {\n reducers: { 1: reducer as unknown as Reducer<PHBaseState> },\n upgradeManifest: connectionUpgradeManifest,\n });\n },\n isStateOfType(state) {\n return isConnectionState(state);\n },\n assertIsStateOfType(state) {\n return assertIsConnectionState(state);\n },\n isDocumentOfType(document) {\n return isConnectionDocument(document);\n },\n assertIsDocumentOfType(document) {\n return assertIsConnectionDocument(document);\n },\n};\n","export * from \"./reactor-connection.js\";\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { DocumentModelUtils } from \"document-model\";\nimport type { ConnectionPHState } from \"./gen/types.js\";\nimport { utils as genUtils } from \"./gen/utils.js\";\nimport * as customUtils from \"./src/utils.js\";\n\n/** Utils for the Connection document model */\nexport const utils: DocumentModelUtils<ConnectionPHState> = {\n ...genUtils,\n ...customUtils,\n};\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { DocumentModelModule } from \"document-model\";\nimport { createState, defaultBaseState } from \"document-model\";\nimport { actions } from \"./actions.js\";\nimport { documentModel } from \"./gen/document-model.js\";\nimport { reducer } from \"./gen/reducer.js\";\nimport type { ConnectionPHState } from \"./gen/types.js\";\nimport { utils } from \"./utils.js\";\n\n/** Document model module for the Connection document type */\nexport const Connection = {\n version: 1,\n reducer,\n actions,\n utils,\n documentModel: createState(defaultBaseState(), documentModel),\n} as const satisfies DocumentModelModule<ConnectionPHState>;\n"],"mappings":";;;;;AAAA,MAAa,oBAAoB,CAAC,CAAC;AAEnC,MAAa,gBAAgB,kBAAkB;;;ACK/C,MAAa,4BAET;CACF,cAAc;CACd;CACA;CACA,UAAU,CAAC;AACb;;;ACYA,MAAa,uBAAuB,MAClC,MAAM,KAAA,KAAa,MAAM;AAE3B,MAAa,0BAA0BA,IACpC,IAAI,CAAC,CACL,QAAQ,MAAM,oBAAoB,CAAC,CAAC;AAEvC,MAAa,2BAA2BA,IAAE,KAAK;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,yBAAyBA,IAAE,KAAK;CAC3C;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,wBAEd;CACA,OAAOA,IAAE,OAAO;EACd,YAAYA,IAAE,QAAQ,iBAAiB,CAAC,CAAC,SAAS;EAClD,cAAcA,IAAE,OAAO,CAAC,CAAC,QAAQ;EACjC,UAAU;EACV,QAAQA,IAAE,QAAQ;EAClB,aAAaA,IAAE,OAAO;EACtB,eAAeA,IAAE,IAAI,SAAS,CAAC,CAAC,QAAQ;EACxC,WAAWA,IAAE,OAAO,CAAC,CAAC,QAAQ;EAC9B,MAAMA,IAAE,OAAO;EACf,YAAYA,IAAE,MAAMA,IAAE,WAAW,gBAAgB,CAAC,CAAC;EACnD,QAAQ;CACV,CAAC;AACH;AAEA,SAAgB,gCAEd;CACA,OAAOA,IAAE,OAAO;EACd,YAAYA,IAAE,QAAQ,yBAAyB,CAAC,CAAC,SAAS;EAC1D,QAAQA,IAAE,OAAO,CAAC,CAAC,QAAQ;EAC3B,UAAUA,IAAE,OAAO;CACrB,CAAC;AACH;AAEA,SAAgB,+BAEd;CACA,OAAOA,IAA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OACE,IAAI;OACJ,MAAM;OACN,MAAM;OACN,aACE;OACF,UAAU;MACZ,CACF;MACA,UAAU,CAAC;MACX,OAAO;KACT;KACA;MACE,IAAI;MACJ,MAAM;MACN,aAAa;MACb,QACE;MACF,UAAU;MACV,SACE;MACF,QAAQ,CAAC;MACT,UAAU,CAAC;MACX,OAAO;KACT;IACF;GACF;GACA;IACE,IAAI;IACJ,MAAM;IACN,aAAa;IACb,YAAY;KACV;MACE,IAAI;MACJ,MAAM;MACN,aAAa;MACb,QAAQ;MACR,UAAU;MACV,SAAS;MACT,QAAQ,CACN;OACE,IAAI;OACJ,MAAM;OACN,MAAM;OACN,aACE;OACF,UAAU;MACZ,CACF;MACA,UAAU,CAAC;MACX,OAAO;KACT;KACA;MACE,IAAI;MACJ,MAAM;MACN,aACE;MACF,QACE;MACF,UACE;MACF,SAAS;MACT,QAAQ,CACN;OACE,IAAI;OACJ,MAAM;OACN,MAAM;OACN,aACE;OACF,UAAU;MACZ,CACF;MACA,UAAU,CAAC;MACX,OAAO;KACT;KACA;MACE,IAAI;MACJ,MAAM;MACN,aACE;MACF,QAAQ;MACR,UACE;MACF,SAAS;MACT,QAAQ,CACN;OACE,IAAI;OACJ,MAAM;OACN,MAAM;OACN,aACE;OACF,UAAU;MACZ,CACF;MACA,UAAU,CAAC;MACX,OAAO;KACT;KACA;MACE,IAAI;MACJ,MAAM;MACN,aACE;MACF,QACE;MACF,UACE;MACF,SACE;MACF,QAAQ,CACN;OACE,IAAI;OACJ,MAAM;OACN,MAAM;OACN,aAAa;OACb,UAAU;MACZ,CACF;MACA,UAAU,CAAC;MACX,OAAO;KACT;KACA;MACE,IAAI;MACJ,MAAM;MACN,aAAa;MACb,QAAQ;MACR,UAAU;MACV,SACE;MACF,QAAQ,CACN;OACE,IAAI;OACJ,MAAM;OACN,MAAM;OACN,aAAa;OACb,UAAU;MACZ,CACF;MACA,UAAU,CAAC;MACX,OAAO;KACT;IACF;GACF;GACA;IACE,IAAI;IACJ,MAAM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Q,CAAC;CACT,YAAY,CAAC;CACb,QAAQ;CACR,eAAe;CACf,WAAW;CACX,cAAc;AAChB;AACA,MAAa,oBAA0C,CAAC;AAExD,MAAaC,UAA+C;CAC1D,eAAe;CACf,YAAY,OAAO;EACjB,OAAO;GACL,GAAG,gBAAgB,OAAO,MAAM;IAAE,SAAS;IAAG,GAAG,OAAO;GAAS,CAAC;GAClE,QAAQ;IAAE,GAAG;IAAoB,GAAG,OAAO;GAAO;GAClD,OAAO;IAAE,GAAG;IAAmB,GAAG,OAAO;GAAM;EACjD;CACF;CACA,eAAe,OAAO;EACpB,OAAO,mBAAmBA,QAAM,aAAa,OAAO,sBAAsB;CAC5E;CACA,iBAAiB,UAAU,OAAO;EAChC,OAAO,qBAAqB,UAAU,KAAK;CAC7C;CACA,cAAc,OAAO;EACnB,OAAO,2BAA2B,OAAO;GACvC,UAAU,EAAE,GAAG,QAA2C;GAC1D,iBAAiB;EACnB,CAAC;CACH;CACA,cAAc,OAAO;EACnB,OAAO,kBAAkB,KAAK;CAChC;CACA,oBAAoB,OAAO;EACzB,OAAO,wBAAwB,KAAK;CACtC;CACA,iBAAiB,UAAU;EACzB,OAAO,qBAAqB,QAAQ;CACtC;CACA,uBAAuB,UAAU;EAC/B,OAAO,2BAA2B,QAAQ;CAC5C;AACF;;;;;;;;;;;;;AE9DA,MAAa,QAA+C;CAC1D,GAAGC;CACH,GAAGC;AACL;;;;ACAA,MAAa,aAAa;CACxB,SAAS;CACT;CACA;CACA;CACA,eAAe,YAAY,iBAAiB,GAAG,aAAa;AAC9D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { v as isReactorConnectorId } from "./module-BEEASith.mjs";
|
|
1
2
|
//#region editors/connection-editor/piece-auth.ts
|
|
2
3
|
const UNKNOWN_AUTH = "UNKNOWN";
|
|
3
4
|
function isConfigValueMissing(value) {
|
|
@@ -22,7 +23,7 @@ function toField(name, prop) {
|
|
|
22
23
|
required: prop.required ?? false,
|
|
23
24
|
description: prop.description,
|
|
24
25
|
inputType: prop.type,
|
|
25
|
-
options: prop.options?.options?.filter((option) => option.value !== void 0).map((option) => ({
|
|
26
|
+
options: (prop.staticOptions ?? prop.options?.options)?.filter((option) => option.value !== void 0).map((option) => ({
|
|
26
27
|
label: option.label ?? String(option.value),
|
|
27
28
|
value: option.value
|
|
28
29
|
}))
|
|
@@ -140,7 +141,14 @@ function packageFromConnectorId(connectorId) {
|
|
|
140
141
|
const at = spec.indexOf("@", 1);
|
|
141
142
|
return at > 0 ? spec.slice(0, at) : spec;
|
|
142
143
|
}
|
|
144
|
+
const REACTOR_SERVICE_LABEL = "Powerhouse documents";
|
|
145
|
+
function serviceName(connectorId, catalog) {
|
|
146
|
+
if (connectorId === "") return null;
|
|
147
|
+
if (isReactorConnectorId(connectorId)) return REACTOR_SERVICE_LABEL;
|
|
148
|
+
const packageName = packageFromConnectorId(connectorId);
|
|
149
|
+
return catalog?.find((entry) => entry.name === packageName)?.displayName ?? packageName;
|
|
150
|
+
}
|
|
143
151
|
//#endregion
|
|
144
|
-
export {
|
|
152
|
+
export { isAuthComplete as a, planForConnection as c, serviceName as d, connectorIdForPiece as i, planFromAuth as l, REACTOR_SERVICE_LABEL as n, isConfigValueMissing as o, UNKNOWN_AUTH as r, packageFromConnectorId as s, OAUTH_TOKEN as t, plansFromAuth as u };
|
|
145
153
|
|
|
146
|
-
//# sourceMappingURL=piece-auth-
|
|
154
|
+
//# sourceMappingURL=piece-auth-C0u0XTO8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"piece-auth-C0u0XTO8.mjs","names":[],"sources":["../../editors/connection-editor/piece-auth.ts"],"sourcesContent":["// Turns a piece's PieceAuth descriptor into a concrete field plan that maps\n// onto powerhouse/connection state: config fields vs secret refs.\nimport {\n isReactorConnectorId,\n type ConnectionAuthType,\n} from \"document-models/connection\";\n\nexport interface AuthField {\n name: string;\n displayName: string;\n required: boolean;\n description?: string;\n // Non-secret fields only: SHORT_TEXT | NUMBER | CHECKBOX | STATIC_DROPDOWN.\n inputType?: string;\n options?: { label: string; value: unknown }[];\n}\n\n// A piece auth type this runtime doesn't know: shown, never saved.\nexport const UNKNOWN_AUTH = \"UNKNOWN\";\n\nexport interface AuthPlan {\n authType: ConnectionAuthType | typeof UNKNOWN_AUTH;\n displayName?: string;\n description?: string;\n configFields: AuthField[];\n secretFields: AuthField[];\n // OIDC is declared but not executable by the runtime yet.\n supported: boolean;\n // Signed in through the provider; the token is stored by the switchboard.\n oauth2?: boolean;\n // The piece's own name for an UNKNOWN auth type.\n declaredType?: string;\n}\n\n// Missing means unset, explicitly null, or emptied to \"\" - not `false`/`0`.\nexport function isConfigValueMissing(value: unknown): boolean {\n return value === undefined || value === null || value === \"\";\n}\n\n// Whether every required config/secret field of the plan is filled; pure so\n// it can drive a live re-check as the user edits, not just a one-time mark.\nexport function isAuthComplete(\n plan: AuthPlan,\n config: Record<string, unknown>,\n refs: Map<string, string>,\n): boolean {\n const configOk = plan.configFields.every(\n (field) => !field.required || !isConfigValueMissing(config[field.name]),\n );\n const secretsOk = plan.secretFields.every(\n (field) => !field.required || Boolean(refs.get(field.name)),\n );\n return configOk && secretsOk;\n}\n\ninterface AuthPropDescriptor {\n displayName?: string;\n description?: string;\n required?: boolean;\n type?: string;\n options?: { options?: { label?: string; value?: unknown }[] };\n // How the runtime's catalog lists a STATIC_DROPDOWN's options.\n staticOptions?: { label?: string; value?: unknown }[];\n}\n\ninterface PieceAuthDescriptor {\n type?: string;\n unsupported?: string;\n displayName?: string;\n description?: string;\n required?: boolean;\n // A record in a published listing; a named list from a loaded piece.\n props?:\n | Partial<Record<string, AuthPropDescriptor>>\n | (AuthPropDescriptor & { name?: string })[];\n}\n\n// Names the connection's config and secretRefs use for an OAuth2 app.\nexport const OAUTH_CLIENT_ID = \"client_id\";\nexport const OAUTH_CLIENT_SECRET = \"client_secret\";\nexport const OAUTH_TOKEN = \"token\";\n\nfunction propEntries(\n props: PieceAuthDescriptor[\"props\"],\n): [string, AuthPropDescriptor][] {\n if (Array.isArray(props)) {\n return props.flatMap((prop) => (prop.name ? [[prop.name, prop]] : []));\n }\n return Object.entries(props ?? {}).filter(\n (entry): entry is [string, AuthPropDescriptor] => entry[1] !== undefined,\n );\n}\n\nfunction toField(name: string, prop: AuthPropDescriptor): AuthField {\n return {\n name,\n displayName: prop.displayName ?? name,\n required: prop.required ?? false,\n description: prop.description,\n inputType: prop.type,\n options: (prop.staticOptions ?? prop.options?.options)\n ?.filter((option) => option.value !== undefined)\n .map((option) => ({\n label: option.label ?? String(option.value as string),\n value: option.value,\n })),\n };\n}\n\n// Every sign-in method a piece offers, in its order, one per auth type.\nexport function plansFromAuth(auth: unknown): AuthPlan[] {\n const plans = (Array.isArray(auth) ? auth : [auth]).map(planFromAuth);\n return plans.filter(\n (plan, index) =>\n plans.findIndex((other) => other.authType === plan.authType) === index,\n );\n}\n\n// The method a connection signs in with: the one of its auth type when the\n// runtime can run it, otherwise the piece's default.\nexport function planForConnection(\n auth: unknown,\n authType: ConnectionAuthType,\n): AuthPlan {\n return (\n plansFromAuth(auth).find(\n (plan) => plan.authType === authType && plan.supported,\n ) ?? planFromAuth(auth)\n );\n}\n\nexport function planFromAuth(auth: unknown): AuthPlan {\n // Some pieces declare multiple auth methods; prefer one the runtime supports.\n if (Array.isArray(auth)) {\n const plans = auth.map(planFromAuth);\n return (\n plans.find((plan) => plan.supported && plan.authType !== \"NONE\") ??\n plans.at(0) ??\n planFromAuth(null)\n );\n }\n const descriptor = (auth ?? null) as PieceAuthDescriptor | null;\n const plan = planForDescriptor(descriptor);\n // The runtime's own verdict, e.g. a CUSTOM_AUTH that needs token refresh.\n return descriptor?.unsupported ? { ...plan, supported: false } : plan;\n}\n\nfunction planForDescriptor(descriptor: PieceAuthDescriptor | null): AuthPlan {\n const base = {\n displayName: descriptor?.displayName,\n description: descriptor?.description,\n };\n switch (descriptor?.type) {\n case \"SECRET_TEXT\":\n return {\n ...base,\n authType: \"SECRET_TEXT\",\n configFields: [],\n secretFields: [\n {\n name: \"value\",\n displayName: descriptor.displayName ?? \"Secret\",\n required: descriptor.required ?? true,\n description: descriptor.description,\n },\n ],\n supported: true,\n };\n case \"BASIC_AUTH\": {\n const props: Partial<Record<string, AuthPropDescriptor>> =\n Object.fromEntries(propEntries(descriptor.props));\n return {\n ...base,\n authType: \"BASIC_AUTH\",\n configFields: [\n toField(\"username\", props.username ?? { displayName: \"Username\" }),\n ],\n secretFields: [\n toField(\"password\", props.password ?? { displayName: \"Password\" }),\n ],\n supported: true,\n };\n }\n case \"CUSTOM_AUTH\": {\n const entries = propEntries(descriptor.props);\n return {\n ...base,\n authType: \"CUSTOM_AUTH\",\n configFields: entries\n .filter(([, prop]) => prop.type !== \"SECRET_TEXT\")\n .map(([name, prop]) => toField(name, prop)),\n secretFields: entries\n .filter(([, prop]) => prop.type === \"SECRET_TEXT\")\n .map(([name, prop]) => toField(name, prop)),\n supported: true,\n };\n }\n case \"OAUTH2\": {\n const entries = propEntries(descriptor.props);\n return {\n ...base,\n authType: \"OAUTH2\",\n configFields: [\n {\n name: OAUTH_CLIENT_ID,\n displayName: \"Client ID\",\n required: true,\n description: \"From the OAuth app you registered with the service.\",\n },\n ...entries\n .filter(([, prop]) => prop.type !== \"SECRET_TEXT\")\n .map(([name, prop]) => toField(name, prop)),\n ],\n secretFields: [\n {\n name: OAUTH_CLIENT_SECRET,\n displayName: \"Client secret\",\n required: true,\n },\n ...entries\n .filter(([, prop]) => prop.type === \"SECRET_TEXT\")\n .map(([name, prop]) => toField(name, prop)),\n ],\n supported: true,\n oauth2: true,\n };\n }\n case \"OIDC\":\n return {\n ...base,\n authType: \"OIDC\",\n configFields: [],\n secretFields: [],\n supported: false,\n };\n case undefined:\n case \"NONE\":\n return {\n ...base,\n authType: \"NONE\",\n configFields: [],\n secretFields: [],\n supported: true,\n };\n default:\n return {\n ...base,\n authType: UNKNOWN_AUTH,\n declaredType: descriptor?.type,\n configFields: [],\n secretFields: [],\n supported: false,\n };\n }\n}\n\n// \"@activepieces/piece-gotify\" -> \"@activepieces/piece-gotify#gotify\"\nexport function connectorIdForPiece(packageName: string): string {\n const short =\n packageName\n .split(\"/\")\n .pop()\n ?.replace(/^piece-/, \"\") ?? packageName;\n return `${packageName}#${short}`;\n}\n\n// \"<piece package>#<short name>\" -> the package; a bare name is its own.\nexport function packageFromConnectorId(connectorId: string): string {\n const separator = connectorId.lastIndexOf(\"#\");\n if (separator <= 0) return connectorId;\n const spec = connectorId.slice(0, separator);\n const at = spec.indexOf(\"@\", 1);\n return at > 0 ? spec.slice(0, at) : spec;\n}\n\nexport const REACTOR_SERVICE_LABEL = \"Powerhouse documents\";\n\n// The service a connection is bound to, by name; null while none is chosen.\nexport function serviceName(\n connectorId: string,\n catalog: readonly { name: string; displayName: string }[] | null,\n): string | null {\n if (connectorId === \"\") return null;\n if (isReactorConnectorId(connectorId)) return REACTOR_SERVICE_LABEL;\n const packageName = packageFromConnectorId(connectorId);\n return (\n catalog?.find((entry) => entry.name === packageName)?.displayName ??\n packageName\n );\n}\n"],"mappings":";;AAkBA,MAAa,eAAe;AAiB5B,SAAgB,qBAAqB,OAAyB;CAC5D,OAAO,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU;AAC5D;AAIA,SAAgB,eACd,MACA,QACA,MACS;CACT,MAAM,WAAW,KAAK,aAAa,OAChC,UAAU,CAAC,MAAM,YAAY,CAAC,qBAAqB,OAAO,MAAM,KAAK,CACxE;CACA,MAAM,YAAY,KAAK,aAAa,OACjC,UAAU,CAAC,MAAM,YAAY,QAAQ,KAAK,IAAI,MAAM,IAAI,CAAC,CAC5D;CACA,OAAO,YAAY;AACrB;AAyBA,MAAa,kBAAkB;AAC/B,MAAa,sBAAsB;AACnC,MAAa,cAAc;AAE3B,SAAS,YACP,OACgC;CAChC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,SAAS,SAAU,KAAK,OAAO,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC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