Commit 13cfebe
Ricardo DeMatos
feat(managed-agent): Claude Platform Managed Agents workflow blocks
Ship two workflow blocks that let a workflow author invoke a Claude
Platform Managed Agent (cloud or self-hosted) as a first-class node,
plus the workspace-scoped connection layer that stores the linked
Anthropic API key.
Blocks
- **Claude Managed Agents** (`managed_agent_cloud`) — cloud
environments. Session-create payload carries `agent`,
`environment_id`, `vault_ids`, `resources` (memory + files) and
free-form `metadata` tags.
- **Claude Managed Agents (self-hosted)** (`managed_agent_self_hosted`)
— self-hosted environments. Session `metadata` is forwarded as
env vars to the deployer's self-hosted agent sandbox; the memory
fields are gated behind
`NEXT_PUBLIC_MANAGED_AGENT_SELF_HOSTED_MEMORY_ENABLED` because
Claude self-hosted environments do not currently support the
memory-store resource attach on the session API. Default seed
rows for the Session-parameters table come from
`NEXT_PUBLIC_MANAGED_AGENT_SELF_HOSTED_DEFAULTS` (JSON object);
the seeded keys stay out of source so this block is deployment-
neutral in the public tree.
Connections
- New `managed_agent_connection` table (workspace-scoped, encrypted
API key). All CRUD paths go through
`getUserEntityPermissions(userId, 'workspace', workspaceId)`;
`admin`/`write` to create, rotate, or delete; any workspace
member can list/browse. Plaintext keys never cross the client
boundary — list responses return only a masked preview.
- Settings surface under `settings/components/managed-agents/` lets
admins add / rotate / remove connections with an inline
Anthropic-API verify (`GET /v1/agents`).
- 8 server routes proxy the Claude Platform read endpoints (agents,
environments, memory stores, vaults, environment detail) so the
block picker resolves options against the linked workspace.
Tool + session client
- `tools/managed_agent/run_session.ts` (client-safe skeleton) +
`run_session.server.ts` (server-only impl, self-registered on
boot via `globalThis` so the client bundle never pulls
`postgres` / `fs` / encryption). Reconnect + `events.list`
catch-up loop matches the docs' two-step session lifecycle.
- `lib/managed-agents/session-client.ts` — the reusable HTTP
client that shapes the cloud vs. self-hosted request bodies.
- `tools/managed_agent/normalizers.ts` — pure input normalizers
that coerce the workflow block's runtime shapes (table rows,
JSON strings, flat objects, comma-lists) into typed values.
Node UX
- Optional `BlockConfig.nodeWidth` (default 250, MA blocks use 400)
threaded through `calculateWorkflowBlockDimensions` for both the
workflow-block hook and autolayout so long Anthropic IDs are not
ellipsis-truncated in the collapsed row.
- Friendly-name hydration on the collapsed row resolves connection
/ agent / environment / vault / memory-store IDs to human labels
via the React Query hooks. New `blockType` prop on `SubBlockRow`
gates the lookup.
- New optional `defaultRows` prop on the `Table` subblock so any
block can seed a fresh table with initial rows.
Test coverage
Aligned with the repo's existing patterns (`@vitest-environment
node`, `vi.hoisted` + `vi.mock` + static imports, `@sim/testing`
helpers). 86 tests across 5 files:
- `tools/managed_agent/normalizers.test.ts` (27) — every shape the
block subblocks hand off + bad-input paths.
- `lib/managed-agents/session-client.test.ts` (17) — cloud vs.
self-hosted branch: memory routing (resource vs. metadata),
file resources cloud-only, `vault_ids` only when non-empty,
user metadata does not overwrite memory keys, envType-omitted
default.
- `lib/managed-agents/connections.test.ts` (17) — CRUD via
captured DB-chain args: encryption on write (plaintext never
lands in row), masking on read, workspace-scoped `WHERE` on
every op, `verify` gate blocks persistence, error truncation
to 500 chars.
- `app/api/managed-agent-connections/route.test.ts` (15) —
permission gates on GET/POST/DELETE: 401 unauthenticated,
400 missing params, 403 read-tier callers on create/delete,
404 for missing rows, plaintext never in POST response, both
`write` and `admin` accepted.
- `blocks/blocks/managed_agent_self_hosted.test.ts` (10) —
env-driven `readSessionMetadataDefaults` and
`isSelfHostedMemoryEnabled` (truthy/falsy/whitespace forms).
Documentation
- New env vars documented in `apps/sim/.env.example`:
`MANAGED_AGENT_DEBUG_PAYLOAD`,
`NEXT_PUBLIC_MANAGED_AGENT_SELF_HOSTED_DEFAULTS`,
`NEXT_PUBLIC_MANAGED_AGENT_SELF_HOSTED_MEMORY_ENABLED`.1 parent 4ddad74 commit 13cfebe
49 files changed
Lines changed: 22435 additions & 12 deletions
File tree
- apps/sim
- app
- api/managed-agent-connections
- [id]
- agents
- environments
- [envId]
- memory-stores
- vaults
- workspace/[workspaceId]
- settings
- [section]
- components/managed-agents
- w/[workflowId]/components
- panel/components/editor/components/sub-block
- components/table
- workflow-block
- blocks
- blocks
- components
- settings
- hooks/queries
- lib
- api/contracts
- core/config
- managed-agents
- workflows
- autolayout
- blocks
- tools
- managed_agent
- packages/db
- migrations
- meta
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
Lines changed: 89 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
Lines changed: 102 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
Lines changed: 96 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments