@aexhq/sdk 0.40.16 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +25 -25
  2. package/dist/_contracts/api-key.d.ts +6 -4
  3. package/dist/_contracts/api-key.js +20 -7
  4. package/dist/_contracts/connection-ticket.d.ts +5 -5
  5. package/dist/_contracts/connection-ticket.js +7 -7
  6. package/dist/_contracts/error-codes.d.ts +1 -1
  7. package/dist/_contracts/error-codes.js +4 -4
  8. package/dist/_contracts/error-factory.js +1 -1
  9. package/dist/_contracts/event-envelope.d.ts +41 -41
  10. package/dist/_contracts/event-envelope.js +49 -49
  11. package/dist/_contracts/event-stream-client.d.ts +9 -9
  12. package/dist/_contracts/event-stream-client.js +5 -5
  13. package/dist/_contracts/event-view.d.ts +6 -6
  14. package/dist/_contracts/event-view.js +12 -12
  15. package/dist/_contracts/http.js +1 -1
  16. package/dist/_contracts/index.d.ts +10 -10
  17. package/dist/_contracts/index.js +9 -9
  18. package/dist/_contracts/models.d.ts +17 -17
  19. package/dist/_contracts/models.js +14 -14
  20. package/dist/_contracts/operations.d.ts +79 -82
  21. package/dist/_contracts/operations.js +233 -243
  22. package/dist/_contracts/provider-support.d.ts +2 -2
  23. package/dist/_contracts/runner-event.d.ts +8 -8
  24. package/dist/_contracts/runner-event.js +9 -9
  25. package/dist/_contracts/runtime-manifest.d.ts +12 -12
  26. package/dist/_contracts/runtime-manifest.js +1 -1
  27. package/dist/_contracts/runtime-sizes.d.ts +12 -12
  28. package/dist/_contracts/runtime-sizes.js +18 -18
  29. package/dist/_contracts/runtime-types.d.ts +117 -117
  30. package/dist/_contracts/runtime-types.js +2 -2
  31. package/dist/_contracts/sdk-errors.d.ts +3 -3
  32. package/dist/_contracts/sdk-errors.js +4 -4
  33. package/dist/_contracts/sdk-secrets.js +10 -10
  34. package/dist/_contracts/session-artifacts.d.ts +151 -0
  35. package/dist/_contracts/session-artifacts.js +234 -0
  36. package/dist/_contracts/{run-config.d.ts → session-config.d.ts} +29 -29
  37. package/dist/_contracts/{run-config.js → session-config.js} +37 -37
  38. package/dist/_contracts/session-cost.d.ts +140 -0
  39. package/dist/_contracts/{run-cost.js → session-cost.js} +94 -94
  40. package/dist/_contracts/{run-custody.d.ts → session-custody.d.ts} +16 -16
  41. package/dist/_contracts/{run-custody.js → session-custody.js} +42 -42
  42. package/dist/_contracts/session-record.d.ts +112 -0
  43. package/dist/_contracts/{run-record.js → session-record.js} +23 -23
  44. package/dist/_contracts/session-retention.d.ts +209 -0
  45. package/dist/_contracts/{run-retention.js → session-retention.js} +116 -116
  46. package/dist/_contracts/{run-unit.d.ts → session-unit.d.ts} +38 -38
  47. package/dist/_contracts/{run-unit.js → session-unit.js} +33 -33
  48. package/dist/_contracts/side-effect-audit.d.ts +14 -14
  49. package/dist/_contracts/side-effect-audit.js +38 -38
  50. package/dist/_contracts/sse.d.ts +1 -1
  51. package/dist/_contracts/sse.js +0 -0
  52. package/dist/_contracts/stable.d.ts +1 -1
  53. package/dist/_contracts/stable.js +1 -1
  54. package/dist/_contracts/status.d.ts +18 -18
  55. package/dist/_contracts/status.js +19 -19
  56. package/dist/_contracts/submission.d.ts +101 -99
  57. package/dist/_contracts/submission.js +96 -96
  58. package/dist/_contracts/{run-trace.d.ts → turn-trace.d.ts} +1 -1
  59. package/dist/_contracts/webhook-verify.d.ts +1 -1
  60. package/dist/_contracts/webhook-verify.js +1 -1
  61. package/dist/agents-md.d.ts +4 -4
  62. package/dist/agents-md.js +5 -5
  63. package/dist/agents-md.js.map +1 -1
  64. package/dist/bundle.d.ts +1 -1
  65. package/dist/bundle.js +1 -1
  66. package/dist/bundle.js.map +1 -1
  67. package/dist/cli.mjs +578 -621
  68. package/dist/cli.mjs.sha256 +1 -1
  69. package/dist/client.d.ts +141 -155
  70. package/dist/client.js +236 -245
  71. package/dist/client.js.map +1 -1
  72. package/dist/fetch-archive.js +3 -3
  73. package/dist/file.d.ts +7 -7
  74. package/dist/file.js +8 -8
  75. package/dist/file.js.map +1 -1
  76. package/dist/index.d.ts +10 -10
  77. package/dist/index.js +8 -8
  78. package/dist/index.js.map +1 -1
  79. package/dist/mcp-server.d.ts +1 -1
  80. package/dist/retry.d.ts +1 -1
  81. package/dist/secret.d.ts +6 -6
  82. package/dist/secret.js +6 -6
  83. package/dist/secret.js.map +1 -1
  84. package/dist/skill.d.ts +2 -2
  85. package/dist/skill.js +3 -3
  86. package/dist/skill.js.map +1 -1
  87. package/dist/tool.js +2 -2
  88. package/dist/tool.js.map +1 -1
  89. package/dist/version.d.ts +1 -1
  90. package/dist/version.js +1 -1
  91. package/dist/version.js.map +1 -1
  92. package/docs/authentication.md +11 -11
  93. package/docs/billing.md +3 -3
  94. package/docs/cleanup.md +5 -5
  95. package/docs/concepts/agent-tools.md +5 -5
  96. package/docs/concepts/composition.md +3 -3
  97. package/docs/concepts/providers-and-runtimes.md +3 -3
  98. package/docs/concepts/{runs.md → sessions.md} +8 -8
  99. package/docs/concepts/subagents.md +16 -16
  100. package/docs/credentials.md +7 -7
  101. package/docs/defaults.md +14 -14
  102. package/docs/errors.md +10 -10
  103. package/docs/events.md +26 -26
  104. package/docs/files.md +267 -0
  105. package/docs/limits-and-quotas.md +35 -35
  106. package/docs/limits.md +6 -6
  107. package/docs/mcp.md +3 -3
  108. package/docs/networking.md +24 -24
  109. package/docs/provider-runtime-capabilities.md +1 -1
  110. package/docs/public-surface.json +6 -6
  111. package/docs/quickstart.md +13 -13
  112. package/docs/release.md +5 -5
  113. package/docs/retries.md +3 -3
  114. package/docs/secrets.md +16 -16
  115. package/docs/session-config.md +58 -0
  116. package/docs/{run-record.md → session-record.md} +16 -16
  117. package/docs/skills.md +9 -9
  118. package/docs/vision-skills.md +7 -7
  119. package/docs/webhooks.md +11 -11
  120. package/examples/feature-tour.ts +17 -17
  121. package/examples/spike-settle-latency.ts +11 -11
  122. package/package.json +1 -1
  123. package/dist/_contracts/run-artifacts.d.ts +0 -49
  124. package/dist/_contracts/run-artifacts.js +0 -102
  125. package/dist/_contracts/run-cost.d.ts +0 -140
  126. package/dist/_contracts/run-record.d.ts +0 -116
  127. package/dist/_contracts/run-retention.d.ts +0 -209
  128. package/docs/outputs.md +0 -267
  129. package/docs/run-config.md +0 -58
  130. /package/dist/_contracts/{run-trace.js → turn-trace.js} +0 -0
@@ -1,13 +1,13 @@
1
- import { isTerminalRunStatus } from "./status.js";
2
- export const RUN_RETENTION_SCHEMA_VERSION = 1;
3
- export const RUN_DELETION_MANIFEST_KIND = "aex.run_deletion_manifest.v1";
4
- export const RUN_DELETION_JOB_KIND = "aex.run_deletion_job.v1";
5
- export const RUN_DELETION_MANIFEST_CONTENT_TYPE = "application/json; charset=utf-8";
6
- export const RUN_RETENTION_REDACTION_SCANNER_VERSION = 1;
7
- export const RUN_DELETION_REASONS = ["manual_delete", "retention_gc"];
8
- export const RUN_DELETION_MANIFEST_MODES = ["dry_run", "final"];
9
- export const RUN_DELETION_CANDIDATE_STATUSES = ["selected", "blocked"];
10
- export const RUN_DELETION_BLOCKERS = [
1
+ import { isTerminalSessionControlStatus } from "./status.js";
2
+ export const SESSION_RETENTION_SCHEMA_VERSION = 1;
3
+ export const SESSION_DELETION_MANIFEST_KIND = "aex.session_deletion_manifest.v1";
4
+ export const SESSION_DELETION_JOB_KIND = "aex.session_deletion_job.v1";
5
+ export const SESSION_DELETION_MANIFEST_CONTENT_TYPE = "application/json; charset=utf-8";
6
+ export const SESSION_RETENTION_REDACTION_SCANNER_VERSION = 1;
7
+ export const SESSION_DELETION_REASONS = ["manual_delete", "retention_gc"];
8
+ export const SESSION_DELETION_MANIFEST_MODES = ["dry_run", "final"];
9
+ export const SESSION_DELETION_CANDIDATE_STATUSES = ["selected", "blocked"];
10
+ export const SESSION_DELETION_BLOCKERS = [
11
11
  "non_terminal",
12
12
  "retention_policy_disabled",
13
13
  "unexpired",
@@ -16,20 +16,20 @@ export const RUN_DELETION_BLOCKERS = [
16
16
  "unresolved_cleanup",
17
17
  "unresolved_custody"
18
18
  ];
19
- export const RUN_DELETION_COUNT_CLASSES = [
19
+ export const SESSION_DELETION_COUNT_CLASSES = [
20
20
  "object_store_objects",
21
- "outputs",
21
+ "files",
22
22
  "logs",
23
23
  "events",
24
24
  "assets",
25
25
  "db_event_rows",
26
- "db_output_rows",
26
+ "db_file_rows",
27
27
  "capture_failures",
28
28
  "storage_samples",
29
29
  "custody_manifests"
30
30
  ];
31
- export const RUN_DELETION_COUNT_STATUSES = ["counted", "not_counted", "partial", "failed"];
32
- export const RUN_DELETION_JOB_STATUSES = [
31
+ export const SESSION_DELETION_COUNT_STATUSES = ["counted", "not_counted", "partial", "failed"];
32
+ export const SESSION_DELETION_JOB_STATUSES = [
33
33
  "queued",
34
34
  "planning",
35
35
  "blocked",
@@ -39,14 +39,14 @@ export const RUN_DELETION_JOB_STATUSES = [
39
39
  "completed",
40
40
  "failed"
41
41
  ];
42
- export const RUN_DELETION_PROOF_STATUSES = [
42
+ export const SESSION_DELETION_PROOF_STATUSES = [
43
43
  "not_started",
44
44
  "running",
45
45
  "completed",
46
46
  "failed"
47
47
  ];
48
- export const RUN_DELETION_WRITE_STATUSES = ["not_written", "written", "write_failed"];
49
- export const RUN_RETENTION_EXCLUDED_VALUE_CLASSES = [
48
+ export const SESSION_DELETION_WRITE_STATUSES = ["not_written", "written", "write_failed"];
49
+ export const SESSION_RETENTION_EXCLUDED_VALUE_CLASSES = [
50
50
  "raw_paths",
51
51
  "object_keys",
52
52
  "filenames",
@@ -58,67 +58,67 @@ export const RUN_RETENTION_EXCLUDED_VALUE_CLASSES = [
58
58
  "resource_handles",
59
59
  "signed_urls"
60
60
  ];
61
- export class RunRetentionValidationError extends Error {
62
- code = "run_retention_contract_invalid";
61
+ export class SessionRetentionValidationError extends Error {
62
+ code = "session_retention_contract_invalid";
63
63
  constructor(message) {
64
64
  super(message);
65
- this.name = "RunRetentionValidationError";
65
+ this.name = "SessionRetentionValidationError";
66
66
  }
67
67
  }
68
- export class RunRetentionRedactionError extends Error {
69
- code = "run_retention_payload_not_public_safe";
68
+ export class SessionRetentionRedactionError extends Error {
69
+ code = "session_retention_payload_not_public_safe";
70
70
  findings;
71
71
  constructor(findings) {
72
- super(`run retention payload contains non-public data at ${formatFindingPaths(findings)}`);
73
- this.name = "RunRetentionRedactionError";
72
+ super(`session retention payload contains non-public data at ${formatFindingPaths(findings)}`);
73
+ this.name = "SessionRetentionRedactionError";
74
74
  this.findings = Object.freeze([...findings]);
75
75
  }
76
76
  }
77
- export class FakeRunDeletionManifestObjectStore {
77
+ export class FakeSessionDeletionManifestObjectStore {
78
78
  #objects = new Map();
79
- async putRunDeletionManifestObject(object) {
80
- assertPublicSafeRunRetentionPayload(object.manifest);
81
- this.#objects.set(object.runId, cloneJson(object.manifest));
79
+ async putSessionDeletionManifestObject(object) {
80
+ assertPublicSafeSessionRetentionPayload(object.manifest);
81
+ this.#objects.set(object.sessionId, cloneJson(object.manifest));
82
82
  }
83
- getByRunId(runId) {
84
- return this.get(runId);
83
+ getBySessionId(sessionId) {
84
+ return this.get(sessionId);
85
85
  }
86
- get(runId) {
87
- const object = this.#objects.get(runId);
86
+ get(sessionId) {
87
+ const object = this.#objects.get(sessionId);
88
88
  return object ? cloneJson(object) : undefined;
89
89
  }
90
- listRunIds() {
90
+ listSessionIds() {
91
91
  return Object.freeze([...this.#objects.keys()].sort());
92
92
  }
93
93
  }
94
- export function createRunDeletionManifestWriter(store) {
94
+ export function createSessionDeletionManifestWriter(store) {
95
95
  return {
96
- async writeRunDeletionManifest(input) {
97
- return writeRunDeletionManifest(store, input);
96
+ async writeSessionDeletionManifest(input) {
97
+ return writeSessionDeletionManifest(store, input);
98
98
  }
99
99
  };
100
100
  }
101
- export async function writeRunDeletionManifest(store, input) {
102
- const manifest = buildRunDeletionManifest(input);
103
- await store.putRunDeletionManifestObject({
104
- runId: manifest.run.runId,
105
- workspaceId: manifest.run.workspaceId,
106
- contentType: RUN_DELETION_MANIFEST_CONTENT_TYPE,
101
+ export async function writeSessionDeletionManifest(store, input) {
102
+ const manifest = buildSessionDeletionManifest(input);
103
+ await store.putSessionDeletionManifestObject({
104
+ sessionId: manifest.session.sessionId,
105
+ workspaceId: manifest.session.workspaceId,
106
+ contentType: SESSION_DELETION_MANIFEST_CONTENT_TYPE,
107
107
  manifest
108
108
  });
109
109
  return Object.freeze({
110
110
  status: "written",
111
- schemaVersion: RUN_RETENTION_SCHEMA_VERSION,
112
- runId: manifest.run.runId,
113
- workspaceId: manifest.run.workspaceId,
111
+ schemaVersion: SESSION_RETENTION_SCHEMA_VERSION,
112
+ sessionId: manifest.session.sessionId,
113
+ workspaceId: manifest.session.workspaceId,
114
114
  writtenAt: manifest.generatedAt,
115
115
  mode: manifest.mode
116
116
  });
117
117
  }
118
- export function buildRunRetentionPolicy(input = {}) {
118
+ export function buildSessionRetentionPolicy(input = {}) {
119
119
  if (input.automaticDeletion) {
120
120
  if (input.retentionDays === undefined) {
121
- throw new RunRetentionValidationError("automatic retention deletion requires an explicit positive retentionDays value");
121
+ throw new SessionRetentionValidationError("automatic retention deletion requires an explicit positive retentionDays value");
122
122
  }
123
123
  return Object.freeze({
124
124
  mode: "delete_after_days",
@@ -128,7 +128,7 @@ export function buildRunRetentionPolicy(input = {}) {
128
128
  });
129
129
  }
130
130
  if (input.retentionDays !== undefined) {
131
- throw new RunRetentionValidationError("retentionDays is not allowed when automatic retention deletion is disabled");
131
+ throw new SessionRetentionValidationError("retentionDays is not allowed when automatic retention deletion is disabled");
132
132
  }
133
133
  return Object.freeze({
134
134
  mode: "retain_indefinitely",
@@ -136,19 +136,19 @@ export function buildRunRetentionPolicy(input = {}) {
136
136
  automaticDeletion: "disabled"
137
137
  });
138
138
  }
139
- export function evaluateRunDeletionCandidate(input) {
139
+ export function evaluateSessionDeletionCandidate(input) {
140
140
  const now = assertTimestamp(input.now, "candidate.now");
141
- const run = normalizeCandidateRun(input.run);
141
+ const session = normalizeCandidateSession(input.session);
142
142
  const policy = normalizePolicy(input.policy);
143
143
  const blockers = [];
144
- addRunBlockers(blockers, run, now);
144
+ addSessionBlockers(blockers, session, now);
145
145
  let eligibleAt;
146
146
  if (input.reason === "retention_gc") {
147
147
  if (policy.mode !== "delete_after_days" || policy.retentionDays === undefined) {
148
148
  blockers.push(blocker("retention_policy_disabled", now));
149
149
  }
150
- else if (run.terminalAt) {
151
- eligibleAt = addDaysIso(run.terminalAt, policy.retentionDays);
150
+ else if (session.terminalAt) {
151
+ eligibleAt = addDaysIso(session.terminalAt, policy.retentionDays);
152
152
  if (Date.parse(now) < Date.parse(eligibleAt)) {
153
153
  blockers.push(blocker("unexpired", now));
154
154
  }
@@ -165,53 +165,53 @@ export function evaluateRunDeletionCandidate(input) {
165
165
  blockers: Object.freeze(blockers)
166
166
  });
167
167
  }
168
- export function buildRunDeletionManifest(input) {
168
+ export function buildSessionDeletionManifest(input) {
169
169
  const candidate = input.candidate ??
170
- evaluateRunDeletionCandidate({
171
- run: input.run,
170
+ evaluateSessionDeletionCandidate({
171
+ session: input.session,
172
172
  reason: input.request.reason,
173
173
  now: input.generatedAt,
174
174
  ...(input.policy ? { policy: input.policy } : {})
175
175
  });
176
176
  const normalizedCandidate = normalizeCandidate(candidate);
177
- const run = normalizeManifestRun(input.run, normalizedCandidate.eligibleAt);
178
- const summary = buildRunDeletionSummary(input.counts ?? [], normalizedCandidate);
177
+ const session = normalizeManifestSession(input.session, normalizedCandidate.eligibleAt);
178
+ const summary = buildSessionDeletionSummary(input.counts ?? [], normalizedCandidate);
179
179
  const manifest = Object.freeze({
180
- schemaVersion: RUN_RETENTION_SCHEMA_VERSION,
181
- kind: RUN_DELETION_MANIFEST_KIND,
180
+ schemaVersion: SESSION_RETENTION_SCHEMA_VERSION,
181
+ kind: SESSION_DELETION_MANIFEST_KIND,
182
182
  generatedAt: assertTimestamp(input.generatedAt, "manifest.generatedAt"),
183
183
  mode: input.mode,
184
- run,
184
+ session,
185
185
  request: normalizeRequest(input.request),
186
186
  candidate: normalizedCandidate,
187
187
  summary,
188
188
  redaction: Object.freeze({
189
189
  policy: "counts_status_timestamps_only",
190
- scannerVersion: RUN_RETENTION_REDACTION_SCANNER_VERSION,
191
- excludes: Object.freeze([...RUN_RETENTION_EXCLUDED_VALUE_CLASSES])
190
+ scannerVersion: SESSION_RETENTION_REDACTION_SCANNER_VERSION,
191
+ excludes: Object.freeze([...SESSION_RETENTION_EXCLUDED_VALUE_CLASSES])
192
192
  })
193
193
  });
194
- assertPublicSafeRunRetentionPayload(manifest);
194
+ assertPublicSafeSessionRetentionPayload(manifest);
195
195
  return manifest;
196
196
  }
197
- export function assertRunDeletionOrder(proof) {
197
+ export function assertSessionDeletionOrder(proof) {
198
198
  const manifest = normalizeManifestProof(proof.manifest);
199
199
  const purge = normalizePurgeProof(proof.purge);
200
200
  const purgeStarted = purge.status === "running" || purge.status === "completed" || purge.status === "failed";
201
201
  if (purgeStarted && manifest.status !== "written") {
202
- throw new RunRetentionValidationError("run deletion cannot purge assets before the deletion manifest is written");
202
+ throw new SessionRetentionValidationError("session deletion cannot purge assets before the deletion manifest is written");
203
203
  }
204
204
  if (purgeStarted && manifest.mode !== "final") {
205
- throw new RunRetentionValidationError("run deletion cannot purge assets from a dry-run deletion manifest");
205
+ throw new SessionRetentionValidationError("session deletion cannot purge assets from a dry-run deletion manifest");
206
206
  }
207
207
  }
208
- export function buildRunDeletionJob(input) {
209
- assertRunDeletionOrder(input.order);
208
+ export function buildSessionDeletionJob(input) {
209
+ assertSessionDeletionOrder(input.order);
210
210
  const job = Object.freeze({
211
- schemaVersion: RUN_RETENTION_SCHEMA_VERSION,
212
- kind: RUN_DELETION_JOB_KIND,
211
+ schemaVersion: SESSION_RETENTION_SCHEMA_VERSION,
212
+ kind: SESSION_DELETION_JOB_KIND,
213
213
  jobId: assertSafeIdentifier(input.jobId, "job.jobId"),
214
- runId: assertSafeIdentifier(input.runId, "job.runId"),
214
+ sessionId: assertSafeIdentifier(input.sessionId, "job.sessionId"),
215
215
  workspaceId: assertSafeIdentifier(input.workspaceId, "job.workspaceId"),
216
216
  reason: input.reason,
217
217
  mode: input.mode,
@@ -222,63 +222,63 @@ export function buildRunDeletionJob(input) {
222
222
  ...(input.candidate ? { candidate: normalizeCandidate(input.candidate) } : {}),
223
223
  ...(input.summary ? { summary: normalizeSummary(input.summary) } : {})
224
224
  });
225
- assertPublicSafeRunRetentionPayload(job);
225
+ assertPublicSafeSessionRetentionPayload(job);
226
226
  return job;
227
227
  }
228
- export function scanRunRetentionPayloadForSensitiveValues(input) {
228
+ export function scanSessionRetentionPayloadForSensitiveValues(input) {
229
229
  const findings = [];
230
230
  visitRetentionValue(input, "$", findings);
231
231
  return Object.freeze(findings);
232
232
  }
233
- export function assertPublicSafeRunRetentionPayload(input) {
234
- const findings = scanRunRetentionPayloadForSensitiveValues(input);
233
+ export function assertPublicSafeSessionRetentionPayload(input) {
234
+ const findings = scanSessionRetentionPayloadForSensitiveValues(input);
235
235
  if (findings.length > 0) {
236
- throw new RunRetentionRedactionError(findings);
236
+ throw new SessionRetentionRedactionError(findings);
237
237
  }
238
238
  }
239
239
  function normalizePolicy(input) {
240
240
  if (!input) {
241
- return buildRunRetentionPolicy();
241
+ return buildSessionRetentionPolicy();
242
242
  }
243
243
  if ("mode" in input) {
244
244
  if (input.mode === "delete_after_days") {
245
245
  if (input.retentionDays === undefined) {
246
- throw new RunRetentionValidationError("delete_after_days retention policy requires an explicit retentionDays value");
246
+ throw new SessionRetentionValidationError("delete_after_days retention policy requires an explicit retentionDays value");
247
247
  }
248
- return buildRunRetentionPolicy({
248
+ return buildSessionRetentionPolicy({
249
249
  automaticDeletion: true,
250
250
  retentionDays: input.retentionDays
251
251
  });
252
252
  }
253
253
  if (input.retentionDays !== undefined) {
254
- throw new RunRetentionValidationError("retain_indefinitely retention policy cannot include retentionDays");
254
+ throw new SessionRetentionValidationError("retain_indefinitely retention policy cannot include retentionDays");
255
255
  }
256
- return buildRunRetentionPolicy();
256
+ return buildSessionRetentionPolicy();
257
257
  }
258
- return buildRunRetentionPolicy(input);
258
+ return buildSessionRetentionPolicy(input);
259
259
  }
260
- function normalizeCandidateRun(input) {
260
+ function normalizeCandidateSession(input) {
261
261
  return Object.freeze({
262
- runId: assertSafeIdentifier(input.runId, "run.runId"),
263
- workspaceId: assertSafeIdentifier(input.workspaceId, "run.workspaceId"),
264
- status: assertSafeMetadataString(input.status, "run.status"),
265
- ...(input.createdAt ? { createdAt: assertTimestamp(input.createdAt, "run.createdAt") } : {}),
266
- ...(input.terminalAt ? { terminalAt: assertTimestamp(input.terminalAt, "run.terminalAt") } : {}),
262
+ sessionId: assertSafeIdentifier(input.sessionId, "session.sessionId"),
263
+ workspaceId: assertSafeIdentifier(input.workspaceId, "session.workspaceId"),
264
+ status: assertSafeMetadataString(input.status, "session.status"),
265
+ ...(input.createdAt ? { createdAt: assertTimestamp(input.createdAt, "session.createdAt") } : {}),
266
+ ...(input.terminalAt ? { terminalAt: assertTimestamp(input.terminalAt, "session.terminalAt") } : {}),
267
267
  ...(input.held !== undefined ? { held: input.held } : {}),
268
268
  ...(input.retentionExempt !== undefined ? { retentionExempt: input.retentionExempt } : {}),
269
269
  ...(input.unresolvedCleanup !== undefined ? { unresolvedCleanup: input.unresolvedCleanup } : {}),
270
270
  ...(input.unresolvedCustody !== undefined ? { unresolvedCustody: input.unresolvedCustody } : {})
271
271
  });
272
272
  }
273
- function normalizeManifestRun(input, eligibleAt) {
274
- const run = normalizeCandidateRun(input);
273
+ function normalizeManifestSession(input, eligibleAt) {
274
+ const session = normalizeCandidateSession(input);
275
275
  return Object.freeze({
276
- runId: run.runId,
277
- workspaceId: run.workspaceId,
278
- status: run.status,
279
- ...(run.createdAt ? { createdAt: run.createdAt } : {}),
280
- ...(run.terminalAt ? { terminalAt: run.terminalAt } : {}),
281
- ...(eligibleAt ? { eligibleAt: assertTimestamp(eligibleAt, "run.eligibleAt") } : {})
276
+ sessionId: session.sessionId,
277
+ workspaceId: session.workspaceId,
278
+ status: session.status,
279
+ ...(session.createdAt ? { createdAt: session.createdAt } : {}),
280
+ ...(session.terminalAt ? { terminalAt: session.terminalAt } : {}),
281
+ ...(eligibleAt ? { eligibleAt: assertTimestamp(eligibleAt, "session.eligibleAt") } : {})
282
282
  });
283
283
  }
284
284
  function normalizeRequest(input) {
@@ -311,7 +311,7 @@ function normalizeCount(input) {
311
311
  ...(input.errorClass ? { errorClass: assertSafeMetadataString(input.errorClass, "summary.count.errorClass") } : {})
312
312
  });
313
313
  }
314
- function buildRunDeletionSummary(input, candidate) {
314
+ function buildSessionDeletionSummary(input, candidate) {
315
315
  const counts = Object.freeze(input.map(normalizeCount));
316
316
  return Object.freeze({
317
317
  totalCount: counts.reduce((sum, item) => sum + item.count, 0),
@@ -353,20 +353,20 @@ function normalizePurgeProof(input) {
353
353
  : {})
354
354
  });
355
355
  }
356
- function addRunBlockers(blockers, run, observedAt) {
357
- if (!isTerminalStatusLike(run.status)) {
356
+ function addSessionBlockers(blockers, session, observedAt) {
357
+ if (!isTerminalStatusLike(session.status)) {
358
358
  blockers.push(blocker("non_terminal", observedAt));
359
359
  }
360
- if (run.held) {
360
+ if (session.held) {
361
361
  blockers.push(blocker("held", observedAt));
362
362
  }
363
- if (run.retentionExempt) {
363
+ if (session.retentionExempt) {
364
364
  blockers.push(blocker("retention_exempt", observedAt));
365
365
  }
366
- if (run.unresolvedCleanup) {
366
+ if (session.unresolvedCleanup) {
367
367
  blockers.push(blocker("unresolved_cleanup", observedAt));
368
368
  }
369
- if (run.unresolvedCustody) {
369
+ if (session.unresolvedCustody) {
370
370
  blockers.push(blocker("unresolved_custody", observedAt));
371
371
  }
372
372
  }
@@ -374,10 +374,10 @@ function blocker(code, observedAt) {
374
374
  return Object.freeze({ code, observedAt });
375
375
  }
376
376
  function isTerminalStatusLike(status) {
377
- return isTerminalRunStatus(status);
377
+ return isTerminalSessionControlStatus(status);
378
378
  }
379
379
  function addDaysIso(timestamp, days) {
380
- const start = Date.parse(assertTimestamp(timestamp, "candidate.run.terminalAt"));
380
+ const start = Date.parse(assertTimestamp(timestamp, "candidate.session.terminalAt"));
381
381
  const end = start + positiveInteger(days, "policy.retentionDays") * 24 * 60 * 60 * 1000;
382
382
  return new Date(end).toISOString();
383
383
  }
@@ -414,11 +414,11 @@ function scanStringValue(value, path, findings) {
414
414
  }
415
415
  const forbiddenStringPatterns = Object.freeze([
416
416
  { reason: "signed_url", regex: /[?&](?:X-Amz-Signature|X-Amz-Credential|X-Amz-Algorithm|AWSAccessKeyId)=/i },
417
- { reason: "object_store_key", regex: /(^|[\s"'`])(?:runs|assets)\/[^?<#\s"'`]+/i },
417
+ { reason: "object_store_key", regex: /(^|[\s"'`])(?:sessions|assets)\/[^?<#\s"'`]+/i },
418
418
  { reason: "vault_id", regex: /\b(?:vault|vlt|secret)[_:-][A-Za-z0-9][A-Za-z0-9_-]{7,}\b/i },
419
419
  {
420
420
  reason: "private_resource_handle",
421
- regex: /\b(?:machine|session|resource|handle|provider|asset)[_:-][A-Za-z0-9][A-Za-z0-9_-]{7,}\b/i
421
+ regex: /\b(?:machine|resource|handle|provider|asset)[_:-][A-Za-z0-9][A-Za-z0-9_-]{7,}\b/i
422
422
  },
423
423
  { reason: "hash_like_value", regex: /\b(?:sha256|hash)[:_-][A-Fa-f0-9]{16,}\b/ }
424
424
  ]);
@@ -428,38 +428,38 @@ function isForbiddenRetentionFieldName(key) {
428
428
  function assertSafeIdentifier(value, field) {
429
429
  assertNonEmptyString(value, field);
430
430
  if (!/^[A-Za-z0-9._:-]+$/.test(value)) {
431
- throw new RunRetentionValidationError(`run retention ${field} must be an opaque identifier without path separators`);
431
+ throw new SessionRetentionValidationError(`session retention ${field} must be an opaque identifier without path separators`);
432
432
  }
433
- assertPublicSafeRunRetentionPayload(value);
433
+ assertPublicSafeSessionRetentionPayload(value);
434
434
  return value;
435
435
  }
436
436
  function assertSafeMetadataString(value, field) {
437
437
  assertNonEmptyString(value, field);
438
- assertPublicSafeRunRetentionPayload(value);
438
+ assertPublicSafeSessionRetentionPayload(value);
439
439
  return value;
440
440
  }
441
441
  function assertNonEmptyString(value, field) {
442
442
  if (typeof value !== "string" || value.trim().length === 0) {
443
- throw new RunRetentionValidationError(`run retention ${field} must be a non-empty string`);
443
+ throw new SessionRetentionValidationError(`session retention ${field} must be a non-empty string`);
444
444
  }
445
445
  }
446
446
  function assertTimestamp(value, field) {
447
447
  assertSafeMetadataString(value, field);
448
448
  const ms = Date.parse(value);
449
449
  if (!Number.isFinite(ms)) {
450
- throw new RunRetentionValidationError(`run retention ${field} must be an ISO timestamp string`);
450
+ throw new SessionRetentionValidationError(`session retention ${field} must be an ISO timestamp string`);
451
451
  }
452
452
  return value;
453
453
  }
454
454
  function nonNegativeInteger(value, field) {
455
455
  if (!Number.isSafeInteger(value) || value < 0) {
456
- throw new RunRetentionValidationError(`run retention ${field} must be a non-negative safe integer`);
456
+ throw new SessionRetentionValidationError(`session retention ${field} must be a non-negative safe integer`);
457
457
  }
458
458
  return value;
459
459
  }
460
460
  function positiveInteger(value, field) {
461
461
  if (!Number.isSafeInteger(value) || value <= 0) {
462
- throw new RunRetentionValidationError(`run retention ${field} must be a positive safe integer`);
462
+ throw new SessionRetentionValidationError(`session retention ${field} must be a positive safe integer`);
463
463
  }
464
464
  return value;
465
465
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
- * RunUnit — the self-contained read shape of a run.
2
+ * SessionUnit — the self-contained read shape of a session.
3
3
  *
4
4
  * One canonical struct that captures every non-secret artifact persisted
5
- * for a single run: parsed submission inputs, status/lifecycle, attempts,
6
- * indexed events, raw-event Storage manifest, outputs, and capture failures.
5
+ * for a single session: parsed submission inputs, status/lifecycle, attempts,
6
+ * indexed events, raw-event Storage manifest, session files, and capture failures.
7
7
  *
8
- * Wire contract for `GET /api/runs/:runId`, the per-run archive's
9
- * `run.json`/`submission.json`/`caps.json`, and the SDK/CLI
10
- * `client.runs.get(runId)` return type.
8
+ * Wire contract for `GET /api/sessions/:sessionId`, the per-session archive's
9
+ * `session.json`/`submission.json`/`caps.json`, and the SDK/CLI
10
+ * `client.sessions.get(sessionId)` return type.
11
11
  *
12
12
  * Immutability: every field here is read-only. Edit endpoints do not
13
13
  * exist by design.
@@ -20,16 +20,16 @@
20
20
  import type { CleanupStatus } from "./status.js";
21
21
  import type { JsonValue, PlatformSubmission } from "./submission.js";
22
22
  /**
23
- * Parsed view of the legacy run snapshot jsonb. Stored shape is
23
+ * Parsed view of the legacy session snapshot jsonb. Stored shape is
24
24
  * `{kind:"submission", submission}` written by the hosted API's
25
- * server-side run creation for all runs.
25
+ * server-side session creation for all sessions.
26
26
  */
27
- export type RunUnitSubmission = RunUnitFlatSubmission;
28
- export interface RunUnitFlatSubmission {
27
+ export type SessionUnitSubmission = SessionUnitFlatSubmission;
28
+ export interface SessionUnitFlatSubmission {
29
29
  readonly kind: "submission";
30
30
  readonly submission: PlatformSubmission;
31
31
  }
32
- export interface RunUnitAttempt {
32
+ export interface SessionUnitAttempt {
33
33
  readonly id: string;
34
34
  readonly attemptNumber: number;
35
35
  readonly status: string;
@@ -46,7 +46,7 @@ export interface RunUnitAttempt {
46
46
  * each event are NOT here — they ride in `rawEventPages`. This struct
47
47
  * stays small so the detail response is bounded.
48
48
  */
49
- export interface RunUnitEvent {
49
+ export interface SessionUnitEvent {
50
50
  readonly id: string;
51
51
  readonly attemptId?: string;
52
52
  readonly providerEventId?: string;
@@ -58,21 +58,21 @@ export interface RunUnitEvent {
58
58
  }
59
59
  /**
60
60
  * Inline slice of events plus an optional cursor for the tail. Most
61
- * runs fit entirely inline; long-running ones overflow and the
62
- * consumer paginates via `GET /api/runs/:runId/events?cursor=...`.
61
+ * sessions fit entirely inline; long-running ones overflow and the
62
+ * consumer paginates via `GET /api/sessions/:sessionId/events?cursor=...`.
63
63
  */
64
- export interface RunUnitEventPage {
65
- readonly entries: readonly RunUnitEvent[];
64
+ export interface SessionUnitEventPage {
65
+ readonly entries: readonly SessionUnitEvent[];
66
66
  readonly totalCount: number;
67
67
  readonly truncated: boolean;
68
68
  readonly nextCursor?: string;
69
69
  }
70
70
  /**
71
- * One gzipped JSONL page of raw provider events captured for the run record.
71
+ * One gzipped JSONL page of raw provider events captured for the session record.
72
72
  * Bytes are downloaded through auth-gated routes or surfaced inside the
73
- * per-run archive zip. `artifactPath` is run-record relative.
73
+ * per-session archive zip. `artifactPath` is session-record relative.
74
74
  */
75
- export interface RunUnitRawEventPage {
75
+ export interface SessionUnitRawEventPage {
76
76
  readonly attempt: number;
77
77
  readonly page: number;
78
78
  readonly byteSize: number;
@@ -81,13 +81,13 @@ export interface RunUnitRawEventPage {
81
81
  readonly contentEncoding: "gzip";
82
82
  readonly createdAt: string;
83
83
  }
84
- export interface RunUnitOutput {
84
+ export interface SessionUnitFile {
85
85
  readonly id: string;
86
86
  readonly fileName: string;
87
87
  readonly byteSize: number;
88
88
  readonly contentType?: string;
89
89
  }
90
- export interface RunUnitOutputCaptureFailure {
90
+ export interface SessionUnitFileCaptureFailure {
91
91
  readonly id: string;
92
92
  readonly providerFileId?: string;
93
93
  readonly filename?: string;
@@ -96,7 +96,7 @@ export interface RunUnitOutputCaptureFailure {
96
96
  readonly errorMessage?: string;
97
97
  readonly createdAt: string;
98
98
  }
99
- export interface RunUnit {
99
+ export interface SessionUnit {
100
100
  readonly id: string;
101
101
  readonly workspaceId: string;
102
102
  readonly status: string;
@@ -108,16 +108,16 @@ export interface RunUnit {
108
108
  readonly terminalAt?: string;
109
109
  readonly deletedAt?: string;
110
110
  readonly attemptCount: number;
111
- readonly submission: RunUnitSubmission;
111
+ readonly submission: SessionUnitSubmission;
112
112
  readonly capsSnapshot?: Record<string, JsonValue>;
113
- readonly attempts: readonly RunUnitAttempt[];
114
- readonly events: RunUnitEventPage;
115
- readonly rawEventPages: readonly RunUnitRawEventPage[];
116
- readonly outputs: readonly RunUnitOutput[];
117
- readonly outputCaptureFailures: readonly RunUnitOutputCaptureFailure[];
118
- readonly costTelemetry?: import("./run-cost.js").RunCostTelemetry;
113
+ readonly attempts: readonly SessionUnitAttempt[];
114
+ readonly events: SessionUnitEventPage;
115
+ readonly rawEventPages: readonly SessionUnitRawEventPage[];
116
+ readonly sessionFiles: readonly SessionUnitFile[];
117
+ readonly fileCaptureFailures: readonly SessionUnitFileCaptureFailure[];
118
+ readonly costTelemetry?: import("./session-cost.js").SessionCostTelemetry;
119
119
  /**
120
- * Per-run, per-provider runtime manifest — derived from the validated
120
+ * Per-session, per-provider runtime manifest — derived from the validated
121
121
  * submission + the chosen provider (`buildRuntimeManifest`). Tells
122
122
  * SDK consumers where aex placed things in-container and what
123
123
  * env vars the agent will see. Undefined on responses from BFFs
@@ -126,7 +126,7 @@ export interface RunUnit {
126
126
  readonly runtimeManifest?: import("./runtime-manifest.js").RuntimeManifest;
127
127
  }
128
128
  /**
129
- * Parse a legacy run snapshot jsonb payload into the typed flat
129
+ * Parse a legacy session snapshot jsonb payload into the typed flat
130
130
  * submission. Never throws on minor unknown keys so we can
131
131
  * forward-compat with hosted API enrichment.
132
132
  *
@@ -135,16 +135,16 @@ export interface RunUnit {
135
135
  * must still render *something* for a buggy historical row rather than 500ing
136
136
  * the whole detail page.
137
137
  */
138
- export declare function parseRunUnitSubmission(input: unknown, fallbackModel?: unknown): RunUnitSubmission;
138
+ export declare function parseSessionUnitSubmission(input: unknown, fallbackModel?: unknown): SessionUnitSubmission;
139
139
  /**
140
- * Normalize a `GET /api/runs/:runId` payload into a RunUnit whose type contract
140
+ * Normalize a `GET /api/sessions/:sessionId` payload into a SessionUnit whose type contract
141
141
  * holds AT RUNTIME. The managed (AWS) plane returns a LEAN record (scalars +
142
- * costTelemetry only) and omits the aggregate collections; the RunUnit type
143
- * declares those non-optional, so a naive cast leaves `unit.outputs` /
142
+ * costTelemetry only) and omits the aggregate collections; the SessionUnit type
143
+ * declares those non-optional, so a naive cast leaves `unit.sessionFiles` /
144
144
  * `unit.events.totalCount` `undefined` and a typed consumer crashes on
145
145
  * `.map()` / `.totalCount` (pre-launch edge-sweep F25). We fill the aggregates
146
146
  * with their empty defaults so array/page access is always safe. NOTE: on the
147
- * managed plane these summaries are best-effort — read `outputs()` / `events()`
148
- * / `messages()` for the authoritative per-run data.
147
+ * managed plane these summaries are best-effort — read `files()` / `events()`
148
+ * / `messages()` for the authoritative per-session data.
149
149
  */
150
- export declare function normalizeRunUnit(raw: unknown): RunUnit;
150
+ export declare function normalizeSessionUnit(raw: unknown): SessionUnit;