@elie-laloum/outpost 4.1.0 → 4.2.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/CHANGELOG.md +11 -0
- package/README.md +9 -5
- package/SECURITY.md +2 -0
- package/dist/adapters/models/openai-compatible.constants.d.ts +4 -0
- package/dist/adapters/models/openai-compatible.constants.js +10 -0
- package/dist/adapters/models/openai-compatible.constants.js.map +1 -0
- package/dist/adapters/models/openai-compatible.d.ts +3 -0
- package/dist/adapters/models/openai-compatible.js +78 -0
- package/dist/adapters/models/openai-compatible.js.map +1 -0
- package/dist/adapters/models/openai-compatible.types.d.ts +14 -0
- package/dist/adapters/models/openai-compatible.types.js +2 -0
- package/dist/adapters/models/openai-compatible.types.js.map +1 -0
- package/dist/adapters/models/openai-http.d.ts +1 -0
- package/dist/adapters/models/openai-http.js +30 -0
- package/dist/adapters/models/openai-http.js.map +1 -0
- package/dist/adapters/models/openai-request.d.ts +4 -0
- package/dist/adapters/models/openai-request.js +46 -0
- package/dist/adapters/models/openai-request.js.map +1 -0
- package/dist/adapters/models/openai-response.d.ts +3 -0
- package/dist/adapters/models/openai-response.js +65 -0
- package/dist/adapters/models/openai-response.js.map +1 -0
- package/dist/application/execution.types.d.ts +2 -0
- package/dist/application/execution.types.js.map +1 -1
- package/dist/application/outpost.types.d.ts +5 -0
- package/dist/application/outpost.types.js.map +1 -1
- package/dist/application/recovery-archive.d.ts +4 -0
- package/dist/application/recovery-archive.js +29 -0
- package/dist/application/recovery-archive.js.map +1 -0
- package/dist/application/recovery-archive.types.d.ts +10 -0
- package/dist/application/recovery-archive.types.js +2 -0
- package/dist/application/recovery-archive.types.js.map +1 -0
- package/dist/application/recovery-inspection.js +3 -0
- package/dist/application/recovery-inspection.js.map +1 -1
- package/dist/application/recovery-inspection.types.d.ts +2 -0
- package/dist/application/recovery-inspection.types.js.map +1 -1
- package/dist/application/recovery-retention.d.ts +2 -1
- package/dist/application/recovery-retention.js +9 -1
- package/dist/application/recovery-retention.js.map +1 -1
- package/dist/application/recovery-retention.types.d.ts +6 -0
- package/dist/application/recovery-retention.types.js.map +1 -1
- package/dist/application/remote-backup.js +8 -0
- package/dist/application/remote-backup.js.map +1 -1
- package/dist/application/remote-workspace.types.d.ts +2 -0
- package/dist/application/remote-workspace.types.js.map +1 -1
- package/dist/application/sandbox-agents.js +2 -1
- package/dist/application/sandbox-agents.js.map +1 -1
- package/dist/application/sandbox-dispatch.js +9 -0
- package/dist/application/sandbox-dispatch.js.map +1 -1
- package/dist/application/sandbox-provision.js +6 -0
- package/dist/application/sandbox-provision.js.map +1 -1
- package/dist/application/storage-reservation.js +3 -0
- package/dist/application/storage-reservation.js.map +1 -1
- package/dist/application/transport-inspection.constants.d.ts +2 -0
- package/dist/application/transport-inspection.constants.js +10 -0
- package/dist/application/transport-inspection.constants.js.map +1 -0
- package/dist/application/transport-inspection.d.ts +2 -0
- package/dist/application/transport-inspection.js +103 -0
- package/dist/application/transport-inspection.js.map +1 -0
- package/dist/application/transport-retention.d.ts +4 -0
- package/dist/application/transport-retention.js +153 -0
- package/dist/application/transport-retention.js.map +1 -0
- package/dist/domain/conversation.types.d.ts +2 -0
- package/dist/domain/conversation.types.js.map +1 -1
- package/dist/domain/model.types.d.ts +15 -0
- package/dist/domain/model.types.js +2 -0
- package/dist/domain/model.types.js.map +1 -0
- package/dist/domain/transport.constants.d.ts +2 -0
- package/dist/domain/transport.constants.js +3 -0
- package/dist/domain/transport.constants.js.map +1 -0
- package/dist/domain/transport.d.ts +6 -0
- package/dist/domain/transport.js +21 -0
- package/dist/domain/transport.js.map +1 -0
- package/dist/domain/transport.types.d.ts +31 -0
- package/dist/domain/transport.types.js +2 -0
- package/dist/domain/transport.types.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/artifact-store.js +10 -0
- package/dist/infrastructure/artifact-store.js.map +1 -1
- package/dist/infrastructure/artifact-store.types.d.ts +3 -1
- package/dist/infrastructure/artifact-store.types.js.map +1 -1
- package/dist/infrastructure/conversations/capture.js +1 -1
- package/dist/infrastructure/conversations/capture.js.map +1 -1
- package/dist/infrastructure/conversations.d.ts +2 -0
- package/dist/infrastructure/conversations.js +2 -0
- package/dist/infrastructure/conversations.js.map +1 -1
- package/dist/infrastructure/inspection-file.js +3 -3
- package/dist/infrastructure/inspection-file.js.map +1 -1
- package/dist/infrastructure/inspection-hash.js +4 -3
- package/dist/infrastructure/inspection-hash.js.map +1 -1
- package/dist/infrastructure/inspection-path.d.ts +1 -0
- package/dist/infrastructure/inspection-path.js +18 -0
- package/dist/infrastructure/inspection-path.js.map +1 -0
- package/dist/infrastructure/journal.js +6 -0
- package/dist/infrastructure/journal.js.map +1 -1
- package/dist/infrastructure/journal.types.d.ts +3 -0
- package/dist/infrastructure/journal.types.js.map +1 -1
- package/dist/infrastructure/local-transport.d.ts +3 -0
- package/dist/infrastructure/local-transport.js +146 -0
- package/dist/infrastructure/local-transport.js.map +1 -0
- package/dist/infrastructure/local-transport.types.d.ts +3 -0
- package/dist/infrastructure/local-transport.types.js +2 -0
- package/dist/infrastructure/local-transport.types.js.map +1 -0
- package/dist/infrastructure/resource-activity-inspection.d.ts +2 -1
- package/dist/infrastructure/resource-activity-inspection.js +2 -2
- package/dist/infrastructure/resource-activity-inspection.js.map +1 -1
- package/dist/infrastructure/resource-activity.js +42 -14
- package/dist/infrastructure/resource-activity.js.map +1 -1
- package/dist/infrastructure/resource-activity.types.d.ts +2 -0
- package/dist/infrastructure/resource-activity.types.js.map +1 -1
- package/dist/infrastructure/s3-transport.d.ts +4 -0
- package/dist/infrastructure/s3-transport.js +144 -0
- package/dist/infrastructure/s3-transport.js.map +1 -0
- package/dist/infrastructure/s3-transport.types.d.ts +6 -0
- package/dist/infrastructure/s3-transport.types.js +2 -0
- package/dist/infrastructure/s3-transport.types.js.map +1 -0
- package/dist/infrastructure/storage-inventory.types.d.ts +2 -1
- package/dist/infrastructure/storage-inventory.types.js.map +1 -1
- package/dist/infrastructure/storage-reservations.types.d.ts +2 -0
- package/dist/infrastructure/storage-reservations.types.js.map +1 -1
- package/dist/infrastructure/task-queue-bullmq-resources.d.ts +13 -0
- package/dist/infrastructure/task-queue-bullmq-resources.js +118 -0
- package/dist/infrastructure/task-queue-bullmq-resources.js.map +1 -0
- package/dist/infrastructure/task-queue-bullmq-state.d.ts +5 -0
- package/dist/infrastructure/task-queue-bullmq-state.js +26 -0
- package/dist/infrastructure/task-queue-bullmq-state.js.map +1 -0
- package/dist/infrastructure/task-queue-bullmq.constants.d.ts +7 -0
- package/dist/infrastructure/task-queue-bullmq.constants.js +79 -0
- package/dist/infrastructure/task-queue-bullmq.constants.js.map +1 -0
- package/dist/infrastructure/task-queue-bullmq.d.ts +3 -0
- package/dist/infrastructure/task-queue-bullmq.js +124 -0
- package/dist/infrastructure/task-queue-bullmq.js.map +1 -0
- package/dist/infrastructure/task-queue-bullmq.types.d.ts +17 -0
- package/dist/infrastructure/task-queue-bullmq.types.js +2 -0
- package/dist/infrastructure/task-queue-bullmq.types.js.map +1 -0
- package/dist/infrastructure/transport-archive.constants.d.ts +6 -0
- package/dist/infrastructure/transport-archive.constants.js +7 -0
- package/dist/infrastructure/transport-archive.constants.js.map +1 -0
- package/dist/infrastructure/transport-archive.d.ts +5 -0
- package/dist/infrastructure/transport-archive.js +157 -0
- package/dist/infrastructure/transport-archive.js.map +1 -0
- package/dist/infrastructure/transport-archive.types.d.ts +17 -0
- package/dist/infrastructure/transport-archive.types.js +2 -0
- package/dist/infrastructure/transport-archive.types.js.map +1 -0
- package/dist/infrastructure/transport-artifact-store.d.ts +3 -0
- package/dist/infrastructure/transport-artifact-store.js +31 -0
- package/dist/infrastructure/transport-artifact-store.js.map +1 -0
- package/dist/infrastructure/transport-artifact-store.types.d.ts +4 -0
- package/dist/infrastructure/transport-artifact-store.types.js +2 -0
- package/dist/infrastructure/transport-artifact-store.types.js.map +1 -0
- package/dist/infrastructure/transport-checkpoint.d.ts +5 -0
- package/dist/infrastructure/transport-checkpoint.js +105 -0
- package/dist/infrastructure/transport-checkpoint.js.map +1 -0
- package/dist/infrastructure/transport-checkpoint.types.d.ts +9 -0
- package/dist/infrastructure/transport-checkpoint.types.js +2 -0
- package/dist/infrastructure/transport-checkpoint.types.js.map +1 -0
- package/dist/infrastructure/transport-conversations.d.ts +4 -0
- package/dist/infrastructure/transport-conversations.js +69 -0
- package/dist/infrastructure/transport-conversations.js.map +1 -0
- package/dist/infrastructure/transport-conversations.types.d.ts +4 -0
- package/dist/infrastructure/transport-conversations.types.js +2 -0
- package/dist/infrastructure/transport-conversations.types.js.map +1 -0
- package/dist/infrastructure/transport-envelope.d.ts +7 -0
- package/dist/infrastructure/transport-envelope.js +47 -0
- package/dist/infrastructure/transport-envelope.js.map +1 -0
- package/dist/infrastructure/transport-journal.d.ts +6 -0
- package/dist/infrastructure/transport-journal.js +93 -0
- package/dist/infrastructure/transport-journal.js.map +1 -0
- package/dist/infrastructure/transport-journal.types.d.ts +10 -0
- package/dist/infrastructure/transport-journal.types.js +2 -0
- package/dist/infrastructure/transport-journal.types.js.map +1 -0
- package/dist/infrastructure/transport-json.d.ts +6 -0
- package/dist/infrastructure/transport-json.js +46 -0
- package/dist/infrastructure/transport-json.js.map +1 -0
- package/dist/infrastructure/transport-reservations.d.ts +5 -0
- package/dist/infrastructure/transport-reservations.js +89 -0
- package/dist/infrastructure/transport-reservations.js.map +1 -0
- package/dist/infrastructure/transport-reservations.types.d.ts +4 -0
- package/dist/infrastructure/transport-reservations.types.js +2 -0
- package/dist/infrastructure/transport-reservations.types.js.map +1 -0
- package/dist/infrastructure/transport.constants.d.ts +8 -0
- package/dist/infrastructure/transport.constants.js +9 -0
- package/dist/infrastructure/transport.constants.js.map +1 -0
- package/dist/infrastructure/workflow-checkpoint.js +7 -0
- package/dist/infrastructure/workflow-checkpoint.js.map +1 -1
- package/dist/infrastructure/workflow-checkpoint.types.d.ts +3 -1
- package/dist/infrastructure/workflow-checkpoint.types.js.map +1 -1
- package/package.json +26 -5
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { transportDefaults } from "../infrastructure/transport.constants.js";
|
|
2
|
+
import { resourceRecord } from "../infrastructure/resource-activity-inspection.js";
|
|
3
|
+
import { jsonObject } from "../infrastructure/transport-json.js";
|
|
4
|
+
import { invariant, positive } from "../domain/errors.js";
|
|
5
|
+
import { transportCategories } from "./transport-inspection.constants.js";
|
|
6
|
+
export async function inspectTransportRecovery(options) {
|
|
7
|
+
const transporter = options.transporter;
|
|
8
|
+
invariant(transporter, "Transport is required");
|
|
9
|
+
invariant(!options.git && !options.locks, "Transport inspection cannot verify host Git or process locks");
|
|
10
|
+
const maxEntries = positive(options.maxEntries ?? transportDefaults.maxEntries, "maxEntries");
|
|
11
|
+
const buckets = transportCategories.map((name) => ({
|
|
12
|
+
name,
|
|
13
|
+
path: name,
|
|
14
|
+
entries: [],
|
|
15
|
+
}));
|
|
16
|
+
const categories = buckets;
|
|
17
|
+
const usage = {
|
|
18
|
+
bytes: 0,
|
|
19
|
+
files: 0,
|
|
20
|
+
directories: 0,
|
|
21
|
+
symlinks: 0,
|
|
22
|
+
other: 0,
|
|
23
|
+
};
|
|
24
|
+
const issues = [];
|
|
25
|
+
const resources = [];
|
|
26
|
+
let scannedEntries = 0, complete = true;
|
|
27
|
+
for await (const entry of transporter.list()) {
|
|
28
|
+
if (scannedEntries >= maxEntries) {
|
|
29
|
+
complete = false;
|
|
30
|
+
issues.push({ path: "", code: "ENTRY_LIMIT" });
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
scannedEntries++;
|
|
34
|
+
const name = entry.key.split("/")[0];
|
|
35
|
+
const category = buckets.find((category) => category.name === name);
|
|
36
|
+
if (!category) {
|
|
37
|
+
complete = false;
|
|
38
|
+
issues.push({ path: entry.key, code: "UNKNOWN_TRANSPORT_CATEGORY" });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const stored = {
|
|
42
|
+
name: entry.key,
|
|
43
|
+
path: entry.key,
|
|
44
|
+
kind: "file",
|
|
45
|
+
modifiedAt: entry.modifiedAt,
|
|
46
|
+
complete: true,
|
|
47
|
+
bytes: entry.size,
|
|
48
|
+
files: 1,
|
|
49
|
+
directories: 0,
|
|
50
|
+
symlinks: 0,
|
|
51
|
+
other: 0,
|
|
52
|
+
revision: entry.revision,
|
|
53
|
+
};
|
|
54
|
+
category.entries.push(stored);
|
|
55
|
+
usage.bytes += entry.size;
|
|
56
|
+
usage.files++;
|
|
57
|
+
if (options.resources && name === "resources") {
|
|
58
|
+
try {
|
|
59
|
+
const object = await transporter.read(entry.key);
|
|
60
|
+
invariant(object?.revision === entry.revision, "Resource changed during inspection");
|
|
61
|
+
const record = resourceRecord(jsonObject(object));
|
|
62
|
+
resources.push({
|
|
63
|
+
path: entry.key,
|
|
64
|
+
record,
|
|
65
|
+
ownership: { status: "unknown", reason: "REMOTE_OWNER_UNVERIFIED" },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
issues.push({ path: entry.key, code: "RESOURCE_RECORD_UNREADABLE" });
|
|
70
|
+
complete = false;
|
|
71
|
+
resources.push({
|
|
72
|
+
path: entry.key,
|
|
73
|
+
ownership: {
|
|
74
|
+
status: "unknown",
|
|
75
|
+
reason: "RESOURCE_RECORD_UNREADABLE",
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
repository: options.repository ?? "",
|
|
83
|
+
root: "transport",
|
|
84
|
+
activity: "unverified",
|
|
85
|
+
categories,
|
|
86
|
+
usage,
|
|
87
|
+
issues,
|
|
88
|
+
complete,
|
|
89
|
+
scannedEntries,
|
|
90
|
+
maxEntries,
|
|
91
|
+
...(options.resources
|
|
92
|
+
? {
|
|
93
|
+
resources: {
|
|
94
|
+
scope: "recorded-sandboxes",
|
|
95
|
+
complete,
|
|
96
|
+
entries: resources,
|
|
97
|
+
issues,
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
: {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=transport-inspection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-inspection.js","sourceRoot":"","sources":["../../src/application/transport-inspection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAW7E,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAkC;IAElC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACxC,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IAChD,SAAS,CACP,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAC9B,8DAA8D,CAC/D,CAAC;IACF,MAAM,UAAU,GAAG,QAAQ,CACzB,OAAO,CAAC,UAAU,IAAI,iBAAiB,CAAC,UAAU,EAClD,YAAY,CACb,CAAC;IACF,MAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI;QACJ,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,EAAoB;KAC9B,CAAC,CAAC,CAAC;IACJ,MAAM,UAAU,GAAsB,OAAO,CAAC;IAC9C,MAAM,KAAK,GAAiB;QAC1B,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,CAAC;QACR,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,CAAC;KACT,CA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E,SAAS,EAAE;oBACT,KAAK,EAAE,oBAAoB;oBAC3B,QAAQ;oBACR,OAAO,EAAE,SAAS;oBAClB,MAAM;iBACP;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { transportDefaults } from \"../infrastructure/transport.constants.ts\";\nimport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./recovery-inspection.types.ts\";\nimport type {\n StorageCategory,\n StorageEntry,\n StorageUsage,\n} from \"../infrastructure/storage-inventory.types.ts\";\nimport type { ResourceInspectionEntry } from \"../infrastructure/resource-activity.types.ts\";\nimport { resourceRecord } from \"../infrastructure/resource-activity-inspection.ts\";\nimport { jsonObject } from \"../infrastructure/transport-json.ts\";\nimport { invariant, positive } from \"../domain/errors.ts\";\nimport { transportCategories } from \"./transport-inspection.constants.ts\";\n\nexport async function inspectTransportRecovery(\n options: RecoveryInspectionOptions,\n): Promise<RecoveryInspection> {\n const transporter = options.transporter;\n invariant(transporter, \"Transport is required\");\n invariant(\n !options.git && !options.locks,\n \"Transport inspection cannot verify host Git or process locks\",\n );\n const maxEntries = positive(\n options.maxEntries ?? transportDefaults.maxEntries,\n \"maxEntries\",\n );\n const buckets = transportCategories.map((name) => ({\n name,\n path: name,\n entries: [] as StorageEntry[],\n }));\n const categories: StorageCategory[] = buckets;\n const usage: StorageUsage = {\n bytes: 0,\n files: 0,\n directories: 0,\n symlinks: 0,\n other: 0,\n };\n const issues = [];\n const resources: ResourceInspectionEntry[] = [];\n let scannedEntries = 0,\n complete = true;\n for await (const entry of transporter.list()) {\n if (scannedEntries >= maxEntries) {\n complete = false;\n issues.push({ path: \"\", code: \"ENTRY_LIMIT\" });\n break;\n }\n scannedEntries++;\n const name = entry.key.split(\"/\")[0];\n const category = buckets.find((category) => category.name === name);\n if (!category) {\n complete = false;\n issues.push({ path: entry.key, code: \"UNKNOWN_TRANSPORT_CATEGORY\" });\n continue;\n }\n const stored = {\n name: entry.key,\n path: entry.key,\n kind: \"file\" as const,\n modifiedAt: entry.modifiedAt,\n complete: true,\n bytes: entry.size,\n files: 1,\n directories: 0,\n symlinks: 0,\n other: 0,\n revision: entry.revision,\n };\n category.entries.push(stored);\n usage.bytes += entry.size;\n usage.files++;\n if (options.resources && name === \"resources\") {\n try {\n const object = await transporter.read(entry.key);\n invariant(\n object?.revision === entry.revision,\n \"Resource changed during inspection\",\n );\n const record = resourceRecord(jsonObject(object));\n resources.push({\n path: entry.key,\n record,\n ownership: { status: \"unknown\", reason: \"REMOTE_OWNER_UNVERIFIED\" },\n });\n } catch {\n issues.push({ path: entry.key, code: \"RESOURCE_RECORD_UNREADABLE\" });\n complete = false;\n resources.push({\n path: entry.key,\n ownership: {\n status: \"unknown\",\n reason: \"RESOURCE_RECORD_UNREADABLE\",\n },\n });\n }\n }\n }\n return {\n repository: options.repository ?? \"\",\n root: \"transport\",\n activity: \"unverified\",\n categories,\n usage,\n issues,\n complete,\n scannedEntries,\n maxEntries,\n ...(options.resources\n ? {\n resources: {\n scope: \"recorded-sandboxes\",\n complete,\n entries: resources,\n issues,\n },\n }\n : {}),\n };\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TransportStoreOptions } from "../domain/transport.types.ts";
|
|
2
|
+
import type { RecoveryRetentionOptions, RecoveryRetentionPlan, RecoveryPruneResult } from "./recovery-retention.types.ts";
|
|
3
|
+
export declare function planTransportRetention(options: RecoveryRetentionOptions): Promise<RecoveryRetentionPlan>;
|
|
4
|
+
export declare function pruneTransportRetention(plan: RecoveryRetentionPlan, options: TransportStoreOptions): Promise<RecoveryPruneResult>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { invariant } from "../domain/errors.js";
|
|
2
|
+
import { inspectTransportRecovery } from "./transport-inspection.js";
|
|
3
|
+
import { journalSnapshot } from "../infrastructure/transport-journal.js";
|
|
4
|
+
import { jsonObject } from "../infrastructure/transport-json.js";
|
|
5
|
+
import { retentionPolicy } from "./recovery-retention-policy.js";
|
|
6
|
+
export async function planTransportRetention(options) {
|
|
7
|
+
const transporter = options.transporter;
|
|
8
|
+
invariant(transporter, "Transport is required");
|
|
9
|
+
retentionPolicy(options.policy);
|
|
10
|
+
invariant(!options.policy.scopes.includes("clean-workspaces") &&
|
|
11
|
+
options.policy.maxWorkspaces === undefined, "Transport retention cannot inspect local workspaces");
|
|
12
|
+
const inspection = await inspectTransportRecovery(options);
|
|
13
|
+
const inspectedAt = new Date().toISOString();
|
|
14
|
+
const entries = [];
|
|
15
|
+
const handled = new Set();
|
|
16
|
+
for (const category of inspection.categories) {
|
|
17
|
+
for (const entry of category.entries) {
|
|
18
|
+
if (handled.has(entry.path))
|
|
19
|
+
continue;
|
|
20
|
+
let eligible = false, reason = "RECOVERY_DATA_PROTECTED";
|
|
21
|
+
let objects = [];
|
|
22
|
+
if (category.name === "logs") {
|
|
23
|
+
const prefix = entry.path.slice(0, entry.path.lastIndexOf("/") + 1);
|
|
24
|
+
const group = category.entries.filter((value) => value.path.startsWith(prefix));
|
|
25
|
+
objects = group.map((value) => {
|
|
26
|
+
invariant(value.revision && value.modifiedAt, "Missing transport entry version");
|
|
27
|
+
return {
|
|
28
|
+
key: value.path,
|
|
29
|
+
revision: value.revision,
|
|
30
|
+
size: value.bytes,
|
|
31
|
+
modifiedAt: value.modifiedAt,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
for (const object of objects)
|
|
35
|
+
handled.add(object.key);
|
|
36
|
+
const index = group.find((value) => value.path === prefix + "index");
|
|
37
|
+
reason = "LOG_ACTIVITY_OR_CONTENT_UNKNOWN";
|
|
38
|
+
if (index && options.policy.scopes.includes("closed-logs")) {
|
|
39
|
+
try {
|
|
40
|
+
const current = await transporter.read(index.path);
|
|
41
|
+
if (current?.revision === index.revision &&
|
|
42
|
+
journalSnapshot(jsonObject(current)).closed) {
|
|
43
|
+
eligible =
|
|
44
|
+
inspection.complete &&
|
|
45
|
+
objects.every((value) => Date.parse(inspectedAt) - Date.parse(value.modifiedAt) >=
|
|
46
|
+
options.policy.minAgeMs);
|
|
47
|
+
reason = eligible
|
|
48
|
+
? "ELIGIBLE"
|
|
49
|
+
: "RETENTION_AGE_OR_INCOMPLETE_INVENTORY";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
reason = "LOG_ACTIVITY_OR_CONTENT_UNKNOWN";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const indexObject = objects.find((value) => value.key === prefix + "index");
|
|
57
|
+
entries.push({
|
|
58
|
+
path: prefix + "index",
|
|
59
|
+
category: category.name,
|
|
60
|
+
bytes: objects.reduce((sum, value) => sum + value.size, 0),
|
|
61
|
+
eligible,
|
|
62
|
+
reason,
|
|
63
|
+
objects,
|
|
64
|
+
...(indexObject
|
|
65
|
+
? {
|
|
66
|
+
revision: indexObject.revision,
|
|
67
|
+
modifiedAt: indexObject.modifiedAt,
|
|
68
|
+
}
|
|
69
|
+
: {}),
|
|
70
|
+
});
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
entries.push({
|
|
74
|
+
path: entry.path,
|
|
75
|
+
category: category.name,
|
|
76
|
+
bytes: entry.bytes,
|
|
77
|
+
eligible,
|
|
78
|
+
reason,
|
|
79
|
+
...(entry.revision ? { revision: entry.revision } : {}),
|
|
80
|
+
...(entry.modifiedAt ? { modifiedAt: entry.modifiedAt } : {}),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const projectedBytes = inspection.usage.bytes -
|
|
85
|
+
entries
|
|
86
|
+
.filter((entry) => entry.eligible)
|
|
87
|
+
.reduce((sum, entry) => sum + entry.bytes, 0);
|
|
88
|
+
return {
|
|
89
|
+
repository: inspection.repository,
|
|
90
|
+
source: "transport",
|
|
91
|
+
policy: structuredClone(options.policy),
|
|
92
|
+
inspectedAt,
|
|
93
|
+
inspection,
|
|
94
|
+
entries,
|
|
95
|
+
complete: inspection.complete,
|
|
96
|
+
usageBytes: inspection.usage.bytes,
|
|
97
|
+
projectedBytes,
|
|
98
|
+
quota: !inspection.complete
|
|
99
|
+
? "unknown"
|
|
100
|
+
: options.policy.maxBytes !== undefined &&
|
|
101
|
+
projectedBytes > options.policy.maxBytes
|
|
102
|
+
? "exceeded"
|
|
103
|
+
: "within",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export async function pruneTransportRetention(plan, options) {
|
|
107
|
+
invariant(plan.complete, "Cannot prune an incomplete retention plan");
|
|
108
|
+
retentionPolicy(plan.policy);
|
|
109
|
+
const removed = [], retained = [];
|
|
110
|
+
for (const candidate of plan.entries.filter((entry) => entry.eligible)) {
|
|
111
|
+
const fresh = await planTransportRetention({
|
|
112
|
+
transporter: options.transporter,
|
|
113
|
+
policy: plan.policy,
|
|
114
|
+
repository: plan.repository,
|
|
115
|
+
});
|
|
116
|
+
const entry = fresh.entries.find((entry) => entry.path === candidate.path);
|
|
117
|
+
if (!entry?.eligible ||
|
|
118
|
+
entry.revision !== candidate.revision ||
|
|
119
|
+
JSON.stringify(entry.objects) !== JSON.stringify(candidate.objects)) {
|
|
120
|
+
retained.push({ path: candidate.path, reason: "PLAN_CHANGED" });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
invariant(entry.revision && entry.objects, "Missing log revisions");
|
|
125
|
+
await options.transporter.remove(entry.path, {
|
|
126
|
+
ifRevision: entry.revision,
|
|
127
|
+
});
|
|
128
|
+
for (const object of entry.objects) {
|
|
129
|
+
if (object.key !== entry.path)
|
|
130
|
+
await options.transporter.remove(object.key, {
|
|
131
|
+
ifRevision: object.revision,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
removed.push(entry.path);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
retained.push({
|
|
138
|
+
path: entry.path,
|
|
139
|
+
reason: "REVALIDATION_OR_REMOVAL_FAILED",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
removed,
|
|
145
|
+
retained,
|
|
146
|
+
after: await planTransportRetention({
|
|
147
|
+
transporter: options.transporter,
|
|
148
|
+
policy: plan.policy,
|
|
149
|
+
repository: plan.repository,
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=transport-retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-retention.js","sourceRoot":"","sources":["../../src/application/transport-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAWhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAiC;IAEjC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACxC,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IAChD,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,SAAS,CACP,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QACjD,OAAO,CAAC,MAAM,CAAC,aAAa,KAAK,SAAS,EAC5C,qDAAqD,CACtD,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,MAAM,OAAO,GAA6B,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QAC7C,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BAAuB,CAAC,CAAC;YACpE,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;gBAC3C,UAAU,EAAE,KAAK,CAAC,QAAQ;aAC3B,CAAC,CAAC;YACH,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBACnC,IAAI,MAAM,CAAC,GAAG,KAAK,KAAK,CAAC,IAAI;oBAC3B,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;wBAC3C,UAAU,EAAE,MAAM,CAAC,QAAQ;qBAC5B,CAAC,CAAC;YACP,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,gCAAgC;aACzC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO;QACL,OAAO;QACP,QAAQ;QACR,KAAK,EAAE,MAAM,sBAAsB,CAAC;YAClC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../domain/errors.ts\";\nimport type {\n TransportStoreOptions,\n TransportEntry,\n} from \"../domain/transport.types.ts\";\nimport type {\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n} from \"./recovery-retention.types.ts\";\nimport { inspectTransportRecovery } from \"./transport-inspection.ts\";\nimport { journalSnapshot } from \"../infrastructure/transport-journal.ts\";\nimport { jsonObject } from \"../infrastructure/transport-json.ts\";\nimport { retentionPolicy } from \"./recovery-retention-policy.ts\";\n\nexport async function planTransportRetention(\n options: RecoveryRetentionOptions,\n): Promise<RecoveryRetentionPlan> {\n const transporter = options.transporter;\n invariant(transporter, \"Transport is required\");\n retentionPolicy(options.policy);\n invariant(\n !options.policy.scopes.includes(\"clean-workspaces\") &&\n options.policy.maxWorkspaces === undefined,\n \"Transport retention cannot inspect local workspaces\",\n );\n const inspection = await inspectTransportRecovery(options);\n const inspectedAt = new Date().toISOString();\n const entries: RecoveryRetentionEntry[] = [];\n const handled = new Set<string>();\n for (const category of inspection.categories) {\n for (const entry of category.entries) {\n if (handled.has(entry.path)) continue;\n let eligible = false,\n reason = \"RECOVERY_DATA_PROTECTED\";\n let objects: TransportEntry[] = [];\n if (category.name === \"logs\") {\n const prefix = entry.path.slice(0, entry.path.lastIndexOf(\"/\") + 1);\n const group = category.entries.filter((value) =>\n value.path.startsWith(prefix),\n );\n objects = group.map((value) => {\n invariant(\n value.revision && value.modifiedAt,\n \"Missing transport entry version\",\n );\n return {\n key: value.path,\n revision: value.revision,\n size: value.bytes,\n modifiedAt: value.modifiedAt,\n };\n });\n for (const object of objects) handled.add(object.key);\n const index = group.find((value) => value.path === prefix + \"index\");\n reason = \"LOG_ACTIVITY_OR_CONTENT_UNKNOWN\";\n if (index && options.policy.scopes.includes(\"closed-logs\")) {\n try {\n const current = await transporter.read(index.path);\n if (\n current?.revision === index.revision &&\n journalSnapshot(jsonObject(current)).closed\n ) {\n eligible =\n inspection.complete &&\n objects.every(\n (value) =>\n Date.parse(inspectedAt) - Date.parse(value.modifiedAt) >=\n options.policy.minAgeMs,\n );\n reason = eligible\n ? \"ELIGIBLE\"\n : \"RETENTION_AGE_OR_INCOMPLETE_INVENTORY\";\n }\n } catch {\n reason = \"LOG_ACTIVITY_OR_CONTENT_UNKNOWN\";\n }\n }\n const indexObject = objects.find(\n (value) => value.key === prefix + \"index\",\n );\n entries.push({\n path: prefix + \"index\",\n category: category.name,\n bytes: objects.reduce((sum, value) => sum + value.size, 0),\n eligible,\n reason,\n objects,\n ...(indexObject\n ? {\n revision: indexObject.revision,\n modifiedAt: indexObject.modifiedAt,\n }\n : {}),\n });\n continue;\n }\n entries.push({\n path: entry.path,\n category: category.name,\n bytes: entry.bytes,\n eligible,\n reason,\n ...(entry.revision ? { revision: entry.revision } : {}),\n ...(entry.modifiedAt ? { modifiedAt: entry.modifiedAt } : {}),\n });\n }\n }\n const projectedBytes =\n inspection.usage.bytes -\n entries\n .filter((entry) => entry.eligible)\n .reduce((sum, entry) => sum + entry.bytes, 0);\n return {\n repository: inspection.repository,\n source: \"transport\",\n policy: structuredClone(options.policy),\n inspectedAt,\n inspection,\n entries,\n complete: inspection.complete,\n usageBytes: inspection.usage.bytes,\n projectedBytes,\n quota: !inspection.complete\n ? \"unknown\"\n : options.policy.maxBytes !== undefined &&\n projectedBytes > options.policy.maxBytes\n ? \"exceeded\"\n : \"within\",\n };\n}\n\nexport async function pruneTransportRetention(\n plan: RecoveryRetentionPlan,\n options: TransportStoreOptions,\n): Promise<RecoveryPruneResult> {\n invariant(plan.complete, \"Cannot prune an incomplete retention plan\");\n retentionPolicy(plan.policy);\n const removed: string[] = [],\n retained = [];\n for (const candidate of plan.entries.filter((entry) => entry.eligible)) {\n const fresh = await planTransportRetention({\n transporter: options.transporter,\n policy: plan.policy,\n repository: plan.repository,\n });\n const entry = fresh.entries.find((entry) => entry.path === candidate.path);\n if (\n !entry?.eligible ||\n entry.revision !== candidate.revision ||\n JSON.stringify(entry.objects) !== JSON.stringify(candidate.objects)\n ) {\n retained.push({ path: candidate.path, reason: \"PLAN_CHANGED\" });\n continue;\n }\n try {\n invariant(entry.revision && entry.objects, \"Missing log revisions\");\n await options.transporter.remove(entry.path, {\n ifRevision: entry.revision,\n });\n for (const object of entry.objects) {\n if (object.key !== entry.path)\n await options.transporter.remove(object.key, {\n ifRevision: object.revision,\n });\n }\n removed.push(entry.path);\n } catch {\n retained.push({\n path: entry.path,\n reason: \"REVALIDATION_OR_REMOVAL_FAILED\",\n });\n }\n }\n return {\n removed,\n retained,\n after: await planTransportRetention({\n transporter: options.transporter,\n policy: plan.policy,\n repository: plan.repository,\n }),\n };\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { TransportReference } from "./transport.types.ts";
|
|
1
2
|
import type { SandboxLease } from "./sandbox.types.ts";
|
|
2
3
|
export interface ConversationRecord {
|
|
3
4
|
readonly id: string;
|
|
4
5
|
readonly file: string;
|
|
6
|
+
readonly reference?: TransportReference;
|
|
5
7
|
readonly format: string;
|
|
6
8
|
}
|
|
7
9
|
export interface ConversationContext {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.types.js","sourceRoot":"","sources":["../../src/domain/conversation.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SandboxLease } from \"./sandbox.types.ts\";\n\nexport interface ConversationRecord {\n readonly id: string;\n readonly file: string;\n readonly format: string;\n}\n\nexport interface ConversationContext {\n readonly repository: string;\n readonly sandbox: SandboxLease;\n readonly staging: string;\n readonly home?: string;\n readonly local?: boolean;\n readonly warn?: (message: string) => void;\n}\n\nexport interface ConversationStore {\n readonly name: string;\n locate(\n id: string,\n repository: string,\n home?: string,\n ): Promise<ConversationRecord>;\n capture(\n id: string,\n context: ConversationContext,\n ): Promise<ConversationRecord>;\n restore(\n record: ConversationRecord,\n context: ConversationContext,\n ): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"conversation.types.js","sourceRoot":"","sources":["../../src/domain/conversation.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TransportReference } from \"./transport.types.ts\";\nimport type { SandboxLease } from \"./sandbox.types.ts\";\n\nexport interface ConversationRecord {\n readonly id: string;\n readonly file: string;\n readonly reference?: TransportReference;\n readonly format: string;\n}\n\nexport interface ConversationContext {\n readonly repository: string;\n readonly sandbox: SandboxLease;\n readonly staging: string;\n readonly home?: string;\n readonly local?: boolean;\n readonly warn?: (message: string) => void;\n}\n\nexport interface ConversationStore {\n readonly name: string;\n locate(\n id: string,\n repository: string,\n home?: string,\n ): Promise<ConversationRecord>;\n capture(\n id: string,\n context: ConversationContext,\n ): Promise<ConversationRecord>;\n restore(\n record: ConversationRecord,\n context: ConversationContext,\n ): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Usage } from "./agent.types.ts";
|
|
2
|
+
export interface ModelRequest {
|
|
3
|
+
readonly prompt: string;
|
|
4
|
+
readonly system?: string;
|
|
5
|
+
readonly maxOutputTokens?: number;
|
|
6
|
+
readonly signal?: AbortSignal;
|
|
7
|
+
}
|
|
8
|
+
export interface ModelResult {
|
|
9
|
+
readonly text: string;
|
|
10
|
+
readonly usage?: Usage;
|
|
11
|
+
}
|
|
12
|
+
export interface ModelProvider {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
generate(request: ModelRequest): Promise<ModelResult>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.types.js","sourceRoot":"","sources":["../../src/domain/model.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Usage } from \"./agent.types.ts\";\n\nexport interface ModelRequest {\n readonly prompt: string;\n readonly system?: string;\n readonly maxOutputTokens?: number;\n readonly signal?: AbortSignal;\n}\n\nexport interface ModelResult {\n readonly text: string;\n readonly usage?: Usage;\n}\n\nexport interface ModelProvider {\n readonly name: string;\n generate(request: ModelRequest): Promise<ModelResult>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.constants.js","sourceRoot":"","sources":["../../src/domain/transport.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,gCAAgC,CAAC","sourcesContent":["export const transportKeyMaxLength = 512;\nexport const transportSegmentPattern = /^[A-Za-z0-9_-][A-Za-z0-9_.-]*$/;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { transportKeyMaxLength, transportSegmentPattern, } from "./transport.constants.js";
|
|
2
|
+
export class TransportConflict extends Error {
|
|
3
|
+
key;
|
|
4
|
+
constructor(key) {
|
|
5
|
+
super(`Transport revision conflict: ${key}`);
|
|
6
|
+
this.name = "TransportConflict";
|
|
7
|
+
this.key = key;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function transportKey(key) {
|
|
11
|
+
if (!key ||
|
|
12
|
+
key.length > transportKeyMaxLength ||
|
|
13
|
+
key.split("/").some((part) => !transportSegmentPattern.test(part)))
|
|
14
|
+
throw new Error("Invalid transport key");
|
|
15
|
+
return key;
|
|
16
|
+
}
|
|
17
|
+
export function transportCondition(value) {
|
|
18
|
+
if (value !== null && (typeof value !== "string" || !value.trim()))
|
|
19
|
+
throw new Error("A transport mutation requires an explicit revision condition");
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/domain/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAElC,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,GAAG,CAAS;IACrB,YAAY,GAAW;QACrB,KAAK,CAAC,gCAAgC,GAAG,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IACE,CAAC,GAAG;QACJ,GAAG,CAAC,MAAM,GAAG,qBAAqB;QAClC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;AACN,CAAC","sourcesContent":["import {\n transportKeyMaxLength,\n transportSegmentPattern,\n} from \"./transport.constants.ts\";\n\nexport class TransportConflict extends Error {\n readonly key: string;\n constructor(key: string) {\n super(`Transport revision conflict: ${key}`);\n this.name = \"TransportConflict\";\n this.key = key;\n }\n}\n\nexport function transportKey(key: string): string {\n if (\n !key ||\n key.length > transportKeyMaxLength ||\n key.split(\"/\").some((part) => !transportSegmentPattern.test(part))\n )\n throw new Error(\"Invalid transport key\");\n return key;\n}\n\nexport function transportCondition(\n value: unknown,\n): asserts value is string | null {\n if (value !== null && (typeof value !== \"string\" || !value.trim()))\n throw new Error(\n \"A transport mutation requires an explicit revision condition\",\n );\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface TransportReadOptions {
|
|
2
|
+
readonly signal?: AbortSignal;
|
|
3
|
+
readonly maxBytes?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface TransportWriteOptions {
|
|
6
|
+
readonly signal?: AbortSignal;
|
|
7
|
+
readonly ifRevision: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface TransportEntry {
|
|
10
|
+
readonly key: string;
|
|
11
|
+
readonly revision: string;
|
|
12
|
+
readonly size: number;
|
|
13
|
+
readonly modifiedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface TransportObject extends TransportEntry {
|
|
16
|
+
readonly bytes: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
export interface Transport {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
read(key: string, options?: TransportReadOptions): Promise<TransportObject | undefined>;
|
|
21
|
+
write(key: string, bytes: Uint8Array, options: TransportWriteOptions): Promise<TransportEntry>;
|
|
22
|
+
remove(key: string, options: TransportWriteOptions): Promise<void>;
|
|
23
|
+
list(prefix?: string, options?: TransportReadOptions): AsyncIterable<TransportEntry>;
|
|
24
|
+
}
|
|
25
|
+
export interface TransportStoreOptions {
|
|
26
|
+
readonly transporter: Transport;
|
|
27
|
+
}
|
|
28
|
+
export interface TransportReference {
|
|
29
|
+
readonly key: string;
|
|
30
|
+
readonly revision: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.types.js","sourceRoot":"","sources":["../../src/domain/transport.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface TransportReadOptions {\n readonly signal?: AbortSignal;\n readonly maxBytes?: number;\n}\n\nexport interface TransportWriteOptions {\n readonly signal?: AbortSignal;\n readonly ifRevision: string | null;\n}\n\nexport interface TransportEntry {\n readonly key: string;\n readonly revision: string;\n readonly size: number;\n readonly modifiedAt: string;\n}\n\nexport interface TransportObject extends TransportEntry {\n readonly bytes: Uint8Array;\n}\n\nexport interface Transport {\n readonly name: string;\n read(\n key: string,\n options?: TransportReadOptions,\n ): Promise<TransportObject | undefined>;\n write(\n key: string,\n bytes: Uint8Array,\n options: TransportWriteOptions,\n ): Promise<TransportEntry>;\n remove(key: string, options: TransportWriteOptions): Promise<void>;\n list(\n prefix?: string,\n options?: TransportReadOptions,\n ): AsyncIterable<TransportEntry>;\n}\n\nexport interface TransportStoreOptions {\n readonly transporter: Transport;\n}\n\nexport interface TransportReference {\n readonly key: string;\n readonly revision: string;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export { TransportConflict } from "./domain/transport.ts";
|
|
2
|
+
export type { Transport, TransportEntry, TransportObject, TransportReadOptions, TransportWriteOptions, TransportReference, TransportStoreOptions, } from "./domain/transport.types.ts";
|
|
3
|
+
export { localTransport } from "./infrastructure/local-transport.ts";
|
|
4
|
+
export type { LocalTransportOptions } from "./infrastructure/local-transport.types.ts";
|
|
5
|
+
export { artifactStore } from "./infrastructure/transport-artifact-store.ts";
|
|
6
|
+
export type { ArtifactStoreOptions } from "./infrastructure/transport-artifact-store.types.ts";
|
|
7
|
+
export { workflowCheckpointStore, recoverWorkflowCheckpoint, } from "./infrastructure/transport-checkpoint.ts";
|
|
8
|
+
export type { CheckpointRecoveryOptions } from "./infrastructure/transport-checkpoint.types.ts";
|
|
9
|
+
export { readJournal } from "./infrastructure/transport-journal.ts";
|
|
10
|
+
export type { ReadJournalOptions } from "./infrastructure/transport-journal.types.ts";
|
|
11
|
+
export { transportConversations } from "./infrastructure/transport-conversations.ts";
|
|
12
|
+
export type { TransportConversationOptions } from "./infrastructure/transport-conversations.types.ts";
|
|
13
|
+
export { archiveRecovery, materializeRecoveryArchive, } from "./application/recovery-archive.ts";
|
|
14
|
+
export type { RecoveryArchiveOptions, RecoveryArchiveRestoreOptions, } from "./application/recovery-archive.types.ts";
|
|
1
15
|
export { attach, createSandbox, dispatch, openWorkspace, } from "./application/outpost.ts";
|
|
2
16
|
export type { AttachOptions, AttachResult, ContinuationOptions, DispatchResult, Sandbox, SandboxOptions, WarmDispatchResult, Workspace, WorkspaceOptions, } from "./application/outpost.ts";
|
|
3
17
|
export type { DispatchOptions, Execution, Turn, } from "./application/execution.ts";
|
|
@@ -59,3 +73,6 @@ export type { QueuedTaskOptions } from "./application/queued-task.types.ts";
|
|
|
59
73
|
export type { EgressPolicy } from "./domain/egress.types.ts";
|
|
60
74
|
export { speculate } from "./application/speculation.ts";
|
|
61
75
|
export type { SpeculationOptions, SpeculationResult, SpeculativeCandidate, SpeculativeCandidateResult, SpeculativeOutput, SpeculativeHostSnapshot, SpeculativeValidation, } from "./application/speculation.types.ts";
|
|
76
|
+
export { openaiCompatible } from "./adapters/models/openai-compatible.ts";
|
|
77
|
+
export type { OpenAICompatibleOptions } from "./adapters/models/openai-compatible.types.ts";
|
|
78
|
+
export type { ModelProvider, ModelRequest, ModelResult, } from "./domain/model.types.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export { TransportConflict } from "./domain/transport.js";
|
|
2
|
+
export { localTransport } from "./infrastructure/local-transport.js";
|
|
3
|
+
export { artifactStore } from "./infrastructure/transport-artifact-store.js";
|
|
4
|
+
export { workflowCheckpointStore, recoverWorkflowCheckpoint, } from "./infrastructure/transport-checkpoint.js";
|
|
5
|
+
export { readJournal } from "./infrastructure/transport-journal.js";
|
|
6
|
+
export { transportConversations } from "./infrastructure/transport-conversations.js";
|
|
7
|
+
export { archiveRecovery, materializeRecoveryArchive, } from "./application/recovery-archive.js";
|
|
1
8
|
export { attach, createSandbox, dispatch, openWorkspace, } from "./application/outpost.js";
|
|
2
9
|
export { WorkflowFailure, WorkflowBudgetExceeded, task, workflow, } from "./domain/workflow.js";
|
|
3
10
|
export { agentTask, commandTask, isolatedTask } from "./application/tasks.js";
|
|
@@ -25,4 +32,5 @@ export { serveTaskQueue, httpTaskQueue, } from "./infrastructure/task-queue-http
|
|
|
25
32
|
export { runQueueWorker } from "./application/queue-worker.js";
|
|
26
33
|
export { queuedTask } from "./application/queued-task.js";
|
|
27
34
|
export { speculate } from "./application/speculation.js";
|
|
35
|
+
export { openaiCompatible } from "./adapters/models/openai-compatible.js";
|
|
28
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAu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+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAwB1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex, gemini } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type {\n ClaudeSettings,\n CodexSettings,\n CodexModelProvider,\n GeminiSettings,\n} from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n\nexport { reserveRecoveryStorage } from \"./application/storage-reservation.ts\";\nexport type { RecoveryStorageReservationOptions } from \"./application/storage-reservation.types.ts\";\nexport type {\n StorageReservation,\n StorageReservationOptions,\n} from \"./infrastructure/storage-reservations.types.ts\";\n\nexport {\n planRecoveryRestore,\n restoreRecoveryTransfer,\n} from \"./application/recovery-restore.ts\";\nexport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./application/recovery-restore.types.ts\";\n\nexport { fileWorkflowCheckpointStore } from \"./infrastructure/workflow-checkpoint.ts\";\nexport type { FileWorkflowCheckpointOptions } from \"./infrastructure/workflow-checkpoint.types.ts\";\nexport type {\n WorkflowCheckpoint,\n WorkflowCheckpointOptions,\n WorkflowCheckpointStore,\n WorkflowCheckpointLease,\n WorkflowCheckpointValue,\n WorkflowJson,\n} from \"./domain/workflow/checkpoint.types.ts\";\n\nexport { approvalTask, pauseTask } from \"./domain/workflow/gates.ts\";\nexport type {\n WorkflowGate,\n WorkflowGateOptions,\n WorkflowPauseRequest,\n WorkflowDecision,\n WorkflowDecisionRecord,\n} from \"./domain/workflow/gates.types.ts\";\n\nexport { inspectRecovery } from \"./application/recovery-inspection.ts\";\nexport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./application/recovery-inspection.types.ts\";\nexport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationKind,\n ResourceOperationResult,\n ResourcePhase,\n} from \"./infrastructure/resource-activity.types.ts\";\n\nexport {\n artifact,\n publishArtifact,\n readStoredArtifact,\n} from \"./domain/artifact.ts\";\nexport { artifactTask, readArtifact } from \"./application/artifact-tasks.ts\";\nexport { fileArtifactStore } from \"./infrastructure/artifact-store.ts\";\nexport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactIdentity,\n ArtifactProducer,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./domain/artifact.types.ts\";\nexport type { ArtifactTaskOptions } from \"./application/artifact-tasks.types.ts\";\nexport type { FileArtifactStoreOptions } from \"./infrastructure/artifact-store.types.ts\";\n\nexport { sqliteTaskQueue } from \"./infrastructure/task-queue.ts\";\nexport {\n serveTaskQueue,\n httpTaskQueue,\n} from \"./infrastructure/task-queue-http.ts\";\nexport { runQueueWorker } from \"./application/queue-worker.ts\";\nexport { queuedTask } from \"./application/queued-task.ts\";\nexport type {\n QueueRequest,\n QueueResult,\n QueueJob,\n QueueClaim,\n QueueLease,\n TaskQueue,\n DurableTaskQueue,\n} from \"./domain/task-queue.types.ts\";\nexport type {\n QueueServerOptions,\n QueueServer,\n QueueClientOptions,\n} from \"./infrastructure/task-queue-http.types.ts\";\nexport type {\n QueueHandlerContext,\n QueueHandler,\n QueueWorkerOptions,\n} from \"./application/queue-worker.types.ts\";\nexport type { QueuedTaskOptions } from \"./application/queued-task.types.ts\";\n\nexport type { EgressPolicy } from \"./domain/egress.types.ts\";\n\nexport { speculate } from \"./application/speculation.ts\";\nexport type {\n SpeculationOptions,\n SpeculationResult,\n SpeculativeCandidate,\n SpeculativeCandidateResult,\n SpeculativeOutput,\n SpeculativeHostSnapshot,\n SpeculativeValidation,\n} from \"./application/speculation.types.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAU1D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAE7E,OAAO,EACL,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAErF,OAAO,EACL,eAAe,EACf,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAM3C,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA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d,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAwB1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAWzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { TransportConflict } from \"./domain/transport.ts\";\nexport type {\n Transport,\n TransportEntry,\n TransportObject,\n TransportReadOptions,\n TransportWriteOptions,\n TransportReference,\n TransportStoreOptions,\n} from \"./domain/transport.types.ts\";\nexport { localTransport } from \"./infrastructure/local-transport.ts\";\nexport type { LocalTransportOptions } from \"./infrastructure/local-transport.types.ts\";\nexport { artifactStore } from \"./infrastructure/transport-artifact-store.ts\";\nexport type { ArtifactStoreOptions } from \"./infrastructure/transport-artifact-store.types.ts\";\nexport {\n workflowCheckpointStore,\n recoverWorkflowCheckpoint,\n} from \"./infrastructure/transport-checkpoint.ts\";\nexport type { CheckpointRecoveryOptions } from \"./infrastructure/transport-checkpoint.types.ts\";\nexport { readJournal } from \"./infrastructure/transport-journal.ts\";\nexport type { ReadJournalOptions } from \"./infrastructure/transport-journal.types.ts\";\nexport { transportConversations } from \"./infrastructure/transport-conversations.ts\";\nexport type { TransportConversationOptions } from \"./infrastructure/transport-conversations.types.ts\";\nexport {\n archiveRecovery,\n materializeRecoveryArchive,\n} from \"./application/recovery-archive.ts\";\nexport type {\n RecoveryArchiveOptions,\n RecoveryArchiveRestoreOptions,\n} from \"./application/recovery-archive.types.ts\";\n\nexport {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex, gemini } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type {\n ClaudeSettings,\n CodexSettings,\n CodexModelProvider,\n GeminiSettings,\n} from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n\nexport { reserveRecoveryStorage } from \"./application/storage-reservation.ts\";\nexport type { RecoveryStorageReservationOptions } from \"./application/storage-reservation.types.ts\";\nexport type {\n StorageReservation,\n StorageReservationOptions,\n} from \"./infrastructure/storage-reservations.types.ts\";\n\nexport {\n planRecoveryRestore,\n restoreRecoveryTransfer,\n} from \"./application/recovery-restore.ts\";\nexport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./application/recovery-restore.types.ts\";\n\nexport { fileWorkflowCheckpointStore } from \"./infrastructure/workflow-checkpoint.ts\";\nexport type { FileWorkflowCheckpointOptions } from \"./infrastructure/workflow-checkpoint.types.ts\";\nexport type {\n WorkflowCheckpoint,\n WorkflowCheckpointOptions,\n WorkflowCheckpointStore,\n WorkflowCheckpointLease,\n WorkflowCheckpointValue,\n WorkflowJson,\n} from \"./domain/workflow/checkpoint.types.ts\";\n\nexport { approvalTask, pauseTask } from \"./domain/workflow/gates.ts\";\nexport type {\n WorkflowGate,\n WorkflowGateOptions,\n WorkflowPauseRequest,\n WorkflowDecision,\n WorkflowDecisionRecord,\n} from \"./domain/workflow/gates.types.ts\";\n\nexport { inspectRecovery } from \"./application/recovery-inspection.ts\";\nexport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./application/recovery-inspection.types.ts\";\nexport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationKind,\n ResourceOperationResult,\n ResourcePhase,\n} from \"./infrastructure/resource-activity.types.ts\";\n\nexport {\n artifact,\n publishArtifact,\n readStoredArtifact,\n} from \"./domain/artifact.ts\";\nexport { artifactTask, readArtifact } from \"./application/artifact-tasks.ts\";\nexport { fileArtifactStore } from \"./infrastructure/artifact-store.ts\";\nexport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactIdentity,\n ArtifactProducer,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./domain/artifact.types.ts\";\nexport type { ArtifactTaskOptions } from \"./application/artifact-tasks.types.ts\";\nexport type { FileArtifactStoreOptions } from \"./infrastructure/artifact-store.types.ts\";\n\nexport { sqliteTaskQueue } from \"./infrastructure/task-queue.ts\";\nexport {\n serveTaskQueue,\n httpTaskQueue,\n} from \"./infrastructure/task-queue-http.ts\";\nexport { runQueueWorker } from \"./application/queue-worker.ts\";\nexport { queuedTask } from \"./application/queued-task.ts\";\nexport type {\n QueueRequest,\n QueueResult,\n QueueJob,\n QueueClaim,\n QueueLease,\n TaskQueue,\n DurableTaskQueue,\n} from \"./domain/task-queue.types.ts\";\nexport type {\n QueueServerOptions,\n QueueServer,\n QueueClientOptions,\n} from \"./infrastructure/task-queue-http.types.ts\";\nexport type {\n QueueHandlerContext,\n QueueHandler,\n QueueWorkerOptions,\n} from \"./application/queue-worker.types.ts\";\nexport type { QueuedTaskOptions } from \"./application/queued-task.types.ts\";\n\nexport type { EgressPolicy } from \"./domain/egress.types.ts\";\n\nexport { speculate } from \"./application/speculation.ts\";\nexport type {\n SpeculationOptions,\n SpeculationResult,\n SpeculativeCandidate,\n SpeculativeCandidateResult,\n SpeculativeOutput,\n SpeculativeHostSnapshot,\n SpeculativeValidation,\n} from \"./application/speculation.types.ts\";\n\nexport { openaiCompatible } from \"./adapters/models/openai-compatible.ts\";\nexport type { OpenAICompatibleOptions } from \"./adapters/models/openai-compatible.types.ts\";\nexport type {\n ModelProvider,\n ModelRequest,\n ModelResult,\n} from \"./domain/model.types.ts\";\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { artifactStore } from "./transport-artifact-store.js";
|
|
1
2
|
import { artifactDigestPattern } from "../domain/artifact.constants.js";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { link, lstat, mkdir, open, rm } from "node:fs/promises";
|
|
@@ -38,6 +39,15 @@ async function readArtifactFile(path, maxBytes) {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
export function fileArtifactStore(options) {
|
|
42
|
+
if ((options.directory === undefined) === (options.transporter === undefined))
|
|
43
|
+
throw new Error("Provide exactly one artifact directory or transporter");
|
|
44
|
+
if (options.transporter)
|
|
45
|
+
return artifactStore({
|
|
46
|
+
transporter: options.transporter,
|
|
47
|
+
...(options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes }),
|
|
48
|
+
});
|
|
49
|
+
if (options.directory === undefined)
|
|
50
|
+
throw new Error("Artifact directory is required");
|
|
41
51
|
const root = resolve(options.directory), maxBytes = options.maxBytes ?? artifactMaxBytes;
|
|
42
52
|
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
|
|
43
53
|
throw new Error("Artifact maxBytes must be a positive safe integer");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-store.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM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AAC,EAAE,CAAC,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACvD,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { artifactDigestPattern } from \"../domain/artifact.constants.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport { link, lstat, mkdir, open, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { ArtifactStore } from \"../domain/artifact.types.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport { artifactMaxBytes } from \"./artifact-store.constants.ts\";\nimport type { FileArtifactStoreOptions } from \"./artifact-store.types.ts\";\n\nasync function directory(path: string): Promise<void> {\n const parent = dirname(path);\n if (parent !== path) {\n await directory(parent);\n try {\n await mkdir(path, { mode: 0o700 });\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n }\n }\n if (!(await lstat(path)).isDirectory())\n throw new Error(\"Artifact directory must not contain symlinks\");\n}\n\nfunction code(error: unknown, expected: string): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === expected\n );\n}\n\nasync function readArtifactFile(\n path: string,\n maxBytes: number,\n): Promise<Buffer> {\n try {\n return await readInspectionFile(path, maxBytes);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n error.message !== \"Inspection file changed\"\n )\n throw error;\n // Removing the staging hard link can change ctime once after publication.\n return readInspectionFile(path, maxBytes);\n }\n}\n\nexport function fileArtifactStore(\n options: FileArtifactStoreOptions,\n): ArtifactStore {\n const root = resolve(options.directory),\n maxBytes = options.maxBytes ?? artifactMaxBytes;\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)\n throw new Error(\"Artifact maxBytes must be a positive safe integer\");\n const path = (id: string) => {\n if (!artifactDigestPattern.test(id))\n throw new Error(\"Invalid artifact storage ID\");\n return join(root, `${id}.blob`);\n };\n return {\n async put(id, input, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n if (input.byteLength > maxBytes)\n throw new Error(\"Artifact exceeds maxBytes\");\n const bytes = Buffer.from(input);\n await directory(root);\n const temporary = join(root, `.${randomUUID()}.tmp`);\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(bytes, signal ? { signal } : {});\n await file.sync();\n } finally {\n await file.close();\n }\n signal?.throwIfAborted();\n try {\n await link(temporary, target);\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n if (!bytes.equals(await readArtifactFile(target, maxBytes)))\n throw new Error(\"Existing artifact content integrity mismatch\");\n }\n if (process.platform !== \"win32\") {\n const parent = await open(root, \"r\");\n try {\n await parent.sync();\n } finally {\n await parent.close();\n }\n }\n } finally {\n await rm(temporary, { force: true });\n }\n },\n async get(id, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n const bytes = await readArtifactFile(target, maxBytes);\n signal?.throwIfAborted();\n return bytes;\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"artifact-store.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,KAAK,UAAU,SAAS,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAA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H,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM;YAClB,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACvD,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { artifactStore } from \"./transport-artifact-store.ts\";\nimport { artifactDigestPattern } from \"../domain/artifact.constants.ts\";\nimport { randomUUID } from \"node:crypto\";\nimport { link, lstat, mkdir, open, rm } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { ArtifactStore } from \"../domain/artifact.types.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport { artifactMaxBytes } from \"./artifact-store.constants.ts\";\nimport type { FileArtifactStoreOptions } from \"./artifact-store.types.ts\";\n\nasync function directory(path: string): Promise<void> {\n const parent = dirname(path);\n if (parent !== path) {\n await directory(parent);\n try {\n await mkdir(path, { mode: 0o700 });\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n }\n }\n if (!(await lstat(path)).isDirectory())\n throw new Error(\"Artifact directory must not contain symlinks\");\n}\n\nfunction code(error: unknown, expected: string): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === expected\n );\n}\n\nasync function readArtifactFile(\n path: string,\n maxBytes: number,\n): Promise<Buffer> {\n try {\n return await readInspectionFile(path, maxBytes);\n } catch (error) {\n if (\n !(error instanceof Error) ||\n error.message !== \"Inspection file changed\"\n )\n throw error;\n // Removing the staging hard link can change ctime once after publication.\n return readInspectionFile(path, maxBytes);\n }\n}\n\nexport function fileArtifactStore(\n options: FileArtifactStoreOptions,\n): ArtifactStore {\n if ((options.directory === undefined) === (options.transporter === undefined))\n throw new Error(\"Provide exactly one artifact directory or transporter\");\n if (options.transporter)\n return artifactStore({\n transporter: options.transporter,\n ...(options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes }),\n });\n if (options.directory === undefined)\n throw new Error(\"Artifact directory is required\");\n const root = resolve(options.directory),\n maxBytes = options.maxBytes ?? artifactMaxBytes;\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)\n throw new Error(\"Artifact maxBytes must be a positive safe integer\");\n const path = (id: string) => {\n if (!artifactDigestPattern.test(id))\n throw new Error(\"Invalid artifact storage ID\");\n return join(root, `${id}.blob`);\n };\n return {\n async put(id, input, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n if (input.byteLength > maxBytes)\n throw new Error(\"Artifact exceeds maxBytes\");\n const bytes = Buffer.from(input);\n await directory(root);\n const temporary = join(root, `.${randomUUID()}.tmp`);\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(bytes, signal ? { signal } : {});\n await file.sync();\n } finally {\n await file.close();\n }\n signal?.throwIfAborted();\n try {\n await link(temporary, target);\n } catch (error) {\n if (!code(error, \"EEXIST\")) throw error;\n if (!bytes.equals(await readArtifactFile(target, maxBytes)))\n throw new Error(\"Existing artifact content integrity mismatch\");\n }\n if (process.platform !== \"win32\") {\n const parent = await open(root, \"r\");\n try {\n await parent.sync();\n } finally {\n await parent.close();\n }\n }\n } finally {\n await rm(temporary, { force: true });\n }\n },\n async get(id, signal) {\n signal?.throwIfAborted();\n const target = path(id);\n const bytes = await readArtifactFile(target, maxBytes);\n signal?.throwIfAborted();\n return bytes;\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-store.types.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"artifact-store.types.js","sourceRoot":"","sources":["../../src/infrastructure/artifact-store.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Transport } from \"../domain/transport.types.ts\";\n\nexport interface FileArtifactStoreOptions {\n readonly directory?: string;\n readonly transporter?: Transport;\n readonly maxBytes?: number;\n}\n"]}
|