skydive-cli 0.5.0-beta.9 → 0.6.0-beta.3

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 (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +61 -13
  3. package/dist/js/api-BFQ4PQDA.mjs +315 -0
  4. package/dist/js/{billing-blocked-Dgu5-oDy.mjs → billing-blocked-SE6tySLd.mjs} +1 -1
  5. package/dist/js/bin.mjs +674 -307
  6. package/dist/js/{boot-Q-Kh3nn5.mjs → boot-CleHADz9.mjs} +4558 -930
  7. package/dist/js/chunk-BbwQpWto.mjs +33 -0
  8. package/dist/js/{client-c4c5MmgN.mjs → client-Btq6bMzX.mjs} +108 -2
  9. package/dist/js/{client-DabRpc_T.mjs → client-CErCpXl9.mjs} +437 -39
  10. package/dist/js/client-qY4nTj2Y.mjs +5 -0
  11. package/dist/js/daemon-BuTGs-Ns.mjs +7 -0
  12. package/dist/js/{daemon-D21wQ7DI.mjs → daemon-Cuy4S6Rw.mjs} +238 -50
  13. package/dist/js/daemon-client-BVX-rWfX.mjs +8 -0
  14. package/dist/js/{daemon-client-DPUNjhBB.mjs → daemon-client-b10uck-j.mjs} +1 -1
  15. package/dist/js/dist-CRtjM7ba.mjs +1750 -0
  16. package/dist/js/forward-C-f04uyE.mjs +208 -0
  17. package/dist/js/{profiler-BkCV__ao.mjs → install-D7MwRv0n.mjs} +545 -215
  18. package/dist/js/launcher.mjs +49 -0
  19. package/dist/js/localhost-cert-Bn-UBUmj.mjs +67 -0
  20. package/dist/js/{print-BpuyEfWX.mjs → print-B3yhPm0N.mjs} +257 -35
  21. package/dist/js/{print-Wakr3GJd.mjs → print-VulYMc7x.mjs} +3 -3
  22. package/dist/js/{print-share-CKLPmsg0.mjs → print-share-DfTHn1HL.mjs} +9 -3
  23. package/dist/js/raw-pty-Ci2qFR9F.mjs +5 -0
  24. package/dist/js/{raw-pty-DY4KelZW.mjs → raw-pty-D5PhKZSl.mjs} +1 -1
  25. package/dist/js/rest-CRRpVyot.mjs +6 -0
  26. package/dist/js/{rest-I3imNduB.mjs → rest-ChXt8YGA.mjs} +144 -19
  27. package/dist/js/tls-cert-BpCaD5AT.mjs +4 -0
  28. package/dist/js/tls-cert-Rua2oV7n.mjs +67 -0
  29. package/package.json +14 -6
  30. package/dist/js/api-DG5W6iwx.mjs +0 -131
  31. package/dist/js/client-BuU34IVE.mjs +0 -5
  32. package/dist/js/daemon-LSDSvMaC.mjs +0 -6
  33. package/dist/js/daemon-client-CUSq-Wuh.mjs +0 -7
  34. package/dist/js/forward-18QoL5dO.mjs +0 -68
  35. package/dist/js/raw-pty-DmdUf4_w.mjs +0 -5
  36. package/dist/js/rest-D29qNkto.mjs +0 -6
  37. /package/dist/js/{billing-blocked-2wju4gC_.mjs → billing-blocked-D3l5kJlX.mjs} +0 -0
  38. /package/dist/js/{http-error-DzyrsLAZ.mjs → http-error-BF2NZZE3.mjs} +0 -0
  39. /package/dist/js/{output-DYzzdXYV.mjs → output-C9mb3sUB.mjs} +0 -0
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+
4
+ //#region \0rolldown/runtime.js
5
+ var __create = Object.create;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) {
17
+ __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ }
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
+ value: mod,
28
+ enumerable: true
29
+ }) : target, mod));
30
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
31
+
32
+ //#endregion
33
+ export { __require as n, __toESM as r, __commonJSMin as t };
@@ -1,6 +1,108 @@
1
1
  #!/usr/bin/env node
2
2
  import { WebSocket } from "ws";
3
3
 
4
+ //#region ../sandbox-stream-protocol/src/fs.ts
5
+ /** fs frame type bytes. Disjoint from FRAME.* in ./index.ts. */
6
+ const FS_FRAME = {
7
+ REQ: 32,
8
+ RES: 33
9
+ };
10
+ /** Filesystem operations the channel supports. One byte on the wire. */
11
+ const FS_OP = {
12
+ LIST: 1,
13
+ STAT: 2,
14
+ READ: 3,
15
+ WRITE: 4,
16
+ MKDIR: 5,
17
+ RENAME: 6,
18
+ REMOVE: 7,
19
+ EXISTS: 8
20
+ };
21
+ /** Reply status. OK carries a result; ERR carries a message in `json.message`. */
22
+ const FS_STATUS = {
23
+ OK: 0,
24
+ ERR: 1
25
+ };
26
+ const FS_MAX_BLOB_BYTES = 8 * 1024 * 1024;
27
+ const OP_TO_CODE = {
28
+ list: FS_OP.LIST,
29
+ stat: FS_OP.STAT,
30
+ read: FS_OP.READ,
31
+ write: FS_OP.WRITE,
32
+ mkdir: FS_OP.MKDIR,
33
+ rename: FS_OP.RENAME,
34
+ remove: FS_OP.REMOVE,
35
+ exists: FS_OP.EXISTS
36
+ };
37
+ const CODE_TO_OP = new Map(Object.entries(OP_TO_CODE).map(([op, code]) => [code, op]));
38
+ const textEncoder = new TextEncoder();
39
+ const textDecoder = new TextDecoder();
40
+ function frame(type, reqId, byte2, json, blob) {
41
+ const jsonBytes = textEncoder.encode(JSON.stringify(json ?? {}));
42
+ const out = new Uint8Array(10 + jsonBytes.length + blob.length);
43
+ const dv = new DataView(out.buffer);
44
+ out[0] = type;
45
+ dv.setUint32(1, reqId >>> 0);
46
+ out[5] = byte2;
47
+ dv.setUint32(6, jsonBytes.length);
48
+ out.set(jsonBytes, 10);
49
+ out.set(blob, 10 + jsonBytes.length);
50
+ return out;
51
+ }
52
+ const EMPTY = new Uint8Array(0);
53
+ /** client → server: encode an fs request. `blob` is the write payload, or null. */
54
+ function encodeFsRequest(reqId, req, blob) {
55
+ return frame(FS_FRAME.REQ, reqId, OP_TO_CODE[req.op], req, blob ?? EMPTY);
56
+ }
57
+ /**
58
+ * Decode a server fs reply frame. Returns null for a malformed frame so a peer
59
+ * on a newer protocol can't crash the client.
60
+ */
61
+ function decodeFsResponse(frameBytes) {
62
+ const parsed = parseFrame(FS_FRAME.RES, frameBytes);
63
+ if (!parsed) return null;
64
+ if (parsed.byte2 === FS_STATUS.ERR) {
65
+ const message = typeof parsed.json.message === "string" ? parsed.json.message : "fs operation failed";
66
+ return {
67
+ reqId: parsed.reqId,
68
+ status: "error",
69
+ message
70
+ };
71
+ }
72
+ return {
73
+ reqId: parsed.reqId,
74
+ status: "ok",
75
+ result: parsed.json,
76
+ blob: parsed.blob
77
+ };
78
+ }
79
+ function parseFrame(expectedType, frameBytes) {
80
+ if (frameBytes.length < 10) return null;
81
+ if (frameBytes[0] !== expectedType) return null;
82
+ const dv = new DataView(frameBytes.buffer, frameBytes.byteOffset, frameBytes.byteLength);
83
+ const reqId = dv.getUint32(1);
84
+ const byte2 = frameBytes[5] ?? 0;
85
+ const jsonLen = dv.getUint32(6);
86
+ const jsonStart = 10;
87
+ const jsonEnd = jsonStart + jsonLen;
88
+ if (jsonEnd > frameBytes.length) return null;
89
+ let json;
90
+ try {
91
+ const parsed = jsonLen ? JSON.parse(textDecoder.decode(frameBytes.subarray(jsonStart, jsonEnd))) : {};
92
+ if (typeof parsed !== "object" || parsed === null) return null;
93
+ json = parsed;
94
+ } catch {
95
+ return null;
96
+ }
97
+ return {
98
+ reqId,
99
+ byte2,
100
+ json,
101
+ blob: frameBytes.subarray(jsonEnd)
102
+ };
103
+ }
104
+
105
+ //#endregion
4
106
  //#region ../sandbox-stream-protocol/src/index.ts
5
107
  const SANDBOX_STREAM_PATH = "/api/v1/sandbox/stream";
6
108
  const FRAME = {
@@ -19,11 +121,15 @@ function streamSpecToQuery(spec) {
19
121
  cols: String(spec.cols),
20
122
  rows: String(spec.rows)
21
123
  };
22
- return {
124
+ if (spec.mode === "exec") return {
23
125
  agentId: spec.agentId,
24
126
  mode: "exec",
25
127
  command: spec.command
26
128
  };
129
+ return {
130
+ agentId: spec.agentId,
131
+ mode: "fs"
132
+ };
27
133
  }
28
134
  function withType(type, payload) {
29
135
  const frame = new Uint8Array(1 + payload.length);
@@ -166,4 +272,4 @@ function toBuffer(data) {
166
272
  }
167
273
 
168
274
  //#endregion
169
- export { SandboxStream as t };
275
+ export { encodeFsRequest as a, decodeFsResponse as i, SANDBOX_STREAM_PATH as n, streamSpecToQuery as r, SandboxStream as t };