@tickernelz/wardmote-plugin-daytona 0.0.0 → 2026.1108.2

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 (67) hide show
  1. package/README.md +51 -6
  2. package/dist/duplex-command-stream.d.ts +97 -0
  3. package/dist/duplex-command-stream.d.ts.map +1 -0
  4. package/dist/duplex-command-stream.js +205 -0
  5. package/dist/duplex-command-stream.js.map +1 -0
  6. package/dist/duplex-command-stream.live.test.d.ts +2 -0
  7. package/dist/duplex-command-stream.live.test.d.ts.map +1 -0
  8. package/dist/duplex-command-stream.live.test.js +324 -0
  9. package/dist/duplex-command-stream.live.test.js.map +1 -0
  10. package/dist/duplex-command-stream.test.d.ts +2 -0
  11. package/dist/duplex-command-stream.test.d.ts.map +1 -0
  12. package/dist/duplex-command-stream.test.js +519 -0
  13. package/dist/duplex-command-stream.test.js.map +1 -0
  14. package/dist/file-sync-diagnostics.test.d.ts +2 -0
  15. package/dist/file-sync-diagnostics.test.d.ts.map +1 -0
  16. package/dist/file-sync-diagnostics.test.js +117 -0
  17. package/dist/file-sync-diagnostics.test.js.map +1 -0
  18. package/dist/file-sync.d.ts +79 -0
  19. package/dist/file-sync.d.ts.map +1 -0
  20. package/dist/file-sync.js +1197 -0
  21. package/dist/file-sync.js.map +1 -0
  22. package/dist/file-sync.test.d.ts +2 -0
  23. package/dist/file-sync.test.d.ts.map +1 -0
  24. package/dist/file-sync.test.js +1047 -0
  25. package/dist/file-sync.test.js.map +1 -0
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +3 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/login-pty.d.ts +162 -0
  31. package/dist/login-pty.d.ts.map +1 -0
  32. package/dist/login-pty.js +258 -0
  33. package/dist/login-pty.js.map +1 -0
  34. package/dist/login-pty.test.d.ts +2 -0
  35. package/dist/login-pty.test.d.ts.map +1 -0
  36. package/dist/login-pty.test.js +319 -0
  37. package/dist/login-pty.test.js.map +1 -0
  38. package/dist/manifest.d.ts +5 -0
  39. package/dist/manifest.d.ts.map +1 -0
  40. package/dist/manifest.js +182 -0
  41. package/dist/manifest.js.map +1 -0
  42. package/dist/plugin.d.ts +49 -0
  43. package/dist/plugin.d.ts.map +1 -0
  44. package/dist/plugin.js +2930 -0
  45. package/dist/plugin.js.map +1 -0
  46. package/dist/plugin.test.d.ts +2 -0
  47. package/dist/plugin.test.d.ts.map +1 -0
  48. package/dist/plugin.test.js +5627 -0
  49. package/dist/plugin.test.js.map +1 -0
  50. package/dist/pty-chunked-input.d.ts +48 -0
  51. package/dist/pty-chunked-input.d.ts.map +1 -0
  52. package/dist/pty-chunked-input.js +74 -0
  53. package/dist/pty-chunked-input.js.map +1 -0
  54. package/dist/pty-chunked-input.test.d.ts +2 -0
  55. package/dist/pty-chunked-input.test.d.ts.map +1 -0
  56. package/dist/pty-chunked-input.test.js +115 -0
  57. package/dist/pty-chunked-input.test.js.map +1 -0
  58. package/dist/tar-listing.test.d.ts +2 -0
  59. package/dist/tar-listing.test.d.ts.map +1 -0
  60. package/dist/tar-listing.test.js +220 -0
  61. package/dist/tar-listing.test.js.map +1 -0
  62. package/dist/worker.d.ts +3 -0
  63. package/dist/worker.d.ts.map +1 -0
  64. package/dist/worker.js +5 -0
  65. package/dist/worker.js.map +1 -0
  66. package/package.json +35 -9
  67. package/index.js +0 -1
@@ -0,0 +1,117 @@
1
+ import { promises as fs } from "node:fs";
2
+ import { execFileSync } from "node:child_process";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { afterEach, expect, it, vi } from "vitest";
6
+ import { environmentSyncErrorData, withEnvironmentSyncErrorCapture, readEnvironmentSyncErrorDiagnostic } from "@tickernelz/wardmote-plugin-sdk";
7
+ vi.mock("./plugin.js", async () => {
8
+ const { NOOP_PLUGIN_TRACER } = await import("@tickernelz/wardmote-plugin-sdk");
9
+ return { getPluginTracer: () => NOOP_PLUGIN_TRACER };
10
+ });
11
+ import { performSyncOut } from "./file-sync.js";
12
+ const dirs = [];
13
+ afterEach(async () => { await Promise.all(dirs.splice(0).map(dir => fs.rm(dir, { recursive: true, force: true }))); });
14
+ it.each([
15
+ ["guard", "sandbox_guard", "command_failed", 42],
16
+ ["create", "archive_create", "command_failed", 2],
17
+ ["download", "archive_download", "download_failed", undefined],
18
+ ["missing", "archive_download", "download_missing", undefined],
19
+ ["file", "file_download", "download_failed", undefined],
20
+ ["file-missing", "file_download", "download_missing", undefined],
21
+ ])("records producer evidence for %s without copying output or paths", async (failure, step, kind, exitCode) => {
22
+ const dir = await fs.mkdtemp(path.join(os.tmpdir(), "daytona-diagnostic-"));
23
+ dirs.push(dir);
24
+ const sandbox = {
25
+ process: { executeCommand: async (command) => ({
26
+ exitCode: failure === "guard" ? 42 : failure === "create" && command.includes("tar -c") ? 2 : 0,
27
+ result: "private-command-output",
28
+ }) },
29
+ fs: {
30
+ downloadFiles: async (requests) => failure.endsWith("missing") ? []
31
+ : requests.map(request => ({ source: request.source, error: "private-download-error" })),
32
+ deleteFile: async () => undefined,
33
+ },
34
+ };
35
+ await withEnvironmentSyncErrorCapture(async () => {
36
+ let caught;
37
+ try {
38
+ await performSyncOut({ sandbox: sandbox, remoteDir: "/workspace", timeoutSeconds: 30,
39
+ operations: [{ operationId: "fixture", files: [{
40
+ sourcePath: "/workspace/private-path", targetPath: path.join(dir, "target"), kind: failure.startsWith("file") ? "file" : "directory",
41
+ }] }], });
42
+ }
43
+ catch (error) {
44
+ caught = error;
45
+ }
46
+ expect(caught).toBeInstanceOf(Error);
47
+ const diagnostic = readEnvironmentSyncErrorDiagnostic({ data: environmentSyncErrorData(caught) });
48
+ expect(diagnostic).toEqual({ errorCode: "unknown", transferStep: step, transferFailureKind: kind,
49
+ ...(exitCode !== undefined ? { exitCode } : {}),
50
+ });
51
+ expect(JSON.stringify(diagnostic)).not.toContain("private-");
52
+ expect(caught).not.toHaveProperty("transferStep");
53
+ expect(caught).not.toHaveProperty("exitCode");
54
+ });
55
+ });
56
+ it("keeps a thrown download exception identical and its nested safe code", async () => {
57
+ const original = Object.freeze(new Error("private-download-error", { cause: { code: "ECONNRESET", token: "private-token" } }));
58
+ const sandbox = {
59
+ process: { executeCommand: async () => ({ exitCode: 0 }) },
60
+ fs: { downloadFiles: async () => { throw original; }, deleteFile: async () => undefined },
61
+ };
62
+ await withEnvironmentSyncErrorCapture(async () => {
63
+ await expect(performSyncOut({ sandbox: sandbox, remoteDir: "/workspace", timeoutSeconds: 30,
64
+ operations: [{ operationId: "fixture", files: [{ sourcePath: "/workspace/private-path", targetPath: "/unused", kind: "directory" }] }], })).rejects.toBe(original);
65
+ expect(readEnvironmentSyncErrorDiagnostic({ data: environmentSyncErrorData(original) })).toEqual({
66
+ errorCode: "ECONNRESET", transferStep: "archive_download",
67
+ });
68
+ });
69
+ });
70
+ it.each(["file_finalize", "archive_validate", "archive_extract"])("identifies the host-side %s failure without relaxing confinement", async (step) => {
71
+ const dir = await fs.mkdtemp(path.join(os.tmpdir(), "daytona-host-diagnostic-"));
72
+ dirs.push(dir);
73
+ const target = path.join(dir, "target");
74
+ const archive = path.join(dir, "safe.tar");
75
+ if (step === "archive_extract") {
76
+ await fs.writeFile(path.join(dir, "safe.txt"), "fixture");
77
+ execFileSync("tar", ["-cf", archive, "-C", dir, "safe.txt"]);
78
+ await fs.writeFile(target, "preserve target");
79
+ }
80
+ const sandbox = {
81
+ process: { executeCommand: async () => ({ exitCode: 0 }) },
82
+ fs: {
83
+ downloadFiles: async (requests) => {
84
+ for (const request of requests) {
85
+ if (step === "archive_validate")
86
+ await fs.writeFile(request.destination, "invalid private archive");
87
+ if (step === "archive_extract")
88
+ await fs.copyFile(archive, request.destination);
89
+ }
90
+ return requests.map(request => ({ source: request.source }));
91
+ },
92
+ deleteFile: async () => undefined,
93
+ },
94
+ };
95
+ await withEnvironmentSyncErrorCapture(async () => {
96
+ let caught;
97
+ try {
98
+ await performSyncOut({ sandbox: sandbox, remoteDir: "/workspace", timeoutSeconds: 30,
99
+ operations: [{ operationId: "fixture", files: [{ sourcePath: "/workspace/private-path", targetPath: target,
100
+ kind: step === "file_finalize" ? "file" : "directory" }] }], });
101
+ }
102
+ catch (error) {
103
+ caught = error;
104
+ }
105
+ expect(caught).toBeInstanceOf(Error);
106
+ const diagnostic = readEnvironmentSyncErrorDiagnostic({ data: environmentSyncErrorData(caught) });
107
+ expect(diagnostic?.transferStep).toBe(step);
108
+ expect(JSON.stringify(diagnostic)).not.toContain("private");
109
+ if (step === "file_finalize")
110
+ expect(diagnostic?.errorCode).toBe("ENOENT");
111
+ if (step === "archive_validate")
112
+ expect(diagnostic?.transferFailureKind).toBe("command_failed");
113
+ if (step === "archive_extract")
114
+ expect(await fs.readFile(target, "utf8")).toBe("preserve target");
115
+ });
116
+ });
117
+ //# sourceMappingURL=file-sync-diagnostics.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-sync-diagnostics.test.js","sourceRoot":"","sources":["../src/file-sync-diagnostics.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AAChJ,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;IAChC,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,iCAAiC,CAAC,CAAC;IAC/E,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC;AACvD,CAAC,CAAC,CAAC;AACH,OAAO,E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C,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,MAAM,GAAG,KAAK,CAAC;QAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,kCAAkC,CAAC,EAAE,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAClG,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,IAAI,KAAK,eAAe;YAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3E,IAAI,IAAI,KAAK,kBAAkB;YAAE,MAAM,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAChG,IAAI,IAAI,KAAK,iBAAiB;YAAE,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACpG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,79 @@
1
+ import type { Sandbox } from "@daytonaio/sdk";
2
+ import type { PluginEnvironmentSyncResult, PluginSpan, PluginSyncOperation } from "@tickernelz/wardmote-plugin-sdk";
3
+ /**
4
+ * Run one span-wrapped step through the plugin tracer. The pack step, the
5
+ * transfer step, and each command round trip share this helper. It seeds the
6
+ * provider family, runs the step, marks a thrown step failed, and always ends
7
+ * the span. The host records the span with its true wall-clock width from the
8
+ * worker timestamps, so the span shows real time in the trace. The tracer is a
9
+ * no-op until the host injects a live tracer, so the span never changes the sync
10
+ * control flow.
11
+ *
12
+ * `wallMsAttr` is optional. The `pack` and `transfer` spans pass it to keep
13
+ * their existing `*.wall_ms` attribute. A per-round-trip span omits it, so it
14
+ * carries no `*.wall_ms` attribute and relies on the native span width.
15
+ *
16
+ * `run` receives the live span, so a caller that needs to record an attribute
17
+ * only known after the step completes (for example the compression byte
18
+ * counts) can call `span.setAttribute` directly, without a second span.
19
+ */
20
+ export declare function withProviderSpan<T>(input: {
21
+ name: string;
22
+ wallMsAttr?: string;
23
+ attributes?: Record<string, string | number | boolean>;
24
+ run: (span: PluginSpan) => Promise<T>;
25
+ }): Promise<T>;
26
+ /**
27
+ * Host-side complete-mediation guard applied as defense-in-depth below the
28
+ * orchestrator's own confinement. Every sandbox-side path (the sync target for
29
+ * inbound, the sync source for outbound) MUST canonicalize inside the workspace
30
+ * remote dir; absolute escapes and `..` traversal are rejected fail-closed before
31
+ * any bytes move. Sandbox paths on the server are POSIX.
32
+ */
33
+ export declare function assertConfinedSandboxPath(remoteDir: string, candidate: string, label: string): void;
34
+ /**
35
+ * Parse one `tar -tvf` verbose listing line into its leading type flag and the
36
+ * trailing name-and-link-target field. The listing dialect depends on which tar
37
+ * the host ships: GNU/busybox emit
38
+ * `<perms> <owner>/<group> <size> <date> <time> <rest>`, while bsdtar
39
+ * (libarchive — the system tar on macOS) emits the ls-style
40
+ * `<perms> <links> <user> <group> <size> <Mon> <day> <time|year> <rest>`.
41
+ * The second field disambiguates: GNU always slash-joins owner/group, bsdtar
42
+ * puts a pure-digit link count there, so no line satisfies both shapes — the
43
+ * slash requirement is load-bearing, since a bsdtar line with numeric uid/gid
44
+ * would otherwise match the GNU shape shifted, hiding traversal in `<rest>`.
45
+ * Entries whose size column is not a plain byte count (e.g. a device node's
46
+ * `major,minor`) match neither shape. Returns null when nothing matches so
47
+ * callers can fail closed.
48
+ */
49
+ export declare function parseTarVerboseListingLine(line: string): {
50
+ typeFlag: string;
51
+ rest: string;
52
+ } | null;
53
+ /**
54
+ * Split a verbose-listing link field (`<name><delimiter><target>`) exactly
55
+ * once. The sandbox controls both halves, so a field with zero or multiple
56
+ * delimiter occurrences is unresolvable: a link name that itself contains the
57
+ * delimiter shifts the split point, and taking the first (or last) occurrence
58
+ * would let a crafted name or target hide an escaping link target from the
59
+ * confinement check. Returns null so callers fail closed.
60
+ */
61
+ export declare function splitLinkEntryOnce(field: string, delimiter: string): {
62
+ name: string;
63
+ target: string;
64
+ } | null;
65
+ export declare function assertTarballEntriesConfined(archivePath: string, timeoutMs?: number): Promise<void>;
66
+ export declare function performSyncIn(input: {
67
+ sandbox: Sandbox;
68
+ operations: PluginSyncOperation[];
69
+ remoteDir: string;
70
+ timeoutSeconds: number;
71
+ }): Promise<PluginEnvironmentSyncResult>;
72
+ export declare function performSyncOut(input: {
73
+ sandbox: Sandbox;
74
+ operations: PluginSyncOperation[];
75
+ remoteDir: string;
76
+ timeoutSeconds: number;
77
+ onArchiveRecovery?: () => void;
78
+ }): Promise<PluginEnvironmentSyncResult>;
79
+ //# sourceMappingURL=file-sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-sync.d.ts","sourceRoot":"","sources":["../src/file-sync.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAyD,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,KAAK,EACV,2BAA2B,EAE3B,UAAU,EAEV,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAiCzC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACvD,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACvC,GAAG,OAAO,CAAC,CAAC,CAAC,CAcb;AAoC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