@aexhq/sdk 0.32.0 → 0.33.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.
- package/README.md +29 -31
- package/dist/_contracts/event-stream-client.d.ts +2 -2
- package/dist/_contracts/event-stream-client.js +3 -3
- package/dist/_contracts/index.d.ts +0 -1
- package/dist/_contracts/index.js +0 -1
- package/dist/_contracts/operations.d.ts +15 -1
- package/dist/_contracts/operations.js +79 -0
- package/dist/_contracts/post-hook.d.ts +4 -4
- package/dist/_contracts/post-hook.js +1 -1
- package/dist/_contracts/run-config.d.ts +0 -4
- package/dist/_contracts/run-config.js +0 -7
- package/dist/_contracts/runtime-types.d.ts +86 -0
- package/dist/_contracts/status.d.ts +3 -1
- package/dist/_contracts/status.js +17 -0
- package/dist/_contracts/submission.d.ts +1 -10
- package/dist/_contracts/submission.js +0 -4
- package/dist/cli.mjs +110 -97
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +116 -34
- package/dist/client.js +453 -62
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/defaults.md +0 -2
- package/docs/events.md +32 -13
- package/docs/limits.md +4 -3
- package/docs/public-surface.json +14 -9
- package/docs/quickstart.md +36 -11
- package/docs/run-config.md +1 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@ aex is an agent execution platform for launching autonomous agents from a simple
|
|
|
8
8
|
|
|
9
9
|
The package ships:
|
|
10
10
|
|
|
11
|
-
- `AgentExecutor` for
|
|
11
|
+
- `Aex` / `AgentExecutor` for sessions, one-shot runs, inspect, download, cancel, and delete.
|
|
12
|
+
- `sessions` / `openSession()` for durable, resumable agent sessions.
|
|
12
13
|
- Typed run primitives: `Models`, `Providers`, `RuntimeSizes`, `Skill`, `AgentsMd`, `File`, `McpServer`, `ProxyEndpoint`, and `Secret`.
|
|
13
14
|
- A bundled `aex` CLI with the same run, status, events, outputs, download, cancel, delete, whoami, and skills operations.
|
|
14
15
|
|
|
@@ -27,56 +28,53 @@ export AEX_API_TOKEN="<your-aex-token>"
|
|
|
27
28
|
export ANTHROPIC_API_KEY="<your-anthropic-api-key>"
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
## First
|
|
31
|
+
## First Session
|
|
31
32
|
|
|
32
33
|
```ts
|
|
33
|
-
import {
|
|
34
|
+
import { Aex, Models, Sizes } from "@aexhq/sdk";
|
|
34
35
|
|
|
35
|
-
const aex = new
|
|
36
|
+
const aex = new Aex({ apiToken: process.env.AEX_API_TOKEN! });
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
// no manual poll loop. `provider` is derived from the model.
|
|
39
|
-
const { text, ok } = await aex.run({
|
|
38
|
+
const session = await aex.openSession({
|
|
40
39
|
model: Models.CLAUDE_HAIKU_4_5,
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
system: "You are a concise engineering assistant.",
|
|
41
|
+
runtime: Sizes.SHARED_0_25X_1GB,
|
|
42
|
+
// Default is "3m"; set it explicitly when you want a different idle window.
|
|
43
|
+
overrides: { idleTtl: "3m" },
|
|
44
|
+
apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! }
|
|
43
45
|
});
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
const first = await session.send("Summarize this repo.").done();
|
|
48
|
+
console.log(first.status, first.text);
|
|
49
|
+
|
|
50
|
+
const resumed = await aex.openSession(session.id);
|
|
51
|
+
await resumed.send("Continue with the follow-up validation.").done();
|
|
46
52
|
```
|
|
47
53
|
|
|
48
|
-
Need
|
|
54
|
+
Need a one-shot convenience? `run()` opens a session, sends `message` as one
|
|
55
|
+
turn, and returns the collected result. The returned `runId` is the session id,
|
|
56
|
+
so it can be resumed later with `openSession(runId)`.
|
|
49
57
|
|
|
50
58
|
```ts
|
|
51
|
-
const
|
|
59
|
+
const result = await aex.run({
|
|
52
60
|
model: Models.CLAUDE_HAIKU_4_5,
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
apiKeys: { anthropic: process.env.ANTHROPIC_API_KEY! },
|
|
62
|
+
message: "Write the report and save outputs."
|
|
55
63
|
});
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
console.log(event.type);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const run = await aex.wait(runId);
|
|
62
|
-
console.log(run.status);
|
|
63
|
-
|
|
64
|
-
await aex.download(runId, { to: "./run.zip" });
|
|
65
|
+
console.log(result.runId, result.status, result.text);
|
|
65
66
|
```
|
|
66
67
|
|
|
67
|
-
For multiple providers
|
|
68
|
-
each BYOK key in `secrets.apiKeys`:
|
|
68
|
+
For multiple providers, include each BYOK key in `apiKeys`:
|
|
69
69
|
|
|
70
70
|
```ts
|
|
71
71
|
await aex.run({
|
|
72
72
|
model: Models.CLAUDE_HAIKU_4_5,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
openai: process.env.OPENAI_API_KEY!
|
|
77
|
-
}
|
|
73
|
+
apiKeys: {
|
|
74
|
+
anthropic: process.env.ANTHROPIC_API_KEY!,
|
|
75
|
+
openai: process.env.OPENAI_API_KEY!
|
|
78
76
|
},
|
|
79
|
-
|
|
77
|
+
message: "Delegate research to a subagent."
|
|
80
78
|
});
|
|
81
79
|
```
|
|
82
80
|
|
|
@@ -144,7 +142,7 @@ finds output files across runs and returns references (no bytes) you then
|
|
|
144
142
|
|
|
145
143
|
## Feature Areas
|
|
146
144
|
|
|
147
|
-
- **Agent runtime:** managed autonomous runs with filesystem read/edit, grep/glob/head/tail, open web fetch/search defaults, optional notebook tools
|
|
145
|
+
- **Agent runtime:** managed autonomous runs with filesystem read/edit, grep/glob/head/tail, open web fetch/search defaults, and optional notebook tools.
|
|
148
146
|
- **Durable infrastructure:** run records, status, wait/cancel/delete, idempotency, typed events, output capture, downloads, timeouts, and runtime sizes.
|
|
149
147
|
- **Agent composition:** skills, files, AGENTS.md, remote MCP servers, proxy endpoints, environment variables, packages, and networking controls.
|
|
150
148
|
- **Subagents:** typed parent/child lineage for async child runs, output handoff, and bounded agent delegation.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* A silently half-open socket (no close/error, no frames) is the dangerous
|
|
13
13
|
* case: the read loop would block forever and MISS a terminal that was already
|
|
14
14
|
* persisted server-side. So the client sends a tiny keep-alive ping the
|
|
15
|
-
* coordinator
|
|
15
|
+
* coordinator answers with a matching pong, and runs an idle
|
|
16
16
|
* watchdog: if no frame arrives within {@link CoordinatorStreamOptions.idleTimeoutMs},
|
|
17
17
|
* the socket is treated as dead and reconnected — resume-from-cursor then
|
|
18
18
|
* replays the terminal.
|
|
@@ -65,7 +65,7 @@ export interface CoordinatorStreamOptions {
|
|
|
65
65
|
readonly idleTimeoutMs?: number;
|
|
66
66
|
/**
|
|
67
67
|
* Client keep-alive ping cadence. The client sends {@link COORDINATOR_PING},
|
|
68
|
-
* which the coordinator
|
|
68
|
+
* which the coordinator answers with a matching pong, so
|
|
69
69
|
* a legitimately quiet run keeps the socket measurably alive and does not trip
|
|
70
70
|
* the watchdog. Default 15s. Set 0 to disable (then only real events reset the
|
|
71
71
|
* watchdog → quiet runs may reconnect).
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* A silently half-open socket (no close/error, no frames) is the dangerous
|
|
13
13
|
* case: the read loop would block forever and MISS a terminal that was already
|
|
14
14
|
* persisted server-side. So the client sends a tiny keep-alive ping the
|
|
15
|
-
* coordinator
|
|
15
|
+
* coordinator answers with a matching pong, and runs an idle
|
|
16
16
|
* watchdog: if no frame arrives within {@link CoordinatorStreamOptions.idleTimeoutMs},
|
|
17
17
|
* the socket is treated as dead and reconnected — resume-from-cursor then
|
|
18
18
|
* replays the terminal.
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
*/
|
|
27
27
|
const isTerminalType = (e) => e.type === "RUN_FINISHED" || e.type === "RUN_ERROR";
|
|
28
28
|
/**
|
|
29
|
-
* Keep-alive ping the client sends; the coordinator answers it
|
|
30
|
-
*
|
|
29
|
+
* Keep-alive ping the client sends; the coordinator answers it with the matching
|
|
30
|
+
* pong in its WebSocket message handler. Must stay byte-identical to
|
|
31
31
|
* the coordinator's pair (aex-platform `packages/shared/src/event-stream-client.ts`).
|
|
32
32
|
*/
|
|
33
33
|
const COORDINATOR_PING = "aex:ping";
|
|
@@ -4,7 +4,6 @@ export * from "./models.js";
|
|
|
4
4
|
export * from "./status.js";
|
|
5
5
|
export * from "./submission.js";
|
|
6
6
|
export * from "./runtime-sizes.js";
|
|
7
|
-
export * from "./post-hook.js";
|
|
8
7
|
export * from "./runner-event.js";
|
|
9
8
|
export * from "./event-envelope.js";
|
|
10
9
|
export * from "./connection-ticket.js";
|
package/dist/_contracts/index.js
CHANGED
|
@@ -4,7 +4,6 @@ export * from "./models.js";
|
|
|
4
4
|
export * from "./status.js";
|
|
5
5
|
export * from "./submission.js";
|
|
6
6
|
export * from "./runtime-sizes.js";
|
|
7
|
-
export * from "./post-hook.js";
|
|
8
7
|
export * from "./runner-event.js";
|
|
9
8
|
export * from "./event-envelope.js";
|
|
10
9
|
export * from "./connection-ticket.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from "./http.js";
|
|
2
2
|
import type { RunUnit } from "./run-unit.js";
|
|
3
|
-
import type { AgentsMdRecord, FileRecord, Output, OutputLink, OutputLinkOptions, OutputFileDownload, OutputFileSelector, OutputFileType, OutputQuery, OutputText, ReadOutputTextOptions, Run, RunEvent, RunListPage, RunListQuery, RunWebhookDelivery, SecretRecord, SecretReveal, Skill, WhoAmI } from "./runtime-types.js";
|
|
3
|
+
import type { AgentsMdRecord, FileRecord, Output, OutputLink, OutputLinkOptions, OutputFileDownload, OutputFileSelector, OutputFileType, OutputQuery, OutputText, ReadOutputTextOptions, Run, RunEvent, RunListPage, RunListQuery, Session, SessionCreateRequest, SessionEvent, SessionListPage, SessionListQuery, SessionMessageAccepted, SessionMessageRequest, SessionStateChangeAccepted, RunWebhookDelivery, SecretRecord, SecretReveal, Skill, WhoAmI } from "./runtime-types.js";
|
|
4
4
|
import type { PlatformRunSubmissionInput } from "./submission.js";
|
|
5
5
|
/**
|
|
6
6
|
* The single source of truth for SDK<->BFF transport. The SDK class
|
|
@@ -37,6 +37,20 @@ export declare function getRunUnit(http: HttpClient, runId: string): Promise<Run
|
|
|
37
37
|
* For a single page; callers wanting every run loop on `nextCursor` themselves.
|
|
38
38
|
*/
|
|
39
39
|
export declare function listRuns(http: HttpClient, query?: RunListQuery): Promise<RunListPage>;
|
|
40
|
+
export interface IdempotencyOptions {
|
|
41
|
+
readonly idempotencyKey?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function createSession(http: HttpClient, request: SessionCreateRequest, options?: IdempotencyOptions): Promise<Session>;
|
|
44
|
+
export declare function getSession(http: HttpClient, sessionId: string): Promise<Session>;
|
|
45
|
+
export declare function listSessions(http: HttpClient, query?: SessionListQuery): Promise<SessionListPage>;
|
|
46
|
+
export declare function sendSessionMessage(http: HttpClient, sessionId: string, request: SessionMessageRequest, options?: IdempotencyOptions): Promise<SessionMessageAccepted>;
|
|
47
|
+
export declare function suspendSession(http: HttpClient, sessionId: string, options?: IdempotencyOptions): Promise<SessionStateChangeAccepted>;
|
|
48
|
+
export declare function cancelSession(http: HttpClient, sessionId: string, options?: IdempotencyOptions): Promise<SessionStateChangeAccepted>;
|
|
49
|
+
export declare function resumeSession(http: HttpClient, sessionId: string, options?: IdempotencyOptions): Promise<SessionStateChangeAccepted>;
|
|
50
|
+
export declare function deleteSession(http: HttpClient, sessionId: string, options?: IdempotencyOptions): Promise<SessionStateChangeAccepted | void>;
|
|
51
|
+
export declare function listSessionEvents(http: HttpClient, sessionId: string): Promise<readonly SessionEvent[]>;
|
|
52
|
+
export declare function listSessionOutputs(http: HttpClient, sessionId: string, query?: OutputQuery): Promise<readonly Output[]>;
|
|
53
|
+
export declare function getSessionCoordinatorTicket(http: HttpClient, sessionId: string): Promise<CoordinatorTicket>;
|
|
40
54
|
/**
|
|
41
55
|
* List a run's events. The read endpoint is PAGED (bounded per response so a
|
|
42
56
|
* long run can't return an unbounded body); this follows `nextCursor` across
|
|
@@ -52,6 +52,79 @@ export async function listRuns(http, query) {
|
|
|
52
52
|
params.cursor = query.cursor;
|
|
53
53
|
return http.request("/api/runs", {}, params);
|
|
54
54
|
}
|
|
55
|
+
function idempotencyHeaders(options) {
|
|
56
|
+
return options?.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : undefined;
|
|
57
|
+
}
|
|
58
|
+
export async function createSession(http, request, options) {
|
|
59
|
+
const headers = idempotencyHeaders(options);
|
|
60
|
+
const result = await http.request("/api/sessions", {
|
|
61
|
+
method: "POST",
|
|
62
|
+
...(headers ? { headers } : {}),
|
|
63
|
+
body: JSON.stringify(request)
|
|
64
|
+
});
|
|
65
|
+
return unwrapSession(result);
|
|
66
|
+
}
|
|
67
|
+
export async function getSession(http, sessionId) {
|
|
68
|
+
const result = await http.request(`/api/sessions/${encodeURIComponent(sessionId)}`);
|
|
69
|
+
return unwrapSession(result);
|
|
70
|
+
}
|
|
71
|
+
export async function listSessions(http, query) {
|
|
72
|
+
const params = {};
|
|
73
|
+
if (query?.status !== undefined)
|
|
74
|
+
params.status = query.status;
|
|
75
|
+
if (query?.since !== undefined)
|
|
76
|
+
params.since = query.since;
|
|
77
|
+
if (query?.limit !== undefined)
|
|
78
|
+
params.limit = String(query.limit);
|
|
79
|
+
if (query?.cursor !== undefined)
|
|
80
|
+
params.cursor = query.cursor;
|
|
81
|
+
return http.request("/api/sessions", {}, params);
|
|
82
|
+
}
|
|
83
|
+
export async function sendSessionMessage(http, sessionId, request, options) {
|
|
84
|
+
const headers = idempotencyHeaders(options);
|
|
85
|
+
return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/messages`, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
...(headers ? { headers } : {}),
|
|
88
|
+
body: JSON.stringify(request)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export async function suspendSession(http, sessionId, options) {
|
|
92
|
+
const headers = idempotencyHeaders(options);
|
|
93
|
+
return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/suspend`, { method: "POST", ...(headers ? { headers } : {}) });
|
|
94
|
+
}
|
|
95
|
+
export async function cancelSession(http, sessionId, options) {
|
|
96
|
+
const headers = idempotencyHeaders(options);
|
|
97
|
+
return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/cancel`, { method: "POST", ...(headers ? { headers } : {}) });
|
|
98
|
+
}
|
|
99
|
+
export async function resumeSession(http, sessionId, options) {
|
|
100
|
+
const headers = idempotencyHeaders(options);
|
|
101
|
+
return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/resume`, { method: "POST", ...(headers ? { headers } : {}) });
|
|
102
|
+
}
|
|
103
|
+
export async function deleteSession(http, sessionId, options) {
|
|
104
|
+
const headers = idempotencyHeaders(options);
|
|
105
|
+
return http.request(`/api/sessions/${encodeURIComponent(sessionId)}`, { method: "DELETE", ...(headers ? { headers } : {}) });
|
|
106
|
+
}
|
|
107
|
+
export async function listSessionEvents(http, sessionId) {
|
|
108
|
+
const path = `/api/sessions/${encodeURIComponent(sessionId)}/events`;
|
|
109
|
+
const all = [];
|
|
110
|
+
let cursor;
|
|
111
|
+
for (let page = 0; page < LIST_EVENTS_PAGE_BUDGET; page++) {
|
|
112
|
+
const query = cursor !== undefined ? { cursor: String(cursor) } : {};
|
|
113
|
+
const result = await http.request(path, {}, query);
|
|
114
|
+
all.push(...result.events);
|
|
115
|
+
if (typeof result.nextCursor !== "number")
|
|
116
|
+
break;
|
|
117
|
+
cursor = result.nextCursor;
|
|
118
|
+
}
|
|
119
|
+
return all;
|
|
120
|
+
}
|
|
121
|
+
export async function listSessionOutputs(http, sessionId, query) {
|
|
122
|
+
const result = await http.request(`/api/sessions/${encodeURIComponent(sessionId)}/outputs`);
|
|
123
|
+
return query === undefined ? result.outputs : filterOutputs(result.outputs, query);
|
|
124
|
+
}
|
|
125
|
+
export async function getSessionCoordinatorTicket(http, sessionId) {
|
|
126
|
+
return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/events/ticket`, { method: "POST" });
|
|
127
|
+
}
|
|
55
128
|
// Bound the transparent pager: the read route caps each page at 1000, so this
|
|
56
129
|
// admits up to ~1e6 events before bailing — past any real run, but bounded so a
|
|
57
130
|
// server that never clears `nextCursor` can't loop forever.
|
|
@@ -815,6 +888,12 @@ function unwrapSkill(result) {
|
|
|
815
888
|
function hasRun(value) {
|
|
816
889
|
return Boolean(value && typeof value === "object" && "run" in value);
|
|
817
890
|
}
|
|
891
|
+
function unwrapSession(result) {
|
|
892
|
+
if (result && typeof result === "object" && "session" in result) {
|
|
893
|
+
return result.session;
|
|
894
|
+
}
|
|
895
|
+
return result;
|
|
896
|
+
}
|
|
818
897
|
/**
|
|
819
898
|
* Upload bytes to the hosted API's content-addressable asset endpoint.
|
|
820
899
|
* Returns a storage-neutral asset id suitable for `kind:"asset"` refs in a
|
|
@@ -3,9 +3,9 @@ export declare const DEFAULT_POST_HOOK_TIMEOUT_MS: number;
|
|
|
3
3
|
/** Default number of repair turns after a failing hook. */
|
|
4
4
|
export declare const DEFAULT_POST_HOOK_MAX_TURNS = 10;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* {@link PlatformPostHook}.
|
|
6
|
+
* Legacy/private post-agent-run verifier input. The public SDK no longer
|
|
7
|
+
* accepts this field; platform-internal paths may still normalize old wire
|
|
8
|
+
* records to {@link PlatformPostHook}.
|
|
9
9
|
*/
|
|
10
10
|
export interface PlatformPostHookInput {
|
|
11
11
|
readonly command: string;
|
|
@@ -21,7 +21,7 @@ export interface PlatformPostHook {
|
|
|
21
21
|
readonly maxChars: number | null;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Parse the
|
|
24
|
+
* Parse the legacy/private `postHook` option. An omitted hook, null hook, or hook with
|
|
25
25
|
* an empty/whitespace-only command is treated as omitted so callers can pre-fill
|
|
26
26
|
* configs without enabling the verifier accidentally.
|
|
27
27
|
*/
|
|
@@ -4,7 +4,7 @@ export const DEFAULT_POST_HOOK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
|
4
4
|
/** Default number of repair turns after a failing hook. */
|
|
5
5
|
export const DEFAULT_POST_HOOK_MAX_TURNS = 10;
|
|
6
6
|
/**
|
|
7
|
-
* Parse the
|
|
7
|
+
* Parse the legacy/private `postHook` option. An omitted hook, null hook, or hook with
|
|
8
8
|
* an empty/whitespace-only command is treated as omitted so callers can pre-fill
|
|
9
9
|
* configs without enabling the verifier accidentally.
|
|
10
10
|
*/
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
import { type JsonValue, type PlatformProxyEndpoint, type PlatformEnvironment } from "./submission.js";
|
|
32
32
|
import { type RunModel } from "./models.js";
|
|
33
33
|
import type { RuntimeSize } from "./runtime-sizes.js";
|
|
34
|
-
import { type PlatformPostHookInput } from "./post-hook.js";
|
|
35
34
|
/**
|
|
36
35
|
* Mirrors the server-side CHECK constraint
|
|
37
36
|
* `skill_bundles_id_format_chk = check (id ~ '^skl_[A-Za-z0-9_-]{8,128}$')`
|
|
@@ -299,8 +298,6 @@ export interface RunRequestConfig {
|
|
|
299
298
|
readonly runtimeSize?: RuntimeSize;
|
|
300
299
|
/** Run deadline as a duration string (`"1h"`, `"30m"`); bounded [1m, 6h] server-side. */
|
|
301
300
|
readonly timeout?: string;
|
|
302
|
-
/** Post-agent-run verifier command. Empty command is treated as omitted. */
|
|
303
|
-
readonly postHook?: PlatformPostHookInput;
|
|
304
301
|
readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
|
|
305
302
|
readonly metadata?: Readonly<Record<string, JsonValue>>;
|
|
306
303
|
}
|
|
@@ -330,7 +327,6 @@ export interface NormalisedRunRequestConfig {
|
|
|
330
327
|
readonly environment?: PlatformEnvironment;
|
|
331
328
|
readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
|
|
332
329
|
readonly metadata?: Readonly<Record<string, JsonValue>>;
|
|
333
|
-
readonly postHook?: PlatformPostHookInput;
|
|
334
330
|
/**
|
|
335
331
|
* MCP servers whose run-config entry carried `headers`. Keyed by the `name`
|
|
336
332
|
* that appears in `mcpServers` so the BFF can pair them up.
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
* boundary.
|
|
30
30
|
*/
|
|
31
31
|
import { parseRunModel } from "./models.js";
|
|
32
|
-
import { parsePostHook } from "./post-hook.js";
|
|
33
32
|
// ---------------------------------------------------------------------------
|
|
34
33
|
// Skill ID + name format
|
|
35
34
|
// ---------------------------------------------------------------------------
|
|
@@ -617,7 +616,6 @@ export function parseRunRequestConfig(input) {
|
|
|
617
616
|
"environment",
|
|
618
617
|
"runtimeSize",
|
|
619
618
|
"timeout",
|
|
620
|
-
"postHook",
|
|
621
619
|
"proxyEndpoints",
|
|
622
620
|
"metadata"
|
|
623
621
|
]);
|
|
@@ -634,7 +632,6 @@ export function parseRunRequestConfig(input) {
|
|
|
634
632
|
const prompt = parseRunRequestConfigPrompt(record.prompt);
|
|
635
633
|
const skills = parseRunRequestConfigSkills(record.skills);
|
|
636
634
|
const mcpServers = parseRunRequestConfigMcpServers(record.mcpServers);
|
|
637
|
-
const postHook = parsePostHook(record.postHook, "run request config postHook");
|
|
638
635
|
return {
|
|
639
636
|
model,
|
|
640
637
|
...(system !== undefined ? { system } : {}),
|
|
@@ -654,9 +651,6 @@ export function parseRunRequestConfig(input) {
|
|
|
654
651
|
...(record.timeout !== undefined
|
|
655
652
|
? { timeout: record.timeout }
|
|
656
653
|
: {}),
|
|
657
|
-
...(postHook !== undefined
|
|
658
|
-
? { postHook: record.postHook }
|
|
659
|
-
: {}),
|
|
660
654
|
...(record.proxyEndpoints !== undefined
|
|
661
655
|
? { proxyEndpoints: record.proxyEndpoints }
|
|
662
656
|
: {}),
|
|
@@ -734,7 +728,6 @@ export function normaliseRunRequestConfig(config) {
|
|
|
734
728
|
...(config.environment !== undefined ? { environment: config.environment } : {}),
|
|
735
729
|
...(config.proxyEndpoints !== undefined ? { proxyEndpoints: config.proxyEndpoints } : {}),
|
|
736
730
|
...(config.metadata !== undefined ? { metadata: config.metadata } : {}),
|
|
737
|
-
...(config.postHook !== undefined ? { postHook: config.postHook } : {}),
|
|
738
731
|
mcpServerSecrets
|
|
739
732
|
};
|
|
740
733
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SessionStatus } from "./status.js";
|
|
2
|
+
import type { PlatformRunSubmissionInput, PlatformSubmission } from "./submission.js";
|
|
1
3
|
/**
|
|
2
4
|
* Loose record describing a run as the dashboard BFF returns it. Concrete
|
|
3
5
|
* dashboard-managed fields appear in the index signature; the SDK and CLI
|
|
@@ -38,6 +40,90 @@ export interface Run {
|
|
|
38
40
|
readonly runtimeManifest?: import("./runtime-manifest.js").RuntimeManifest;
|
|
39
41
|
readonly [key: string]: unknown;
|
|
40
42
|
}
|
|
43
|
+
export type SessionTurnStatus = "none" | "launching" | "running" | "parking" | "idle" | "suspended" | "failed";
|
|
44
|
+
export interface SessionTurn {
|
|
45
|
+
readonly sessionId: string;
|
|
46
|
+
readonly turnSeq: number;
|
|
47
|
+
readonly turnId?: string;
|
|
48
|
+
readonly status?: SessionTurnStatus;
|
|
49
|
+
readonly startedAt?: string;
|
|
50
|
+
readonly endedAt?: string | null;
|
|
51
|
+
readonly eventCursor?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface Session {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly sessionId?: string;
|
|
56
|
+
readonly status: SessionStatus | string;
|
|
57
|
+
readonly turnSeq?: number;
|
|
58
|
+
readonly turnStatus?: SessionTurnStatus;
|
|
59
|
+
/** How long the session may remain idle before it is suspended. */
|
|
60
|
+
readonly idleTtl?: string;
|
|
61
|
+
readonly idleTtlMs?: number;
|
|
62
|
+
readonly createdAt?: string;
|
|
63
|
+
readonly updatedAt?: string;
|
|
64
|
+
readonly idleAt?: string | null;
|
|
65
|
+
readonly suspendedAt?: string | null;
|
|
66
|
+
readonly activeDurationMs?: number;
|
|
67
|
+
readonly lastTurnDurationMs?: number;
|
|
68
|
+
readonly retainedStorageBytes?: number;
|
|
69
|
+
readonly usage?: UsageSummary;
|
|
70
|
+
readonly costUsd?: number;
|
|
71
|
+
readonly errorMessage?: string | null;
|
|
72
|
+
readonly [key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
export interface SessionSummary {
|
|
75
|
+
readonly id: string;
|
|
76
|
+
readonly sessionId?: string;
|
|
77
|
+
readonly status: SessionStatus | string;
|
|
78
|
+
readonly turnSeq?: number;
|
|
79
|
+
/** How long the session may remain idle before it is suspended. */
|
|
80
|
+
readonly idleTtl?: string;
|
|
81
|
+
readonly idleTtlMs?: number;
|
|
82
|
+
readonly createdAt: string;
|
|
83
|
+
readonly updatedAt: string;
|
|
84
|
+
readonly idleAt?: string | null;
|
|
85
|
+
readonly suspendedAt?: string | null;
|
|
86
|
+
readonly activeDurationMs?: number;
|
|
87
|
+
readonly retainedStorageBytes?: number;
|
|
88
|
+
readonly costUsd?: number;
|
|
89
|
+
}
|
|
90
|
+
export interface SessionListQuery {
|
|
91
|
+
readonly status?: string;
|
|
92
|
+
readonly since?: string;
|
|
93
|
+
readonly limit?: number;
|
|
94
|
+
readonly cursor?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface SessionListPage {
|
|
97
|
+
readonly sessions: readonly SessionSummary[];
|
|
98
|
+
readonly nextCursor?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface SessionRetentionPolicy {
|
|
101
|
+
/** How long the session may remain idle before it is suspended. */
|
|
102
|
+
readonly idleTtl?: string;
|
|
103
|
+
}
|
|
104
|
+
export type SessionSubmission = Omit<PlatformSubmission, "prompt"> & {
|
|
105
|
+
readonly prompt?: readonly string[];
|
|
106
|
+
};
|
|
107
|
+
export type SessionCreateRequest = Omit<PlatformRunSubmissionInput, "idempotencyKey" | "submission"> & {
|
|
108
|
+
readonly submission: SessionSubmission;
|
|
109
|
+
readonly input?: string | readonly string[];
|
|
110
|
+
readonly retention?: SessionRetentionPolicy;
|
|
111
|
+
};
|
|
112
|
+
export interface SessionMessageRequest {
|
|
113
|
+
readonly input: string | readonly string[];
|
|
114
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
115
|
+
}
|
|
116
|
+
export interface SessionMessageAccepted {
|
|
117
|
+
readonly session: Session;
|
|
118
|
+
readonly turn: SessionTurn;
|
|
119
|
+
readonly eventCursor?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface SessionStateChangeAccepted {
|
|
122
|
+
readonly session: Session;
|
|
123
|
+
readonly turn?: SessionTurn;
|
|
124
|
+
readonly eventCursor?: number;
|
|
125
|
+
}
|
|
126
|
+
export type SessionEvent = import("./event-envelope.js").AexEvent;
|
|
41
127
|
export interface UsageSummary {
|
|
42
128
|
readonly inputTokens?: number;
|
|
43
129
|
readonly outputTokens?: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
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"];
|
|
1
|
+
export declare const RUN_STATUSES: readonly ["queued", "claiming", "provisioning", "session_created", "dispatched", "provider_running", "provider_idle", "provider_rescheduled", "idle", "suspending", "suspended", "deleting", "deleted", "expired", "cancelling", "capturing_outputs", "cleaning_up", "succeeded", "failed", "timed_out", "cancelled", "cleanup_failed"];
|
|
2
2
|
export type RunStatus = typeof RUN_STATUSES[number];
|
|
3
|
+
export declare const SESSION_STATUSES: readonly ["creating", "running", "idle", "suspending", "suspended", "cancelling", "deleting", "deleted", "error"];
|
|
4
|
+
export type SessionStatus = typeof SESSION_STATUSES[number];
|
|
3
5
|
export type RunStatusKind = "active" | "terminal";
|
|
4
6
|
export declare const TERMINAL_RUN_STATUSES: readonly ["succeeded", "failed", "timed_out", "cancelled", "cleanup_failed"];
|
|
5
7
|
export declare function isTerminalRunStatus(status: RunStatus): boolean;
|
|
@@ -7,6 +7,12 @@ export const RUN_STATUSES = [
|
|
|
7
7
|
"provider_running",
|
|
8
8
|
"provider_idle",
|
|
9
9
|
"provider_rescheduled",
|
|
10
|
+
"idle",
|
|
11
|
+
"suspending",
|
|
12
|
+
"suspended",
|
|
13
|
+
"deleting",
|
|
14
|
+
"deleted",
|
|
15
|
+
"expired",
|
|
10
16
|
"cancelling",
|
|
11
17
|
"capturing_outputs",
|
|
12
18
|
"cleaning_up",
|
|
@@ -16,6 +22,17 @@ export const RUN_STATUSES = [
|
|
|
16
22
|
"cancelled",
|
|
17
23
|
"cleanup_failed"
|
|
18
24
|
];
|
|
25
|
+
export const SESSION_STATUSES = [
|
|
26
|
+
"creating",
|
|
27
|
+
"running",
|
|
28
|
+
"idle",
|
|
29
|
+
"suspending",
|
|
30
|
+
"suspended",
|
|
31
|
+
"cancelling",
|
|
32
|
+
"deleting",
|
|
33
|
+
"deleted",
|
|
34
|
+
"error"
|
|
35
|
+
];
|
|
19
36
|
export const TERMINAL_RUN_STATUSES = [
|
|
20
37
|
"succeeded",
|
|
21
38
|
"failed",
|
|
@@ -2,7 +2,6 @@ import { PROXY_ENDPOINT_DEFAULTS, type ProxyAuthShape, type ProxyMethod, type Pr
|
|
|
2
2
|
export { PROXY_ENDPOINT_DEFAULTS };
|
|
3
3
|
import type { AgentsMdRef, FileRef, McpServerRef, SkillRef, ToolRef } from "./run-config.js";
|
|
4
4
|
import { type RuntimeSize } from "./runtime-sizes.js";
|
|
5
|
-
import { type PlatformPostHook, type PlatformPostHookInput } from "./post-hook.js";
|
|
6
5
|
import { type RunModel } from "./models.js";
|
|
7
6
|
import { type RuntimeSecurityProfileName } from "./runtime-security-profile.js";
|
|
8
7
|
export type JsonPrimitive = string | number | boolean | null;
|
|
@@ -395,13 +394,6 @@ export interface PlatformRunSubmissionRequest {
|
|
|
395
394
|
* terminal wait window and self-kill deadline.
|
|
396
395
|
*/
|
|
397
396
|
readonly timeoutMs?: number;
|
|
398
|
-
/**
|
|
399
|
-
* Optional post-agent-run verifier. Parsed from the public `postHook`
|
|
400
|
-
* duration/string shape into fixed runner budgets. The runner executes it
|
|
401
|
-
* after a successful agent process and sends failures back through the model
|
|
402
|
-
* for repair until this budget is exhausted.
|
|
403
|
-
*/
|
|
404
|
-
readonly postHook?: PlatformPostHook;
|
|
405
397
|
/**
|
|
406
398
|
* Lineage parent (agent-session §9). When present the server admits this
|
|
407
399
|
* run as a CHILD of `parentRunId`: it walks the parent's lineage, enforces
|
|
@@ -466,7 +458,7 @@ export interface RunLimits {
|
|
|
466
458
|
* {@link DEFAULT_RUN_PROVIDER} (`anthropic`). The parser fills it in
|
|
467
459
|
* before the value enters the run snapshot.
|
|
468
460
|
*/
|
|
469
|
-
export type PlatformRunSubmissionInput = Omit<PlatformRunSubmissionRequest, "workspaceId" | "provider" | "timeoutMs"
|
|
461
|
+
export type PlatformRunSubmissionInput = Omit<PlatformRunSubmissionRequest, "workspaceId" | "provider" | "timeoutMs"> & {
|
|
470
462
|
readonly workspaceId?: string;
|
|
471
463
|
readonly provider?: RunProvider;
|
|
472
464
|
/**
|
|
@@ -475,7 +467,6 @@ export type PlatformRunSubmissionInput = Omit<PlatformRunSubmissionRequest, "wor
|
|
|
475
467
|
* {@link PlatformRunSubmissionRequest.timeoutMs}. Absent ⇒ 1h default.
|
|
476
468
|
*/
|
|
477
469
|
readonly timeout?: string;
|
|
478
|
-
readonly postHook?: PlatformPostHookInput;
|
|
479
470
|
};
|
|
480
471
|
export interface ParseRunSubmissionOptions {
|
|
481
472
|
}
|
|
@@ -6,7 +6,6 @@ import { authShapeHeaderName, PROXY_ALLOWED_METHODS, PROXY_ENDPOINT_DEFAULTS, PR
|
|
|
6
6
|
export { PROXY_ENDPOINT_DEFAULTS };
|
|
7
7
|
import { TOOL_NAME_PATTERN, normaliseSkillBundlePath, parseAssetRefFields, parseMcpServerRef, parseSkillRef } from "./run-config.js";
|
|
8
8
|
import { parseRunTimeout, parseRuntimeSize } from "./runtime-sizes.js";
|
|
9
|
-
import { parsePostHook } from "./post-hook.js";
|
|
10
9
|
import { assertRunModelMatchesProvider, parseRunModel } from "./models.js";
|
|
11
10
|
import { parseRuntimeSecurityProfile } from "./runtime-security-profile.js";
|
|
12
11
|
/**
|
|
@@ -994,7 +993,6 @@ export function parseRunSubmissionRequest(input, options = {}) {
|
|
|
994
993
|
"submission",
|
|
995
994
|
"runtimeSize",
|
|
996
995
|
"timeout",
|
|
997
|
-
"postHook",
|
|
998
996
|
"proxyEndpoints",
|
|
999
997
|
"parentRunId",
|
|
1000
998
|
"webhook",
|
|
@@ -1027,7 +1025,6 @@ export function parseRunSubmissionRequest(input, options = {}) {
|
|
|
1027
1025
|
const parentRunId = optionalString(value.parentRunId, "submission.parentRunId");
|
|
1028
1026
|
const webhook = parseRunWebhook(value.webhook);
|
|
1029
1027
|
const limits = parseRunLimits(value.limits);
|
|
1030
|
-
const postHook = parsePostHook(value.postHook, "submission.postHook");
|
|
1031
1028
|
const proxyEndpoints = parseProxyEndpoints(value.proxyEndpoints);
|
|
1032
1029
|
const secrets = parseInlineSecrets(value.secrets);
|
|
1033
1030
|
enforceCredentialSecretPolicy(secrets, provider, {
|
|
@@ -1062,7 +1059,6 @@ export function parseRunSubmissionRequest(input, options = {}) {
|
|
|
1062
1059
|
submission,
|
|
1063
1060
|
...(runtimeSize ? { runtimeSize } : {}),
|
|
1064
1061
|
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
1065
|
-
...(postHook !== undefined ? { postHook } : {}),
|
|
1066
1062
|
...(proxyEndpoints ? { proxyEndpoints } : {}),
|
|
1067
1063
|
...(parentRunId !== undefined ? { parentRunId } : {}),
|
|
1068
1064
|
...(webhook !== undefined ? { webhook } : {}),
|