@aexhq/sdk 0.40.16 → 0.41.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 +25 -25
- package/dist/_contracts/api-key.d.ts +6 -4
- package/dist/_contracts/api-key.js +20 -7
- package/dist/_contracts/connection-ticket.d.ts +5 -5
- package/dist/_contracts/connection-ticket.js +7 -7
- package/dist/_contracts/error-codes.d.ts +1 -1
- package/dist/_contracts/error-codes.js +4 -4
- package/dist/_contracts/error-factory.js +1 -1
- package/dist/_contracts/event-envelope.d.ts +41 -41
- package/dist/_contracts/event-envelope.js +49 -49
- package/dist/_contracts/event-stream-client.d.ts +9 -9
- package/dist/_contracts/event-stream-client.js +5 -5
- package/dist/_contracts/event-view.d.ts +6 -6
- package/dist/_contracts/event-view.js +12 -12
- package/dist/_contracts/http.js +1 -1
- package/dist/_contracts/index.d.ts +10 -10
- package/dist/_contracts/index.js +9 -9
- package/dist/_contracts/models.d.ts +17 -17
- package/dist/_contracts/models.js +14 -14
- package/dist/_contracts/operations.d.ts +79 -82
- package/dist/_contracts/operations.js +233 -243
- package/dist/_contracts/provider-support.d.ts +2 -2
- package/dist/_contracts/runner-event.d.ts +8 -8
- package/dist/_contracts/runner-event.js +9 -9
- package/dist/_contracts/runtime-manifest.d.ts +12 -12
- package/dist/_contracts/runtime-manifest.js +1 -1
- package/dist/_contracts/runtime-sizes.d.ts +12 -12
- package/dist/_contracts/runtime-sizes.js +18 -18
- package/dist/_contracts/runtime-types.d.ts +117 -117
- package/dist/_contracts/runtime-types.js +2 -2
- package/dist/_contracts/sdk-errors.d.ts +3 -3
- package/dist/_contracts/sdk-errors.js +4 -4
- package/dist/_contracts/sdk-secrets.js +10 -10
- package/dist/_contracts/session-artifacts.d.ts +151 -0
- package/dist/_contracts/session-artifacts.js +234 -0
- package/dist/_contracts/{run-config.d.ts → session-config.d.ts} +29 -29
- package/dist/_contracts/{run-config.js → session-config.js} +37 -37
- package/dist/_contracts/session-cost.d.ts +140 -0
- package/dist/_contracts/{run-cost.js → session-cost.js} +94 -94
- package/dist/_contracts/{run-custody.d.ts → session-custody.d.ts} +16 -16
- package/dist/_contracts/{run-custody.js → session-custody.js} +42 -42
- package/dist/_contracts/session-record.d.ts +112 -0
- package/dist/_contracts/{run-record.js → session-record.js} +23 -23
- package/dist/_contracts/session-retention.d.ts +209 -0
- package/dist/_contracts/{run-retention.js → session-retention.js} +116 -116
- package/dist/_contracts/{run-unit.d.ts → session-unit.d.ts} +38 -38
- package/dist/_contracts/{run-unit.js → session-unit.js} +33 -33
- package/dist/_contracts/side-effect-audit.d.ts +14 -14
- package/dist/_contracts/side-effect-audit.js +38 -38
- package/dist/_contracts/sse.d.ts +1 -1
- package/dist/_contracts/sse.js +0 -0
- package/dist/_contracts/stable.d.ts +1 -1
- package/dist/_contracts/stable.js +1 -1
- package/dist/_contracts/status.d.ts +18 -18
- package/dist/_contracts/status.js +19 -19
- package/dist/_contracts/submission.d.ts +101 -99
- package/dist/_contracts/submission.js +96 -96
- package/dist/_contracts/{run-trace.d.ts → turn-trace.d.ts} +1 -1
- package/dist/_contracts/webhook-verify.d.ts +1 -1
- package/dist/_contracts/webhook-verify.js +1 -1
- package/dist/agents-md.d.ts +4 -4
- package/dist/agents-md.js +5 -5
- package/dist/agents-md.js.map +1 -1
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/dist/cli.mjs +578 -621
- package/dist/cli.mjs.sha256 +1 -1
- package/dist/client.d.ts +141 -155
- package/dist/client.js +236 -245
- package/dist/client.js.map +1 -1
- package/dist/fetch-archive.js +3 -3
- package/dist/file.d.ts +7 -7
- package/dist/file.js +8 -8
- package/dist/file.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.d.ts +1 -1
- package/dist/retry.d.ts +1 -1
- package/dist/secret.d.ts +6 -6
- package/dist/secret.js +6 -6
- package/dist/secret.js.map +1 -1
- package/dist/skill.d.ts +2 -2
- package/dist/skill.js +3 -3
- package/dist/skill.js.map +1 -1
- package/dist/tool.js +2 -2
- package/dist/tool.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/authentication.md +11 -11
- package/docs/billing.md +3 -3
- package/docs/cleanup.md +5 -5
- package/docs/concepts/agent-tools.md +5 -5
- package/docs/concepts/composition.md +3 -3
- package/docs/concepts/providers-and-runtimes.md +3 -3
- package/docs/concepts/{runs.md → sessions.md} +8 -8
- package/docs/concepts/subagents.md +16 -16
- package/docs/credentials.md +7 -7
- package/docs/defaults.md +14 -14
- package/docs/errors.md +10 -10
- package/docs/events.md +26 -26
- package/docs/files.md +267 -0
- package/docs/limits-and-quotas.md +35 -35
- package/docs/limits.md +6 -6
- package/docs/mcp.md +3 -3
- package/docs/networking.md +24 -24
- package/docs/provider-runtime-capabilities.md +1 -1
- package/docs/public-surface.json +6 -6
- package/docs/quickstart.md +13 -13
- package/docs/release.md +5 -5
- package/docs/retries.md +3 -3
- package/docs/secrets.md +16 -16
- package/docs/session-config.md +58 -0
- package/docs/{run-record.md → session-record.md} +16 -16
- package/docs/skills.md +9 -9
- package/docs/vision-skills.md +7 -7
- package/docs/webhooks.md +11 -11
- package/examples/feature-tour.ts +17 -17
- package/examples/spike-settle-latency.ts +11 -11
- package/package.json +1 -1
- package/dist/_contracts/run-artifacts.d.ts +0 -49
- package/dist/_contracts/run-artifacts.js +0 -102
- package/dist/_contracts/run-cost.d.ts +0 -140
- package/dist/_contracts/run-record.d.ts +0 -116
- package/dist/_contracts/run-retention.d.ts +0 -209
- package/docs/outputs.md +0 -267
- package/docs/run-config.md +0 -58
- /package/dist/_contracts/{run-trace.js → turn-trace.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderName } from "./submission.js";
|
|
2
2
|
export interface SupportPointer {
|
|
3
3
|
readonly label: string;
|
|
4
4
|
/** Markdown href, relative to `packages/sdk/docs/provider-runtime-capabilities.md`. */
|
|
@@ -224,4 +224,4 @@ export declare const PROVIDER_PUBLIC_SUPPORT: {
|
|
|
224
224
|
}];
|
|
225
225
|
};
|
|
226
226
|
};
|
|
227
|
-
export declare function providerPublicSupport(provider:
|
|
227
|
+
export declare function providerPublicSupport(provider: ProviderName): ProviderPublicSupport;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Unified runner event schema. The managed runtime feeds one shape into
|
|
3
3
|
* the hosted aex event pipeline:
|
|
4
4
|
*
|
|
5
|
-
* - The per-
|
|
6
|
-
* `/
|
|
5
|
+
* - The per-session managed runtime POSTs batches of NDJSON events to
|
|
6
|
+
* `/sessions/{id}/runner/events`; the runtime adapter translates each
|
|
7
7
|
* event into one or more `RunnerEvent`s.
|
|
8
8
|
*
|
|
9
9
|
* The downstream subscribers (dashboard, SDK `streamEvents`, observable
|
|
@@ -37,9 +37,9 @@ export declare const RUNNER_EVENT_VERSION: 1;
|
|
|
37
37
|
* - `notification` — runtime/extension notification; catch-all
|
|
38
38
|
* for diagnostic data.
|
|
39
39
|
* - `stream_error` — stream-level error (non-fatal). Subscribers
|
|
40
|
-
* may surface this as a UI warning; the
|
|
40
|
+
* may surface this as a UI warning; the session
|
|
41
41
|
* continues unless `runtime_terminal` follows.
|
|
42
|
-
* - `runtime_terminal` — the
|
|
42
|
+
* - `runtime_terminal` — the session reached a terminal state. The
|
|
43
43
|
* adapter MUST emit exactly one of these per
|
|
44
44
|
* run; subscribers gate on it for end-of-stream.
|
|
45
45
|
*/
|
|
@@ -48,7 +48,7 @@ export type RunnerEventKind = (typeof RUNNER_EVENT_KINDS)[number];
|
|
|
48
48
|
/**
|
|
49
49
|
* One event in the unified stream. `seq` is monotonically increasing
|
|
50
50
|
* within a single run (the adapter is responsible for assigning seqs
|
|
51
|
-
* — no two events with the same `seq` for the same `
|
|
51
|
+
* — no two events with the same `seq` for the same `sessionId`); `tMs` is
|
|
52
52
|
* a millisecond-resolution timestamp that is also monotonically
|
|
53
53
|
* non-decreasing within a single run (an event's `tMs` is never less
|
|
54
54
|
* than the previous event's `tMs`). `data` carries the runtime- and
|
|
@@ -69,7 +69,7 @@ export interface RunnerEvent {
|
|
|
69
69
|
*/
|
|
70
70
|
export interface RunnerEventBatch {
|
|
71
71
|
readonly v: typeof RUNNER_EVENT_VERSION;
|
|
72
|
-
readonly
|
|
72
|
+
readonly sessionId: string;
|
|
73
73
|
readonly events: readonly RunnerEvent[];
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -93,7 +93,7 @@ export type RunnerEventBatchValidation = {
|
|
|
93
93
|
readonly code: RunnerEventBatchValidationCode;
|
|
94
94
|
readonly message: string;
|
|
95
95
|
};
|
|
96
|
-
export declare const RUNNER_EVENT_BATCH_VALIDATION_CODES: readonly ["invalid_envelope", "version_mismatch", "
|
|
96
|
+
export declare const RUNNER_EVENT_BATCH_VALIDATION_CODES: readonly ["invalid_envelope", "version_mismatch", "missing_session_id", "empty_batch", "batch_too_large", "invalid_event", "seq_not_monotonic", "t_ms_not_monotonic"];
|
|
97
97
|
export type RunnerEventBatchValidationCode = (typeof RUNNER_EVENT_BATCH_VALIDATION_CODES)[number];
|
|
98
98
|
/**
|
|
99
99
|
* Parse + validate an inbound runner event batch (untrusted input).
|
|
@@ -103,7 +103,7 @@ export type RunnerEventBatchValidationCode = (typeof RUNNER_EVENT_BATCH_VALIDATI
|
|
|
103
103
|
* Successful validation guarantees:
|
|
104
104
|
* - top-level envelope matches {@link RunnerEventBatch}
|
|
105
105
|
* - `v === RUNNER_EVENT_VERSION`
|
|
106
|
-
* - `
|
|
106
|
+
* - `sessionId` is a non-empty string
|
|
107
107
|
* - `events` is a non-empty array of at most
|
|
108
108
|
* {@link RUNNER_EVENT_BATCH_MAX_EVENTS} entries
|
|
109
109
|
* - each event is a {@link RunnerEvent} with a known `kind`
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Unified runner event schema. The managed runtime feeds one shape into
|
|
3
3
|
* the hosted aex event pipeline:
|
|
4
4
|
*
|
|
5
|
-
* - The per-
|
|
6
|
-
* `/
|
|
5
|
+
* - The per-session managed runtime POSTs batches of NDJSON events to
|
|
6
|
+
* `/sessions/{id}/runner/events`; the runtime adapter translates each
|
|
7
7
|
* event into one or more `RunnerEvent`s.
|
|
8
8
|
*
|
|
9
9
|
* The downstream subscribers (dashboard, SDK `streamEvents`, observable
|
|
@@ -36,9 +36,9 @@ export const RUNNER_EVENT_VERSION = 1;
|
|
|
36
36
|
* - `notification` — runtime/extension notification; catch-all
|
|
37
37
|
* for diagnostic data.
|
|
38
38
|
* - `stream_error` — stream-level error (non-fatal). Subscribers
|
|
39
|
-
* may surface this as a UI warning; the
|
|
39
|
+
* may surface this as a UI warning; the session
|
|
40
40
|
* continues unless `runtime_terminal` follows.
|
|
41
|
-
* - `runtime_terminal` — the
|
|
41
|
+
* - `runtime_terminal` — the session reached a terminal state. The
|
|
42
42
|
* adapter MUST emit exactly one of these per
|
|
43
43
|
* run; subscribers gate on it for end-of-stream.
|
|
44
44
|
*/
|
|
@@ -63,7 +63,7 @@ export const RUNNER_EVENT_BATCH_MAX_EVENTS = 256;
|
|
|
63
63
|
export const RUNNER_EVENT_BATCH_VALIDATION_CODES = [
|
|
64
64
|
"invalid_envelope",
|
|
65
65
|
"version_mismatch",
|
|
66
|
-
"
|
|
66
|
+
"missing_session_id",
|
|
67
67
|
"empty_batch",
|
|
68
68
|
"batch_too_large",
|
|
69
69
|
"invalid_event",
|
|
@@ -78,7 +78,7 @@ export const RUNNER_EVENT_BATCH_VALIDATION_CODES = [
|
|
|
78
78
|
* Successful validation guarantees:
|
|
79
79
|
* - top-level envelope matches {@link RunnerEventBatch}
|
|
80
80
|
* - `v === RUNNER_EVENT_VERSION`
|
|
81
|
-
* - `
|
|
81
|
+
* - `sessionId` is a non-empty string
|
|
82
82
|
* - `events` is a non-empty array of at most
|
|
83
83
|
* {@link RUNNER_EVENT_BATCH_MAX_EVENTS} entries
|
|
84
84
|
* - each event is a {@link RunnerEvent} with a known `kind`
|
|
@@ -92,8 +92,8 @@ export function validateRunnerEventBatch(input) {
|
|
|
92
92
|
if (input.v !== RUNNER_EVENT_VERSION) {
|
|
93
93
|
return invalid("version_mismatch", `batch.v must equal ${RUNNER_EVENT_VERSION} (got ${JSON.stringify(input.v)})`);
|
|
94
94
|
}
|
|
95
|
-
if (typeof input.
|
|
96
|
-
return invalid("
|
|
95
|
+
if (typeof input.sessionId !== "string" || input.sessionId.length === 0) {
|
|
96
|
+
return invalid("missing_session_id", "batch.sessionId must be a non-empty string");
|
|
97
97
|
}
|
|
98
98
|
if (!Array.isArray(input.events) || input.events.length === 0) {
|
|
99
99
|
return invalid("empty_batch", "batch.events must be a non-empty array");
|
|
@@ -148,7 +148,7 @@ export function validateRunnerEventBatch(input) {
|
|
|
148
148
|
}
|
|
149
149
|
return {
|
|
150
150
|
ok: true,
|
|
151
|
-
batch: { v: RUNNER_EVENT_VERSION,
|
|
151
|
+
batch: { v: RUNNER_EVENT_VERSION, sessionId: input.sessionId, events: Object.freeze(events) }
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
function invalid(code, message) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderName } from "./submission.js";
|
|
2
2
|
/**
|
|
3
|
-
* Runtime manifest: the per-
|
|
3
|
+
* Runtime manifest: the per-session description of where
|
|
4
4
|
* aex places things inside the agent container, plus the merged
|
|
5
5
|
* env-var bag delivered via `RUNTIME.env` / `RUNTIME.json`.
|
|
6
6
|
*
|
|
7
|
-
* The hosted API computes a manifest at
|
|
7
|
+
* The hosted API computes a manifest at startSessionRecord-response time
|
|
8
8
|
* from the validated submission via {@link buildRuntimeManifest} and
|
|
9
9
|
* echoes it on the wire as
|
|
10
|
-
* `
|
|
10
|
+
* `SessionRecord.runtimeManifest`, so caller code (anyone rendering catalog markdown
|
|
11
11
|
* pre-submission, or resolving aex's in-container path strings) doesn't
|
|
12
12
|
* have to guess.
|
|
13
13
|
* The managed runtime materialises the actual `RUNTIME.env` / `RUNTIME.json`
|
|
@@ -16,7 +16,7 @@ import type { RunProvider } from "./submission.js";
|
|
|
16
16
|
*
|
|
17
17
|
* Manifest values are derived, never persisted separately — the source
|
|
18
18
|
* of truth for the customer half remains `submission.environment.envVars`
|
|
19
|
-
* on the
|
|
19
|
+
* on the session row; the aex half is constant for a given SDK version.
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* The in-container paths the agent and skill code reference at
|
|
@@ -30,18 +30,18 @@ import type { RunProvider } from "./submission.js";
|
|
|
30
30
|
* under `/mnt/session/uploads/`.
|
|
31
31
|
*/
|
|
32
32
|
export interface RuntimeManifest {
|
|
33
|
-
readonly provider:
|
|
33
|
+
readonly provider: ProviderName | string;
|
|
34
34
|
/** Where skill bundles auto-discover in the managed runner. */
|
|
35
35
|
readonly skillsRoot: string;
|
|
36
36
|
/** Parent dir of File mounts: `<filesRoot>/<f_id>/<rel-path>`. */
|
|
37
37
|
readonly filesRoot: string;
|
|
38
38
|
/** Parent dir of non-SKILL.md asset mounts: `<assetsRoot>/<skl_id>/<rel-path>`. */
|
|
39
39
|
readonly assetsRoot: string;
|
|
40
|
-
/** Absolute path of the in-container aex
|
|
40
|
+
/** Absolute path of the in-container aex starttime bridge (invoke via `bun`). */
|
|
41
41
|
readonly aexCli: string;
|
|
42
|
-
/** Absolute path of the in-container aex
|
|
42
|
+
/** Absolute path of the in-container aex starttime index. */
|
|
43
43
|
readonly indexJson: string;
|
|
44
|
-
/** Absolute path of the always-mounted aex
|
|
44
|
+
/** Absolute path of the always-mounted aex starttime contract README. */
|
|
45
45
|
readonly readme: string;
|
|
46
46
|
/** Absolute path of the machine-readable manifest mirror. */
|
|
47
47
|
readonly runtimeJson: string;
|
|
@@ -60,11 +60,11 @@ export interface RuntimeManifest {
|
|
|
60
60
|
* caller can learn where a handed file landed. `mountPath` is the validated
|
|
61
61
|
* directory the archive unzipped into (the SDK default is `/workspace`); a
|
|
62
62
|
* single file lands at `<mountPath>/<realFilename>`, a folder lands its entries
|
|
63
|
-
* under `<mountPath>/`. Empty when the
|
|
63
|
+
* under `<mountPath>/`. Empty when the session carried no files.
|
|
64
64
|
*/
|
|
65
65
|
readonly mountedFiles: readonly MountedFileManifest[];
|
|
66
66
|
}
|
|
67
|
-
/** One submitted `File`'s resolved mount directory (surfaced on the
|
|
67
|
+
/** One submitted `File`'s resolved mount directory (surfaced on the Session record). */
|
|
68
68
|
export interface MountedFileManifest {
|
|
69
69
|
/** The file's storage slug (`FileRef.name`). */
|
|
70
70
|
readonly name: string;
|
|
@@ -89,7 +89,7 @@ declare const RUNTIME_PATHS: Readonly<{
|
|
|
89
89
|
}>;
|
|
90
90
|
export declare function runtimePaths(): typeof RUNTIME_PATHS;
|
|
91
91
|
export interface BuildRuntimeManifestInput {
|
|
92
|
-
readonly provider:
|
|
92
|
+
readonly provider: ProviderName | string;
|
|
93
93
|
/**
|
|
94
94
|
* Customer-supplied `environment.envVars` from the validated
|
|
95
95
|
* submission. Keys with the reserved `AEX_` prefix are
|
|
@@ -26,7 +26,7 @@ export function runtimePaths() {
|
|
|
26
26
|
const AEX_PREFIX = "AEX_";
|
|
27
27
|
/**
|
|
28
28
|
* Default mount DIRECTORY for a `File` with no explicit `mountPath`. Mirrors
|
|
29
|
-
* `DEFAULT_FILE_MOUNT_PATH` in `
|
|
29
|
+
* `DEFAULT_FILE_MOUNT_PATH` in `session-config.ts`; duplicated here so this module
|
|
30
30
|
* stays self-contained (tree-shakeable) — the same reason {@link AEX_PREFIX}
|
|
31
31
|
* is inlined rather than imported from the submission parser.
|
|
32
32
|
*/
|
|
@@ -12,7 +12,7 @@ export interface RuntimeResources {
|
|
|
12
12
|
/**
|
|
13
13
|
* The single source of truth: every offered preset, keyed by its wire token.
|
|
14
14
|
* Tokens intentionally remain stable product presets. The smallest
|
|
15
|
-
* (`shared-0.06x-256mb`) tier is for light / IO-bound
|
|
15
|
+
* (`shared-0.06x-256mb`) tier is for light / IO-bound sessions only.
|
|
16
16
|
*/
|
|
17
17
|
export declare const RUNTIME_SIZE_PRESETS: {
|
|
18
18
|
readonly "shared-0.06x-256mb": {
|
|
@@ -65,12 +65,12 @@ export declare function runtimeResources(size: RuntimeSize): RuntimeResources;
|
|
|
65
65
|
* consumers apply {@link DEFAULT_RUNTIME_SIZE}.
|
|
66
66
|
*/
|
|
67
67
|
export declare function parseRuntimeSize(input: unknown): RuntimeSize | undefined;
|
|
68
|
-
/** Default
|
|
69
|
-
export declare const
|
|
70
|
-
/** Hard ceiling on a
|
|
71
|
-
export declare const
|
|
72
|
-
/** Floor on a
|
|
73
|
-
export declare const
|
|
68
|
+
/** Default session deadline when `timeout` is omitted (8 hours). */
|
|
69
|
+
export declare const DEFAULT_SESSION_TIMEOUT_MS: number;
|
|
70
|
+
/** Hard ceiling on a session deadline (8 hours). */
|
|
71
|
+
export declare const MAX_SESSION_TIMEOUT_MS: number;
|
|
72
|
+
/** Floor on a session deadline (1 minute). */
|
|
73
|
+
export declare const MIN_SESSION_TIMEOUT_MS: number;
|
|
74
74
|
/**
|
|
75
75
|
* Parse a human duration string (`"1h"`, `"90m"`, `"3600s"`, `"500ms"`, or a
|
|
76
76
|
* bare-ms integer) into milliseconds. Throws on malformed input.
|
|
@@ -79,17 +79,17 @@ export declare function parseDurationToMs(input: string): number;
|
|
|
79
79
|
/**
|
|
80
80
|
* Validate the wire `timeout` field (a duration string) into a bounded ms
|
|
81
81
|
* value. `undefined` (omitted) returns `undefined`; the consumer applies
|
|
82
|
-
* {@link
|
|
82
|
+
* {@link DEFAULT_SESSION_TIMEOUT_MS}.
|
|
83
83
|
*/
|
|
84
|
-
export declare function
|
|
84
|
+
export declare function parseSessionTimeout(input: unknown): number | undefined;
|
|
85
85
|
/** Apply the default when a parsed `timeoutMs` is absent. */
|
|
86
|
-
export declare function
|
|
86
|
+
export declare function resolveSessionTimeoutMs(timeoutMs: number | undefined): number;
|
|
87
87
|
/** Format a millisecond deadline as a second-granularity duration string. */
|
|
88
88
|
export declare function orchestrationTimeoutString(ms: number): string;
|
|
89
89
|
/** Runtime process: time to wait after graceful interrupt before hard kill. */
|
|
90
|
-
export declare const
|
|
90
|
+
export declare const SESSION_PROCESS_KILL_GRACE_MS: number;
|
|
91
91
|
/**
|
|
92
92
|
* Orchestrator: extra window past `timeoutMs` to wait for terminal callback
|
|
93
93
|
* before host-level cleanup.
|
|
94
94
|
*/
|
|
95
|
-
export declare const
|
|
95
|
+
export declare const SESSION_TERMINAL_GRACE_MS: number;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* The single source of truth: every offered preset, keyed by its wire token.
|
|
10
10
|
* Tokens intentionally remain stable product presets. The smallest
|
|
11
|
-
* (`shared-0.06x-256mb`) tier is for light / IO-bound
|
|
11
|
+
* (`shared-0.06x-256mb`) tier is for light / IO-bound sessions only.
|
|
12
12
|
*/
|
|
13
13
|
export const RUNTIME_SIZE_PRESETS = {
|
|
14
14
|
"shared-0.06x-256mb": { cpus: 0.0625, memoryMb: 256 },
|
|
@@ -52,14 +52,14 @@ export function parseRuntimeSize(input) {
|
|
|
52
52
|
return input;
|
|
53
53
|
}
|
|
54
54
|
// ===========================================================================
|
|
55
|
-
//
|
|
55
|
+
// SessionRecord timeout
|
|
56
56
|
// ===========================================================================
|
|
57
|
-
/** Default
|
|
58
|
-
export const
|
|
59
|
-
/** Hard ceiling on a
|
|
60
|
-
export const
|
|
61
|
-
/** Floor on a
|
|
62
|
-
export const
|
|
57
|
+
/** Default session deadline when `timeout` is omitted (8 hours). */
|
|
58
|
+
export const DEFAULT_SESSION_TIMEOUT_MS = 8 * 60 * 60 * 1000;
|
|
59
|
+
/** Hard ceiling on a session deadline (8 hours). */
|
|
60
|
+
export const MAX_SESSION_TIMEOUT_MS = 8 * 60 * 60 * 1000;
|
|
61
|
+
/** Floor on a session deadline (1 minute). */
|
|
62
|
+
export const MIN_SESSION_TIMEOUT_MS = 60 * 1000;
|
|
63
63
|
const DURATION_PATTERN = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/;
|
|
64
64
|
/**
|
|
65
65
|
* Parse a human duration string (`"1h"`, `"90m"`, `"3600s"`, `"500ms"`, or a
|
|
@@ -81,9 +81,9 @@ export function parseDurationToMs(input) {
|
|
|
81
81
|
/**
|
|
82
82
|
* Validate the wire `timeout` field (a duration string) into a bounded ms
|
|
83
83
|
* value. `undefined` (omitted) returns `undefined`; the consumer applies
|
|
84
|
-
* {@link
|
|
84
|
+
* {@link DEFAULT_SESSION_TIMEOUT_MS}.
|
|
85
85
|
*/
|
|
86
|
-
export function
|
|
86
|
+
export function parseSessionTimeout(input) {
|
|
87
87
|
if (input === undefined) {
|
|
88
88
|
return undefined;
|
|
89
89
|
}
|
|
@@ -91,26 +91,26 @@ export function parseRunTimeout(input) {
|
|
|
91
91
|
throw new Error(`timeout must be a duration string (e.g. "1h", "30m"); got ${JSON.stringify(input)}`);
|
|
92
92
|
}
|
|
93
93
|
const ms = parseDurationToMs(input);
|
|
94
|
-
if (ms <
|
|
95
|
-
throw new Error(`timeout must be at least ${
|
|
94
|
+
if (ms < MIN_SESSION_TIMEOUT_MS) {
|
|
95
|
+
throw new Error(`timeout must be at least ${MIN_SESSION_TIMEOUT_MS}ms (1m); got ${ms}ms`);
|
|
96
96
|
}
|
|
97
|
-
if (ms >
|
|
98
|
-
throw new Error(`timeout must be at most ${
|
|
97
|
+
if (ms > MAX_SESSION_TIMEOUT_MS) {
|
|
98
|
+
throw new Error(`timeout must be at most ${MAX_SESSION_TIMEOUT_MS}ms (8h); got ${ms}ms`);
|
|
99
99
|
}
|
|
100
100
|
return ms;
|
|
101
101
|
}
|
|
102
102
|
/** Apply the default when a parsed `timeoutMs` is absent. */
|
|
103
|
-
export function
|
|
104
|
-
return timeoutMs ??
|
|
103
|
+
export function resolveSessionTimeoutMs(timeoutMs) {
|
|
104
|
+
return timeoutMs ?? DEFAULT_SESSION_TIMEOUT_MS;
|
|
105
105
|
}
|
|
106
106
|
/** Format a millisecond deadline as a second-granularity duration string. */
|
|
107
107
|
export function orchestrationTimeoutString(ms) {
|
|
108
108
|
return `${Math.max(1, Math.ceil(ms / 1000))}s`;
|
|
109
109
|
}
|
|
110
110
|
/** Runtime process: time to wait after graceful interrupt before hard kill. */
|
|
111
|
-
export const
|
|
111
|
+
export const SESSION_PROCESS_KILL_GRACE_MS = 60 * 1000;
|
|
112
112
|
/**
|
|
113
113
|
* Orchestrator: extra window past `timeoutMs` to wait for terminal callback
|
|
114
114
|
* before host-level cleanup.
|
|
115
115
|
*/
|
|
116
|
-
export const
|
|
116
|
+
export const SESSION_TERMINAL_GRACE_MS = 90 * 1000;
|