Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
Third-party integration steps in Workflows (Activepieces-backed) — implementation plan
Spec / source: .ai/specs/2026-08-27-workflow-integrations.md
Research: .ai/research/activepieces-integrations.md, .ai/research/workflows-catalog-refresher.md
Branch: feat/active-pieces-integration
Scope of v1: one piece (Google Calendar), OAuth2 only, actions only, several named connections per company. Everything else is listed under Non-goals in the spec.
Progress
- Task 1: Migration —
integrationConnectiontable, RLS, vault RPCs - Task 2: Regenerate database types
- Task 3: Add Google OAuth env vars
- Task 4: Add the pinned piece dependency, allowlist and registry loader
- Task 5: Piece property ⇄ Carbon value-type mapping
- Task 6: Teach the catalog the
pieceroute block - Task 7: Fifth generator input — emit piece actions
- Task 8: Connections service (CRUD + fresh-token resolution)
- Task 9: OAuth connect and callback routes
- Task 10: Settings → Integrations connections panel
- Task 11: The integration action executor
- Task 12: Smart-dropdown options endpoint
- Task 13: Builder — connection picker and dynamic options
- Task 14: End-to-end verification — run log at
.ai/runs/2026-08-27-workflow-integrations.md. Every automated gate passes; every BROWSER criterion is unverified pending a Google Cloud OAuth app.
Dependencies
1 → 2 → 3
4 → 5 → 6 → 7 (5 and 6 are independent of each other; both need 4)
2 + 4 → 8 → 9 → 10
7 + 8 → 11
8 + 5 → 12 → 13
everything → 14
Tasks 5 and 6 may run in parallel. Tasks 9–10 and 11 may run in parallel once 8 lands.
Task 1: Migration — integrationConnection table, RLS, vault RPCs
Depends on: none
Files:
- Create:
packages/database/supabase/migrations/<timestamp>_workflow-integration-connections.sql(created by the command below) - Copy from (precedent):
packages/database/supabase/migrations/20260817122916_integration-secret-vault.sql(the three vault RPCs + the delete trigger) andpackages/database/supabase/migrations/20250201181148_rls-refactor.sqllines 719–760 (thecompanyIntegrationRLS policy shape)
Steps:
- Create the migration file:
pnpm db:migrate:new workflow-integration-connections - Write the table.
id('icn')follows the repo's prefixed-id convention; the composite primary key("id", "companyId")is mandatory for every Carbon table.CREATE TABLE "integrationConnection" ( "id" TEXT NOT NULL DEFAULT id('icn'), "companyId" TEXT NOT NULL, "pieceName" TEXT NOT NULL, "name" TEXT NOT NULL, "authType" TEXT NOT NULL DEFAULT 'OAUTH2', "accountLabel" TEXT, "metadata" JSONB NOT NULL DEFAULT '{}', "secretRef" TEXT, "expiresAt" TIMESTAMP WITH TIME ZONE, "refreshingAt" TIMESTAMP WITH TIME ZONE, "status" TEXT NOT NULL DEFAULT 'Active', "lastError" TEXT, "createdBy" TEXT NOT NULL REFERENCES "user"("id"), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), "updatedBy" TEXT REFERENCES "user"("id"), "updatedAt" TIMESTAMP WITH TIME ZONE, CONSTRAINT "integrationConnection_pkey" PRIMARY KEY ("id", "companyId"), CONSTRAINT "integrationConnection_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "company"("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "integrationConnection_status_check" CHECK ("status" IN ('Active', 'Expired', 'Revoked')), CONSTRAINT "integrationConnection_name_unique" UNIQUE ("companyId", "pieceName", "name") ); CREATE INDEX "integrationConnection_companyId_pieceName_idx" ON "integrationConnection" ("companyId", "pieceName"); - Add RLS, copying the
companyIntegrationpolicy shape verbatim and only changing the table name — samesettings_view/settings_create/settings_update/settings_deletegates:ALTER TABLE "integrationConnection" ENABLE ROW LEVEL SECURITY; CREATE POLICY "SELECT" ON "public"."integrationConnection" FOR SELECT USING ( "companyId" = ANY ((SELECT get_companies_with_employee_permission ('settings_view'))::text[]) ); CREATE POLICY "INSERT" ON "public"."integrationConnection" FOR INSERT WITH CHECK ( "companyId" = ANY ((SELECT get_companies_with_employee_permission ('settings_create'))::text[]) ); CREATE POLICY "UPDATE" ON "public"."integrationConnection" FOR UPDATE USING ( "companyId" = ANY ((SELECT get_companies_with_employee_permission ('settings_update'))::text[]) ); CREATE POLICY "DELETE" ON "public"."integrationConnection" FOR DELETE USING ( "companyId" = ANY ((SELECT get_companies_with_employee_permission ('settings_delete'))::text[]) ); - Add three vault RPCs. The existing
upsert_integration_secret/get_integration_secret/delete_integration_secretare hard-wired to thecompanyIntegrationtable and its'integration:' || companyId || ':' || idsecret name, so they cannot be reused. Mirror them exactly against the new table, with the secret name prefixconnection::CREATE OR REPLACE FUNCTION upsert_connection_secret(p_company_id text, p_connection_id text, p_secret jsonb) RETURNS text LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, vault AS $$ DECLARE v_name text := 'connection:' || p_company_id || ':' || p_connection_id; v_id uuid; BEGIN SELECT id INTO v_id FROM vault.secrets WHERE name = v_name; IF v_id IS NULL THEN v_id := vault.create_secret(p_secret::text, v_name, 'Carbon integration connection secret'); ELSE PERFORM vault.update_secret(v_id, p_secret::text); END IF; UPDATE "integrationConnection" SET "secretRef" = v_id::text WHERE "companyId" = p_company_id AND "id" = p_connection_id; RETURN v_id::text; END $$; CREATE OR REPLACE FUNCTION get_connection_secret(p_company_id text, p_connection_id text) RETURNS jsonb LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, vault AS $$ DECLARE v_ref text; v_secret text; BEGIN SELECT "secretRef" INTO v_ref FROM "integrationConnection" WHERE "companyId" = p_company_id AND "id" = p_connection_id; IF v_ref IS NULL THEN RETURN NULL; END IF; SELECT decrypted_secret INTO v_secret FROM vault.decrypted_secrets WHERE id = v_ref::uuid; IF v_secret IS NULL THEN RETURN NULL; END IF; RETURN v_secret::jsonb; END $$; CREATE OR REPLACE FUNCTION delete_connection_secret(p_company_id text, p_connection_id text) RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, vault AS $$ BEGIN DELETE FROM vault.secrets WHERE name = 'connection:' || p_company_id || ':' || p_connection_id; UPDATE "integrationConnection" SET "secretRef" = NULL WHERE "companyId" = p_company_id AND "id" = p_connection_id; END $$; - Add the delete trigger so a deleted row does not strand its vault secret (vault does not
cascade), copying
drop_integration_secret_on_deletefrom the precedent migration:CREATE OR REPLACE FUNCTION drop_connection_secret_on_delete() RETURNS trigger LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, vault AS $$ BEGIN DELETE FROM vault.secrets WHERE name = 'connection:' || OLD."companyId" || ':' || OLD.id; RETURN OLD; END $$; CREATE TRIGGER "integrationConnection_drop_secret" AFTER DELETE ON "integrationConnection" FOR EACH ROW EXECUTE FUNCTION drop_connection_secret_on_delete(); - Grant execute on the three RPCs to
service_roleonly, matching the precedent migration's grant block. Read that block and copy its exact form — do NOT grant toauthenticated. - Apply it:
pnpm db:migrate
Verify:
pnpm db:migrate
# Expected: the migration applies with no error.
Then confirm the RPCs exist and the table is protected — run in your local database:
SELECT proname FROM pg_proc
WHERE proname IN ('upsert_connection_secret','get_connection_secret','delete_connection_secret');
-- Expected: 3 rows.
SELECT relrowsecurity FROM pg_class WHERE relname = 'integrationConnection';
-- Expected: t
Out of scope: any change to companyIntegration, its RPCs, or its policies. The 12 existing
integrations must keep working untouched.
If
get_companies_with_employee_permissionor theid()function is not present in this database, STOP and report — do not invent a substitute.
Task 2: Regenerate database types
Depends on: Task 1
Files:
- Modify (generated):
packages/database/src/types.ts,packages/database/supabase/functions/lib/types.ts
Steps:
- Run the generator. This must happen before any typecheck that touches the new table —
@carbon/databasetypes are generated, never hand-edited.pnpm run generate:types - Commit the regenerated files alongside the migration.
Verify:
grep -c "integrationConnection" packages/database/src/types.ts
# Expected: a number greater than 0.
Out of scope: hand-editing any generated type. If the table is missing from the output, the migration did not apply — go back to Task 1.
Task 3: Add Google OAuth env vars
Depends on: none (do it alongside Task 1)
Files:
- Modify:
packages/env/src/index.ts— add three exports - Copy from (precedent): the
ONSHAPE_CLIENT_IDdeclaration atpackages/env/src/index.ts:252
Steps:
- Add, following the exact
getEnv(...)shape used byONSHAPE_CLIENT_IDimmediately above:GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET,GOOGLE_OAUTH_REDIRECT_URL. - Mark them optional in the same way Onshape's are, so a developer without Google credentials can still boot the app. A piece whose credentials are absent must be listed as unavailable rather than crashing the Integrations page (handled in Task 10).
- Add the three names to
.env.exampleif that file exists at the repo root, with empty values and a comment pointing at the Google Cloud Console.
Verify:
pnpm exec turbo run typecheck --filter=@carbon/env
# Expected: no errors.
Out of scope: committing any real credential value. Never put a client secret in the repo.
Task 4: Add the pinned piece dependency, allowlist and registry loader
Depends on: none
Files:
- Modify:
packages/jobs/package.json— add the dependency, pinned exactly - Create:
packages/jobs/src/workflows/integrations/allowlist.ts - Create:
packages/jobs/src/workflows/integrations/registry.ts - Create:
packages/jobs/src/workflows/integrations/registry.test.ts
Steps:
- Add the dependency with an exact version — no
^, no~. The spec's Design Decisions require exact pins so an upstream release cannot silently change executed code:
Then editpnpm --filter @carbon/jobs add @activepieces/[email protected]packages/jobs/package.jsonto make sure the recorded range is the bare string"0.10.3", not"^0.10.3". - Write
allowlist.ts— the single hand-written declaration of what we expose:export interface AllowlistEntry { package: string; version: string; label: string; actions: readonly string[]; } export const PIECE_ALLOWLIST: Record<string, AllowlistEntry> = { "google-calendar": { package: "@activepieces/piece-google-calendar", version: "0.10.3", label: "Google Calendar", actions: [ "create_google_calendar_event", "google_calendar_get_events" ] } }; export type PieceName = keyof typeof PIECE_ALLOWLIST; - Write
registry.ts. It is the only module allowed to import a piece package, so nothing else can accidentally pull Node-only code into a browser bundle:export async function loadPiece(name: string): Promise<Piece>; export async function getPieceAction(name: string, action: string): Promise<PieceAction>; export async function getPieceOAuth2Auth(name: string): Promise<OAuth2AuthDeclaration>;loadPiecedynamically importsPIECE_ALLOWLIST[name].packageand returns the exported piece object (for Google Calendar the export is namedgoogleCalendar; find the export by picking the first value that has bothauthand anactions()function, so a differently named export in a future piece still resolves).getPieceActionthrows a named error when the action is not in that entry'sactionslist — the allowlist, not the piece, decides what we expose.getPieceOAuth2Authhandlespiece.authbeing an array (Google Calendar exposes['OAUTH2', 'CUSTOM_AUTH']) and returns theOAUTH2member, throwing when there is none. v1 supports OAuth2 only.
- Write
registry.test.tsasserting, against the real installed package: the piece loads;create_google_calendar_eventresolves; a non-allowlisted action name throws;getPieceOAuth2Auth("google-calendar").authUrl === "https://accounts.google.com/o/oauth2/auth".
Verify:
pnpm --filter @carbon/jobs test -- registry
# Expected: all tests pass, including the auth URL assertion.
Out of scope: importing any piece package from packages/workflows or from apps/erp.
packages/workflows compiles for the browser at ES2019 and must never see piece code.
If
piece.actions()is not a function on the installed version, STOP and report — the piece API has changed since the spike and the mapping in Task 5 needs rechecking.
Task 5: Piece property ⇄ Carbon value-type mapping
Depends on: Task 4
Files:
- Create:
packages/jobs/src/workflows/integrations/properties.ts - Create:
packages/jobs/src/workflows/integrations/properties.test.ts
Steps:
Write
toValueType(property)mapping a piece property to a CarbonValueTypefrom@carbon/workflows(t.string,t.number,t.boolean,t.date,t.list(...)). Type imports only — never a value import that would drag piece code in. Map:Piece typeCarbon type SHORT_TEXT,LONG_TEXTt.stringNUMBERt.numberCHECKBOXt.booleanDATE_TIMEt.dateARRAYt.list(t.string)STATIC_DROPDOWNt.string+choicesread offproperty.options.optionsDROPDOWNt.string+ adynamicOptions: truemarker (resolved at edit time, Task 12)MULTI_SELECT_DROPDOWNt.list(t.string)+ the same choices/marker ruleEvery other kind (
OBJECT,JSON,FILE,DYNAMIC,MARKDOWN, …) throwsUnmappablePropertyErrorcarrying the piece, action and property names. The generator in Task 7 turns that into a build failure. A half-described action must never be emitted.Write
toPropsValue(actionProps, inputs)— the inverse, converting resolved CarbonRuntimeValues back into the plain object a piece'srun()expects. A date becomes an ISO string; a list becomes a plain array; an absent optional input is omitted rather than sent asnull(pieces branch onundefined).Write
properties.test.tscovering: each mapped kind; thatSTATIC_DROPDOWNcarries its threesend_notificationschoices from the real piece; thatOBJECTthrows with all three names in the message; and atoPropsValueround-trip for the create-event inputs.
Verify:
pnpm --filter @carbon/jobs test -- properties
# Expected: all tests pass, including the UnmappablePropertyError message assertions.
Out of scope: supporting OBJECT/JSON/FILE/DYNAMIC. They are Non-goals for v1 and must
fail loudly, not degrade.
Task 6: Teach the catalog the piece route block
Depends on: Task 4
Files:
- Modify:
packages/workflows/src/catalog/build.ts— addpiecetoBuiltAction - Modify:
packages/workflows/src/catalog/catalog.ts—getActionRoutereturns it - Modify:
packages/workflows/src/catalog/catalog.test.ts— cover the new route - Copy from (precedent): the existing
callandupdateroute blocks in the same two files
Steps:
- Add to
BuiltActionan optionalpiece?: { name: string; action: string }, documented in the same style as the existingcallandupdatefields ("Set by the generator; never hand-written"). - Extend
getActionRouteso it surfacespiecealongsidecallandupdate. Routing must stay off the catalog entry, never off the id's shape — the existing comment inpackages/jobs/src/workflows/actions/services.tsstates this rule and it applies here. - Add a
catalog.test.tscase asserting that an action with apieceblock returns it fromgetActionRoute, and that an action without one returnspieceasundefined. - Add an
integrationgrouping hint so the builder palette can group these separately — reuse whatever grouping the palette already reads; if there is none, group on theintegration.id prefix in the palette (Task 13) and add nothing here.
Verify:
pnpm --filter @carbon/workflows test -- catalog
pnpm exec turbo run typecheck --filter=@carbon/workflows
# Expected: all tests pass; no type errors.
Out of scope: adding a new node type. An integration step is an ordinary action node —
NODE_KINDS is unchanged, and so is CURRENT_DEFINITION_FORMAT_VERSION (still 4).
Task 7: Fifth generator input — emit piece actions
Depends on: Tasks 5, 6
Files:
- Modify:
scripts/generate-workflow-catalog.ts— read the allowlist and emit piece actions - Modify:
scripts/check-workflow-catalog.ts— keep the staleness check honest - Modify (generated, committed):
packages/workflows/src/catalog/actions.generated.ts,labels.generated.ts,help.generated.ts - Copy from (precedent): the existing
buildCatalog(...)call inscripts/generate-workflow-catalog.ts
Steps:
- In the generator, import
PIECE_ALLOWLISTand the registry frompackages/jobs/src/workflows/integrations/. The script runs undertsxin Node, so importing piece code here is fine — this is the one place outsidepackages/jobsthat may. - For every allowlisted piece and action, emit an entry keyed
integration.<pieceName>.<actionName>(e.g.integration.google-calendar.create_google_calendar_event) with:label—"<piece label>: <action displayName>", e.g."Google Calendar: Create Event"permission—{ module: "workflows", action: "update" }inputs—connectionIdfirst (t.string, required, label"connection"), then one input per piece prop viatoValueType,requiredcopied from the prop,labelfrom itsdisplayNameoutputs—{ result: t.string }for v1; the piece's own output schema is not mappedbatchable: falsepiece: { name, action }
- Emit a
WORKFLOW_LABELSentry for each new action id, so the builder and the run history name the step properly. Labels go inlabels.generated.tsas `msg``…``` like every other entry. - Let
UnmappablePropertyErrorpropagate — the generator must exit non-zero with the piece, action and property named, and write no files. - Update
scripts/check-workflow-catalog.tsso the staleness comparison includes the piece actions (it rebuilds the catalog and diffs against the committed file; feeding it the same fifth input is enough). CI runs this via.github/workflows/check.yml, so skipping it makes the build red. - Regenerate and commit the output:
pnpm run generate:workflow-catalog
Verify:
pnpm run generate:workflow-catalog && pnpm run check:workflow-catalog
# Expected: generation succeeds; the check reports no drift.
pnpm exec tsx -e 'import {WORKFLOW_ACTION_CATALOG} from "./packages/workflows/src/catalog/actions.generated"; const a = WORKFLOW_ACTION_CATALOG["integration.google-calendar.create_google_calendar_event"]; console.log(Object.keys(a.inputs).join(","), JSON.stringify(a.piece));'
# Expected: the input list starts with connectionId and includes title and start_date_time,
# and the piece block is {"name":"google-calendar","action":"create_google_calendar_event"}.
Out of scope: hand-editing any *.generated.ts file. Change the generator and re-run.
Task 8: Connections service (CRUD + fresh-token resolution)
Depends on: Tasks 2, 4
Files:
- Create:
packages/ee/src/integrations/connections.ts - Create:
packages/ee/src/integrations/connections.test.ts - Modify:
packages/ee/src/integrations/secrets.ts— nothing structural; see step 5 - Modify:
packages/ee/src/index.ts— export the new service - Copy from (precedent):
packages/ee/src/integrations/secrets.ts(persistIntegrationSecrets/resolveIntegrationSecretsare the shape to mirror, but they targetcompanyIntegration, so these are new functions against the new RPCs from Task 1)
Steps:
- Implement, all taking a Supabase client as the first argument in Carbon's service idiom:
listConnections(client, companyId, pieceName?) getConnection(client, companyId, connectionId) // non-secret fields only createConnection(serviceClient, { companyId, pieceName, name, authType, accountLabel, metadata, tokens, expiresAt, createdBy }) renameConnection(client, companyId, connectionId, name, updatedBy) disconnectConnection(serviceClient, companyId, connectionId, updatedBy) resolveConnectionAuth(serviceClient, companyId, connectionId) // returns FRESH auth createConnectioninserts the row, then writes{ accessToken, refreshToken }through theupsert_connection_secretRPC. Tokens must never be written intometadata.disconnectConnectioncallsdelete_connection_secretand setsstatus = 'Revoked',secretRef = NULL. It does not delete the row — a saved workflow node may reference the id, and a dangling id produces a worse error than a clear "reconnect this" message.resolveConnectionAuth:- reads the row; throws a named
ConnectionRevokedErrorwhenstatus !== 'Active' - reads tokens via
get_connection_secret; throwsConnectionSecretUnavailableErrorwhen null (fail closed, exactly asresolveIntegrationSecretsdoes) - when
expiresAtis more than five minutes away, returns the token as is - otherwise claims the refresh with a conditional update, so two concurrent workflow steps
cannot both refresh and clobber each other's token:
The claimant POSTsUPDATE "integrationConnection" SET "refreshingAt" = NOW() WHERE "id" = :id AND "companyId" = :companyId AND ("refreshingAt" IS NULL OR "refreshingAt" < NOW() - INTERVAL '30 seconds') RETURNING "id"grant_type=refresh_tokento the piece'stokenUrlwith our client id and secret, writes the new token throughupsert_connection_secret, updatesexpiresAt, and clearsrefreshingAt. A caller that does not win the claim waits 250 ms and re-reads, up to 20 times (5 s), then throwsConnectionRefreshTimeoutError. - on a refresh rejected by the vendor: set
status = 'Expired'andlastError, then throwConnectionRevokedError.
- reads the row; throws a named
- Add a
SECRET_KEYS-style guarantee for the new table by asserting in a test thatmetadatanever containsaccessTokenorrefreshTokenaftercreateConnection. The existingSECRET_KEYSmap is keyed bycompanyIntegrationid and is not used here; do not add connection keys to it. - Write
connections.test.tswith a mocked client covering: create writes tokens via the RPC and not into metadata; resolve returns the stored token when far from expiry; resolve refreshes exactly once when two calls race (the loser observes the winner's token); a revoked connection throwsConnectionRevokedError.
Verify:
pnpm --filter @carbon/ee test -- connections
pnpm exec turbo run typecheck --filter=@carbon/ee
# Expected: all tests pass, including the concurrent-refresh test; no type errors.
Out of scope: touching persistIntegrationSecrets / resolveIntegrationSecrets or
SECRET_KEYS. The 12 existing integrations keep their own path.
Task 9: OAuth connect and callback routes
Depends on: Tasks 3, 8
Files:
- Create:
apps/erp/app/routes/api+/integrations.connections.$piece.connect.ts - Create:
apps/erp/app/routes/api+/integrations.connections.callback.ts - Modify:
apps/erp/app/utils/path.ts— add the two route paths next to the existingintegrationsentries around line 122 - Copy from (precedent):
apps/erp/app/routes/api+/integrations.slack.install.ts(the install loader shape) andapps/erp/app/routes/api+/integrations.onshape.oauth.ts(the callback:requirePermissions(request, { update: "settings" }),export const config = { runtime: "nodejs" }, theconnectionFailedredirect helper, and the rule that a failure redirects to the integrations page with an error code rather than returning JSON)
Steps:
- Connect loader. Takes
?name=<connection name>and the$pieceroute param. Requires{ update: "settings" }. Builds the consent URL from the piece's own OAuth2 declaration (getPieceOAuth2Auth) —authUrlandscope— plusGOOGLE_OAUTH_CLIENT_IDandGOOGLE_OAUTH_REDIRECT_URL, withresponse_type=code,access_type=offline,prompt=consent(needed for Google to return a refresh token) and a signedstate. Returns{ url }, matching the Slack install route's contract so the client opens it in a popup. statemust be signed and verified. Sign{ companyId, pieceName, name, userId, nonce }with an existing server secret; the callback rejects anything that fails verification, is older than 10 minutes, or whosecompanyIddoes not match the session. This is the control that stops a token being planted into another company's connection — it is not optional and must not be reduced to an unsigned query parameter.- Callback loader. Mirrors the Onshape callback: handle a
?error=denial first, then parse withoAuthCallbackSchemafromapps/erp/app/modules/shared/shared.models.ts, then verifystate. Exchange the code at the piece'stokenUrlserver-side withGOOGLE_OAUTH_CLIENT_SECRET. CallcreateConnectionwith a service-role client (getCarbonServiceRolefrom@carbon/auth/client.server). Fetch the account label (the connected email) if the token response carries it; otherwise leave it null. - Log parameter names only on a malformed callback, never values —
codeis a live credential. The Onshape route's comment states this; keep it. - On success, redirect to
path.to.integrations; the popup-closing behaviour follows Slack'sapp_oauth_completedpostMessageconvention inpackages/ee/src/slack/config.tsx.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: no type errors. (The app package is named `erp`, not `@carbon/erp` — a wrong
# filter silently passes.)
Manual: from Settings → Integrations, click Connect on Google Calendar, complete consent, and
confirm a row appears in integrationConnection with secretRef set and no token in metadata.
Out of scope: any change to the Slack, Onshape, Jira, QuickBooks or Xero OAuth routes.
Task 10: Settings → Integrations connections panel
Depends on: Task 9
Files:
- Create:
apps/erp/app/modules/settings/ui/Integrations/ConnectionsPanel.tsx - Modify:
apps/erp/app/modules/settings/ui/Integrations/IntegrationsList.tsx— list allowlisted pieces alongside the existing integrations - Modify:
apps/erp/app/routes/x+/settings+/integrations.$id.tsx— load connections for a piece - Copy from (precedent):
apps/erp/app/modules/settings/ui/Integrations/IntegrationCard.tsxfor the card, andapps/erp/app/modules/settings/ui/Integrations/SyncActivity.tsxfor a list-inside-an-integration-detail layout
Steps:
- Add allowlisted pieces to the integrations grid as cards using the same
IntegrationCardcomponent. A piece whose OAuth env vars are absent renders disabled with "Not configured on this server" — the same treatmentdefineIntegration's computedactivegives an integration with no client id. ConnectionsPanellists that company's connections for the piece: name, connected account, status badge,lastErrorwhen present, and per-row Rename and Disconnect. A "Connect" button opens the Task 9 connect URL in a popup (copy the popup code frompackages/ee/src/slack/config.tsx, including theapp_oauth_completedlistener).- Connecting asks for a name first, defaulting to the piece label, and rejects a duplicate name in the same company with the message the unique constraint implies.
- Use existing components only — grep
packages/react/src/andapps/erp/app/components/before writing any new UI primitive.
Verify:
pnpm exec turbo run typecheck --filter=erp
pnpm exec biome check
# Expected: no type errors; no new error-severity biome findings (pre-existing warnings stay).
Manual: the Google Calendar card appears, connects, and shows two differently-named connections.
Out of scope: redesigning the integrations page, or changing how the 12 existing integrations render.
Task 11: The integration action executor
Depends on: Tasks 7, 8
Files:
- Create:
packages/jobs/src/workflows/integrations/context.ts - Create:
packages/jobs/src/workflows/actions/integration.ts - Create:
packages/jobs/src/workflows/actions/integration.test.ts - Modify:
packages/jobs/src/workflows/actions/services.ts— one new branch inrunAction - Copy from (precedent):
packages/jobs/src/workflows/actions/webhook.ts(an outbound action returningActionOutcome) and the existingroute.update/route.callbranches inservices.ts
Steps:
context.tsexportsbuildPieceContext({ auth, propsValue })returning the object the spike proved sufficient:auth,propsValue, plusstore,connections,project,flows,step,files. Every stub throws a named error when called, rather than returning empty — a piece that genuinely needs one must fail loudly in development, not misbehave in production.integration.tsexportsrunIntegrationAction({ client, companyId, pieceName, actionName, inputs }): pullconnectionIdout ofinputs;resolveConnectionAuth; map the remaining inputs withtoPropsValue;getPieceAction; callrun(buildPieceContext(...)); return{ ok: true, outputs: { result } }.- Every failure returns
{ ok: false, error }with a sentence a customer can act on, following the existing constants at the top ofservices.ts(GONE,NO_DISPATCH,UNKNOWN_RESULT):- no
connectionId→"This step needs a connection." ConnectionRevokedError→"The <label> connection needs to be reconnected."- refresh failure → the same reconnect sentence
- a vendor error → the vendor's message, truncated, prefixed
"<label> rejected this: "
- no
- In
services.ts#runAction, add the branch before theroute.update/route.callbranches and route it offroute.piece, never off the id's shape — the existing comment in that file states the rule. - Confirm
redactForLoginpackages/jobs/src/workflows/engine/ledger.tsalready redacts the keys a piece auth object uses (access_token,refresh_token,client_secretall match its regex). Add a test asserting a step's recordedinputcontains no token. If any key escapes the regex, widen the regex rather than filtering at this call site. integration.test.tscovers: a successful run with a stubbed piece; each failure sentence; and the redaction assertion.
Verify:
pnpm --filter @carbon/jobs test -- integration
pnpm exec turbo run typecheck --filter=@carbon/jobs
# Expected: all tests pass; no type errors.
Out of scope: triggers, and any non-OAuth2 auth variant. Both are Non-goals for v1.
Task 12: Smart-dropdown options endpoint
Depends on: Tasks 5, 8
Files:
- Create:
apps/erp/app/routes/api+/integrations.connections.options.ts - Copy from (precedent):
apps/erp/app/routes/api+/integrations.quickbooks.accounts.ts(a resource route that fetches a remote list for a picker)
Steps:
- Action/loader takes
{ pieceName, actionName, propName, connectionId }plus the node's current input values (a dropdown'srefreshersmay name other props). - Gate with
requirePermissions(request, { update: "workflows" })— the same permission the action itself carries, so the endpoint cannot be used to reach a vendor a user could not otherwise call. - Resolve fresh auth via
resolveConnectionAuth, load the property from the piece, and call itsoptions({ auth, propsValue }). Return{ options: [{ label, value }] }. - Never echo the auth value back in the response or in an error message.
- On failure return
{ options: [], error }with a short sentence — the builder shows it inline rather than blocking the form.
Verify:
pnpm exec turbo run typecheck --filter=erp
# Expected: no type errors.
Manual: with a connection in place, request the route for calendar_id and confirm it returns
the connected account's real calendars.
Out of scope: caching. If the vendor rate-limits, handle it in a follow-up.
Task 13: Builder — connection picker and dynamic options
Depends on: Task 12
Files:
- Modify:
apps/erp/app/modules/workflows/ui/Builder/fields/recordPickers.tsx— add a connection picker for theconnectionIdinput - Modify:
apps/erp/app/modules/workflows/ui/Builder/fields/choiceOptions.tsx— fetch options from the Task 12 route when an input is markeddynamicOptions - Modify:
apps/erp/app/modules/workflows/ui/Builder/NodePalette.tsx— group ids startingintegration.under an "Integrations" heading - Copy from (precedent): the existing pickers in
recordPickers.tsxand the existing static choice rendering inchoiceOptions.tsx
Steps:
- The connection picker lists the company's connections for the action's piece (read the piece
name off the catalog entry's
pieceblock). With none, it renders an inline link to Settings → Integrations rather than an empty dropdown. - A
dynamicOptionsinput renders as a select that fetches from/api/integrations/connections/optionsonce a connection is chosen, with a visible loading state and a plain error state:"Couldn't load options — check the connection." - Refetch when the chosen connection changes. Reset the field's value on connection change — a calendar id from one account is meaningless in another.
- Add no new UI primitive; use what
fields/already has.
Verify:
pnpm exec turbo run typecheck --filter=erp
npx vitest run apps/erp/app/modules/workflows
# Expected: no type errors; existing builder tests still pass.
Manual: add "Google Calendar: Create Event" to a workflow; the connection picker lists your connection and the calendar dropdown lists real calendars.
Out of scope: changing how Carbon's own actions render. The generic field renderers are shared — a regression there breaks all 16 existing actions.
Task 14: End-to-end verification
Depends on: all previous tasks
Files: none created; this task only runs and records.
Steps:
- Run the full gate set:
pnpm run generate:workflow-catalog pnpm run check:workflow-catalog pnpm exec biome check pnpm exec turbo run typecheck --filter=@carbon/workflows --filter=@carbon/jobs --filter=@carbon/ee --filter=erp pnpm --filter @carbon/workflows test pnpm --filter @carbon/jobs test pnpm --filter @carbon/ee test - Walk the spec's Acceptance Criteria list in order, in the running app, and record the result
of each in
.ai/runs/2026-08-27-workflow-integrations.md. The criteria that need a browser: connect a Google account; add a second named connection; reject a duplicate name; build the node and see real calendars; missing connection blocks activation; a real trigger creates a real calendar event; the run history shows Succeeded with no token ininput/output; an expired token refreshes once; a disconnected connection fails the run with the reconnect message and recovers after reconnecting without editing the workflow. - Record any criterion that could not be verified, and why. Do not mark the plan complete with an unverified criterion silently dropped.
Verify:
pnpm exec turbo run typecheck --filter=@carbon/workflows --filter=@carbon/jobs --filter=@carbon/ee --filter=erp
# Expected: all four packages typecheck clean.
Out of scope: a whole-repo pnpm run build — the repo-wide typecheck OOMs, which is why the
scoped filters above are used instead.
Notes for the executor
- Never use
npm. Alwayspnpm. - Never hand-edit
packages/database/src/types.tsor any*.generated.ts— regenerate. - Run
pnpm run generate:typesafter the migration and before any typecheck that touches the new table. apps/erpsits near TypeScript's instantiation budget; if a new type surface trips TS2589 in an unrelated file, prefer flat selects and verify with a directtsgorun rather than the turbo cache.- Do not commit anything without explicit permission from the user.