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/README.md +52 -26
- package/dist/_shared/config.d.ts +17 -1
- package/dist/_shared/config.js +19 -2
- package/dist/_shared/index.d.ts +2 -0
- package/dist/_shared/index.js +1 -0
- package/dist/_shared/operations.d.ts +48 -0
- package/dist/_shared/operations.js +149 -0
- package/dist/_shared/proxy-protocol.d.ts +15 -0
- package/dist/_shared/proxy-protocol.js +15 -0
- package/dist/_shared/runtime-types.d.ts +8 -2
- package/dist/_shared/sse.d.ts +74 -0
- package/dist/_shared/sse.js +0 -0
- package/dist/cli.mjs +370 -7
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +19 -3
- package/dist/client.js +54 -6
- package/dist/client.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/events.md +7 -6
- package/docs/quickstart.md +26 -16
- package/docs/templates.md +45 -16
- package/package.json +1 -1
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.
|
|
29
|
-
>
|
|
30
|
-
>
|
|
31
|
-
>
|
|
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 … --
|
|
37
|
-
antpath events <run-id> --follow --api-token … --
|
|
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.
|
package/docs/quickstart.md
CHANGED
|
@@ -5,27 +5,20 @@ title: antpath quickstart
|
|
|
5
5
|
# Quickstart
|
|
6
6
|
|
|
7
7
|
1. Get an antpath SDK API token (`ant_…`).
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
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
|
|
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
|
|
21
|
-
name: "hello",
|
|
19
|
+
const ref = await client.submitRun({
|
|
22
20
|
model: "claude-haiku-4-5",
|
|
23
|
-
|
|
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
|
|
49
|
+
antpath run \
|
|
41
50
|
--api-token "$ANTPATH_API_TOKEN" \
|
|
42
51
|
--anthropic-api-key "$ANTHROPIC_API_KEY" \
|
|
43
|
-
--
|
|
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.
|
|
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:
|
|
2
|
+
title: Blueprints (run configuration)
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Blueprints
|
|
6
6
|
|
|
7
|
-
|
|
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
|
|
9
|
+
Allowed `Blueprint` fields:
|
|
10
10
|
|
|
11
|
-
- model
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|