antpath 0.2.1 → 0.4.0
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 +54 -40
- package/dist/_shared/cleanup-policy.d.ts +8 -0
- package/dist/_shared/cleanup-policy.js +24 -0
- package/dist/_shared/config.d.ts +47 -0
- package/dist/_shared/config.js +150 -0
- package/dist/_shared/dev-stack.d.ts +19 -0
- package/dist/_shared/dev-stack.js +105 -0
- package/dist/_shared/errors.d.ts +8 -0
- package/dist/_shared/errors.js +18 -0
- package/dist/_shared/http.d.ts +25 -0
- package/dist/_shared/http.js +93 -0
- package/dist/_shared/index.d.ts +17 -0
- package/dist/_shared/index.js +20 -0
- package/dist/{providers → _shared}/known-events.d.ts +10 -10
- package/dist/{providers → _shared}/known-events.js +9 -9
- package/dist/_shared/operations.d.ts +24 -0
- package/dist/_shared/operations.js +47 -0
- package/dist/_shared/proxy-protocol.d.ts +148 -0
- package/dist/_shared/proxy-protocol.js +113 -0
- package/dist/_shared/proxy-validation.d.ts +19 -0
- package/dist/_shared/proxy-validation.js +51 -0
- package/dist/_shared/runtime-types.d.ts +90 -0
- package/dist/_shared/runtime-types.js +2 -0
- package/dist/{errors.d.ts → _shared/sdk-errors.d.ts} +10 -1
- package/dist/{errors.js → _shared/sdk-errors.js} +15 -2
- package/dist/{utils/secrets.js → _shared/sdk-secrets.js} +1 -1
- package/dist/_shared/secrets.d.ts +7 -0
- package/dist/_shared/secrets.js +20 -0
- package/dist/_shared/stable.d.ts +16 -0
- package/dist/{utils → _shared}/stable.js +14 -0
- package/dist/_shared/status.d.ts +8 -0
- package/dist/_shared/status.js +46 -0
- package/dist/_shared/submission.d.ts +157 -0
- package/dist/_shared/submission.js +681 -0
- package/dist/{template → _shared/template}/compiler.js +3 -3
- package/dist/{template/index.d.ts → _shared/template/helpers.d.ts} +0 -2
- package/dist/{template/index.js → _shared/template/helpers.js} +1 -2
- package/dist/_shared/template/index.d.ts +4 -0
- package/dist/_shared/template/index.js +4 -0
- package/dist/_shared/template/mapper.d.ts +11 -0
- package/dist/_shared/template/mapper.js +70 -0
- package/dist/cli.mjs +1223 -64
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +100 -8
- package/dist/client.js +193 -30
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/docs/cleanup.md +7 -4
- package/docs/credentials.md +10 -12
- package/docs/events.md +19 -82
- package/docs/outputs.md +15 -4
- package/docs/quickstart.md +40 -6
- package/docs/release.md +57 -12
- package/docs/skills.md +1 -1
- package/docs/templates.md +1 -1
- package/docs/testing.md +11 -8
- package/examples/mcp-static-bearer.ts +12 -9
- package/examples/quickstart.ts +6 -6
- package/package.json +5 -7
- package/dist/credentials.d.ts +0 -3
- package/dist/credentials.js +0 -56
- package/dist/credentials.js.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/files/downloader.d.ts +0 -3
- package/dist/files/downloader.js +0 -43
- package/dist/files/downloader.js.map +0 -1
- package/dist/platform/client.d.ts +0 -204
- package/dist/platform/client.js +0 -203
- package/dist/platform/client.js.map +0 -1
- package/dist/platform/index.d.ts +0 -1
- package/dist/platform/index.js +0 -2
- package/dist/platform/index.js.map +0 -1
- package/dist/providers/anthropic/provider.d.ts +0 -36
- package/dist/providers/anthropic/provider.js +0 -380
- package/dist/providers/anthropic/provider.js.map +0 -1
- package/dist/providers/known-events.js.map +0 -1
- package/dist/providers/types.d.ts +0 -42
- package/dist/providers/types.js.map +0 -1
- package/dist/run/controller.d.ts +0 -30
- package/dist/run/controller.js +0 -314
- package/dist/run/controller.js.map +0 -1
- package/dist/skills/packager.d.ts +0 -11
- package/dist/skills/packager.js +0 -76
- package/dist/skills/packager.js.map +0 -1
- package/dist/template/compiler.js.map +0 -1
- package/dist/template/index.js.map +0 -1
- package/dist/template/types.js +0 -2
- package/dist/template/types.js.map +0 -1
- package/dist/types.d.ts +0 -149
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/events.d.ts +0 -27
- package/dist/utils/events.js +0 -120
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -3
- package/dist/utils/paths.js +0 -27
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/secrets.js.map +0 -1
- package/dist/utils/stable.d.ts +0 -2
- package/dist/utils/stable.js.map +0 -1
- package/references/architecture-decisions.md +0 -473
- package/references/implementation-plan.md +0 -452
- package/references/research-sources.md +0 -41
- package/references/testing-strategy.md +0 -29
- /package/dist/{utils/secrets.d.ts → _shared/sdk-secrets.d.ts} +0 -0
- /package/dist/{template → _shared/template}/compiler.d.ts +0 -0
- /package/dist/{template → _shared/template}/types.d.ts +0 -0
- /package/dist/{providers → _shared/template}/types.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { redactSecrets } from "./
|
|
1
|
+
import { redactSecrets } from "./sdk-secrets.js";
|
|
2
2
|
export class AntpathError extends Error {
|
|
3
3
|
code;
|
|
4
4
|
details;
|
|
@@ -36,4 +36,17 @@ export class CleanupError extends AntpathError {
|
|
|
36
36
|
super("CLEANUP_ERROR", message, details);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Thrown by SDK and CLI operations when the dashboard BFF returns a non-2xx
|
|
41
|
+
* response. Carries the HTTP status and parsed body for the caller to inspect.
|
|
42
|
+
*/
|
|
43
|
+
export class AntpathApiError extends AntpathError {
|
|
44
|
+
status;
|
|
45
|
+
body;
|
|
46
|
+
constructor(status, message, body) {
|
|
47
|
+
super("API_ERROR", message, body);
|
|
48
|
+
this.status = status;
|
|
49
|
+
this.body = redactSecrets(body);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=sdk-errors.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface RedactedSecret {
|
|
2
|
+
expose(): string;
|
|
3
|
+
toJSON(): string;
|
|
4
|
+
toString(): string;
|
|
5
|
+
}
|
|
6
|
+
export declare function redactedSecret(value: string): RedactedSecret;
|
|
7
|
+
export declare function redactKnownSecrets(input: string, secrets: readonly RedactedSecret[]): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const REDACTED = "[secret]";
|
|
2
|
+
export function redactedSecret(value) {
|
|
3
|
+
if (value.length === 0) {
|
|
4
|
+
throw new Error("Secret value must not be empty");
|
|
5
|
+
}
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
expose: () => value,
|
|
8
|
+
toJSON: () => REDACTED,
|
|
9
|
+
toString: () => REDACTED
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function redactKnownSecrets(input, secrets) {
|
|
13
|
+
let output = input;
|
|
14
|
+
const longestFirst = [...secrets].sort((a, b) => b.expose().length - a.expose().length);
|
|
15
|
+
for (const secret of longestFirst) {
|
|
16
|
+
output = output.split(secret.expose()).join(REDACTED);
|
|
17
|
+
}
|
|
18
|
+
return output;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical hosted antpath URL. Used as the default `baseUrl` for the
|
|
3
|
+
* SDK `AntpathClient` and the host-side CLI `--dashboard-url` flag.
|
|
4
|
+
*
|
|
5
|
+
* A single canonical default is not a "footnote mode" — it is the
|
|
6
|
+
* canonical product. Self-hosted deployments override via the
|
|
7
|
+
* explicit `baseUrl` / `--dashboard-url` parameter. The value lives in
|
|
8
|
+
* source (no env-var override) so the agent reading the SDK call site
|
|
9
|
+
* can see exactly where the call goes.
|
|
10
|
+
*
|
|
11
|
+
* See `references/development-principles.md` (Agent-first surface
|
|
12
|
+
* design, Concrete rule 3).
|
|
13
|
+
*/
|
|
14
|
+
export declare const ANTPATH_DEFAULT_BASE_URL = "https://antpath.ai";
|
|
15
|
+
export declare function stableStringify(value: unknown): string;
|
|
16
|
+
export declare function sha256(value: unknown): string;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical hosted antpath URL. Used as the default `baseUrl` for the
|
|
4
|
+
* SDK `AntpathClient` and the host-side CLI `--dashboard-url` flag.
|
|
5
|
+
*
|
|
6
|
+
* A single canonical default is not a "footnote mode" — it is the
|
|
7
|
+
* canonical product. Self-hosted deployments override via the
|
|
8
|
+
* explicit `baseUrl` / `--dashboard-url` parameter. The value lives in
|
|
9
|
+
* source (no env-var override) so the agent reading the SDK call site
|
|
10
|
+
* can see exactly where the call goes.
|
|
11
|
+
*
|
|
12
|
+
* See `references/development-principles.md` (Agent-first surface
|
|
13
|
+
* design, Concrete rule 3).
|
|
14
|
+
*/
|
|
15
|
+
export const ANTPATH_DEFAULT_BASE_URL = "https://antpath.ai";
|
|
2
16
|
export function stableStringify(value) {
|
|
3
17
|
return JSON.stringify(sortValue(value));
|
|
4
18
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const RUN_STATUSES: readonly ["queued", "claiming", "provisioning", "session_created", "dispatched", "provider_running", "provider_idle", "provider_rescheduled", "cancelling", "capturing_outputs", "cleaning_up", "succeeded", "failed", "timed_out", "cancelled", "cleanup_failed", "pending_delete", "deleted"];
|
|
2
|
+
export type RunStatus = typeof RUN_STATUSES[number];
|
|
3
|
+
export type RunStatusKind = "active" | "terminal";
|
|
4
|
+
export declare const TERMINAL_RUN_STATUSES: readonly ["succeeded", "failed", "timed_out", "cancelled", "cleanup_failed", "pending_delete", "deleted"];
|
|
5
|
+
export declare function isTerminalRunStatus(status: RunStatus): boolean;
|
|
6
|
+
export declare function getRunStatusKind(status: RunStatus): RunStatusKind;
|
|
7
|
+
export declare const CLEANUP_STATUSES: readonly ["not_started", "pending", "running", "succeeded", "failed_retryable", "failed_terminal", "skipped"];
|
|
8
|
+
export type CleanupStatus = typeof CLEANUP_STATUSES[number];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const RUN_STATUSES = [
|
|
2
|
+
"queued",
|
|
3
|
+
"claiming",
|
|
4
|
+
"provisioning",
|
|
5
|
+
"session_created",
|
|
6
|
+
"dispatched",
|
|
7
|
+
"provider_running",
|
|
8
|
+
"provider_idle",
|
|
9
|
+
"provider_rescheduled",
|
|
10
|
+
"cancelling",
|
|
11
|
+
"capturing_outputs",
|
|
12
|
+
"cleaning_up",
|
|
13
|
+
"succeeded",
|
|
14
|
+
"failed",
|
|
15
|
+
"timed_out",
|
|
16
|
+
"cancelled",
|
|
17
|
+
"cleanup_failed",
|
|
18
|
+
"pending_delete",
|
|
19
|
+
"deleted"
|
|
20
|
+
];
|
|
21
|
+
export const TERMINAL_RUN_STATUSES = [
|
|
22
|
+
"succeeded",
|
|
23
|
+
"failed",
|
|
24
|
+
"timed_out",
|
|
25
|
+
"cancelled",
|
|
26
|
+
"cleanup_failed",
|
|
27
|
+
"pending_delete",
|
|
28
|
+
"deleted"
|
|
29
|
+
];
|
|
30
|
+
const terminalRunStatuses = new Set(TERMINAL_RUN_STATUSES);
|
|
31
|
+
export function isTerminalRunStatus(status) {
|
|
32
|
+
return terminalRunStatuses.has(status);
|
|
33
|
+
}
|
|
34
|
+
export function getRunStatusKind(status) {
|
|
35
|
+
return isTerminalRunStatus(status) ? "terminal" : "active";
|
|
36
|
+
}
|
|
37
|
+
export const CLEANUP_STATUSES = [
|
|
38
|
+
"not_started",
|
|
39
|
+
"pending",
|
|
40
|
+
"running",
|
|
41
|
+
"succeeded",
|
|
42
|
+
"failed_retryable",
|
|
43
|
+
"failed_terminal",
|
|
44
|
+
"skipped"
|
|
45
|
+
];
|
|
46
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { type ProxyAuthShape, type ProxyMethod, type ProxyResponseMode } from "./proxy-protocol.js";
|
|
2
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
3
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
4
|
+
readonly [key: string]: JsonValue;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Networking + runtime-package snapshot carried alongside the template
|
|
8
|
+
* so the worker can deep-clone and mutate it per run (e.g. injecting
|
|
9
|
+
* the proxy hostname into `allowed_hosts` or the `node` runtime into
|
|
10
|
+
* `packages`) without sharing state across concurrent runs.
|
|
11
|
+
*
|
|
12
|
+
* Today this is consumed only by the worker's `templateFromSnapshot`
|
|
13
|
+
* reconstruction. The shape stays intentionally narrow: only fields
|
|
14
|
+
* the worker can act on land here; freeform extensions belong in
|
|
15
|
+
* `metadata`.
|
|
16
|
+
*/
|
|
17
|
+
export interface PlatformTemplateEnvironment {
|
|
18
|
+
readonly networking?: PlatformTemplateNetworking;
|
|
19
|
+
readonly packages?: readonly PlatformTemplatePackage[];
|
|
20
|
+
}
|
|
21
|
+
export interface PlatformTemplateNetworking {
|
|
22
|
+
readonly mode: "limited" | "open";
|
|
23
|
+
/** Lowercase host names. The worker always appends the proxy host. */
|
|
24
|
+
readonly allowedHosts?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export interface PlatformTemplatePackage {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly version?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PlatformTemplateSubmission {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly model: string;
|
|
33
|
+
readonly templateHash: string;
|
|
34
|
+
readonly system?: string;
|
|
35
|
+
readonly messages: readonly string[];
|
|
36
|
+
readonly metadata?: Record<string, JsonValue>;
|
|
37
|
+
readonly environment?: PlatformTemplateEnvironment;
|
|
38
|
+
}
|
|
39
|
+
export type PlatformClaudeSessionCleanup = "retain" | "delete";
|
|
40
|
+
export type PlatformSessionCleanup = "retain" | "delete";
|
|
41
|
+
export interface PlatformCleanupPolicy {
|
|
42
|
+
readonly session?: PlatformSessionCleanup;
|
|
43
|
+
/** @deprecated use `session` instead. Accepted for one release for back-compat. */
|
|
44
|
+
readonly claudeSession?: PlatformClaudeSessionCleanup;
|
|
45
|
+
}
|
|
46
|
+
export interface PlatformAnthropicSecrets {
|
|
47
|
+
readonly apiKey: string;
|
|
48
|
+
readonly baseUrl?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface PlatformMcpServerSecret {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly url: string;
|
|
53
|
+
readonly headers?: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
export interface PlatformSkillReference {
|
|
56
|
+
readonly skillId: string;
|
|
57
|
+
readonly version?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Per-run auth value for a declared proxy endpoint. The `name` must
|
|
61
|
+
* match a `proxyEndpoints[i].name` in the same submission, and `value`'s
|
|
62
|
+
* shape must match that endpoint's `authShape.type`. The cross-validation
|
|
63
|
+
* lives in `parseRunSubmissionRequest`.
|
|
64
|
+
*/
|
|
65
|
+
export interface PlatformProxyEndpointAuth {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly value: PlatformProxyAuthValue;
|
|
68
|
+
}
|
|
69
|
+
export type PlatformProxyAuthValue = {
|
|
70
|
+
readonly type: "bearer";
|
|
71
|
+
readonly token: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: "basic";
|
|
74
|
+
readonly username: string;
|
|
75
|
+
readonly password: string;
|
|
76
|
+
} | {
|
|
77
|
+
readonly type: "header";
|
|
78
|
+
readonly value: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly type: "query";
|
|
81
|
+
readonly value: string;
|
|
82
|
+
};
|
|
83
|
+
export interface PlatformInlineSecrets {
|
|
84
|
+
readonly anthropic: PlatformAnthropicSecrets;
|
|
85
|
+
readonly mcpServers?: readonly PlatformMcpServerSecret[];
|
|
86
|
+
readonly skills?: readonly PlatformSkillReference[];
|
|
87
|
+
readonly proxyEndpointAuth?: readonly PlatformProxyEndpointAuth[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Per-run named HTTP proxy endpoint. The `authShape` describes how the
|
|
91
|
+
* upstream expects auth; the actual value is supplied separately via
|
|
92
|
+
* `secrets.proxyEndpointAuth`. The auth value never enters the
|
|
93
|
+
* container — the BFF proxy injects it on outbound calls.
|
|
94
|
+
*
|
|
95
|
+
* Caps and allow-lists below are intentionally pessimistic by default
|
|
96
|
+
* so a misconfigured endpoint can't accidentally permit a wide attack
|
|
97
|
+
* surface; raise per endpoint if needed.
|
|
98
|
+
*/
|
|
99
|
+
export interface PlatformProxyEndpoint {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly baseUrl: string;
|
|
102
|
+
readonly authShape: ProxyAuthShape;
|
|
103
|
+
readonly allowMethods: readonly ProxyMethod[];
|
|
104
|
+
readonly allowPathPrefixes: readonly string[];
|
|
105
|
+
readonly allowHeaders?: readonly string[];
|
|
106
|
+
readonly responseMode?: ProxyResponseMode;
|
|
107
|
+
readonly maxRequestBytes?: number;
|
|
108
|
+
readonly maxResponseBytes?: number;
|
|
109
|
+
readonly timeoutMs?: number;
|
|
110
|
+
readonly perCallBudget?: number;
|
|
111
|
+
readonly responseByteBudget?: number;
|
|
112
|
+
}
|
|
113
|
+
export interface PlatformRunSubmissionRequest {
|
|
114
|
+
readonly workspaceId: string;
|
|
115
|
+
readonly idempotencyKey: string;
|
|
116
|
+
readonly template: PlatformTemplateSubmission;
|
|
117
|
+
readonly variables?: Record<string, JsonValue>;
|
|
118
|
+
readonly cleanup?: PlatformCleanupPolicy;
|
|
119
|
+
readonly secrets: PlatformInlineSecrets;
|
|
120
|
+
/**
|
|
121
|
+
* Declared HTTP endpoints reachable via the antpath managed proxy
|
|
122
|
+
* during this run. Empty array (or omitted) → no proxy surface is
|
|
123
|
+
* provisioned; the CLI's `/antpath/index.json` shows `endpoints: []`
|
|
124
|
+
* and the `/antpath/run-token` mount is omitted.
|
|
125
|
+
*/
|
|
126
|
+
readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Wire shape posted by the SDK and CLI. `workspaceId` is **omitted by
|
|
130
|
+
* design** — token-authenticated clients never name the workspace
|
|
131
|
+
* because it is derived from their API token on the server. The BFF
|
|
132
|
+
* route resolves the workspace from the token and injects it before
|
|
133
|
+
* calling `parseRunSubmissionRequest`. The dashboard UI (Auth.js user
|
|
134
|
+
* principal, multi-workspace) is the only caller that supplies
|
|
135
|
+
* `workspaceId` itself.
|
|
136
|
+
*
|
|
137
|
+
* See `references/development-principles.md` (Agent-first surface
|
|
138
|
+
* design, Concrete rule 3).
|
|
139
|
+
*/
|
|
140
|
+
export type PlatformRunSubmissionInput = Omit<PlatformRunSubmissionRequest, "workspaceId"> & {
|
|
141
|
+
readonly workspaceId?: string;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Default caps for a proxy endpoint when the submission doesn't specify
|
|
145
|
+
* one. Conservative on purpose. Operators can override the platform-
|
|
146
|
+
* wide ceiling through env vars (see `references/environment-variables.md`).
|
|
147
|
+
*/
|
|
148
|
+
export declare const PROXY_ENDPOINT_DEFAULTS: {
|
|
149
|
+
readonly allowHeaders: readonly string[];
|
|
150
|
+
readonly responseMode: ProxyResponseMode;
|
|
151
|
+
readonly maxRequestBytes: number;
|
|
152
|
+
readonly maxResponseBytes: number;
|
|
153
|
+
readonly timeoutMs: 10000;
|
|
154
|
+
readonly perCallBudget: 60;
|
|
155
|
+
readonly responseByteBudget: number;
|
|
156
|
+
};
|
|
157
|
+
export declare function parseRunSubmissionRequest(input: unknown): PlatformRunSubmissionRequest;
|