@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
package/examples/feature-tour.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SDK feature tour: one managed session that uses typed model/runtime constants,
|
|
3
3
|
* inline AGENTS.md guidance, uploaded files, a custom tool bundle, selected
|
|
4
|
-
* built-in tools, runtime env vars/secrets, streamed events,
|
|
4
|
+
* built-in tools, runtime env vars/secrets, streamed events, file reads, and
|
|
5
5
|
* a follow-up session turn.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* SessionRecord from the repository root after building the workspace package:
|
|
8
8
|
*
|
|
9
9
|
* AEX_API_KEY=... DEEPSEEK_API_KEY=... bun packages/sdk/examples/feature-tour.ts
|
|
10
10
|
*
|
|
@@ -107,7 +107,7 @@ const runRules = await AgentsMd.fromContent(
|
|
|
107
107
|
"# Feature tour rules",
|
|
108
108
|
"- Use `/workspace/input/quarterly-metrics.csv` as the source table.",
|
|
109
109
|
"- Call `metric_lookup` for atlas, beacon, and cinder before writing conclusions.",
|
|
110
|
-
"- Write final artifacts under `/workspace/
|
|
110
|
+
"- Write final artifacts under `/workspace/files`.",
|
|
111
111
|
"- Never print runtime secret values or provider keys."
|
|
112
112
|
].join("\n"),
|
|
113
113
|
{ name: "feature-tour-rules" }
|
|
@@ -156,12 +156,12 @@ const session = await aex.openSession({
|
|
|
156
156
|
networking: { mode: "open" },
|
|
157
157
|
variables: {
|
|
158
158
|
FEATURE_TOUR: "true",
|
|
159
|
-
REPORT_DIR: "/workspace/
|
|
159
|
+
REPORT_DIR: "/workspace/files"
|
|
160
160
|
},
|
|
161
161
|
...(environmentSecrets ? { secrets: environmentSecrets } : {})
|
|
162
162
|
},
|
|
163
|
-
|
|
164
|
-
allowedDirs: ["/workspace/
|
|
163
|
+
fileCapture: {
|
|
164
|
+
allowedDirs: ["/workspace/files"],
|
|
165
165
|
deniedDirs: ["*.tmp"],
|
|
166
166
|
maxFiles: 10,
|
|
167
167
|
maxFileBytes: 1_000_000
|
|
@@ -185,8 +185,8 @@ console.log(`session: ${session.id}`);
|
|
|
185
185
|
const prompt = [
|
|
186
186
|
"Analyze the attached quarterly metrics.",
|
|
187
187
|
"Call metric_lookup for atlas, beacon, and cinder.",
|
|
188
|
-
"Create /workspace/
|
|
189
|
-
"Create /workspace/
|
|
188
|
+
"Create /workspace/files/feature-tour-report.md with a short table, a ranking by q2_revenue_usd, and two risks.",
|
|
189
|
+
"Create /workspace/files/summary.json with keys topProduct, totalQ2RevenueUsd, highestActivationProduct, and riskCount."
|
|
190
190
|
].join(" ");
|
|
191
191
|
|
|
192
192
|
const firstTurn = session.send(prompt);
|
|
@@ -230,24 +230,24 @@ console.log(`assistant messages: ${messages.length}`);
|
|
|
230
230
|
const events = await session.events().list();
|
|
231
231
|
console.log(`captured events: ${events.length}`);
|
|
232
232
|
|
|
233
|
-
const
|
|
234
|
-
console.log("
|
|
235
|
-
for (const
|
|
236
|
-
console.log(`- ${
|
|
233
|
+
const files = await session.files().list();
|
|
234
|
+
console.log("files:");
|
|
235
|
+
for (const file of files) {
|
|
236
|
+
console.log(`- ${file.filename ?? file.id} (${file.contentType ?? "unknown"})`);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
const summary = await session.
|
|
239
|
+
const summary = await session.files().read(
|
|
240
240
|
{ path: "summary.json", match: "suffix" },
|
|
241
241
|
{ maxBytes: 20_000 }
|
|
242
242
|
);
|
|
243
243
|
console.log("summary.json:");
|
|
244
244
|
console.log(summary.text);
|
|
245
245
|
|
|
246
|
-
const report = await session.
|
|
246
|
+
const report = await session.files().findOne({
|
|
247
247
|
filename: "feature-tour-report.md"
|
|
248
248
|
});
|
|
249
249
|
if (report) {
|
|
250
|
-
const reportPreview = await session.
|
|
250
|
+
const reportPreview = await session.files().read(report, {
|
|
251
251
|
maxBytes: 4_000,
|
|
252
252
|
grep: "risk"
|
|
253
253
|
});
|
|
@@ -255,8 +255,8 @@ if (report) {
|
|
|
255
255
|
console.log(reportPreview.text || "(no risk lines found)");
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
const
|
|
259
|
-
console.log(`
|
|
258
|
+
const reopenedFiles = await aex.sessions.files(session.id).list();
|
|
259
|
+
console.log(`files via aex.sessions.files(...): ${reopenedFiles.length}`);
|
|
260
260
|
|
|
261
261
|
if (downloadPath) {
|
|
262
262
|
const bytes = await session.download({ to: downloadPath });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SPIKE (throwaway): measure the real park-event -> record-idle gap for interactive
|
|
3
3
|
* session turns. This is the extra wall-clock Option B (settle-consistent turn stream)
|
|
4
|
-
* would force onto EVERY turn: the turn stream currently ends on the
|
|
4
|
+
* would force onto EVERY turn: the turn stream currently ends on the TURN_FINISHED park
|
|
5
5
|
* event, but the session RECORD flips running->idle later, in the async settle lambda.
|
|
6
6
|
*
|
|
7
7
|
* AEX_API_KEY=... DEEPSEEK_API_KEY=... AEX_API_URL=... bun packages/sdk/examples/spike-settle-latency.ts
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Optional: SPIKE_TURNS=8 (samples), SPIKE_POLL_MS=120 (record poll interval).
|
|
10
10
|
*
|
|
11
11
|
* Method per turn:
|
|
12
|
-
* 1) send a tiny prompt, stream events, capture t_runFinished at the
|
|
12
|
+
* 1) send a tiny prompt, stream events, capture t_runFinished at the TURN_FINISHED event
|
|
13
13
|
* (this is where the default turn stream ends), then stop consuming.
|
|
14
14
|
* 2) tight-poll session.refresh() until status === "idle"; capture t_idle.
|
|
15
15
|
* 3) settleGapMs = t_idle - t_runFinished <-- the Option B tax.
|
|
@@ -48,21 +48,21 @@ const samples: Sample[] = [];
|
|
|
48
48
|
for (let i = 0; i < turns; i++) {
|
|
49
49
|
const stream = session.send(`Say hello #${i + 1} in one short sentence.`);
|
|
50
50
|
const tStart = performance.now();
|
|
51
|
-
let
|
|
51
|
+
let tTurnFinished = 0;
|
|
52
52
|
let errored = false;
|
|
53
53
|
for await (const event of stream) {
|
|
54
|
-
if (event.
|
|
54
|
+
if (event.isTurnError()) {
|
|
55
55
|
errored = true;
|
|
56
|
-
|
|
56
|
+
tTurnFinished = performance.now();
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
if (event.
|
|
60
|
-
|
|
59
|
+
if (event.isTurnFinished()) {
|
|
60
|
+
tTurnFinished = performance.now();
|
|
61
61
|
break; // default turn stream would end HERE
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
65
|
-
const turnMs =
|
|
64
|
+
if (tTurnFinished === 0) tTurnFinished = performance.now();
|
|
65
|
+
const turnMs = tTurnFinished - tStart;
|
|
66
66
|
|
|
67
67
|
// Tight-poll the authoritative record until it leaves running.
|
|
68
68
|
let polls = 0;
|
|
@@ -84,11 +84,11 @@ for (let i = 0; i < turns; i++) {
|
|
|
84
84
|
}
|
|
85
85
|
await sleep(pollMs);
|
|
86
86
|
}
|
|
87
|
-
const settleGapMs = tIdle -
|
|
87
|
+
const settleGapMs = tIdle - tTurnFinished;
|
|
88
88
|
samples.push({ turn: i + 1, turnMs, settleGapMs, polls, timedOut });
|
|
89
89
|
console.log(
|
|
90
90
|
`turn ${String(i + 1).padStart(2)} turn=${fmt(turnMs)} settleGap=${fmt(settleGapMs)} polls=${polls}` +
|
|
91
|
-
(errored ? " (
|
|
91
|
+
(errored ? " (TURN_ERROR)" : "") +
|
|
92
92
|
(timedOut ? " (TIMEOUT>90s)" : "")
|
|
93
93
|
);
|
|
94
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.1",
|
|
4
4
|
"description": "TypeScript SDK for running autonomous agent sessions across providers (Anthropic, OpenAI, DeepSeek, Gemini, Mistral) behind one interface.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single source of truth for a run's artifact namespaces.
|
|
3
|
-
*
|
|
4
|
-
* Every run stores public outputs and internal diagnostics under separate
|
|
5
|
-
* prefixes:
|
|
6
|
-
*
|
|
7
|
-
* runs/<runId>/outputs/<rel> — the run's real deliverables.
|
|
8
|
-
* runs/<runId>/internal/logs/<rel> — platform diagnostics
|
|
9
|
-
* (`runtime/`, `host/`,
|
|
10
|
-
* `provider-proxy/`,
|
|
11
|
-
* `control-plane/`).
|
|
12
|
-
*
|
|
13
|
-
* The runner uploads every file with a workspace-relative path and the
|
|
14
|
-
* server decides the namespace from that path's prefix, so the split is
|
|
15
|
-
* owned here — the runner does not need to know about it. Diagnostics
|
|
16
|
-
* reach the upload route as workspace dotdirs (`.runtime-logs/...`,
|
|
17
|
-
* `.host-logs/...`, etc.) or runtime-managed home-directory state; the stored
|
|
18
|
-
* path uses canonical log namespaces.
|
|
19
|
-
*/
|
|
20
|
-
export declare const RUN_OUTPUTS_PREFIX = "outputs";
|
|
21
|
-
export declare const RUN_INTERNAL_LOGS_PREFIX = "internal/logs";
|
|
22
|
-
/**
|
|
23
|
-
* Relative-path prefixes that mark a stored artifact as a platform diagnostic
|
|
24
|
-
* rather than a run deliverable. Dotted forms are upload-time paths; legacy
|
|
25
|
-
* forms are accepted so old records normalize to the canonical namespace.
|
|
26
|
-
*/
|
|
27
|
-
export declare const RUN_LOG_REL_PREFIXES: readonly [".runtime-logs/", ".host-logs/", ".provider-proxy/", ".control-plane/", ".anthropic-debug/", ".goose-logs/", ".fly-logs/", "runtime/", "host/", "provider-proxy/", "control-plane/", "anthropic-debug/", "goose-logs/", "fly-logs/"];
|
|
28
|
-
/** True when a workspace-relative artifact path belongs to the internal logs namespace. */
|
|
29
|
-
export declare function isRunLogRelPath(rel: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* The artifact's path relative to its namespace prefix as stored. Diagnostics
|
|
32
|
-
* are canonicalized (`.runtime-logs/x` -> `runtime/x`,
|
|
33
|
-
* legacy `.goose-logs/x` -> `runtime/x`, legacy `.fly-logs/x` -> `host/x`).
|
|
34
|
-
*/
|
|
35
|
-
export declare function runArtifactRel(rel: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Storage key for a run artifact uploaded with relative path `rel`, routing
|
|
38
|
-
* diagnostics into `internal/logs/` and everything else into `outputs/`.
|
|
39
|
-
*/
|
|
40
|
-
export declare function runArtifactKey(runId: string, rel: string): string;
|
|
41
|
-
/** The `assets` namespace under a run's prefix. */
|
|
42
|
-
export declare const RUN_ASSETS_PREFIX = "assets";
|
|
43
|
-
/**
|
|
44
|
-
* Storage key for a run's snapshotted asset, addressed by its content hash.
|
|
45
|
-
* At submit, each referenced shared-store asset is copied here so the run owns
|
|
46
|
-
* its bytes. Accepts a `sha256:<hex>` hash or a bare 64-hex digest; the stored
|
|
47
|
-
* suffix is the hex.
|
|
48
|
-
*/
|
|
49
|
-
export declare function runAssetKey(runId: string, hash: string): string;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single source of truth for a run's artifact namespaces.
|
|
3
|
-
*
|
|
4
|
-
* Every run stores public outputs and internal diagnostics under separate
|
|
5
|
-
* prefixes:
|
|
6
|
-
*
|
|
7
|
-
* runs/<runId>/outputs/<rel> — the run's real deliverables.
|
|
8
|
-
* runs/<runId>/internal/logs/<rel> — platform diagnostics
|
|
9
|
-
* (`runtime/`, `host/`,
|
|
10
|
-
* `provider-proxy/`,
|
|
11
|
-
* `control-plane/`).
|
|
12
|
-
*
|
|
13
|
-
* The runner uploads every file with a workspace-relative path and the
|
|
14
|
-
* server decides the namespace from that path's prefix, so the split is
|
|
15
|
-
* owned here — the runner does not need to know about it. Diagnostics
|
|
16
|
-
* reach the upload route as workspace dotdirs (`.runtime-logs/...`,
|
|
17
|
-
* `.host-logs/...`, etc.) or runtime-managed home-directory state; the stored
|
|
18
|
-
* path uses canonical log namespaces.
|
|
19
|
-
*/
|
|
20
|
-
export const RUN_OUTPUTS_PREFIX = "outputs";
|
|
21
|
-
export const RUN_INTERNAL_LOGS_PREFIX = "internal/logs";
|
|
22
|
-
/**
|
|
23
|
-
* Relative-path prefixes that mark a stored artifact as a platform diagnostic
|
|
24
|
-
* rather than a run deliverable. Dotted forms are upload-time paths; legacy
|
|
25
|
-
* forms are accepted so old records normalize to the canonical namespace.
|
|
26
|
-
*/
|
|
27
|
-
export const RUN_LOG_REL_PREFIXES = [
|
|
28
|
-
".runtime-logs/",
|
|
29
|
-
".host-logs/",
|
|
30
|
-
".provider-proxy/",
|
|
31
|
-
".control-plane/",
|
|
32
|
-
".anthropic-debug/",
|
|
33
|
-
".goose-logs/",
|
|
34
|
-
".fly-logs/",
|
|
35
|
-
"runtime/",
|
|
36
|
-
"host/",
|
|
37
|
-
"provider-proxy/",
|
|
38
|
-
"control-plane/",
|
|
39
|
-
"anthropic-debug/",
|
|
40
|
-
"goose-logs/",
|
|
41
|
-
"fly-logs/"
|
|
42
|
-
];
|
|
43
|
-
/** True when a workspace-relative artifact path belongs to the internal logs namespace. */
|
|
44
|
-
export function isRunLogRelPath(rel) {
|
|
45
|
-
return RUN_LOG_REL_PREFIXES.some((prefix) => rel.startsWith(prefix));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The artifact's path relative to its namespace prefix as stored. Diagnostics
|
|
49
|
-
* are canonicalized (`.runtime-logs/x` -> `runtime/x`,
|
|
50
|
-
* legacy `.goose-logs/x` -> `runtime/x`, legacy `.fly-logs/x` -> `host/x`).
|
|
51
|
-
*/
|
|
52
|
-
export function runArtifactRel(rel) {
|
|
53
|
-
if (rel.startsWith(".runtime-logs/"))
|
|
54
|
-
return `runtime/${rel.slice(".runtime-logs/".length)}`;
|
|
55
|
-
if (rel.startsWith("runtime/"))
|
|
56
|
-
return rel;
|
|
57
|
-
if (rel.startsWith(".host-logs/"))
|
|
58
|
-
return `host/${rel.slice(".host-logs/".length)}`;
|
|
59
|
-
if (rel.startsWith("host/"))
|
|
60
|
-
return rel;
|
|
61
|
-
if (rel.startsWith(".provider-proxy/"))
|
|
62
|
-
return `provider-proxy/${rel.slice(".provider-proxy/".length)}`;
|
|
63
|
-
if (rel.startsWith("provider-proxy/"))
|
|
64
|
-
return rel;
|
|
65
|
-
if (rel.startsWith(".control-plane/"))
|
|
66
|
-
return `control-plane/${rel.slice(".control-plane/".length)}`;
|
|
67
|
-
if (rel.startsWith("control-plane/"))
|
|
68
|
-
return rel;
|
|
69
|
-
if (rel.startsWith(".goose-logs/"))
|
|
70
|
-
return `runtime/${rel.slice(".goose-logs/".length)}`;
|
|
71
|
-
if (rel.startsWith("goose-logs/"))
|
|
72
|
-
return `runtime/${rel.slice("goose-logs/".length)}`;
|
|
73
|
-
if (rel.startsWith(".fly-logs/"))
|
|
74
|
-
return `host/${rel.slice(".fly-logs/".length)}`;
|
|
75
|
-
if (rel.startsWith("fly-logs/"))
|
|
76
|
-
return `host/${rel.slice("fly-logs/".length)}`;
|
|
77
|
-
if (rel.startsWith(".anthropic-debug/"))
|
|
78
|
-
return `provider-proxy/${rel.slice(".anthropic-debug/".length)}`;
|
|
79
|
-
if (rel.startsWith("anthropic-debug/"))
|
|
80
|
-
return `provider-proxy/${rel.slice("anthropic-debug/".length)}`;
|
|
81
|
-
return rel;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Storage key for a run artifact uploaded with relative path `rel`, routing
|
|
85
|
-
* diagnostics into `internal/logs/` and everything else into `outputs/`.
|
|
86
|
-
*/
|
|
87
|
-
export function runArtifactKey(runId, rel) {
|
|
88
|
-
const namespace = isRunLogRelPath(rel) ? RUN_INTERNAL_LOGS_PREFIX : RUN_OUTPUTS_PREFIX;
|
|
89
|
-
return `runs/${runId}/${namespace}/${runArtifactRel(rel)}`;
|
|
90
|
-
}
|
|
91
|
-
/** The `assets` namespace under a run's prefix. */
|
|
92
|
-
export const RUN_ASSETS_PREFIX = "assets";
|
|
93
|
-
/**
|
|
94
|
-
* Storage key for a run's snapshotted asset, addressed by its content hash.
|
|
95
|
-
* At submit, each referenced shared-store asset is copied here so the run owns
|
|
96
|
-
* its bytes. Accepts a `sha256:<hex>` hash or a bare 64-hex digest; the stored
|
|
97
|
-
* suffix is the hex.
|
|
98
|
-
*/
|
|
99
|
-
export function runAssetKey(runId, hash) {
|
|
100
|
-
const hex = hash.startsWith("sha256:") ? hash.slice("sha256:".length) : hash;
|
|
101
|
-
return `runs/${runId}/${RUN_ASSETS_PREFIX}/${hex}`;
|
|
102
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import type { RunProvider } from "./submission.js";
|
|
2
|
-
export declare const RUN_COST_TELEMETRY_SCHEMA_VERSION = 1;
|
|
3
|
-
export declare const RUN_USAGE_SAMPLE_SCHEMA_VERSION = 1;
|
|
4
|
-
export declare const RUN_COST_SUMMARY_STATUSES: readonly ["pending", "partial", "complete", "unavailable", "not_applicable"];
|
|
5
|
-
export type RunCostSummaryStatus = (typeof RUN_COST_SUMMARY_STATUSES)[number];
|
|
6
|
-
export declare const RUN_USAGE_SAMPLE_UNITS: readonly ["token", "millisecond", "byte", "byte_millisecond", "count", "file", "credit_unit"];
|
|
7
|
-
export type RunUsageSampleUnit = (typeof RUN_USAGE_SAMPLE_UNITS)[number];
|
|
8
|
-
export declare const RUN_USAGE_SAMPLE_SOURCE_TYPES: readonly ["coordinator-event", "run-event", "usage-ledger", "output-object", "proxy-call", "runtime-job", "provider-session", "storage-accrual", "manual-adjustment"];
|
|
9
|
-
export type RunUsageSampleSourceType = (typeof RUN_USAGE_SAMPLE_SOURCE_TYPES)[number];
|
|
10
|
-
export declare const RUN_USAGE_SAMPLE_METRICS: readonly ["provider.input_tokens", "provider.output_tokens", "provider.cache_read_input_tokens", "provider.cache_creation_input_tokens", "provider.total_tokens", "runtime.queued_ms", "runtime.active_ms", "runtime.output_capture_ms", "runtime.cleanup_ms", "run.total_ms", "output.discovered_files", "output.captured_files", "output.failed_files", "output.captured_bytes", "retry.runtime_attempts", "retry.provider_poll", "retry.output_capture", "retry.output_upload", "capture.uploaded_files", "capture.failed_files", "capture.total_bytes", "storage.current_bytes", "storage.byte_milliseconds", "proxy.call_count", "proxy.failed_call_count", "proxy.request_bytes", "proxy.response_bytes", "proxy.duration_ms"];
|
|
11
|
-
export type RunUsageSampleMetric = (typeof RUN_USAGE_SAMPLE_METRICS)[number];
|
|
12
|
-
export interface RunUsageSampleSource {
|
|
13
|
-
readonly type: RunUsageSampleSourceType;
|
|
14
|
-
readonly id: string;
|
|
15
|
-
readonly observedAt?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface RunUsageSample {
|
|
18
|
-
readonly schemaVersion: typeof RUN_USAGE_SAMPLE_SCHEMA_VERSION;
|
|
19
|
-
readonly sampleId?: string;
|
|
20
|
-
readonly runId?: string;
|
|
21
|
-
readonly metric: RunUsageSampleMetric;
|
|
22
|
-
readonly unit: RunUsageSampleUnit;
|
|
23
|
-
readonly quantity: number;
|
|
24
|
-
readonly source: RunUsageSampleSource;
|
|
25
|
-
readonly provider?: RunProvider | string;
|
|
26
|
-
readonly model?: string;
|
|
27
|
-
readonly recordedAt?: string;
|
|
28
|
-
}
|
|
29
|
-
export type RunUsageSampleInput = Omit<RunUsageSample, "schemaVersion" | "unit"> & {
|
|
30
|
-
readonly unit?: RunUsageSampleUnit;
|
|
31
|
-
};
|
|
32
|
-
export interface RunCostSourceSummary {
|
|
33
|
-
readonly sampleCount: number;
|
|
34
|
-
readonly metrics?: readonly RunUsageSampleMetric[];
|
|
35
|
-
readonly sourceTypes?: readonly RunUsageSampleSourceType[];
|
|
36
|
-
readonly sourceSampleIds?: readonly string[];
|
|
37
|
-
}
|
|
38
|
-
export interface RunCostDurations {
|
|
39
|
-
readonly queuedMs?: number;
|
|
40
|
-
readonly runtimeMs?: number;
|
|
41
|
-
readonly outputCaptureMs?: number;
|
|
42
|
-
readonly cleanupMs?: number;
|
|
43
|
-
readonly totalMs?: number;
|
|
44
|
-
}
|
|
45
|
-
export interface RunCostOutputTelemetry {
|
|
46
|
-
readonly discoveredFiles?: number;
|
|
47
|
-
readonly capturedFiles?: number;
|
|
48
|
-
readonly failedFiles?: number;
|
|
49
|
-
readonly capturedBytes?: number;
|
|
50
|
-
}
|
|
51
|
-
export interface RunCostRetryTelemetry {
|
|
52
|
-
readonly runtimeAttempts?: number;
|
|
53
|
-
readonly providerPollRetries?: number;
|
|
54
|
-
readonly outputCaptureRetries?: number;
|
|
55
|
-
readonly outputUploadRetries?: number;
|
|
56
|
-
}
|
|
57
|
-
export interface RunCostCaptureTelemetry {
|
|
58
|
-
readonly attempted: boolean;
|
|
59
|
-
readonly uploadedFiles?: number;
|
|
60
|
-
readonly failedFiles?: number;
|
|
61
|
-
readonly totalBytes?: number;
|
|
62
|
-
readonly failureReasons?: readonly string[];
|
|
63
|
-
}
|
|
64
|
-
export interface RunCostProviderUsage {
|
|
65
|
-
readonly provider: RunProvider | string;
|
|
66
|
-
readonly model?: string;
|
|
67
|
-
readonly inputTokens?: number;
|
|
68
|
-
readonly outputTokens?: number;
|
|
69
|
-
readonly cacheReadInputTokens?: number;
|
|
70
|
-
readonly cacheCreationInputTokens?: number;
|
|
71
|
-
readonly totalTokens?: number;
|
|
72
|
-
readonly sourceEventId?: string;
|
|
73
|
-
readonly sourceSampleIds?: readonly string[];
|
|
74
|
-
}
|
|
75
|
-
export interface RunCostStorageTelemetry {
|
|
76
|
-
readonly storedBytes?: number;
|
|
77
|
-
readonly byteMilliseconds?: number;
|
|
78
|
-
}
|
|
79
|
-
export interface RunCostProxyTelemetry {
|
|
80
|
-
readonly calls?: number;
|
|
81
|
-
readonly failedCalls?: number;
|
|
82
|
-
readonly requestBytes?: number;
|
|
83
|
-
readonly responseBytes?: number;
|
|
84
|
-
readonly durationMs?: number;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The basis for a {@link RunCostTelemetry.billedCostUsd}: an honest marker of
|
|
88
|
-
* whether the figure is a settle-time ESTIMATE or has been RECONCILED against
|
|
89
|
-
* authoritative actuals. Deliberately carries NO rate-card version or unit
|
|
90
|
-
* rates — the platform's public-safe convention treats `rateCard`/`margin` as
|
|
91
|
-
* private tokens (run-cost.test.ts privateCostFieldPattern), so the version the
|
|
92
|
-
* figure was derived under stays internal (recorded only in the platform's
|
|
93
|
-
* internal raw-usage export).
|
|
94
|
-
*/
|
|
95
|
-
export declare const RUN_COST_BASIS_STATUSES: readonly ["estimated", "reconciled"];
|
|
96
|
-
export type RunCostBasisStatus = (typeof RUN_COST_BASIS_STATUSES)[number];
|
|
97
|
-
export interface RunCostBasis {
|
|
98
|
-
readonly currency: "USD";
|
|
99
|
-
readonly status: RunCostBasisStatus;
|
|
100
|
-
}
|
|
101
|
-
export interface RunCostTelemetry {
|
|
102
|
-
readonly schemaVersion: typeof RUN_COST_TELEMETRY_SCHEMA_VERSION;
|
|
103
|
-
readonly runId?: string;
|
|
104
|
-
readonly provider?: RunProvider | string;
|
|
105
|
-
readonly recordedAt?: string;
|
|
106
|
-
readonly status?: RunCostSummaryStatus;
|
|
107
|
-
readonly sourceSummary?: RunCostSourceSummary;
|
|
108
|
-
readonly durations?: RunCostDurations;
|
|
109
|
-
readonly outputs?: RunCostOutputTelemetry;
|
|
110
|
-
readonly retries?: RunCostRetryTelemetry;
|
|
111
|
-
readonly capture?: RunCostCaptureTelemetry;
|
|
112
|
-
readonly providerUsage?: readonly RunCostProviderUsage[];
|
|
113
|
-
readonly storage?: RunCostStorageTelemetry;
|
|
114
|
-
readonly proxy?: RunCostProxyTelemetry;
|
|
115
|
-
/**
|
|
116
|
-
* Customer-facing AEX cost of serving this run, USD — a REPORTED ESTIMATE,
|
|
117
|
-
* not a charge (telemetry/showback only; no invoicing or credit deduction).
|
|
118
|
-
* = rawCostUsd × marginMultiplier (margin currently a global 1.0). EXCLUDES
|
|
119
|
-
* the customer's BYOK provider spend. The raw (pre-margin) figure is kept
|
|
120
|
-
* internal and never appears on this public-safe shape. A plain number, so it
|
|
121
|
-
* passes the run-record public-safe archive scan. Absent when the run incurred
|
|
122
|
-
* no priced AEX usage.
|
|
123
|
-
*/
|
|
124
|
-
readonly billedCostUsd?: number;
|
|
125
|
-
/** Currency + estimate/reconciled basis for {@link billedCostUsd}. */
|
|
126
|
-
readonly costBasis?: RunCostBasis;
|
|
127
|
-
}
|
|
128
|
-
export type RunCostTelemetryInput = Omit<RunCostTelemetry, "schemaVersion">;
|
|
129
|
-
export interface RunCostTelemetryFromUsageSamplesInput {
|
|
130
|
-
readonly runId?: string;
|
|
131
|
-
readonly provider?: RunProvider | string;
|
|
132
|
-
readonly recordedAt?: string;
|
|
133
|
-
readonly status?: RunCostSummaryStatus;
|
|
134
|
-
readonly samples: readonly RunUsageSampleInput[];
|
|
135
|
-
}
|
|
136
|
-
export declare function buildRunUsageSample(input: RunUsageSampleInput): RunUsageSample;
|
|
137
|
-
export declare function buildRunCostTelemetry(input: RunCostTelemetryInput): RunCostTelemetry;
|
|
138
|
-
export declare function buildRunCostTelemetryFromUsageSamples(input: RunCostTelemetryFromUsageSamplesInput): RunCostTelemetry;
|
|
139
|
-
export declare function summarizeUsageSamples(samples: readonly RunUsageSampleInput[]): RunCostSourceSummary;
|
|
140
|
-
export declare function mergeRunCostTelemetry(base: RunCostTelemetry, next: RunCostTelemetryInput): RunCostTelemetry;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { RunCostTelemetry } from "./run-cost.js";
|
|
2
|
-
import { type CustodyManifestV1, type CustodyRedactionFinding } from "./run-custody.js";
|
|
3
|
-
import type { AexEvent } from "./event-envelope.js";
|
|
4
|
-
import type { Run, Output } from "./runtime-types.js";
|
|
5
|
-
import type { PlatformSubmission } from "./submission.js";
|
|
6
|
-
export declare const RUN_RECORD_SCHEMA_VERSION: "aex.run-record.v1";
|
|
7
|
-
export declare const RUN_RECORD_MANIFEST_SCHEMA_VERSION: "aex.run-record.manifest.v1";
|
|
8
|
-
export type RunRecordArchiveNamespaceV1 = "metadata" | "events" | "outputs";
|
|
9
|
-
export type RunRecordFileStatusV1 = "present" | "absent" | "pending" | "unavailable" | "not_applicable" | "error";
|
|
10
|
-
export type RunRecordArchiveFileRoleV1 = "run_metadata" | "submission_snapshot" | "cost" | "custody" | "typed_events" | "coordinator_events_manifest" | "output";
|
|
11
|
-
export interface RunRecordSubmissionSnapshotV1 {
|
|
12
|
-
readonly submission: PlatformSubmission;
|
|
13
|
-
}
|
|
14
|
-
export interface RunRecordCostV1 {
|
|
15
|
-
readonly status: RunRecordFileStatusV1;
|
|
16
|
-
readonly telemetry?: RunCostTelemetry;
|
|
17
|
-
}
|
|
18
|
-
export interface RunRecordMetadataV1 {
|
|
19
|
-
readonly run: Run;
|
|
20
|
-
readonly submission?: RunRecordSubmissionSnapshotV1;
|
|
21
|
-
readonly cost?: RunRecordCostV1;
|
|
22
|
-
readonly custody?: CustodyManifestV1;
|
|
23
|
-
}
|
|
24
|
-
export interface RunRecordEventsV1 {
|
|
25
|
-
/** Typed `channel: "event"` records in the SDK `events/events.jsonl` export. */
|
|
26
|
-
readonly typed: readonly AexEvent[];
|
|
27
|
-
}
|
|
28
|
-
export interface RunRecordV1 {
|
|
29
|
-
readonly schemaVersion: typeof RUN_RECORD_SCHEMA_VERSION;
|
|
30
|
-
readonly runId: string;
|
|
31
|
-
readonly metadata: RunRecordMetadataV1;
|
|
32
|
-
readonly events: RunRecordEventsV1;
|
|
33
|
-
readonly outputs: readonly Output[];
|
|
34
|
-
readonly manifest: RunRecordManifestV1;
|
|
35
|
-
}
|
|
36
|
-
export interface RunRecordNamespaceV1 {
|
|
37
|
-
readonly name: RunRecordArchiveNamespaceV1;
|
|
38
|
-
readonly prefix: `${RunRecordArchiveNamespaceV1}/`;
|
|
39
|
-
readonly status: RunRecordFileStatusV1;
|
|
40
|
-
readonly description: string;
|
|
41
|
-
}
|
|
42
|
-
export interface RunRecordArchiveFileV1 {
|
|
43
|
-
readonly namespace: RunRecordArchiveNamespaceV1;
|
|
44
|
-
readonly path: string;
|
|
45
|
-
readonly role: RunRecordArchiveFileRoleV1;
|
|
46
|
-
readonly status: RunRecordFileStatusV1;
|
|
47
|
-
readonly id?: string;
|
|
48
|
-
readonly filename?: string | null;
|
|
49
|
-
readonly sizeBytes?: number;
|
|
50
|
-
readonly contentType?: string;
|
|
51
|
-
readonly recordCount?: number;
|
|
52
|
-
}
|
|
53
|
-
export interface RunRecordArtifactSummaryV1 {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
readonly filename: string | null;
|
|
56
|
-
readonly sizeBytes?: number;
|
|
57
|
-
readonly contentType?: string;
|
|
58
|
-
}
|
|
59
|
-
export interface RunRecordDownloadErrorV1 {
|
|
60
|
-
readonly namespace: "outputs";
|
|
61
|
-
readonly id: string;
|
|
62
|
-
readonly filename: string | null;
|
|
63
|
-
readonly message: string;
|
|
64
|
-
}
|
|
65
|
-
export interface RunRecordManifestV1 {
|
|
66
|
-
readonly schemaVersion: typeof RUN_RECORD_MANIFEST_SCHEMA_VERSION;
|
|
67
|
-
readonly runRecordSchemaVersion: typeof RUN_RECORD_SCHEMA_VERSION;
|
|
68
|
-
readonly runId: string;
|
|
69
|
-
readonly namespaces: readonly RunRecordNamespaceV1[];
|
|
70
|
-
readonly files: readonly RunRecordArchiveFileV1[];
|
|
71
|
-
/**
|
|
72
|
-
* Compatibility aliases for existing consumers of `manifest.json`.
|
|
73
|
-
* Prefer `files[]` for new code because it carries namespace, role, and
|
|
74
|
-
* presence state for optional run-record members.
|
|
75
|
-
*/
|
|
76
|
-
readonly outputs: readonly RunRecordArtifactSummaryV1[];
|
|
77
|
-
readonly errors: readonly RunRecordDownloadErrorV1[];
|
|
78
|
-
}
|
|
79
|
-
export interface BuildRunRecordDownloadManifestV1Input {
|
|
80
|
-
readonly runId: string;
|
|
81
|
-
readonly outputs: readonly RunRecordArtifactSummaryV1[];
|
|
82
|
-
readonly errors?: readonly RunRecordDownloadErrorV1[];
|
|
83
|
-
readonly typedEventCount?: number;
|
|
84
|
-
readonly submission?: RunRecordFileManifestInputV1;
|
|
85
|
-
readonly cost?: RunRecordFileManifestInputV1;
|
|
86
|
-
readonly custody?: RunRecordFileManifestInputV1;
|
|
87
|
-
readonly coordinatorEventsManifest?: RunRecordFileManifestInputV1;
|
|
88
|
-
}
|
|
89
|
-
export interface RunRecordFileManifestInputV1 {
|
|
90
|
-
readonly status: RunRecordFileStatusV1;
|
|
91
|
-
readonly recordCount?: number;
|
|
92
|
-
}
|
|
93
|
-
export interface RunRecordArchiveEntryForRedactionV1 {
|
|
94
|
-
readonly path: string;
|
|
95
|
-
readonly bytes: Uint8Array;
|
|
96
|
-
readonly contentType?: string;
|
|
97
|
-
/**
|
|
98
|
-
* Customer-authored output bytes are intentionally outside the public-record
|
|
99
|
-
* redaction guarantee. Metadata, event exports, and manifests remain scanned.
|
|
100
|
-
*/
|
|
101
|
-
readonly customerContent?: boolean;
|
|
102
|
-
}
|
|
103
|
-
export interface RunRecordArchiveRedactionFindingV1 {
|
|
104
|
-
readonly entryPath: string;
|
|
105
|
-
readonly path: string;
|
|
106
|
-
readonly reason: CustodyRedactionFinding["reason"];
|
|
107
|
-
readonly valueLength?: number;
|
|
108
|
-
}
|
|
109
|
-
export declare class RunRecordArchiveRedactionError extends Error {
|
|
110
|
-
readonly code = "run_record_archive_not_public_safe";
|
|
111
|
-
readonly findings: readonly RunRecordArchiveRedactionFindingV1[];
|
|
112
|
-
constructor(findings: readonly RunRecordArchiveRedactionFindingV1[]);
|
|
113
|
-
}
|
|
114
|
-
export declare function buildRunRecordDownloadManifestV1(input: BuildRunRecordDownloadManifestV1Input): RunRecordManifestV1;
|
|
115
|
-
export declare function scanRunRecordArchiveEntriesV1(entries: readonly RunRecordArchiveEntryForRedactionV1[]): readonly RunRecordArchiveRedactionFindingV1[];
|
|
116
|
-
export declare function assertRunRecordArchivePublicSafeV1(entries: readonly RunRecordArchiveEntryForRedactionV1[]): void;
|