@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
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Single source of truth for a session's artifact namespaces.
3
+ *
4
+ * Every session stores public files and internal diagnostics under its
5
+ * workspace-scoped session prefix:
6
+ *
7
+ * workspaces/<workspaceId>/sessions/<sessionId>/checkpoints/current.json
8
+ * workspaces/<workspaceId>/sessions/<sessionId>/checkpoints/<checkpointId>/workspace/index.json
9
+ * workspaces/<workspaceId>/sessions/<sessionId>/checkpoints/<checkpointId>/workspace/objects/<fileId>
10
+ * workspaces/<workspaceId>/sessions/<sessionId>/internal/logs/<rel>
11
+ *
12
+ * The latest complete checkpoint is the recovery source and the public files
13
+ * source. Diagnostics reach storage as workspace dotdirs (`.runtime-logs/...`,
14
+ * `.host-logs/...`, etc.); the stored path uses canonical log namespaces.
15
+ */
16
+ export declare const WORKSPACES_PREFIX = "workspaces";
17
+ export declare const SESSIONS_PREFIX = "sessions";
18
+ export declare const SESSION_CHECKPOINTS_PREFIX = "checkpoints";
19
+ export declare const SESSION_INTERNAL_PREFIX = "internal";
20
+ export declare const SESSION_INTERNAL_LOGS_PREFIX = "internal/logs";
21
+ export declare const S3_RETENTION_TAG_KEY = "aex-retention";
22
+ export declare const S3_RETENTION_TAG_VALUES: readonly ["session-file-current", "workspace-asset", "session-core", "checkpoint-pending", "checkpoint-superseded", "upload-staging", "internal-log", "internal-event", "internal-usage", "admin-archive"];
23
+ export type S3ObjectRetentionTagValue = (typeof S3_RETENTION_TAG_VALUES)[number];
24
+ /**
25
+ * Internal raw-usage export namespace (cost & usage metering). Lives under
26
+ * `internal/` so public downloads never include it by default. Holds
27
+ * `SessionUsageSample` ndjson — the durable system of record for raw usage, written
28
+ * by the coordinator event stream; the public-safe `session_cost` table holds the summary.
29
+ */
30
+ export declare const SESSION_INTERNAL_USAGE_PREFIX = "internal/usage";
31
+ /** Object-key prefix (trailing slash) every session-local object for a session lives under. */
32
+ export declare function runSessionPrefix(workspaceId: string, sessionId: string): string;
33
+ /** Object key for a session's raw-usage ndjson chunk (n = monotonic chunk index). */
34
+ export declare function runInternalUsageKey(workspaceId: string, sessionId: string, chunk: number): string;
35
+ /** Object-key prefix (trailing slash) for a session's current-file checkpoints. */
36
+ export declare function runCheckpointPrefix(workspaceId: string, sessionId: string): string;
37
+ /** Pointer to the latest complete checkpoint. Written last during checkpoint commit. */
38
+ export declare function runCheckpointCurrentKey(workspaceId: string, sessionId: string): string;
39
+ /** Optional compact list of available checkpoints for admin/debug views. */
40
+ export declare function runCheckpointIndexKey(workspaceId: string, sessionId: string): string;
41
+ export declare function runCheckpointManifestKey(workspaceId: string, sessionId: string, checkpointId: string): string;
42
+ export declare function runCheckpointWorkspaceIndexKey(workspaceId: string, sessionId: string, checkpointId: string): string;
43
+ export declare function runCheckpointWorkspaceObjectKey(workspaceId: string, sessionId: string, checkpointId: string, fileId: string): string;
44
+ export declare function runCheckpointBrainJournalKey(workspaceId: string, sessionId: string, checkpointId: string): string;
45
+ export declare function runCheckpointBrainStateKey(workspaceId: string, sessionId: string, checkpointId: string): string;
46
+ /** Object-key prefix (trailing slash) for operator-built archive zips for a session. */
47
+ export declare function runAdminArchivePrefix(workspaceId: string, sessionId: string): string;
48
+ /** Object-key prefix (trailing slash) for generated event archive files for a session. */
49
+ export declare function runEventArchivePrefix(workspaceId: string, sessionId: string): string;
50
+ /**
51
+ * Relative-path prefixes that mark a stored artifact as a platform diagnostic
52
+ * rather than a session deliverable. Dotted forms are upload-time paths.
53
+ */
54
+ export declare const SESSION_LOG_REL_PREFIXES: readonly [".runtime-logs/", ".host-logs/", ".provider-proxy/", ".control-plane/", ".anthropic-debug/", "runtime/", "host/", "provider-proxy/", "control-plane/", "anthropic-debug/"];
55
+ /** True when a workspace-relative artifact path belongs to the internal logs namespace. */
56
+ export declare function isSessionLogRelPath(rel: string): boolean;
57
+ /**
58
+ * The artifact's path relative to its namespace prefix as stored. Diagnostics
59
+ * are canonicalized (`.runtime-logs/x` -> `runtime/x`).
60
+ */
61
+ export declare function sessionArtifactRel(rel: string): string;
62
+ /**
63
+ * Storage key for a session artifact uploaded with relative path `rel`, routing
64
+ * diagnostics into `internal/logs/`. Workspace files are stored by checkpoint
65
+ * helpers, not by this function.
66
+ */
67
+ export declare function sessionInternalArtifactKey(workspaceId: string, sessionId: string, rel: string): string;
68
+ /**
69
+ * Opaque, non-reversible file id. Derived as SHA-256 hex of
70
+ * `sessionId:relPath` so a caller cannot construct an id by guessing a filename.
71
+ * It is the single id scheme for session files: the checkpoint index records it,
72
+ * the list route emits it, the download/link routes resolve it back to a path
73
+ * from the latest checkpoint index, and the object key uses it directly. Hex is
74
+ * URL-safe. WebCrypto, no new dep.
75
+ */
76
+ export declare function opaqueSessionFileId(sessionId: string, relPath: string): Promise<string>;
77
+ export interface SessionCheckpointCurrent {
78
+ readonly v: 1;
79
+ readonly workspaceId: string;
80
+ readonly sessionId: string;
81
+ readonly checkpointId: string;
82
+ readonly manifestKey: string;
83
+ readonly committedAt: string;
84
+ readonly throughSeq: number;
85
+ }
86
+ export interface SessionCheckpointIndex {
87
+ readonly v: 1;
88
+ readonly workspaceId: string;
89
+ readonly sessionId: string;
90
+ readonly currentCheckpointId: string;
91
+ readonly checkpoints: readonly SessionCheckpointIndexEntry[];
92
+ }
93
+ export interface SessionCheckpointIndexEntry {
94
+ readonly checkpointId: string;
95
+ readonly manifestKey: string;
96
+ readonly committedAt: string;
97
+ readonly throughSeq: number;
98
+ readonly fileCount: number;
99
+ readonly totalBytes: number;
100
+ }
101
+ export interface SessionCheckpointManifest {
102
+ readonly v: 1;
103
+ readonly workspaceId: string;
104
+ readonly sessionId: string;
105
+ readonly checkpointId: string;
106
+ readonly status: "complete";
107
+ readonly createdAt: string;
108
+ readonly committedAt: string;
109
+ readonly throughSeq: number;
110
+ readonly workspace: {
111
+ readonly indexKey: string;
112
+ readonly fileCount: number;
113
+ readonly totalBytes: number;
114
+ };
115
+ readonly brain?: {
116
+ readonly journalKey?: string;
117
+ readonly stateKey?: string;
118
+ };
119
+ }
120
+ export interface SessionWorkspaceFile {
121
+ readonly fileId: string;
122
+ readonly path: string;
123
+ readonly sizeBytes: number;
124
+ readonly contentType: string;
125
+ readonly objectKey: string;
126
+ readonly sha256?: string;
127
+ readonly createdAt: string;
128
+ }
129
+ export interface SessionCheckpointWorkspaceIndex {
130
+ readonly v: 1;
131
+ readonly workspaceId: string;
132
+ readonly sessionId: string;
133
+ readonly checkpointId: string;
134
+ readonly fileCount: number;
135
+ readonly totalBytes: number;
136
+ readonly files: readonly SessionWorkspaceFile[];
137
+ }
138
+ /**
139
+ * Storage key for a session's snapshotted asset, addressed by its content hash.
140
+ * This is used only for pre-checkpoint reusable workspace assets. Session boot
141
+ * should materialize those assets into an initial checkpoint before execution.
142
+ */
143
+ export declare function workspaceAssetKey(workspaceId: string, hash: string): string;
144
+ /**
145
+ * Retention class for an S3 key. Writers set this as the `aex-retention` object
146
+ * tag so bucket lifecycle rules can apply per logical namespace even though the
147
+ * useful category sits after dynamic workspace/session ids.
148
+ */
149
+ export declare function s3ObjectRetentionTagValue(key: string): S3ObjectRetentionTagValue | undefined;
150
+ /** S3 PutObject/CreateMultipartUpload/Upload `Tagging` header value for a key. */
151
+ export declare function s3ObjectRetentionTaggingHeader(key: string): string | undefined;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Single source of truth for a session's artifact namespaces.
3
+ *
4
+ * Every session stores public files and internal diagnostics under its
5
+ * workspace-scoped session prefix:
6
+ *
7
+ * workspaces/<workspaceId>/sessions/<sessionId>/checkpoints/current.json
8
+ * workspaces/<workspaceId>/sessions/<sessionId>/checkpoints/<checkpointId>/workspace/index.json
9
+ * workspaces/<workspaceId>/sessions/<sessionId>/checkpoints/<checkpointId>/workspace/objects/<fileId>
10
+ * workspaces/<workspaceId>/sessions/<sessionId>/internal/logs/<rel>
11
+ *
12
+ * The latest complete checkpoint is the recovery source and the public files
13
+ * source. Diagnostics reach storage as workspace dotdirs (`.runtime-logs/...`,
14
+ * `.host-logs/...`, etc.); the stored path uses canonical log namespaces.
15
+ */
16
+ export const WORKSPACES_PREFIX = "workspaces";
17
+ export const SESSIONS_PREFIX = "sessions";
18
+ export const SESSION_CHECKPOINTS_PREFIX = "checkpoints";
19
+ export const SESSION_INTERNAL_PREFIX = "internal";
20
+ export const SESSION_INTERNAL_LOGS_PREFIX = `${SESSION_INTERNAL_PREFIX}/logs`;
21
+ export const S3_RETENTION_TAG_KEY = "aex-retention";
22
+ export const S3_RETENTION_TAG_VALUES = [
23
+ "session-file-current",
24
+ "workspace-asset",
25
+ "session-core",
26
+ "checkpoint-pending",
27
+ "checkpoint-superseded",
28
+ "upload-staging",
29
+ "internal-log",
30
+ "internal-event",
31
+ "internal-usage",
32
+ "admin-archive"
33
+ ];
34
+ /**
35
+ * Internal raw-usage export namespace (cost & usage metering). Lives under
36
+ * `internal/` so public downloads never include it by default. Holds
37
+ * `SessionUsageSample` ndjson — the durable system of record for raw usage, written
38
+ * by the coordinator event stream; the public-safe `session_cost` table holds the summary.
39
+ */
40
+ export const SESSION_INTERNAL_USAGE_PREFIX = `${SESSION_INTERNAL_PREFIX}/usage`;
41
+ /** Object-key prefix (trailing slash) every session-local object for a session lives under. */
42
+ export function runSessionPrefix(workspaceId, sessionId) {
43
+ return `${WORKSPACES_PREFIX}/${workspaceId}/${SESSIONS_PREFIX}/${sessionId}/`;
44
+ }
45
+ /** Object key for a session's raw-usage ndjson chunk (n = monotonic chunk index). */
46
+ export function runInternalUsageKey(workspaceId, sessionId, chunk) {
47
+ return `${runSessionPrefix(workspaceId, sessionId)}${SESSION_INTERNAL_USAGE_PREFIX}/${chunk}.ndjson`;
48
+ }
49
+ /** Object-key prefix (trailing slash) for a session's current-file checkpoints. */
50
+ export function runCheckpointPrefix(workspaceId, sessionId) {
51
+ return `${runSessionPrefix(workspaceId, sessionId)}${SESSION_CHECKPOINTS_PREFIX}/`;
52
+ }
53
+ /** Pointer to the latest complete checkpoint. Written last during checkpoint commit. */
54
+ export function runCheckpointCurrentKey(workspaceId, sessionId) {
55
+ return `${runCheckpointPrefix(workspaceId, sessionId)}current.json`;
56
+ }
57
+ /** Optional compact list of available checkpoints for admin/debug views. */
58
+ export function runCheckpointIndexKey(workspaceId, sessionId) {
59
+ return `${runCheckpointPrefix(workspaceId, sessionId)}index.json`;
60
+ }
61
+ export function runCheckpointManifestKey(workspaceId, sessionId, checkpointId) {
62
+ return `${runCheckpointPrefix(workspaceId, sessionId)}${checkpointId}/manifest.json`;
63
+ }
64
+ export function runCheckpointWorkspaceIndexKey(workspaceId, sessionId, checkpointId) {
65
+ return `${runCheckpointPrefix(workspaceId, sessionId)}${checkpointId}/workspace/index.json`;
66
+ }
67
+ export function runCheckpointWorkspaceObjectKey(workspaceId, sessionId, checkpointId, fileId) {
68
+ return `${runCheckpointPrefix(workspaceId, sessionId)}${checkpointId}/workspace/objects/${fileId}`;
69
+ }
70
+ export function runCheckpointBrainJournalKey(workspaceId, sessionId, checkpointId) {
71
+ return `${runCheckpointPrefix(workspaceId, sessionId)}${checkpointId}/brain/journal.jsonl`;
72
+ }
73
+ export function runCheckpointBrainStateKey(workspaceId, sessionId, checkpointId) {
74
+ return `${runCheckpointPrefix(workspaceId, sessionId)}${checkpointId}/brain/state.json`;
75
+ }
76
+ /** Object-key prefix (trailing slash) for operator-built archive zips for a session. */
77
+ export function runAdminArchivePrefix(workspaceId, sessionId) {
78
+ return `${runSessionPrefix(workspaceId, sessionId)}${SESSION_INTERNAL_PREFIX}/admin-archives/`;
79
+ }
80
+ /** Object-key prefix (trailing slash) for generated event archive files for a session. */
81
+ export function runEventArchivePrefix(workspaceId, sessionId) {
82
+ return `${runSessionPrefix(workspaceId, sessionId)}${SESSION_INTERNAL_PREFIX}/events/`;
83
+ }
84
+ /**
85
+ * Relative-path prefixes that mark a stored artifact as a platform diagnostic
86
+ * rather than a session deliverable. Dotted forms are upload-time paths.
87
+ */
88
+ export const SESSION_LOG_REL_PREFIXES = [
89
+ ".runtime-logs/",
90
+ ".host-logs/",
91
+ ".provider-proxy/",
92
+ ".control-plane/",
93
+ ".anthropic-debug/",
94
+ "runtime/",
95
+ "host/",
96
+ "provider-proxy/",
97
+ "control-plane/",
98
+ "anthropic-debug/"
99
+ ];
100
+ /** True when a workspace-relative artifact path belongs to the internal logs namespace. */
101
+ export function isSessionLogRelPath(rel) {
102
+ return SESSION_LOG_REL_PREFIXES.some((prefix) => matchesRelPrefix(rel, prefix));
103
+ }
104
+ /**
105
+ * The artifact's path relative to its namespace prefix as stored. Diagnostics
106
+ * are canonicalized (`.runtime-logs/x` -> `runtime/x`).
107
+ */
108
+ export function sessionArtifactRel(rel) {
109
+ if (rel.startsWith(".runtime-logs/"))
110
+ return `runtime/${rel.slice(".runtime-logs/".length)}`;
111
+ if (rel.startsWith("runtime/"))
112
+ return rel;
113
+ if (rel.startsWith(".host-logs/"))
114
+ return `host/${rel.slice(".host-logs/".length)}`;
115
+ if (rel.startsWith("host/"))
116
+ return rel;
117
+ if (rel.startsWith(".provider-proxy/"))
118
+ return `provider-proxy/${rel.slice(".provider-proxy/".length)}`;
119
+ if (rel.startsWith("provider-proxy/"))
120
+ return rel;
121
+ if (rel.startsWith(".control-plane/"))
122
+ return `control-plane/${rel.slice(".control-plane/".length)}`;
123
+ if (rel.startsWith("control-plane/"))
124
+ return rel;
125
+ if (rel.startsWith(".anthropic-debug/"))
126
+ return `provider-proxy/${rel.slice(".anthropic-debug/".length)}`;
127
+ if (rel.startsWith("anthropic-debug/"))
128
+ return `provider-proxy/${rel.slice("anthropic-debug/".length)}`;
129
+ return rel;
130
+ }
131
+ /**
132
+ * Storage key for a session artifact uploaded with relative path `rel`, routing
133
+ * diagnostics into `internal/logs/`. Workspace files are stored by checkpoint
134
+ * helpers, not by this function.
135
+ */
136
+ export function sessionInternalArtifactKey(workspaceId, sessionId, rel) {
137
+ return `${runSessionPrefix(workspaceId, sessionId)}${SESSION_INTERNAL_LOGS_PREFIX}/${sessionArtifactRel(rel)}`;
138
+ }
139
+ /**
140
+ * Opaque, non-reversible file id. Derived as SHA-256 hex of
141
+ * `sessionId:relPath` so a caller cannot construct an id by guessing a filename.
142
+ * It is the single id scheme for session files: the checkpoint index records it,
143
+ * the list route emits it, the download/link routes resolve it back to a path
144
+ * from the latest checkpoint index, and the object key uses it directly. Hex is
145
+ * URL-safe. WebCrypto, no new dep.
146
+ */
147
+ export async function opaqueSessionFileId(sessionId, relPath) {
148
+ const data = new TextEncoder().encode(`${sessionId}:${relPath}`);
149
+ const digest = await crypto.subtle.digest("SHA-256", data);
150
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
151
+ }
152
+ function matchesRelPrefix(rel, prefix) {
153
+ if (prefix.endsWith("/"))
154
+ return rel.startsWith(prefix);
155
+ return rel === prefix || rel.startsWith(`${prefix}/`);
156
+ }
157
+ /**
158
+ * Storage key for a session's snapshotted asset, addressed by its content hash.
159
+ * This is used only for pre-checkpoint reusable workspace assets. Session boot
160
+ * should materialize those assets into an initial checkpoint before execution.
161
+ */
162
+ export function workspaceAssetKey(workspaceId, hash) {
163
+ const hex = hash.startsWith("sha256:") ? hash.slice("sha256:".length) : hash;
164
+ return `${WORKSPACES_PREFIX}/${workspaceId}/assets/content/${hex}`;
165
+ }
166
+ /**
167
+ * Retention class for an S3 key. Writers set this as the `aex-retention` object
168
+ * tag so bucket lifecycle rules can apply per logical namespace even though the
169
+ * useful category sits after dynamic workspace/session ids.
170
+ */
171
+ export function s3ObjectRetentionTagValue(key) {
172
+ const normalized = key.replace(/^\/+/, "");
173
+ if (normalized.startsWith(`${WORKSPACES_PREFIX}/`)) {
174
+ const parts = normalized.split("/");
175
+ if (parts[2] === "assets" && parts[3] === "content" && parts.length >= 5)
176
+ return "workspace-asset";
177
+ if (parts[2] === "uploads" && parts.length >= 4)
178
+ return "upload-staging";
179
+ if (parts[2] !== SESSIONS_PREFIX || parts.length < 5)
180
+ return undefined;
181
+ const rel = parts.slice(4).join("/");
182
+ if (rel.startsWith(`${SESSION_CHECKPOINTS_PREFIX}/`)) {
183
+ if (rel.includes("/workspace/objects/"))
184
+ return "session-file-current";
185
+ return "session-core";
186
+ }
187
+ if (rel.startsWith(`${SESSION_INTERNAL_PREFIX}/admin-archives/`))
188
+ return "admin-archive";
189
+ if (rel.startsWith(`${SESSION_INTERNAL_PREFIX}/events/`))
190
+ return "internal-event";
191
+ if (rel.startsWith(`${SESSION_INTERNAL_USAGE_PREFIX}/`))
192
+ return "internal-usage";
193
+ if (rel.startsWith(`${SESSION_INTERNAL_LOGS_PREFIX}/`))
194
+ return "internal-log";
195
+ if (rel.startsWith(`${SESSION_INTERNAL_PREFIX}/`))
196
+ return "internal-log";
197
+ return undefined;
198
+ }
199
+ // Current control-plane core is still read by the running container from the
200
+ // legacy control namespace. It is not a public files namespace and can be cut
201
+ // over independently after boot/journal consumers move to workspace-scoped keys.
202
+ if (normalized.startsWith(`${SESSIONS_PREFIX}/`)) {
203
+ const parts = normalized.split("/");
204
+ if (parts.length < 4 || parts[2] !== "session")
205
+ return undefined;
206
+ const rel = parts.slice(3).join("/");
207
+ if (rel.startsWith("logs/"))
208
+ return "internal-log";
209
+ if (rel.startsWith("internal/usage/"))
210
+ return "internal-usage";
211
+ if (rel.startsWith("internal/events/"))
212
+ return "internal-event";
213
+ if (rel.startsWith("admin-archives/") || rel.startsWith("internal/admin-archives/"))
214
+ return "admin-archive";
215
+ if (rel === "terminal-failure.json")
216
+ return "internal-log";
217
+ if (rel === "boot.json" ||
218
+ rel === "settle.json" ||
219
+ rel === "control.json" ||
220
+ rel === "secrets.sealed" ||
221
+ rel.startsWith("journal/") ||
222
+ rel.startsWith("turns/")) {
223
+ return "session-core";
224
+ }
225
+ }
226
+ return undefined;
227
+ }
228
+ /** S3 PutObject/CreateMultipartUpload/Upload `Tagging` header value for a key. */
229
+ export function s3ObjectRetentionTaggingHeader(key) {
230
+ const value = s3ObjectRetentionTagValue(key);
231
+ if (value === undefined)
232
+ return undefined;
233
+ return `${encodeURIComponent(S3_RETENTION_TAG_KEY)}=${encodeURIComponent(value)}`;
234
+ }
@@ -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.
@@ -36,7 +36,7 @@
36
36
  * boundary.
37
37
  */
38
38
  import { type JsonValue, type PlatformEnvironment } from "./submission.js";
39
- import { type RunModel } from "./models.js";
39
+ import { type ModelName } from "./models.js";
40
40
  import type { RuntimeSize } from "./runtime-sizes.js";
41
41
  /**
42
42
  * Mirrors the server-side CHECK constraint
@@ -96,8 +96,8 @@ export declare const SKILL_BUNDLE_LIMITS: {
96
96
  /**
97
97
  * The PUBLIC wire reference to a workspace skill — by NAME, no bytes, no hash.
98
98
  * This is what the SDK sends in `submission.skills` and what the idempotency
99
- * hash covers. The run resolves the name to the workspace skill's CURRENT bytes
100
- * at submit time (a re-upload under the same name changes what later runs see).
99
+ * hash covers. The session resolves the name to the workspace skill's CURRENT bytes
100
+ * at submit time (a re-upload under the same name changes what later sessions see).
101
101
  */
102
102
  export interface SkillRef {
103
103
  readonly kind: "skill";
@@ -185,7 +185,7 @@ export declare function assertValidMountPath(value: string, field: string): void
185
185
  */
186
186
  export declare function parseAssetRefFields(record: Record<string, unknown>, path: string): AssetRef;
187
187
  /**
188
- * Manifest entry persisted in `skill_bundles.manifest` and in run-owned
188
+ * Manifest entry persisted in `skill_bundles.manifest` and in session-owned
189
189
  * snapshots. `path` is forward-slash, relative, normalised. `mode` is the
190
190
  * stored POSIX mode (sanitised, NOT the user's filesystem mode) — see
191
191
  * `SKILL_BUNDLE_LIMITS.defaultFileMode`.
@@ -285,7 +285,7 @@ export type RemoteMcpTransport = (typeof REMOTE_MCP_TRANSPORTS)[number];
285
285
  export declare const REMOTE_MCP_STDIO_REJECTED_MESSAGE = "stdio MCP servers are not supported by Aex. Aex supports remote MCP servers over HTTP/SSE only.";
286
286
  /**
287
287
  * The non-secret half of an MCP server declaration. This is what enters
288
- * the hashed submission, the run snapshot, and any audit log. `name`
288
+ * the hashed submission, the session snapshot, and any audit log. `name`
289
289
  * keys into `secrets.mcpServers` for the per-request headers.
290
290
  *
291
291
  * `transport` is optional on the wire — when omitted, the runtime is
@@ -300,11 +300,11 @@ export interface McpServerRef {
300
300
  }
301
301
  export declare const MCP_SERVER_NAME_PATTERN: RegExp;
302
302
  /**
303
- * A run-config MCP entry. The user is free to supply headers inline; the SDK
303
+ * A session-config MCP entry. The user is free to supply headers inline; the SDK
304
304
  * splits the call site cleanly at submission time so the Authorization (or
305
305
  * other auth-bearing) header never enters the non-secret wire payload.
306
306
  */
307
- export interface RunConfigMcpServer extends McpServerRef {
307
+ export interface SessionConfigMcpServer extends McpServerRef {
308
308
  readonly headers?: Readonly<Record<string, string>>;
309
309
  }
310
310
  export declare function parseMcpServerRef(input: unknown, path: string): McpServerRef;
@@ -316,48 +316,48 @@ export declare function parseMcpServerRef(input: unknown, path: string): McpServ
316
316
  */
317
317
  export declare function rejectStdioMcpShape(record: Record<string, unknown>): void;
318
318
  /**
319
- * Plain JSON accepted by `aex run --config <path>`. This is not a
320
- * platform object; it is only the non-secret run parameters that the CLI folds
319
+ * Plain JSON accepted by `aex start --config <path>`. This is not a
320
+ * platform object; it is only the non-secret session parameters that the CLI folds
321
321
  * into the normal `submit` request.
322
322
  */
323
- export interface RunRequestConfig {
324
- readonly model: RunModel;
323
+ export interface SessionRequestConfig {
324
+ readonly model: ModelName;
325
325
  readonly system?: string;
326
326
  readonly prompt: string | readonly string[];
327
- readonly mcpServers?: readonly RunConfigMcpServer[];
327
+ readonly mcpServers?: readonly SessionConfigMcpServer[];
328
328
  readonly environment?: PlatformEnvironment;
329
329
  /** Managed runtime size preset (see {@link RuntimeSize}). */
330
330
  readonly runtimeSize?: RuntimeSize;
331
- /** Run deadline as a duration string (`"1h"`, `"30m"`); bounded [1m, 8h] server-side. */
331
+ /** SessionRecord deadline as a duration string (`"1h"`, `"30m"`); bounded [1m, 8h] server-side. */
332
332
  readonly timeout?: string;
333
333
  readonly metadata?: Readonly<Record<string, JsonValue>>;
334
334
  }
335
335
  /**
336
- * Parse a run request config from JSON. Defensive — used by the host CLI to
337
- * load `--config run.json`. Throws with the JSON path that failed so
336
+ * Parse a session request config from JSON. Defensive — used by the host CLI to
337
+ * load `--config session.json`. Throws with the JSON path that failed so
338
338
  * a user can fix their file. Headers are preserved here and split out
339
339
  * later by the SDK normalisation step.
340
340
  */
341
- export declare function parseRunRequestConfig(input: unknown): RunRequestConfig;
341
+ export declare function parseSessionRequestConfig(input: unknown): SessionRequestConfig;
342
342
  /**
343
- * Result of splitting a run config into the non-secret submission and the
343
+ * Result of splitting a session config into the non-secret submission and the
344
344
  * secret MCP-headers bundle. The SDK calls this just before posting to
345
- * /api/runs: the `submission` half is what the BFF hashes for idempotency, the
346
- * `mcpServerSecrets` half is what enters run-scoped custody.
345
+ * /api/sessions: the `submission` half is what the BFF hashes for idempotency, the
346
+ * `mcpServerSecrets` half is what enters session-scoped custody.
347
347
  *
348
348
  * `prompt` is normalised to `readonly string[]` (single-string callers
349
349
  * get wrapped in a length-1 array) so the wire payload, the hosted API,
350
350
  * and the audit log don't have to re-handle two shapes.
351
351
  */
352
- export interface NormalisedRunRequestConfig {
353
- readonly model: RunModel;
352
+ export interface NormalisedSessionRequestConfig {
353
+ readonly model: ModelName;
354
354
  readonly system?: string;
355
355
  readonly prompt: readonly string[];
356
356
  readonly mcpServers: readonly McpServerRef[];
357
357
  readonly environment?: PlatformEnvironment;
358
358
  readonly metadata?: Readonly<Record<string, JsonValue>>;
359
359
  /**
360
- * MCP servers whose run-config entry carried `headers`. Keyed by the `name`
360
+ * MCP servers whose session-config entry carried `headers`. Keyed by the `name`
361
361
  * that appears in `mcpServers` so the BFF can pair them up.
362
362
  */
363
363
  readonly mcpServerSecrets: ReadonlyArray<{
@@ -366,5 +366,5 @@ export interface NormalisedRunRequestConfig {
366
366
  readonly headers: Readonly<Record<string, string>>;
367
367
  }>;
368
368
  }
369
- export declare function normaliseRunRequestConfig(config: RunRequestConfig): NormalisedRunRequestConfig;
369
+ export declare function normaliseSessionRequestConfig(config: SessionRequestConfig): NormalisedSessionRequestConfig;
370
370
  export {};