@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
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { Transport } from "../domain/transport.types.ts";
|
|
1
2
|
import type { ResourceInspection } from "../infrastructure/resource-activity.types.ts";
|
|
2
3
|
import type { LockInspection } from "../infrastructure/git/lock-inspection.types.ts";
|
|
3
4
|
import type { WorkspaceGitInspection } from "../infrastructure/git/worktree-inspection.types.ts";
|
|
4
5
|
import type { StorageInventory } from "../infrastructure/storage-inventory.types.ts";
|
|
5
6
|
export interface RecoveryInspectionOptions {
|
|
7
|
+
readonly transporter?: Transport;
|
|
6
8
|
readonly repository?: string;
|
|
7
9
|
readonly maxEntries?: number;
|
|
8
10
|
readonly git?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-inspection.types.js","sourceRoot":"","sources":["../../src/application/recovery-inspection.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ResourceInspection } from \"../infrastructure/resource-activity.types.ts\";\nimport type { LockInspection } from \"../infrastructure/git/lock-inspection.types.ts\";\nimport type { WorkspaceGitInspection } from \"../infrastructure/git/worktree-inspection.types.ts\";\nimport type { StorageInventory } from \"../infrastructure/storage-inventory.types.ts\";\n\nexport interface RecoveryInspectionOptions {\n readonly repository?: string;\n readonly maxEntries?: number;\n readonly git?: boolean;\n readonly locks?: boolean;\n readonly resources?: boolean;\n}\nexport interface RecoveryInspection extends StorageInventory {\n readonly repository: string;\n readonly activity: \"unverified\";\n readonly git?: WorkspaceGitInspection;\n readonly locks?: LockInspection;\n readonly resources?: ResourceInspection;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recovery-inspection.types.js","sourceRoot":"","sources":["../../src/application/recovery-inspection.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Transport } from \"../domain/transport.types.ts\";\nimport type { ResourceInspection } from \"../infrastructure/resource-activity.types.ts\";\nimport type { LockInspection } from \"../infrastructure/git/lock-inspection.types.ts\";\nimport type { WorkspaceGitInspection } from \"../infrastructure/git/worktree-inspection.types.ts\";\nimport type { StorageInventory } from \"../infrastructure/storage-inventory.types.ts\";\n\nexport interface RecoveryInspectionOptions {\n readonly transporter?: Transport;\n readonly repository?: string;\n readonly maxEntries?: number;\n readonly git?: boolean;\n readonly locks?: boolean;\n readonly resources?: boolean;\n}\nexport interface RecoveryInspection extends StorageInventory {\n readonly repository: string;\n readonly activity: \"unverified\";\n readonly git?: WorkspaceGitInspection;\n readonly locks?: LockInspection;\n readonly resources?: ResourceInspection;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { TransportStoreOptions } from "../domain/transport.types.ts";
|
|
1
2
|
import type { RecoveryPruneResult, RecoveryQuotaOptions, RecoveryRetentionOptions, RecoveryRetentionPlan } from "./recovery-retention.types.ts";
|
|
2
3
|
export declare function planRecoveryRetention(options: RecoveryRetentionOptions): Promise<RecoveryRetentionPlan>;
|
|
3
|
-
export declare function pruneRecoveryRetention(plan: RecoveryRetentionPlan): Promise<RecoveryPruneResult>;
|
|
4
|
+
export declare function pruneRecoveryRetention(plan: RecoveryRetentionPlan, options?: TransportStoreOptions): Promise<RecoveryPruneResult>;
|
|
4
5
|
export declare function assertRecoveryQuota(options: RecoveryQuotaOptions): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { planTransportRetention, pruneTransportRetention, } from "./transport-retention.js";
|
|
1
2
|
import { lstat, rm } from "node:fs/promises";
|
|
2
3
|
import { OutpostError, invariant } from "../domain/errors.js";
|
|
3
4
|
import { git } from "../infrastructure/git/command.js";
|
|
@@ -47,6 +48,8 @@ async function workspaceReason(entry, inspection) {
|
|
|
47
48
|
return "ELIGIBLE";
|
|
48
49
|
}
|
|
49
50
|
export async function planRecoveryRetention(options) {
|
|
51
|
+
if (options.transporter)
|
|
52
|
+
return planTransportRetention(options);
|
|
50
53
|
retentionPolicy(options.policy);
|
|
51
54
|
const policy = structuredClone(options.policy);
|
|
52
55
|
const inspection = await inspectRecovery({
|
|
@@ -122,7 +125,12 @@ export async function planRecoveryRetention(options) {
|
|
|
122
125
|
quota: !complete ? "unknown" : exceeded ? "exceeded" : "within",
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
|
-
export async function pruneRecoveryRetention(plan) {
|
|
128
|
+
export async function pruneRecoveryRetention(plan, options) {
|
|
129
|
+
if (plan.source === "transport") {
|
|
130
|
+
invariant(options, "Transport retention requires its transporter");
|
|
131
|
+
return pruneTransportRetention(plan, options);
|
|
132
|
+
}
|
|
133
|
+
invariant(!options, "Local retention does not accept a transporter");
|
|
126
134
|
retentionPolicy(plan.policy);
|
|
127
135
|
invariant(plan.complete, "Cannot prune an incomplete retention plan");
|
|
128
136
|
const removed = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-retention.js","sourceRoot":"","sources":["../../src/application/recovery-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAUjE,KAAK,UAAU,eAAe,CAC5B,KAAmB,EACnB,UAA8B;IAE9B,IAAI,UAAU,CAAC,SAAS,EAAE,QAAQ,KAAK,KAAK;QAC1C,OAAO,2BAA2B,CAAC;IACrC,IACE,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAChC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,KAAK,CAAC,IAAI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AC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,MAAM,EAAE,gCAAgC;aACzC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO;QACL,OAAO;QACP,QAAQ;QACR,KAAK,EAAE,MAAM,qBAAqB,CAAC;YACjC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA6B;IAE7B,SAAS,CACP,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,EAC/D,wCAAwC,CACzC,CAAC;IACF,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;IAC1C,SAAS,CACP,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAC7C,4CAA4C,CAC7C,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAClD,IACE,CAAC,UAAU,CAAC,QAAQ;QACpB,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ;QAEnD,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,yCAAyC,EACzC;YACE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK;YAClC,YAAY,EAAE,OAAO;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CACF,CAAC;AACN,CAAC","sourcesContent":["import { lstat, rm } from \"node:fs/promises\";\nimport { OutpostError, invariant } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { lock, lockPath } from \"../infrastructure/git/lock.ts\";\nimport { closedJournal } from \"../infrastructure/journal-retention.ts\";\nimport type { StorageEntry } from \"../infrastructure/storage-inventory.types.ts\";\nimport type { RecoveryInspection } from \"./recovery-inspection.types.ts\";\nimport { inspectRecovery } from \"./recovery-inspection.ts\";\nimport { retentionPolicy } from \"./recovery-retention-policy.ts\";\nimport type {\n RecoveryPruneResult,\n RecoveryRetainedEntry,\n RecoveryQuotaOptions,\n RecoveryRetentionEntry,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n} from \"./recovery-retention.types.ts\";\n\nasync function workspaceReason(\n entry: StorageEntry,\n inspection: RecoveryInspection,\n): Promise<string> {\n if (inspection.resources?.complete === false)\n return \"RESOURCE_ACTIVITY_UNKNOWN\";\n if (\n inspection.resources?.entries.some(\n (resource) => resource.record?.workspace === entry.path,\n )\n )\n return \"RESOURCE_ACTIVITY_RECORDED\";\n const workspace = inspection.git?.workspaces.find(\n (value) => value.path === entry.path,\n );\n if (!workspace || workspace.state !== \"registered\")\n return \"WORKSPACE_UNREGISTERED_OR_UNKNOWN\";\n if (workspace.branch === null) return \"DETACHED_WORKSPACE\";\n if (workspace.dirty) return \"DIRTY_WORKSPACE\";\n if (workspace.locked) return \"GIT_LOCKED_WORKSPACE\";\n try {\n await lstat(lockPath(inspection.repository, workspace.branch));\n return \"OPERATION_LOCK_PRESENT\";\n } catch (error) {\n if (!(\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ))\n return \"OWNERSHIP_UNKNOWN\";\n }\n try {\n const ignored = await git(entry.path, [\n \"ls-files\",\n \"--others\",\n \"--ignored\",\n \"--exclude-standard\",\n \"-z\",\n ]);\n if (ignored.length) return \"IGNORED_FILES\";\n } catch {\n return \"WORKSPACE_STATE_UNKNOWN\";\n }\n return \"ELIGIBLE\";\n}\n\nexport async function planRecoveryRetention(\n options: RecoveryRetentionOptions,\n): Promise<RecoveryRetentionPlan> {\n retentionPolicy(options.policy);\n const policy = structuredClone(options.policy);\n const inspection = await inspectRecovery({\n ...options,\n git: true,\n locks: true,\n resources: true,\n });\n const entries: RecoveryRetentionEntry[] = [];\n const inspectedAt = new Date().toISOString();\n const complete = inspection.complete && inspection.git?.complete !== false;\n for (const category of inspection.categories) {\n for (const entry of category.entries) {\n let reason = \"RECOVERY_DATA_PROTECTED\";\n if (category.name === \"locks\") reason = \"OWNERSHIP_RECORD_PROTECTED\";\n if (category.name === \"logs\") reason = \"LOG_ACTIVITY_OR_CONTENT_UNKNOWN\";\n if (category.name === \"workspaces\") reason = \"SCOPE_NOT_SELECTED\";\n if (\n category.name === \"workspaces\" &&\n policy.scopes.includes(\"clean-workspaces\")\n )\n reason = await workspaceReason(entry, inspection);\n if (\n category.name === \"logs\" &&\n policy.scopes.includes(\"closed-logs\") &&\n entry.kind === \"file\" &&\n entry.name.endsWith(\".jsonl\") &&\n (await closedJournal(entry.path))\n )\n reason = \"ELIGIBLE\";\n if (category.name === \"logs\" && entry.name.endsWith(\".closed.json\"))\n reason = \"CLOSURE_RECORD_PROTECTED\";\n if (\n reason === \"ELIGIBLE\" &&\n (!entry.modifiedAt ||\n Date.parse(inspectedAt) - Date.parse(entry.modifiedAt) <\n policy.minAgeMs)\n )\n reason = \"RETENTION_AGE\";\n if (reason === \"ELIGIBLE\" && (!complete || !entry.complete))\n reason = \"INCOMPLETE_INVENTORY\";\n const workspace = inspection.git?.workspaces.find(\n (value) => value.path === entry.path,\n );\n entries.push({\n path: entry.path,\n category: category.name,\n bytes: entry.bytes,\n eligible: reason === \"ELIGIBLE\",\n reason,\n ...(entry.modifiedAt ? { modifiedAt: entry.modifiedAt } : {}),\n ...(workspace?.state === \"registered\" && workspace.branch\n ? { branch: workspace.branch, head: workspace.head }\n : {}),\n });\n }\n }\n const projectedBytes =\n inspection.usage.bytes -\n entries\n .filter((entry) => entry.eligible)\n .reduce(\n (sum, entry) =>\n sum +\n entry.bytes +\n (entry.category === \"logs\"\n ? (entries.find(\n (other) => other.path === `${entry.path}.closed.json`,\n )?.bytes ?? 0)\n : 0),\n 0,\n );\n const workspaces = entries.filter(\n (entry) => entry.category === \"workspaces\" && !entry.eligible,\n ).length;\n const exceeded =\n (policy.maxBytes !== undefined && projectedBytes > policy.maxBytes) ||\n (policy.maxWorkspaces !== undefined && workspaces > policy.maxWorkspaces);\n return {\n repository: inspection.repository,\n policy,\n inspectedAt,\n inspection,\n entries,\n complete,\n usageBytes: inspection.usage.bytes,\n projectedBytes,\n quota: !complete ? \"unknown\" : exceeded ? \"exceeded\" : \"within\",\n };\n}\n\nexport async function pruneRecoveryRetention(\n plan: RecoveryRetentionPlan,\n): Promise<RecoveryPruneResult> {\n retentionPolicy(plan.policy);\n invariant(plan.complete, \"Cannot prune an incomplete retention plan\");\n const removed: string[] = [];\n const retained: RecoveryRetainedEntry[] = [];\n for (const candidate of plan.entries.filter((entry) => entry.eligible)) {\n const fresh = await planRecoveryRetention({\n repository: plan.repository,\n policy: plan.policy,\n });\n const entry = fresh.entries.find((value) => value.path === candidate.path);\n if (\n !entry?.eligible ||\n entry.head !== candidate.head ||\n entry.branch !== candidate.branch ||\n entry.bytes !== candidate.bytes ||\n entry.modifiedAt !== candidate.modifiedAt\n ) {\n retained.push({ path: candidate.path, reason: \"PLAN_CHANGED\" });\n continue;\n }\n try {\n if (entry.category === \"workspaces\" && entry.branch) {\n const release = await lock(plan.repository, entry.branch);\n try {\n const status = await git(entry.path, [\n \"status\",\n \"--porcelain=v1\",\n \"--ignored\",\n \"--untracked-files=all\",\n ]);\n invariant(!status.length, \"Workspace changed before pruning\");\n invariant(\n (await git(entry.path, [\"rev-parse\", \"HEAD\"])).trim() ===\n entry.head,\n \"Workspace HEAD changed before pruning\",\n );\n invariant(\n (\n await git(entry.path, [\"symbolic-ref\", \"--short\", \"HEAD\"])\n ).trim() === entry.branch,\n \"Workspace branch changed before pruning\",\n );\n await git(plan.repository, [\"worktree\", \"remove\", entry.path]);\n } finally {\n await release();\n }\n } else {\n const release = await lock(plan.repository, `journal:${entry.path}`);\n try {\n invariant(\n entry.category === \"logs\" && (await closedJournal(entry.path)),\n \"Journal changed before pruning\",\n );\n await rm(entry.path);\n await rm(`${entry.path}.closed.json`);\n } finally {\n await release();\n }\n }\n removed.push(entry.path);\n } catch {\n retained.push({\n path: candidate.path,\n reason: \"REVALIDATION_OR_REMOVAL_FAILED\",\n });\n }\n }\n return {\n removed,\n retained,\n after: await planRecoveryRetention({\n repository: plan.repository,\n policy: plan.policy,\n }),\n };\n}\n\nexport async function assertRecoveryQuota(\n options: RecoveryQuotaOptions,\n): Promise<void> {\n invariant(\n Number.isSafeInteger(options.maxBytes) && options.maxBytes >= 0,\n \"maxBytes must be a nonnegative integer\",\n );\n const reserve = options.reserveBytes ?? 0;\n invariant(\n Number.isSafeInteger(reserve) && reserve >= 0,\n \"reserveBytes must be a nonnegative integer\",\n );\n const inspection = await inspectRecovery(options);\n if (\n !inspection.complete ||\n inspection.usage.bytes + reserve > options.maxBytes\n )\n throw new OutpostError(\n \"workspace\",\n \"Outpost storage quota admission refused\",\n {\n usageBytes: inspection.usage.bytes,\n reserveBytes: reserve,\n maxBytes: options.maxBytes,\n complete: inspection.complete,\n },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recovery-retention.js","sourceRoot":"","sources":["../../src/application/recovery-retention.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,M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IACF,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;IAC1C,SAAS,CACP,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAC7C,4CAA4C,CAC7C,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAClD,IACE,CAAC,UAAU,CAAC,QAAQ;QACpB,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ;QAEnD,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,yCAAyC,EACzC;YACE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK;YAClC,YAAY,EAAE,OAAO;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CACF,CAAC;AACN,CAAC","sourcesContent":["import type { TransportStoreOptions } from \"../domain/transport.types.ts\";\nimport {\n planTransportRetention,\n pruneTransportRetention,\n} from \"./transport-retention.ts\";\nimport { lstat, rm } from \"node:fs/promises\";\nimport { OutpostError, invariant } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { lock, lockPath } from \"../infrastructure/git/lock.ts\";\nimport { closedJournal } from \"../infrastructure/journal-retention.ts\";\nimport type { StorageEntry } from \"../infrastructure/storage-inventory.types.ts\";\nimport type { RecoveryInspection } from \"./recovery-inspection.types.ts\";\nimport { inspectRecovery } from \"./recovery-inspection.ts\";\nimport { retentionPolicy } from \"./recovery-retention-policy.ts\";\nimport type {\n RecoveryPruneResult,\n RecoveryRetainedEntry,\n RecoveryQuotaOptions,\n RecoveryRetentionEntry,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n} from \"./recovery-retention.types.ts\";\n\nasync function workspaceReason(\n entry: StorageEntry,\n inspection: RecoveryInspection,\n): Promise<string> {\n if (inspection.resources?.complete === false)\n return \"RESOURCE_ACTIVITY_UNKNOWN\";\n if (\n inspection.resources?.entries.some(\n (resource) => resource.record?.workspace === entry.path,\n )\n )\n return \"RESOURCE_ACTIVITY_RECORDED\";\n const workspace = inspection.git?.workspaces.find(\n (value) => value.path === entry.path,\n );\n if (!workspace || workspace.state !== \"registered\")\n return \"WORKSPACE_UNREGISTERED_OR_UNKNOWN\";\n if (workspace.branch === null) return \"DETACHED_WORKSPACE\";\n if (workspace.dirty) return \"DIRTY_WORKSPACE\";\n if (workspace.locked) return \"GIT_LOCKED_WORKSPACE\";\n try {\n await lstat(lockPath(inspection.repository, workspace.branch));\n return \"OPERATION_LOCK_PRESENT\";\n } catch (error) {\n if (!(\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ))\n return \"OWNERSHIP_UNKNOWN\";\n }\n try {\n const ignored = await git(entry.path, [\n \"ls-files\",\n \"--others\",\n \"--ignored\",\n \"--exclude-standard\",\n \"-z\",\n ]);\n if (ignored.length) return \"IGNORED_FILES\";\n } catch {\n return \"WORKSPACE_STATE_UNKNOWN\";\n }\n return \"ELIGIBLE\";\n}\n\nexport async function planRecoveryRetention(\n options: RecoveryRetentionOptions,\n): Promise<RecoveryRetentionPlan> {\n if (options.transporter) return planTransportRetention(options);\n retentionPolicy(options.policy);\n const policy = structuredClone(options.policy);\n const inspection = await inspectRecovery({\n ...options,\n git: true,\n locks: true,\n resources: true,\n });\n const entries: RecoveryRetentionEntry[] = [];\n const inspectedAt = new Date().toISOString();\n const complete = inspection.complete && inspection.git?.complete !== false;\n for (const category of inspection.categories) {\n for (const entry of category.entries) {\n let reason = \"RECOVERY_DATA_PROTECTED\";\n if (category.name === \"locks\") reason = \"OWNERSHIP_RECORD_PROTECTED\";\n if (category.name === \"logs\") reason = \"LOG_ACTIVITY_OR_CONTENT_UNKNOWN\";\n if (category.name === \"workspaces\") reason = \"SCOPE_NOT_SELECTED\";\n if (\n category.name === \"workspaces\" &&\n policy.scopes.includes(\"clean-workspaces\")\n )\n reason = await workspaceReason(entry, inspection);\n if (\n category.name === \"logs\" &&\n policy.scopes.includes(\"closed-logs\") &&\n entry.kind === \"file\" &&\n entry.name.endsWith(\".jsonl\") &&\n (await closedJournal(entry.path))\n )\n reason = \"ELIGIBLE\";\n if (category.name === \"logs\" && entry.name.endsWith(\".closed.json\"))\n reason = \"CLOSURE_RECORD_PROTECTED\";\n if (\n reason === \"ELIGIBLE\" &&\n (!entry.modifiedAt ||\n Date.parse(inspectedAt) - Date.parse(entry.modifiedAt) <\n policy.minAgeMs)\n )\n reason = \"RETENTION_AGE\";\n if (reason === \"ELIGIBLE\" && (!complete || !entry.complete))\n reason = \"INCOMPLETE_INVENTORY\";\n const workspace = inspection.git?.workspaces.find(\n (value) => value.path === entry.path,\n );\n entries.push({\n path: entry.path,\n category: category.name,\n bytes: entry.bytes,\n eligible: reason === \"ELIGIBLE\",\n reason,\n ...(entry.modifiedAt ? { modifiedAt: entry.modifiedAt } : {}),\n ...(workspace?.state === \"registered\" && workspace.branch\n ? { branch: workspace.branch, head: workspace.head }\n : {}),\n });\n }\n }\n const projectedBytes =\n inspection.usage.bytes -\n entries\n .filter((entry) => entry.eligible)\n .reduce(\n (sum, entry) =>\n sum +\n entry.bytes +\n (entry.category === \"logs\"\n ? (entries.find(\n (other) => other.path === `${entry.path}.closed.json`,\n )?.bytes ?? 0)\n : 0),\n 0,\n );\n const workspaces = entries.filter(\n (entry) => entry.category === \"workspaces\" && !entry.eligible,\n ).length;\n const exceeded =\n (policy.maxBytes !== undefined && projectedBytes > policy.maxBytes) ||\n (policy.maxWorkspaces !== undefined && workspaces > policy.maxWorkspaces);\n return {\n repository: inspection.repository,\n policy,\n inspectedAt,\n inspection,\n entries,\n complete,\n usageBytes: inspection.usage.bytes,\n projectedBytes,\n quota: !complete ? \"unknown\" : exceeded ? \"exceeded\" : \"within\",\n };\n}\n\nexport async function pruneRecoveryRetention(\n plan: RecoveryRetentionPlan,\n options?: TransportStoreOptions,\n): Promise<RecoveryPruneResult> {\n if (plan.source === \"transport\") {\n invariant(options, \"Transport retention requires its transporter\");\n return pruneTransportRetention(plan, options);\n }\n invariant(!options, \"Local retention does not accept a transporter\");\n retentionPolicy(plan.policy);\n invariant(plan.complete, \"Cannot prune an incomplete retention plan\");\n const removed: string[] = [];\n const retained: RecoveryRetainedEntry[] = [];\n for (const candidate of plan.entries.filter((entry) => entry.eligible)) {\n const fresh = await planRecoveryRetention({\n repository: plan.repository,\n policy: plan.policy,\n });\n const entry = fresh.entries.find((value) => value.path === candidate.path);\n if (\n !entry?.eligible ||\n entry.head !== candidate.head ||\n entry.branch !== candidate.branch ||\n entry.bytes !== candidate.bytes ||\n entry.modifiedAt !== candidate.modifiedAt\n ) {\n retained.push({ path: candidate.path, reason: \"PLAN_CHANGED\" });\n continue;\n }\n try {\n if (entry.category === \"workspaces\" && entry.branch) {\n const release = await lock(plan.repository, entry.branch);\n try {\n const status = await git(entry.path, [\n \"status\",\n \"--porcelain=v1\",\n \"--ignored\",\n \"--untracked-files=all\",\n ]);\n invariant(!status.length, \"Workspace changed before pruning\");\n invariant(\n (await git(entry.path, [\"rev-parse\", \"HEAD\"])).trim() ===\n entry.head,\n \"Workspace HEAD changed before pruning\",\n );\n invariant(\n (\n await git(entry.path, [\"symbolic-ref\", \"--short\", \"HEAD\"])\n ).trim() === entry.branch,\n \"Workspace branch changed before pruning\",\n );\n await git(plan.repository, [\"worktree\", \"remove\", entry.path]);\n } finally {\n await release();\n }\n } else {\n const release = await lock(plan.repository, `journal:${entry.path}`);\n try {\n invariant(\n entry.category === \"logs\" && (await closedJournal(entry.path)),\n \"Journal changed before pruning\",\n );\n await rm(entry.path);\n await rm(`${entry.path}.closed.json`);\n } finally {\n await release();\n }\n }\n removed.push(entry.path);\n } catch {\n retained.push({\n path: candidate.path,\n reason: \"REVALIDATION_OR_REMOVAL_FAILED\",\n });\n }\n }\n return {\n removed,\n retained,\n after: await planRecoveryRetention({\n repository: plan.repository,\n policy: plan.policy,\n }),\n };\n}\n\nexport async function assertRecoveryQuota(\n options: RecoveryQuotaOptions,\n): Promise<void> {\n invariant(\n Number.isSafeInteger(options.maxBytes) && options.maxBytes >= 0,\n \"maxBytes must be a nonnegative integer\",\n );\n const reserve = options.reserveBytes ?? 0;\n invariant(\n Number.isSafeInteger(reserve) && reserve >= 0,\n \"reserveBytes must be a nonnegative integer\",\n );\n const inspection = await inspectRecovery(options);\n if (\n !inspection.complete ||\n inspection.usage.bytes + reserve > options.maxBytes\n )\n throw new OutpostError(\n \"workspace\",\n \"Outpost storage quota admission refused\",\n {\n usageBytes: inspection.usage.bytes,\n reserveBytes: reserve,\n maxBytes: options.maxBytes,\n complete: inspection.complete,\n },\n );\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Transport, TransportEntry } from "../domain/transport.types.ts";
|
|
1
2
|
import type { RecoveryInspection } from "./recovery-inspection.types.ts";
|
|
2
3
|
export interface RecoveryRetentionPolicy {
|
|
3
4
|
readonly version: 1;
|
|
@@ -7,11 +8,14 @@ export interface RecoveryRetentionPolicy {
|
|
|
7
8
|
readonly maxWorkspaces?: number;
|
|
8
9
|
}
|
|
9
10
|
export interface RecoveryRetentionOptions {
|
|
11
|
+
readonly transporter?: Transport;
|
|
10
12
|
readonly repository?: string;
|
|
11
13
|
readonly policy: RecoveryRetentionPolicy;
|
|
12
14
|
readonly maxEntries?: number;
|
|
13
15
|
}
|
|
14
16
|
export interface RecoveryRetentionEntry {
|
|
17
|
+
readonly revision?: string;
|
|
18
|
+
readonly objects?: readonly TransportEntry[];
|
|
15
19
|
readonly path: string;
|
|
16
20
|
readonly category: string;
|
|
17
21
|
readonly bytes: number;
|
|
@@ -22,6 +26,7 @@ export interface RecoveryRetentionEntry {
|
|
|
22
26
|
readonly modifiedAt?: string;
|
|
23
27
|
}
|
|
24
28
|
export interface RecoveryRetentionPlan {
|
|
29
|
+
readonly source?: "transport";
|
|
25
30
|
readonly repository: string;
|
|
26
31
|
readonly policy: RecoveryRetentionPolicy;
|
|
27
32
|
readonly inspectedAt: string;
|
|
@@ -45,6 +50,7 @@ export interface RecoveryPruneResult {
|
|
|
45
50
|
readonly after: RecoveryRetentionPlan;
|
|
46
51
|
}
|
|
47
52
|
export interface RecoveryQuotaOptions {
|
|
53
|
+
readonly transporter?: Transport;
|
|
48
54
|
readonly repository?: string;
|
|
49
55
|
readonly maxBytes: number;
|
|
50
56
|
readonly reserveBytes?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery-retention.types.js","sourceRoot":"","sources":["../../src/application/recovery-retention.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RecoveryInspection } from \"./recovery-inspection.types.ts\";\nexport interface RecoveryRetentionPolicy {\n readonly version: 1;\n readonly scopes: readonly (\"clean-workspaces\" | \"closed-logs\")[];\n readonly minAgeMs: number;\n readonly maxBytes?: number;\n readonly maxWorkspaces?: number;\n}\nexport interface RecoveryRetentionOptions {\n readonly repository?: string;\n readonly policy: RecoveryRetentionPolicy;\n readonly maxEntries?: number;\n}\nexport interface RecoveryRetentionEntry {\n readonly path: string;\n readonly category: string;\n readonly bytes: number;\n readonly eligible: boolean;\n readonly reason: string;\n readonly branch?: string;\n readonly head?: string;\n readonly modifiedAt?: string;\n}\nexport interface RecoveryRetentionPlan {\n readonly repository: string;\n readonly policy: RecoveryRetentionPolicy;\n readonly inspectedAt: string;\n readonly inspection: RecoveryInspection;\n readonly entries: readonly RecoveryRetentionEntry[];\n readonly complete: boolean;\n readonly usageBytes: number;\n readonly projectedBytes: number;\n readonly quota: \"within\" | \"exceeded\" | \"unknown\";\n}\nexport interface RecoveryRetainedEntry {\n readonly path: string;\n readonly reason: string;\n}\nexport interface RecoveryPruneResult {\n readonly removed: readonly string[];\n readonly retained: readonly {\n readonly path: string;\n readonly reason: string;\n }[];\n readonly after: RecoveryRetentionPlan;\n}\nexport interface RecoveryQuotaOptions {\n readonly repository?: string;\n readonly maxBytes: number;\n readonly reserveBytes?: number;\n readonly maxEntries?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"recovery-retention.types.js","sourceRoot":"","sources":["../../src/application/recovery-retention.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Transport, TransportEntry } from \"../domain/transport.types.ts\";\nimport type { RecoveryInspection } from \"./recovery-inspection.types.ts\";\nexport interface RecoveryRetentionPolicy {\n readonly version: 1;\n readonly scopes: readonly (\"clean-workspaces\" | \"closed-logs\")[];\n readonly minAgeMs: number;\n readonly maxBytes?: number;\n readonly maxWorkspaces?: number;\n}\nexport interface RecoveryRetentionOptions {\n readonly transporter?: Transport;\n readonly repository?: string;\n readonly policy: RecoveryRetentionPolicy;\n readonly maxEntries?: number;\n}\nexport interface RecoveryRetentionEntry {\n readonly revision?: string;\n readonly objects?: readonly TransportEntry[];\n readonly path: string;\n readonly category: string;\n readonly bytes: number;\n readonly eligible: boolean;\n readonly reason: string;\n readonly branch?: string;\n readonly head?: string;\n readonly modifiedAt?: string;\n}\nexport interface RecoveryRetentionPlan {\n readonly source?: \"transport\";\n readonly repository: string;\n readonly policy: RecoveryRetentionPolicy;\n readonly inspectedAt: string;\n readonly inspection: RecoveryInspection;\n readonly entries: readonly RecoveryRetentionEntry[];\n readonly complete: boolean;\n readonly usageBytes: number;\n readonly projectedBytes: number;\n readonly quota: \"within\" | \"exceeded\" | \"unknown\";\n}\nexport interface RecoveryRetainedEntry {\n readonly path: string;\n readonly reason: string;\n}\nexport interface RecoveryPruneResult {\n readonly removed: readonly string[];\n readonly retained: readonly {\n readonly path: string;\n readonly reason: string;\n }[];\n readonly after: RecoveryRetentionPlan;\n}\nexport interface RecoveryQuotaOptions {\n readonly transporter?: Transport;\n readonly repository?: string;\n readonly maxBytes: number;\n readonly reserveBytes?: number;\n readonly maxEntries?: number;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { archiveRecovery } from "./recovery-archive.js";
|
|
1
2
|
import { captureRecoveryChecksums } from "./recovery-checksum-capture.js";
|
|
2
3
|
import { cp, mkdir, writeFile } from "node:fs/promises";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
@@ -37,6 +38,13 @@ export async function backupHost(context, changes, synchronized, transfer) {
|
|
|
37
38
|
};
|
|
38
39
|
await writeFile(join(transfer, "state.json"), JSON.stringify(state));
|
|
39
40
|
await captureRecoveryChecksums(transfer, state);
|
|
41
|
+
if (context.options.recoveryTransport) {
|
|
42
|
+
const reference = await archiveRecovery({
|
|
43
|
+
directory: transfer,
|
|
44
|
+
transporter: context.options.recoveryTransport,
|
|
45
|
+
});
|
|
46
|
+
await writeFile(join(transfer, "archive-reference.json"), JSON.stringify(reference), { mode: 0o600 });
|
|
47
|
+
}
|
|
40
48
|
return { previousPatch, previousExtras };
|
|
41
49
|
}
|
|
42
50
|
//# sourceMappingURL=remote-backup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-backup.js","sourceRoot":"","sources":["../../src/application/remote-backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAMvD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAA+B,EAC/B,OAAsB,EACtB,YAAoB,EACpB,QAAgB;IAEhB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC9B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACvD,MAAM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AI,CAAC,EAAE,MAAM,EAAE;YACjE,WAAW,EAAE,KAAK;YAClB,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IACD,MAAM,KAAK,GAAG;QACZ,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,IAAI;QACV,cAAc;QACd,QAAQ;KACT,CAAC;IACF,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,MAAM,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC;YACtC,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,iBAAiB;SAC/C,CAAC,CAAC;QACH,MAAM,SAAS,CACb,IAAI,CAAC,QAAQ,EAAE,wBAAwB,CAAC,EACxC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EACzB,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import { archiveRecovery } from \"./recovery-archive.ts\";\nimport { captureRecoveryChecksums } from \"./recovery-checksum-capture.ts\";\nimport { cp, mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport type {\n HostBackup,\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { extras } from \"./workspace-fingerprint.ts\";\n\nexport async function backupHost(\n context: RemoteWorkspaceContext,\n changes: RemoteChanges,\n synchronized: string,\n transfer: string,\n): Promise<HostBackup> {\n const { workspace } = context;\n const { head, incoming } = changes;\n const previousPatch = join(transfer, \"previous.patch\");\n await git(workspace.directory, [\n \"diff\",\n \"--binary\",\n \"HEAD\",\n `--output=${previousPatch}`,\n ]);\n await git(workspace.directory, [\n \"diff\",\n \"--cached\",\n \"--binary\",\n `--output=${join(transfer, \"previous-index.patch\")}`,\n ]);\n const previousExtras = await extras(workspace.directory);\n for (const file of previousExtras) {\n const backup = await safeDestination(\n join(transfer, \"previous-files\"),\n file,\n );\n await mkdir(dirname(backup), { recursive: true });\n await cp(await safeDestination(workspace.directory, file), backup, {\n dereference: false,\n verbatimSymlinks: true,\n });\n }\n const state = {\n previous: synchronized,\n next: head,\n previousExtras,\n incoming,\n };\n await writeFile(join(transfer, \"state.json\"), JSON.stringify(state));\n await captureRecoveryChecksums(transfer, state);\n if (context.options.recoveryTransport) {\n const reference = await archiveRecovery({\n directory: transfer,\n transporter: context.options.recoveryTransport,\n });\n await writeFile(\n join(transfer, \"archive-reference.json\"),\n JSON.stringify(reference),\n { mode: 0o600 },\n );\n }\n\n return { previousPatch, previousExtras };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Transport } from "../domain/transport.types.ts";
|
|
1
2
|
import type { FileManifestEntry, SandboxLease } from "../domain/sandbox.types.ts";
|
|
2
3
|
import type { StageLimits, WorkspaceRecord } from "../domain/workspace.types.ts";
|
|
3
4
|
export interface RemoteSync {
|
|
@@ -5,6 +6,7 @@ export interface RemoteSync {
|
|
|
5
6
|
close(): Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
export interface RemoteSyncOptions {
|
|
9
|
+
readonly recoveryTransport?: Transport;
|
|
8
10
|
readonly includeUncommitted?: boolean;
|
|
9
11
|
readonly signal?: AbortSignal;
|
|
10
12
|
readonly limits?: StageLimits;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-workspace.types.js","sourceRoot":"","sources":["../../src/application/remote-workspace.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n FileManifestEntry,\n SandboxLease,\n} from \"../domain/sandbox.types.ts\";\nimport type {\n StageLimits,\n WorkspaceRecord,\n} from \"../domain/workspace.types.ts\";\n\nexport interface RemoteSync {\n pull(): Promise<void>;\n close(): Promise<void>;\n}\n\nexport interface RemoteSyncOptions {\n readonly includeUncommitted?: boolean;\n readonly signal?: AbortSignal;\n readonly limits?: StageLimits;\n}\n\nexport interface RemoteWorkspaceContext {\n readonly transferred?: Map<string, FileManifestEntry>;\n readonly workspace: WorkspaceRecord;\n readonly lease: SandboxLease;\n readonly options: RemoteSyncOptions;\n readonly recovery: string;\n readonly remoteBundle: string;\n readonly run: (args: readonly string[]) => Promise<string>;\n readonly protectedFiles: readonly string[];\n readonly originalHead: string;\n readonly initialPatch: string;\n readonly initialIndex: string;\n}\nexport interface RemoteChanges {\n readonly manifest?: readonly FileManifestEntry[];\n readonly head: string;\n readonly patch: string;\n readonly incoming: readonly string[];\n}\nexport interface HostBackup {\n readonly previousPatch: string;\n readonly previousExtras: readonly string[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remote-workspace.types.js","sourceRoot":"","sources":["../../src/application/remote-workspace.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Transport } from \"../domain/transport.types.ts\";\nimport type {\n FileManifestEntry,\n SandboxLease,\n} from \"../domain/sandbox.types.ts\";\nimport type {\n StageLimits,\n WorkspaceRecord,\n} from \"../domain/workspace.types.ts\";\n\nexport interface RemoteSync {\n pull(): Promise<void>;\n close(): Promise<void>;\n}\n\nexport interface RemoteSyncOptions {\n readonly recoveryTransport?: Transport;\n readonly includeUncommitted?: boolean;\n readonly signal?: AbortSignal;\n readonly limits?: StageLimits;\n}\n\nexport interface RemoteWorkspaceContext {\n readonly transferred?: Map<string, FileManifestEntry>;\n readonly workspace: WorkspaceRecord;\n readonly lease: SandboxLease;\n readonly options: RemoteSyncOptions;\n readonly recovery: string;\n readonly remoteBundle: string;\n readonly run: (args: readonly string[]) => Promise<string>;\n readonly protectedFiles: readonly string[];\n readonly originalHead: string;\n readonly initialPatch: string;\n readonly initialIndex: string;\n}\nexport interface RemoteChanges {\n readonly manifest?: readonly FileManifestEntry[];\n readonly head: string;\n readonly patch: string;\n readonly incoming: readonly string[];\n}\nexport interface HostBackup {\n readonly previousPatch: string;\n readonly previousExtras: readonly string[];\n}\n"]}
|
|
@@ -34,7 +34,8 @@ export function sandboxAgents(context) {
|
|
|
34
34
|
const storage = storageFor(agent);
|
|
35
35
|
invariant(storage, "This adapter does not support native conversations");
|
|
36
36
|
const found = await storage.locate(id, workspace.repository, options.conversationHome);
|
|
37
|
-
if (
|
|
37
|
+
if (found.reference !== undefined ||
|
|
38
|
+
provider.placement !== "host" ||
|
|
38
39
|
workspace.directory !== workspace.repository)
|
|
39
40
|
await storage.restore(found, {
|
|
40
41
|
repository: workspace.repository,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-agents.js","sourceRoot":"","sources":["../../src/application/sandbox-agents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhD,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC7E,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,EACvB,QAAkC,EAClC,MAAmB,EACnB,EAAE;QACF,SAAS,CAAC,QAAQ,EAAE,mDAAmD,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;YACzB,QAAQ,CAAC,GAAG,CACV,QAAQ,EACR,QAAQ,CAAC,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SAAS,KAAK,MAAM;YAC7B,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,UAAU;YAE5C,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE;gBAC3B,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,OAAO,EAAE,OAAO;gBAChB,OAAO;aACR,CAAC,CAAC;QACL,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,OAAO;QACP,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACtB,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentAdapter } from \"../domain/agent.types.ts\";\nimport type { Command } from \"../domain/command.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { resolveVariables } from \"../infrastructure/settings.ts\";\nimport { prepareAdapter } from \"./agent-bootstrap.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport type {\n ProvisionedSandbox,\n SandboxAgents,\n} from \"./sandbox-session.types.ts\";\n\nexport function sandboxAgents(context: ProvisionedSandbox): SandboxAgents {\n const { options, provider, workspace, runtime, prepared, staging } = context;\n const known = new Set<string>();\n const selectAgent = async (\n selected: AgentAdapter | undefined,\n signal: AbortSignal,\n ) => {\n invariant(selected, \"Provide an agent on the sandbox or this operation\");\n if (!prepared.has(selected))\n prepared.set(\n selected,\n provider.placement === \"remote\" && options.bootstrap !== false\n ? await prepareAdapter(selected, runtime, signal)\n : selected,\n );\n const variables = await resolveVariables(\n workspace.repository,\n selected.variables,\n provider.variables,\n );\n const adapter = prepared.get(selected)!;\n return {\n selected,\n adapter,\n executionLease: {\n ...runtime,\n invoke(command: Command) {\n return runtime.invoke({\n ...command,\n variables: { ...variables, ...command.variables },\n });\n },\n },\n };\n };\n const conversationKey = (agent: AgentAdapter, id: string) =>\n `${agent.storage?.name ?? agent.conversations ?? agent.name}:${id}`;\n const restore = async (id: string, agent: AgentAdapter) => {\n if (known.has(conversationKey(agent, id))) return;\n const storage = storageFor(agent);\n invariant(storage, \"This adapter does not support native conversations\");\n const found = await storage.locate(\n id,\n workspace.repository,\n options.conversationHome,\n );\n if (\n provider.placement !== \"host\" ||\n workspace.directory !== workspace.repository\n )\n await storage.restore(found, {\n repository: workspace.repository,\n sandbox: runtime,\n staging,\n });\n known.add(conversationKey(agent, id));\n };\n\n return {\n selectAgent,\n restore,\n remember: (agent, id) => {\n known.add(conversationKey(agent, id));\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sandbox-agents.js","sourceRoot":"","sources":["../../src/application/sandbox-agents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhD,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC7E,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,WAAW,GAAG,KAAK,EACvB,QAAkC,EAClC,MAAmB,EACnB,EAAE;QACF,SAAS,CAAC,QAAQ,EAAE,mDAAmD,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;YACzB,QAAQ,CAAC,GAAG,CACV,QAAQ,EACR,QAAQ,CAAC,SAAS,KAAK,QAAQ,IAAI,OAAO,CAAC,SAAS,KAAK,KAAK;gBAC5D,CAAC,CAAC,MAAM,cAAc,CAA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,CAAC,UAAU;YAE5C,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE;gBAC3B,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,OAAO,EAAE,OAAO;gBAChB,OAAO;aACR,CAAC,CAAC;QACL,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC;IAEF,OAAO;QACL,WAAW;QACX,OAAO;QACP,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;YACtB,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentAdapter } from \"../domain/agent.types.ts\";\nimport type { Command } from \"../domain/command.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { resolveVariables } from \"../infrastructure/settings.ts\";\nimport { prepareAdapter } from \"./agent-bootstrap.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport type {\n ProvisionedSandbox,\n SandboxAgents,\n} from \"./sandbox-session.types.ts\";\n\nexport function sandboxAgents(context: ProvisionedSandbox): SandboxAgents {\n const { options, provider, workspace, runtime, prepared, staging } = context;\n const known = new Set<string>();\n const selectAgent = async (\n selected: AgentAdapter | undefined,\n signal: AbortSignal,\n ) => {\n invariant(selected, \"Provide an agent on the sandbox or this operation\");\n if (!prepared.has(selected))\n prepared.set(\n selected,\n provider.placement === \"remote\" && options.bootstrap !== false\n ? await prepareAdapter(selected, runtime, signal)\n : selected,\n );\n const variables = await resolveVariables(\n workspace.repository,\n selected.variables,\n provider.variables,\n );\n const adapter = prepared.get(selected)!;\n return {\n selected,\n adapter,\n executionLease: {\n ...runtime,\n invoke(command: Command) {\n return runtime.invoke({\n ...command,\n variables: { ...variables, ...command.variables },\n });\n },\n },\n };\n };\n const conversationKey = (agent: AgentAdapter, id: string) =>\n `${agent.storage?.name ?? agent.conversations ?? agent.name}:${id}`;\n const restore = async (id: string, agent: AgentAdapter) => {\n if (known.has(conversationKey(agent, id))) return;\n const storage = storageFor(agent);\n invariant(storage, \"This adapter does not support native conversations\");\n const found = await storage.locate(\n id,\n workspace.repository,\n options.conversationHome,\n );\n if (\n found.reference !== undefined ||\n provider.placement !== \"host\" ||\n workspace.directory !== workspace.repository\n )\n await storage.restore(found, {\n repository: workspace.repository,\n sandbox: runtime,\n staging,\n });\n known.add(conversationKey(agent, id));\n };\n\n return {\n selectAgent,\n restore,\n remember: (agent, id) => {\n known.add(conversationKey(agent, id));\n },\n };\n}\n"]}
|
|
@@ -61,6 +61,9 @@ export async function dispatchInSandbox(context, agents, result, dispatch) {
|
|
|
61
61
|
return {
|
|
62
62
|
...turn,
|
|
63
63
|
transcript: location.file,
|
|
64
|
+
...(location.reference
|
|
65
|
+
? { transcriptReference: location.reference }
|
|
66
|
+
: {}),
|
|
64
67
|
...(usage ? { usage } : {}),
|
|
65
68
|
};
|
|
66
69
|
});
|
|
@@ -98,6 +101,8 @@ export async function dispatchInSandbox(context, agents, result, dispatch) {
|
|
|
98
101
|
commits: changes,
|
|
99
102
|
transcript: transcript?.file,
|
|
100
103
|
log: log.file,
|
|
104
|
+
logReference: log.reference,
|
|
105
|
+
transcriptReference: transcript?.reference,
|
|
101
106
|
});
|
|
102
107
|
throw failure;
|
|
103
108
|
}
|
|
@@ -109,6 +114,10 @@ export async function dispatchInSandbox(context, agents, result, dispatch) {
|
|
|
109
114
|
commits: changes,
|
|
110
115
|
...(transcript ? { transcript: transcript.file } : {}),
|
|
111
116
|
...(log.file ? { log: log.file } : {}),
|
|
117
|
+
...(log.reference ? { logReference: log.reference } : {}),
|
|
118
|
+
...(transcript?.reference
|
|
119
|
+
? { transcriptReference: transcript.reference }
|
|
120
|
+
: {}),
|
|
112
121
|
resume(next) {
|
|
113
122
|
warmContinuation(next);
|
|
114
123
|
invariant(conversation, "No conversation was emitted");
|
|
@@ -1 +1 @@
|
|
|
1
|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E;YACtB,MAAM,EAAE,SAAS,CAAC,MAAM;YACxB,SAAS,EAAE,SAAS,CAAC,SAAS;YAC9B,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE,UAAU,EAAE,IAAI;YAC5B,GAAG,EAAE,GAAG,CAAC,IAAI;SACd,CAAC,CAAC;QACH,MAAM,OAAO,CAAC;IAChB,CAAC;IACD,SAAS,CAAC,SAAS,EAAE,oCAAoC,CAAC,CAAC;IAC3D,OAAO;QACL,GAAG,SAAS;QACZ,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,OAAO,EAAE,OAAO;QAChB,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,MAAM,CAAI,IAAwB;YAChC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACvB,SAAS,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;YACvD,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAI,IAAwB;YAC9B,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACvB,SAAS,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;YACvD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { ConversationRecord } from \"../domain/conversation.types.ts\";\nimport { invariant, recordRecovery } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { commits } from \"../infrastructure/git/history.ts\";\nimport { journal } from \"../infrastructure/journal.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { warmContinuation } from \"./continuation.ts\";\nimport { preflightDispatch } from \"./dispatch-validation.ts\";\nimport { execute } from \"./execution.ts\";\nimport type { DispatchOptions, Execution } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\nimport type { Sandbox, WarmDispatchResult } from \"./outpost.types.ts\";\nimport type {\n ProvisionedSandbox,\n SandboxAgents,\n} from \"./sandbox-session.types.ts\";\n\nexport async function dispatchInSandbox<T>(\n context: ProvisionedSandbox,\n agents: SandboxAgents,\n result: Sandbox,\n dispatch: DispatchOptions<T>,\n): Promise<WarmDispatchResult<T>> {\n const { options, provider, workspace, runtime, sync, stop, staging } =\n context;\n const { selectAgent, restore } = agents;\n await preflightDispatch(\n dispatch,\n workspace.repository,\n dispatch.agent ?? options.agent,\n );\n const signal = dispatch.signal\n ? AbortSignal.any([dispatch.signal, stop.signal])\n : stop.signal;\n const { selected, adapter, executionLease } = await selectAgent(\n dispatch.agent ?? options.agent,\n signal,\n );\n if (dispatch.continuation) await restore(dispatch.continuation.id, selected);\n const baseline = (\n await git(workspace.directory, [\"rev-parse\", \"HEAD\"])\n ).trim();\n const log = await journal(\n workspace.repository,\n dispatch.logging ?? options.logging,\n dispatch.label,\n );\n let execution: Execution<T> | undefined,\n transcript: ConversationRecord | undefined;\n const captured = new Map<string, ConversationRecord>();\n const storage = storageFor(selected);\n let failure: unknown;\n let conversation = dispatch.continuation?.id;\n const conversations = new Set<string>(conversation ? [conversation] : []);\n const save = async (id: string) => {\n invariant(storage, \"Conversation storage is unavailable\");\n const location = await storage.capture(id, {\n repository: workspace.repository,\n sandbox: runtime,\n staging,\n ...(options.conversationHome ? { home: options.conversationHome } : {}),\n ...(dispatch.warn ? { warn: dispatch.warn } : {}),\n local: provider.placement === \"host\",\n });\n captured.set(id, location);\n transcript = location;\n return location;\n };\n try {\n execution = await execute(\n workspace,\n executionLease,\n adapter,\n provider.placement === \"host\",\n {\n ...dispatch,\n signal,\n observe(event) {\n if (event.kind === \"conversation\") {\n conversation = event.id;\n conversations.add(event.id);\n agents.remember(selected, event.id);\n }\n log.record(event);\n notify(dispatch.observe, event);\n },\n },\n async (turn) => {\n if (!turn.conversation || !storage || selected.capture === false)\n return turn;\n const location = await save(turn.conversation);\n const usage = selected.transcriptUsage?.(\n await readFile(location.file, \"utf8\"),\n );\n return {\n ...turn,\n transcript: location.file,\n ...(usage ? { usage } : {}),\n };\n },\n );\n } catch (cause) {\n failure = cause;\n log.record({\n kind: \"failure\",\n message: cause instanceof Error ? cause.message : String(cause),\n });\n }\n try {\n await sync?.pull();\n if (storage && selected.capture !== false)\n for (const id of conversations)\n if (failure || !captured.has(id)) await save(id);\n } catch (cause) {\n failure = failure\n ? new AggregateError(\n [failure, cause],\n \"Execution and recovery both failed\",\n )\n : cause;\n }\n try {\n await log.close();\n } catch (cause) {\n failure ??= cause;\n }\n const changes = await commits(\n workspace.directory,\n baseline,\n options.limits?.collectMs,\n );\n if (failure) {\n recordRecovery(failure, {\n branch: workspace.branch,\n directory: workspace.directory,\n commits: changes,\n transcript: transcript?.file,\n log: log.file,\n });\n throw failure;\n }\n invariant(execution, \"Execution did not produce a result\");\n return {\n ...execution,\n branch: workspace.branch,\n directory: workspace.directory,\n commits: changes,\n ...(transcript ? { transcript: transcript.file } : {}),\n ...(log.file ? { log: log.file } : {}),\n resume<U>(next: DispatchOptions<U>) {\n warmContinuation(next);\n invariant(conversation, \"No conversation was emitted\");\n return result.resume(conversation, { agent: selected, ...next });\n },\n fork<U>(next: DispatchOptions<U>) {\n warmContinuation(next);\n invariant(conversation, \"No conversation was emitted\");\n return result.fork(conversation, { agent: selected, ...next });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sandbox-dispatch.js","sourceRoot":"","sources":["../../src/application/sandbox-dispatch.ts"],"names":[],"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IAAI,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAI,IAAwB;YAC9B,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACvB,SAAS,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;YACvD,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { ConversationRecord } from \"../domain/conversation.types.ts\";\nimport { invariant, recordRecovery } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { commits } from \"../infrastructure/git/history.ts\";\nimport { journal } from \"../infrastructure/journal.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { warmContinuation } from \"./continuation.ts\";\nimport { preflightDispatch } from \"./dispatch-validation.ts\";\nimport { execute } from \"./execution.ts\";\nimport type { DispatchOptions, Execution } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\nimport type { Sandbox, WarmDispatchResult } from \"./outpost.types.ts\";\nimport type {\n ProvisionedSandbox,\n SandboxAgents,\n} from \"./sandbox-session.types.ts\";\n\nexport async function dispatchInSandbox<T>(\n context: ProvisionedSandbox,\n agents: SandboxAgents,\n result: Sandbox,\n dispatch: DispatchOptions<T>,\n): Promise<WarmDispatchResult<T>> {\n const { options, provider, workspace, runtime, sync, stop, staging } =\n context;\n const { selectAgent, restore } = agents;\n await preflightDispatch(\n dispatch,\n workspace.repository,\n dispatch.agent ?? options.agent,\n );\n const signal = dispatch.signal\n ? AbortSignal.any([dispatch.signal, stop.signal])\n : stop.signal;\n const { selected, adapter, executionLease } = await selectAgent(\n dispatch.agent ?? options.agent,\n signal,\n );\n if (dispatch.continuation) await restore(dispatch.continuation.id, selected);\n const baseline = (\n await git(workspace.directory, [\"rev-parse\", \"HEAD\"])\n ).trim();\n const log = await journal(\n workspace.repository,\n dispatch.logging ?? options.logging,\n dispatch.label,\n );\n let execution: Execution<T> | undefined,\n transcript: ConversationRecord | undefined;\n const captured = new Map<string, ConversationRecord>();\n const storage = storageFor(selected);\n let failure: unknown;\n let conversation = dispatch.continuation?.id;\n const conversations = new Set<string>(conversation ? [conversation] : []);\n const save = async (id: string) => {\n invariant(storage, \"Conversation storage is unavailable\");\n const location = await storage.capture(id, {\n repository: workspace.repository,\n sandbox: runtime,\n staging,\n ...(options.conversationHome ? { home: options.conversationHome } : {}),\n ...(dispatch.warn ? { warn: dispatch.warn } : {}),\n local: provider.placement === \"host\",\n });\n captured.set(id, location);\n transcript = location;\n return location;\n };\n try {\n execution = await execute(\n workspace,\n executionLease,\n adapter,\n provider.placement === \"host\",\n {\n ...dispatch,\n signal,\n observe(event) {\n if (event.kind === \"conversation\") {\n conversation = event.id;\n conversations.add(event.id);\n agents.remember(selected, event.id);\n }\n log.record(event);\n notify(dispatch.observe, event);\n },\n },\n async (turn) => {\n if (!turn.conversation || !storage || selected.capture === false)\n return turn;\n const location = await save(turn.conversation);\n const usage = selected.transcriptUsage?.(\n await readFile(location.file, \"utf8\"),\n );\n return {\n ...turn,\n transcript: location.file,\n ...(location.reference\n ? { transcriptReference: location.reference }\n : {}),\n ...(usage ? { usage } : {}),\n };\n },\n );\n } catch (cause) {\n failure = cause;\n log.record({\n kind: \"failure\",\n message: cause instanceof Error ? cause.message : String(cause),\n });\n }\n try {\n await sync?.pull();\n if (storage && selected.capture !== false)\n for (const id of conversations)\n if (failure || !captured.has(id)) await save(id);\n } catch (cause) {\n failure = failure\n ? new AggregateError(\n [failure, cause],\n \"Execution and recovery both failed\",\n )\n : cause;\n }\n try {\n await log.close();\n } catch (cause) {\n failure ??= cause;\n }\n const changes = await commits(\n workspace.directory,\n baseline,\n options.limits?.collectMs,\n );\n if (failure) {\n recordRecovery(failure, {\n branch: workspace.branch,\n directory: workspace.directory,\n commits: changes,\n transcript: transcript?.file,\n log: log.file,\n logReference: log.reference,\n transcriptReference: transcript?.reference,\n });\n throw failure;\n }\n invariant(execution, \"Execution did not produce a result\");\n return {\n ...execution,\n branch: workspace.branch,\n directory: workspace.directory,\n commits: changes,\n ...(transcript ? { transcript: transcript.file } : {}),\n ...(log.file ? { log: log.file } : {}),\n ...(log.reference ? { logReference: log.reference } : {}),\n ...(transcript?.reference\n ? { transcriptReference: transcript.reference }\n : {}),\n resume<U>(next: DispatchOptions<U>) {\n warmContinuation(next);\n invariant(conversation, \"No conversation was emitted\");\n return result.resume(conversation, { agent: selected, ...next });\n },\n fork<U>(next: DispatchOptions<U>) {\n warmContinuation(next);\n invariant(conversation, \"No conversation was emitted\");\n return result.fork(conversation, { agent: selected, ...next });\n },\n };\n}\n"]}
|
|
@@ -46,6 +46,9 @@ export async function provisionSandbox(options) {
|
|
|
46
46
|
try {
|
|
47
47
|
activity = await registerResourceActivity({
|
|
48
48
|
repository: workspace.repository,
|
|
49
|
+
...(options.activityTransport
|
|
50
|
+
? { transporter: options.activityTransport }
|
|
51
|
+
: {}),
|
|
49
52
|
workspace: workspace.directory,
|
|
50
53
|
provider: provider.name,
|
|
51
54
|
placement: provider.placement,
|
|
@@ -74,6 +77,9 @@ export async function provisionSandbox(options) {
|
|
|
74
77
|
});
|
|
75
78
|
if (provider.placement === "remote") {
|
|
76
79
|
sync = await seedRemote(workspace, lease, {
|
|
80
|
+
...(options.recoveryTransport
|
|
81
|
+
? { recoveryTransport: options.recoveryTransport }
|
|
82
|
+
: {}),
|
|
77
83
|
...(options.includeUncommitted ? { includeUncommitted: true } : {}),
|
|
78
84
|
...(options.limits ? { limits: options.limits } : {}),
|
|
79
85
|
signal: setupSignal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-provision.js","sourceRoot":"","sources":["../../src/application/sandbox-provision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,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OAAO;QACL,OAAO;QACP,QAAQ;QACR,SAAS;QACT,KAAK;QACL,KAAK;QACL,IAAI;QACJ,OAAO,EAAE,KAAK;QACd,QAAQ;QACR,IAAI;QACJ,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { lstat } from \"node:fs/promises\";\nimport { join, posix } from \"node:path\";\nimport type { AgentAdapter } from \"../domain/agent.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { executeProcess } from \"../infrastructure/process.ts\";\nimport { resolveVariables } from \"../infrastructure/settings.ts\";\nimport { registerResourceActivity } from \"../infrastructure/resource-activity.ts\";\nimport type { ResourceActivity } from \"../infrastructure/resource-activity.types.ts\";\nimport { trackedSandboxLease } from \"./sandbox-activity.ts\";\nimport { boundedTransfers } from \"../infrastructure/transfer.ts\";\nimport { docker } from \"../providers/docker.ts\";\nimport { prepareAdapter } from \"./agent-bootstrap.ts\";\nimport { hooks } from \"./lifecycle-hooks.ts\";\nimport type { SandboxOptions } from \"./outpost.types.ts\";\nimport { uploadFiles } from \"./remote-upload.ts\";\nimport { seedRemote } from \"./remote-workspace.ts\";\nimport type { RemoteSync } from \"./remote-workspace.types.ts\";\nimport type { ProvisionedSandbox } from \"./sandbox-session.types.ts\";\nimport { startupFailure } from \"./startup-recovery.ts\";\nimport { workspaces } from \"./workspace-registry.ts\";\nimport { openWorkspace } from \"./workspace.ts\";\n\nexport async function provisionSandbox(\n options: SandboxOptions,\n): Promise<ProvisionedSandbox> {\n options.signal?.throwIfAborted();\n const provider = options.provider ?? docker();\n if (provider.placement === \"remote\" && !options.workspace && !options.branch)\n options = { ...options, branch: { mode: \"integrate\" } };\n invariant(\n !options.workspace ||\n (!options.repository &&\n !options.branch &&\n !options.copies &&\n !options.storageQuota),\n \"A supplied workspace owns its repository, branch, copied inputs and storage quota\",\n );\n const owned = !options.workspace;\n invariant(\n provider.placement !== \"remote\" ||\n ((options.workspace?.policy ?? options.branch)?.mode !== \"current\" &&\n (options.workspace || options.branch)),\n \"Remote providers require a named or integration workspace\",\n );\n const workspace = options.workspace ?? (await openWorkspace(options));\n const state = workspaces.get(workspace);\n invariant(\n state && !state.closed && !state.active,\n \"Workspace must be open and cannot belong to another sandbox\",\n );\n state.active = true;\n const lifecycle = options.hooks ?? state.hooks;\n const stop = new AbortController();\n const setupSignal = options.signal\n ? AbortSignal.any([options.signal, stop.signal])\n : stop.signal;\n let lease: SandboxLease | undefined, sync: RemoteSync | undefined;\n let activity: ResourceActivity | undefined;\n let acquisitionStarted = false;\n const prepared = new Map<AgentAdapter, AgentAdapter>();\n const staging = join(\n workspace.repository,\n \".outpost\",\n \"recovery\",\n \"conversations\",\n );\n try {\n activity = await registerResourceActivity({\n repository: workspace.repository,\n workspace: workspace.directory,\n provider: provider.name,\n placement: provider.placement,\n });\n const configured = await resolveVariables(\n workspace.repository,\n {},\n provider.variables,\n );\n const name = (\n await git(workspace.repository, [\"config\", \"--get\", \"user.name\"]).catch(\n () => \"Outpost\",\n )\n ).trim();\n const email = (\n await git(workspace.repository, [\"config\", \"--get\", \"user.email\"]).catch(\n () => \"outpost@localhost\",\n )\n ).trim();\n const variables = {\n GIT_AUTHOR_NAME: name,\n GIT_COMMITTER_NAME: name,\n GIT_AUTHOR_EMAIL: email,\n GIT_COMMITTER_EMAIL: email,\n ...configured,\n };\n acquisitionStarted = true;\n lease = boundedTransfers(\n trackedSandboxLease(\n await provider.acquire({\n repository: workspace.repository,\n directory: workspace.directory,\n gitDirectories: workspace.gitDirectories,\n variables,\n signal: setupSignal,\n }),\n activity,\n ),\n {\n ...(options.limits?.copyMs\n ? { deadlineMs: options.limits.copyMs }\n : {}),\n },\n );\n if (provider.placement === \"remote\") {\n sync = await seedRemote(workspace, lease, {\n ...(options.includeUncommitted ? { includeUncommitted: true } : {}),\n ...(options.limits ? { limits: options.limits } : {}),\n signal: setupSignal,\n });\n const copiedFiles: string[] = [];\n for (const path of options.copies ?? []) {\n const info = await lstat(join(workspace.directory, path)).catch(\n (error) => {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\")\n return undefined;\n throw error;\n },\n );\n if (!info) continue;\n if (info.isFile() || info.isSymbolicLink()) {\n copiedFiles.push(path.replaceAll(\"\\\\\", \"/\"));\n continue;\n }\n await lease.upload(\n join(workspace.directory, path),\n posix.join(lease.root, path.replaceAll(\"\\\\\", \"/\")),\n { signal: setupSignal },\n );\n }\n await uploadFiles(lease, workspace.directory, [...new Set(copiedFiles)], {\n signal: setupSignal,\n });\n if (options.bootstrap !== false && options.agent)\n prepared.set(\n options.agent,\n await prepareAdapter(options.agent, lease, setupSignal),\n );\n }\n const initialized = await Promise.allSettled(\n [\n hooks(\n lifecycle?.hostReady ?? [],\n workspace.directory,\n executeProcess,\n setupSignal,\n ),\n hooks(\n lifecycle?.sandboxReady ?? [],\n lease.root,\n lease.invoke.bind(lease),\n setupSignal,\n true,\n ),\n ].map((pending) =>\n pending.catch((cause) => {\n stop.abort(cause);\n throw cause;\n }),\n ),\n );\n const failure = initialized.find((item) => item.status === \"rejected\");\n if (failure?.status === \"rejected\") throw failure.reason;\n await activity.phase(\"ready\");\n } catch (cause) {\n await startupFailure(workspace, cause, options);\n const allocationUncertain = acquisitionStarted && !lease;\n let cleanupFailed = allocationUncertain;\n await activity?.phase(\"closing\").catch(() => {\n cleanupFailed = true;\n });\n await lease?.release().catch(() => {\n cleanupFailed = true;\n });\n if (activity && !(await activity.idle())) cleanupFailed = true;\n state.active = false;\n if (owned)\n await workspace.close({ preserve: cleanupFailed }).catch(() => {\n cleanupFailed = true;\n });\n if (cleanupFailed)\n await activity\n ?.phase(allocationUncertain ? \"allocation-uncertain\" : \"cleanup-failed\")\n .catch(() => undefined);\n if (!cleanupFailed) await activity?.remove().catch(() => undefined);\n throw cause;\n }\n\n return {\n options,\n provider,\n workspace,\n state,\n owned,\n stop,\n runtime: lease,\n activity,\n sync,\n prepared,\n sta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AAK,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC5D,aAAa,GAAG,IAAI,CAAC;YACvB,CAAC,CAAC,CAAC;QACL,IAAI,aAAa;YACf,MAAM,QAAQ;gBACZ,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,CAAC;iBACvE,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,aAAa;YAAE,MAAM,QAAQ,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACpE,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO;QACP,QAAQ;QACR,SAAS;QACT,KAAK;QACL,KAAK;QACL,IAAI;QACJ,OAAO,EAAE,KAAK;QACd,QAAQ;QACR,IAAI;QACJ,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import { lstat } from \"node:fs/promises\";\nimport { join, posix } from \"node:path\";\nimport type { AgentAdapter } from \"../domain/agent.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { executeProcess } from \"../infrastructure/process.ts\";\nimport { resolveVariables } from \"../infrastructure/settings.ts\";\nimport { registerResourceActivity } from \"../infrastructure/resource-activity.ts\";\nimport type { ResourceActivity } from \"../infrastructure/resource-activity.types.ts\";\nimport { trackedSandboxLease } from \"./sandbox-activity.ts\";\nimport { boundedTransfers } from \"../infrastructure/transfer.ts\";\nimport { docker } from \"../providers/docker.ts\";\nimport { prepareAdapter } from \"./agent-bootstrap.ts\";\nimport { hooks } from \"./lifecycle-hooks.ts\";\nimport type { SandboxOptions } from \"./outpost.types.ts\";\nimport { uploadFiles } from \"./remote-upload.ts\";\nimport { seedRemote } from \"./remote-workspace.ts\";\nimport type { RemoteSync } from \"./remote-workspace.types.ts\";\nimport type { ProvisionedSandbox } from \"./sandbox-session.types.ts\";\nimport { startupFailure } from \"./startup-recovery.ts\";\nimport { workspaces } from \"./workspace-registry.ts\";\nimport { openWorkspace } from \"./workspace.ts\";\n\nexport async function provisionSandbox(\n options: SandboxOptions,\n): Promise<ProvisionedSandbox> {\n options.signal?.throwIfAborted();\n const provider = options.provider ?? docker();\n if (provider.placement === \"remote\" && !options.workspace && !options.branch)\n options = { ...options, branch: { mode: \"integrate\" } };\n invariant(\n !options.workspace ||\n (!options.repository &&\n !options.branch &&\n !options.copies &&\n !options.storageQuota),\n \"A supplied workspace owns its repository, branch, copied inputs and storage quota\",\n );\n const owned = !options.workspace;\n invariant(\n provider.placement !== \"remote\" ||\n ((options.workspace?.policy ?? options.branch)?.mode !== \"current\" &&\n (options.workspace || options.branch)),\n \"Remote providers require a named or integration workspace\",\n );\n const workspace = options.workspace ?? (await openWorkspace(options));\n const state = workspaces.get(workspace);\n invariant(\n state && !state.closed && !state.active,\n \"Workspace must be open and cannot belong to another sandbox\",\n );\n state.active = true;\n const lifecycle = options.hooks ?? state.hooks;\n const stop = new AbortController();\n const setupSignal = options.signal\n ? AbortSignal.any([options.signal, stop.signal])\n : stop.signal;\n let lease: SandboxLease | undefined, sync: RemoteSync | undefined;\n let activity: ResourceActivity | undefined;\n let acquisitionStarted = false;\n const prepared = new Map<AgentAdapter, AgentAdapter>();\n const staging = join(\n workspace.repository,\n \".outpost\",\n \"recovery\",\n \"conversations\",\n );\n try {\n activity = await registerResourceActivity({\n repository: workspace.repository,\n ...(options.activityTransport\n ? { transporter: options.activityTransport }\n : {}),\n workspace: workspace.directory,\n provider: provider.name,\n placement: provider.placement,\n });\n const configured = await resolveVariables(\n workspace.repository,\n {},\n provider.variables,\n );\n const name = (\n await git(workspace.repository, [\"config\", \"--get\", \"user.name\"]).catch(\n () => \"Outpost\",\n )\n ).trim();\n const email = (\n await git(workspace.repository, [\"config\", \"--get\", \"user.email\"]).catch(\n () => \"outpost@localhost\",\n )\n ).trim();\n const variables = {\n GIT_AUTHOR_NAME: name,\n GIT_COMMITTER_NAME: name,\n GIT_AUTHOR_EMAIL: email,\n GIT_COMMITTER_EMAIL: email,\n ...configured,\n };\n acquisitionStarted = true;\n lease = boundedTransfers(\n trackedSandboxLease(\n await provider.acquire({\n repository: workspace.repository,\n directory: workspace.directory,\n gitDirectories: workspace.gitDirectories,\n variables,\n signal: setupSignal,\n }),\n activity,\n ),\n {\n ...(options.limits?.copyMs\n ? { deadlineMs: options.limits.copyMs }\n : {}),\n },\n );\n if (provider.placement === \"remote\") {\n sync = await seedRemote(workspace, lease, {\n ...(options.recoveryTransport\n ? { recoveryTransport: options.recoveryTransport }\n : {}),\n ...(options.includeUncommitted ? { includeUncommitted: true } : {}),\n ...(options.limits ? { limits: options.limits } : {}),\n signal: setupSignal,\n });\n const copiedFiles: string[] = [];\n for (const path of options.copies ?? []) {\n const info = await lstat(join(workspace.directory, path)).catch(\n (error) => {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\")\n return undefined;\n throw error;\n },\n );\n if (!info) continue;\n if (info.isFile() || info.isSymbolicLink()) {\n copiedFiles.push(path.replaceAll(\"\\\\\", \"/\"));\n continue;\n }\n await lease.upload(\n join(workspace.directory, path),\n posix.join(lease.root, path.replaceAll(\"\\\\\", \"/\")),\n { signal: setupSignal },\n );\n }\n await uploadFiles(lease, workspace.directory, [...new Set(copiedFiles)], {\n signal: setupSignal,\n });\n if (options.bootstrap !== false && options.agent)\n prepared.set(\n options.agent,\n await prepareAdapter(options.agent, lease, setupSignal),\n );\n }\n const initialized = await Promise.allSettled(\n [\n hooks(\n lifecycle?.hostReady ?? [],\n workspace.directory,\n executeProcess,\n setupSignal,\n ),\n hooks(\n lifecycle?.sandboxReady ?? [],\n lease.root,\n lease.invoke.bind(lease),\n setupSignal,\n true,\n ),\n ].map((pending) =>\n pending.catch((cause) => {\n stop.abort(cause);\n throw cause;\n }),\n ),\n );\n const failure = initialized.find((item) => item.status === \"rejected\");\n if (failure?.status === \"rejected\") throw failure.reason;\n await activity.phase(\"ready\");\n } catch (cause) {\n await startupFailure(workspace, cause, options);\n const allocationUncertain = acquisitionStarted && !lease;\n let cleanupFailed = allocationUncertain;\n await activity?.phase(\"closing\").catch(() => {\n cleanupFailed = true;\n });\n await lease?.release().catch(() => {\n cleanupFailed = true;\n });\n if (activity && !(await activity.idle())) cleanupFailed = true;\n state.active = false;\n if (owned)\n await workspace.close({ preserve: cleanupFailed }).catch(() => {\n cleanupFailed = true;\n });\n if (cleanupFailed)\n await activity\n ?.phase(allocationUncertain ? \"allocation-uncertain\" : \"cleanup-failed\")\n .catch(() => undefined);\n if (!cleanupFailed) await activity?.remove().catch(() => undefined);\n throw cause;\n }\n\n return {\n options,\n provider,\n workspace,\n state,\n owned,\n stop,\n runtime: lease,\n activity,\n sync,\n prepared,\n staging,\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reserveTransportStorage } from "../infrastructure/transport-reservations.js";
|
|
1
2
|
import { directory } from "../infrastructure/files.js";
|
|
2
3
|
import { git } from "../infrastructure/git/command.js";
|
|
3
4
|
import { reserveStorage } from "../infrastructure/storage-reservations.js";
|
|
@@ -5,6 +6,8 @@ export async function reserveRecoveryStorage(options) {
|
|
|
5
6
|
options.signal?.throwIfAborted();
|
|
6
7
|
const requested = await directory(options.repository);
|
|
7
8
|
const root = await directory((await git(requested, ["rev-parse", "--show-toplevel"])).trim());
|
|
9
|
+
if (options.transporter)
|
|
10
|
+
return reserveTransportStorage(options.transporter, root, options);
|
|
8
11
|
return reserveStorage(root, options);
|
|
9
12
|
}
|
|
10
13
|
//# sourceMappingURL=storage-reservation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-reservation.js","sourceRoot":"","sources":["../../src/application/storage-reservation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAI3E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAA0C;IAE1C,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,MAAM,SAAS,CAC1B,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAChE,CAAC;IACF,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { directory } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { reserveStorage } from \"../infrastructure/storage-reservations.ts\";\nimport type { StorageReservation } from \"../infrastructure/storage-reservations.types.ts\";\nimport type { RecoveryStorageReservationOptions } from \"./storage-reservation.types.ts\";\n\nexport async function reserveRecoveryStorage(\n options: RecoveryStorageReservationOptions,\n): Promise<StorageReservation> {\n options.signal?.throwIfAborted();\n const requested = await directory(options.repository);\n const root = await directory(\n (await git(requested, [\"rev-parse\", \"--show-toplevel\"])).trim(),\n );\n return reserveStorage(root, options);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage-reservation.js","sourceRoot":"","sources":["../../src/application/storage-reservation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAI3E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAA0C;IAE1C,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,MAAM,SAAS,CAC1B,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAChE,CAAC;IACF,IAAI,OAAO,CAAC,WAAW;QACrB,OAAO,uBAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACrE,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { reserveTransportStorage } from \"../infrastructure/transport-reservations.ts\";\nimport { directory } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { reserveStorage } from \"../infrastructure/storage-reservations.ts\";\nimport type { StorageReservation } from \"../infrastructure/storage-reservations.types.ts\";\nimport type { RecoveryStorageReservationOptions } from \"./storage-reservation.types.ts\";\n\nexport async function reserveRecoveryStorage(\n options: RecoveryStorageReservationOptions,\n): Promise<StorageReservation> {\n options.signal?.throwIfAborted();\n const requested = await directory(options.repository);\n const root = await directory(\n (await git(requested, [\"rev-parse\", \"--show-toplevel\"])).trim(),\n );\n if (options.transporter)\n return reserveTransportStorage(options.transporter, root, options);\n return reserveStorage(root, options);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-inspection.constants.js","sourceRoot":"","sources":["../../src/application/transport-inspection.constants.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,mBAAmB,GAAmC;IACjE,WAAW;IACX,aAAa;IACb,eAAe;IACf,UAAU;IACV,MAAM;IACN,cAAc;IACd,WAAW;CACZ,CAAC","sourcesContent":["import type { StorageCategoryName } from \"../infrastructure/storage-inventory.types.ts\";\nexport const transportCategories: readonly StorageCategoryName[] = [\n \"artifacts\",\n \"checkpoints\",\n \"conversations\",\n \"recovery\",\n \"logs\",\n \"reservations\",\n \"resources\",\n];\n"]}
|