@agent-compose/sdk 0.5.7 → 0.5.9
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/agent/__tests__/run-agent-liveness.test.d.ts +17 -0
- package/dist/agent/agent-context.d.ts +67 -0
- package/dist/agent/agent-loop.d.ts +23 -12
- package/dist/agent/local-pause-request.d.ts +49 -0
- package/dist/agent/local-pause-request.test.d.ts +1 -0
- package/dist/agent/steer-control.d.ts +22 -6
- package/dist/client.d.ts +76 -2
- package/dist/index.d.ts +10 -5
- package/dist/index.js +2409 -1457
- package/dist/pause/checkpoint.d.ts +27 -10
- package/dist/pause/manager.d.ts +1 -0
- package/dist/pause/pause-core.d.ts +23 -0
- package/dist/pause/state-dir.d.ts +1 -1
- package/dist/pause/wrappers.d.ts +7 -11
- package/dist/processors/builtins.d.ts +20 -1
- package/dist/processors/index.d.ts +1 -1
- package/dist/processors/processor.d.ts +13 -0
- package/dist/runtimes/_acp-client.d.ts +140 -0
- package/dist/runtimes/_cli-agent.d.ts +155 -3
- package/dist/runtimes/amp.d.ts +2 -2
- package/dist/runtimes/cli-agent-acp-live.test.d.ts +30 -0
- package/dist/runtimes/cli-agent.test.d.ts +22 -6
- package/dist/runtimes/codex.d.ts +7 -2
- package/dist/runtimes/openai-desktop.js +2394 -1457
- package/dist/runtimes/vercel.js +389 -2
- package/dist/sandbox.d.ts +132 -14
- package/dist/step-invocation/types.d.ts +1 -1
- package/dist/types/__tests__/environment-build-flag.test.d.ts +1 -0
- package/dist/types/__tests__/workflow-metadata-provider.test.d.ts +1 -0
- package/dist/types/execution-context.d.ts +1 -11
- package/dist/types/protocol.d.ts +32 -1
- package/dist/types/runtime.d.ts +7 -0
- package/dist/types/sandbox-environment.d.ts +6 -1
- package/dist/types/sandbox.d.ts +41 -6
- package/dist/types/workflow-metadata.d.ts +47 -6
- package/dist/types/workflow.d.ts +27 -4
- package/dist/utils/bundler.d.ts +7 -1
- package/dist/workflow-steps/observability.d.ts +28 -2
- package/dist/workflow-steps/types.d.ts +11 -7
- package/dist/workflow-steps/workflow.d.ts +5 -1
- package/package.json +3 -2
- package/src/agent/agent-context.ts +220 -0
- package/src/agent/agent-loop.ts +90 -22
- package/src/agent/local-pause-request.ts +90 -0
- package/src/agent/run-agent.ts +43 -3
- package/src/agent/steer-control.ts +21 -7
- package/src/client.ts +123 -2
- package/src/index.ts +16 -4
- package/src/pause/checkpoint.ts +33 -14
- package/src/pause/manager.ts +2 -2
- package/src/pause/pause-core.ts +35 -0
- package/src/pause/state-dir.ts +2 -2
- package/src/pause/wrappers.ts +7 -21
- package/src/processors/builtins.ts +44 -1
- package/src/processors/index.ts +1 -0
- package/src/processors/processor.ts +13 -0
- package/src/runtimes/_acp-client.ts +516 -0
- package/src/runtimes/_cli-agent.ts +418 -3
- package/src/runtimes/claude.ts +27 -3
- package/src/runtimes/codex.ts +21 -1
- package/src/runtimes/vercel.ts +4 -1
- package/src/sandbox.ts +429 -67
- package/src/step-invocation/types.ts +1 -1
- package/src/types/execution-context.ts +1 -11
- package/src/types/protocol.ts +27 -1
- package/src/types/runtime.ts +7 -0
- package/src/types/sandbox-environment.ts +12 -1
- package/src/types/sandbox.ts +40 -6
- package/src/types/workflow-metadata.ts +51 -6
- package/src/types/workflow.ts +27 -6
- package/src/utils/bundler.ts +9 -1
- package/src/workflow-steps/observability.ts +51 -5
- package/src/workflow-steps/runner.ts +9 -5
- package/src/workflow-steps/types.ts +11 -7
- package/src/workflow-steps/workflow.ts +5 -1
- package/src/workflows/invoke-child.ts +7 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* run-agent working-dir liveness probe (the degraded-FUSE-wedge fix).
|
|
3
|
+
*
|
|
4
|
+
* `agent()` delivers the platform context file (AGENTS.md / CLAUDE.md /
|
|
5
|
+
* GEMINI.md) to the working dir AND uses that write as a bounded liveness
|
|
6
|
+
* probe of the dir. AGENT_COMPOSE_RUN_DIR points at the /factory FUSE drive,
|
|
7
|
+
* whose writes HANG uninterruptibly (no timeout) when the mount degraded —
|
|
8
|
+
* launching the agent there wedges it silently with zero output. The probe
|
|
9
|
+
* bounds the write at 15s and falls back to /workspace (always present +
|
|
10
|
+
* writable) when the run dir is wedged.
|
|
11
|
+
*
|
|
12
|
+
* These tests pin: (1) the happy path keeps RUN_DIR; (2) a RUN_DIR whose write
|
|
13
|
+
* hangs forever still selects /workspace within the deadline. `agentLoop` is
|
|
14
|
+
* mocked so we observe only the `cwd` the loop is launched with; fake timers
|
|
15
|
+
* drive the 15s deadline without waiting in real time.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness-agnostic agent context delivery.
|
|
3
|
+
*
|
|
4
|
+
* Every coding-agent harness we drive (Claude Code, Codex, Amp, Gemini, …)
|
|
5
|
+
* looks for an instruction file in its working directory — but they disagree
|
|
6
|
+
* on the NAME (Codex/Amp read `AGENTS.md`; Claude reads `CLAUDE.md`; Gemini
|
|
7
|
+
* reads `GEMINI.md`). So `agent()` writes the SAME platform manual under all
|
|
8
|
+
* three names at the agent's working dir, and every harness finds the one it
|
|
9
|
+
* knows. The manual is the single source of truth here; `base-env` bakes a
|
|
10
|
+
* static copy at `/workspace/AGENTS.md` for plain shell sessions, but the
|
|
11
|
+
* per-run copy `agent()` writes is the authoritative one — it carries the
|
|
12
|
+
* live connector list and lands at the run's working dir.
|
|
13
|
+
*/
|
|
14
|
+
import type { SandboxProvider } from "../types/sandbox.js";
|
|
15
|
+
/**
|
|
16
|
+
* The platform manual delivered to every agent, regardless of harness.
|
|
17
|
+
* Covers the three things an agent must know: where files go (the factory
|
|
18
|
+
* drive + the persist-by-default working dir), how to pause for a human, and
|
|
19
|
+
* that credentials are network-injected (never in the env). The live
|
|
20
|
+
* "Connectors & access" section is appended per-run by `buildAgentContextDoc`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const AGENT_COMPOSE_MANUAL = "# Working inside an Agent Compose sandbox\n\nYou are an agent running in a per-run sandbox on the Agent Compose platform.\nUse the **`agentc` CLI** and the **`@agent-compose/sdk`** for everything below \u2014\ndo NOT hand-roll raw HTTP/curl calls against the platform API. The CLI is on\nyour PATH and already authenticated from the environment\n(`AGENT_COMPOSE_URL` / `AGENT_COMPOSE_API_KEY` / `AGENT_COMPOSE_FACTORY` are\ninjected for this run), so commands just work \u2014 no login, no keys to manage.\n\nThe `/ac:*` skills are installed as Claude Code slash commands (`/ac:invoke`,\n`/ac:events`, `/ac:logs`, `/ac:register`, \u2026) \u2014 reach for them too.\n\n## Files \u2014 your outputs persist by default\n\nYour working directory defaults to **`$AGENT_COMPOSE_RUN_DIR`** \u2014 a per-run\ndirectory on the shared factory drive\n(`$AGENT_COMPOSE_FACTORY_DIR/<workflow>/<version>/<run-id>/`) the platform\ncreates and attributes to this run. **Files you write here persist by\ndefault** \u2014 they show up in the dashboard's Files tab and the run's Artifacts\ncard, with no API calls to save them. The dir already exists and is writable.\n\nNeed throwaway scratch \u2014 heavy build output, package caches, temp files?\n`cd /tmp` (or any path outside `/factory`): anything off the factory drive is\nephemeral and discarded when the sandbox ends. In short: **stay in your working\ndir to keep something, `cd` out to throw it away.**\n\nThe whole shared drive is POSIX-mounted at `/factory`; the dashboard-visible\nroot is `$AGENT_COMPOSE_FACTORY_DIR` (`/factory/files`). Earlier versions and\nruns live in sibling dirs under\n`$AGENT_COMPOSE_FACTORY_DIR/$AGENT_COMPOSE_WORKFLOW/` \u2014 read them for prior\ncontext. Other workflows' dirs are present but not your concern.\n\n## Events \u2014 the factory timeline\n\nRecord something on the run/factory timeline (the dashboard renders these)\nwith the CLI \u2014 your run id is `$RUN_ID`:\n\n agentc events send \"$RUN_ID\" <name> --summary \"<one line>\" [--body '<json>']\n\nNames like `note.created` / `brief.posted` surface in the Workbench;\n`agentc events list` reads them back. `/ac:events` is the skill equivalent.\n\n## Runs\n\n agentc list # registered workflows (/ac:list)\n agentc logs \"$RUN_ID\" # a run's logs (/ac:logs)\n agentc invoke <workflow> -i '<json>' # dispatch a workflow (/ac:invoke)\n\n## Writing workflow / agent code \u2014 the SDK\n\n`@agent-compose/sdk` is installed in `/workspace` \u2014 import it from any script\nyou write there:\n\n import { defineWorkflow, agent, AgentComposeClient } from \"@agent-compose/sdk\";\n\nUse `/ac:generate-workflow` / `/ac:generate-agent` to scaffold, then\n`agentc register <file.ts>` (or `/ac:register`).\n\n## Pausing to ask the human \u2014 `agentc pause`\n\nWhen you can't or shouldn't proceed without a human, run `agentc pause`, then\n**END YOUR TURN**:\n\n agentc pause --reason \"Notion returned 401 \u2014 connect Notion to continue\" \\\n --option retry --option skip\n\n`agentc pause` does NOT block and does NOT print the answer. It records your\nquestion and returns immediately. The moment you end your turn, the run pauses\n(your sandbox is snapshotted and compute stops while the human decides) and the\nhuman's answer is delivered to you as your **next message** \u2014 you pick up\nexactly where you left off, with the answer in hand. So: ask, end your turn,\nand wait. Do NOT keep working, do NOT call more tools, and do NOT mark the task\ncomplete after pausing.\n\nReach for it the moment you hit \u2014 or foresee \u2014 any of these:\n- **A wall only a human can clear:** a 401/403, a missing credential, an\n unconnected provider, a host the network refuses. Do NOT retry blindly or try\n to work around it \u2014 pause and say what needs enabling.\n- **A durable or outward-facing action that needs sign-off:** registering a\n workflow, deploying, sending email/messages, deleting or overwriting shared\n data, spending money. Prepare everything, then pause for approval BEFORE you\n commit it.\n- **A judgment call only the human can settle:** an under-specified request,\n several valid paths, a conflict with existing state, missing input only they have.\n\nYou compose the `--reason` (the ask) yourself; pass `--option` choices when\nthere are clear ones, omit them for a free-form answer. Each agent pauses\nindependently \u2014 pausing doesn't stop the others.\n\n## Credentials\n\nConnector credentials (Google, GitHub, \u2026) are NEVER in your environment.\nThey're injected at the network layer when you call an allowed host \u2014 make the\nrequest **without** an Authorization header and the platform adds it. Don't try\nto read or exfiltrate tokens; they aren't here. The \"Connectors & access\"\nsection below (when present) lists exactly which providers this run can reach.\n\n## Tools in this environment\n\n- `agentc` \u2014 Agent Compose CLI (your primary interface; authed from env)\n- `@agent-compose/sdk` \u2014 installed in /workspace for writing workflows\n- `/ac:*` Claude Code skills \u2014 slash commands for the above\n- `archil` (factory drive), `rtk`, `bun`\n- A world-writable `/workspace` working directory";
|
|
23
|
+
/**
|
|
24
|
+
* One connector this run can reach, as the agent should see it. Strictly
|
|
25
|
+
* NON-SECRET — hosts, methods, paths, identity only. The access token is
|
|
26
|
+
* injected at the network layer and never appears here. The server builds
|
|
27
|
+
* this list at dispatch from the run's connector grants × the provider
|
|
28
|
+
* catalogue and delivers it as the `AGENT_COMPOSE_CONNECTORS` env (JSON array).
|
|
29
|
+
*/
|
|
30
|
+
export interface AgentConnectorInfo {
|
|
31
|
+
/** Provider key (`github`, `notion`, …). */
|
|
32
|
+
provider: string;
|
|
33
|
+
/** Human label ("GitHub", "Notion"). */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** API hosts the credential is injected for. */
|
|
36
|
+
hosts?: string[];
|
|
37
|
+
/** Allowed HTTP methods (Tier-2 narrowing). Empty/absent = any. */
|
|
38
|
+
methods?: string[];
|
|
39
|
+
/** Allowed path prefixes (Tier-2 narrowing). Empty/absent = any. */
|
|
40
|
+
pathPrefixes?: string[];
|
|
41
|
+
/** GitHub: the repository the minted token is scoped to. */
|
|
42
|
+
repository?: string;
|
|
43
|
+
/** Coarse capability the token was minted with. */
|
|
44
|
+
access?: string;
|
|
45
|
+
/** Human scope descriptions, when the provider declares them. */
|
|
46
|
+
scopes?: string[];
|
|
47
|
+
}
|
|
48
|
+
/** Compose the full per-run agent doc: the static manual + the live
|
|
49
|
+
* connectors section read from `AGENT_COMPOSE_CONNECTORS` (a JSON array;
|
|
50
|
+
* malformed/absent → no section). */
|
|
51
|
+
export declare function buildAgentContextDoc(env: Record<string, string | undefined>): string;
|
|
52
|
+
/**
|
|
53
|
+
* Write the platform context at the agent's working dir under every harness's
|
|
54
|
+
* instruction-file name, so whichever CLI runs finds the one it reads. Codex
|
|
55
|
+
* and Amp read `AGENTS.md` natively; Claude reads `CLAUDE.md`; Gemini reads
|
|
56
|
+
* `GEMINI.md` — we write identical content to all three rather than detect the
|
|
57
|
+
* harness (the runtime's `kind` isn't known until after spawn, and a few extra
|
|
58
|
+
* small files in our own run dir are harmless).
|
|
59
|
+
*
|
|
60
|
+
* Best-effort: a write failure logs and is swallowed — never fail an agent
|
|
61
|
+
* because its context file couldn't be written.
|
|
62
|
+
*/
|
|
63
|
+
export declare function writeAgentContext(args: {
|
|
64
|
+
sandbox: Pick<SandboxProvider, "files">;
|
|
65
|
+
cwd: string;
|
|
66
|
+
env: Record<string, string | undefined>;
|
|
67
|
+
}): Promise<void>;
|
|
@@ -6,8 +6,10 @@ import type { RuntimeOptions, ModelExecutionContract } from "../index.js";
|
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import type { AgentStatus, AgentMessage } from "./protocol.js";
|
|
8
8
|
import type { Processor } from "../processors/processor.js";
|
|
9
|
+
import { type BoundaryPauseFn } from "../pause/pause-core.js";
|
|
9
10
|
import { RequestContext } from "../request-context/request-context.js";
|
|
10
11
|
import { type SteerPayload } from "./steer-control.js";
|
|
12
|
+
import { type LocalPauseRequest } from "./local-pause-request.js";
|
|
11
13
|
export declare const DEFAULT_CLAUDE_MODEL = "claude-fable-5";
|
|
12
14
|
export declare function parseAgentStatus(text: string): AgentStatus | null;
|
|
13
15
|
export interface AgentLoopResult<TResponse = unknown> {
|
|
@@ -46,12 +48,20 @@ export type AgentMessageSummary = {
|
|
|
46
48
|
cacheCreationTokens: number;
|
|
47
49
|
durationMs: number;
|
|
48
50
|
numTurns: number;
|
|
51
|
+
model?: string;
|
|
49
52
|
} | {
|
|
50
53
|
type: "done";
|
|
51
54
|
sessionId: string;
|
|
52
55
|
} | {
|
|
53
56
|
type: "error";
|
|
54
57
|
text: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "plan";
|
|
60
|
+
entries: {
|
|
61
|
+
content: string;
|
|
62
|
+
priority: "high" | "medium" | "low";
|
|
63
|
+
status: "pending" | "in_progress" | "completed";
|
|
64
|
+
}[];
|
|
55
65
|
};
|
|
56
66
|
export declare function summarizeAgentMessage(msg: AgentMessage): AgentMessageSummary;
|
|
57
67
|
export type AgentLifecycleEvent = {
|
|
@@ -127,23 +137,24 @@ export interface AgentLoopOpts<TResponse = unknown> {
|
|
|
127
137
|
text: string;
|
|
128
138
|
senderName?: string | null;
|
|
129
139
|
}>;
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* Absent ⇒ no
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
correlationKey?: string;
|
|
137
|
-
schema?: z.ZodType<T>;
|
|
138
|
-
}, agentScope: {
|
|
139
|
-
agentId: string;
|
|
140
|
-
iteration: number;
|
|
141
|
-
}) => Promise<T>;
|
|
140
|
+
/** The run's pause boundary. agent() builds it (a corePause closed over
|
|
141
|
+
* runId/stepIndex); the loop supplies the agentScope so the pauseId is
|
|
142
|
+
* stable across resume. Drives both PR-7 steer-pause AND a processor's
|
|
143
|
+
* `ctx.pause` (human-approval gate). Absent ⇒ no pause (local tests,
|
|
144
|
+
* non-sandbox callers). */
|
|
145
|
+
pause?: BoundaryPauseFn;
|
|
142
146
|
/** PR 7: take-once read of this agent's pending steer (set by the control
|
|
143
147
|
* poller). Returns the steer's payload (reason / correlationKey) or null.
|
|
144
148
|
* The boundary consumes it once per check, and only when no steer is
|
|
145
149
|
* already staged. */
|
|
146
150
|
consumeSteerPending?: () => SteerPayload | null;
|
|
151
|
+
/** Take-once read of a local `agentc pause` request this agent dropped in the
|
|
152
|
+
* state dir during its turn (the CLI writes it; see local-pause-request.ts).
|
|
153
|
+
* Returns the request (reason + offered options) or null. The loop turns it
|
|
154
|
+
* into a staged self-pause the next boundary takes — the same snapshot-release
|
|
155
|
+
* path as `needs_input`, but triggered by an explicit `agentc pause` call so
|
|
156
|
+
* it is honored regardless of `mode`. */
|
|
157
|
+
consumeLocalPauseRequest?: () => LocalPauseRequest | null;
|
|
147
158
|
/** PR 7: `auto` (autonomous, default) or `hitl` (can be steer-paused). The
|
|
148
159
|
* boundary is inert unless `hitl`. */
|
|
149
160
|
mode?: "auto" | "hitl";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local pause-request marker — the in-sandbox bridge from `agentc pause` to
|
|
3
|
+
* the agent loop's snapshot-release pause boundary.
|
|
4
|
+
*
|
|
5
|
+
* `agentc pause` runs as a grandchild subprocess of the runner (the agent CLI
|
|
6
|
+
* shells out to it). It cannot throw a `PauseSignal` into the loop and the
|
|
7
|
+
* in-memory steer flag (`signalSteerPending`) lives in a different process, so
|
|
8
|
+
* the only reliable channel is the shared sandbox filesystem. The CLI writes a
|
|
9
|
+
* durable marker here; the agent loop consumes it at the end of the turn
|
|
10
|
+
* (alongside the `needs_input` self-pause) and stages a real `ctx.pause` the
|
|
11
|
+
* next boundary takes — which snapshots the sandbox, releases the activity
|
|
12
|
+
* (compute stops), and parks the workflow. On resume the human's answer is
|
|
13
|
+
* delivered as the agent's next user turn.
|
|
14
|
+
*
|
|
15
|
+
* This is the ONLY place the marker path + shape are defined — both the CLI
|
|
16
|
+
* (writer) and the SDK loop (reader) import it, so the two halves can never
|
|
17
|
+
* drift. Like the rest of the state-dir, the layout is a wire protocol between
|
|
18
|
+
* the runner and the next subprocess invocation (ADR-0006). The marker is
|
|
19
|
+
* consumed BEFORE the snapshot, so it never needs to survive a pause.
|
|
20
|
+
*
|
|
21
|
+
* Scoped by `agentId` so concurrent `agent()` calls sharing one sandbox each
|
|
22
|
+
* see only their own request. When the id is unavailable (older agent env that
|
|
23
|
+
* doesn't inject `AGENT_COMPOSE_AGENT_ID`) both sides fall back to a single
|
|
24
|
+
* unscoped slot — correct for the common single-agent step, and the only case
|
|
25
|
+
* where an unscoped marker can be ambiguous (two anonymous agents) is one the
|
|
26
|
+
* old block-poll CLI couldn't handle either.
|
|
27
|
+
*/
|
|
28
|
+
/** A choice offered to the human. A bare string is shorthand for
|
|
29
|
+
* `{ label, value }` with both equal — exactly what the dashboard's
|
|
30
|
+
* `readOptions` accepts. */
|
|
31
|
+
export type PauseOption = string | {
|
|
32
|
+
label: string;
|
|
33
|
+
value: string;
|
|
34
|
+
};
|
|
35
|
+
/** What `agentc pause` records for the loop to turn into a `ctx.pause`. */
|
|
36
|
+
export interface LocalPauseRequest {
|
|
37
|
+
/** The question shown to the human (becomes the pause `reason`). */
|
|
38
|
+
reason: string;
|
|
39
|
+
/** Optional offered choices, rendered as buttons in the dashboard. */
|
|
40
|
+
options?: PauseOption[];
|
|
41
|
+
}
|
|
42
|
+
/** Write the marker atomically (tmp → rename) so the loop never reads a
|
|
43
|
+
* partial file mid-write. Called by `agentc pause`. */
|
|
44
|
+
export declare function writeLocalPauseRequest(agentId: string | undefined | null, req: LocalPauseRequest): void;
|
|
45
|
+
/** Take-once read: returns + deletes this agent's pending pause request, else
|
|
46
|
+
* null. Checks the agent-scoped slot first, then the unscoped fallback. The
|
|
47
|
+
* loop calls this once per turn; a malformed marker is dropped (deleted +
|
|
48
|
+
* null) rather than wedging the loop. */
|
|
49
|
+
export declare function consumeLocalPauseRequest(agentId: string | undefined | null): LocalPauseRequest | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,13 +15,29 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
/** What a steer/resume answer carries. Used as the boundary pause's `schema`
|
|
18
|
-
* so it is validated client-side in the re-spawned runner —
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
* so it is validated client-side in the re-spawned runner — an empty answer
|
|
19
|
+
* is rejected (PauseSchemaError) so an agent never resumes on nothing. The
|
|
20
|
+
* normalised `message` becomes the agent's next user turn.
|
|
21
|
+
*
|
|
22
|
+
* Accepts BOTH resume-payload conventions and normalises to `{ message }`:
|
|
23
|
+
* - `{ message }` — the SDK / API steer convention (`answerSteer`).
|
|
24
|
+
* - `{ decision }` — what the dashboard's RunPausePanel universally sends
|
|
25
|
+
* for every pause (option click or free text). Without this, resuming an
|
|
26
|
+
* agent steer / `needs_input` / `agentc pause` pause from the dashboard
|
|
27
|
+
* failed schema validation in the re-spawned runner and the agent never
|
|
28
|
+
* got the answer — the resume looked like it did nothing. */
|
|
29
|
+
export declare const SteerDecisionSchema: z.ZodPipe<z.ZodObject<{
|
|
30
|
+
message: z.ZodOptional<z.ZodString>;
|
|
31
|
+
decision: z.ZodOptional<z.ZodString>;
|
|
23
32
|
actor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
|
-
}, z.core.$strip
|
|
33
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
34
|
+
message: string;
|
|
35
|
+
actor: string | null;
|
|
36
|
+
}, {
|
|
37
|
+
message?: string | undefined;
|
|
38
|
+
decision?: string | undefined;
|
|
39
|
+
actor?: string | null | undefined;
|
|
40
|
+
}>>;
|
|
25
41
|
export type SteerDecision = z.infer<typeof SteerDecisionSchema>;
|
|
26
42
|
/** Metadata a pending steer carries from the control message to the boundary
|
|
27
43
|
* that turns it into a durable pause row. The flag store used to be a bare
|
package/dist/client.d.ts
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* `register()` accepts pre-built sources — use the CLI (`agent-compose
|
|
11
11
|
* register`) or build sources yourself and pass them directly.
|
|
12
12
|
*/
|
|
13
|
-
import type { SandboxNetworkPolicy } from "./sandbox.js";
|
|
13
|
+
import type { SandboxNetworkPolicy, SandboxSize } from "./sandbox.js";
|
|
14
14
|
import type { RunEvent } from "./types/events.js";
|
|
15
15
|
import type { WorkflowPlan } from "./types/workflow-plan.js";
|
|
16
|
-
import type { SnapshotConfig, IOSchema, ConnectorRequirements, ConnectorOperationTag, InvokePolicy } from "./types/workflow-metadata.js";
|
|
16
|
+
import type { SnapshotConfig, IOSchema, ConnectorRequirements, ConnectorOperationTag, InvokePolicy, SandboxResources } from "./types/workflow-metadata.js";
|
|
17
17
|
import type { WorkflowManifest } from "./utils/bundler.js";
|
|
18
18
|
export interface RegisterResult {
|
|
19
19
|
id: string;
|
|
@@ -67,6 +67,9 @@ export interface RegisterWorkflowInput {
|
|
|
67
67
|
/** All snapshot config — `bootFrom` (where to restore at run start),
|
|
68
68
|
* `save`, `retain`. See `WorkflowMetadata.snapshots`. */
|
|
69
69
|
snapshots?: SnapshotConfig;
|
|
70
|
+
/** Sandbox machine resources — size + provider (template defaults).
|
|
71
|
+
* See `WorkflowMetadata.resources`. */
|
|
72
|
+
resources?: SandboxResources;
|
|
70
73
|
/** Provider-neutral execution plan detected by the CLI bundler. */
|
|
71
74
|
workflowPlan?: WorkflowPlan;
|
|
72
75
|
/** Connector requirements declared via `defineWorkflow({ connectors })`
|
|
@@ -83,6 +86,10 @@ export interface RegisterWorkflowInput {
|
|
|
83
86
|
inputSchema?: IOSchema;
|
|
84
87
|
/** Output schema extracted from the workflow's `output` zod schema. */
|
|
85
88
|
outputSchema?: IOSchema;
|
|
89
|
+
/** Set by `defineSandboxEnvironment` — marks an environment build so the
|
|
90
|
+
* server skips the /factory mount for its runs (#13). See
|
|
91
|
+
* `WorkflowMetadata.environmentBuild`. */
|
|
92
|
+
environmentBuild?: boolean;
|
|
86
93
|
/** Factory slug. Defaults to `"default"`. */
|
|
87
94
|
factorySlug?: string;
|
|
88
95
|
}
|
|
@@ -101,6 +108,10 @@ export interface InvokeWorkflowOptions {
|
|
|
101
108
|
* vars after brokering. Replaces the template-level placeholders for
|
|
102
109
|
* this run only — registered metadata is not mutated. */
|
|
103
110
|
placeholders?: Record<string, string>;
|
|
111
|
+
/** Per-invocation machine-size override of the template's `resources.size`.
|
|
112
|
+
* `small` (default) | `medium` | `large`; omit → the template default,
|
|
113
|
+
* else `small`. Honoured on Vercel (→ vCPUs); E2B ignores it. */
|
|
114
|
+
size?: SandboxSize;
|
|
104
115
|
/** Explicit parent run id. Pass `null` to suppress ambient RUN_ID auto-detection. */
|
|
105
116
|
parentRunId?: string | null;
|
|
106
117
|
/** Agent loop inside the parent run that caused this invoke, when applicable. */
|
|
@@ -135,6 +146,53 @@ export interface TemplateRow {
|
|
|
135
146
|
export interface ListTemplatesOptions {
|
|
136
147
|
factorySlug?: string;
|
|
137
148
|
}
|
|
149
|
+
/** A human member of your team — the people an agent (or you) can @-flag. */
|
|
150
|
+
export interface TeamMember {
|
|
151
|
+
/** Membership row id. */
|
|
152
|
+
id: string;
|
|
153
|
+
/** The user id — what you pass to `createMentions({ mentionedUserIds })`. */
|
|
154
|
+
userId: string;
|
|
155
|
+
role: string;
|
|
156
|
+
email: string;
|
|
157
|
+
name: string;
|
|
158
|
+
joinedAt: string;
|
|
159
|
+
}
|
|
160
|
+
/** A "you were flagged" ping, persisted server-side so it reaches the
|
|
161
|
+
* mentioned teammate in their Workbench. */
|
|
162
|
+
export interface Mention {
|
|
163
|
+
id: string;
|
|
164
|
+
factoryId: string;
|
|
165
|
+
mentionedUserId: string;
|
|
166
|
+
/** Who flagged: 'user' | 'api_key' | 'run' | 'system'. */
|
|
167
|
+
actorKind: string;
|
|
168
|
+
actorId: string | null;
|
|
169
|
+
actorLabel: string | null;
|
|
170
|
+
/** Where it lives: 'doc' | 'comment' | 'plan' | 'run'. */
|
|
171
|
+
contextKind: string;
|
|
172
|
+
contextPath: string | null;
|
|
173
|
+
/** Ready-made relative dashboard URL the Workbench card links to. */
|
|
174
|
+
contextUrl: string | null;
|
|
175
|
+
text: string;
|
|
176
|
+
runId: string | null;
|
|
177
|
+
seenAt: string | null;
|
|
178
|
+
resolvedAt: string | null;
|
|
179
|
+
createdAt: string;
|
|
180
|
+
}
|
|
181
|
+
export interface CreateMentionsInput {
|
|
182
|
+
/** Team-member user ids to flag (1–20). Discover them via `listMembers()`.
|
|
183
|
+
* Non-members are dropped server-side. */
|
|
184
|
+
mentionedUserIds: string[];
|
|
185
|
+
/** The flag message shown in the teammate's Workbench. */
|
|
186
|
+
text: string;
|
|
187
|
+
contextKind: "doc" | "comment" | "plan" | "run";
|
|
188
|
+
/** Factory-relative file path or comment thread id, when applicable. */
|
|
189
|
+
contextPath?: string;
|
|
190
|
+
/** Ready-made relative dashboard URL the Workbench card links to (e.g.
|
|
191
|
+
* `/factories/<slug>/files/view?path=<plan>`). */
|
|
192
|
+
contextUrl?: string;
|
|
193
|
+
runId?: string;
|
|
194
|
+
factorySlug?: string;
|
|
195
|
+
}
|
|
138
196
|
export interface CreateFactoryInput {
|
|
139
197
|
slug: string;
|
|
140
198
|
name: string;
|
|
@@ -622,6 +680,16 @@ export declare class AgentComposeClient {
|
|
|
622
680
|
factorySlug?: string;
|
|
623
681
|
revision?: number;
|
|
624
682
|
}): Promise<string>;
|
|
683
|
+
/** List the human members of your team — the people you (or an agent) can
|
|
684
|
+
* @-flag with `createMentions`. Each row's `userId` is what
|
|
685
|
+
* `mentionedUserIds` expects. */
|
|
686
|
+
listMembers(): Promise<TeamMember[]>;
|
|
687
|
+
/** Flag one or more teammates — a durable ping that lands in their factory
|
|
688
|
+
* Workbench. Use from an agent (e.g. a remediation plan that needs a human
|
|
689
|
+
* to rotate a secret) or any team automation. Resolve `mentionedUserIds`
|
|
690
|
+
* via `listMembers()`. When run inside a sandbox the run-callback token is
|
|
691
|
+
* forwarded so the ping is attributed to the run ("flagged by <workflow>"). */
|
|
692
|
+
createMentions(input: CreateMentionsInput): Promise<Mention[]>;
|
|
625
693
|
/** List events ingested into a factory, newest first. Supports
|
|
626
694
|
* case-insensitive substring filter (`name`) and timestamp-cursor
|
|
627
695
|
* pagination (`before`). Returns `{ events, has_more }` — the
|
|
@@ -673,6 +741,12 @@ export declare class AgentComposeClient {
|
|
|
673
741
|
listSecrets(workflowName: string, opts?: SecretOptions): Promise<SecretListEntry[]>;
|
|
674
742
|
/** Delete a workflow secret. */
|
|
675
743
|
deleteSecret(workflowName: string, key: string, opts?: SecretOptions): Promise<void>;
|
|
744
|
+
/** Create or update a factory-level secret. */
|
|
745
|
+
setFactorySecret(key: string, value: string, opts?: SecretOptions): Promise<SetSecretResult>;
|
|
746
|
+
/** List factory-level secret keys (metadata only — values are never returned). */
|
|
747
|
+
listFactorySecrets(opts?: SecretOptions): Promise<SecretListEntry[]>;
|
|
748
|
+
/** Delete a factory-level secret. */
|
|
749
|
+
deleteFactorySecret(key: string, opts?: SecretOptions): Promise<void>;
|
|
676
750
|
/** Create a new API key on the caller's team. The plaintext `key` is
|
|
677
751
|
* returned once — it cannot be retrieved later.
|
|
678
752
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -23,12 +23,12 @@ export type { WorkflowPlan, WorkflowStepPlan } from "./types/workflow-plan.js";
|
|
|
23
23
|
export type { BaseExecutionContext, InvokeChild } from "./types/execution-context.js";
|
|
24
24
|
export { RequestContext, ReservedKeyError, NonSerialisableValueError, AC_RESERVED_PREFIX, AC_TEAM_ID, AC_RUN_ID, AC_WORKFLOW_ID, AC_FACTORY_ID, AC_API_KEY_SCOPES, AC_PARENT_RUN_ID, AC_ABORT_SIGNAL, } from "./request-context/index.js";
|
|
25
25
|
export type { RequestContextReserved, RequestContextWire, } from "./request-context/index.js";
|
|
26
|
-
export { Verdict, runProcessorChain, denyTools, requireScope, redactPattern, } from "./processors/index.js";
|
|
26
|
+
export { Verdict, runProcessorChain, denyTools, humanApproval, requireScope, redactPattern, } from "./processors/index.js";
|
|
27
27
|
export type { Processor, ProcessorContext, ProcessorVerdict, ToolCall, } from "./processors/index.js";
|
|
28
28
|
export type { AgentMessage, AgentMessageInit, AgentMessageText, AgentMessageThinking, AgentMessageToolUse, AgentMessageToolResult, AgentMessageDone, AgentMessageError, AgentMessageUsage, AgentStatus, } from "./types/protocol.js";
|
|
29
29
|
export type { SandboxProvider, DesktopSandboxProvider, } from "./types/sandbox.js";
|
|
30
30
|
export { AgentComposeClient } from "./client.js";
|
|
31
|
-
export type { RegisterResult, RegisterWorkflowInput, RuntimeSourceInput, TemplateSourceRef, InvokeWorkflowOptions, InvokeAndWaitOptions, InvokeResult, ListSnapshotsOptions, TemplateRow, ListTemplatesOptions, CreateFactoryInput, UpdateFactoryInput, SecretOptions, SetSecretResult, SecretListEntry, CreateApiKeyInput, StreamRunLogsOptions, EventSubjectType, EventRow, ReportEventInput, ListEventsOptions, ListEventsResult, RunLogLine, ListRunLogsOptions, RegisteredRuntime, RunState, RunStatus, FactoryRow, SnapshotListEntry, SnapshotListResponse, ApiKey, ApiKeyCreated, UsageRollupRow, UsageResponse, CancelRunResponse, RequestAgentPauseOptions, RequestAgentPauseResponse, SendAgentMessageOptions, SendAgentMessageResponse, AnswerSteerOptions, ResumePauseOptions, ResumePauseResponse, ResumePauseSuccess, ResumePausePending, ResumePauseActor, } from "./client.js";
|
|
31
|
+
export type { RegisterResult, RegisterWorkflowInput, RuntimeSourceInput, TemplateSourceRef, InvokeWorkflowOptions, InvokeAndWaitOptions, InvokeResult, ListSnapshotsOptions, TemplateRow, ListTemplatesOptions, CreateFactoryInput, UpdateFactoryInput, SecretOptions, SetSecretResult, SecretListEntry, CreateApiKeyInput, StreamRunLogsOptions, TeamMember, Mention, CreateMentionsInput, EventSubjectType, EventRow, ReportEventInput, ListEventsOptions, ListEventsResult, RunLogLine, ListRunLogsOptions, RegisteredRuntime, RunState, RunStatus, FactoryRow, SnapshotListEntry, SnapshotListResponse, ApiKey, ApiKeyCreated, UsageRollupRow, UsageResponse, CancelRunResponse, RequestAgentPauseOptions, RequestAgentPauseResponse, SendAgentMessageOptions, SendAgentMessageResponse, AnswerSteerOptions, ResumePauseOptions, ResumePauseResponse, ResumePauseSuccess, ResumePausePending, ResumePauseActor, } from "./client.js";
|
|
32
32
|
export { parseSseStream } from "./sse.js";
|
|
33
33
|
export { AgentComposeError } from "./errors.js";
|
|
34
34
|
export { formatError } from "./utils/errors.js";
|
|
@@ -50,9 +50,10 @@ export { default as ampRuntime } from "./runtimes/amp.js";
|
|
|
50
50
|
export { bashTool, codingTools, editTool, readTool, writeTool } from "./tools/index.js";
|
|
51
51
|
export type { CodingTool } from "./tools/index.js";
|
|
52
52
|
export type { RunEvent } from "./types/events.js";
|
|
53
|
-
export { createSandbox, reconnectSandbox, killAllSandboxes, killSandboxById, getSandboxQuotas, listOwnedSandboxes, deleteSandboxSnapshot, makeSandboxProvider, makeDesktopSandboxProvider, parseSseExecStream, AGENT_COMPOSE_TAG } from "./sandbox.js";
|
|
53
|
+
export { createSandbox, reconnectSandbox, killAllSandboxes, killSandboxById, getSandboxQuotas, listOwnedSandboxes, deleteSandboxSnapshot, snapshotResolves, makeSandboxProvider, makeDesktopSandboxProvider, parseSseExecStream, AGENT_COMPOSE_TAG, SANDBOX_VCPUS, DEFAULT_SANDBOX_SIZE, E2B_TEMPLATE_SIZES, isE2bSupportedSize, e2bMachineSpec, e2bBaseTemplate, e2bAgentEnvTemplate, isPlatformE2bTemplateAlias } from "./sandbox.js";
|
|
54
54
|
export { SandboxUnavailableError, SANDBOX_UNAVAILABLE_PREFIX } from "./sandbox-errors.js";
|
|
55
|
-
export type { SandboxCreateOpts, SandboxNetworkPolicy, SandboxNetworkHeaderTransform, SandboxNetworkAllowRule, SandboxNetworkSubnetPolicy, SandboxProviderName, SandboxQuotaResult, OwnedSandboxResult, OwnedSandbox, ParseSseExecStreamOptions, SandboxCommandRunOptions, SandboxCommandResult, } from "./sandbox.js";
|
|
55
|
+
export type { SandboxCreateOpts, SandboxNetworkPolicy, SandboxNetworkHeaderTransform, SandboxNetworkAllowRule, SandboxNetworkSubnetPolicy, SandboxProviderName, SandboxQuotaResult, OwnedSandboxResult, OwnedSandbox, SandboxSize, ParseSseExecStreamOptions, SandboxCommandRunOptions, SandboxCommandResult, } from "./sandbox.js";
|
|
56
|
+
export type { SandboxResources } from "./types/workflow-metadata.js";
|
|
56
57
|
export { runWorkflow, WorkflowError, EngineError, classifyError, parseNameVersion } from "./workflows/engine.js";
|
|
57
58
|
export type { WorkflowResult, RunWorkflowOptions, EngineSubsystem } from "./workflows/engine.js";
|
|
58
59
|
export { buildInvokeChild } from "./workflows/invoke-child.js";
|
|
@@ -62,11 +63,15 @@ export { invokeStep, serveStep, parseStepResult, buildStepEnvs, StepExecutionErr
|
|
|
62
63
|
export { PauseError, PauseExpiredError, PauseSchemaError, PauseRequestError, } from "./pause/errors.js";
|
|
63
64
|
export type { PauseErrorCode } from "./pause/errors.js";
|
|
64
65
|
export type { PauseRequest } from "./pause/pause-core.js";
|
|
65
|
-
export type {
|
|
66
|
+
export type { WaitForEventRequest } from "./pause/wrappers.js";
|
|
67
|
+
export { writeLocalPauseRequest, consumeLocalPauseRequest } from "./agent/local-pause-request.js";
|
|
68
|
+
export type { LocalPauseRequest, PauseOption } from "./agent/local-pause-request.js";
|
|
66
69
|
export type { StepRequest, StepResult, StepInvocationError, StepPauseRequest, StepHandler, StepHandlerResult, ServeStepRequest, } from "./step-invocation/index.js";
|
|
67
70
|
export { agentLoop, parseAgentStatus, DEFAULT_CLAUDE_MODEL } from "./agent/agent-loop.js";
|
|
68
71
|
export type { AgentLifecycleEvent, AgentLoopOpts, AgentLoopResult } from "./agent/agent-loop.js";
|
|
69
72
|
export { agent } from "./agent/run-agent.js";
|
|
70
73
|
export type { AgentOpts } from "./agent/run-agent.js";
|
|
74
|
+
export { AGENT_COMPOSE_MANUAL, buildAgentContextDoc, writeAgentContext } from "./agent/agent-context.js";
|
|
75
|
+
export type { AgentConnectorInfo } from "./agent/agent-context.js";
|
|
71
76
|
export { AgentMessageSchema, parseAgentResponse } from "./agent/protocol.js";
|
|
72
77
|
export { importSourceModule, TMP_DIR, LATEST_VERSION } from "./utils/source-loader.js";
|