@aexhq/sdk 0.13.6
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/LICENSE +201 -0
- package/README.md +160 -0
- package/dist/_contracts/connection-ticket.d.ts +21 -0
- package/dist/_contracts/connection-ticket.js +49 -0
- package/dist/_contracts/event-envelope.d.ts +276 -0
- package/dist/_contracts/event-envelope.js +324 -0
- package/dist/_contracts/event-stream-client.d.ts +47 -0
- package/dist/_contracts/event-stream-client.js +141 -0
- package/dist/_contracts/http.d.ts +35 -0
- package/dist/_contracts/http.js +114 -0
- package/dist/_contracts/index.d.ts +28 -0
- package/dist/_contracts/index.js +29 -0
- package/dist/_contracts/managed-key.d.ts +74 -0
- package/dist/_contracts/managed-key.js +110 -0
- package/dist/_contracts/operations.d.ts +237 -0
- package/dist/_contracts/operations.js +632 -0
- package/dist/_contracts/provider-support.d.ts +220 -0
- package/dist/_contracts/provider-support.js +90 -0
- package/dist/_contracts/proxy-protocol.d.ts +257 -0
- package/dist/_contracts/proxy-protocol.js +234 -0
- package/dist/_contracts/proxy-validation.d.ts +19 -0
- package/dist/_contracts/proxy-validation.js +51 -0
- package/dist/_contracts/run-artifacts.d.ts +47 -0
- package/dist/_contracts/run-artifacts.js +101 -0
- package/dist/_contracts/run-config.d.ts +304 -0
- package/dist/_contracts/run-config.js +659 -0
- package/dist/_contracts/run-cost.d.ts +125 -0
- package/dist/_contracts/run-cost.js +616 -0
- package/dist/_contracts/run-custody.d.ts +226 -0
- package/dist/_contracts/run-custody.js +465 -0
- package/dist/_contracts/run-record.d.ts +127 -0
- package/dist/_contracts/run-record.js +177 -0
- package/dist/_contracts/run-retention.d.ts +213 -0
- package/dist/_contracts/run-retention.js +484 -0
- package/dist/_contracts/run-unit.d.ts +194 -0
- package/dist/_contracts/run-unit.js +215 -0
- package/dist/_contracts/runner-event.d.ts +114 -0
- package/dist/_contracts/runner-event.js +187 -0
- package/dist/_contracts/runtime-manifest.d.ts +106 -0
- package/dist/_contracts/runtime-manifest.js +98 -0
- package/dist/_contracts/runtime-security-profile.d.ts +27 -0
- package/dist/_contracts/runtime-security-profile.js +82 -0
- package/dist/_contracts/runtime-sizes.d.ts +144 -0
- package/dist/_contracts/runtime-sizes.js +136 -0
- package/dist/_contracts/runtime-types.d.ts +212 -0
- package/dist/_contracts/runtime-types.js +2 -0
- package/dist/_contracts/sdk-errors.d.ts +34 -0
- package/dist/_contracts/sdk-errors.js +52 -0
- package/dist/_contracts/sdk-secrets.d.ts +31 -0
- package/dist/_contracts/sdk-secrets.js +220 -0
- package/dist/_contracts/side-effect-audit.d.ts +129 -0
- package/dist/_contracts/side-effect-audit.js +494 -0
- package/dist/_contracts/sse.d.ts +74 -0
- package/dist/_contracts/sse.js +0 -0
- package/dist/_contracts/stable.d.ts +26 -0
- package/dist/_contracts/stable.js +44 -0
- package/dist/_contracts/status.d.ts +19 -0
- package/dist/_contracts/status.js +61 -0
- package/dist/_contracts/submission.d.ts +383 -0
- package/dist/_contracts/submission.js +1380 -0
- package/dist/agents-md.d.ts +46 -0
- package/dist/agents-md.js +83 -0
- package/dist/agents-md.js.map +1 -0
- package/dist/asset-upload.d.ts +66 -0
- package/dist/asset-upload.js +168 -0
- package/dist/asset-upload.js.map +1 -0
- package/dist/bundle.d.ts +33 -0
- package/dist/bundle.js +89 -0
- package/dist/bundle.js.map +1 -0
- package/dist/cli.mjs +4140 -0
- package/dist/cli.mjs.sha256 +1 -0
- package/dist/client.d.ts +460 -0
- package/dist/client.js +857 -0
- package/dist/client.js.map +1 -0
- package/dist/fetch-archive.d.ts +16 -0
- package/dist/fetch-archive.js +170 -0
- package/dist/fetch-archive.js.map +1 -0
- package/dist/file.d.ts +57 -0
- package/dist/file.js +153 -0
- package/dist/file.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +84 -0
- package/dist/mcp-server.js +114 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/node-fs.d.ts +12 -0
- package/dist/node-fs.js +44 -0
- package/dist/node-fs.js.map +1 -0
- package/dist/proxy-endpoint.d.ts +131 -0
- package/dist/proxy-endpoint.js +147 -0
- package/dist/proxy-endpoint.js.map +1 -0
- package/dist/skill.d.ts +117 -0
- package/dist/skill.js +169 -0
- package/dist/skill.js.map +1 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/docs/cleanup.md +38 -0
- package/docs/credentials.md +153 -0
- package/docs/events.md +76 -0
- package/docs/mcp.md +47 -0
- package/docs/outputs.md +157 -0
- package/docs/product-boundaries.md +57 -0
- package/docs/provider-runtime-capabilities.md +103 -0
- package/docs/quickstart.md +110 -0
- package/docs/release.md +99 -0
- package/docs/run-config.md +53 -0
- package/docs/run-record.md +39 -0
- package/docs/skills.md +139 -0
- package/docs/testing.md +29 -0
- package/package.json +47 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { RunCostTelemetry } from "./run-cost.js";
|
|
2
|
+
import { type CustodyManifestV1, type CustodyRedactionFinding } from "./run-custody.js";
|
|
3
|
+
import type { Run, RunEvent, Output } from "./runtime-types.js";
|
|
4
|
+
import type { PlatformSubmission } from "./submission.js";
|
|
5
|
+
export declare const RUN_RECORD_SCHEMA_VERSION: "aex.run-record.v1";
|
|
6
|
+
export declare const RUN_RECORD_MANIFEST_SCHEMA_VERSION: "aex.run-record.manifest.v1";
|
|
7
|
+
export type RunRecordArchiveNamespaceV1 = "metadata" | "events" | "outputs" | "logs";
|
|
8
|
+
export type RunRecordFileStatusV1 = "present" | "absent" | "pending" | "unavailable" | "not_applicable" | "error";
|
|
9
|
+
export type RunRecordArchiveFileRoleV1 = "run_metadata" | "submission_snapshot" | "cost" | "custody" | "typed_events" | "log_events" | "all_events" | "coordinator_events_manifest" | "output" | "log";
|
|
10
|
+
export interface RunRecordSubmissionSnapshotV1 {
|
|
11
|
+
readonly submission: PlatformSubmission;
|
|
12
|
+
}
|
|
13
|
+
export interface RunRecordCostV1 {
|
|
14
|
+
readonly status: RunRecordFileStatusV1;
|
|
15
|
+
readonly telemetry?: RunCostTelemetry;
|
|
16
|
+
}
|
|
17
|
+
export interface RunRecordMetadataV1 {
|
|
18
|
+
readonly run: Run;
|
|
19
|
+
readonly submission?: RunRecordSubmissionSnapshotV1;
|
|
20
|
+
readonly cost?: RunRecordCostV1;
|
|
21
|
+
readonly custody?: CustodyManifestV1;
|
|
22
|
+
}
|
|
23
|
+
export interface RunRecordEventsV1 {
|
|
24
|
+
/**
|
|
25
|
+
* Typed `channel: "event"` records. This is the current SDK
|
|
26
|
+
* `events/events.jsonl` export. Log-channel records are not mixed into this
|
|
27
|
+
* file.
|
|
28
|
+
*/
|
|
29
|
+
readonly typed: readonly RunEvent[];
|
|
30
|
+
readonly logs?: readonly RunEvent[];
|
|
31
|
+
readonly all?: readonly RunEvent[];
|
|
32
|
+
}
|
|
33
|
+
export interface RunRecordV1 {
|
|
34
|
+
readonly schemaVersion: typeof RUN_RECORD_SCHEMA_VERSION;
|
|
35
|
+
readonly runId: string;
|
|
36
|
+
readonly metadata: RunRecordMetadataV1;
|
|
37
|
+
readonly events: RunRecordEventsV1;
|
|
38
|
+
readonly outputs: readonly Output[];
|
|
39
|
+
readonly logs: readonly Output[];
|
|
40
|
+
readonly manifest: RunRecordManifestV1;
|
|
41
|
+
}
|
|
42
|
+
export interface RunRecordNamespaceV1 {
|
|
43
|
+
readonly name: RunRecordArchiveNamespaceV1;
|
|
44
|
+
readonly prefix: `${RunRecordArchiveNamespaceV1}/`;
|
|
45
|
+
readonly status: RunRecordFileStatusV1;
|
|
46
|
+
readonly description: string;
|
|
47
|
+
}
|
|
48
|
+
export interface RunRecordArchiveFileV1 {
|
|
49
|
+
readonly namespace: RunRecordArchiveNamespaceV1;
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly role: RunRecordArchiveFileRoleV1;
|
|
52
|
+
readonly status: RunRecordFileStatusV1;
|
|
53
|
+
readonly id?: string;
|
|
54
|
+
readonly filename?: string | null;
|
|
55
|
+
readonly sizeBytes?: number;
|
|
56
|
+
readonly contentType?: string;
|
|
57
|
+
readonly recordCount?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface RunRecordArtifactSummaryV1 {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly filename: string | null;
|
|
62
|
+
readonly sizeBytes?: number;
|
|
63
|
+
readonly contentType?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface RunRecordDownloadErrorV1 {
|
|
66
|
+
readonly namespace: "outputs" | "logs";
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly filename: string | null;
|
|
69
|
+
readonly message: string;
|
|
70
|
+
}
|
|
71
|
+
export interface RunRecordManifestV1 {
|
|
72
|
+
readonly schemaVersion: typeof RUN_RECORD_MANIFEST_SCHEMA_VERSION;
|
|
73
|
+
readonly runRecordSchemaVersion: typeof RUN_RECORD_SCHEMA_VERSION;
|
|
74
|
+
readonly runId: string;
|
|
75
|
+
readonly namespaces: readonly RunRecordNamespaceV1[];
|
|
76
|
+
readonly files: readonly RunRecordArchiveFileV1[];
|
|
77
|
+
/**
|
|
78
|
+
* Compatibility aliases for existing consumers of `manifest.json`.
|
|
79
|
+
* Prefer `files[]` for new code because it carries namespace, role, and
|
|
80
|
+
* presence state for optional run-record members.
|
|
81
|
+
*/
|
|
82
|
+
readonly outputs: readonly RunRecordArtifactSummaryV1[];
|
|
83
|
+
readonly logs: readonly RunRecordArtifactSummaryV1[];
|
|
84
|
+
readonly errors: readonly RunRecordDownloadErrorV1[];
|
|
85
|
+
}
|
|
86
|
+
export interface BuildRunRecordDownloadManifestV1Input {
|
|
87
|
+
readonly runId: string;
|
|
88
|
+
readonly outputs: readonly RunRecordArtifactSummaryV1[];
|
|
89
|
+
readonly logs: readonly RunRecordArtifactSummaryV1[];
|
|
90
|
+
readonly errors?: readonly RunRecordDownloadErrorV1[];
|
|
91
|
+
readonly typedEventCount?: number;
|
|
92
|
+
readonly submission?: RunRecordFileManifestInputV1;
|
|
93
|
+
readonly cost?: RunRecordFileManifestInputV1;
|
|
94
|
+
readonly custody?: RunRecordFileManifestInputV1;
|
|
95
|
+
readonly logEvents?: RunRecordFileManifestInputV1;
|
|
96
|
+
readonly allEvents?: RunRecordFileManifestInputV1;
|
|
97
|
+
readonly coordinatorEventsManifest?: RunRecordFileManifestInputV1;
|
|
98
|
+
}
|
|
99
|
+
export interface RunRecordFileManifestInputV1 {
|
|
100
|
+
readonly status: RunRecordFileStatusV1;
|
|
101
|
+
readonly recordCount?: number;
|
|
102
|
+
}
|
|
103
|
+
export interface RunRecordArchiveEntryForRedactionV1 {
|
|
104
|
+
readonly path: string;
|
|
105
|
+
readonly bytes: Uint8Array;
|
|
106
|
+
readonly contentType?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Customer-authored output bytes are intentionally outside the public-record
|
|
109
|
+
* redaction guarantee. Metadata, event exports, manifests, and platform logs
|
|
110
|
+
* remain scanned.
|
|
111
|
+
*/
|
|
112
|
+
readonly customerContent?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface RunRecordArchiveRedactionFindingV1 {
|
|
115
|
+
readonly entryPath: string;
|
|
116
|
+
readonly path: string;
|
|
117
|
+
readonly reason: CustodyRedactionFinding["reason"];
|
|
118
|
+
readonly valueLength?: number;
|
|
119
|
+
}
|
|
120
|
+
export declare class RunRecordArchiveRedactionError extends Error {
|
|
121
|
+
readonly code = "run_record_archive_not_public_safe";
|
|
122
|
+
readonly findings: readonly RunRecordArchiveRedactionFindingV1[];
|
|
123
|
+
constructor(findings: readonly RunRecordArchiveRedactionFindingV1[]);
|
|
124
|
+
}
|
|
125
|
+
export declare function buildRunRecordDownloadManifestV1(input: BuildRunRecordDownloadManifestV1Input): RunRecordManifestV1;
|
|
126
|
+
export declare function scanRunRecordArchiveEntriesV1(entries: readonly RunRecordArchiveEntryForRedactionV1[]): readonly RunRecordArchiveRedactionFindingV1[];
|
|
127
|
+
export declare function assertRunRecordArchivePublicSafeV1(entries: readonly RunRecordArchiveEntryForRedactionV1[]): void;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { scanCustodyPayloadForSensitiveValues } from "./run-custody.js";
|
|
2
|
+
export const RUN_RECORD_SCHEMA_VERSION = "aex.run-record.v1";
|
|
3
|
+
export const RUN_RECORD_MANIFEST_SCHEMA_VERSION = "aex.run-record.manifest.v1";
|
|
4
|
+
export class RunRecordArchiveRedactionError extends Error {
|
|
5
|
+
code = "run_record_archive_not_public_safe";
|
|
6
|
+
findings;
|
|
7
|
+
constructor(findings) {
|
|
8
|
+
super(`run record archive contains non-public data at ${formatArchiveFindingPaths(findings)}`);
|
|
9
|
+
this.name = "RunRecordArchiveRedactionError";
|
|
10
|
+
this.findings = Object.freeze([...findings]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function buildRunRecordDownloadManifestV1(input) {
|
|
14
|
+
const outputs = input.outputs.map((file) => normalizeArtifactSummary(file));
|
|
15
|
+
const logs = input.logs.map((file) => normalizeArtifactSummary(file));
|
|
16
|
+
const errors = (input.errors ?? []).map((error) => Object.freeze({ ...error }));
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
schemaVersion: RUN_RECORD_MANIFEST_SCHEMA_VERSION,
|
|
19
|
+
runRecordSchemaVersion: RUN_RECORD_SCHEMA_VERSION,
|
|
20
|
+
runId: input.runId,
|
|
21
|
+
namespaces: Object.freeze([
|
|
22
|
+
namespace("metadata", "Run metadata, submission snapshot, custody, and cost files."),
|
|
23
|
+
namespace("events", "Typed event-channel exports and optional full-stream/log-channel exports."),
|
|
24
|
+
namespace("outputs", "Captured deliverables produced by the run."),
|
|
25
|
+
namespace("logs", "Platform diagnostics and runtime log artifacts.")
|
|
26
|
+
]),
|
|
27
|
+
files: Object.freeze([
|
|
28
|
+
file("metadata", "metadata/run.json", "run_metadata", "present"),
|
|
29
|
+
file("metadata", "metadata/submission.json", "submission_snapshot", input.submission?.status ?? "unavailable"),
|
|
30
|
+
file("metadata", "metadata/cost.json", "cost", input.cost?.status ?? "pending"),
|
|
31
|
+
file("metadata", "metadata/custody.json", "custody", input.custody?.status ?? "pending"),
|
|
32
|
+
file("events", "events/events.jsonl", "typed_events", "present", {
|
|
33
|
+
recordCount: input.typedEventCount ?? 0
|
|
34
|
+
}),
|
|
35
|
+
file("events", "events/logs.jsonl", "log_events", input.logEvents?.status ?? "unavailable", recordCountExtra(input.logEvents)),
|
|
36
|
+
file("events", "events/all.jsonl", "all_events", input.allEvents?.status ?? "unavailable", recordCountExtra(input.allEvents)),
|
|
37
|
+
file("events", "events/manifest.json", "coordinator_events_manifest", input.coordinatorEventsManifest?.status ?? "unavailable"),
|
|
38
|
+
...outputs.map((output) => artifactFile("outputs", "output", "outputs/", output)),
|
|
39
|
+
...logs.map((log) => artifactFile("logs", "log", "logs/", log))
|
|
40
|
+
]),
|
|
41
|
+
outputs: Object.freeze(outputs),
|
|
42
|
+
logs: Object.freeze(logs),
|
|
43
|
+
errors: Object.freeze(errors)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function namespace(name, description) {
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
name,
|
|
49
|
+
prefix: `${name}/`,
|
|
50
|
+
status: "present",
|
|
51
|
+
description
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function file(namespaceName, path, role, status, extra) {
|
|
55
|
+
return Object.freeze({
|
|
56
|
+
namespace: namespaceName,
|
|
57
|
+
path,
|
|
58
|
+
role,
|
|
59
|
+
status,
|
|
60
|
+
...(extra?.recordCount !== undefined ? { recordCount: extra.recordCount } : {})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function recordCountExtra(input) {
|
|
64
|
+
return input?.status === "present" && input.recordCount !== undefined
|
|
65
|
+
? { recordCount: input.recordCount }
|
|
66
|
+
: undefined;
|
|
67
|
+
}
|
|
68
|
+
function artifactFile(namespaceName, role, prefix, artifact) {
|
|
69
|
+
return Object.freeze({
|
|
70
|
+
namespace: namespaceName,
|
|
71
|
+
path: `${prefix}${artifact.filename ?? artifact.id}`,
|
|
72
|
+
role,
|
|
73
|
+
status: "present",
|
|
74
|
+
id: artifact.id,
|
|
75
|
+
filename: artifact.filename,
|
|
76
|
+
...(artifact.sizeBytes !== undefined ? { sizeBytes: artifact.sizeBytes } : {}),
|
|
77
|
+
...(artifact.contentType !== undefined ? { contentType: artifact.contentType } : {})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function normalizeArtifactSummary(input) {
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
id: input.id,
|
|
83
|
+
filename: input.filename,
|
|
84
|
+
...(input.sizeBytes !== undefined ? { sizeBytes: input.sizeBytes } : {}),
|
|
85
|
+
...(input.contentType !== undefined ? { contentType: input.contentType } : {})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export function scanRunRecordArchiveEntriesV1(entries) {
|
|
89
|
+
const findings = [];
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
if (entry.customerContent || !shouldScanArchiveEntry(entry)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
for (const finding of scanArchiveEntry(entry)) {
|
|
95
|
+
findings.push(finding);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return Object.freeze(findings);
|
|
99
|
+
}
|
|
100
|
+
export function assertRunRecordArchivePublicSafeV1(entries) {
|
|
101
|
+
const findings = scanRunRecordArchiveEntriesV1(entries);
|
|
102
|
+
if (findings.length > 0) {
|
|
103
|
+
throw new RunRecordArchiveRedactionError(findings);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function shouldScanArchiveEntry(entry) {
|
|
107
|
+
if (entry.path.startsWith("outputs/")) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const contentType = entry.contentType?.toLowerCase() ?? "";
|
|
111
|
+
if (contentType.startsWith("text/") ||
|
|
112
|
+
contentType.includes("json") ||
|
|
113
|
+
contentType.includes("xml") ||
|
|
114
|
+
contentType.includes("yaml")) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return /\.(?:json|jsonl|ndjson|txt|log|md|csv|tsv|ya?ml)$/i.test(entry.path);
|
|
118
|
+
}
|
|
119
|
+
function scanArchiveEntry(entry) {
|
|
120
|
+
const text = new TextDecoder().decode(entry.bytes);
|
|
121
|
+
const parsedValues = parseArchiveTextValues(entry.path, text);
|
|
122
|
+
const rawFindings = parsedValues.length > 0
|
|
123
|
+
? parsedValues.flatMap((value) => [...scanCustodyPayloadForSensitiveValues(value.value)].map((finding) => ({
|
|
124
|
+
...finding,
|
|
125
|
+
path: `${value.path}${finding.path === "$" ? "" : finding.path.slice(1)}`
|
|
126
|
+
})))
|
|
127
|
+
: scanCustodyPayloadForSensitiveValues(text);
|
|
128
|
+
return Object.freeze(rawFindings
|
|
129
|
+
.filter((finding) => !isAllowedArchiveHighEntropyField(entry.path, finding))
|
|
130
|
+
.map((finding) => Object.freeze({
|
|
131
|
+
entryPath: entry.path,
|
|
132
|
+
path: finding.path,
|
|
133
|
+
reason: finding.reason,
|
|
134
|
+
...(finding.valueLength !== undefined ? { valueLength: finding.valueLength } : {})
|
|
135
|
+
})));
|
|
136
|
+
}
|
|
137
|
+
function isAllowedArchiveHighEntropyField(entryPath, finding) {
|
|
138
|
+
if (finding.reason !== "high_entropy_token" || !entryPath.endsWith("manifest.json")) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return /^\$(?:\.files\[\d+\]|\.outputs\[\d+\]|\.logs\[\d+\])\.id$/.test(finding.path);
|
|
142
|
+
}
|
|
143
|
+
function parseArchiveTextValues(path, text) {
|
|
144
|
+
if (/\.json$/i.test(path)) {
|
|
145
|
+
const parsed = tryParseJson(text);
|
|
146
|
+
return parsed.ok ? Object.freeze([{ path: "$", value: parsed.value }]) : Object.freeze([]);
|
|
147
|
+
}
|
|
148
|
+
if (/\.(?:jsonl|ndjson)$/i.test(path)) {
|
|
149
|
+
const values = [];
|
|
150
|
+
const lines = text.split(/\r?\n/);
|
|
151
|
+
for (let i = 0; i < lines.length; i++) {
|
|
152
|
+
const line = lines[i];
|
|
153
|
+
if (!line?.trim()) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const parsed = tryParseJson(line);
|
|
157
|
+
if (!parsed.ok) {
|
|
158
|
+
return Object.freeze([]);
|
|
159
|
+
}
|
|
160
|
+
values.push({ path: `$[${i}]`, value: parsed.value });
|
|
161
|
+
}
|
|
162
|
+
return Object.freeze(values);
|
|
163
|
+
}
|
|
164
|
+
return Object.freeze([]);
|
|
165
|
+
}
|
|
166
|
+
function tryParseJson(text) {
|
|
167
|
+
try {
|
|
168
|
+
return { ok: true, value: JSON.parse(text) };
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return { ok: false };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function formatArchiveFindingPaths(findings) {
|
|
175
|
+
return findings.map((finding) => `${finding.entryPath}${finding.path} (${finding.reason})`).join(", ");
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=run-record.js.map
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { RunStatus } from "./status.js";
|
|
2
|
+
export declare const RUN_RETENTION_SCHEMA_VERSION = 1;
|
|
3
|
+
export declare const RUN_DELETION_MANIFEST_KIND = "aex.run_deletion_manifest.v1";
|
|
4
|
+
export declare const RUN_DELETION_JOB_KIND = "aex.run_deletion_job.v1";
|
|
5
|
+
export declare const RUN_DELETION_MANIFEST_CONTENT_TYPE = "application/json; charset=utf-8";
|
|
6
|
+
export declare const RUN_RETENTION_REDACTION_SCANNER_VERSION = 1;
|
|
7
|
+
export declare const RUN_DELETION_REASONS: readonly ["manual_delete", "retention_gc"];
|
|
8
|
+
export type RunDeletionReason = (typeof RUN_DELETION_REASONS)[number];
|
|
9
|
+
export declare const RUN_DELETION_MANIFEST_MODES: readonly ["dry_run", "final"];
|
|
10
|
+
export type RunDeletionManifestMode = (typeof RUN_DELETION_MANIFEST_MODES)[number];
|
|
11
|
+
export declare const RUN_DELETION_CANDIDATE_STATUSES: readonly ["selected", "blocked"];
|
|
12
|
+
export type RunDeletionCandidateStatus = (typeof RUN_DELETION_CANDIDATE_STATUSES)[number];
|
|
13
|
+
export declare const RUN_DELETION_BLOCKERS: readonly ["non_terminal", "already_deleted", "concurrent_delete", "retention_policy_disabled", "unexpired", "held", "retention_exempt", "unresolved_cleanup", "unresolved_custody"];
|
|
14
|
+
export type RunDeletionBlocker = (typeof RUN_DELETION_BLOCKERS)[number];
|
|
15
|
+
export declare const RUN_DELETION_COUNT_CLASSES: readonly ["r2_objects", "outputs", "logs", "events", "assets", "db_event_rows", "db_output_rows", "capture_failures", "storage_samples", "custody_manifests"];
|
|
16
|
+
export type RunDeletionCountClass = (typeof RUN_DELETION_COUNT_CLASSES)[number];
|
|
17
|
+
export declare const RUN_DELETION_COUNT_STATUSES: readonly ["counted", "not_counted", "partial", "failed"];
|
|
18
|
+
export type RunDeletionCountStatus = (typeof RUN_DELETION_COUNT_STATUSES)[number];
|
|
19
|
+
export declare const RUN_DELETION_JOB_STATUSES: readonly ["queued", "planning", "blocked", "manifest_written", "deleting", "delete_failed", "completed", "failed"];
|
|
20
|
+
export type RunDeletionJobStatus = (typeof RUN_DELETION_JOB_STATUSES)[number];
|
|
21
|
+
export declare const RUN_DELETION_PROOF_STATUSES: readonly ["not_started", "running", "completed", "failed"];
|
|
22
|
+
export type RunDeletionProofStatus = (typeof RUN_DELETION_PROOF_STATUSES)[number];
|
|
23
|
+
export declare const RUN_DELETION_WRITE_STATUSES: readonly ["not_written", "written", "write_failed"];
|
|
24
|
+
export type RunDeletionWriteStatus = (typeof RUN_DELETION_WRITE_STATUSES)[number];
|
|
25
|
+
export declare const RUN_RETENTION_EXCLUDED_VALUE_CLASSES: readonly ["raw_paths", "object_keys", "filenames", "object_sizes", "hashes", "provider_ids", "vault_ids", "resource_ids", "resource_handles", "signed_urls"];
|
|
26
|
+
export type RunRetentionExcludedValueClass = (typeof RUN_RETENTION_EXCLUDED_VALUE_CLASSES)[number];
|
|
27
|
+
export interface RunRetentionPolicyV1 {
|
|
28
|
+
readonly mode: "retain_indefinitely" | "delete_after_days";
|
|
29
|
+
readonly manualDelete: "enabled";
|
|
30
|
+
readonly automaticDeletion: "disabled" | "enabled";
|
|
31
|
+
readonly retentionDays?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface RunRetentionPolicyInput {
|
|
34
|
+
readonly automaticDeletion?: boolean;
|
|
35
|
+
readonly retentionDays?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface RunDeletionCandidateRunV1 {
|
|
38
|
+
readonly runId: string;
|
|
39
|
+
readonly workspaceId: string;
|
|
40
|
+
readonly status: RunStatus | string;
|
|
41
|
+
readonly createdAt?: string;
|
|
42
|
+
readonly terminalAt?: string;
|
|
43
|
+
readonly pendingDeleteAt?: string;
|
|
44
|
+
readonly deletedAt?: string;
|
|
45
|
+
readonly held?: boolean;
|
|
46
|
+
readonly retentionExempt?: boolean;
|
|
47
|
+
readonly unresolvedCleanup?: boolean;
|
|
48
|
+
readonly unresolvedCustody?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface RunDeletionBlockerV1 {
|
|
51
|
+
readonly code: RunDeletionBlocker;
|
|
52
|
+
readonly observedAt: string;
|
|
53
|
+
}
|
|
54
|
+
export interface RunDeletionCandidateV1 {
|
|
55
|
+
readonly status: RunDeletionCandidateStatus;
|
|
56
|
+
readonly reason: RunDeletionReason;
|
|
57
|
+
readonly evaluatedAt: string;
|
|
58
|
+
readonly eligibleAt?: string;
|
|
59
|
+
readonly blockers: readonly RunDeletionBlockerV1[];
|
|
60
|
+
}
|
|
61
|
+
export interface RunDeletionCandidateInput {
|
|
62
|
+
readonly run: RunDeletionCandidateRunV1;
|
|
63
|
+
readonly reason: RunDeletionReason;
|
|
64
|
+
readonly policy?: RunRetentionPolicyV1 | RunRetentionPolicyInput;
|
|
65
|
+
readonly now: string;
|
|
66
|
+
}
|
|
67
|
+
export interface RunDeletionCountV1 {
|
|
68
|
+
readonly class: RunDeletionCountClass | string;
|
|
69
|
+
readonly count: number;
|
|
70
|
+
readonly status: RunDeletionCountStatus;
|
|
71
|
+
readonly countedAt?: string;
|
|
72
|
+
readonly errorClass?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface RunDeletionManifestRunV1 {
|
|
75
|
+
readonly runId: string;
|
|
76
|
+
readonly workspaceId: string;
|
|
77
|
+
readonly status: RunStatus | string;
|
|
78
|
+
readonly createdAt?: string;
|
|
79
|
+
readonly terminalAt?: string;
|
|
80
|
+
readonly eligibleAt?: string;
|
|
81
|
+
readonly pendingDeleteAt?: string;
|
|
82
|
+
readonly deletedAt?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface RunDeletionManifestRequestV1 {
|
|
85
|
+
readonly reason: RunDeletionReason;
|
|
86
|
+
readonly actorClass: "user" | "api_token" | "system" | "operator";
|
|
87
|
+
}
|
|
88
|
+
export interface RunDeletionManifestSummaryV1 {
|
|
89
|
+
readonly totalCount: number;
|
|
90
|
+
readonly failedCountClasses: number;
|
|
91
|
+
readonly partialCountClasses: number;
|
|
92
|
+
readonly blockerCount: number;
|
|
93
|
+
readonly counts: readonly RunDeletionCountV1[];
|
|
94
|
+
}
|
|
95
|
+
export interface RunDeletionManifestRedactionV1 {
|
|
96
|
+
readonly policy: "counts_status_timestamps_only";
|
|
97
|
+
readonly scannerVersion: typeof RUN_RETENTION_REDACTION_SCANNER_VERSION;
|
|
98
|
+
readonly excludes: readonly RunRetentionExcludedValueClass[];
|
|
99
|
+
}
|
|
100
|
+
export interface RunDeletionManifestV1 {
|
|
101
|
+
readonly schemaVersion: typeof RUN_RETENTION_SCHEMA_VERSION;
|
|
102
|
+
readonly kind: typeof RUN_DELETION_MANIFEST_KIND;
|
|
103
|
+
readonly generatedAt: string;
|
|
104
|
+
readonly mode: RunDeletionManifestMode;
|
|
105
|
+
readonly run: RunDeletionManifestRunV1;
|
|
106
|
+
readonly request: RunDeletionManifestRequestV1;
|
|
107
|
+
readonly candidate: RunDeletionCandidateV1;
|
|
108
|
+
readonly summary: RunDeletionManifestSummaryV1;
|
|
109
|
+
readonly redaction: RunDeletionManifestRedactionV1;
|
|
110
|
+
}
|
|
111
|
+
export interface RunDeletionManifestInput {
|
|
112
|
+
readonly generatedAt: string;
|
|
113
|
+
readonly mode: RunDeletionManifestMode;
|
|
114
|
+
readonly run: RunDeletionCandidateRunV1;
|
|
115
|
+
readonly request: RunDeletionManifestRequestV1;
|
|
116
|
+
readonly candidate?: RunDeletionCandidateV1;
|
|
117
|
+
readonly policy?: RunRetentionPolicyV1 | RunRetentionPolicyInput;
|
|
118
|
+
readonly counts?: readonly RunDeletionCountV1[];
|
|
119
|
+
}
|
|
120
|
+
export interface RunDeletionManifestProofV1 {
|
|
121
|
+
readonly status: RunDeletionWriteStatus;
|
|
122
|
+
readonly mode?: RunDeletionManifestMode;
|
|
123
|
+
readonly writtenAt?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface RunDeletionPurgeProofV1 {
|
|
126
|
+
readonly status: RunDeletionProofStatus;
|
|
127
|
+
readonly startedAt?: string;
|
|
128
|
+
readonly completedAt?: string;
|
|
129
|
+
readonly deletedObjectCount?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface RunDeletionOrderProofV1 {
|
|
132
|
+
readonly manifest: RunDeletionManifestProofV1;
|
|
133
|
+
readonly purge: RunDeletionPurgeProofV1;
|
|
134
|
+
}
|
|
135
|
+
export interface RunDeletionJobV1 {
|
|
136
|
+
readonly schemaVersion: typeof RUN_RETENTION_SCHEMA_VERSION;
|
|
137
|
+
readonly kind: typeof RUN_DELETION_JOB_KIND;
|
|
138
|
+
readonly jobId: string;
|
|
139
|
+
readonly runId: string;
|
|
140
|
+
readonly workspaceId: string;
|
|
141
|
+
readonly reason: RunDeletionReason;
|
|
142
|
+
readonly mode: RunDeletionManifestMode;
|
|
143
|
+
readonly status: RunDeletionJobStatus;
|
|
144
|
+
readonly createdAt: string;
|
|
145
|
+
readonly updatedAt?: string;
|
|
146
|
+
readonly order: RunDeletionOrderProofV1;
|
|
147
|
+
readonly candidate?: RunDeletionCandidateV1;
|
|
148
|
+
readonly summary?: RunDeletionManifestSummaryV1;
|
|
149
|
+
}
|
|
150
|
+
export interface RunDeletionJobInput {
|
|
151
|
+
readonly jobId: string;
|
|
152
|
+
readonly runId: string;
|
|
153
|
+
readonly workspaceId: string;
|
|
154
|
+
readonly reason: RunDeletionReason;
|
|
155
|
+
readonly mode: RunDeletionManifestMode;
|
|
156
|
+
readonly status: RunDeletionJobStatus;
|
|
157
|
+
readonly createdAt: string;
|
|
158
|
+
readonly updatedAt?: string;
|
|
159
|
+
readonly order: RunDeletionOrderProofV1;
|
|
160
|
+
readonly candidate?: RunDeletionCandidateV1;
|
|
161
|
+
readonly summary?: RunDeletionManifestSummaryV1;
|
|
162
|
+
}
|
|
163
|
+
export interface RunDeletionManifestWriteObject {
|
|
164
|
+
readonly runId: string;
|
|
165
|
+
readonly workspaceId: string;
|
|
166
|
+
readonly contentType: typeof RUN_DELETION_MANIFEST_CONTENT_TYPE;
|
|
167
|
+
readonly manifest: RunDeletionManifestV1;
|
|
168
|
+
}
|
|
169
|
+
export interface RunDeletionManifestObjectStore {
|
|
170
|
+
putRunDeletionManifestObject(object: RunDeletionManifestWriteObject): Promise<void>;
|
|
171
|
+
}
|
|
172
|
+
export interface RunDeletionManifestWriteResult {
|
|
173
|
+
readonly status: "written";
|
|
174
|
+
readonly schemaVersion: typeof RUN_RETENTION_SCHEMA_VERSION;
|
|
175
|
+
readonly runId: string;
|
|
176
|
+
readonly workspaceId: string;
|
|
177
|
+
readonly writtenAt: string;
|
|
178
|
+
readonly mode: RunDeletionManifestMode;
|
|
179
|
+
}
|
|
180
|
+
export interface RunDeletionManifestWriter {
|
|
181
|
+
writeRunDeletionManifest(input: RunDeletionManifestInput): Promise<RunDeletionManifestWriteResult>;
|
|
182
|
+
}
|
|
183
|
+
export type RunRetentionRedactionReason = "forbidden_field_name" | "signed_url" | "r2_object_key" | "vault_id" | "private_resource_handle" | "hash_like_value";
|
|
184
|
+
export interface RunRetentionRedactionFinding {
|
|
185
|
+
readonly path: string;
|
|
186
|
+
readonly reason: RunRetentionRedactionReason;
|
|
187
|
+
readonly valueLength?: number;
|
|
188
|
+
}
|
|
189
|
+
export declare class RunRetentionValidationError extends Error {
|
|
190
|
+
readonly code = "run_retention_contract_invalid";
|
|
191
|
+
constructor(message: string);
|
|
192
|
+
}
|
|
193
|
+
export declare class RunRetentionRedactionError extends Error {
|
|
194
|
+
readonly code = "run_retention_payload_not_public_safe";
|
|
195
|
+
readonly findings: readonly RunRetentionRedactionFinding[];
|
|
196
|
+
constructor(findings: readonly RunRetentionRedactionFinding[]);
|
|
197
|
+
}
|
|
198
|
+
export declare class FakeRunDeletionManifestObjectStore implements RunDeletionManifestObjectStore {
|
|
199
|
+
#private;
|
|
200
|
+
putRunDeletionManifestObject(object: RunDeletionManifestWriteObject): Promise<void>;
|
|
201
|
+
getByRunId(runId: string): RunDeletionManifestV1 | undefined;
|
|
202
|
+
get(runId: string): RunDeletionManifestV1 | undefined;
|
|
203
|
+
listRunIds(): readonly string[];
|
|
204
|
+
}
|
|
205
|
+
export declare function createRunDeletionManifestWriter(store: RunDeletionManifestObjectStore): RunDeletionManifestWriter;
|
|
206
|
+
export declare function writeRunDeletionManifest(store: RunDeletionManifestObjectStore, input: RunDeletionManifestInput): Promise<RunDeletionManifestWriteResult>;
|
|
207
|
+
export declare function buildRunRetentionPolicy(input?: RunRetentionPolicyInput): RunRetentionPolicyV1;
|
|
208
|
+
export declare function evaluateRunDeletionCandidate(input: RunDeletionCandidateInput): RunDeletionCandidateV1;
|
|
209
|
+
export declare function buildRunDeletionManifest(input: RunDeletionManifestInput): RunDeletionManifestV1;
|
|
210
|
+
export declare function assertRunDeletionOrder(proof: RunDeletionOrderProofV1): void;
|
|
211
|
+
export declare function buildRunDeletionJob(input: RunDeletionJobInput): RunDeletionJobV1;
|
|
212
|
+
export declare function scanRunRetentionPayloadForSensitiveValues(input: unknown): readonly RunRetentionRedactionFinding[];
|
|
213
|
+
export declare function assertPublicSafeRunRetentionPayload(input: unknown): void;
|