@agent-compose/sdk 0.2.5 → 0.3.1

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.
@@ -477,18 +477,24 @@ var WORKFLOW_BRAND = Symbol.for("@agent-compose/sdk.Workflow");
477
477
  // src/types/workflow-metadata.ts
478
478
  function extractMetadata(source) {
479
479
  const out = {};
480
+ if (source.description !== undefined)
481
+ out.description = source.description;
480
482
  if (source.networkPolicy !== undefined)
481
483
  out.networkPolicy = freezeMetadataValue(source.networkPolicy);
482
484
  if (source.placeholders !== undefined)
483
485
  out.placeholders = Object.freeze({ ...source.placeholders });
484
- if (source.snapshot !== undefined)
485
- out.snapshot = source.snapshot;
486
- if (source.saveSnapshot !== undefined)
487
- out.saveSnapshot = source.saveSnapshot;
486
+ if (source.inputSchema !== undefined)
487
+ out.inputSchema = freezeMetadataValue(source.inputSchema);
488
+ if (source.outputSchema !== undefined)
489
+ out.outputSchema = freezeMetadataValue(source.outputSchema);
490
+ if (source.snapshots !== undefined)
491
+ out.snapshots = Object.freeze({ ...source.snapshots });
488
492
  if (source.processors !== undefined)
489
493
  out.processors = Object.freeze([...source.processors]);
490
494
  if (source.memory !== undefined)
491
- out.memory = typeof source.memory === "object" && source.memory !== null ? Object.freeze({ ...source.memory }) : source.memory;
495
+ out.memory = source.memory;
496
+ if (source.postRunHooks !== undefined)
497
+ out.postRunHooks = Object.freeze([...source.postRunHooks]);
492
498
  return Object.freeze(out);
493
499
  }
494
500
  function freezeMetadataValue(value) {
@@ -583,7 +589,9 @@ function defineSandboxEnvironment(env) {
583
589
  throw new Error(`defineSandboxEnvironment(${env.name}): 'setup' must be a function`);
584
590
  }
585
591
  return defineWorkflow({
586
- saveSnapshot: env.saveSnapshot ?? true,
592
+ ...env.description !== undefined ? { description: env.description } : {},
593
+ snapshots: env.snapshots ?? { saveLatest: true },
594
+ memory: env.memory ?? false,
587
595
  run: async (_ctx, sandbox) => env.setup(sandbox)
588
596
  });
589
597
  }
@@ -695,12 +703,18 @@ function templatePath(factorySlug, ...rest) {
695
703
  const tail = rest.length > 0 ? "/" + rest.map(encodeURIComponent).join("/") : "";
696
704
  return `/api/v1/factories/${encodeURIComponent(factorySlug)}/templates${tail}`;
697
705
  }
706
+ var PUBLIC_API_HOST = "https://api.agentcompose.ai";
698
707
 
699
708
  class AgentComposeClient {
700
709
  fetch;
701
710
  baseUrl;
702
711
  apiKey;
703
- constructor(baseUrl, apiKey) {
712
+ constructor(options = {}) {
713
+ const apiKey = options.apiKey ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_API_KEY : undefined) ?? "";
714
+ if (!apiKey) {
715
+ throw new Error("AgentComposeClient: `apiKey` is required. Pass it as `{ apiKey }` " + "or set the AGENT_COMPOSE_API_KEY env var.");
716
+ }
717
+ const baseUrl = options.baseUrl ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_URL : undefined) ?? PUBLIC_API_HOST;
704
718
  this.baseUrl = baseUrl.replace(/\/$/, "");
705
719
  this.apiKey = apiKey;
706
720
  this.fetch = ofetch.create({
@@ -723,10 +737,11 @@ class AgentComposeClient {
723
737
  method: "POST",
724
738
  body: {
725
739
  input,
726
- ...opts?.snapshot !== undefined ? { snapshot: opts.snapshot } : {},
727
- ...opts?.saveSnapshot !== undefined ? { saveSnapshot: opts.saveSnapshot } : {},
740
+ ...opts?.snapshots !== undefined ? { snapshots: opts.snapshots } : {},
728
741
  ...opts?.networkPolicy !== undefined ? { networkPolicy: opts.networkPolicy } : {},
729
742
  ...opts?.placeholders !== undefined ? { placeholders: opts.placeholders } : {},
743
+ ...opts?.memory !== undefined ? { memory: opts.memory } : {},
744
+ ...opts?.postRunHooks !== undefined ? { postRunHooks: opts.postRunHooks } : {},
730
745
  ...parentRunId ? { parentRunId } : {},
731
746
  ...opts?.agentId ? { agentId: opts.agentId } : {}
732
747
  }
@@ -747,16 +762,29 @@ class AgentComposeClient {
747
762
  throw new AgentComposeError(504, `invokeAndWait: run ${runId} did not settle within ${timeoutMs}ms`);
748
763
  }
749
764
  async listSnapshots(opts) {
765
+ const body = await this.listSnapshotsPage(opts);
766
+ return body.data;
767
+ }
768
+ async listSnapshotsPage(opts) {
769
+ const factorySlug = opts?.factorySlug ?? DEFAULT_FACTORY;
750
770
  const q2 = new URLSearchParams;
751
771
  if (opts?.workflow)
752
772
  q2.set("workflow", opts.workflow);
753
773
  if (opts?.limit != null)
754
774
  q2.set("limit", String(opts.limit));
755
- const body = await this.fetch(`/api/v1/snapshots${q2.toString() ? `?${q2}` : ""}`);
756
- return body.data;
775
+ if (opts?.before)
776
+ q2.set("before", opts.before);
777
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/snapshots${q2.toString() ? `?${q2}` : ""}`);
757
778
  }
758
779
  deleteSnapshot(runId) {
759
- return this.fetch(`/api/v1/workflows/${runId}/snapshot`, { method: "DELETE" });
780
+ return this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/snapshot`, { method: "DELETE" });
781
+ }
782
+ async listRunSnapshots(runId) {
783
+ const body = await this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/snapshots`);
784
+ return body.data;
785
+ }
786
+ deleteRunSnapshot(runId, snapshotId) {
787
+ return this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/snapshots/${encodeURIComponent(snapshotId)}`, { method: "DELETE" });
760
788
  }
761
789
  getStatus(runId) {
762
790
  return this.fetch(`/api/v1/workflows/${runId}/status`);
@@ -1017,17 +1045,59 @@ async function bundleWorkflow(workflowPath, overrides) {
1017
1045
  sourceHash: sha256(source),
1018
1046
  bundlerVersion: BUNDLER_VERSION
1019
1047
  };
1048
+ const inputSchema = extractIOSchema(workflow.input);
1049
+ const outputSchema = extractIOSchema(workflow.output);
1020
1050
  return {
1021
1051
  source,
1022
1052
  manifest,
1023
1053
  workflowPlan: plan,
1024
1054
  networkPolicy: overrides?.networkPolicy ?? metadata.networkPolicy,
1025
1055
  placeholders: overrides?.placeholders ?? metadata.placeholders,
1026
- ...metadata.snapshot !== undefined ? { snapshot: metadata.snapshot } : {},
1027
- ...metadata.saveSnapshot !== undefined ? { saveSnapshot: metadata.saveSnapshot } : {},
1028
- ...metadata.memory !== undefined ? { memory: metadata.memory } : {}
1056
+ ...inputSchema !== undefined ? { inputSchema } : {},
1057
+ ...outputSchema !== undefined ? { outputSchema } : {},
1058
+ ...metadata.snapshots !== undefined ? { snapshots: metadata.snapshots } : {},
1059
+ ...metadata.memory !== undefined ? { memory: metadata.memory } : {},
1060
+ ...metadata.postRunHooks !== undefined ? { postRunHooks: metadata.postRunHooks } : {}
1029
1061
  };
1030
1062
  }
1063
+ function extractIOSchema(zodSchema) {
1064
+ let json;
1065
+ try {
1066
+ const z3 = __require("zod");
1067
+ if (!z3.toJSONSchema)
1068
+ return;
1069
+ json = z3.toJSONSchema(zodSchema);
1070
+ } catch {
1071
+ return;
1072
+ }
1073
+ if (!json || typeof json !== "object")
1074
+ return;
1075
+ if (Object.keys(json).filter((k) => k !== "$schema").length === 0)
1076
+ return;
1077
+ const out = {};
1078
+ if (json.type !== undefined)
1079
+ out.type = json.type;
1080
+ if (json.description !== undefined)
1081
+ out.description = String(json.description);
1082
+ if (json.properties && typeof json.properties === "object") {
1083
+ const props = {};
1084
+ for (const [key, raw] of Object.entries(json.properties)) {
1085
+ if (raw && typeof raw === "object") {
1086
+ const r = raw;
1087
+ props[key] = {};
1088
+ if (r.type !== undefined)
1089
+ props[key].type = r.type;
1090
+ if (r.description !== undefined)
1091
+ props[key].description = String(r.description);
1092
+ }
1093
+ }
1094
+ if (Object.keys(props).length > 0)
1095
+ out.properties = props;
1096
+ }
1097
+ if (Array.isArray(json.required))
1098
+ out.required = json.required.map(String);
1099
+ return out;
1100
+ }
1031
1101
  // src/utils/schemas.ts
1032
1102
  import { z as z3 } from "zod";
1033
1103
  var AgentStatusSchema = z3.object({
@@ -1544,7 +1614,11 @@ function makeVercelSandboxProvider(sb, globalEnvs) {
1544
1614
  },
1545
1615
  async snapshot() {
1546
1616
  const res = await sb.snapshot({ expiration: 0 });
1547
- return { snapshotId: res.snapshotId };
1617
+ const sizeBytes = typeof res.sizeBytes === "number" ? res.sizeBytes : undefined;
1618
+ return {
1619
+ snapshotId: res.snapshotId,
1620
+ ...sizeBytes !== undefined ? { sizeBytes } : {}
1621
+ };
1548
1622
  }
1549
1623
  };
1550
1624
  }
@@ -2049,7 +2123,7 @@ function buildInvokeChild(runId, opts = {}) {
2049
2123
  if (!baseUrl || !apiKey) {
2050
2124
  throw new Error("ctx.invokeChild requires AGENT_COMPOSE_URL and AGENT_COMPOSE_API_KEY");
2051
2125
  }
2052
- childClient = new AgentComposeClient(baseUrl, apiKey);
2126
+ childClient = new AgentComposeClient({ apiKey, baseUrl });
2053
2127
  return childClient;
2054
2128
  };
2055
2129
  return (name, input, childOpts) => getChildClient().invokeAndWait(name, input, {
@@ -1,16 +1,14 @@
1
1
  /**
2
2
  * A sandbox environment is a workflow whose job is to leave its VM in a
3
3
  * configured state, then snapshot it so other workflows can boot from that
4
- * state. Capture is **opt-in**: the wrapper below sets `saveSnapshot: true`
5
- * by default (opt out with `saveSnapshot: false` if you only want side
6
- * effects).
4
+ * state. Capture is **opt-in**: the wrapper below sets
5
+ * `snapshots: { saveLatest: true }` by default (opt out with
6
+ * `saveLatest: false` if you only want side effects).
7
7
  *
8
- * Once captured, reference the snapshot from another workflow's `snapshot`
9
- * field by run UUID, workflow name, or `name@version`:
8
+ * Once captured, reference the snapshot from another workflow's
9
+ * `snapshots.bootFrom` field by provider snapshot id:
10
10
  *
11
- * snapshot: "my-setup" // most recent successful snapshot
12
- * snapshot: "my-setup@v1" // version-scoped recency
13
- * snapshot: "<run-uuid>" // pinned to an exact run
11
+ * snapshots: { bootFrom: { snapshotId: "snap_..." } }
14
12
  *
15
13
  * `defineSandboxEnvironment` is sugar over `defineWorkflow` — it makes the
16
14
  * setup recipe read like an imperative script by supplying the local
@@ -20,7 +18,7 @@
20
18
  * 1. Author a setup file with `defineSandboxEnvironment`.
21
19
  * 2. `agentc register setup.ts --build` — registers and invokes once to
22
20
  * capture the snapshot.
23
- * 3. Other workflows declare `snapshot: "name"` and boot from it.
21
+ * 3. Other workflows declare `snapshots: { bootFrom: { snapshotId } }`.
24
22
  * 4. `agentc snapshot list` / `delete` to manage the Vercel storage bill.
25
23
  *
26
24
  * @example
@@ -37,16 +35,27 @@
37
35
  */
38
36
  import type { SandboxProvider } from "./sandbox.js";
39
37
  import type { Workflow } from "../workflow-steps/types.js";
38
+ import type { SnapshotConfig } from "./workflow-metadata.js";
40
39
  export interface SandboxEnvironmentDefinition {
41
40
  name: string;
42
41
  description?: string;
43
42
  setup: (sb: SandboxProvider) => Promise<void>;
44
- /** Override the sugar's `saveSnapshot: true` default. Set `false` to opt
45
- * out of snapshot capture (rarely useful — an env with no snapshot can't
46
- * be referenced as the `snapshot` field on another workflow). */
47
- saveSnapshot?: boolean;
43
+ /** Override the sugar's `{ saveLatest: true }` default. Set
44
+ * `{ saveLatest: false }` to opt out of snapshot capture (rarely
45
+ * useful — an env with no snapshot can't be referenced as a
46
+ * `bootFrom` on another workflow). */
47
+ snapshots?: SnapshotConfig;
48
+ /** Override the sugar's `memory: false` default. Setup workflows
49
+ * don't typically benefit from memory extraction; opt in explicitly
50
+ * when they do. */
51
+ memory?: boolean;
48
52
  }
49
53
  /** Sugar over `defineWorkflow` for setup-only workflows that exist to
50
54
  * capture a snapshot. The workflow takes no meaningful input and returns
51
- * nothing — its value is the side effect on the sandbox VM. */
55
+ * nothing — its value is the side effect on the sandbox VM.
56
+ *
57
+ * Defaults `memory: false` because sandbox environments emit setup
58
+ * output (npm installs, command exit codes) rather than agent traces
59
+ * worth memorising. Authors can opt in explicitly via `env.memory:
60
+ * true` if their environment somehow does want extraction. */
52
61
  export declare function defineSandboxEnvironment(env: SandboxEnvironmentDefinition): Workflow<Record<string, unknown>, void>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Regression test: `defineSandboxEnvironment.description` must reach
3
+ * the workflow's metadata so the dashboard template tile shows it
4
+ * instead of "No description.".
5
+ *
6
+ * Earlier the wrapper dropped the field on the floor — `agent-env`
7
+ * literally had `description: "..."` in source but the dashboard
8
+ * rendered "No description." because nothing propagated it through to
9
+ * `WorkflowMetadata.description`.
10
+ */
11
+ export {};
@@ -29,9 +29,14 @@ export interface SandboxProvider {
29
29
  /** Capture the running sandbox's state as a reusable snapshot. Vercel
30
30
  * supports it natively; E2B's model is Dockerfile-based and doesn't map
31
31
  * cleanly — `undefined` on providers that don't. Used by the server's
32
- * `--build` flow to stamp the snapshot id on the workflow row. */
32
+ * `--build` flow to stamp the snapshot id on the workflow row.
33
+ *
34
+ * `sizeBytes` is the on-disk footprint reported by the provider. May
35
+ * be omitted when the provider doesn't expose it; the server stores
36
+ * `null` for missing values rather than estimating. */
33
37
  snapshot?(): Promise<{
34
38
  snapshotId: string;
39
+ sizeBytes?: number;
35
40
  }>;
36
41
  }
37
42
  /** Stateless provider-level snapshot deletion — no live sandbox needed,
@@ -18,19 +18,88 @@ import type { Processor } from "../processors/processor.js";
18
18
  * The bundler reads these from the default export at registration time
19
19
  * and forwards them to the server's POST /api/v1/templates payload.
20
20
  */
21
- /** Server-side knob for whether/how a Workflow Memory agent should run
22
- * after this workflow completes. `"default"` runs the built-in extractor;
23
- * `false` disables; an object names a custom memory workflow to dispatch. */
24
- export type WorkflowMemoryConfig = "default" | false | {
25
- workflow: string;
21
+ /** Whether the built-in Workflow Memory extractor should run after this
22
+ * workflow completes. Boolean toggle — custom post-run workflows live
23
+ * in the separate `postRunHooks` array on `WorkflowMetadata`. */
24
+ export type WorkflowMemoryConfig = boolean;
25
+ /** Where a run boots from. The snapshot id is the unit of identity —
26
+ * each captured snapshot already records the workflow + version it
27
+ * came from on the snapshot row, so there's no separate "latest of
28
+ * workflow X" resolution at dispatch time. Operators pick a snapshot
29
+ * from the dashboard snapshot list (or `agentc snapshot list`) and
30
+ * paste the id here.
31
+ *
32
+ * Omit `bootFrom` entirely to boot a fresh base sandbox. */
33
+ export type BootSnapshot = {
34
+ snapshotId: string;
26
35
  };
36
+ /** Snapshot configuration — boot source plus capture knobs. One object
37
+ * per workflow / per invocation; collapsing boot + capture under a
38
+ * single key reads as "all snapshot config lives here." */
39
+ export interface SnapshotConfig {
40
+ /** Where the runner restores from at run start. Structured (workflow
41
+ * ref or snapshot id) so the intent is explicit at the call site. */
42
+ bootFrom?: BootSnapshot;
43
+ /** Capture the sandbox state on terminal success. The latest pointer
44
+ * on `workflow_runs.vercel_snapshot_id` always tracks the most
45
+ * recent capture; without `retainSteps`, prior captures are deleted
46
+ * as new ones land — constant storage cost. */
47
+ saveLatest?: boolean;
48
+ /** Only meaningful with `saveLatest: true`. Retain every step's
49
+ * snapshot in `run_step_snapshots` so a future dispatch can boot
50
+ * from a specific step's checkpoint via its `snapshotId`. Cost
51
+ * scales linearly with step count. */
52
+ retainSteps?: boolean;
53
+ }
54
+ /** JSON-Schema-shaped description captured by the bundler from a
55
+ * workflow's `input` or `output` zod schema. Carried in template
56
+ * metadata so the dashboard can render typed input forms + output
57
+ * type tables. */
58
+ export interface IOSchema {
59
+ /** JSON Schema `type` keyword, when single-valued. Omitted for unions / unknowns. */
60
+ type?: string | string[];
61
+ /** Free-form description pulled from `.describe(...)` on the root. */
62
+ description?: string;
63
+ /** Object-shape: one entry per property. */
64
+ properties?: Record<string, {
65
+ type?: string | string[];
66
+ description?: string;
67
+ }>;
68
+ /** Required property names — relevant only when `type === "object"`. */
69
+ required?: string[];
70
+ }
71
+ /** Alias kept for backwards source-compatibility with the original
72
+ * output-only release. New code should prefer `IOSchema`. */
73
+ export type OutputSchema = IOSchema;
27
74
  export interface WorkflowMetadata {
75
+ /** One-line, human-readable description of what the workflow does.
76
+ * Surfaced on the dashboard template tile + run page header. Authors
77
+ * set it via `defineWorkflow({ description: "..." })` (either shape)
78
+ * or `defineSandboxEnvironment({ description: "..." })`. */
79
+ description?: string;
28
80
  networkPolicy?: SandboxNetworkPolicy;
29
81
  placeholders?: Record<string, string>;
30
- snapshot?: string;
31
- saveSnapshot?: boolean;
82
+ /** Input schema captured at bundle time from the workflow's
83
+ * declared `input` zod schema. Step-form workflows populate this
84
+ * automatically; run-form workflows (no explicit input schema —
85
+ * defaults to `z.unknown()`) leave it undefined. */
86
+ inputSchema?: IOSchema;
87
+ /** Output schema captured at bundle time from the workflow's
88
+ * declared `output` zod schema. Step-form workflows populate this
89
+ * automatically; run-form workflows whose `run()` returns
90
+ * arbitrarily-typed values leave it undefined. */
91
+ outputSchema?: IOSchema;
92
+ /** All snapshot config — boot source + capture mode. */
93
+ snapshots?: SnapshotConfig;
32
94
  processors?: readonly Processor[];
33
- memory?: WorkflowMemoryConfig;
95
+ /** Run the built-in memory extractor after this workflow completes.
96
+ * Opt-in; defaults to false when omitted. */
97
+ memory?: boolean;
98
+ /** Ordered list of workflow names that run after this workflow
99
+ * completes. The runtime dispatches them in declaration order; the
100
+ * built-in memory extractor (when `memory: true`) runs as a separate
101
+ * hook alongside whatever's declared here. */
102
+ postRunHooks?: readonly string[];
34
103
  }
35
104
  /**
36
105
  * Pull the server-readable declarations off a source object (run-form
@@ -25,8 +25,8 @@ export type { WorkflowMetadata } from "./workflow-metadata.js";
25
25
  export interface AgentEventSink {
26
26
  emit(event: AgentLifecycleEvent): void | Promise<void>;
27
27
  }
28
- import type { WorkflowMemoryConfig } from "./workflow-metadata.js";
29
- export type { WorkflowMemoryConfig };
28
+ import type { WorkflowMemoryConfig, SnapshotConfig, BootSnapshot, IOSchema, OutputSchema } from "./workflow-metadata.js";
29
+ export type { WorkflowMemoryConfig, SnapshotConfig, BootSnapshot, IOSchema, OutputSchema };
30
30
  /** Turn/iteration budget for `agent(opts)`. Re-exported here so authors
31
31
  * can type per-invoke budget overrides they pass as workflow input. */
32
32
  export interface AgentBudget {
@@ -67,23 +67,26 @@ export type WorkflowFn<TOutput = unknown, TInput extends Record<string, unknown>
67
67
  * works — the workflow just runs with secrets passed directly in env.
68
68
  */
69
69
  export interface WorkflowDefinition<TOutput = unknown, TInput extends Record<string, unknown> = Record<string, unknown>> {
70
+ /** One-line, human-readable description of what this workflow does.
71
+ * Surfaced on the dashboard template tile + run page header. */
72
+ description?: string;
70
73
  run: WorkflowFn<TOutput, TInput>;
71
74
  /**
72
- * Reference to a snapshot the runner should boot from at run start.
73
- * Accepts a run UUID, a workflow name, or `name@version` — any workflow
74
- * registered with `--build` produces a snapshot you can name here. The
75
- * runner VM starts in that pre-configured state. Per-invocation
76
- * `invoke({ snapshot })` overrides this default.
77
- */
78
- snapshot?: string;
79
- /**
80
- * Capture a snapshot of the sandbox on successful /complete. Snapshots
81
- * are long-lived (never auto-expire) — customers list + delete them
82
- * explicitly via `agentc snapshot list/delete`. Per-invocation
83
- * `invoke({ saveSnapshot })` overrides this default.
84
- * `defineSandboxEnvironment` sugar sets this to true by default.
75
+ * All snapshot config — boot source plus capture mode.
76
+ *
77
+ * `snapshots.bootFrom`: the runner restores from this exact provider
78
+ * snapshot id at run start. Omit to boot a fresh sandbox.
79
+ *
80
+ * `snapshots.saveLatest`: `true` captures one snapshot after each
81
+ * successful step (latest-only — prior is freed).
82
+ * `{ saveLatest: true, retainSteps: true }` keeps every step's
83
+ * snapshot for fork / replay / time-travel.
84
+ *
85
+ * Snapshots are long-lived (never auto-expire). List + delete via
86
+ * `agentc snapshot list/delete`. Per-invocation
87
+ * `invoke({ snapshots })` overrides this default.
85
88
  */
86
- saveSnapshot?: boolean;
89
+ snapshots?: SnapshotConfig;
87
90
  /**
88
91
  * Outbound network policy for the runner sandbox.
89
92
  * Use "*": [] to allow all traffic while still injecting headers for specific domains.
@@ -120,10 +123,14 @@ export interface WorkflowDefinition<TOutput = unknown, TInput extends Record<str
120
123
  * }
121
124
  */
122
125
  placeholders?: Record<string, string>;
123
- /** Workflow Memory extraction. Defaults to "default" when omitted.
124
- * Set false to skip memory extraction for this workflow, or point at a
125
- * custom memory workflow once custom extractors are supported. */
126
+ /** Run the built-in memory extractor after this workflow completes.
127
+ * Opt-in; defaults to false when omitted. */
126
128
  memory?: WorkflowMemoryConfig;
129
+ /** Ordered list of workflow names to dispatch as post-hooks after
130
+ * this workflow completes. Each hook receives the source run's
131
+ * context. The memory extractor (when `memory: true`) runs as an
132
+ * additional hook alongside these. */
133
+ postRunHooks?: readonly string[];
127
134
  }
128
135
  /**
129
136
  * Declare a workflow. Two forms; both return a `Workflow` whose
@@ -19,7 +19,7 @@
19
19
  * this function returns alongside the bundled bytes, and cross-checks the
20
20
  * manifest's `sourceHash` against the source it received.
21
21
  */
22
- import type { WorkflowMemoryConfig } from "../types/workflow.js";
22
+ import type { WorkflowMemoryConfig, SnapshotConfig } from "../types/workflow.js";
23
23
  import type { SandboxNetworkPolicy } from "../sandbox.js";
24
24
  import { type WorkflowPlan } from "../types/workflow-plan.js";
25
25
  /** Bumped when the manifest contract changes in a way the server should
@@ -51,15 +51,20 @@ export interface BundledWorkflow {
51
51
  manifest: WorkflowManifest;
52
52
  networkPolicy?: SandboxNetworkPolicy;
53
53
  placeholders?: Record<string, string>;
54
- /** Run UUID, workflow name, or `name@version` referencing the snapshot
55
- * this workflow's runner boots from, if declared via the `snapshot`
56
- * field on `defineWorkflow`. */
57
- snapshot?: string;
58
- /** Default capture-on-success flag from the workflow definition. */
59
- saveSnapshot?: boolean;
54
+ /** Snapshot config from the workflow definition — `bootFrom` (where to
55
+ * restore at run start), `save`, `retain`. */
56
+ snapshots?: SnapshotConfig;
60
57
  workflowPlan: WorkflowPlan;
61
58
  /** Workflow Memory extractor config. */
62
59
  memory?: WorkflowMemoryConfig;
60
+ /** Ordered post-hook workflow names declared on the workflow. */
61
+ postRunHooks?: readonly string[];
62
+ /** Compact JSON-Schema-shaped description of the workflow's input
63
+ * type. Extracted from the workflow's declared `input` zod schema
64
+ * at bundle time; undefined when the schema is `z.unknown()`. */
65
+ inputSchema?: import("../types/workflow-metadata.js").IOSchema;
66
+ /** Same for the workflow's output zod schema. */
67
+ outputSchema?: import("../types/workflow-metadata.js").IOSchema;
63
68
  }
64
69
  /**
65
70
  * Parse the bundled source and assert the default export is a CallExpression
@@ -20,6 +20,7 @@
20
20
  */
21
21
  import type { z } from "zod";
22
22
  import type { Step, Workflow } from "./types.js";
23
+ import type { SnapshotConfig, WorkflowMemoryConfig } from "../types/workflow-metadata.js";
23
24
  import type { SandboxNetworkPolicy } from "../sandbox.js";
24
25
  import type { Processor } from "../processors/processor.js";
25
26
  export interface WorkflowBuilder<TInput, TCurrent> {
@@ -37,12 +38,16 @@ export interface WorkflowBuilder<TInput, TCurrent> {
37
38
  }
38
39
  export interface StepWorkflowDefinition<TInput, TOutput> {
39
40
  id: string;
41
+ /** One-line, human-readable description of what this workflow does.
42
+ * Surfaced on the dashboard template tile + run page header. */
43
+ description?: string;
40
44
  input: z.ZodType<TInput>;
41
45
  output: z.ZodType<TOutput>;
42
46
  networkPolicy?: SandboxNetworkPolicy;
43
47
  placeholders?: Record<string, string>;
44
- snapshot?: string;
45
- saveSnapshot?: boolean;
48
+ snapshots?: SnapshotConfig;
49
+ memory?: WorkflowMemoryConfig;
50
+ postRunHooks?: readonly string[];
46
51
  processors?: readonly Processor[];
47
52
  }
48
53
  export declare function createStepWorkflow<TInput, TOutput>(opts: StepWorkflowDefinition<TInput, TOutput>): WorkflowBuilder<TInput, TInput>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-compose/sdk",
3
- "version": "0.2.5",
3
+ "version": "0.3.1",
4
4
  "description": "Client library for agent-compose — define agents, runtimes, and workflows, and invoke them against an agent-compose server.",
5
5
  "license": "MIT",
6
6
  "repository": {