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