antpath 0.10.13 → 0.10.15

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/docs/events.md CHANGED
@@ -25,16 +25,17 @@ for await (const event of ref.stream({ intervalMs: 1000 })) {
25
25
 
26
26
  > **Transport.** `stream()` polls under the hood — it issues `GET
27
27
  > /api/runs/:id/events?since=…` calls at `intervalMs` until the run
28
- > reaches a terminal status. There is no SSE / WebSocket push from the
29
- > BFF today. For latency-sensitive UIs this is acceptable down to about
30
- > 500 ms; below that, every dashboard request is one round-trip. A push
31
- > transport is on the public backlog not committed to a release.
28
+ > reaches a terminal status. The dashboard BFF also exposes an SSE
29
+ > endpoint (`GET /api/runs/:id/events/stream`) that the dashboard UI
30
+ > consumes; an SSE-backed SDK transport is on the public backlog. For
31
+ > latency-sensitive consumers the polling baseline is acceptable down
32
+ > to about 500 ms.
32
33
 
33
34
  The CLI mirrors the same surface:
34
35
 
35
36
  ```bash
36
- antpath events <run-id> --api-token … --workspace … --dashboard-url … # snapshot
37
- antpath events <run-id> --follow --api-token … --workspace … --dashboard-url … # stream until terminal
37
+ antpath events <run-id> --api-token … [--dashboard-url …] # snapshot
38
+ antpath events <run-id> --follow --api-token … [--dashboard-url …] # stream until terminal
38
39
  ```
39
40
 
40
41
  Both surfaces observe the same events. A subscriber attached after `submitRun()` returns replays the events it missed, then continues live.
@@ -5,27 +5,20 @@ title: antpath quickstart
5
5
  # Quickstart
6
6
 
7
7
  1. Get an antpath SDK API token (`ant_…`).
8
- 2. Define a secret-free Template in TypeScript (or JSON / a `.mjs` default export).
9
- 3. Create `AntpathClient` the workspace is derived server-side from the token.
10
- 4. Submit the run with an inline `secrets` bundle. Wait for terminal status. Fetch outputs.
8
+ 2. Create `AntpathClient` the workspace is derived server-side from the token.
9
+ 3. Submit the run with the agent's brief plus an inline `secrets` bundle. Wait for terminal status. Fetch outputs.
11
10
 
12
11
  ```ts
13
- import { AntpathClient, defineTemplate, string } from "antpath";
12
+ import { AntpathClient } from "antpath";
14
13
 
15
14
  const client = new AntpathClient({
16
15
  apiToken: process.env.ANTPATH_API_TOKEN!
17
16
  // baseUrl defaults to https://www.antpath.ai — set it for self-hosted deployments.
18
17
  });
19
18
 
20
- const template = defineTemplate({
21
- name: "hello",
19
+ const ref = await client.submitRun({
22
20
  model: "claude-haiku-4-5",
23
- messages: ["Write a short answer about {{topic}}."],
24
- variables: { topic: string() }
25
- });
26
-
27
- const ref = await client.submitRun(template, {
28
- variables: { topic: "agent-first SDK design" },
21
+ prompt: "Write a short answer about agent-first SDK design.",
29
22
  secrets: { anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! } }
30
23
  });
31
24
 
@@ -34,17 +27,34 @@ console.log(run.status);
34
27
  console.log(await ref.outputs());
35
28
  ```
36
29
 
30
+ For reusable, credential-free configs, wrap a producer with `defineRun`:
31
+
32
+ ```ts
33
+ import { defineRun } from "antpath";
34
+
35
+ const summarise = defineRun((topic: string) => ({
36
+ model: "claude-haiku-4-5",
37
+ prompt: `Write a short answer about ${topic}.`
38
+ }));
39
+
40
+ const ref = await client.submitRun({
41
+ ...summarise("agent-first SDK design"),
42
+ secrets: { anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! } }
43
+ });
44
+ ```
45
+
37
46
  Or from the shell:
38
47
 
39
48
  ```bash
40
- antpath run ./template.json \
49
+ antpath run \
41
50
  --api-token "$ANTPATH_API_TOKEN" \
42
51
  --anthropic-api-key "$ANTHROPIC_API_KEY" \
43
- --var topic="agent-first SDK design" \
52
+ --model claude-haiku-4-5 \
53
+ --prompt "Write a short answer about agent-first SDK design." \
44
54
  --follow
45
55
  ```
46
56
 
47
- Both surfaces hit the same dashboard BFF and operate on the same durable run records — pick whichever is most convenient.
57
+ For a config-file flow, pass `--config <path>` with a JSON file matching the `Blueprint` shape (`{ model, system?, prompt, skills?, mcpServers?, environment?, cleanup?, proxyEndpoints?, metadata? }`). Both surfaces hit the same dashboard BFF and operate on the same durable run records — pick whichever is most convenient.
48
58
 
49
59
  ## Safe retries with `idempotencyKey`
50
60
 
@@ -57,7 +67,7 @@ Every `submitRun` call carries an `idempotencyKey`. When omitted the SDK auto-ge
57
67
  | Same key + **different** request body hash | HTTP 409 — body `{ error: { message, code: "idempotency_conflict", details: { existingRunId } } }`. The SDK throws an `HttpError` carrying that body. Use `details.existingRunId` to adopt the pre-existing run, or pick a fresh key. |
58
68
  | Omitted `idempotencyKey` | A new UUID is generated on every call — repeat submissions create new runs. |
59
69
 
60
- The request hash is computed server-side over the canonical submission JSON (model, prompt, system, environment, skill refs, MCP server descriptors, proxy endpoints, `outputDirs`, etc.) so reordering JSON keys, adding whitespace, or rotating the inline secret bundle does **not** change the hash. Bumping a variable or changing the prompt does.
70
+ The request hash is computed server-side over the canonical submission JSON (model, prompt, system, environment, skill refs, MCP server descriptors, proxy endpoints, `outputDirs`, etc.) so reordering JSON keys, adding whitespace, or rotating the inline secret bundle does **not** change the hash. Changing the prompt, model, system, or any other non-secret field does.
61
71
 
62
72
  Pattern for safe retries:
63
73
 
package/docs/templates.md CHANGED
@@ -1,24 +1,53 @@
1
1
  ---
2
- title: Templates
2
+ title: Blueprints (run configuration)
3
3
  ---
4
4
 
5
- # Templates
5
+ # Blueprints
6
6
 
7
- Templates are code-defined, immutable, secret-free run configurations.
7
+ A `Blueprint` is the credential-free shape that drives a run. The legacy `Template` wrapper and `{{var}}` DSL are gone — interpolate values at the call site, then pass the blueprint to `submitRun`.
8
8
 
9
- Allowed Template content:
9
+ Allowed `Blueprint` fields:
10
10
 
11
- - model;
12
- - system prompt;
13
- - queued user messages;
14
- - typed variables;
15
- - MCP server declarations;
16
- - MCP tool allow/deny policy;
17
- - environment package and network configuration;
18
- - inline/local/provider skills;
19
- - output conventions;
20
- - non-secret metadata.
11
+ - `model` — required.
12
+ - `prompt` — required (string or array of strings).
13
+ - `system` optional system message.
14
+ - `skills` — array of `Skill` instances (workspace, provider, or inline).
15
+ - `mcpServers` — array of `McpServer` instances (headers are split into `secrets.mcpServers` server-side).
16
+ - `proxyEndpoints` array of `ProxyEndpoint` instances.
17
+ - `agentsMd` / `files` array of `AgentsMd` / `File` instances.
18
+ - `environment` — packages + networking + `outputDirs`.
19
+ - `cleanup` — `{ session: "retain" | "delete" }`.
20
+ - `metadata` — non-secret structured metadata.
21
21
 
22
- Variables use `{{name}}` and are resolved before provider calls. Use `\{{name}}` for a literal placeholder.
22
+ Secrets never live in a `Blueprint`. Pass credentials through `submitRun({ ...blueprint, secrets, proxyEndpointAuth })` (SDK) or the equivalent host-mode flags (`--anthropic-api-key`, `--mcp-auth`, `--proxy-auth`).
23
23
 
24
- Secrets must not appear in Templates. Pass credentials through `submitRun(template, { secrets, proxyEndpointAuth })` (SDK) or the equivalent host-mode flags (`--anthropic-api-key`, `--mcp-secret`, `--proxy-auth`).
24
+ ## `defineRun` typed, reusable factory
25
+
26
+ `defineRun` is identity at runtime; its value is the type boundary. The producer must return a `Blueprint`, so callers cannot accidentally bake credentials into a reusable artifact.
27
+
28
+ ```ts
29
+ import { defineRun } from "antpath";
30
+
31
+ const summarise = defineRun((topic: string) => ({
32
+ model: "claude-haiku-4-5",
33
+ system: "You are a concise automation agent.",
34
+ prompt: `Write a short answer about ${topic}.`
35
+ }));
36
+
37
+ await client.submitRun({
38
+ ...summarise("agent-first SDK design"),
39
+ secrets: { anthropic: { apiKey } }
40
+ });
41
+ ```
42
+
43
+ ## CLI
44
+
45
+ The `antpath run` host subcommand accepts the same blueprint either as a JSON config file:
46
+
47
+ ```bash
48
+ antpath run --config ./blueprint.json \
49
+ --api-token "$ANTPATH_API_TOKEN" \
50
+ --anthropic-api-key "$ANTHROPIC_API_KEY"
51
+ ```
52
+
53
+ …or as explicit flags (`--model`, `--system`, `--prompt`, `--skill`, `--provider-skill`, `--mcp`, `--mcp-auth`, `--proxy-endpoint`, `--proxy-auth`, `--metadata`, `--cleanup`). The two modes are mutually exclusive.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antpath",
3
- "version": "0.10.13",
3
+ "version": "0.10.15",
4
4
  "description": "TypeScript SDK for running autonomous Claude Managed Agents sessions.",
5
5
  "repository": {
6
6
  "type": "git",