@elie-laloum/outpost 4.0.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 +25 -0
- package/README.md +10 -6
- package/SECURITY.md +2 -0
- package/dist/adapters/agents/codex-adapter.js +2 -0
- package/dist/adapters/agents/codex-adapter.js.map +1 -1
- package/dist/adapters/agents/codex-provider.d.ts +2 -0
- package/dist/adapters/agents/codex-provider.js +32 -0
- package/dist/adapters/agents/codex-provider.js.map +1 -0
- package/dist/adapters/agents/codex-request.js +2 -1
- package/dist/adapters/agents/codex-request.js.map +1 -1
- package/dist/adapters/agents/gemini-request.js +2 -0
- package/dist/adapters/agents/gemini-request.js.map +1 -1
- package/dist/adapters/agents/settings.types.d.ts +5 -0
- package/dist/adapters/agents/settings.types.js.map +1 -1
- 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/cli/commands.js +55 -18
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/init-authentication.constants.d.ts +13 -0
- package/dist/cli/init-authentication.constants.js +10 -0
- package/dist/cli/init-authentication.constants.js.map +1 -0
- package/dist/cli/init-authentication.d.ts +4 -0
- package/dist/cli/init-authentication.js +43 -0
- package/dist/cli/init-authentication.js.map +1 -0
- package/dist/cli/init-command.js +74 -15
- package/dist/cli/init-command.js.map +1 -1
- package/dist/cli/main.constants.d.ts +102 -2
- package/dist/cli/main.constants.js +148 -46
- package/dist/cli/main.constants.js.map +1 -1
- package/dist/cli/scaffold-files.js +4 -3
- package/dist/cli/scaffold-files.js.map +1 -1
- package/dist/cli/scaffold-validation.js +19 -0
- package/dist/cli/scaffold-validation.js.map +1 -1
- package/dist/cli/scaffold.constants.d.ts +0 -5
- package/dist/cli/scaffold.constants.js +0 -5
- package/dist/cli/scaffold.constants.js.map +1 -1
- package/dist/cli/scaffold.js +13 -0
- package/dist/cli/scaffold.js.map +1 -1
- package/dist/cli/scaffold.types.d.ts +3 -0
- package/dist/cli/scaffold.types.js.map +1 -1
- package/dist/cli/starters.js +9 -2
- package/dist/cli/starters.js.map +1 -1
- 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 +18 -1
- 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/dist/providers/agents.d.ts +1 -1
- package/dist/providers/agents.js.map +1 -1
- package/dist/providers/daytona-command.constants.d.ts +2 -0
- package/dist/providers/daytona-command.constants.js +13 -0
- package/dist/providers/daytona-command.constants.js.map +1 -0
- package/dist/providers/daytona-command.js +9 -3
- package/dist/providers/daytona-command.js.map +1 -1
- package/dist/providers/daytona-output.d.ts +4 -0
- package/dist/providers/daytona-output.js +37 -0
- package/dist/providers/daytona-output.js.map +1 -0
- package/dist/providers/daytona-terminal.js +3 -1
- package/dist/providers/daytona-terminal.js.map +1 -1
- package/dist/providers/vercel-command.js +2 -2
- package/dist/providers/vercel-command.js.map +1 -1
- package/package.json +31 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-checkpoint.js","sourceRoot":"","sources":["../../src/infrastructure/workflow-checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,MAAM,UAAU,2BAA2B,CACzC,OAAsC;IAEtC,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvD,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,KAAK;YACjB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACzE,MAAM,KAAK,CAAC,mBAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACnE,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,mBAAmB,CAAC,CAAC;YACtD,MAAM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AAK,CAAC,CAAC;wBAChD,IAAI,CAAC;4BACH,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;4BAC3B,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;wBACpB,CAAC;gCAAS,CAAC;4BACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;wBACrB,CAAC;wBACD,MAAM,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;wBAC9B,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;4BACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;4BAC1C,IAAI,CAAC;gCACH,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;4BACtB,CAAC;oCAAS,CAAC;gCACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;4BACvB,CAAC;wBACH,CAAC;oBACH,CAAC;4BAAS,CAAC;wBACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC;gBACD,KAAK,CAAC,OAAO;oBACX,IAAI,QAAQ;wBAAE,OAAO;oBACrB,QAAQ,GAAG,IAAI,CAAC;oBAChB,MAAM,OAAO,EAAE,CAAC;gBAClB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readInspectionFile } from \"./inspection-file.ts\";\nimport { workflowCheckpointMaxBytes } from \"./workflow-checkpoint.constants.ts\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { mkdir, open, realpath, rename, rm } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type { WorkflowCheckpointStore } from \"../domain/workflow/checkpoint.types.ts\";\nimport type { FileWorkflowCheckpointOptions } from \"./workflow-checkpoint.types.ts\";\nimport { lock } from \"./git/lock.ts\";\n\nexport function fileWorkflowCheckpointStore(\n options: FileWorkflowCheckpointOptions,\n): WorkflowCheckpointStore {\n const configuredDirectory = resolve(options.directory);\n return {\n async acquire(runId) {\n if (!runId.trim()) throw new Error(\"Checkpoint runId must not be empty\");\n await mkdir(configuredDirectory, { recursive: true, mode: 0o700 });\n const directory = await realpath(configuredDirectory);\n const release = await lock(directory, `workflow:${runId}`);\n const path = join(\n directory,\n `${createHash(\"sha256\").update(runId).digest(\"hex\")}.json`,\n );\n let released = false;\n const assertOwned = () => {\n if (released) throw new Error(\"Checkpoint lease has been released\");\n };\n return {\n async read() {\n assertOwned();\n try {\n return JSON.parse(\n (\n await readInspectionFile(path, workflowCheckpointMaxBytes)\n ).toString(\"utf8\"),\n ) as unknown;\n } catch (error) {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n )\n return undefined;\n throw error;\n }\n },\n async write(checkpoint) {\n assertOwned();\n const data = JSON.stringify(checkpoint);\n if (Buffer.byteLength(data) > workflowCheckpointMaxBytes)\n throw new Error(\n \"Workflow checkpoint exceeds 16 MiB; store large artifacts separately\",\n );\n const temporary = `${path}.${randomUUID()}.tmp`;\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(data);\n await file.sync();\n } finally {\n await file.close();\n }\n await rename(temporary, path);\n if (process.platform !== \"win32\") {\n const parent = await open(directory, \"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 release() {\n if (released) return;\n released = true;\n await release();\n },\n };\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workflow-checkpoint.js","sourceRoot":"","sources":["../../src/infrastructure/workflow-checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,UAAU,E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AAC;wBACD,MAAM,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;wBAC9B,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;4BACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;4BAC1C,IAAI,CAAC;gCACH,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;4BACtB,CAAC;oCAAS,CAAC;gCACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;4BACvB,CAAC;wBACH,CAAC;oBACH,CAAC;4BAAS,CAAC;wBACT,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC;gBACD,KAAK,CAAC,OAAO;oBACX,IAAI,QAAQ;wBAAE,OAAO;oBACrB,QAAQ,GAAG,IAAI,CAAC;oBAChB,MAAM,OAAO,EAAE,CAAC;gBAClB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { workflowCheckpointStore } from \"./transport-checkpoint.ts\";\nimport { readInspectionFile } from \"./inspection-file.ts\";\nimport { workflowCheckpointMaxBytes } from \"./workflow-checkpoint.constants.ts\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { mkdir, open, realpath, rename, rm } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type { WorkflowCheckpointStore } from \"../domain/workflow/checkpoint.types.ts\";\nimport type { FileWorkflowCheckpointOptions } from \"./workflow-checkpoint.types.ts\";\nimport { lock } from \"./git/lock.ts\";\n\nexport function fileWorkflowCheckpointStore(\n options: FileWorkflowCheckpointOptions,\n): WorkflowCheckpointStore {\n if ((options.directory === undefined) === (options.transporter === undefined))\n throw new Error(\"Provide exactly one checkpoint directory or transporter\");\n if (options.transporter)\n return workflowCheckpointStore({ transporter: options.transporter });\n if (options.directory === undefined)\n throw new Error(\"Checkpoint directory is required\");\n const configuredDirectory = resolve(options.directory);\n return {\n async acquire(runId) {\n if (!runId.trim()) throw new Error(\"Checkpoint runId must not be empty\");\n await mkdir(configuredDirectory, { recursive: true, mode: 0o700 });\n const directory = await realpath(configuredDirectory);\n const release = await lock(directory, `workflow:${runId}`);\n const path = join(\n directory,\n `${createHash(\"sha256\").update(runId).digest(\"hex\")}.json`,\n );\n let released = false;\n const assertOwned = () => {\n if (released) throw new Error(\"Checkpoint lease has been released\");\n };\n return {\n async read() {\n assertOwned();\n try {\n return JSON.parse(\n (\n await readInspectionFile(path, workflowCheckpointMaxBytes)\n ).toString(\"utf8\"),\n ) as unknown;\n } catch (error) {\n if (\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n )\n return undefined;\n throw error;\n }\n },\n async write(checkpoint) {\n assertOwned();\n const data = JSON.stringify(checkpoint);\n if (Buffer.byteLength(data) > workflowCheckpointMaxBytes)\n throw new Error(\n \"Workflow checkpoint exceeds 16 MiB; store large artifacts separately\",\n );\n const temporary = `${path}.${randomUUID()}.tmp`;\n try {\n const file = await open(temporary, \"wx\", 0o600);\n try {\n await file.writeFile(data);\n await file.sync();\n } finally {\n await file.close();\n }\n await rename(temporary, path);\n if (process.platform !== \"win32\") {\n const parent = await open(directory, \"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 release() {\n if (released) return;\n released = true;\n await release();\n },\n };\n },\n };\n}\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { Transport } from "../domain/transport.types.ts";
|
|
1
2
|
export interface FileWorkflowCheckpointOptions {
|
|
2
3
|
/** Private directory for checkpoint data and local process ownership locks. */
|
|
3
|
-
readonly directory
|
|
4
|
+
readonly directory?: string;
|
|
5
|
+
readonly transporter?: Transport;
|
|
4
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-checkpoint.types.js","sourceRoot":"","sources":["../../src/infrastructure/workflow-checkpoint.types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"workflow-checkpoint.types.js","sourceRoot":"","sources":["../../src/infrastructure/workflow-checkpoint.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Transport } from \"../domain/transport.types.ts\";\n\nexport interface FileWorkflowCheckpointOptions {\n /** Private directory for checkpoint data and local process ownership locks. */\n readonly directory?: string;\n readonly transporter?: Transport;\n}\n"]}
|
|
@@ -2,4 +2,4 @@ export { claude } from "../adapters/agents/claude-adapter.ts";
|
|
|
2
2
|
export { codex } from "../adapters/agents/codex-adapter.ts";
|
|
3
3
|
export { gemini } from "../adapters/agents/gemini-adapter.ts";
|
|
4
4
|
export type { GeminiSettings } from "../adapters/agents/gemini.types.ts";
|
|
5
|
-
export type { ClaudeSettings, CodexSettings, } from "../adapters/agents/settings.types.ts";
|
|
5
|
+
export type { ClaudeSettings, CodexSettings, CodexModelProvider, } from "../adapters/agents/settings.types.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/providers/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC","sourcesContent":["export { claude } from \"../adapters/agents/claude-adapter.ts\";\nexport { codex } from \"../adapters/agents/codex-adapter.ts\";\nexport { gemini } from \"../adapters/agents/gemini-adapter.ts\";\nexport type { GeminiSettings } from \"../adapters/agents/gemini.types.ts\";\nexport type {\n ClaudeSettings,\n CodexSettings,\n} from \"../adapters/agents/settings.types.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/providers/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC","sourcesContent":["export { claude } from \"../adapters/agents/claude-adapter.ts\";\nexport { codex } from \"../adapters/agents/codex-adapter.ts\";\nexport { gemini } from \"../adapters/agents/gemini-adapter.ts\";\nexport type { GeminiSettings } from \"../adapters/agents/gemini.types.ts\";\nexport type {\n ClaudeSettings,\n CodexSettings,\n CodexModelProvider,\n} from \"../adapters/agents/settings.types.ts\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const daytonaOutputPrefix = "outpost-output:";
|
|
2
|
+
export const daytonaCommandScript = `const {spawn}=require("node:child_process");
|
|
3
|
+
const {constants}=require("node:os");
|
|
4
|
+
const {Transform}=require("node:stream");
|
|
5
|
+
const frame=data=>${JSON.stringify(daytonaOutputPrefix)}+data.toString("base64")+"\\n";
|
|
6
|
+
const encode=()=>new Transform({transform(data,encoding,done){done(null,frame(data))}});
|
|
7
|
+
const child=spawn(process.argv[1],process.argv.slice(2),{stdio:["inherit","pipe","pipe"]});
|
|
8
|
+
let failed;
|
|
9
|
+
child.stdout.pipe(encode()).pipe(process.stdout);
|
|
10
|
+
child.stderr.pipe(encode()).pipe(process.stderr);
|
|
11
|
+
child.on("error",error=>{failed=error.code==="ENOENT"?127:126;process.stderr.write(frame(Buffer.from(error.message)))});
|
|
12
|
+
child.on("close",(code,signal)=>{process.exitCode=failed??code??(signal?128+(constants.signals[signal]??0):127)});`;
|
|
13
|
+
//# sourceMappingURL=daytona-command.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daytona-command.constants.js","sourceRoot":"","sources":["../../src/providers/daytona-command.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AACrD,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;oBAGhB,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;;;;;;;mHAO4D,CAAC","sourcesContent":["export const daytonaOutputPrefix = \"outpost-output:\";\nexport const daytonaCommandScript = `const {spawn}=require(\"node:child_process\");\nconst {constants}=require(\"node:os\");\nconst {Transform}=require(\"node:stream\");\nconst frame=data=>${JSON.stringify(daytonaOutputPrefix)}+data.toString(\"base64\")+\"\\\\n\";\nconst encode=()=>new Transform({transform(data,encoding,done){done(null,frame(data))}});\nconst child=spawn(process.argv[1],process.argv.slice(2),{stdio:[\"inherit\",\"pipe\",\"pipe\"]});\nlet failed;\nchild.stdout.pipe(encode()).pipe(process.stdout);\nchild.stderr.pipe(encode()).pipe(process.stderr);\nchild.on(\"error\",error=>{failed=error.code===\"ENOENT\"?127:126;process.stderr.write(frame(Buffer.from(error.message)))});\nchild.on(\"close\",(code,signal)=>{process.exitCode=failed??code??(signal?128+(constants.signals[signal]??0):127)});`;\n"]}
|
|
@@ -4,6 +4,8 @@ import { OutpostError } from "../domain/errors.js";
|
|
|
4
4
|
import { interruptible } from "../infrastructure/abort.js";
|
|
5
5
|
import { quote } from "../infrastructure/process.js";
|
|
6
6
|
import { cloudDefaults } from "./cloud.constants.js";
|
|
7
|
+
import { daytonaCommandScript } from "./daytona-command.constants.js";
|
|
8
|
+
import { daytonaOutput } from "./daytona-output.js";
|
|
7
9
|
import { daytonaTerminal } from "./daytona-terminal.js";
|
|
8
10
|
export function daytonaCommand(runtime) {
|
|
9
11
|
const { sandbox, root, options, context, isClosed } = runtime;
|
|
@@ -32,9 +34,9 @@ export function daytonaCommand(runtime) {
|
|
|
32
34
|
]
|
|
33
35
|
.map(quote)
|
|
34
36
|
.join(" ");
|
|
35
|
-
const script = `cd ${quote(command.directory ?? root)} &&
|
|
37
|
+
const script = `cd ${quote(command.directory ?? root)} && env ${Object.entries(variables)
|
|
36
38
|
.map(([key, value]) => quote(`${key}=${value}`))
|
|
37
|
-
.join(" ")} setsid sh -c ${quote(`echo $$ > ${quote(pid)}; test ! -f ${quote(pid + ".cancel")} || exit 130; exec ${program}${command.stdin === undefined ? "" : ` < ${quote(input)}`}`)}`;
|
|
39
|
+
.join(" ")} setsid --wait sh -c ${quote(`echo $$ > ${quote(pid)}; test ! -f ${quote(pid + ".cancel")} || exit 130; exec node -e ${quote(daytonaCommandScript)} -- ${program}${command.stdin === undefined ? "" : ` < ${quote(input)}`}`)}`;
|
|
38
40
|
const output = { stdout: "", stderr: "" };
|
|
39
41
|
let cancellation;
|
|
40
42
|
const cancel = () => {
|
|
@@ -57,7 +59,11 @@ export function daytonaCommand(runtime) {
|
|
|
57
59
|
output[channel] = (output[channel] + chunk).slice(-(command.retain ?? options.retain ?? cloudDefaults.retainBytes));
|
|
58
60
|
command.observe?.(channel, chunk);
|
|
59
61
|
};
|
|
60
|
-
|
|
62
|
+
const stdout = daytonaOutput(consume("stdout"));
|
|
63
|
+
const stderr = daytonaOutput(consume("stderr"));
|
|
64
|
+
await interruptible(sandbox.process.getSessionCommandLogs(id, response.cmdId, stdout.write, stderr.write), signal);
|
|
65
|
+
stdout.close();
|
|
66
|
+
stderr.close();
|
|
61
67
|
if (cancellation)
|
|
62
68
|
await cancellation;
|
|
63
69
|
signal.throwIfAborted();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daytona-command.js","sourceRoot":"","sources":["../../src/providers/daytona-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,UAAU,cAAc,CAC5B,OAAuB;IAEvB,MAAM,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,KAAK,EAAE,CAAC;YACf,MAAM,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,aAAa,CACjB,YAAa,EACb,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAClD,CAAC;YACJ,CAAC;YAAC,OAAO,OAAO,EAAE,CAAC;gBACjB,MAAM,IAAI,cAAc,CACtB,CAAC,KAAK,EAAE,OAAO,CAAC,EAChB,2CAA2C,CAC5C,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5C,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YACxC,MAAM,OAAO,CAAC,OAAO;iBAClB,cAAc,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;iBACrD,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { setTimeout } from \"node:timers/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { interruptible } from \"../infrastructure/abort.ts\";\nimport { quote } from \"../infrastructure/process.ts\";\nimport { cloudDefaults } from \"./cloud.constants.ts\";\nimport { daytonaCommandScript } from \"./daytona-command.constants.ts\";\nimport { daytonaOutput } from \"./daytona-output.ts\";\nimport { daytonaTerminal } from \"./daytona-terminal.ts\";\nimport type { DaytonaRuntime } from \"./daytona.types.ts\";\n\nexport function daytonaCommand(\n runtime: DaytonaRuntime,\n): SandboxLease[\"invoke\"] {\n const { sandbox, root, options, context, isClosed } = runtime;\n return async (command) => {\n if (isClosed())\n throw new OutpostError(\"provider\", \"Cloud sandbox is closed\");\n const signal = command.signal\n ? AbortSignal.any([\n command.signal,\n AbortSignal.timeout(command.deadlineMs ?? cloudDefaults.deadlineMs),\n ])\n : AbortSignal.timeout(command.deadlineMs ?? cloudDefaults.deadlineMs);\n signal.throwIfAborted();\n if (command.interactive) return daytonaTerminal(runtime, command, signal);\n const id = `outpost-${randomUUID()}`;\n const input = `/tmp/${id}.stdin`;\n const pid = `/tmp/${id}.pid`;\n if (command.stdin !== undefined)\n await sandbox.fs.uploadFile(Buffer.from(command.stdin), input);\n const variables = { ...context.variables, ...command.variables };\n const program = [\n ...(command.elevated ? [\"sudo\", \"-n\", \"--\"] : []),\n command.executable,\n ...(command.arguments ?? []),\n ]\n .map(quote)\n .join(\" \");\n const script = `cd ${quote(command.directory ?? root)} && env ${Object.entries(\n variables,\n )\n .map(([key, value]) => quote(`${key}=${value}`))\n .join(\n \" \",\n )} setsid --wait sh -c ${quote(`echo $$ > ${quote(pid)}; test ! -f ${quote(pid + \".cancel\")} || exit 130; exec node -e ${quote(daytonaCommandScript)} -- ${program}${command.stdin === undefined ? \"\" : ` < ${quote(input)}`}`)}`;\n const output = { stdout: \"\", stderr: \"\" };\n let cancellation: Promise<unknown> | undefined;\n const cancel = () => {\n cancellation ??= sandbox.process.executeCommand(\n `touch ${quote(pid + \".cancel\")}; if [ -f ${quote(pid)} ]; then kill -KILL -$(cat ${quote(pid)}) 2>/dev/null || true; fi`,\n );\n void cancellation.catch(() => undefined);\n };\n await sandbox.process.createSession(id);\n try {\n signal.addEventListener(\"abort\", cancel, { once: true });\n if (signal.aborted) cancel();\n signal.throwIfAborted();\n const response = await interruptible(\n sandbox.process.executeSessionCommand(id, {\n command: script,\n async: true,\n }),\n signal,\n );\n if (!response.cmdId)\n throw new OutpostError(\n \"provider\",\n \"Cloud provider returned no command identifier\",\n );\n const consume = (channel: \"stdout\" | \"stderr\") => (chunk: string) => {\n output[channel] = (output[channel] + chunk).slice(\n -(command.retain ?? options.retain ?? cloudDefaults.retainBytes),\n );\n command.observe?.(channel, chunk);\n };\n const stdout = daytonaOutput(consume(\"stdout\"));\n const stderr = daytonaOutput(consume(\"stderr\"));\n await interruptible(\n sandbox.process.getSessionCommandLogs(\n id,\n response.cmdId,\n stdout.write,\n stderr.write,\n ),\n signal,\n );\n stdout.close();\n stderr.close();\n if (cancellation) await cancellation;\n signal.throwIfAborted();\n while (true) {\n const result = await interruptible(\n sandbox.process.getSessionCommand(id, response.cmdId),\n signal,\n );\n if (result.exitCode !== undefined)\n return { status: result.exitCode, ...output };\n await setTimeout(cloudDefaults.pollMs, undefined, { signal });\n }\n } catch (cause) {\n cancel();\n try {\n await interruptible(\n cancellation!,\n AbortSignal.timeout(cloudDefaults.cancellationMs),\n );\n } catch (cleanup) {\n throw new AggregateError(\n [cause, cleanup],\n \"Cloud cancellation could not be confirmed\",\n );\n }\n throw cause;\n } finally {\n signal.removeEventListener(\"abort\", cancel);\n await sandbox.process.deleteSession(id);\n await sandbox.process\n .executeCommand(`rm -f ${quote(input)} ${quote(pid)}`)\n .catch(() => undefined);\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StringDecoder } from "node:string_decoder";
|
|
2
|
+
import { daytonaOutputPrefix } from "./daytona-command.constants.js";
|
|
3
|
+
export function daytonaOutput(emit) {
|
|
4
|
+
const decoder = new StringDecoder("utf8");
|
|
5
|
+
let pending = "";
|
|
6
|
+
return {
|
|
7
|
+
write(chunk) {
|
|
8
|
+
pending += chunk;
|
|
9
|
+
while (pending) {
|
|
10
|
+
if (daytonaOutputPrefix.startsWith(pending))
|
|
11
|
+
return;
|
|
12
|
+
if (!pending.startsWith(daytonaOutputPrefix)) {
|
|
13
|
+
emit(pending);
|
|
14
|
+
pending = "";
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const end = pending.indexOf("\n");
|
|
18
|
+
if (end === -1)
|
|
19
|
+
return;
|
|
20
|
+
const payload = pending.slice(daytonaOutputPrefix.length, end);
|
|
21
|
+
const text = decoder.write(Buffer.from(payload, "base64"));
|
|
22
|
+
if (text)
|
|
23
|
+
emit(text);
|
|
24
|
+
pending = pending.slice(end + 1);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
close() {
|
|
28
|
+
const text = decoder.end();
|
|
29
|
+
if (text)
|
|
30
|
+
emit(text);
|
|
31
|
+
if (pending)
|
|
32
|
+
emit(pending);
|
|
33
|
+
pending = "";
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=daytona-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daytona-output.js","sourceRoot":"","sources":["../../src/providers/daytona-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,UAAU,aAAa,CAAC,IAA4B;IACxD,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,OAAO;QACL,KAAK,CAAC,KAAa;YACjB,OAAO,IAAI,KAAK,CAAC;YACjB,OAAO,OAAO,EAAE,CAAC;gBACf,IAAI,mBAAmB,CAAC,UAAU,CAAC,OAAO,CAAC;oBAAE,OAAO;gBACpD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;oBAC7C,IAAI,CAAC,OAAO,CAAC,CAAC;oBACd,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO;gBACT,CAAC;gBACD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAClC,IAAI,GAAG,KAAK,CAAC,CAAC;oBAAE,OAAO;gBACvB,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC3D,IAAI,IAAI;oBAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,KAAK;YACH,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YAC3B,IAAI,IAAI;gBAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,IAAI,OAAO;gBAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3B,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { StringDecoder } from \"node:string_decoder\";\nimport { daytonaOutputPrefix } from \"./daytona-command.constants.ts\";\n\nexport function daytonaOutput(emit: (text: string) => void) {\n const decoder = new StringDecoder(\"utf8\");\n let pending = \"\";\n return {\n write(chunk: string) {\n pending += chunk;\n while (pending) {\n if (daytonaOutputPrefix.startsWith(pending)) return;\n if (!pending.startsWith(daytonaOutputPrefix)) {\n emit(pending);\n pending = \"\";\n return;\n }\n const end = pending.indexOf(\"\\n\");\n if (end === -1) return;\n const payload = pending.slice(daytonaOutputPrefix.length, end);\n const text = decoder.write(Buffer.from(payload, \"base64\"));\n if (text) emit(text);\n pending = pending.slice(end + 1);\n }\n },\n close() {\n const text = decoder.end();\n if (text) emit(text);\n if (pending) emit(pending);\n pending = \"\";\n },\n };\n}\n"]}
|
|
@@ -114,7 +114,9 @@ exit "$status"
|
|
|
114
114
|
await sandbox.process.killPtySession(id);
|
|
115
115
|
}
|
|
116
116
|
catch (cause) {
|
|
117
|
-
if (!(cause instanceof Error &&
|
|
117
|
+
if (!(cause instanceof Error &&
|
|
118
|
+
(cause.name === "DaytonaNotFoundError" ||
|
|
119
|
+
cause.name === "DaytonaProcessNotFoundError")))
|
|
118
120
|
throw cause;
|
|
119
121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AC,cAAc,CAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CACzD,CACF,CAAC;YACF,IAAI,QAAQ;gBACV,MAAM,OAAO,CAAC,KAAK,IAAI,EAAE;oBACvB,IAAI,CAAC;wBACH,IAAI,MAAM;4BAAE,OAAO,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;wBACvC,MAAM,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;oBAC3C,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,IAAI,CAAC,CACH,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,CAChE;4BACC,MAAM,KAAK,CAAC;oBAChB,CAAC;gBACH,CAAC,CAAC,CAAC;QACP,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAC1C,MAAM,OAAO,CAAC,GAAG,EAAE,CACjB,OAAO,CAAC,OAAO,CAAC,cAAc,CAC5B,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,EAAE,CAC1E,CACF,CAAC;QACF,IAAI,MAAM,CAAC,MAAM;YACf,MAAM,IAAI,cAAc,CACtB,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,EACrD,iCAAiC,CAClC,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { setTimeout } from \"node:timers/promises\";\nimport type { PtyHandle } from \"@daytona/sdk\";\nimport type { Command, CommandResult } from \"../domain/command.types.ts\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { interruptible } from \"../infrastructure/abort.ts\";\nimport { quote } from \"../infrastructure/process.ts\";\nimport { cloudDefaults } from \"./cloud.constants.ts\";\nimport type { DaytonaRuntime } from \"./daytona.types.ts\";\nimport { terminalBridge } from \"./terminal-bridge.ts\";\n\nexport async function daytonaTerminal(\n runtime: DaytonaRuntime,\n command: Command,\n signal: AbortSignal,\n): Promise<CommandResult> {\n const { sandbox, root, options, context } = runtime;\n const id = `outpost-${randomUUID()}`;\n const base = `/tmp/${id}`;\n const program = [\n ...(command.elevated ? [\"sudo\", \"-n\", \"--\"] : []),\n command.executable,\n ...(command.arguments ?? []),\n ]\n .map(quote)\n .join(\" \");\n const script = `kill -0 -$$ 2>/dev/null || exit 125\necho $$ > ${quote(base + \".pid\")}\n${program}\nstatus=$?\nprintf '%s' \"$status\" > ${quote(base + \".status\")}\nexit \"$status\"\n`;\n let handle: PtyHandle | undefined;\n let bridge: ReturnType<typeof terminalBridge> | undefined;\n let completed = false;\n let creating = false;\n let failure: unknown;\n try {\n await sandbox.fs.uploadFile(Buffer.from(script), base);\n signal.throwIfAborted();\n bridge = terminalBridge(\n command,\n command.retain ?? options.retain ?? cloudDefaults.retainBytes,\n );\n // createPty owns its connection timeout; await ownership before cancellation cleanup.\n creating = true;\n handle = await sandbox.process.createPty({\n id,\n cwd: command.directory ?? root,\n envs: {\n TERM: process.env.TERM ?? \"xterm-256color\",\n ...context.variables,\n ...command.variables,\n },\n ...bridge.size(),\n onData: bridge.output,\n });\n signal.throwIfAborted();\n await interruptible(handle.sendInput(`exec sh ${quote(base)}\\n`), signal);\n bridge.connect(handle);\n if (command.stdin !== undefined)\n await interruptible(handle.sendInput(command.stdin), signal);\n let nativeStatus: number | undefined;\n const nativeFailure = handle.wait().then((exit) => {\n nativeStatus = exit.exitCode;\n if (exit.error && exit.exitCode === undefined)\n throw new OutpostError(\n \"provider\",\n `Daytona terminal failed: ${exit.error}`,\n );\n return new Promise<never>(() => {});\n });\n void nativeFailure.catch(() => undefined);\n // The SDK can infer success from socket closure; the script records process completion.\n while (true) {\n const status = await interruptible(\n Promise.race([\n sandbox.process.executeCommand(\n `if [ -f ${quote(base + \".status\")} ]; then cat ${quote(base + \".status\")}; else exit 3; fi`,\n ),\n bridge.failure,\n nativeFailure,\n ]),\n signal,\n );\n const recorded =\n status.exitCode === 0 && /^\\d+$/.test(status.result.trim());\n if (\n recorded ||\n (status.exitCode === 3 &&\n nativeStatus !== undefined &&\n nativeStatus !== 0)\n ) {\n completed = true;\n await interruptible(bridge.flush(), signal);\n return {\n status: recorded ? Number(status.result.trim()) : nativeStatus!,\n stdout: bridge.text(),\n stderr: \"\",\n };\n }\n if (status.exitCode !== 3)\n throw new OutpostError(\n \"provider\",\n \"Daytona terminal returned invalid completion status\",\n );\n await Promise.race([\n setTimeout(cloudDefaults.pollMs, undefined, { signal }),\n bridge.failure,\n nativeFailure,\n ]);\n }\n } catch (cause) {\n failure = signal.aborted ? signal.reason : cause;\n throw failure;\n } finally {\n const errors: unknown[] = [];\n const cleanup = async (operation: () => unknown) => {\n try {\n await interruptible(\n Promise.resolve().then(operation),\n AbortSignal.timeout(cloudDefaults.cancellationMs),\n );\n } catch (cause) {\n errors.push(cause);\n }\n };\n await cleanup(() => bridge?.close());\n if (!completed) {\n // The native PTY already supplies a session; terminate its existing process group.\n const kill = `if [ -f ${quote(base + \".pid\")} ]; then p=$(cat ${quote(base + \".pid\")}); kill -KILL -\"$p\" 2>/dev/null || true; fi`;\n await cleanup(() =>\n sandbox.process.executeCommand(\n command.elevated ? `sudo -n sh -c ${quote(kill)}` : kill,\n ),\n );\n if (creating)\n await cleanup(async () => {\n try {\n if (handle) return await handle.kill();\n await sandbox.process.killPtySession(id);\n } catch (cause) {\n if (!(\n cause instanceof Error && cause.name === \"DaytonaNotFoundError\"\n ))\n throw cause;\n }\n });\n }\n await cleanup(() => handle?.disconnect());\n await cleanup(() =>\n sandbox.process.executeCommand(\n `rm -f ${quote(base)} ${quote(base + \".pid\")} ${quote(base + \".status\")}`,\n ),\n );\n if (errors.length)\n throw new AggregateError(\n failure === undefined ? errors : [failure, ...errors],\n \"Daytona terminal cleanup failed\",\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"daytona-terminal.js","sourceRoot":"","sources":["../../src/providers/daytona-terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAuB,EACvB,OAAgB,EAChB,MAAmB;IAEnB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,EAAE,GAAG,WAAW,UAAU,EAAE,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,EAAE,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,OAAO,CAAC,UAAU;QAClB,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;KAC7B;SACE,GAAG,CAAC,KAAK,CAAC;SACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,MAAM,GAAG;YACL,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC;EAC9B,OAAO;;0BAEiB,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;;CAEhD,CAAC;IACA,I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GAAG,EAAE,CACjB,OAAO,CAAC,OAAO,CAAC,cAAc,CAC5B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CACzD,CACF,CAAC;YACF,IAAI,QAAQ;gBACV,MAAM,OAAO,CAAC,KAAK,IAAI,EAAE;oBACvB,IAAI,CAAC;wBACH,IAAI,MAAM;4BAAE,OAAO,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;wBACvC,MAAM,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;oBAC3C,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,IAAI,CAAC,CACH,KAAK,YAAY,KAAK;4BACtB,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB;gCACpC,KAAK,CAAC,IAAI,KAAK,6BAA6B,CAAC,CAChD;4BACC,MAAM,KAAK,CAAC;oBAChB,CAAC;gBACH,CAAC,CAAC,CAAC;QACP,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAC1C,MAAM,OAAO,CAAC,GAAG,EAAE,CACjB,OAAO,CAAC,OAAO,CAAC,cAAc,CAC5B,SAAS,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,EAAE,CAC1E,CACF,CAAC;QACF,IAAI,MAAM,CAAC,MAAM;YACf,MAAM,IAAI,cAAc,CACtB,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,EACrD,iCAAiC,CAClC,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { setTimeout } from \"node:timers/promises\";\nimport type { PtyHandle } from \"@daytona/sdk\";\nimport type { Command, CommandResult } from \"../domain/command.types.ts\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { interruptible } from \"../infrastructure/abort.ts\";\nimport { quote } from \"../infrastructure/process.ts\";\nimport { cloudDefaults } from \"./cloud.constants.ts\";\nimport type { DaytonaRuntime } from \"./daytona.types.ts\";\nimport { terminalBridge } from \"./terminal-bridge.ts\";\n\nexport async function daytonaTerminal(\n runtime: DaytonaRuntime,\n command: Command,\n signal: AbortSignal,\n): Promise<CommandResult> {\n const { sandbox, root, options, context } = runtime;\n const id = `outpost-${randomUUID()}`;\n const base = `/tmp/${id}`;\n const program = [\n ...(command.elevated ? [\"sudo\", \"-n\", \"--\"] : []),\n command.executable,\n ...(command.arguments ?? []),\n ]\n .map(quote)\n .join(\" \");\n const script = `kill -0 -$$ 2>/dev/null || exit 125\necho $$ > ${quote(base + \".pid\")}\n${program}\nstatus=$?\nprintf '%s' \"$status\" > ${quote(base + \".status\")}\nexit \"$status\"\n`;\n let handle: PtyHandle | undefined;\n let bridge: ReturnType<typeof terminalBridge> | undefined;\n let completed = false;\n let creating = false;\n let failure: unknown;\n try {\n await sandbox.fs.uploadFile(Buffer.from(script), base);\n signal.throwIfAborted();\n bridge = terminalBridge(\n command,\n command.retain ?? options.retain ?? cloudDefaults.retainBytes,\n );\n // createPty owns its connection timeout; await ownership before cancellation cleanup.\n creating = true;\n handle = await sandbox.process.createPty({\n id,\n cwd: command.directory ?? root,\n envs: {\n TERM: process.env.TERM ?? \"xterm-256color\",\n ...context.variables,\n ...command.variables,\n },\n ...bridge.size(),\n onData: bridge.output,\n });\n signal.throwIfAborted();\n await interruptible(handle.sendInput(`exec sh ${quote(base)}\\n`), signal);\n bridge.connect(handle);\n if (command.stdin !== undefined)\n await interruptible(handle.sendInput(command.stdin), signal);\n let nativeStatus: number | undefined;\n const nativeFailure = handle.wait().then((exit) => {\n nativeStatus = exit.exitCode;\n if (exit.error && exit.exitCode === undefined)\n throw new OutpostError(\n \"provider\",\n `Daytona terminal failed: ${exit.error}`,\n );\n return new Promise<never>(() => {});\n });\n void nativeFailure.catch(() => undefined);\n // The SDK can infer success from socket closure; the script records process completion.\n while (true) {\n const status = await interruptible(\n Promise.race([\n sandbox.process.executeCommand(\n `if [ -f ${quote(base + \".status\")} ]; then cat ${quote(base + \".status\")}; else exit 3; fi`,\n ),\n bridge.failure,\n nativeFailure,\n ]),\n signal,\n );\n const recorded =\n status.exitCode === 0 && /^\\d+$/.test(status.result.trim());\n if (\n recorded ||\n (status.exitCode === 3 &&\n nativeStatus !== undefined &&\n nativeStatus !== 0)\n ) {\n completed = true;\n await interruptible(bridge.flush(), signal);\n return {\n status: recorded ? Number(status.result.trim()) : nativeStatus!,\n stdout: bridge.text(),\n stderr: \"\",\n };\n }\n if (status.exitCode !== 3)\n throw new OutpostError(\n \"provider\",\n \"Daytona terminal returned invalid completion status\",\n );\n await Promise.race([\n setTimeout(cloudDefaults.pollMs, undefined, { signal }),\n bridge.failure,\n nativeFailure,\n ]);\n }\n } catch (cause) {\n failure = signal.aborted ? signal.reason : cause;\n throw failure;\n } finally {\n const errors: unknown[] = [];\n const cleanup = async (operation: () => unknown) => {\n try {\n await interruptible(\n Promise.resolve().then(operation),\n AbortSignal.timeout(cloudDefaults.cancellationMs),\n );\n } catch (cause) {\n errors.push(cause);\n }\n };\n await cleanup(() => bridge?.close());\n if (!completed) {\n // The native PTY already supplies a session; terminate its existing process group.\n const kill = `if [ -f ${quote(base + \".pid\")} ]; then p=$(cat ${quote(base + \".pid\")}); kill -KILL -\"$p\" 2>/dev/null || true; fi`;\n await cleanup(() =>\n sandbox.process.executeCommand(\n command.elevated ? `sudo -n sh -c ${quote(kill)}` : kill,\n ),\n );\n if (creating)\n await cleanup(async () => {\n try {\n if (handle) return await handle.kill();\n await sandbox.process.killPtySession(id);\n } catch (cause) {\n if (!(\n cause instanceof Error &&\n (cause.name === \"DaytonaNotFoundError\" ||\n cause.name === \"DaytonaProcessNotFoundError\")\n ))\n throw cause;\n }\n });\n }\n await cleanup(() => handle?.disconnect());\n await cleanup(() =>\n sandbox.process.executeCommand(\n `rm -f ${quote(base)} ${quote(base + \".pid\")} ${quote(base + \".status\")}`,\n ),\n );\n if (errors.length)\n throw new AggregateError(\n failure === undefined ? errors : [failure, ...errors],\n \"Daytona terminal cleanup failed\",\n );\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { OutpostError } from "../domain/errors.js";
|
|
|
3
3
|
import { quote } from "../infrastructure/process.js";
|
|
4
4
|
import { cloudDefaults } from "./cloud.constants.js";
|
|
5
5
|
export function vercelCommand(runtime) {
|
|
6
|
-
const { sandbox, root, options, isClosed } = runtime;
|
|
6
|
+
const { sandbox, root, options, context, isClosed } = runtime;
|
|
7
7
|
return async (command) => {
|
|
8
8
|
if (isClosed())
|
|
9
9
|
throw new OutpostError("provider", "Cloud sandbox is closed");
|
|
@@ -34,7 +34,7 @@ export function vercelCommand(runtime) {
|
|
|
34
34
|
cmd,
|
|
35
35
|
args,
|
|
36
36
|
cwd: command.directory ?? root,
|
|
37
|
-
env: { ...command.variables },
|
|
37
|
+
env: { ...context.variables, ...command.variables },
|
|
38
38
|
sudo: command.elevated ?? false,
|
|
39
39
|
detached: true,
|
|
40
40
|
signal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-command.js","sourceRoot":"","sources":["../../src/providers/vercel-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,UAAU,aAAa,CAAC,OAAsB;IAClD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"vercel-command.js","sourceR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C,OAAO,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAClD,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC,CACjE,CAAC;oBACF,OAAO,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;gBACvC,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;YAChD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;oBAC5B,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC;iBAC/D,CAAC,CAAC;gBACH,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;gBAC7B,MAAM,OAAO;qBACV,UAAU,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;qBACnC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { quote } from \"../infrastructure/process.ts\";\nimport { cloudDefaults } from \"./cloud.constants.ts\";\nimport type { VercelRuntime } from \"./vercel.types.ts\";\n\nexport function vercelCommand(runtime: VercelRuntime): SandboxLease[\"invoke\"] {\n const { sandbox, root, options, context, isClosed } = runtime;\n return async (command) => {\n if (isClosed())\n throw new OutpostError(\"provider\", \"Cloud sandbox is closed\");\n if (command.interactive)\n throw new OutpostError(\n \"provider\",\n \"Interactive terminals require a mounted or local provider\",\n );\n const signal = command.signal\n ? AbortSignal.any([\n command.signal,\n AbortSignal.timeout(command.deadlineMs ?? cloudDefaults.deadlineMs),\n ])\n : AbortSignal.timeout(command.deadlineMs ?? cloudDefaults.deadlineMs);\n signal.throwIfAborted();\n const inputPath = `/tmp/outpost-${randomUUID()}.stdin`;\n if (command.stdin !== undefined)\n await sandbox.writeFiles([\n { path: inputPath, content: Buffer.from(command.stdin) },\n ]);\n const output = { stdout: \"\", stderr: \"\" };\n const cmd = command.stdin === undefined ? command.executable : \"sh\";\n const args =\n command.stdin === undefined\n ? [...(command.arguments ?? [])]\n : [\n \"-c\",\n `exec ${[command.executable, ...(command.arguments ?? [])].map(quote).join(\" \")} < ${quote(inputPath)}`,\n ];\n try {\n const running = await sandbox.runCommand({\n cmd,\n args,\n cwd: command.directory ?? root,\n env: { ...context.variables, ...command.variables },\n sudo: command.elevated ?? false,\n detached: true,\n signal,\n timeoutMs: command.deadlineMs ?? cloudDefaults.deadlineMs,\n });\n try {\n for await (const log of running.logs({ signal })) {\n const channel = log.stream;\n if (channel !== \"stdout\" && channel !== \"stderr\") continue;\n output[channel] = (output[channel] + log.data).slice(\n -(command.retain ?? options.retain ?? cloudDefaults.retainBytes),\n );\n command.observe?.(channel, log.data);\n }\n const result = await running.wait({ signal });\n return { status: result.exitCode, ...output };\n } catch (cause) {\n await running.kill(\"SIGKILL\", {\n abortSignal: AbortSignal.timeout(cloudDefaults.cancellationMs),\n });\n throw cause;\n }\n } finally {\n if (command.stdin !== undefined)\n await sandbox\n .runCommand(\"rm\", [\"-f\", inputPath])\n .catch(() => undefined);\n }\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elie-laloum/outpost",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Programmable sandboxes, coding agents and typed workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,6 +43,14 @@
|
|
|
43
43
|
"./providers/firecracker": {
|
|
44
44
|
"types": "./dist/providers/firecracker.d.ts",
|
|
45
45
|
"import": "./dist/providers/firecracker.js"
|
|
46
|
+
},
|
|
47
|
+
"./transports/s3": {
|
|
48
|
+
"types": "./dist/infrastructure/s3-transport.d.ts",
|
|
49
|
+
"import": "./dist/infrastructure/s3-transport.js"
|
|
50
|
+
},
|
|
51
|
+
"./queues/bullmq": {
|
|
52
|
+
"types": "./dist/infrastructure/task-queue-bullmq.d.ts",
|
|
53
|
+
"import": "./dist/infrastructure/task-queue-bullmq.js"
|
|
46
54
|
}
|
|
47
55
|
},
|
|
48
56
|
"files": [
|
|
@@ -66,11 +74,14 @@
|
|
|
66
74
|
"test:package": "node scripts/package-smoke.mjs",
|
|
67
75
|
"test:container": "node --test test/container.test.ts",
|
|
68
76
|
"architecture": "node scripts/check-architecture.mjs",
|
|
69
|
-
"docs:sync": "npm run build && node docs/scripts/sync-reference.mjs",
|
|
70
|
-
"docs:check": "node docs/scripts/sync-reference.mjs --check && npm run check --prefix docs",
|
|
77
|
+
"docs:sync": "npm run build && node docs/scripts/sync-preparations.mjs && node docs/scripts/sync-reference.mjs",
|
|
78
|
+
"docs:check": "node docs/scripts/sync-preparations.mjs --check && node docs/scripts/sync-reference.mjs --check && npm run check --prefix docs",
|
|
71
79
|
"docs:dev": "npm run dev --prefix docs",
|
|
72
80
|
"docs:build": "npm run build --prefix docs",
|
|
73
|
-
"docs:test": "npm run test:build --prefix docs && node docs/scripts/check-examples.mjs && node --test docs/scripts/release-channel.test.mjs"
|
|
81
|
+
"docs:test": "npm run test:build --prefix docs && node docs/scripts/check-examples.mjs && node --test docs/scripts/release-channel.test.mjs",
|
|
82
|
+
"docs:test:browser": "npm run test:browser --prefix docs",
|
|
83
|
+
"docs:test:container": "node docs/scripts/check-container-examples.mjs",
|
|
84
|
+
"test:redis": "node --test test/redis.test.ts"
|
|
74
85
|
},
|
|
75
86
|
"repository": {
|
|
76
87
|
"type": "git",
|
|
@@ -84,9 +95,11 @@
|
|
|
84
95
|
"provenance": true
|
|
85
96
|
},
|
|
86
97
|
"peerDependencies": {
|
|
98
|
+
"@aws-sdk/client-s3": "^3.1140.0",
|
|
87
99
|
"@daytona/sdk": "^0.216.0",
|
|
88
100
|
"@opentelemetry/api": "^1.9.0",
|
|
89
|
-
"@vercel/sandbox": "^3.3.0"
|
|
101
|
+
"@vercel/sandbox": "^3.3.0",
|
|
102
|
+
"bullmq": "^5.81.5"
|
|
90
103
|
},
|
|
91
104
|
"peerDependenciesMeta": {
|
|
92
105
|
"@daytona/sdk": {
|
|
@@ -97,18 +110,30 @@
|
|
|
97
110
|
},
|
|
98
111
|
"@opentelemetry/api": {
|
|
99
112
|
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"@aws-sdk/client-s3": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"bullmq": {
|
|
118
|
+
"optional": true
|
|
100
119
|
}
|
|
101
120
|
},
|
|
102
121
|
"devDependencies": {
|
|
122
|
+
"@aws-sdk/client-s3": "^3.1140.0",
|
|
103
123
|
"@daytona/sdk": "^0.216.0",
|
|
104
124
|
"@opentelemetry/api": "^1.9.0",
|
|
105
125
|
"@opentelemetry/sdk-metrics": "^2.0.0",
|
|
106
126
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
107
127
|
"@types/node": "^24.0.0",
|
|
108
128
|
"@vercel/sandbox": "^3.3.0",
|
|
129
|
+
"bullmq": "^5.81.5",
|
|
109
130
|
"c8": "^10.1.3",
|
|
110
131
|
"prettier": "^3.5.3",
|
|
111
132
|
"typescript": "^6.0.3"
|
|
112
133
|
},
|
|
113
|
-
"homepage": "https://elie-laloum.github.io/outpost/"
|
|
134
|
+
"homepage": "https://elie-laloum.github.io/outpost/",
|
|
135
|
+
"dependencies": {
|
|
136
|
+
"@clack/prompts": "^1.8.1",
|
|
137
|
+
"commander": "^15.0.0"
|
|
138
|
+
}
|
|
114
139
|
}
|