Skip to content

feat(custom-blocks): add deploy_custom_block copilot tool#5532

Open
TheodoreSpeaks wants to merge 8 commits into
stagingfrom
feat/custom-block-mothership
Open

feat(custom-blocks): add deploy_custom_block copilot tool#5532
TheodoreSpeaks wants to merge 8 commits into
stagingfrom
feat/custom-block-mothership

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • new deploy_custom_block copilot tool handler: the deploy agent can publish a deployed workflow as an org-wide custom block, update it in place (re-deploy upserts), or unpublish with action: undeploy
  • same gates as the REST routes: workspace admin via ensureWorkflowAccess (denied → clean "requires admin permission" message), deploy-as-block flag, enterprise plan; audit events recorded with source: copilot
  • iconUrl accepts a workspace file VFS path (files/icon.png) — bytes are copied into the public workspace-logos context (key prefixed so the serve route treats it as public) so the icon renders org-wide; external URLs pass through
  • entitlements: new computeWorkspaceEntitlements(workspaceId, userId) (flag + enterprise → ['custom-blocks'], 5s promise cache) sent as entitlements in every mothership payload — interactive chat (both branches), /api/mothership/execute (executor block + scheduled tasks), and the inbox executor. The Go side hides the custom-block tool/prompt/skill entirely when absent; fail-closed
  • eligibleOrgForWorkspace now takes an optional userId so per-user flag targeting matches the REST routes
  • synced tool catalog from the copilot repo (adds DeployCustomBlock; regen formatting churn in tool-schemas-v1.ts is from the current generator)
  • new getCustomBlockWithInputsByWorkflowId operation + shared row-hydration helper

Companion PR simstudioai/mothership#346 adds the tool definition, deploy agent wiring, entitlement gating, prompts, and skill — this handler is inert until that ships.

Type of Change

  • New feature

Testing

Tested manually end-to-end via Chat (published a block with a generated icon, verified render + upsert). 15 handler tests incl. icon ingestion + permission errors, payload pass-through tests. lint, type-check, and check:api-validation:strict pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Companion: simstudioai/mothership#346

@TheodoreSpeaks TheodoreSpeaks requested a review from a team as a code owner July 9, 2026 02:58
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 10, 2026 12:54am

Request Review

@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches deployment and plan-gated copilot capabilities; real authorization depends on sim tool handlers because mothership entitlement gating is advertisement-only until the companion Go PR ships.

Overview
Adds a deploy_custom_block copilot tool so agents can publish a deployed workflow as an org custom block, update it in place, or unpublish via action: undeploy. The sim handler enforces the same rules as REST (workspace admin, deploy-as-block flag, enterprise on first publish), re-validates at execution time, records audit events, and can copy files/... icons into public workspace-logos storage.

Introduces computeWorkspaceEntitlements and threads an optional entitlements array (e.g. custom-blocks) through mothership payloads—interactive chat, /api/mothership/execute, and inbox—so Go can hide tools/prompts when absent; empty arrays omit the field. buildCopilotRequestPayload and custom-block ops gain isCustomBlocksEligible / getCustomBlockWithInputsByWorkflowId with optional userId for flag targeting aligned with REST.

Tool catalog/schemas sync adds DeployCustomBlock; xlsx moves to npm:@e965/xlsx@0.20.3.

Reviewed by Cursor Bugbot for commit 1ef3e8d. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds copilot support for deploying workflows as custom blocks. The main changes are:

  • New deploy_custom_block tool catalog entry and server handler.
  • Entitlement propagation in chat, execute, and inbox mothership payloads.
  • Custom-block workflow lookup and shared hydration helpers.
  • Workspace-file icon ingestion into public icon storage.
  • Tests for deployment, undeploy, permissions, entitlement payloads, and validation.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/handlers/deployment/custom-block.ts Adds the custom-block deploy handler with permission, feature, plan, icon, and persisted-field validation.
apps/sim/lib/copilot/entitlements.ts Adds cached workspace entitlement evaluation for mothership payloads.
apps/sim/lib/workflows/custom-blocks/operations.ts Adds custom-block workflow lookup and reuses shared row hydration.
apps/sim/lib/copilot/tool-executor/register-handlers.ts Registers the new custom-block deployment handler.

Reviews (5): Last reviewed commit: "fix(custom-blocks): enterprise gate appl..." | Re-trigger Greptile

Comment thread apps/sim/lib/copilot/tools/handlers/deployment/custom-block.ts
Comment thread apps/sim/lib/copilot/tools/handlers/deployment/custom-block.ts
The dependency was pinned to a direct tarball on cdn.sheetjs.com, which
now returns 403 (Cloudflare bot-challenge) to automated clients, breaking
bun install in CI. npm's own xlsx is frozen at 0.18.5, so switch to the
@e965/xlsx mirror which republishes the identical 0.20.3 CDN build to the
npm registry. No code changes needed — all imports use bare 'xlsx'.
Comment thread apps/sim/lib/copilot/tools/handlers/deployment/custom-block.ts
@github-actions github-actions Bot added the requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep label Jul 10, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Cross-repo companion check

One or more companion PRs aren't merged into staging yet. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.

  • simstudioai/mothership#346OPEN, not merged (targets staging) — feat(deploy): add deploy_custom_block tool, skill, and prompts

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

Comment thread apps/sim/lib/copilot/tools/handlers/deployment/custom-block.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

Comment thread apps/sim/lib/copilot/tools/handlers/deployment/custom-block.ts
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0b2184b. Configure here.

description: `Updated custom block "${updated.name}"`,
metadata: { organizationId, type: updated.type, workflowId, source: 'copilot' },
})
return { success: true, output: { ...customBlockOutput(updated, 'deploy'), updated: true } }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enterprise gate blocks republish

Medium Severity

The copilot handler requires an enterprise plan for every deploy action, including updates to an already-published block. The REST PATCH /api/custom-blocks/[id] route only checks the deploy-as-block flag and workspace admin, so admins can still edit existing blocks after the org leaves enterprise while deploy_custom_block republish fails with an enterprise error.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0b2184b. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant