@elie-laloum/outpost 4.0.0 → 4.1.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +3 -3
  3. package/dist/adapters/agents/codex-adapter.js +2 -0
  4. package/dist/adapters/agents/codex-adapter.js.map +1 -1
  5. package/dist/adapters/agents/codex-provider.d.ts +2 -0
  6. package/dist/adapters/agents/codex-provider.js +32 -0
  7. package/dist/adapters/agents/codex-provider.js.map +1 -0
  8. package/dist/adapters/agents/codex-request.js +2 -1
  9. package/dist/adapters/agents/codex-request.js.map +1 -1
  10. package/dist/adapters/agents/gemini-request.js +2 -0
  11. package/dist/adapters/agents/gemini-request.js.map +1 -1
  12. package/dist/adapters/agents/settings.types.d.ts +5 -0
  13. package/dist/adapters/agents/settings.types.js.map +1 -1
  14. package/dist/cli/commands.js +55 -18
  15. package/dist/cli/commands.js.map +1 -1
  16. package/dist/cli/init-authentication.constants.d.ts +13 -0
  17. package/dist/cli/init-authentication.constants.js +10 -0
  18. package/dist/cli/init-authentication.constants.js.map +1 -0
  19. package/dist/cli/init-authentication.d.ts +4 -0
  20. package/dist/cli/init-authentication.js +43 -0
  21. package/dist/cli/init-authentication.js.map +1 -0
  22. package/dist/cli/init-command.js +74 -15
  23. package/dist/cli/init-command.js.map +1 -1
  24. package/dist/cli/main.constants.d.ts +102 -2
  25. package/dist/cli/main.constants.js +148 -46
  26. package/dist/cli/main.constants.js.map +1 -1
  27. package/dist/cli/scaffold-files.js +4 -3
  28. package/dist/cli/scaffold-files.js.map +1 -1
  29. package/dist/cli/scaffold-validation.js +19 -0
  30. package/dist/cli/scaffold-validation.js.map +1 -1
  31. package/dist/cli/scaffold.constants.d.ts +0 -5
  32. package/dist/cli/scaffold.constants.js +0 -5
  33. package/dist/cli/scaffold.constants.js.map +1 -1
  34. package/dist/cli/scaffold.js +13 -0
  35. package/dist/cli/scaffold.js.map +1 -1
  36. package/dist/cli/scaffold.types.d.ts +3 -0
  37. package/dist/cli/scaffold.types.js.map +1 -1
  38. package/dist/cli/starters.js +9 -2
  39. package/dist/cli/starters.js.map +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/providers/agents.d.ts +1 -1
  43. package/dist/providers/agents.js.map +1 -1
  44. package/dist/providers/daytona-command.constants.d.ts +2 -0
  45. package/dist/providers/daytona-command.constants.js +13 -0
  46. package/dist/providers/daytona-command.constants.js.map +1 -0
  47. package/dist/providers/daytona-command.js +9 -3
  48. package/dist/providers/daytona-command.js.map +1 -1
  49. package/dist/providers/daytona-output.d.ts +4 -0
  50. package/dist/providers/daytona-output.js +37 -0
  51. package/dist/providers/daytona-output.js.map +1 -0
  52. package/dist/providers/daytona-terminal.js +3 -1
  53. package/dist/providers/daytona-terminal.js.map +1 -1
  54. package/dist/providers/vercel-command.js +2 -2
  55. package/dist/providers/vercel-command.js.map +1 -1
  56. package/package.json +6 -2
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.types.js","sourceRoot":"","sources":["../../src/cli/scaffold.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface InitOptions {\n readonly directory?: string;\n readonly repository?: string;\n readonly agent?: \"claude\" | \"codex\" | \"gemini\";\n readonly provider?: \"docker\" | \"podman\" | \"vercel\" | \"daytona\" | \"local\";\n readonly manager?: \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n readonly model?: string;\n readonly install?: boolean;\n readonly build?: boolean;\n readonly image?: string;\n}\n\nexport interface PackageManifest {\n readonly type?: string;\n readonly packageManager?: string;\n}\nexport interface ProjectSettings {\n readonly extension: \"ts\" | \"mts\";\n readonly hasPackage: boolean;\n readonly manager: string;\n}\nexport interface ScaffoldResult {\n files: readonly string[];\n run: string;\n}\n"]}
1
+ {"version":3,"file":"scaffold.types.js","sourceRoot":"","sources":["../../src/cli/scaffold.types.ts"],"names":[],"mappings":"","sourcesContent":["export interface InitOptions {\n readonly directory?: string;\n readonly repository?: string;\n readonly agent?: \"claude\" | \"codex\" | \"gemini\";\n readonly provider?: \"docker\" | \"podman\" | \"vercel\" | \"daytona\" | \"local\";\n readonly manager?: \"npm\" | \"pnpm\" | \"yarn\" | \"bun\";\n readonly model?: string;\n readonly baseUrl?: string;\n readonly apiKeyEnvironment?: string;\n readonly authentication?: \"api-key\" | \"oauth-token\" | \"login\";\n readonly install?: boolean;\n readonly build?: boolean;\n readonly image?: string;\n}\n\nexport interface PackageManifest {\n readonly type?: string;\n readonly packageManager?: string;\n}\nexport interface ProjectSettings {\n readonly extension: \"ts\" | \"mts\";\n readonly hasPackage: boolean;\n readonly manager: string;\n}\nexport interface ScaffoldResult {\n files: readonly string[];\n run: string;\n}\n"]}
@@ -1,11 +1,16 @@
1
+ import { authenticationEnvironment, authenticationSource, } from "./init-authentication.js";
1
2
  export function starter(options) {
2
3
  const agent = options.agent ?? "codex", provider = options.provider ?? "docker";
3
4
  const model = options.model ? `model: ${JSON.stringify(options.model)}` : "";
5
+ const modelProvider = options.baseUrl
6
+ ? `, modelProvider: ${JSON.stringify({ baseUrl: options.baseUrl, ...(options.apiKeyEnvironment ? { apiKeyEnvironment: options.apiKeyEnvironment } : {}) })}`
7
+ : "";
4
8
  const image = options.image && (provider === "docker" || provider === "podman")
5
9
  ? `image: ${JSON.stringify(options.image)}, `
6
10
  : "";
7
11
  return `import { readFile } from "node:fs/promises";
8
12
  import { resolve } from "node:path";
13
+ import { homedir } from "node:os";
9
14
  import { parseEnv } from "node:util";
10
15
  import { dispatch, ${agent}, OutpostError, reporter } from "@elie-laloum/outpost";
11
16
  import { ${provider} } from "@elie-laloum/outpost/providers/${provider}";
@@ -17,10 +22,11 @@ const environment = await readFile(new URL(".env", import.meta.url), "utf8").cat
17
22
  throw error;
18
23
  });
19
24
  const variables = Object.fromEntries(
20
- Object.entries(parseEnv(environment)).map(([key, value]) => [key, value || process.env[key] || ""]),
25
+ Object.entries({ ...parseEnv(${JSON.stringify(authenticationEnvironment(options))}), ...parseEnv(environment) }).map(([key, value]) => [key, value || process.env[key] || ""]),
21
26
  );
27
+ ${authenticationSource(options)}
22
28
  const runtime = {
23
- agent: ${agent}({ ${model} }),
29
+ agent: ${agent}({ ${model}${modelProvider} }),
24
30
  provider: ${provider}({ ${image}variables }),
25
31
  };
26
32
  const objective = process.argv.slice(2).join(" ") || "Inspect this repository and implement one useful improvement.";
@@ -29,6 +35,7 @@ console.error("[outpost] Preparing sandbox...");
29
35
  try {
30
36
  const result = await dispatch({
31
37
  ...runtime,
38
+ hooks: authentication,
32
39
  repository,
33
40
  branch: { mode: "integrate" },
34
41
  brief: { file: resolve(import.meta.dirname, "brief.md"), values: { OBJECTIVE: objective } },
@@ -1 +1 @@
1
- {"version":3,"file":"starters.js","sourceRoot":"","sources":["../../src/cli/starters.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAC,OAAoB;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,EACpC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,MAAM,KAAK,GACT,OAAO,CAAC,KAAK,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,QAAQ,CAAC;QAC/D,CAAC,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI;QAC7C,CAAC,CAAC,EAAE,CAAC;IACT,OAAO;;;qBAGY,KAAK;WACf,QAAQ,2CAA2C,QAAQ;;;kDAGpB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC;;;;;;;;;WAShF,KAAK,MAAM,KAAK;cACb,QAAQ,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;CAoBhC,CAAC;AACF,CAAC","sourcesContent":["import type { InitOptions } from \"./scaffold.types.ts\";\n\nexport function starter(options: InitOptions): string {\n const agent = options.agent ?? \"codex\",\n provider = options.provider ?? \"docker\";\n const model = options.model ? `model: ${JSON.stringify(options.model)}` : \"\";\n const image =\n options.image && (provider === \"docker\" || provider === \"podman\")\n ? `image: ${JSON.stringify(options.image)}, `\n : \"\";\n return `import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { parseEnv } from \"node:util\";\nimport { dispatch, ${agent}, OutpostError, reporter } from \"@elie-laloum/outpost\";\nimport { ${provider} } from \"@elie-laloum/outpost/providers/${provider}\";\n\n// Paths are relative to this workflow, regardless of where Node is launched.\nconst repository = resolve(import.meta.dirname, ${JSON.stringify(options.repository ?? \".\")});\nconst environment = await readFile(new URL(\".env\", import.meta.url), \"utf8\").catch((error) => {\n if (error.code === \"ENOENT\") return \"\";\n throw error;\n});\nconst variables = Object.fromEntries(\n Object.entries(parseEnv(environment)).map(([key, value]) => [key, value || process.env[key] || \"\"]),\n);\nconst runtime = {\n agent: ${agent}({ ${model} }),\n provider: ${provider}({ ${image}variables }),\n};\nconst objective = process.argv.slice(2).join(\" \") || \"Inspect this repository and implement one useful improvement.\";\n\nconsole.error(\"[outpost] Preparing sandbox...\");\ntry {\n const result = await dispatch({\n ...runtime,\n repository,\n branch: { mode: \"integrate\" },\n brief: { file: resolve(import.meta.dirname, \"brief.md\"), values: { OBJECTIVE: objective } },\n observe: reporter(),\n warn: (message) => console.error(message),\n });\n console.log({ branch: result.branch, commits: result.commits, conversation: result.conversation });\n} catch (error) {\n if (!(error instanceof OutpostError) || error.code !== \"aborted\") throw error;\n process.exitCode ||= 130;\n console.error(\"[outpost] Cancelled. Recovery details:\", error.recovery);\n}\n`;\n}\n"]}
1
+ {"version":3,"file":"starters.js","sourceRoot":"","sources":["../../src/cli/starters.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAy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{\n authenticationEnvironment,\n authenticationSource,\n} from \"./init-authentication.ts\";\nimport type { InitOptions } from \"./scaffold.types.ts\";\n\nexport function starter(options: InitOptions): string {\n const agent = options.agent ?? \"codex\",\n provider = options.provider ?? \"docker\";\n const model = options.model ? `model: ${JSON.stringify(options.model)}` : \"\";\n const modelProvider = options.baseUrl\n ? `, modelProvider: ${JSON.stringify({ baseUrl: options.baseUrl, ...(options.apiKeyEnvironment ? { apiKeyEnvironment: options.apiKeyEnvironment } : {}) })}`\n : \"\";\n const image =\n options.image && (provider === \"docker\" || provider === \"podman\")\n ? `image: ${JSON.stringify(options.image)}, `\n : \"\";\n return `import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { parseEnv } from \"node:util\";\nimport { dispatch, ${agent}, OutpostError, reporter } from \"@elie-laloum/outpost\";\nimport { ${provider} } from \"@elie-laloum/outpost/providers/${provider}\";\n\n// Paths are relative to this workflow, regardless of where Node is launched.\nconst repository = resolve(import.meta.dirname, ${JSON.stringify(options.repository ?? \".\")});\nconst environment = await readFile(new URL(\".env\", import.meta.url), \"utf8\").catch((error) => {\n if (error.code === \"ENOENT\") return \"\";\n throw error;\n});\nconst variables = Object.fromEntries(\n Object.entries({ ...parseEnv(${JSON.stringify(authenticationEnvironment(options))}), ...parseEnv(environment) }).map(([key, value]) => [key, value || process.env[key] || \"\"]),\n);\n${authenticationSource(options)}\nconst runtime = {\n agent: ${agent}({ ${model}${modelProvider} }),\n provider: ${provider}({ ${image}variables }),\n};\nconst objective = process.argv.slice(2).join(\" \") || \"Inspect this repository and implement one useful improvement.\";\n\nconsole.error(\"[outpost] Preparing sandbox...\");\ntry {\n const result = await dispatch({\n ...runtime,\n hooks: authentication,\n repository,\n branch: { mode: \"integrate\" },\n brief: { file: resolve(import.meta.dirname, \"brief.md\"), values: { OBJECTIVE: objective } },\n observe: reporter(),\n warn: (message) => console.error(message),\n });\n console.log({ branch: result.branch, commits: result.commits, conversation: result.conversation });\n} catch (error) {\n if (!(error instanceof OutpostError) || error.code !== \"aborted\") throw error;\n process.exitCode ||= 130;\n console.error(\"[outpost] Cancelled. Recovery details:\", error.recovery);\n}\n`;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { claude, codex, gemini } from "./providers/agents.ts";
8
8
  export { agentVersions } from "./providers/versions.ts";
9
9
  export { conversations } from "./infrastructure/conversations.ts";
10
10
  export type { ConversationFormat, ConversationLocation, } from "./infrastructure/conversations.ts";
11
- export type { ClaudeSettings, CodexSettings, GeminiSettings, } from "./providers/agents.ts";
11
+ export type { ClaudeSettings, CodexSettings, CodexModelProvider, GeminiSettings, } from "./providers/agents.ts";
12
12
  export { mountedProvider, remoteProvider } from "./providers/factories.ts";
13
13
  export { ResponseError, response } from "./domain/response.ts";
14
14
  export type { ResponseSpec, StandardValidator } from "./domain/response.ts";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAalE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoCnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAMxD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAS7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAMhF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAWlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAO9E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAO3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAWtF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AASrE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAevE,OAAO,EACL,QAAQ,EACR,eAAe,EACf,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAevE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACL,cAAc,EACd,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAwB1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex, gemini } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type {\n ClaudeSettings,\n CodexSettings,\n GeminiSettings,\n} from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n\nexport { reserveRecoveryStorage } from \"./application/storage-reservation.ts\";\nexport type { RecoveryStorageReservationOptions } from \"./application/storage-reservation.types.ts\";\nexport type {\n StorageReservation,\n StorageReservationOptions,\n} from \"./infrastructure/storage-reservations.types.ts\";\n\nexport {\n planRecoveryRestore,\n restoreRecoveryTransfer,\n} from \"./application/recovery-restore.ts\";\nexport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./application/recovery-restore.types.ts\";\n\nexport { fileWorkflowCheckpointStore } from \"./infrastructure/workflow-checkpoint.ts\";\nexport type { FileWorkflowCheckpointOptions } from \"./infrastructure/workflow-checkpoint.types.ts\";\nexport type {\n WorkflowCheckpoint,\n WorkflowCheckpointOptions,\n WorkflowCheckpointStore,\n WorkflowCheckpointLease,\n WorkflowCheckpointValue,\n WorkflowJson,\n} from \"./domain/workflow/checkpoint.types.ts\";\n\nexport { approvalTask, pauseTask } from \"./domain/workflow/gates.ts\";\nexport type {\n WorkflowGate,\n WorkflowGateOptions,\n WorkflowPauseRequest,\n WorkflowDecision,\n WorkflowDecisionRecord,\n} from \"./domain/workflow/gates.types.ts\";\n\nexport { inspectRecovery } from \"./application/recovery-inspection.ts\";\nexport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./application/recovery-inspection.types.ts\";\nexport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationKind,\n ResourceOperationResult,\n ResourcePhase,\n} from \"./infrastructure/resource-activity.types.ts\";\n\nexport {\n artifact,\n publishArtifact,\n readStoredArtifact,\n} from \"./domain/artifact.ts\";\nexport { artifactTask, readArtifact } from \"./application/artifact-tasks.ts\";\nexport { fileArtifactStore } from \"./infrastructure/artifact-store.ts\";\nexport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactIdentity,\n ArtifactProducer,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./domain/artifact.types.ts\";\nexport type { ArtifactTaskOptions } from \"./application/artifact-tasks.types.ts\";\nexport type { FileArtifactStoreOptions } from \"./infrastructure/artifact-store.types.ts\";\n\nexport { sqliteTaskQueue } from \"./infrastructure/task-queue.ts\";\nexport {\n serveTaskQueue,\n httpTaskQueue,\n} from \"./infrastructure/task-queue-http.ts\";\nexport { runQueueWorker } from \"./application/queue-worker.ts\";\nexport { queuedTask } from \"./application/queued-task.ts\";\nexport type {\n QueueRequest,\n QueueResult,\n QueueJob,\n QueueClaim,\n QueueLease,\n TaskQueue,\n DurableTaskQueue,\n} from \"./domain/task-queue.types.ts\";\nexport type {\n QueueServerOptions,\n QueueServer,\n QueueClientOptions,\n} from \"./infrastructure/task-queue-http.types.ts\";\nexport type {\n QueueHandlerContext,\n QueueHandler,\n QueueWorkerOptions,\n} from \"./application/queue-worker.types.ts\";\nexport type { QueuedTaskOptions } from \"./application/queued-task.types.ts\";\n\nexport type { EgressPolicy } from \"./domain/egress.types.ts\";\n\nexport { speculate } from \"./application/speculation.ts\";\nexport type {\n SpeculationOptions,\n SpeculationResult,\n SpeculativeCandidate,\n SpeculativeCandidateResult,\n SpeculativeOutput,\n SpeculativeHostSnapshot,\n SpeculativeValidation,\n} from \"./application/speculation.types.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,GACd,MAAM,0BAA0B,CAAC;AAoBlC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAclE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoCnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAMxD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAS7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAMhF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAWlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAO9E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAO3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAWtF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AASrE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAevE,OAAO,EACL,QAAQ,EACR,eAAe,EACf,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAevE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACL,cAAc,EACd,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAwB1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n attach,\n createSandbox,\n dispatch,\n openWorkspace,\n} from \"./application/outpost.ts\";\n\nexport type {\n AttachOptions,\n AttachResult,\n ContinuationOptions,\n DispatchResult,\n Sandbox,\n SandboxOptions,\n WarmDispatchResult,\n Workspace,\n WorkspaceOptions,\n} from \"./application/outpost.ts\";\n\nexport type {\n DispatchOptions,\n Execution,\n Turn,\n} from \"./application/execution.ts\";\n\nexport {\n WorkflowFailure,\n WorkflowBudgetExceeded,\n task,\n workflow,\n} from \"./domain/workflow.ts\";\n\nexport type {\n Retry,\n Task,\n TaskContext,\n TaskOptions,\n TaskRecord,\n TaskStatus,\n Workflow,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowBudget,\n WorkflowUsage,\n WorkflowResult,\n} from \"./domain/workflow.ts\";\n\nexport { agentTask, commandTask, isolatedTask } from \"./application/tasks.ts\";\n\nexport { claude, codex, gemini } from \"./providers/agents.ts\";\n\nexport { agentVersions } from \"./providers/versions.ts\";\n\nexport { conversations } from \"./infrastructure/conversations.ts\";\n\nexport type {\n ConversationFormat,\n ConversationLocation,\n} from \"./infrastructure/conversations.ts\";\n\nexport type {\n ClaudeSettings,\n CodexSettings,\n CodexModelProvider,\n GeminiSettings,\n} from \"./providers/agents.ts\";\n\nexport { mountedProvider, remoteProvider } from \"./providers/factories.ts\";\n\nexport { ResponseError, response } from \"./domain/response.ts\";\n\nexport type { ResponseSpec, StandardValidator } from \"./domain/response.ts\";\n\nexport { OutpostError, recoveryDetails } from \"./domain/errors.ts\";\n\nexport type { FaultCode } from \"./domain/errors.ts\";\n\nexport type {\n AgentAdapter,\n AgentEvent,\n AgentInput,\n AgentObservation,\n BranchPolicy,\n Channel,\n Command,\n CommandResult,\n Commit,\n ConversationContext,\n ConversationRecord,\n ConversationStore,\n Disposal,\n LifecycleHooks,\n FileManifestEntry,\n FileTransfers,\n SandboxContext,\n SandboxLease,\n SandboxProvider,\n StageLimits,\n TransferOptions,\n Usage,\n Variables,\n Volume,\n WorkspaceRecord,\n} from \"./domain/ports.ts\";\n\nexport type { Brief, PromptVariables } from \"./domain/prompts.ts\";\n\nexport type { Logging } from \"./infrastructure/journal.ts\";\n\nexport { reporter } from \"./infrastructure/reporter.ts\";\n\nexport type { ReporterOptions } from \"./infrastructure/reporter.ts\";\n\nexport type { VariableQuestion } from \"./application/interactive-brief.ts\";\n\nexport {\n planRecoveryRetention,\n pruneRecoveryRetention,\n assertRecoveryQuota,\n} from \"./application/recovery-retention.ts\";\nexport type {\n RecoveryRetentionPolicy,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n RecoveryRetentionEntry,\n RecoveryPruneResult,\n RecoveryQuotaOptions,\n} from \"./application/recovery-retention.types.ts\";\nexport { verifyRecoveryTransfer } from \"./application/recovery-verification.ts\";\nexport type {\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./application/recovery-verification.types.ts\";\n\nexport { diagnoseSandbox } from \"./application/doctor-sandbox.ts\";\nexport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n DiagnosticCapability,\n} from \"./application/doctor-sandbox.types.ts\";\nexport type {\n DiagnosticCheck,\n DiagnosticStatus,\n DoctorAgent,\n} from \"./application/doctor.types.ts\";\nexport { diagnoseAgentProtocol } from \"./application/doctor-protocol.ts\";\nexport type { AgentProtocolReport } from \"./application/doctor-protocol.types.ts\";\n\nexport { reserveRecoveryStorage } from \"./application/storage-reservation.ts\";\nexport type { RecoveryStorageReservationOptions } from \"./application/storage-reservation.types.ts\";\nexport type {\n StorageReservation,\n StorageReservationOptions,\n} from \"./infrastructure/storage-reservations.types.ts\";\n\nexport {\n planRecoveryRestore,\n restoreRecoveryTransfer,\n} from \"./application/recovery-restore.ts\";\nexport type {\n RecoveryRestoreOptions,\n RecoveryRestorePlan,\n RecoveryRestoreResult,\n} from \"./application/recovery-restore.types.ts\";\n\nexport { fileWorkflowCheckpointStore } from \"./infrastructure/workflow-checkpoint.ts\";\nexport type { FileWorkflowCheckpointOptions } from \"./infrastructure/workflow-checkpoint.types.ts\";\nexport type {\n WorkflowCheckpoint,\n WorkflowCheckpointOptions,\n WorkflowCheckpointStore,\n WorkflowCheckpointLease,\n WorkflowCheckpointValue,\n WorkflowJson,\n} from \"./domain/workflow/checkpoint.types.ts\";\n\nexport { approvalTask, pauseTask } from \"./domain/workflow/gates.ts\";\nexport type {\n WorkflowGate,\n WorkflowGateOptions,\n WorkflowPauseRequest,\n WorkflowDecision,\n WorkflowDecisionRecord,\n} from \"./domain/workflow/gates.types.ts\";\n\nexport { inspectRecovery } from \"./application/recovery-inspection.ts\";\nexport type {\n RecoveryInspection,\n RecoveryInspectionOptions,\n} from \"./application/recovery-inspection.types.ts\";\nexport type {\n ResourceActivityRecord,\n ResourceInspection,\n ResourceInspectionEntry,\n ResourceOperation,\n ResourceOperationKind,\n ResourceOperationResult,\n ResourcePhase,\n} from \"./infrastructure/resource-activity.types.ts\";\n\nexport {\n artifact,\n publishArtifact,\n readStoredArtifact,\n} from \"./domain/artifact.ts\";\nexport { artifactTask, readArtifact } from \"./application/artifact-tasks.ts\";\nexport { fileArtifactStore } from \"./infrastructure/artifact-store.ts\";\nexport type {\n ArtifactContract,\n ArtifactContractOptions,\n ArtifactIdentity,\n ArtifactProducer,\n ArtifactReference,\n ArtifactStore,\n JsonArtifactOptions,\n PublishArtifactOptions,\n ReadArtifactOptions,\n} from \"./domain/artifact.types.ts\";\nexport type { ArtifactTaskOptions } from \"./application/artifact-tasks.types.ts\";\nexport type { FileArtifactStoreOptions } from \"./infrastructure/artifact-store.types.ts\";\n\nexport { sqliteTaskQueue } from \"./infrastructure/task-queue.ts\";\nexport {\n serveTaskQueue,\n httpTaskQueue,\n} from \"./infrastructure/task-queue-http.ts\";\nexport { runQueueWorker } from \"./application/queue-worker.ts\";\nexport { queuedTask } from \"./application/queued-task.ts\";\nexport type {\n QueueRequest,\n QueueResult,\n QueueJob,\n QueueClaim,\n QueueLease,\n TaskQueue,\n DurableTaskQueue,\n} from \"./domain/task-queue.types.ts\";\nexport type {\n QueueServerOptions,\n QueueServer,\n QueueClientOptions,\n} from \"./infrastructure/task-queue-http.types.ts\";\nexport type {\n QueueHandlerContext,\n QueueHandler,\n QueueWorkerOptions,\n} from \"./application/queue-worker.types.ts\";\nexport type { QueuedTaskOptions } from \"./application/queued-task.types.ts\";\n\nexport type { EgressPolicy } from \"./domain/egress.types.ts\";\n\nexport { speculate } from \"./application/speculation.ts\";\nexport type {\n SpeculationOptions,\n SpeculationResult,\n SpeculativeCandidate,\n SpeculativeCandidateResult,\n SpeculativeOutput,\n SpeculativeHostSnapshot,\n SpeculativeValidation,\n} from \"./application/speculation.types.ts\";\n"]}
@@ -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,2 @@
1
+ export declare const daytonaOutputPrefix = "outpost-output:";
2
+ export declare const daytonaCommandScript: string;
@@ -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)} && exec env ${Object.entries(variables)
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
- await interruptible(sandbox.process.getSessionCommandLogs(id, response.cmdId, consume("stdout"), consume("stderr")), signal);
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,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,QAAQ,EAAE;YACZ,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;YAC3B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC;gBACd,OAAO,CAAC,MAAM;gBACd,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,aAAa,CAAC,UAAU,CAAC;aACpE,CAAC;YACJ,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;QACxE,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,IAAI,OAAO,CAAC,WAAW;YAAE,OAAO,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1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AAC,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 { 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)} && exec env ${Object.entries(\n variables,\n )\n .map(([key, value]) => quote(`${key}=${value}`))\n .join(\n \" \",\n )} setsid sh -c ${quote(`echo $$ > ${quote(pid)}; test ! -f ${quote(pid + \".cancel\")} || exit 130; exec ${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 await interruptible(\n sandbox.process.getSessionCommandLogs(\n id,\n response.cmdId,\n consume(\"stdout\"),\n consume(\"stderr\"),\n ),\n signal,\n );\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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ACjB,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,4 @@
1
+ export declare function daytonaOutput(emit: (text: string) => void): {
2
+ write(chunk: string): void;
3
+ close(): void;
4
+ };
@@ -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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;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 && cause.name === "DaytonaNotFoundError"))
117
+ if (!(cause instanceof Error &&
118
+ (cause.name === "DaytonaNotFoundError" ||
119
+ cause.name === "DaytonaProcessNotFoundError")))
118
120
  throw cause;
119
121
  }
120
122
  });
@@ -1 +1 @@
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,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,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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K;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;IACrD,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,QAAQ,EAAE;YACZ,MAAM,IAAI,YAAY,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC;QAChE,IAAI,OAAO,CAAC,WAAW;YACrB,MAAM,IAAI,YAAY,CACpB,UAAU,EACV,2DAA2D,CAC5D,CAAC;QACJ,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;YAC3B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC;gBACd,OAAO,CAAC,MAAM;gBACd,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,aAAa,CAAC,UAAU,CAAC;aACpE,CAAC;YACJ,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;QACxE,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,SAAS,GAAG,gBAAgB,UAAU,EAAE,QAAQ,CAAC;QACvD,IAAI,OAAO,CAAC,KAAK,K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;oBACjD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC;oBAC3B,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ;wBAAE,SAAS;oBAC3D,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,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, 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: { ...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"]}
1
+ {"version":3,"file":"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AAC,MAAM,CAAC,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.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Programmable sandboxes, coding agents and typed workflows.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -110,5 +110,9 @@
110
110
  "prettier": "^3.5.3",
111
111
  "typescript": "^6.0.3"
112
112
  },
113
- "homepage": "https://elie-laloum.github.io/outpost/"
113
+ "homepage": "https://elie-laloum.github.io/outpost/",
114
+ "dependencies": {
115
+ "@clack/prompts": "^1.8.1",
116
+ "commander": "^15.0.0"
117
+ }
114
118
  }