@agent-compose/sdk 0.5.5 → 0.5.7

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 (40) hide show
  1. package/README.md +4 -4
  2. package/dist/agent/agent-loop-contract.test.d.ts +1 -0
  3. package/dist/agent/agent-loop.d.ts +1 -1
  4. package/dist/client.d.ts +65 -23
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.js +389 -109
  7. package/dist/runtimes/_cli-agent.d.ts +25 -8
  8. package/dist/runtimes/amp.d.ts +7 -6
  9. package/dist/runtimes/claude.d.ts +9 -1
  10. package/dist/runtimes/cli-agent.test.d.ts +9 -0
  11. package/dist/runtimes/codex.d.ts +6 -5
  12. package/dist/runtimes/openai-desktop.js +387 -109
  13. package/dist/sandbox-errors.d.ts +49 -0
  14. package/dist/sandbox.d.ts +68 -13
  15. package/dist/step-invocation/protocol.d.ts +6 -0
  16. package/dist/types/sandbox-environment.d.ts +1 -10
  17. package/dist/types/sandbox.d.ts +27 -3
  18. package/dist/types/workflow-metadata.d.ts +88 -23
  19. package/dist/types/workflow.d.ts +38 -10
  20. package/dist/utils/bundler.d.ts +38 -9
  21. package/dist/workflow-steps/workflow.d.ts +1 -3
  22. package/package.json +2 -2
  23. package/src/agent/agent-loop.ts +56 -7
  24. package/src/client.ts +144 -25
  25. package/src/index.ts +4 -2
  26. package/src/runtimes/_cli-agent.ts +75 -42
  27. package/src/runtimes/amp.ts +11 -6
  28. package/src/runtimes/claude.ts +66 -8
  29. package/src/runtimes/codex.ts +10 -5
  30. package/src/sandbox-errors.ts +53 -0
  31. package/src/sandbox.ts +378 -56
  32. package/src/step-invocation/invoker.ts +66 -8
  33. package/src/step-invocation/protocol.ts +9 -0
  34. package/src/step-invocation/server.ts +27 -4
  35. package/src/types/sandbox-environment.ts +1 -11
  36. package/src/types/sandbox.ts +28 -3
  37. package/src/types/workflow-metadata.ts +97 -26
  38. package/src/types/workflow.ts +38 -11
  39. package/src/utils/bundler.ts +43 -13
  40. package/src/workflow-steps/workflow.ts +1 -3
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 @@
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;
package/dist/client.d.ts CHANGED
@@ -13,20 +13,13 @@
13
13
  import type { SandboxNetworkPolicy } 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 } 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
@@ -61,13 +69,16 @@ export interface RegisterWorkflowInput {
61
69
  snapshots?: SnapshotConfig;
62
70
  /** Provider-neutral execution plan detected by the CLI bundler. */
63
71
  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[];
72
+ /** Connector requirements declared via `defineWorkflow({ connectors })`
73
+ * (ADR-0007). Validated against the server's provider registry at
74
+ * registration; tokens are injected at the network layer at dispatch. */
75
+ connectors?: ConnectorRequirements;
76
+ /** Connector-catalogue operation tag — see `ConnectorOperationTag`. */
77
+ connectorOperation?: ConnectorOperationTag;
78
+ /** Tier-1 invoke ACL declared via `defineWorkflow({ invokePolicy })`.
79
+ * Only meaningful when the workflow also declares `connectors` — the
80
+ * server gates dispatch on it before binding any grant. */
81
+ invokePolicy?: InvokePolicy;
71
82
  /** Input schema extracted from the workflow's `input` zod schema. */
72
83
  inputSchema?: IOSchema;
73
84
  /** Output schema extracted from the workflow's `output` zod schema. */
@@ -90,19 +101,16 @@ export interface InvokeWorkflowOptions {
90
101
  * vars after brokering. Replaces the template-level placeholders for
91
102
  * this run only — registered metadata is not mutated. */
92
103
  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[];
100
104
  /** Explicit parent run id. Pass `null` to suppress ambient RUN_ID auto-detection. */
101
105
  parentRunId?: string | null;
102
106
  /** Agent loop inside the parent run that caused this invoke, when applicable. */
103
107
  agentId?: string | null;
104
108
  /** Factory slug. Defaults to `"default"`. */
105
109
  factorySlug?: string;
110
+ /** Idempotency key — sent as the `Idempotency-Key` header. A repeat invoke
111
+ * with the same key inside the server's dedup window returns the original
112
+ * run instead of starting a new one (matches `resumePause`'s pattern). */
113
+ idempotencyKey?: string;
106
114
  }
107
115
  export interface InvokeAndWaitOptions extends InvokeWorkflowOptions {
108
116
  timeoutMs?: number;
@@ -182,6 +190,13 @@ export interface RunStatus<TOutput = unknown> {
182
190
  id: string;
183
191
  status: RunState;
184
192
  output?: TOutput;
193
+ /** The run's latest (`saveLatest`) snapshot id, populated once the run has
194
+ * succeeded — the boot source to fork this run's evolved filesystem from
195
+ * (pass as `snapshots.bootFrom` on a follow-up invoke). `null` while the run
196
+ * is still in flight or when it captured no snapshot. Lets an orchestrator
197
+ * fork a child straight off the `invokeChild` result without a separate
198
+ * `listRunSnapshots` call. */
199
+ latestSnapshotId?: string | null;
185
200
  }
186
201
  /** ADR-0006 step 10 — actor record returned on a successful resume.
187
202
  * Shape mirrors the server's `PauseResumeActor` type after the row
@@ -317,6 +332,20 @@ export interface EventRow {
317
332
  idempotencyKey: string | null;
318
333
  createdAt: string;
319
334
  }
335
+ export interface RunArtifactRow {
336
+ path: string;
337
+ factorySlug: string | null;
338
+ sizeBytes: number | null;
339
+ lastWriteAt: string;
340
+ /** Opening text of the file (≤320 chars) — null for binary/empty. */
341
+ preview: string | null;
342
+ }
343
+ export interface FactoryFileWriteResult {
344
+ path: string;
345
+ contentHash: string;
346
+ sizeBytes: number;
347
+ created: boolean;
348
+ }
320
349
  export interface ReportEventInput {
321
350
  name: string;
322
351
  body: unknown;
@@ -331,7 +360,7 @@ export interface ListEventsOptions {
331
360
  factorySlug?: string;
332
361
  limit?: number;
333
362
  /** Case-insensitive substring match. Server uses `ILIKE %name%`, so
334
- * `"mem"` matches `memory.fact`, `memory.usage`, etc. Pass the
363
+ * `"site"` matches `site.created`, `site.failed`, etc. Pass the
335
364
  * full event name for an effectively-exact filter (any string is a
336
365
  * substring of itself). */
337
366
  name?: string;
@@ -580,6 +609,19 @@ export declare class AgentComposeClient {
580
609
  * like quality.accepted, defect.regression, or intervention.override. */
581
610
  reportEvent(runId: string, input: ReportEventInput): Promise<EventRow>;
582
611
  listRunEvents(runId: string): Promise<EventRow[]>;
612
+ /** Files the run wrote on the factory drive — run-attributed revisions,
613
+ * latest write per path, paths the run later deleted excluded. */
614
+ listRunArtifacts(runId: string): Promise<RunArtifactRow[]>;
615
+ /** Write (create or overwrite) one file on a factory's drive. */
616
+ putFactoryFile(path: string, content: string | Uint8Array, opts?: {
617
+ factorySlug?: string;
618
+ contentType?: string;
619
+ }): Promise<FactoryFileWriteResult>;
620
+ /** Read one file's current content (or a specific revision) as text. */
621
+ getFactoryFile(path: string, opts?: {
622
+ factorySlug?: string;
623
+ revision?: number;
624
+ }): Promise<string>;
583
625
  /** List events ingested into a factory, newest first. Supports
584
626
  * case-insensitive substring filter (`name`) and timestamp-cursor
585
627
  * 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, 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, 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,6 +51,7 @@ 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";
54
+ export { SandboxUnavailableError, SANDBOX_UNAVAILABLE_PREFIX } from "./sandbox-errors.js";
53
55
  export type { SandboxCreateOpts, SandboxNetworkPolicy, SandboxNetworkHeaderTransform, SandboxNetworkAllowRule, SandboxNetworkSubnetPolicy, SandboxProviderName, SandboxQuotaResult, OwnedSandboxResult, OwnedSandbox, ParseSseExecStreamOptions, SandboxCommandRunOptions, SandboxCommandResult, } from "./sandbox.js";
54
56
  export { runWorkflow, WorkflowError, EngineError, classifyError, parseNameVersion } from "./workflows/engine.js";
55
57
  export type { WorkflowResult, RunWorkflowOptions, EngineSubsystem } from "./workflows/engine.js";