@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.
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
- export const RUN_COST_TELEMETRY_SCHEMA_VERSION = 1;
2
- export const RUN_USAGE_SAMPLE_SCHEMA_VERSION = 1;
3
- export const RUN_COST_SUMMARY_STATUSES = [
1
+ export const SESSION_COST_TELEMETRY_SCHEMA_VERSION = 1;
2
+ export const SESSION_USAGE_SAMPLE_SCHEMA_VERSION = 1;
3
+ export const SESSION_COST_SUMMARY_STATUSES = [
4
4
  "pending",
5
5
  "partial",
6
6
  "complete",
7
7
  "unavailable",
8
8
  "not_applicable"
9
9
  ];
10
- export const RUN_USAGE_SAMPLE_UNITS = [
10
+ export const SESSION_USAGE_SAMPLE_UNITS = [
11
11
  "token",
12
12
  "millisecond",
13
13
  "byte",
@@ -16,18 +16,18 @@ export const RUN_USAGE_SAMPLE_UNITS = [
16
16
  "file",
17
17
  "credit_unit"
18
18
  ];
19
- export const RUN_USAGE_SAMPLE_SOURCE_TYPES = [
19
+ export const SESSION_USAGE_SAMPLE_SOURCE_TYPES = [
20
20
  "coordinator-event",
21
- "run-event",
21
+ "session-event",
22
22
  "usage-ledger",
23
- "output-object",
23
+ "file-object",
24
24
  "proxy-call",
25
25
  "runtime-job",
26
26
  "provider-session",
27
27
  "storage-accrual",
28
28
  "manual-adjustment"
29
29
  ];
30
- export const RUN_USAGE_SAMPLE_METRICS = [
30
+ export const SESSION_USAGE_SAMPLE_METRICS = [
31
31
  "provider.input_tokens",
32
32
  "provider.output_tokens",
33
33
  "provider.cache_read_input_tokens",
@@ -35,17 +35,17 @@ export const RUN_USAGE_SAMPLE_METRICS = [
35
35
  "provider.total_tokens",
36
36
  "runtime.queued_ms",
37
37
  "runtime.active_ms",
38
- "runtime.output_capture_ms",
38
+ "runtime.file_capture_ms",
39
39
  "runtime.cleanup_ms",
40
- "run.total_ms",
41
- "output.discovered_files",
42
- "output.captured_files",
43
- "output.failed_files",
44
- "output.captured_bytes",
40
+ "session.total_ms",
41
+ "file.discovered_files",
42
+ "file.captured_files",
43
+ "file.failed_files",
44
+ "file.captured_bytes",
45
45
  "retry.runtime_attempts",
46
46
  "retry.provider_poll",
47
- "retry.output_capture",
48
- "retry.output_upload",
47
+ "retry.file_capture",
48
+ "retry.file_upload",
49
49
  "capture.uploaded_files",
50
50
  "capture.failed_files",
51
51
  "capture.total_bytes",
@@ -57,7 +57,7 @@ export const RUN_USAGE_SAMPLE_METRICS = [
57
57
  "proxy.response_bytes",
58
58
  "proxy.duration_ms"
59
59
  ];
60
- const RUN_USAGE_SAMPLE_METRIC_UNITS = {
60
+ const SESSION_USAGE_SAMPLE_METRIC_UNITS = {
61
61
  "provider.input_tokens": "token",
62
62
  "provider.output_tokens": "token",
63
63
  "provider.cache_read_input_tokens": "token",
@@ -65,17 +65,17 @@ const RUN_USAGE_SAMPLE_METRIC_UNITS = {
65
65
  "provider.total_tokens": "token",
66
66
  "runtime.queued_ms": "millisecond",
67
67
  "runtime.active_ms": "millisecond",
68
- "runtime.output_capture_ms": "millisecond",
68
+ "runtime.file_capture_ms": "millisecond",
69
69
  "runtime.cleanup_ms": "millisecond",
70
- "run.total_ms": "millisecond",
71
- "output.discovered_files": "file",
72
- "output.captured_files": "file",
73
- "output.failed_files": "file",
74
- "output.captured_bytes": "byte",
70
+ "session.total_ms": "millisecond",
71
+ "file.discovered_files": "file",
72
+ "file.captured_files": "file",
73
+ "file.failed_files": "file",
74
+ "file.captured_bytes": "byte",
75
75
  "retry.runtime_attempts": "count",
76
76
  "retry.provider_poll": "count",
77
- "retry.output_capture": "count",
78
- "retry.output_upload": "count",
77
+ "retry.file_capture": "count",
78
+ "retry.file_upload": "count",
79
79
  "capture.uploaded_files": "file",
80
80
  "capture.failed_files": "file",
81
81
  "capture.total_bytes": "byte",
@@ -88,26 +88,26 @@ const RUN_USAGE_SAMPLE_METRIC_UNITS = {
88
88
  "proxy.duration_ms": "millisecond"
89
89
  };
90
90
  /**
91
- * The basis for a {@link RunCostTelemetry.billedCostUsd}: an honest marker of
91
+ * The basis for a {@link SessionCostTelemetry.billedCostUsd}: an honest marker of
92
92
  * whether the figure is a settle-time ESTIMATE or has been RECONCILED against
93
93
  * authoritative actuals. Deliberately carries NO rate-card version or unit
94
94
  * rates — the platform's public-safe convention treats `rateCard`/`margin` as
95
- * private tokens (run-cost.test.ts privateCostFieldPattern), so the version the
95
+ * private tokens (session-cost.test.ts privateCostFieldPattern), so the version the
96
96
  * figure was derived under stays internal (recorded only in the platform's
97
97
  * internal raw-usage export).
98
98
  */
99
- export const RUN_COST_BASIS_STATUSES = ["estimated", "reconciled"];
100
- export function buildRunUsageSample(input) {
99
+ export const SESSION_COST_BASIS_STATUSES = ["estimated", "reconciled"];
100
+ export function buildSessionUsageSample(input) {
101
101
  const metric = normalizeUsageSampleMetric(input.metric);
102
- const expectedUnit = RUN_USAGE_SAMPLE_METRIC_UNITS[metric];
102
+ const expectedUnit = SESSION_USAGE_SAMPLE_METRIC_UNITS[metric];
103
103
  const unit = input.unit ? normalizeUsageSampleUnit(input.unit) : expectedUnit;
104
104
  if (unit !== expectedUnit) {
105
- throw new Error(`run usage sample ${metric} must use ${expectedUnit} units`);
105
+ throw new Error(`session usage sample ${metric} must use ${expectedUnit} units`);
106
106
  }
107
107
  return Object.freeze({
108
- schemaVersion: RUN_USAGE_SAMPLE_SCHEMA_VERSION,
108
+ schemaVersion: SESSION_USAGE_SAMPLE_SCHEMA_VERSION,
109
109
  ...(input.sampleId ? { sampleId: nonEmptyString(input.sampleId, "sampleId") } : {}),
110
- ...(input.runId ? { runId: input.runId } : {}),
110
+ ...(input.sessionId ? { sessionId: input.sessionId } : {}),
111
111
  metric,
112
112
  unit,
113
113
  quantity: nonNegativeFinite(input.quantity, "quantity"),
@@ -117,16 +117,16 @@ export function buildRunUsageSample(input) {
117
117
  ...(input.recordedAt ? { recordedAt: input.recordedAt } : {})
118
118
  });
119
119
  }
120
- export function buildRunCostTelemetry(input) {
120
+ export function buildSessionCostTelemetry(input) {
121
121
  return freezeTelemetry({
122
- schemaVersion: RUN_COST_TELEMETRY_SCHEMA_VERSION,
123
- ...(input.runId ? { runId: input.runId } : {}),
122
+ schemaVersion: SESSION_COST_TELEMETRY_SCHEMA_VERSION,
123
+ ...(input.sessionId ? { sessionId: input.sessionId } : {}),
124
124
  ...(input.provider ? { provider: input.provider } : {}),
125
125
  ...(input.recordedAt ? { recordedAt: input.recordedAt } : {}),
126
126
  ...(input.status ? { status: normalizeSummaryStatus(input.status) } : {}),
127
127
  ...(input.sourceSummary ? { sourceSummary: normalizeSourceSummary(input.sourceSummary) } : {}),
128
128
  ...(input.durations ? { durations: normalizeDurations(input.durations) } : {}),
129
- ...(input.outputs ? { outputs: normalizeOutputs(input.outputs) } : {}),
129
+ ...(input.files ? { files: normalizeFiles(input.files) } : {}),
130
130
  ...(input.retries ? { retries: normalizeRetries(input.retries) } : {}),
131
131
  ...(input.capture ? { capture: normalizeCapture(input.capture) } : {}),
132
132
  ...(input.providerUsage ? { providerUsage: input.providerUsage.map(normalizeProviderUsage) } : {}),
@@ -136,13 +136,13 @@ export function buildRunCostTelemetry(input) {
136
136
  ...(input.costBasis ? { costBasis: normalizeCostBasis(input.costBasis) } : {})
137
137
  });
138
138
  }
139
- export function buildRunCostTelemetryFromUsageSamples(input) {
140
- const samples = input.samples.map(buildRunUsageSample);
139
+ export function buildSessionCostTelemetryFromUsageSamples(input) {
140
+ const samples = input.samples.map(buildSessionUsageSample);
141
141
  const telemetry = {
142
142
  sourceSummary: summarizeUsageSamples(samples)
143
143
  };
144
- if (input.runId)
145
- telemetry.runId = input.runId;
144
+ if (input.sessionId)
145
+ telemetry.sessionId = input.sessionId;
146
146
  if (input.provider)
147
147
  telemetry.provider = input.provider;
148
148
  if (input.recordedAt)
@@ -150,7 +150,7 @@ export function buildRunCostTelemetryFromUsageSamples(input) {
150
150
  if (input.status)
151
151
  telemetry.status = input.status;
152
152
  const durations = {};
153
- const outputs = {};
153
+ const files = {};
154
154
  const retries = {};
155
155
  const capture = {};
156
156
  const storage = {};
@@ -180,26 +180,26 @@ export function buildRunCostTelemetryFromUsageSamples(input) {
180
180
  case "runtime.active_ms":
181
181
  addDraftNumber(durations, "runtimeMs", sample.quantity);
182
182
  break;
183
- case "runtime.output_capture_ms":
184
- addDraftNumber(durations, "outputCaptureMs", sample.quantity);
183
+ case "runtime.file_capture_ms":
184
+ addDraftNumber(durations, "fileCaptureMs", sample.quantity);
185
185
  break;
186
186
  case "runtime.cleanup_ms":
187
187
  addDraftNumber(durations, "cleanupMs", sample.quantity);
188
188
  break;
189
- case "run.total_ms":
189
+ case "session.total_ms":
190
190
  addDraftNumber(durations, "totalMs", sample.quantity);
191
191
  break;
192
- case "output.discovered_files":
193
- addDraftNumber(outputs, "discoveredFiles", sample.quantity);
192
+ case "file.discovered_files":
193
+ addDraftNumber(files, "discoveredFiles", sample.quantity);
194
194
  break;
195
- case "output.captured_files":
196
- addDraftNumber(outputs, "capturedFiles", sample.quantity);
195
+ case "file.captured_files":
196
+ addDraftNumber(files, "capturedFiles", sample.quantity);
197
197
  break;
198
- case "output.failed_files":
199
- addDraftNumber(outputs, "failedFiles", sample.quantity);
198
+ case "file.failed_files":
199
+ addDraftNumber(files, "failedFiles", sample.quantity);
200
200
  break;
201
- case "output.captured_bytes":
202
- addDraftNumber(outputs, "capturedBytes", sample.quantity);
201
+ case "file.captured_bytes":
202
+ addDraftNumber(files, "capturedBytes", sample.quantity);
203
203
  break;
204
204
  case "retry.runtime_attempts":
205
205
  addDraftNumber(retries, "runtimeAttempts", sample.quantity);
@@ -207,11 +207,11 @@ export function buildRunCostTelemetryFromUsageSamples(input) {
207
207
  case "retry.provider_poll":
208
208
  addDraftNumber(retries, "providerPollRetries", sample.quantity);
209
209
  break;
210
- case "retry.output_capture":
211
- addDraftNumber(retries, "outputCaptureRetries", sample.quantity);
210
+ case "retry.file_capture":
211
+ addDraftNumber(retries, "fileCaptureRetries", sample.quantity);
212
212
  break;
213
- case "retry.output_upload":
214
- addDraftNumber(retries, "outputUploadRetries", sample.quantity);
213
+ case "retry.file_upload":
214
+ addDraftNumber(retries, "fileUploadRetries", sample.quantity);
215
215
  break;
216
216
  case "capture.uploaded_files":
217
217
  captureAttempted = true;
@@ -250,8 +250,8 @@ export function buildRunCostTelemetryFromUsageSamples(input) {
250
250
  }
251
251
  if (Object.keys(durations).length > 0)
252
252
  telemetry.durations = durations;
253
- if (Object.keys(outputs).length > 0)
254
- telemetry.outputs = outputs;
253
+ if (Object.keys(files).length > 0)
254
+ telemetry.files = files;
255
255
  if (Object.keys(retries).length > 0)
256
256
  telemetry.retries = retries;
257
257
  if (captureAttempted || Object.keys(capture).length > 0) {
@@ -264,10 +264,10 @@ export function buildRunCostTelemetryFromUsageSamples(input) {
264
264
  telemetry.storage = storage;
265
265
  if (Object.keys(proxy).length > 0)
266
266
  telemetry.proxy = proxy;
267
- return buildRunCostTelemetry(telemetry);
267
+ return buildSessionCostTelemetry(telemetry);
268
268
  }
269
269
  export function summarizeUsageSamples(samples) {
270
- const normalized = samples.map(buildRunUsageSample);
270
+ const normalized = samples.map(buildSessionUsageSample);
271
271
  const metrics = unique(normalized.map((sample) => sample.metric));
272
272
  const sourceTypes = unique(normalized.map((sample) => sample.source.type));
273
273
  const sourceSampleIds = unique(normalized.flatMap((sample) => (sample.sampleId ? [sample.sampleId] : [])));
@@ -278,16 +278,16 @@ export function summarizeUsageSamples(samples) {
278
278
  ...(sourceSampleIds.length > 0 ? { sourceSampleIds } : {})
279
279
  });
280
280
  }
281
- export function mergeRunCostTelemetry(base, next) {
282
- const patch = buildRunCostTelemetry(next);
281
+ export function mergeSessionCostTelemetry(base, next) {
282
+ const patch = buildSessionCostTelemetry(next);
283
283
  const merged = {};
284
- const runId = patch.runId ?? base.runId;
284
+ const sessionId = patch.sessionId ?? base.sessionId;
285
285
  const provider = patch.provider ?? base.provider;
286
286
  const recordedAt = patch.recordedAt ?? base.recordedAt;
287
287
  const status = patch.status ?? base.status;
288
288
  const sourceSummary = mergeSourceSummary(base.sourceSummary, patch.sourceSummary);
289
289
  const durations = sumDurations(base.durations, patch.durations);
290
- const outputs = sumOutputs(base.outputs, patch.outputs);
290
+ const files = sumFiles(base.files, patch.files);
291
291
  const retries = sumRetries(base.retries, patch.retries);
292
292
  const capture = mergeCapture(base.capture, patch.capture);
293
293
  const providerUsage = [...(base.providerUsage ?? []), ...(patch.providerUsage ?? [])];
@@ -298,8 +298,8 @@ export function mergeRunCostTelemetry(base, next) {
298
298
  // not additive metrics.
299
299
  const billedCostUsd = patch.billedCostUsd ?? base.billedCostUsd;
300
300
  const costBasis = patch.costBasis ?? base.costBasis;
301
- if (runId)
302
- merged.runId = runId;
301
+ if (sessionId)
302
+ merged.sessionId = sessionId;
303
303
  if (provider)
304
304
  merged.provider = provider;
305
305
  if (recordedAt)
@@ -310,8 +310,8 @@ export function mergeRunCostTelemetry(base, next) {
310
310
  merged.sourceSummary = sourceSummary;
311
311
  if (durations)
312
312
  merged.durations = durations;
313
- if (outputs)
314
- merged.outputs = outputs;
313
+ if (files)
314
+ merged.files = files;
315
315
  if (retries)
316
316
  merged.retries = retries;
317
317
  if (capture)
@@ -326,18 +326,18 @@ export function mergeRunCostTelemetry(base, next) {
326
326
  merged.billedCostUsd = billedCostUsd;
327
327
  if (costBasis)
328
328
  merged.costBasis = costBasis;
329
- return buildRunCostTelemetry(merged);
329
+ return buildSessionCostTelemetry(merged);
330
330
  }
331
331
  function normalizeDurations(input) {
332
332
  return freezeOptionalNumbers({
333
333
  queuedMs: input.queuedMs,
334
334
  runtimeMs: input.runtimeMs,
335
- outputCaptureMs: input.outputCaptureMs,
335
+ fileCaptureMs: input.fileCaptureMs,
336
336
  cleanupMs: input.cleanupMs,
337
337
  totalMs: input.totalMs
338
338
  });
339
339
  }
340
- function normalizeOutputs(input) {
340
+ function normalizeFiles(input) {
341
341
  return freezeOptionalNumbers({
342
342
  discoveredFiles: input.discoveredFiles,
343
343
  capturedFiles: input.capturedFiles,
@@ -349,8 +349,8 @@ function normalizeRetries(input) {
349
349
  return freezeOptionalNumbers({
350
350
  runtimeAttempts: input.runtimeAttempts,
351
351
  providerPollRetries: input.providerPollRetries,
352
- outputCaptureRetries: input.outputCaptureRetries,
353
- outputUploadRetries: input.outputUploadRetries
352
+ fileCaptureRetries: input.fileCaptureRetries,
353
+ fileUploadRetries: input.fileUploadRetries
354
354
  });
355
355
  }
356
356
  function normalizeCapture(input) {
@@ -408,7 +408,7 @@ function normalizeSourceSummary(input) {
408
408
  }
409
409
  function normalizeUsageSampleSource(input) {
410
410
  if (!input || typeof input !== "object") {
411
- throw new Error("run usage sample source must be an object");
411
+ throw new Error("session usage sample source must be an object");
412
412
  }
413
413
  return Object.freeze({
414
414
  type: normalizeUsageSampleSourceType(input.type),
@@ -417,45 +417,45 @@ function normalizeUsageSampleSource(input) {
417
417
  });
418
418
  }
419
419
  function normalizeUsageSampleMetric(input) {
420
- if (!isStringIn(input, RUN_USAGE_SAMPLE_METRICS)) {
421
- throw new Error(`run usage sample metric ${String(input)} is not supported`);
420
+ if (!isStringIn(input, SESSION_USAGE_SAMPLE_METRICS)) {
421
+ throw new Error(`session usage sample metric ${String(input)} is not supported`);
422
422
  }
423
423
  return input;
424
424
  }
425
425
  function normalizeUsageSampleUnit(input) {
426
- if (!isStringIn(input, RUN_USAGE_SAMPLE_UNITS)) {
427
- throw new Error(`run usage sample unit ${String(input)} is not supported`);
426
+ if (!isStringIn(input, SESSION_USAGE_SAMPLE_UNITS)) {
427
+ throw new Error(`session usage sample unit ${String(input)} is not supported`);
428
428
  }
429
429
  return input;
430
430
  }
431
431
  function normalizeUsageSampleSourceType(input) {
432
- if (!isStringIn(input, RUN_USAGE_SAMPLE_SOURCE_TYPES)) {
433
- throw new Error(`run usage sample source type ${String(input)} is not supported`);
432
+ if (!isStringIn(input, SESSION_USAGE_SAMPLE_SOURCE_TYPES)) {
433
+ throw new Error(`session usage sample source type ${String(input)} is not supported`);
434
434
  }
435
435
  return input;
436
436
  }
437
437
  function normalizeSummaryStatus(input) {
438
- if (!isStringIn(input, RUN_COST_SUMMARY_STATUSES)) {
439
- throw new Error(`run cost telemetry status ${String(input)} is not supported`);
438
+ if (!isStringIn(input, SESSION_COST_SUMMARY_STATUSES)) {
439
+ throw new Error(`session cost telemetry status ${String(input)} is not supported`);
440
440
  }
441
441
  return input;
442
442
  }
443
443
  function normalizeCostBasis(input) {
444
444
  if (!input || typeof input !== "object") {
445
- throw new Error("run cost basis must be an object");
445
+ throw new Error("session cost basis must be an object");
446
446
  }
447
447
  if (input.currency !== "USD") {
448
- throw new Error(`run cost basis currency ${String(input.currency)} is not supported`);
448
+ throw new Error(`session cost basis currency ${String(input.currency)} is not supported`);
449
449
  }
450
- if (!isStringIn(input.status, RUN_COST_BASIS_STATUSES)) {
451
- throw new Error(`run cost basis status ${String(input.status)} is not supported`);
450
+ if (!isStringIn(input.status, SESSION_COST_BASIS_STATUSES)) {
451
+ throw new Error(`session cost basis status ${String(input.status)} is not supported`);
452
452
  }
453
453
  return Object.freeze({ currency: "USD", status: input.status });
454
454
  }
455
455
  function addProviderUsage(usageByKey, input, sample, field) {
456
456
  const provider = sample.provider ?? input.provider;
457
457
  if (!provider) {
458
- throw new Error(`run usage sample ${sample.metric} requires a provider`);
458
+ throw new Error(`session usage sample ${sample.metric} requires a provider`);
459
459
  }
460
460
  const key = `${provider}\u0000${sample.model ?? ""}`;
461
461
  const existing = usageByKey.get(key);
@@ -465,7 +465,7 @@ function addProviderUsage(usageByKey, input, sample, field) {
465
465
  sourceSampleIds: []
466
466
  };
467
467
  usage[field] = (usage[field] ?? 0) + sample.quantity;
468
- if (!usage.sourceEventId && (sample.source.type === "coordinator-event" || sample.source.type === "run-event")) {
468
+ if (!usage.sourceEventId && (sample.source.type === "coordinator-event" || sample.source.type === "session-event")) {
469
469
  usage.sourceEventId = sample.source.id;
470
470
  }
471
471
  if (sample.sampleId) {
@@ -503,13 +503,13 @@ function freezeOptionalNumbers(input) {
503
503
  return Object.freeze(out);
504
504
  }
505
505
  function sumDurations(base, next) {
506
- return sumNumberFields(["queuedMs", "runtimeMs", "outputCaptureMs", "cleanupMs", "totalMs"], base, next);
506
+ return sumNumberFields(["queuedMs", "runtimeMs", "fileCaptureMs", "cleanupMs", "totalMs"], base, next);
507
507
  }
508
- function sumOutputs(base, next) {
508
+ function sumFiles(base, next) {
509
509
  return sumNumberFields(["discoveredFiles", "capturedFiles", "failedFiles", "capturedBytes"], base, next);
510
510
  }
511
511
  function sumRetries(base, next) {
512
- return sumNumberFields(["runtimeAttempts", "providerPollRetries", "outputCaptureRetries", "outputUploadRetries"], base, next);
512
+ return sumNumberFields(["runtimeAttempts", "providerPollRetries", "fileCaptureRetries", "fileUploadRetries"], base, next);
513
513
  }
514
514
  function sumStorage(base, next) {
515
515
  return sumNumberFields(["storedBytes", "byteMilliseconds"], base, next);
@@ -570,13 +570,13 @@ function unique(input) {
570
570
  }
571
571
  function nonEmptyString(value, field) {
572
572
  if (typeof value !== "string" || value.trim().length === 0) {
573
- throw new Error(`run cost telemetry ${field} must be a non-empty string`);
573
+ throw new Error(`session cost telemetry ${field} must be a non-empty string`);
574
574
  }
575
575
  return value;
576
576
  }
577
577
  function nonNegativeFinite(value, field) {
578
578
  if (!Number.isFinite(value) || value < 0) {
579
- throw new Error(`run cost telemetry ${field} must be a non-negative finite number`);
579
+ throw new Error(`session cost telemetry ${field} must be a non-negative finite number`);
580
580
  }
581
581
  return value;
582
582
  }
@@ -1,15 +1,15 @@
1
- import type { RunStatus } from "./status.js";
2
- import type { RunProvider } from "./submission.js";
1
+ import type { SessionControlStatus } from "./status.js";
2
+ import type { ProviderName } from "./submission.js";
3
3
  export declare const CUSTODY_MANIFEST_SCHEMA_VERSION = 1;
4
4
  export declare const CUSTODY_REDACTION_SCANNER_VERSION = 1;
5
5
  export declare const CUSTODY_MANIFEST_KIND = "aex.custody_manifest.v1";
6
6
  export declare const CUSTODY_MANIFEST_CONTENT_TYPE = "application/json; charset=utf-8";
7
- export declare const CUSTODY_MANIFEST_RUN_REL_PATH = "metadata/custody.json";
7
+ export declare const CUSTODY_MANIFEST_SESSION_REL_PATH = "metadata/custody.json";
8
8
  export declare const CUSTODY_SECRET_CLASSES: readonly ["provider_api_key", "mcp_credential", "proxy_endpoint_auth", "runner_bearer", "managed_system_credential"];
9
9
  export type CustodySecretClass = (typeof CUSTODY_SECRET_CLASSES)[number];
10
- export declare const CUSTODY_RESOURCE_CLASSES: readonly ["runtime_machine", "proxy_token", "execution_secret", "event_archive", "run_output", "run_log", "run_asset"];
10
+ export declare const CUSTODY_RESOURCE_CLASSES: readonly ["runtime_machine", "proxy_token", "execution_secret", "event_archive", "session_file", "session_log", "session_asset"];
11
11
  export type CustodyResourceClass = (typeof CUSTODY_RESOURCE_CLASSES)[number];
12
- export declare const CUSTODY_EXPOSURE_SURFACES: readonly ["aex_vault", "aex_kv", "host_env", "host_file", "dashboard_proxy", "api_provider_proxy", "api_mcp_proxy", "run_artifact_store", "coordinator_event_archive"];
12
+ export declare const CUSTODY_EXPOSURE_SURFACES: readonly ["aex_vault", "aex_kv", "host_env", "host_file", "dashboard_proxy", "api_provider_proxy", "api_mcp_proxy", "session_artifact_store", "coordinator_event_archive"];
13
13
  export type CustodyExposureSurface = (typeof CUSTODY_EXPOSURE_SURFACES)[number];
14
14
  export declare const CUSTODY_EXPOSURE_ACCESS_KINDS: readonly ["stored", "injected", "proxied", "replicated", "observed", "unknown"];
15
15
  export type CustodyExposureAccessKind = (typeof CUSTODY_EXPOSURE_ACCESS_KINDS)[number];
@@ -19,15 +19,15 @@ export declare const CUSTODY_DISPOSITION_STATUSES: readonly ["destroyed", "revok
19
19
  export type CustodyDispositionStatus = (typeof CUSTODY_DISPOSITION_STATUSES)[number];
20
20
  export declare const CUSTODY_CLEANUP_STATUSES: readonly ["succeeded", "partial", "failed", "retained", "pending"];
21
21
  export type CustodyCleanupStatus = (typeof CUSTODY_CLEANUP_STATUSES)[number];
22
- export declare const CUSTODY_EVIDENCE_SOURCES: readonly ["run_row", "runtime_manifest", "terminal_event", "cleanup_step", "output_capture", "proxy_audit", "provider_cleanup_summary"];
22
+ export declare const CUSTODY_EVIDENCE_SOURCES: readonly ["session_row", "runtime_manifest", "terminal_event", "cleanup_step", "file_capture", "proxy_audit", "provider_cleanup_summary"];
23
23
  export type CustodyEvidenceSource = (typeof CUSTODY_EVIDENCE_SOURCES)[number];
24
24
  export declare const CUSTODY_MANIFEST_EXCLUDED_VALUE_CLASSES: readonly ["raw_secret_values", "bearer_hashes", "provider_response_bodies", "signed_urls", "object_store_keys", "vault_ids", "private_resource_handles"];
25
25
  export type CustodyManifestExcludedValueClass = (typeof CUSTODY_MANIFEST_EXCLUDED_VALUE_CLASSES)[number];
26
- export interface CustodyManifestRunV1 {
27
- readonly runId: string;
26
+ export interface CustodyManifestSessionV1 {
27
+ readonly sessionId: string;
28
28
  readonly workspaceId: string;
29
- readonly provider: RunProvider | string;
30
- readonly terminalStatus: RunStatus | string;
29
+ readonly provider: ProviderName | string;
30
+ readonly terminalStatus: SessionControlStatus | string;
31
31
  readonly createdAt?: string;
32
32
  readonly terminalAt?: string;
33
33
  }
@@ -100,14 +100,14 @@ export interface CustodyManifestV1 {
100
100
  readonly kind: typeof CUSTODY_MANIFEST_KIND;
101
101
  readonly generatedAt: string;
102
102
  readonly finalizedAt?: string;
103
- readonly run: CustodyManifestRunV1;
103
+ readonly session: CustodyManifestSessionV1;
104
104
  readonly secrets: readonly CustodyManifestSecretClassV1[];
105
105
  readonly resources: readonly CustodyManifestResourceClassV1[];
106
106
  readonly cleanup: CustodyManifestCleanupV1;
107
107
  readonly summary: CustodyManifestSummaryV1;
108
108
  readonly redaction: CustodyManifestRedactionV1;
109
109
  }
110
- export type CustodyManifestRunInput = CustodyManifestRunV1;
110
+ export type CustodyManifestSessionInput = CustodyManifestSessionV1;
111
111
  export type CustodyManifestExposureInput = CustodyManifestExposureV1;
112
112
  export type CustodyManifestDispositionInput = CustodyManifestDispositionV1;
113
113
  export type CustodyManifestEvidenceSummaryInput = CustodyManifestEvidenceSummaryV1;
@@ -123,7 +123,7 @@ export interface CustodyManifestResourceClassInput extends Omit<CustodyManifestR
123
123
  export interface CustodyManifestInput {
124
124
  readonly generatedAt: string;
125
125
  readonly finalizedAt?: string;
126
- readonly run: CustodyManifestRunInput;
126
+ readonly session: CustodyManifestSessionInput;
127
127
  readonly secrets?: readonly CustodyManifestSecretClassInput[];
128
128
  readonly resources?: readonly CustodyManifestResourceClassInput[];
129
129
  readonly cleanup?: CustodyManifestCleanupInput;
@@ -139,7 +139,7 @@ export interface CustodyManifestObjectStore {
139
139
  export interface CustodyManifestWriteResult {
140
140
  readonly status: "written";
141
141
  readonly schemaVersion: typeof CUSTODY_MANIFEST_SCHEMA_VERSION;
142
- readonly runId: string;
142
+ readonly sessionId: string;
143
143
  readonly workspaceId: string;
144
144
  readonly key: string;
145
145
  readonly writtenAt: string;
@@ -161,11 +161,11 @@ export declare class CustodyManifestRedactionError extends Error {
161
161
  export declare class FakeCustodyManifestObjectStore implements CustodyManifestObjectStore {
162
162
  #private;
163
163
  putCustodyManifestObject(object: CustodyManifestWriteObject): Promise<void>;
164
- getByRunId(runId: string): CustodyManifestV1 | undefined;
164
+ getBySessionId(sessionId: string): CustodyManifestV1 | undefined;
165
165
  get(key: string): CustodyManifestV1 | undefined;
166
166
  listKeys(): readonly string[];
167
167
  }
168
- export declare function custodyManifestObjectKey(runId: string): string;
168
+ export declare function custodyManifestObjectKey(sessionId: string): string;
169
169
  export declare function createCustodyManifestWriter(store: CustodyManifestObjectStore): CustodyManifestWriter;
170
170
  export declare function writeCustodyManifest(store: CustodyManifestObjectStore, input: CustodyManifestInput): Promise<CustodyManifestWriteResult>;
171
171
  export declare function buildCustodyManifest(input: CustodyManifestInput): CustodyManifestV1;