@agent-compose/sdk 0.5.6 → 0.5.8

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.
Files changed (44) hide show
  1. package/README.md +4 -4
  2. package/dist/agent/__tests__/run-agent-liveness.test.d.ts +17 -0
  3. package/dist/agent/agent-context.d.ts +67 -0
  4. package/dist/agent/agent-loop-contract.test.d.ts +1 -0
  5. package/dist/agent/agent-loop.d.ts +2 -1
  6. package/dist/client.d.ts +129 -24
  7. package/dist/index.d.ts +9 -4
  8. package/dist/index.js +553 -89
  9. package/dist/pause/wrappers.d.ts +7 -11
  10. package/dist/runtimes/claude.d.ts +9 -1
  11. package/dist/runtimes/openai-desktop.js +548 -89
  12. package/dist/sandbox-errors.d.ts +49 -0
  13. package/dist/sandbox.d.ts +92 -13
  14. package/dist/step-invocation/protocol.d.ts +6 -0
  15. package/dist/step-invocation/types.d.ts +1 -1
  16. package/dist/types/execution-context.d.ts +1 -3
  17. package/dist/types/sandbox-environment.d.ts +1 -10
  18. package/dist/types/sandbox.d.ts +27 -3
  19. package/dist/types/workflow-metadata.d.ts +81 -13
  20. package/dist/types/workflow.d.ts +45 -10
  21. package/dist/utils/bundler.d.ts +40 -9
  22. package/dist/workflow-steps/workflow.d.ts +4 -3
  23. package/package.json +2 -2
  24. package/src/agent/agent-context.ts +212 -0
  25. package/src/agent/agent-loop.ts +78 -10
  26. package/src/agent/run-agent.ts +37 -1
  27. package/src/client.ts +232 -26
  28. package/src/index.ts +9 -4
  29. package/src/pause/wrappers.ts +7 -21
  30. package/src/runtimes/claude.ts +66 -8
  31. package/src/sandbox-errors.ts +53 -0
  32. package/src/sandbox.ts +438 -61
  33. package/src/step-invocation/invoker.ts +66 -8
  34. package/src/step-invocation/protocol.ts +9 -0
  35. package/src/step-invocation/server.ts +27 -4
  36. package/src/step-invocation/types.ts +1 -1
  37. package/src/types/execution-context.ts +1 -3
  38. package/src/types/sandbox-environment.ts +1 -11
  39. package/src/types/sandbox.ts +28 -3
  40. package/src/types/workflow-metadata.ts +91 -16
  41. package/src/types/workflow.ts +45 -12
  42. package/src/utils/bundler.ts +46 -13
  43. package/src/workflow-steps/workflow.ts +4 -3
  44. package/src/workflows/invoke-child.ts +7 -1
package/README.md CHANGED
@@ -64,7 +64,7 @@ export default defineWorkflow({
64
64
  ```
65
65
 
66
66
  `defineWorkflow` is a thin sugar — it returns the bare `run` function with
67
- `networkPolicy` / `placeholders` / `snapshots` / `memory` / `postRunHooks`
67
+ `networkPolicy` / `placeholders` / `snapshots`
68
68
  attached as metadata that the bundler picks up at registration time. A
69
69
  plain `export default async (ctx, sandbox) => {...}` is also valid; you
70
70
  just lose the metadata channel.
@@ -183,7 +183,7 @@ await client.register({
183
183
  runtimes: bundled.runtimes, // [{ name, source }] — embedded so the runner has them locally
184
184
  schedule: "*/30 * * * *", // optional cron
185
185
  factorySlug: "default", // optional — defaults to "default"
186
- // snapshots, memory, postRunHooks, networkPolicy, placeholders — all optional
186
+ // snapshots, networkPolicy, placeholders — all optional
187
187
  });
188
188
  ```
189
189
 
@@ -217,7 +217,7 @@ separate `metadata` field — useful for "side-channel" facts (PR url, plan
217
217
  url) without polluting the structured return.
218
218
 
219
219
  `invoke` and `invokeAndWait` both accept `{ factorySlug, snapshots,
220
- memory, postRunHooks, networkPolicy, placeholders, parentRunId }` as the
220
+ networkPolicy, placeholders, parentRunId }` as the
221
221
  third argument. Per-invocation `snapshots` merges field-by-field with
222
222
  the registered default. `factorySlug` defaults to `"default"`.
223
223
 
@@ -379,7 +379,7 @@ CLI equivalents: `agentc snapshot list` / `agentc snapshot delete <run-id> <snap
379
379
 
380
380
  ### Per-invocation overrides merge field-by-field
381
381
 
382
- The `snapshots` object on `invoke()` is **merged** with the registered template's `snapshots` config — you can override `bootFrom` alone without losing `saveLatest`, or vice versa. Same for `memory` (boolean) and `postRunHooks` (string[]).
382
+ The `snapshots` object on `invoke()` is **merged** with the registered template's `snapshots` config — you can override `bootFrom` alone without losing `saveLatest`, or vice versa.
383
383
 
384
384
  ---
385
385
 
@@ -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`. It\nblocks until they answer on the dashboard, then prints their answer to stdout:\n\n ANSWER=$(agentc pause --reason \"Notion returned 401 \u2014 connect Notion to continue\" \\\n --option retry --option skip)\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. Read the printed answer\nand act on it. Each agent pauses independently \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>;
@@ -0,0 +1 @@
1
+ export {};
@@ -8,7 +8,7 @@ import type { AgentStatus, AgentMessage } from "./protocol.js";
8
8
  import type { Processor } from "../processors/processor.js";
9
9
  import { RequestContext } from "../request-context/request-context.js";
10
10
  import { type SteerPayload } from "./steer-control.js";
11
- export declare const DEFAULT_CLAUDE_MODEL = "claude-opus-4-7";
11
+ export declare const DEFAULT_CLAUDE_MODEL = "claude-fable-5";
12
12
  export declare function parseAgentStatus(text: string): AgentStatus | null;
13
13
  export interface AgentLoopResult<TResponse = unknown> {
14
14
  agentId: string;
@@ -46,6 +46,7 @@ export type AgentMessageSummary = {
46
46
  cacheCreationTokens: number;
47
47
  durationMs: number;
48
48
  numTurns: number;
49
+ model?: string;
49
50
  } | {
50
51
  type: "done";
51
52
  sessionId: string;
package/dist/client.d.ts CHANGED
@@ -10,23 +10,16 @@
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 } 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;
20
20
  name: string;
21
21
  version: string;
22
22
  runtimes?: RegisteredRuntime[];
23
- /** Non-fatal advisories from the server. Surfaced at register time so the
24
- * operator sees them while still in front of the terminal — currently
25
- * covers "memory extraction is configured but its workflow is not
26
- * registered in this factory". Empty/undefined when registration was
27
- * cleanly resolved against everything the workflow declares it
28
- * depends on. */
29
- warnings?: string[];
30
23
  }
31
24
  export interface RegisteredRuntime {
32
25
  id: string;
@@ -37,6 +30,18 @@ export interface RuntimeSourceInput {
37
30
  name: string;
38
31
  source: string;
39
32
  }
33
+ /** GitHub provenance for a registered template's source file — stored as
34
+ * `metadata.source` on the registration. `cloud-build` stamps the built
35
+ * commit's sha; the dashboard's manual link path writes `sha: "manual"`. */
36
+ export interface TemplateSourceRef {
37
+ owner: string;
38
+ repo: string;
39
+ branch: string;
40
+ /** Repo-relative file path, e.g. `.agentc/workflows/workflow-deploy.ts`. */
41
+ path: string;
42
+ /** Commit sha the version was built from, or `"manual"` for hand-links. */
43
+ sha: string;
44
+ }
40
45
  export interface RegisterWorkflowInput {
41
46
  name: string;
42
47
  source: string;
@@ -48,6 +53,9 @@ export interface RegisterWorkflowInput {
48
53
  * executed on the server. */
49
54
  manifest: WorkflowManifest;
50
55
  version?: string;
56
+ /** Where the source file lives on GitHub — stored as `metadata.source`.
57
+ * Named `sourceRef` because `source` is the bundled code itself. */
58
+ sourceRef?: TemplateSourceRef;
51
59
  schedule?: string;
52
60
  runtimes?: RuntimeSourceInput[];
53
61
  /** Human-readable description declared via
@@ -59,15 +67,20 @@ export interface RegisterWorkflowInput {
59
67
  /** All snapshot config — `bootFrom` (where to restore at run start),
60
68
  * `save`, `retain`. See `WorkflowMetadata.snapshots`. */
61
69
  snapshots?: SnapshotConfig;
70
+ /** Sandbox machine size (template default). See `WorkflowMetadata.resources`. */
71
+ resources?: SandboxResources;
62
72
  /** Provider-neutral execution plan detected by the CLI bundler. */
63
73
  workflowPlan?: WorkflowPlan;
64
- /** Run the built-in memory extractor after this workflow completes.
65
- * Opt-in; defaults to false when omitted. */
66
- memory?: boolean;
67
- /** Ordered list of workflow names that run as post-hooks after this
68
- * workflow completes. The memory extractor (when `memory: true`)
69
- * runs as an additional hook alongside these. */
70
- postRunHooks?: readonly string[];
74
+ /** Connector requirements declared via `defineWorkflow({ connectors })`
75
+ * (ADR-0007). Validated against the server's provider registry at
76
+ * registration; tokens are injected at the network layer at dispatch. */
77
+ connectors?: ConnectorRequirements;
78
+ /** Connector-catalogue operation tag — see `ConnectorOperationTag`. */
79
+ connectorOperation?: ConnectorOperationTag;
80
+ /** Tier-1 invoke ACL declared via `defineWorkflow({ invokePolicy })`.
81
+ * Only meaningful when the workflow also declares `connectors` — the
82
+ * server gates dispatch on it before binding any grant. */
83
+ invokePolicy?: InvokePolicy;
71
84
  /** Input schema extracted from the workflow's `input` zod schema. */
72
85
  inputSchema?: IOSchema;
73
86
  /** Output schema extracted from the workflow's `output` zod schema. */
@@ -90,19 +103,20 @@ export interface InvokeWorkflowOptions {
90
103
  * vars after brokering. Replaces the template-level placeholders for
91
104
  * this run only — registered metadata is not mutated. */
92
105
  placeholders?: Record<string, string>;
93
- /** Per-invocation memory-extractor override — `false` skips the
94
- * built-in memory hook for this run; omitting leaves the registered
95
- * default in place. */
96
- memory?: boolean;
97
- /** Per-invocation post-hook override — replaces the registered
98
- * `postRunHooks` array for this run only. */
99
- postRunHooks?: readonly string[];
106
+ /** Per-invocation machine-size override of the template's `resources.size`.
107
+ * `small` (default) | `medium` | `large`; omit → the template default,
108
+ * else `small`. Honoured on Vercel (→ vCPUs); E2B ignores it. */
109
+ size?: SandboxSize;
100
110
  /** Explicit parent run id. Pass `null` to suppress ambient RUN_ID auto-detection. */
101
111
  parentRunId?: string | null;
102
112
  /** Agent loop inside the parent run that caused this invoke, when applicable. */
103
113
  agentId?: string | null;
104
114
  /** Factory slug. Defaults to `"default"`. */
105
115
  factorySlug?: string;
116
+ /** Idempotency key — sent as the `Idempotency-Key` header. A repeat invoke
117
+ * with the same key inside the server's dedup window returns the original
118
+ * run instead of starting a new one (matches `resumePause`'s pattern). */
119
+ idempotencyKey?: string;
106
120
  }
107
121
  export interface InvokeAndWaitOptions extends InvokeWorkflowOptions {
108
122
  timeoutMs?: number;
@@ -127,6 +141,53 @@ export interface TemplateRow {
127
141
  export interface ListTemplatesOptions {
128
142
  factorySlug?: string;
129
143
  }
144
+ /** A human member of your team — the people an agent (or you) can @-flag. */
145
+ export interface TeamMember {
146
+ /** Membership row id. */
147
+ id: string;
148
+ /** The user id — what you pass to `createMentions({ mentionedUserIds })`. */
149
+ userId: string;
150
+ role: string;
151
+ email: string;
152
+ name: string;
153
+ joinedAt: string;
154
+ }
155
+ /** A "you were flagged" ping, persisted server-side so it reaches the
156
+ * mentioned teammate in their Workbench. */
157
+ export interface Mention {
158
+ id: string;
159
+ factoryId: string;
160
+ mentionedUserId: string;
161
+ /** Who flagged: 'user' | 'api_key' | 'run' | 'system'. */
162
+ actorKind: string;
163
+ actorId: string | null;
164
+ actorLabel: string | null;
165
+ /** Where it lives: 'doc' | 'comment' | 'plan' | 'run'. */
166
+ contextKind: string;
167
+ contextPath: string | null;
168
+ /** Ready-made relative dashboard URL the Workbench card links to. */
169
+ contextUrl: string | null;
170
+ text: string;
171
+ runId: string | null;
172
+ seenAt: string | null;
173
+ resolvedAt: string | null;
174
+ createdAt: string;
175
+ }
176
+ export interface CreateMentionsInput {
177
+ /** Team-member user ids to flag (1–20). Discover them via `listMembers()`.
178
+ * Non-members are dropped server-side. */
179
+ mentionedUserIds: string[];
180
+ /** The flag message shown in the teammate's Workbench. */
181
+ text: string;
182
+ contextKind: "doc" | "comment" | "plan" | "run";
183
+ /** Factory-relative file path or comment thread id, when applicable. */
184
+ contextPath?: string;
185
+ /** Ready-made relative dashboard URL the Workbench card links to (e.g.
186
+ * `/factories/<slug>/files/view?path=<plan>`). */
187
+ contextUrl?: string;
188
+ runId?: string;
189
+ factorySlug?: string;
190
+ }
130
191
  export interface CreateFactoryInput {
131
192
  slug: string;
132
193
  name: string;
@@ -182,6 +243,13 @@ export interface RunStatus<TOutput = unknown> {
182
243
  id: string;
183
244
  status: RunState;
184
245
  output?: TOutput;
246
+ /** The run's latest (`saveLatest`) snapshot id, populated once the run has
247
+ * succeeded — the boot source to fork this run's evolved filesystem from
248
+ * (pass as `snapshots.bootFrom` on a follow-up invoke). `null` while the run
249
+ * is still in flight or when it captured no snapshot. Lets an orchestrator
250
+ * fork a child straight off the `invokeChild` result without a separate
251
+ * `listRunSnapshots` call. */
252
+ latestSnapshotId?: string | null;
185
253
  }
186
254
  /** ADR-0006 step 10 — actor record returned on a successful resume.
187
255
  * Shape mirrors the server's `PauseResumeActor` type after the row
@@ -317,6 +385,20 @@ export interface EventRow {
317
385
  idempotencyKey: string | null;
318
386
  createdAt: string;
319
387
  }
388
+ export interface RunArtifactRow {
389
+ path: string;
390
+ factorySlug: string | null;
391
+ sizeBytes: number | null;
392
+ lastWriteAt: string;
393
+ /** Opening text of the file (≤320 chars) — null for binary/empty. */
394
+ preview: string | null;
395
+ }
396
+ export interface FactoryFileWriteResult {
397
+ path: string;
398
+ contentHash: string;
399
+ sizeBytes: number;
400
+ created: boolean;
401
+ }
320
402
  export interface ReportEventInput {
321
403
  name: string;
322
404
  body: unknown;
@@ -331,7 +413,7 @@ export interface ListEventsOptions {
331
413
  factorySlug?: string;
332
414
  limit?: number;
333
415
  /** Case-insensitive substring match. Server uses `ILIKE %name%`, so
334
- * `"mem"` matches `memory.fact`, `memory.usage`, etc. Pass the
416
+ * `"site"` matches `site.created`, `site.failed`, etc. Pass the
335
417
  * full event name for an effectively-exact filter (any string is a
336
418
  * substring of itself). */
337
419
  name?: string;
@@ -580,6 +662,29 @@ export declare class AgentComposeClient {
580
662
  * like quality.accepted, defect.regression, or intervention.override. */
581
663
  reportEvent(runId: string, input: ReportEventInput): Promise<EventRow>;
582
664
  listRunEvents(runId: string): Promise<EventRow[]>;
665
+ /** Files the run wrote on the factory drive — run-attributed revisions,
666
+ * latest write per path, paths the run later deleted excluded. */
667
+ listRunArtifacts(runId: string): Promise<RunArtifactRow[]>;
668
+ /** Write (create or overwrite) one file on a factory's drive. */
669
+ putFactoryFile(path: string, content: string | Uint8Array, opts?: {
670
+ factorySlug?: string;
671
+ contentType?: string;
672
+ }): Promise<FactoryFileWriteResult>;
673
+ /** Read one file's current content (or a specific revision) as text. */
674
+ getFactoryFile(path: string, opts?: {
675
+ factorySlug?: string;
676
+ revision?: number;
677
+ }): Promise<string>;
678
+ /** List the human members of your team — the people you (or an agent) can
679
+ * @-flag with `createMentions`. Each row's `userId` is what
680
+ * `mentionedUserIds` expects. */
681
+ listMembers(): Promise<TeamMember[]>;
682
+ /** Flag one or more teammates — a durable ping that lands in their factory
683
+ * Workbench. Use from an agent (e.g. a remediation plan that needs a human
684
+ * to rotate a secret) or any team automation. Resolve `mentionedUserIds`
685
+ * via `listMembers()`. When run inside a sandbox the run-callback token is
686
+ * forwarded so the ping is attributed to the run ("flagged by <workflow>"). */
687
+ createMentions(input: CreateMentionsInput): Promise<Mention[]>;
583
688
  /** List events ingested into a factory, newest first. Supports
584
689
  * case-insensitive substring filter (`name`) and timestamp-cursor
585
690
  * pagination (`before`). Returns `{ events, has_more }` — the
package/dist/index.d.ts CHANGED
@@ -16,7 +16,8 @@ export type { WorkflowDefinition } from "./types/workflow.js";
16
16
  export { defineSandboxEnvironment } from "./types/sandbox-environment.js";
17
17
  export type { SandboxEnvironmentDefinition } from "./types/sandbox-environment.js";
18
18
  export type { AgentRuntime, McpServerConfig, ModelExecutionContract, ToolCallGateResult, RuntimeOptions, } from "./types/runtime.js";
19
- export type { WorkflowFn, WorkflowCtx, WorkflowRun, AgentBudget, WorkflowHooks, SnapshotConfig, BootSnapshot, ReuseSnapshot, IOSchema, OutputSchema, WorkflowMemoryConfig, } from "./types/workflow.js";
19
+ export type { WorkflowFn, WorkflowCtx, WorkflowRun, AgentBudget, WorkflowHooks, SnapshotConfig, BootSnapshot, ReuseSnapshot, IOSchema, OutputSchema, } from "./types/workflow.js";
20
+ export type { ConnectorRequestRules } from "./types/workflow-metadata.js";
20
21
  export type { RunSnapshotEntry } from "./client.js";
21
22
  export type { WorkflowPlan, WorkflowStepPlan } from "./types/workflow-plan.js";
22
23
  export type { BaseExecutionContext, InvokeChild } from "./types/execution-context.js";
@@ -27,7 +28,7 @@ export type { Processor, ProcessorContext, ProcessorVerdict, ToolCall, } from ".
27
28
  export type { AgentMessage, AgentMessageInit, AgentMessageText, AgentMessageThinking, AgentMessageToolUse, AgentMessageToolResult, AgentMessageDone, AgentMessageError, AgentMessageUsage, AgentStatus, } from "./types/protocol.js";
28
29
  export type { SandboxProvider, DesktopSandboxProvider, } from "./types/sandbox.js";
29
30
  export { AgentComposeClient } from "./client.js";
30
- export type { RegisterResult, RegisterWorkflowInput, RuntimeSourceInput, 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";
31
32
  export { parseSseStream } from "./sse.js";
32
33
  export { AgentComposeError } from "./errors.js";
33
34
  export { formatError } from "./utils/errors.js";
@@ -50,7 +51,9 @@ export { bashTool, codingTools, editTool, readTool, writeTool } from "./tools/in
50
51
  export type { CodingTool } from "./tools/index.js";
51
52
  export type { RunEvent } from "./types/events.js";
52
53
  export { createSandbox, reconnectSandbox, killAllSandboxes, killSandboxById, getSandboxQuotas, listOwnedSandboxes, deleteSandboxSnapshot, makeSandboxProvider, makeDesktopSandboxProvider, parseSseExecStream, AGENT_COMPOSE_TAG } from "./sandbox.js";
53
- export type { SandboxCreateOpts, SandboxNetworkPolicy, SandboxNetworkHeaderTransform, SandboxNetworkAllowRule, SandboxNetworkSubnetPolicy, SandboxProviderName, SandboxQuotaResult, OwnedSandboxResult, OwnedSandbox, ParseSseExecStreamOptions, SandboxCommandRunOptions, SandboxCommandResult, } from "./sandbox.js";
54
+ export { SandboxUnavailableError, SANDBOX_UNAVAILABLE_PREFIX } from "./sandbox-errors.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";
54
57
  export { runWorkflow, WorkflowError, EngineError, classifyError, parseNameVersion } from "./workflows/engine.js";
55
58
  export type { WorkflowResult, RunWorkflowOptions, EngineSubsystem } from "./workflows/engine.js";
56
59
  export { buildInvokeChild } from "./workflows/invoke-child.js";
@@ -60,11 +63,13 @@ export { invokeStep, serveStep, parseStepResult, buildStepEnvs, StepExecutionErr
60
63
  export { PauseError, PauseExpiredError, PauseSchemaError, PauseRequestError, } from "./pause/errors.js";
61
64
  export type { PauseErrorCode } from "./pause/errors.js";
62
65
  export type { PauseRequest } from "./pause/pause-core.js";
63
- export type { RequestDecisionRequest, WaitForEventRequest } from "./pause/wrappers.js";
66
+ export type { WaitForEventRequest } from "./pause/wrappers.js";
64
67
  export type { StepRequest, StepResult, StepInvocationError, StepPauseRequest, StepHandler, StepHandlerResult, ServeStepRequest, } from "./step-invocation/index.js";
65
68
  export { agentLoop, parseAgentStatus, DEFAULT_CLAUDE_MODEL } from "./agent/agent-loop.js";
66
69
  export type { AgentLifecycleEvent, AgentLoopOpts, AgentLoopResult } from "./agent/agent-loop.js";
67
70
  export { agent } from "./agent/run-agent.js";
68
71
  export type { AgentOpts } from "./agent/run-agent.js";
72
+ export { AGENT_COMPOSE_MANUAL, buildAgentContextDoc, writeAgentContext } from "./agent/agent-context.js";
73
+ export type { AgentConnectorInfo } from "./agent/agent-context.js";
69
74
  export { AgentMessageSchema, parseAgentResponse } from "./agent/protocol.js";
70
75
  export { importSourceModule, TMP_DIR, LATEST_VERSION } from "./utils/source-loader.js";