@aexhq/sdk 0.40.15 → 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 (132) 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/asset-upload-helper.d.ts +2 -2
  5. package/dist/_contracts/asset-upload-helper.js +2 -2
  6. package/dist/_contracts/connection-ticket.d.ts +5 -5
  7. package/dist/_contracts/connection-ticket.js +7 -7
  8. package/dist/_contracts/error-codes.d.ts +1 -1
  9. package/dist/_contracts/error-codes.js +4 -4
  10. package/dist/_contracts/error-factory.js +1 -1
  11. package/dist/_contracts/event-envelope.d.ts +41 -41
  12. package/dist/_contracts/event-envelope.js +49 -49
  13. package/dist/_contracts/event-stream-client.d.ts +9 -9
  14. package/dist/_contracts/event-stream-client.js +5 -5
  15. package/dist/_contracts/event-view.d.ts +6 -6
  16. package/dist/_contracts/event-view.js +12 -12
  17. package/dist/_contracts/http.js +1 -1
  18. package/dist/_contracts/index.d.ts +10 -10
  19. package/dist/_contracts/index.js +9 -9
  20. package/dist/_contracts/models.d.ts +17 -17
  21. package/dist/_contracts/models.js +14 -14
  22. package/dist/_contracts/operations.d.ts +79 -82
  23. package/dist/_contracts/operations.js +233 -243
  24. package/dist/_contracts/provider-support.d.ts +2 -2
  25. package/dist/_contracts/runner-event.d.ts +8 -8
  26. package/dist/_contracts/runner-event.js +9 -9
  27. package/dist/_contracts/runtime-manifest.d.ts +12 -12
  28. package/dist/_contracts/runtime-manifest.js +1 -1
  29. package/dist/_contracts/runtime-sizes.d.ts +12 -12
  30. package/dist/_contracts/runtime-sizes.js +18 -18
  31. package/dist/_contracts/runtime-types.d.ts +117 -117
  32. package/dist/_contracts/runtime-types.js +2 -2
  33. package/dist/_contracts/sdk-errors.d.ts +3 -3
  34. package/dist/_contracts/sdk-errors.js +4 -4
  35. package/dist/_contracts/sdk-secrets.js +10 -10
  36. package/dist/_contracts/session-artifacts.d.ts +151 -0
  37. package/dist/_contracts/session-artifacts.js +234 -0
  38. package/dist/_contracts/{run-config.d.ts → session-config.d.ts} +29 -29
  39. package/dist/_contracts/{run-config.js → session-config.js} +37 -37
  40. package/dist/_contracts/session-cost.d.ts +140 -0
  41. package/dist/_contracts/{run-cost.js → session-cost.js} +94 -94
  42. package/dist/_contracts/{run-custody.d.ts → session-custody.d.ts} +16 -16
  43. package/dist/_contracts/{run-custody.js → session-custody.js} +42 -42
  44. package/dist/_contracts/session-record.d.ts +112 -0
  45. package/dist/_contracts/{run-record.js → session-record.js} +23 -23
  46. package/dist/_contracts/session-retention.d.ts +209 -0
  47. package/dist/_contracts/{run-retention.js → session-retention.js} +116 -116
  48. package/dist/_contracts/{run-unit.d.ts → session-unit.d.ts} +38 -38
  49. package/dist/_contracts/{run-unit.js → session-unit.js} +33 -33
  50. package/dist/_contracts/side-effect-audit.d.ts +14 -14
  51. package/dist/_contracts/side-effect-audit.js +38 -38
  52. package/dist/_contracts/sse.d.ts +1 -1
  53. package/dist/_contracts/sse.js +0 -0
  54. package/dist/_contracts/stable.d.ts +1 -1
  55. package/dist/_contracts/stable.js +1 -1
  56. package/dist/_contracts/status.d.ts +18 -18
  57. package/dist/_contracts/status.js +19 -19
  58. package/dist/_contracts/submission.d.ts +101 -99
  59. package/dist/_contracts/submission.js +96 -96
  60. package/dist/_contracts/{run-trace.d.ts → turn-trace.d.ts} +1 -1
  61. package/dist/_contracts/webhook-verify.d.ts +1 -1
  62. package/dist/_contracts/webhook-verify.js +1 -1
  63. package/dist/agents-md.d.ts +4 -4
  64. package/dist/agents-md.js +5 -5
  65. package/dist/agents-md.js.map +1 -1
  66. package/dist/bundle.d.ts +1 -1
  67. package/dist/bundle.js +1 -1
  68. package/dist/bundle.js.map +1 -1
  69. package/dist/cli.mjs +580 -623
  70. package/dist/cli.mjs.sha256 +1 -1
  71. package/dist/client.d.ts +141 -155
  72. package/dist/client.js +236 -245
  73. package/dist/client.js.map +1 -1
  74. package/dist/fetch-archive.js +3 -3
  75. package/dist/file.d.ts +7 -7
  76. package/dist/file.js +8 -8
  77. package/dist/file.js.map +1 -1
  78. package/dist/index.d.ts +10 -10
  79. package/dist/index.js +8 -8
  80. package/dist/index.js.map +1 -1
  81. package/dist/mcp-server.d.ts +1 -1
  82. package/dist/retry.d.ts +1 -1
  83. package/dist/secret.d.ts +6 -6
  84. package/dist/secret.js +6 -6
  85. package/dist/secret.js.map +1 -1
  86. package/dist/skill.d.ts +2 -2
  87. package/dist/skill.js +3 -3
  88. package/dist/skill.js.map +1 -1
  89. package/dist/tool.js +2 -2
  90. package/dist/tool.js.map +1 -1
  91. package/dist/version.d.ts +1 -1
  92. package/dist/version.js +1 -1
  93. package/dist/version.js.map +1 -1
  94. package/docs/authentication.md +11 -11
  95. package/docs/billing.md +3 -3
  96. package/docs/cleanup.md +5 -5
  97. package/docs/concepts/agent-tools.md +5 -5
  98. package/docs/concepts/composition.md +3 -3
  99. package/docs/concepts/providers-and-runtimes.md +3 -3
  100. package/docs/concepts/{runs.md → sessions.md} +8 -8
  101. package/docs/concepts/subagents.md +16 -16
  102. package/docs/credentials.md +7 -7
  103. package/docs/defaults.md +14 -14
  104. package/docs/errors.md +10 -10
  105. package/docs/events.md +26 -26
  106. package/docs/files.md +267 -0
  107. package/docs/limits-and-quotas.md +35 -35
  108. package/docs/limits.md +6 -6
  109. package/docs/mcp.md +3 -3
  110. package/docs/networking.md +24 -24
  111. package/docs/provider-runtime-capabilities.md +1 -1
  112. package/docs/public-surface.json +6 -6
  113. package/docs/quickstart.md +13 -13
  114. package/docs/release.md +5 -5
  115. package/docs/retries.md +3 -3
  116. package/docs/secrets.md +16 -16
  117. package/docs/session-config.md +58 -0
  118. package/docs/{run-record.md → session-record.md} +16 -16
  119. package/docs/skills.md +9 -9
  120. package/docs/vision-skills.md +7 -7
  121. package/docs/webhooks.md +11 -11
  122. package/examples/feature-tour.ts +17 -17
  123. package/examples/spike-settle-latency.ts +11 -11
  124. package/package.json +1 -1
  125. package/dist/_contracts/run-artifacts.d.ts +0 -49
  126. package/dist/_contracts/run-artifacts.js +0 -102
  127. package/dist/_contracts/run-cost.d.ts +0 -140
  128. package/dist/_contracts/run-record.d.ts +0 -116
  129. package/dist/_contracts/run-retention.d.ts +0 -209
  130. package/docs/outputs.md +0 -267
  131. package/docs/run-config.md +0 -58
  132. /package/dist/_contracts/{run-trace.js → turn-trace.js} +0 -0
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Run-request config and composition refs for the public SDK/CLI surface.
2
+ * SessionRecord-request config and composition refs for the public SDK/CLI surface.
3
3
  *
4
4
  * Public composition concepts:
5
5
  *
6
6
  * - `SkillRef` is the PUBLIC wire-level reference to a workspace skill: just
7
- * `{ kind:"skill", name }`. The binding is BY NAME and mutable — the run
7
+ * `{ kind:"skill", name }`. The binding is BY NAME and mutable — the session
8
8
  * resolves the name to the workspace skill's current bytes at submit time.
9
9
  * It travels in `submission.skills` (NOT `submission.tools`).
10
10
  *
@@ -16,12 +16,12 @@
16
16
  *
17
17
  * - `McpServerRef` is the non-secret part of an MCP server declaration:
18
18
  * `name` and `url`. Bearer / cookie / per-request headers travel in
19
- * the run's vaulted `secrets.mcpServers` block keyed by the same
19
+ * the session's vaulted `secrets.mcpServers` block keyed by the same
20
20
  * `name`, and never enter the hashed submission payload or the
21
- * run snapshot.
21
+ * session snapshot.
22
22
  *
23
- * - `RunRequestConfig` is the credential-free set of run parameters that
24
- * can be persisted to disk (e.g. `aex run --config run.json`) or
23
+ * - `SessionRequestConfig` is the credential-free set of session parameters that
24
+ * can be persisted to disk (e.g. `aex start --config session.json`) or
25
25
  * returned from ordinary application helper functions. It excludes
26
26
  * `secrets`/`idempotencyKey`/`signal`; strings are already resolved at
27
27
  * the call site before submission.
@@ -35,7 +35,7 @@
35
35
  * Keep this as the public source of truth for the SDK/CLI composition
36
36
  * boundary.
37
37
  */
38
- import { parseRunModel } from "./models.js";
38
+ import { parseModelName } from "./models.js";
39
39
  // ---------------------------------------------------------------------------
40
40
  // Skill ID + name format
41
41
  // ---------------------------------------------------------------------------
@@ -336,7 +336,7 @@ export function hasSkillMdAtRoot(manifest) {
336
336
  return manifest.entries.some((entry) => entry.path === "SKILL.md");
337
337
  }
338
338
  // ---------------------------------------------------------------------------
339
- // McpServerRef (non-secret) + RunConfigMcpServer (with optional headers)
339
+ // McpServerRef (non-secret) + SessionConfigMcpServer (with optional headers)
340
340
  // ---------------------------------------------------------------------------
341
341
  /**
342
342
  * Remote MCP transports Aex accepts. Both are over HTTP — `http`
@@ -367,13 +367,13 @@ export function parseMcpServerRef(input, path) {
367
367
  }
368
368
  const record = input;
369
369
  rejectStdioMcpShape(record);
370
- // Headers belong on `RunConfigMcpServer`, not the non-secret wire ref;
370
+ // Headers belong on `SessionConfigMcpServer`, not the non-secret wire ref;
371
371
  // and the wire `submission.mcpServers` must NEVER contain headers. So
372
372
  // reject any field other than {name,url,transport} explicitly to make a
373
373
  // caller accidentally inlining `headers` into the non-secret half fail
374
374
  // loudly instead of silently dropping the field.
375
- // `parseRunConfigMcpServerRef` handles the headers case separately for
376
- // run-config entries.
375
+ // `parseSessionConfigMcpServerRef` handles the headers case separately for
376
+ // session-config entries.
377
377
  for (const key of Object.keys(record)) {
378
378
  if (key !== "name" && key !== "url" && key !== "transport") {
379
379
  throw new Error(`${path}.${key} is not an allowed field for McpServerRef; permitted: name, url, transport`);
@@ -394,7 +394,7 @@ export function parseMcpServerRef(input, path) {
394
394
  }
395
395
  // Auth belongs in `secrets.mcpServers[i].headers`, never in the URL
396
396
  // itself. A `https://user:pass@host` style URL would be persisted in
397
- // the non-secret run snapshot and hashed into the idempotency key —
397
+ // the non-secret session snapshot and hashed into the idempotency key —
398
398
  // both unacceptable for credential material.
399
399
  if (parsed.username !== "" || parsed.password !== "") {
400
400
  throw new Error(`${path}.url must not contain userinfo (username/password); use secrets.mcpServers[].headers for auth`);
@@ -556,11 +556,11 @@ function parseRemoteMcpTransport(input, field) {
556
556
  return input;
557
557
  }
558
558
  /**
559
- * Strict parser for run-config MCP server entries. Allows only the
560
- * `{name, url, headers?}` shape so config loaded from `--config run.json`
559
+ * Strict parser for session-config MCP server entries. Allows only the
560
+ * `{name, url, headers?}` shape so config loaded from `--config session.json`
561
561
  * cannot smuggle unrelated fields past the parser.
562
562
  */
563
- function parseRunConfigMcpServerRef(input, path) {
563
+ function parseSessionConfigMcpServerRef(input, path) {
564
564
  if (input === null || typeof input !== "object" || Array.isArray(input)) {
565
565
  throw new Error(`${path} must be an object`);
566
566
  }
@@ -568,7 +568,7 @@ function parseRunConfigMcpServerRef(input, path) {
568
568
  rejectStdioMcpShape(record);
569
569
  for (const key of Object.keys(record)) {
570
570
  if (key !== "name" && key !== "url" && key !== "headers" && key !== "transport") {
571
- throw new Error(`${path}.${key} is not an allowed field for RunConfigMcpServer; permitted: name, url, transport, headers`);
571
+ throw new Error(`${path}.${key} is not an allowed field for SessionConfigMcpServer; permitted: name, url, transport, headers`);
572
572
  }
573
573
  }
574
574
  // Reuse the {name,url,transport} validator by passing the stripped object.
@@ -593,17 +593,17 @@ function parseRunConfigMcpServerRef(input, path) {
593
593
  return { ...ref, headers };
594
594
  }
595
595
  // ---------------------------------------------------------------------------
596
- // Run request config parser (used by CLI to load `run.json`)
596
+ // SessionRecord request config parser (used by CLI to load `session.json`)
597
597
  // ---------------------------------------------------------------------------
598
598
  /**
599
- * Parse a run request config from JSON. Defensive — used by the host CLI to
600
- * load `--config run.json`. Throws with the JSON path that failed so
599
+ * Parse a session request config from JSON. Defensive — used by the host CLI to
600
+ * load `--config session.json`. Throws with the JSON path that failed so
601
601
  * a user can fix their file. Headers are preserved here and split out
602
602
  * later by the SDK normalisation step.
603
603
  */
604
- export function parseRunRequestConfig(input) {
604
+ export function parseSessionRequestConfig(input) {
605
605
  if (input === null || typeof input !== "object" || Array.isArray(input)) {
606
- throw new Error("run request config must be an object");
606
+ throw new Error("session request config must be an object");
607
607
  }
608
608
  const record = input;
609
609
  const allowed = new Set([
@@ -618,23 +618,23 @@ export function parseRunRequestConfig(input) {
618
618
  ]);
619
619
  for (const key of Object.keys(record)) {
620
620
  if (!allowed.has(key)) {
621
- throw new Error(`run request config contains unexpected field: ${key}`);
621
+ throw new Error(`session request config contains unexpected field: ${key}`);
622
622
  }
623
623
  }
624
- const model = parseRunModel(record.model, "run request config model");
624
+ const model = parseModelName(record.model, "session request config model");
625
625
  const system = record.system;
626
626
  if (system !== undefined && typeof system !== "string") {
627
- throw new Error("run request config system, when provided, must be a string");
627
+ throw new Error("session request config system, when provided, must be a string");
628
628
  }
629
- const prompt = parseRunRequestConfigPrompt(record.prompt);
630
- const mcpServers = parseRunRequestConfigMcpServers(record.mcpServers);
629
+ const prompt = parseSessionRequestConfigPrompt(record.prompt);
630
+ const mcpServers = parseSessionRequestConfigMcpServers(record.mcpServers);
631
631
  return {
632
632
  model,
633
633
  ...(system !== undefined ? { system } : {}),
634
634
  prompt,
635
635
  ...(mcpServers !== undefined ? { mcpServers } : {}),
636
636
  // environment / metadata: passed through as-is — the BFF revalidates
637
- // them via `parseRunSubmissionRequest`,
637
+ // them via `parseSessionSubmissionRequest`,
638
638
  // so duplicating the heavyweight parsers here would mean two sources
639
639
  // of truth. The CLI surfaces structural errors at submission time.
640
640
  ...(record.environment !== undefined
@@ -651,10 +651,10 @@ export function parseRunRequestConfig(input) {
651
651
  : {})
652
652
  };
653
653
  }
654
- function parseRunRequestConfigPrompt(value) {
654
+ function parseSessionRequestConfigPrompt(value) {
655
655
  if (typeof value === "string") {
656
656
  if (value.length === 0) {
657
- throw new Error("run request config prompt must be a non-empty string");
657
+ throw new Error("session request config prompt must be a non-empty string");
658
658
  }
659
659
  return value;
660
660
  }
@@ -663,35 +663,35 @@ function parseRunRequestConfigPrompt(value) {
663
663
  for (let i = 0; i < value.length; i++) {
664
664
  const item = value[i];
665
665
  if (typeof item !== "string" || item.length === 0) {
666
- throw new Error(`run request config prompt[${i}] must be a non-empty string`);
666
+ throw new Error(`session request config prompt[${i}] must be a non-empty string`);
667
667
  }
668
668
  arr.push(item);
669
669
  }
670
670
  if (arr.length === 0) {
671
- throw new Error("run request config prompt must be a non-empty string or array of strings");
671
+ throw new Error("session request config prompt must be a non-empty string or array of strings");
672
672
  }
673
673
  return arr;
674
674
  }
675
- throw new Error("run request config prompt must be a string or array of strings");
675
+ throw new Error("session request config prompt must be a string or array of strings");
676
676
  }
677
- function parseRunRequestConfigMcpServers(value) {
677
+ function parseSessionRequestConfigMcpServers(value) {
678
678
  if (value === undefined) {
679
679
  return undefined;
680
680
  }
681
681
  if (!Array.isArray(value)) {
682
- throw new Error("run request config mcpServers must be an array");
682
+ throw new Error("session request config mcpServers must be an array");
683
683
  }
684
684
  const seen = new Set();
685
685
  return value.map((item, index) => {
686
- const entry = parseRunConfigMcpServerRef(item, `run request config mcpServers[${index}]`);
686
+ const entry = parseSessionConfigMcpServerRef(item, `session request config mcpServers[${index}]`);
687
687
  if (seen.has(entry.name)) {
688
- throw new Error(`run request config mcpServers duplicate name: ${entry.name}`);
688
+ throw new Error(`session request config mcpServers duplicate name: ${entry.name}`);
689
689
  }
690
690
  seen.add(entry.name);
691
691
  return entry;
692
692
  });
693
693
  }
694
- export function normaliseRunRequestConfig(config) {
694
+ export function normaliseSessionRequestConfig(config) {
695
695
  const prompt = typeof config.prompt === "string" ? [config.prompt] : config.prompt;
696
696
  const mcpServers = [];
697
697
  const mcpServerSecrets = [];
@@ -0,0 +1,140 @@
1
+ import type { ProviderName } from "./submission.js";
2
+ export declare const SESSION_COST_TELEMETRY_SCHEMA_VERSION = 1;
3
+ export declare const SESSION_USAGE_SAMPLE_SCHEMA_VERSION = 1;
4
+ export declare const SESSION_COST_SUMMARY_STATUSES: readonly ["pending", "partial", "complete", "unavailable", "not_applicable"];
5
+ export type SessionCostSummaryStatus = (typeof SESSION_COST_SUMMARY_STATUSES)[number];
6
+ export declare const SESSION_USAGE_SAMPLE_UNITS: readonly ["token", "millisecond", "byte", "byte_millisecond", "count", "file", "credit_unit"];
7
+ export type SessionUsageSampleUnit = (typeof SESSION_USAGE_SAMPLE_UNITS)[number];
8
+ export declare const SESSION_USAGE_SAMPLE_SOURCE_TYPES: readonly ["coordinator-event", "session-event", "usage-ledger", "file-object", "proxy-call", "runtime-job", "provider-session", "storage-accrual", "manual-adjustment"];
9
+ export type SessionUsageSampleSourceType = (typeof SESSION_USAGE_SAMPLE_SOURCE_TYPES)[number];
10
+ export declare const SESSION_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.file_capture_ms", "runtime.cleanup_ms", "session.total_ms", "file.discovered_files", "file.captured_files", "file.failed_files", "file.captured_bytes", "retry.runtime_attempts", "retry.provider_poll", "retry.file_capture", "retry.file_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 SessionUsageSampleMetric = (typeof SESSION_USAGE_SAMPLE_METRICS)[number];
12
+ export interface SessionUsageSampleSource {
13
+ readonly type: SessionUsageSampleSourceType;
14
+ readonly id: string;
15
+ readonly observedAt?: string;
16
+ }
17
+ export interface SessionUsageSample {
18
+ readonly schemaVersion: typeof SESSION_USAGE_SAMPLE_SCHEMA_VERSION;
19
+ readonly sampleId?: string;
20
+ readonly sessionId?: string;
21
+ readonly metric: SessionUsageSampleMetric;
22
+ readonly unit: SessionUsageSampleUnit;
23
+ readonly quantity: number;
24
+ readonly source: SessionUsageSampleSource;
25
+ readonly provider?: ProviderName | string;
26
+ readonly model?: string;
27
+ readonly recordedAt?: string;
28
+ }
29
+ export type SessionUsageSampleInput = Omit<SessionUsageSample, "schemaVersion" | "unit"> & {
30
+ readonly unit?: SessionUsageSampleUnit;
31
+ };
32
+ export interface SessionCostSourceSummary {
33
+ readonly sampleCount: number;
34
+ readonly metrics?: readonly SessionUsageSampleMetric[];
35
+ readonly sourceTypes?: readonly SessionUsageSampleSourceType[];
36
+ readonly sourceSampleIds?: readonly string[];
37
+ }
38
+ export interface SessionCostDurations {
39
+ readonly queuedMs?: number;
40
+ readonly runtimeMs?: number;
41
+ readonly fileCaptureMs?: number;
42
+ readonly cleanupMs?: number;
43
+ readonly totalMs?: number;
44
+ }
45
+ export interface SessionCostFileTelemetry {
46
+ readonly discoveredFiles?: number;
47
+ readonly capturedFiles?: number;
48
+ readonly failedFiles?: number;
49
+ readonly capturedBytes?: number;
50
+ }
51
+ export interface SessionCostRetryTelemetry {
52
+ readonly runtimeAttempts?: number;
53
+ readonly providerPollRetries?: number;
54
+ readonly fileCaptureRetries?: number;
55
+ readonly fileUploadRetries?: number;
56
+ }
57
+ export interface SessionCostCaptureTelemetry {
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 SessionCostProviderUsage {
65
+ readonly provider: ProviderName | 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 SessionCostStorageTelemetry {
76
+ readonly storedBytes?: number;
77
+ readonly byteMilliseconds?: number;
78
+ }
79
+ export interface SessionCostProxyTelemetry {
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 SessionCostTelemetry.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 (session-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 SESSION_COST_BASIS_STATUSES: readonly ["estimated", "reconciled"];
96
+ export type SessionCostBasisStatus = (typeof SESSION_COST_BASIS_STATUSES)[number];
97
+ export interface SessionCostBasis {
98
+ readonly currency: "USD";
99
+ readonly status: SessionCostBasisStatus;
100
+ }
101
+ export interface SessionCostTelemetry {
102
+ readonly schemaVersion: typeof SESSION_COST_TELEMETRY_SCHEMA_VERSION;
103
+ readonly sessionId?: string;
104
+ readonly provider?: ProviderName | string;
105
+ readonly recordedAt?: string;
106
+ readonly status?: SessionCostSummaryStatus;
107
+ readonly sourceSummary?: SessionCostSourceSummary;
108
+ readonly durations?: SessionCostDurations;
109
+ readonly files?: SessionCostFileTelemetry;
110
+ readonly retries?: SessionCostRetryTelemetry;
111
+ readonly capture?: SessionCostCaptureTelemetry;
112
+ readonly providerUsage?: readonly SessionCostProviderUsage[];
113
+ readonly storage?: SessionCostStorageTelemetry;
114
+ readonly proxy?: SessionCostProxyTelemetry;
115
+ /**
116
+ * Customer-facing AEX cost of serving this session, 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 session-record public-safe archive scan. Absent when the session incurred
122
+ * no priced AEX usage.
123
+ */
124
+ readonly billedCostUsd?: number;
125
+ /** Currency + estimate/reconciled basis for {@link billedCostUsd}. */
126
+ readonly costBasis?: SessionCostBasis;
127
+ }
128
+ export type SessionCostTelemetryInput = Omit<SessionCostTelemetry, "schemaVersion">;
129
+ export interface SessionCostTelemetryFromUsageSamplesInput {
130
+ readonly sessionId?: string;
131
+ readonly provider?: ProviderName | string;
132
+ readonly recordedAt?: string;
133
+ readonly status?: SessionCostSummaryStatus;
134
+ readonly samples: readonly SessionUsageSampleInput[];
135
+ }
136
+ export declare function buildSessionUsageSample(input: SessionUsageSampleInput): SessionUsageSample;
137
+ export declare function buildSessionCostTelemetry(input: SessionCostTelemetryInput): SessionCostTelemetry;
138
+ export declare function buildSessionCostTelemetryFromUsageSamples(input: SessionCostTelemetryFromUsageSamplesInput): SessionCostTelemetry;
139
+ export declare function summarizeUsageSamples(samples: readonly SessionUsageSampleInput[]): SessionCostSourceSummary;
140
+ export declare function mergeSessionCostTelemetry(base: SessionCostTelemetry, next: SessionCostTelemetryInput): SessionCostTelemetry;