@microvac/plugin-daytona 0.0.0-stage → 0.1.0-rc.15

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 (122) hide show
  1. package/README.md +98 -2
  2. package/dist/archive-stream-window.test.d.ts +2 -0
  3. package/dist/archive-stream-window.test.d.ts.map +1 -0
  4. package/dist/archive-stream-window.test.js +93 -0
  5. package/dist/archive-stream-window.test.js.map +1 -0
  6. package/dist/archive-stream.d.ts +10 -0
  7. package/dist/archive-stream.d.ts.map +1 -0
  8. package/dist/archive-stream.js +159 -0
  9. package/dist/archive-stream.js.map +1 -0
  10. package/dist/archive-stream.test.d.ts +2 -0
  11. package/dist/archive-stream.test.d.ts.map +1 -0
  12. package/dist/archive-stream.test.js +121 -0
  13. package/dist/archive-stream.test.js.map +1 -0
  14. package/dist/duplex-close-deadline.test.d.ts +2 -0
  15. package/dist/duplex-close-deadline.test.d.ts.map +1 -0
  16. package/dist/duplex-close-deadline.test.js +106 -0
  17. package/dist/duplex-close-deadline.test.js.map +1 -0
  18. package/dist/duplex-command-stream.d.ts +98 -0
  19. package/dist/duplex-command-stream.d.ts.map +1 -0
  20. package/dist/duplex-command-stream.js +218 -0
  21. package/dist/duplex-command-stream.js.map +1 -0
  22. package/dist/duplex-command-stream.live.test.d.ts +2 -0
  23. package/dist/duplex-command-stream.live.test.d.ts.map +1 -0
  24. package/dist/duplex-command-stream.live.test.js +324 -0
  25. package/dist/duplex-command-stream.live.test.js.map +1 -0
  26. package/dist/duplex-command-stream.test.d.ts +2 -0
  27. package/dist/duplex-command-stream.test.d.ts.map +1 -0
  28. package/dist/duplex-command-stream.test.js +519 -0
  29. package/dist/duplex-command-stream.test.js.map +1 -0
  30. package/dist/file-sync-capacity.live.test.d.ts +2 -0
  31. package/dist/file-sync-capacity.live.test.d.ts.map +1 -0
  32. package/dist/file-sync-capacity.live.test.js +122 -0
  33. package/dist/file-sync-capacity.live.test.js.map +1 -0
  34. package/dist/file-sync-capacity.test.d.ts +2 -0
  35. package/dist/file-sync-capacity.test.d.ts.map +1 -0
  36. package/dist/file-sync-capacity.test.js +337 -0
  37. package/dist/file-sync-capacity.test.js.map +1 -0
  38. package/dist/file-sync-diagnostics.test.d.ts +2 -0
  39. package/dist/file-sync-diagnostics.test.d.ts.map +1 -0
  40. package/dist/file-sync-diagnostics.test.js +165 -0
  41. package/dist/file-sync-diagnostics.test.js.map +1 -0
  42. package/dist/file-sync.d.ts +80 -0
  43. package/dist/file-sync.d.ts.map +1 -0
  44. package/dist/file-sync.js +1362 -0
  45. package/dist/file-sync.js.map +1 -0
  46. package/dist/file-sync.test.d.ts +2 -0
  47. package/dist/file-sync.test.d.ts.map +1 -0
  48. package/dist/file-sync.test.js +1214 -0
  49. package/dist/file-sync.test.js.map +1 -0
  50. package/dist/idle-activity.d.ts +40 -0
  51. package/dist/idle-activity.d.ts.map +1 -0
  52. package/dist/idle-activity.js +145 -0
  53. package/dist/idle-activity.js.map +1 -0
  54. package/dist/idle-activity.test.d.ts +2 -0
  55. package/dist/idle-activity.test.d.ts.map +1 -0
  56. package/dist/idle-activity.test.js +159 -0
  57. package/dist/idle-activity.test.js.map +1 -0
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +3 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/lease-tracing.d.ts +7 -0
  63. package/dist/lease-tracing.d.ts.map +1 -0
  64. package/dist/lease-tracing.js +31 -0
  65. package/dist/lease-tracing.js.map +1 -0
  66. package/dist/lease-tracing.test.d.ts +2 -0
  67. package/dist/lease-tracing.test.d.ts.map +1 -0
  68. package/dist/lease-tracing.test.js +298 -0
  69. package/dist/lease-tracing.test.js.map +1 -0
  70. package/dist/login-pty.d.ts +162 -0
  71. package/dist/login-pty.d.ts.map +1 -0
  72. package/dist/login-pty.js +258 -0
  73. package/dist/login-pty.js.map +1 -0
  74. package/dist/login-pty.test.d.ts +2 -0
  75. package/dist/login-pty.test.d.ts.map +1 -0
  76. package/dist/login-pty.test.js +319 -0
  77. package/dist/login-pty.test.js.map +1 -0
  78. package/dist/manifest.d.ts +5 -0
  79. package/dist/manifest.d.ts.map +1 -0
  80. package/dist/manifest.js +189 -0
  81. package/dist/manifest.js.map +1 -0
  82. package/dist/one-shot-exec-deadline.test.d.ts +2 -0
  83. package/dist/one-shot-exec-deadline.test.d.ts.map +1 -0
  84. package/dist/one-shot-exec-deadline.test.js +73 -0
  85. package/dist/one-shot-exec-deadline.test.js.map +1 -0
  86. package/dist/plugin.d.ts +103 -0
  87. package/dist/plugin.d.ts.map +1 -0
  88. package/dist/plugin.js +3572 -0
  89. package/dist/plugin.js.map +1 -0
  90. package/dist/plugin.test.d.ts +2 -0
  91. package/dist/plugin.test.d.ts.map +1 -0
  92. package/dist/plugin.test.js +7276 -0
  93. package/dist/plugin.test.js.map +1 -0
  94. package/dist/pty-chunked-input.d.ts +48 -0
  95. package/dist/pty-chunked-input.d.ts.map +1 -0
  96. package/dist/pty-chunked-input.js +74 -0
  97. package/dist/pty-chunked-input.js.map +1 -0
  98. package/dist/pty-chunked-input.test.d.ts +2 -0
  99. package/dist/pty-chunked-input.test.d.ts.map +1 -0
  100. package/dist/pty-chunked-input.test.js +115 -0
  101. package/dist/pty-chunked-input.test.js.map +1 -0
  102. package/dist/runner-ingress.sdk-integration.d.ts +2 -0
  103. package/dist/runner-ingress.sdk-integration.d.ts.map +1 -0
  104. package/dist/runner-ingress.sdk-integration.js +87 -0
  105. package/dist/runner-ingress.sdk-integration.js.map +1 -0
  106. package/dist/session-command-completion.test.d.ts +2 -0
  107. package/dist/session-command-completion.test.d.ts.map +1 -0
  108. package/dist/session-command-completion.test.js +251 -0
  109. package/dist/session-command-completion.test.js.map +1 -0
  110. package/dist/session-stream-exit.d.ts +13 -0
  111. package/dist/session-stream-exit.d.ts.map +1 -0
  112. package/dist/session-stream-exit.js +48 -0
  113. package/dist/session-stream-exit.js.map +1 -0
  114. package/dist/tar-listing.test.d.ts +2 -0
  115. package/dist/tar-listing.test.d.ts.map +1 -0
  116. package/dist/tar-listing.test.js +220 -0
  117. package/dist/tar-listing.test.js.map +1 -0
  118. package/dist/worker.d.ts +3 -0
  119. package/dist/worker.d.ts.map +1 -0
  120. package/dist/worker.js +5 -0
  121. package/dist/worker.js.map +1 -0
  122. package/package.json +42 -4
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # `@paperclipai/plugin-daytona`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Published Daytona sandbox provider plugin for Paperclip.
4
+
5
+ This package lives in the Paperclip monorepo, but it is intentionally excluded from the root `pnpm` workspace and shaped to publish and install like a standalone npm package. That lets operators install it from the Plugins page by package name without introducing root lockfile churn for Daytona's SDK dependencies.
6
+
7
+ ## Install
8
+
9
+ From a Paperclip instance, install:
10
+
11
+ ```text
12
+ @paperclipai/plugin-daytona
13
+ ```
14
+
15
+ The host plugin installer runs `npm install` into the managed plugin directory, so transitive dependencies such as `@daytonaio/sdk` are pulled in during installation.
16
+
17
+ ## Configuration
18
+
19
+ Configure Daytona from `Instance Settings -> Environments`, not from the plugin's plugin page.
20
+
21
+ - Put the Daytona API key on the sandbox environment itself.
22
+ - When you save an environment, Paperclip stores pasted API keys as company secrets.
23
+ - `DAYTONA_API_KEY` remains an optional host-level fallback when an environment omits the key.
24
+ - Optional `apiUrl` and `target` settings map directly to the Daytona SDK/client configuration. If `apiUrl` is omitted, the Daytona SDK uses its default endpoint.
25
+
26
+ Notes:
27
+
28
+ - The current published Daytona SDK package is `@daytonaio/sdk`.
29
+ - The driver supports both `snapshot`-based and `image`-based sandbox creation. If both are set, validation rejects the config as ambiguous.
30
+ - Optional `ttlMinutes` sets a positive whole-minute wall-clock lifetime in the creation request. It applies to image and snapshot sandboxes, including probes and interactive setup. The driver requires the provider to confirm the expiry before it returns the sandbox. It preserves an earlier creation expiry when a caller supplies a later deadline. Daytona destroys the sandbox and its files at expiry, even while active, stopped, paused, or archived. Omit this setting to keep existing lifetime behavior. This is separate from inactivity cleanup.
31
+ - Each cold create uses a unique provider name and ownership labels. If creation fails after Daytona has allocated a sandbox, the driver looks up that exact name, checks every ownership label, and waits for deletion. Failed, missing, or timed-out lookups and failed deletions report unconfirmed cleanup with the provider name; they never return a usable lease. A missing name lookup after an uncertain create is not proof that a delayed provider request cannot create a resource.
32
+ - For plugin-backed sandbox lease acquisition, unresolved creation cleanup crosses the worker RPC as a validated ownership envelope. The host records `pending_cleanup` before retrying deletion. If only a creation name is known, the provider first returns an ownership-verified sandbox ID without deleting it. The host saves that observation before authorizing deletion. Its existing cleanup sweep and durable spool preserve retries across controller restarts and environment deletion. A missing observed ID confirms cleanup after a lost deletion reply or database update; a name that has never been observed remains unresolved. Provider exceptions and resolved credentials are excluded from that envelope. This requires the matching host and plugin SDK update; probe and custom-image interactive-setup calls still report unconfirmed immediate cleanup without this lease-recovery path.
33
+ - Reusable leases map to Daytona stop/start semantics. Non-reusable leases are deleted on release. A provider-resolved `target` does not change the identity of an existing sandbox. Release closes the same scoped lease that a later sentinel-verified resume reopens.
34
+ - Idle sleep tracks pending hooks, underlying provider requests, open terminals, and sandbox allocations. A successful stop or delete clears only that sandbox's company, environment, and account scope. Every sandbox deletion waits for completed remote destruction within its existing timeout; acceptance alone cannot clear idle evidence. A timeout does not settle the underlying request. Cleanup that overlaps other work on the same sandbox needs a later quiet stop/delete receipt or read-only observation of the exact stopped or missing sandbox. Proof is captured before the provider observation. Other work that starts or finishes before its reply invalidates that proof, even after the other request has settled. An unobserved creation name is never absence proof. Active resources and uncertain cleanup continue to prevent idle sleep; verified cleanup no longer blocks sleep for the worker's entire lifetime.
35
+ - A command that has already exited returns its final separated log snapshot without opening a follow socket. The initial status check is bounded to 500ms and the caller's command deadline. Each follow connection also makes up to four early status reads, with 25/50/100/200ms delays and the same observation/deadline bounds. A confirmed exit still requires the final separated snapshot, but does not wait for the follow socket to close. Unconfirmed or unavailable status keeps streaming; the early reads stop after their bounded attempt window. The command is dispatched only once.
36
+ - A session log socket can close while its command still runs. The driver requires a recorded command exit before returning a completed execution. It reconnects the log stream once, then polls status and log snapshots at most once per second. Replayed output is removed by byte offset, new output continues to reach the host, and the command is never dispatched again. A socket that delivers no output for 15 seconds switches directly to polling, even if the socket stays open or its initial connection never completes. Late callbacks from that socket are ignored. This recovers pending permission requests and cancellation results from saved output without replaying the command. Healthy initial and reconnected streams retain their existing lifetime under the caller’s RPC/run guard. After a clean close or an idle socket, each status or snapshot read gets a fresh operation timeout; successful recovery polling does not impose a new command lifetime. When both stream attempts fail without a clean close, fallback retains its original timeout budget starting after the stream attempts.
37
+ - The SDK returns full log snapshots, so fallback bandwidth grows with retained output; it has no paged snapshot or stream cancellation API. A recovery-read timeout keeps partial output and explicitly reports whether command exit remains unconfirmed; it does not prove the remote command stopped. Provider/session teardown remains responsible for closing an outstanding socket. A final snapshot reconciles bytes missed by the stream before returning a recorded exit.
38
+ - A sandbox record can survive the loss of its underlying container. Resume treats it as expired only when a fresh provider read confirms the exact missing-container error for that sandbox and marks it unrecoverable. Unknown errors and failed confirmation reads preserve the lease. The host still requires a verified native-runner backup before replacement.
39
+ - Daytona rejects Stop for a sandbox in its `error` state, for example after the sandbox disk fills. The stop-only hook confirms the retention policy first. If Daytona marks the error recoverable, the hook calls Recover once and waits at most 20 seconds for the sandbox to start. Then it stops the sandbox normally. The hook never calls Recover a second time in the same call. An unrecoverable error, a sandbox that is back in `error` after recovery, or an unfinished recovery returns a typed `PluginEnvironmentStopError` instead of the generic stop error. The sandbox is never deleted.
40
+ - Directory export normally builds a sandbox archive and downloads it. If archive creation exhausts disk space, quota, or the file-size limit, export streams the archive through a raw terminal instead. The sender can send up to sixteen 40 KiB chunks before it waits for their host write acknowledgements. The host writes them in order and rejects a sender that exceeds the pending-frame limit. This bounds queued payloads to 640 KiB while avoiding one network round trip per chunk. Import still requires successful tar completion and the existing archive/path validation. The total archive cannot exceed the provider-reported sandbox disk allocation, and each host write must leave a 1 GiB free-space reserve. This fallback writes no sandbox archive or command log, preserves source files, and retains the configured transfer timeout. Terminal cleanup has a separate five-second limit and cannot hold the host archive open. It requires Bash and GNU `tar`, `dd`, and `base64` in the sandbox. It does not repair a provider session that already failed to save its state or increase the sandbox's disk allocation.
41
+ - Single-file export normally downloads a guarded sandbox copy. If that copy exhausts disk space, quota, or the file-size limit, the provider removes partial copies and streams the source through the same bounded sandbox-user channel. The stream rechecks canonical confinement and regular-file identity, refuses a symlink at open, and publishes host files only after a successful transfer receipt. It never hands a mutable source to the privileged download API. Permission, confinement, and transport failures still fail; a failed stream leaves prior host files intact. This removes the second archive-sized copy needed to download an already captured workspace archive. Creating the workspace archive itself still needs sandbox space.
42
+
43
+ Native file transfers accept an optional `minimumTimeoutMs` from the host. The
44
+ minimum must be a positive whole number no greater than 30 minutes. File sync
45
+ uses the larger of this minimum and the configured timeout. Sandbox start and
46
+ command timeouts keep their configured limits. Without the field, behavior is
47
+ unchanged.
48
+
49
+ ## Local development
50
+
51
+ ```bash
52
+ cd packages/plugins/sandbox-providers/daytona
53
+ pnpm install --ignore-workspace --no-lockfile
54
+ pnpm build
55
+ pnpm test
56
+ pnpm exec vitest run --config vitest.sdk-ingress.config.ts
57
+ pnpm typecheck
58
+ ```
59
+
60
+ These commands assume the repo root has already been installed once so the local `@paperclipai/plugin-sdk` workspace package is available to the compiler during development.
61
+
62
+ The dedicated `vitest.sdk-ingress.config.ts` requires this package's installed, pinned Daytona SDK. It sends
63
+ local HTTP faults through the real SDK and worker RPC without a provider account
64
+ or sandbox. The root workspace does not install standalone provider dependencies;
65
+ its normal Daytona tests use mocked SDK boundaries. This target fails if the SDK
66
+ is missing and runs all ingress acceptance cases without a conditional skip.
67
+
68
+ The capacity regression uses Python 3 for a real local PTY, Bash, and GNU core
69
+ utilities (`gtar`, `gdd`, and `gbase64` on macOS). It skips when those prerequisites
70
+ are unavailable or their version checks do not match. With `DAYTONA_API_KEY` set, run
71
+ `pnpm test src/file-sync-capacity.live.test.ts` to exercise an actual stopped and
72
+ resumed Daytona sandbox, tar and file-copy writes to `/dev/full`, validated
73
+ exports, and second exports after reconnect. Each case creates and deletes one
74
+ disposable 1 GiB Ubuntu sandbox; it does not fill a disk or modify existing sandboxes.
75
+
76
+ ## Package layout
77
+
78
+ - `src/manifest.ts` declares the sandbox-provider driver metadata
79
+ - `src/plugin.ts` implements the environment lifecycle hooks
80
+ - `paperclipPlugin.manifest` and `paperclipPlugin.worker` point the host at the built plugin entrypoints in `dist/`
81
+
82
+
83
+ ### Interrupted run-lease creation
84
+
85
+ The host commits a company-scoped creation operation before acquiring a new run
86
+ lease. The operation UUID becomes `paperclip-create-<uuid>` and the
87
+ `paperclip-create-attempt` label. The existing inspection hook can resolve that
88
+ name and validate company, environment and run labels without starting a sandbox.
89
+ Recovery persists the observed provider ID before the existing cleanup worker
90
+ deletes it. A missing creation name is an uncertain outcome, not proof of removal.
91
+ The host retains that operation for manual reconciliation and never repeats the
92
+ creation request blindly. Credential identity must still match admission.
93
+
94
+ This capability is declared as `creationOperationVersion: 1` in manifest version
95
+ 0.1.10. It covers normal run/ad-hoc lease acquisition and plugin task replacement.
96
+ Legacy provider `environmentProbe` and custom-image interactive setup have separate
97
+ lifecycles and are outside this lease-orphan fallback replacement. The normal Test
98
+ path which acquires a runtime lease is covered. Unit fixtures exercise lookup and
99
+ deletion; live provider qualification requires an explicit disposable test account.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=archive-stream-window.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-stream-window.test.d.ts","sourceRoot":"","sources":["../src/archive-stream-window.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,93 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import { randomBytes } from "node:crypto";
3
+ import { promises as fs } from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { afterEach, expect, it, vi } from "vitest";
7
+ const { openSession } = vi.hoisted(() => ({ openSession: vi.fn() }));
8
+ vi.mock("./duplex-command-stream.js", () => ({ openDaytonaDuplexChannelSession: openSession }));
9
+ import { streamSandboxArchive } from "./archive-stream.js";
10
+ const roots = [];
11
+ const timers = new Set();
12
+ const children = new Set();
13
+ const executable = (names, version) => names.map(name => {
14
+ const resolved = spawnSync("/bin/sh", ["-c", 'command -v "$1"', "sh", name], { encoding: "utf8" }).stdout?.trim();
15
+ return resolved && spawnSync(resolved, ["--version"], { encoding: "utf8" }).stdout?.includes(version) ? resolved : undefined;
16
+ }).find(Boolean);
17
+ const tools = { dd: executable(["gdd", "dd"], "coreutils"), base64: executable(["gbase64", "base64"], "coreutils") };
18
+ function kill(child) {
19
+ if (child.exitCode !== null || child.signalCode !== null || !child.pid)
20
+ return;
21
+ try {
22
+ process.kill(-child.pid, "SIGKILL");
23
+ }
24
+ catch (error) {
25
+ if (error.code !== "ESRCH")
26
+ throw error;
27
+ }
28
+ }
29
+ afterEach(async () => {
30
+ for (const timer of timers)
31
+ clearTimeout(timer);
32
+ timers.clear();
33
+ for (const child of children)
34
+ kill(child);
35
+ children.clear();
36
+ vi.resetAllMocks();
37
+ await Promise.all(roots.splice(0).map(root => fs.rm(root, { recursive: true, force: true })));
38
+ });
39
+ it.skipIf(process.platform === "win32" || !tools.dd || !tools.base64).each([0, 1024 * 1024 + 17])("transfers %i bytes within its deadline across delayed acknowledgements", async (size) => {
40
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "archive-credit-window-"));
41
+ roots.push(root);
42
+ const bin = path.join(root, "bin");
43
+ await fs.mkdir(bin);
44
+ await fs.symlink(tools.dd, path.join(bin, "dd"));
45
+ await fs.symlink(tools.base64, path.join(bin, "base64"));
46
+ const source = path.join(root, "source.bin");
47
+ const destination = path.join(root, "saved.bin");
48
+ const bytes = randomBytes(size);
49
+ await fs.writeFile(source, bytes);
50
+ let closed = false;
51
+ openSession.mockImplementation(async (_process, command) => {
52
+ const marker = command.join(" ").match(/paperclip-archive-[a-f0-9-]+/)[0];
53
+ const child = spawn(command[0], command.slice(1), { cwd: root, detached: true,
54
+ env: { ...process.env, PATH: `${bin}:${process.env.PATH}` }, stdio: ["pipe", "pipe", "pipe"] });
55
+ children.add(child);
56
+ let stderr = "";
57
+ child.stderr.on("data", chunk => { stderr += chunk.toString(); });
58
+ const completion = new Promise((resolve, reject) => {
59
+ child.once("error", reject);
60
+ child.once("close", code => {
61
+ if (code && !closed)
62
+ reject(new Error(stderr || `archive producer exited ${code}`));
63
+ else
64
+ resolve({ exitCode: code, transportClosed: false });
65
+ });
66
+ });
67
+ return {
68
+ onData: callback => { child.stdout.on("data", callback); },
69
+ write: data => {
70
+ if (!data.toString().startsWith(marker)) {
71
+ child.stdin.write(data);
72
+ return;
73
+ }
74
+ const timer = setTimeout(() => {
75
+ timers.delete(timer);
76
+ if (!closed)
77
+ child.stdin.write(data);
78
+ }, 400);
79
+ timers.add(timer);
80
+ },
81
+ wait: () => completion,
82
+ kill: () => kill(child),
83
+ close: async () => { closed = true; kill(child); await completion; },
84
+ };
85
+ });
86
+ const quote = (value) => `'${value.replace(/'/g, `'"'"'`)}'`;
87
+ await streamSandboxArchive({ process: {}, cwd: root, archiveScript: `cat ${quote(source)}`,
88
+ destination, timeoutSeconds: 4, maxBytes: size + 1024 });
89
+ expect(await fs.readFile(destination)).toEqual(bytes);
90
+ expect(await fs.readFile(source)).toEqual(bytes);
91
+ expect(closed).toBe(true);
92
+ }, 15_000);
93
+ //# sourceMappingURL=archive-stream-window.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-stream-window.test.js","sourceRoot":"","sources":["../src/archive-stream-window.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,SA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AI,CAAC,CAAC;AAC5B,CAAC,EAAE,MAAM,CACV,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type DaytonaPtyProcess } from "./duplex-command-stream.js";
2
+ export declare function streamSandboxArchive(input: {
3
+ process: DaytonaPtyProcess;
4
+ cwd: string;
5
+ archiveScript: string;
6
+ destination: string;
7
+ timeoutSeconds: number;
8
+ maxBytes: number;
9
+ }): Promise<void>;
10
+ //# sourceMappingURL=archive-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-stream.d.ts","sourceRoot":"","sources":["../src/archive-stream.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmC,KAAK,iBAAiB,EAA6B,MAAM,4BAA4B,CAAC;AAsBhI,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmHhB"}
@@ -0,0 +1,159 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { open, statfs } from "node:fs/promises";
3
+ import { openDaytonaDuplexChannelSession } from "./duplex-command-stream.js";
4
+ const CHUNK_BYTES = 40 * 1024;
5
+ const CREDIT_WINDOW = 16;
6
+ const MAX_FRAME_BYTES = Math.ceil(CHUNK_BYTES / 3) * 4 + 128;
7
+ const MAX_BUFFER_BYTES = MAX_FRAME_BYTES * CREDIT_WINDOW;
8
+ const HOST_FREE_RESERVE_BYTES = 1024 ** 3;
9
+ const CLEANUP_TIMEOUT_MS = 5_000;
10
+ const quote = (value) => `'${value.replace(/'/g, `'"'"'`)}'`;
11
+ async function closeArchiveSession(session) {
12
+ let timer;
13
+ try {
14
+ await Promise.race([
15
+ session.close().catch(() => undefined),
16
+ new Promise(resolve => { timer = setTimeout(resolve, CLEANUP_TIMEOUT_MS); }),
17
+ ]);
18
+ }
19
+ finally {
20
+ clearTimeout(timer);
21
+ }
22
+ }
23
+ export async function streamSandboxArchive(input) {
24
+ if (!Number.isSafeInteger(input.maxBytes) || input.maxBytes <= 0) {
25
+ throw new Error("Daytona archive stream requires a verified sandbox disk budget");
26
+ }
27
+ const marker = `paperclip-archive-${randomUUID()}`;
28
+ const ready = `${marker}:ready`;
29
+ const start = `${marker}:start`;
30
+ const done = `${marker}:done`;
31
+ // fd 3 retains the PTY input while tar owns the pipeline's stdin. pipefail
32
+ // preserves tar failure even when the last encoder completes successfully.
33
+ const receiveAcknowledgements = [
34
+ 'while [ "$outstanding" -gt 0 ]; do',
35
+ `IFS= read -r ack <&3 && [ "$ack" = ${quote(marker)} ] || exit 1;`,
36
+ 'outstanding=$((outstanding - 1));',
37
+ "done",
38
+ ].join(" ");
39
+ const sender = [
40
+ "outstanding=0;",
41
+ "while :; do",
42
+ `chunk=$(dd bs=${CHUNK_BYTES} count=1 iflag=fullblock status=none | base64 -w 0) || exit 1;`,
43
+ '[ -n "$chunk" ] || break;',
44
+ 'printf "data:%s\\n" "$chunk";',
45
+ "outstanding=$((outstanding + 1));",
46
+ `if [ "$outstanding" -eq ${CREDIT_WINDOW} ]; then ${receiveAcknowledgements}; fi;`,
47
+ "done;",
48
+ receiveAcknowledgements,
49
+ ].join(" ");
50
+ // Duplicate the original input before constructing the tar pipeline.
51
+ const command = `exec 3<&0; printf '\\n%s\\n' ${quote(start)}; { ${input.archiveScript}; } | ( ${sender} ); `;
52
+ const launch = `${command}status=$?; [ "$status" -eq 0 ] || exit "$status"; ` +
53
+ `printf '%s\\n' ${quote(done)}; IFS= read -r ack <&3 && [ "$ack" = ${quote(done)} ]`;
54
+ const file = await open(input.destination, "w", 0o600);
55
+ let session;
56
+ let stopped = false;
57
+ let started = false;
58
+ let launched = false;
59
+ let complete = false;
60
+ let pendingFrames = 0;
61
+ let buffer = "";
62
+ let receivedBytes = 0;
63
+ let pending = Promise.resolve();
64
+ let rejectFailure;
65
+ const failure = new Promise((_, reject) => { rejectFailure = reject; });
66
+ const fail = (message) => rejectFailure(new Error(message));
67
+ const timer = setTimeout(() => fail("Daytona archive stream timed out"), input.timeoutSeconds * 1000);
68
+ const transfer = async () => {
69
+ session = await openDaytonaDuplexChannelSession(input.process, ["bash", "--noprofile", "--norc", "-o", "pipefail", "-c",
70
+ `printf '\\n%s\\n' ${quote(ready)}; IFS= read -r script && eval "$(printf %s \"$script\" | base64 -d)"`], { cwd: input.cwd, diagnosticsPath: "/dev/null" });
71
+ if (stopped) {
72
+ await closeArchiveSession(session);
73
+ return;
74
+ }
75
+ session.onData(bytes => {
76
+ if (stopped)
77
+ return;
78
+ buffer += Buffer.from(bytes).toString("utf8");
79
+ if (buffer.length > MAX_BUFFER_BYTES) {
80
+ fail("Daytona archive stream exceeded its buffer limit");
81
+ return;
82
+ }
83
+ for (let newline = buffer.indexOf("\n"); newline >= 0; newline = buffer.indexOf("\n")) {
84
+ const line = buffer.slice(0, newline).replace(/\r$/, "");
85
+ buffer = buffer.slice(newline + 1);
86
+ // The bootstrap confirms raw mode before sending the potentially long
87
+ // archive script, which would exceed a canonical terminal's line cap.
88
+ if (!launched && line === ready) {
89
+ launched = true;
90
+ session.write(Buffer.from(`${Buffer.from(launch).toString("base64")}\n`));
91
+ continue;
92
+ }
93
+ if (!started) {
94
+ if (line === start)
95
+ started = true;
96
+ continue;
97
+ }
98
+ if (line === done && !complete && pendingFrames === 0) {
99
+ complete = true;
100
+ session.write(Buffer.from(`${done}\n`));
101
+ continue;
102
+ }
103
+ if (!line || complete || !line.startsWith("data:")) {
104
+ fail("Invalid Daytona archive stream frame");
105
+ return;
106
+ }
107
+ if (pendingFrames >= CREDIT_WINDOW) {
108
+ fail("Daytona archive stream exceeded its pending frame limit");
109
+ return;
110
+ }
111
+ const encoded = line.slice(5);
112
+ const data = Buffer.from(encoded, "base64");
113
+ if (!data.length || data.length > CHUNK_BYTES || data.toString("base64") !== encoded) {
114
+ fail("Invalid Daytona archive stream payload");
115
+ return;
116
+ }
117
+ pendingFrames += 1;
118
+ pending = pending.then(async () => {
119
+ if (stopped)
120
+ return;
121
+ if (receivedBytes + data.length > input.maxBytes) {
122
+ throw new Error("Daytona archive stream exceeds the sandbox disk budget");
123
+ }
124
+ const available = await statfs(input.destination);
125
+ if (available.bavail * available.bsize - data.length < HOST_FREE_RESERVE_BYTES) {
126
+ throw new Error("Daytona archive stream would exhaust the host free-space reserve");
127
+ }
128
+ if (stopped)
129
+ return;
130
+ await file.writeFile(data);
131
+ receivedBytes += data.length;
132
+ pendingFrames -= 1;
133
+ session.write(Buffer.from(`${marker}\n`));
134
+ }).catch(error => { stopped = true; rejectFailure(error); });
135
+ }
136
+ });
137
+ const exit = await session.wait();
138
+ await pending;
139
+ if (exit.exitCode !== 0 || exit.transportClosed || !complete || buffer.trim()) {
140
+ throw new Error(`Daytona archive stream ended without a successful archive receipt (exit=${exit.exitCode ?? "unknown"}, started=${started}, complete=${complete}, pendingBytes=${buffer.length})`);
141
+ }
142
+ };
143
+ try {
144
+ await Promise.race([transfer(), failure]);
145
+ }
146
+ finally {
147
+ stopped = true;
148
+ clearTimeout(timer);
149
+ const cleanup = session ? closeArchiveSession(session) : Promise.resolve();
150
+ try {
151
+ await pending;
152
+ }
153
+ finally {
154
+ await file.close();
155
+ await cleanup;
156
+ }
157
+ }
158
+ }
159
+ //# sourceMappingURL=archive-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-stream.js","sourceRoot":"","sources":["../src/archive-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAqD,MAAM,4BAA4B,CAAC;AAEhI,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,aAAa,GAAG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,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,2EAA2E,IAAI,CAAC,QAAQ,IAAI,SAAS,aAAa,OAAO,cAAc,QAAQ,kBAAkB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACrM,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,CAAC;YAAS,CAAC;QACT,OAAO,GAAG,IAAI,CAAC;QACf,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3E,IAAI,CAAC;YACH,MAAM,OAAO,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,OAAO,CAAC;QAChB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=archive-stream.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-stream.test.d.ts","sourceRoot":"","sources":["../src/archive-stream.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,121 @@
1
+ import { promises as fs } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { open, statfs } from "node:fs/promises";
5
+ import { afterEach, expect, it, vi } from "vitest";
6
+ const { openSession } = vi.hoisted(() => ({ openSession: vi.fn() }));
7
+ vi.mock("./duplex-command-stream.js", () => ({ openDaytonaDuplexChannelSession: openSession }));
8
+ vi.mock("node:fs/promises", async (importOriginal) => {
9
+ const actual = await importOriginal();
10
+ return { ...actual, open: vi.fn(actual.open), statfs: vi.fn(actual.statfs) };
11
+ });
12
+ import { streamSandboxArchive } from "./archive-stream.js";
13
+ const roots = [];
14
+ afterEach(async () => {
15
+ vi.resetAllMocks();
16
+ vi.useRealTimers();
17
+ await Promise.all(roots.splice(0).map(root => fs.rm(root, { recursive: true, force: true })));
18
+ });
19
+ it.each(["missing receipt", "tar failure", "transport loss", "invalid base64", "oversized frame", "timeout", "host reserve", "archive budget"])("rejects %s and closes the transfer", async (fault) => {
20
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "archive-stream-"));
21
+ roots.push(root);
22
+ const close = vi.fn(async () => { });
23
+ if (fault === "host reserve")
24
+ vi.mocked(statfs).mockResolvedValue({ bavail: 0, bsize: 4096 });
25
+ openSession.mockImplementation(async (_process, command) => {
26
+ const marker = command.join(" ").match(/paperclip-archive-[a-f0-9-]+/)[0];
27
+ let listener;
28
+ let end;
29
+ const completion = new Promise(resolve => { end = resolve; });
30
+ let writes = 0;
31
+ const emit = (text) => listener(Buffer.from(text));
32
+ return {
33
+ onData: (callback) => { listener = callback; emit(`${marker}:ready\n`); },
34
+ write: () => {
35
+ queueMicrotask(() => {
36
+ if (++writes === 1) {
37
+ emit(`${marker}:start\n`);
38
+ if (fault === "timeout")
39
+ return;
40
+ if (fault === "invalid base64")
41
+ emit("data:not!base64\n");
42
+ else if (fault === "oversized frame")
43
+ emit(`data:${"a".repeat(6 * 1024 * 1024)}`);
44
+ else
45
+ emit(`data:${Buffer.from("partial archive").toString("base64")}\n`);
46
+ }
47
+ else {
48
+ if (fault === "tar failure")
49
+ emit(`${marker}:done\n`);
50
+ end({ exitCode: fault === "tar failure" ? 2 : fault === "transport loss" ? null : 0, transportClosed: fault === "transport loss" });
51
+ }
52
+ });
53
+ },
54
+ wait: () => completion,
55
+ kill: () => { },
56
+ close,
57
+ };
58
+ });
59
+ await expect(streamSandboxArchive({ process: {}, cwd: "/workspace", archiveScript: "tar -cf - .", destination: path.join(root, "archive.tar"), maxBytes: fault === "archive budget" ? 8 : 1024, timeoutSeconds: fault === "timeout" ? 0.02 : 5 })).rejects.toThrow(/archive stream/i);
60
+ if (fault === "host reserve" || fault === "archive budget")
61
+ expect((await fs.stat(path.join(root, "archive.tar"))).size).toBe(0);
62
+ expect(close).toHaveBeenCalledOnce();
63
+ });
64
+ it("closes the host file and bounds a stalled provider teardown", async () => {
65
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "archive-stream-"));
66
+ roots.push(root);
67
+ vi.useFakeTimers();
68
+ const close = vi.fn(() => new Promise(() => { }));
69
+ openSession.mockResolvedValue({ onData: vi.fn(), write: vi.fn(), wait: () => new Promise(() => { }), kill: vi.fn(), close });
70
+ const transfer = streamSandboxArchive({ process: {}, cwd: "/workspace", archiveScript: "tar -cf - .", destination: path.join(root, "archive.tar"), maxBytes: 1024, timeoutSeconds: 0.02 });
71
+ const rejected = expect(transfer).rejects.toThrow("timed out");
72
+ await vi.waitFor(() => expect(openSession).toHaveBeenCalledOnce());
73
+ await vi.advanceTimersByTimeAsync(20);
74
+ const file = await vi.mocked(open).mock.results[0].value;
75
+ await vi.waitFor(async () => { await expect(file.stat()).rejects.toMatchObject({ code: "EBADF" }); });
76
+ await vi.advanceTimersByTimeAsync(5_000);
77
+ await rejected;
78
+ expect(close).toHaveBeenCalledOnce();
79
+ });
80
+ it("closes a session that connects after the deadline", async () => {
81
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "archive-stream-"));
82
+ roots.push(root);
83
+ let connect;
84
+ openSession.mockReturnValue(new Promise(resolve => { connect = resolve; }));
85
+ await expect(streamSandboxArchive({ process: {}, cwd: "/workspace", archiveScript: "tar -cf - .", destination: path.join(root, "archive.tar"), maxBytes: 1024, timeoutSeconds: 0.02 })).rejects.toThrow("timed out");
86
+ const close = vi.fn(async () => { });
87
+ const onData = vi.fn();
88
+ connect({ close, onData, write: vi.fn(), wait: vi.fn(), kill: vi.fn() });
89
+ await vi.waitFor(() => expect(close).toHaveBeenCalledOnce());
90
+ expect(onData).not.toHaveBeenCalled();
91
+ });
92
+ it.each(["window overflow", "host write failure"])("stops queued frames after %s", async (fault) => {
93
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "archive-stream-window-"));
94
+ roots.push(root);
95
+ const destination = path.join(root, "archive.tar");
96
+ const file = await fs.open(destination, "w");
97
+ const writeFile = vi.fn(async () => { throw new Error("injected host write failure"); });
98
+ if (fault === "host write failure")
99
+ vi.mocked(open).mockResolvedValue({ writeFile, close: () => file.close() });
100
+ const close = vi.fn(async () => { });
101
+ openSession.mockImplementation(async (_process, command) => {
102
+ const marker = command.join(" ").match(/paperclip-archive-[a-f0-9-]+/)[0];
103
+ let emit;
104
+ return {
105
+ onData: callback => { emit = callback; queueMicrotask(() => emit(Buffer.from(`${marker}:ready\n`))); },
106
+ write: () => { queueMicrotask(() => emit(Buffer.from(`${marker}:start\n${"data:Ynl0ZXM=\n".repeat(fault === "window overflow" ? 17 : 16)}`))); },
107
+ wait: () => new Promise(() => { }), kill: vi.fn(), close,
108
+ };
109
+ });
110
+ try {
111
+ await expect(streamSandboxArchive({ process: {}, cwd: "/workspace", archiveScript: "cat source",
112
+ destination, maxBytes: 1024, timeoutSeconds: 5 })).rejects.toThrow(fault === "window overflow" ? "pending frame limit" : "injected host write failure");
113
+ if (fault === "host write failure")
114
+ expect(writeFile).toHaveBeenCalledOnce();
115
+ expect(close).toHaveBeenCalledOnce();
116
+ }
117
+ finally {
118
+ await file.close();
119
+ }
120
+ });
121
+ //# sourceMappingURL=archive-stream.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive-stream.test.js","sourceRoot":"","sources":["../src/archive-stream.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChD,OA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,CAAC,CAAC,CAAC,CAAC;YAChJ,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK;SACzB,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAW,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY;YACtG,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAClE,KAAK,KAAK,iBAAiB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,6BAA6B,CACpF,CAAC;QACF,IAAI,KAAK,KAAK,oBAAoB;YAAE,MAAM,CAAC,SAAS,CAAC,CAAC,oBAAoB,EAAE,CAAC;QAC7E,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACvC,CAAC;YAAS,CAAC;QAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=duplex-close-deadline.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duplex-close-deadline.test.d.ts","sourceRoot":"","sources":["../src/duplex-close-deadline.test.ts"],"names":[],"mappings":""}