@dreamlake/dreamlake-cli 0.117.0 → 0.118.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 (38) hide show
  1. package/dist/api/file-multipart.d.ts +6 -0
  2. package/dist/api/file-multipart.js +11 -0
  3. package/dist/api/index.d.ts +44 -0
  4. package/dist/api/native-experiments.d.ts +25 -0
  5. package/dist/api/native-experiments.js +49 -3
  6. package/dist/cli/experiments/index.js +4 -0
  7. package/dist/cli/experiments/management.d.ts +16 -0
  8. package/dist/cli/experiments/management.js +82 -0
  9. package/dist/cli/experiments/transfer/adapter.d.ts +86 -0
  10. package/dist/cli/experiments/transfer/adapter.js +637 -0
  11. package/dist/cli/experiments/transfer/context.d.ts +13 -0
  12. package/dist/cli/experiments/transfer/context.js +20 -0
  13. package/dist/cli/experiments/transfer/download.d.ts +24 -0
  14. package/dist/cli/experiments/transfer/download.js +516 -0
  15. package/dist/cli/experiments/transfer/index.d.ts +2 -0
  16. package/dist/cli/experiments/transfer/index.js +38 -0
  17. package/dist/cli/experiments/transfer/local/safe-path.d.ts +29 -0
  18. package/dist/cli/experiments/transfer/local/safe-path.js +106 -0
  19. package/dist/cli/experiments/transfer/local/storage.d.ts +125 -0
  20. package/dist/cli/experiments/transfer/local/storage.js +432 -0
  21. package/dist/cli/experiments/transfer/transport.d.ts +7 -0
  22. package/dist/cli/experiments/transfer/transport.js +31 -0
  23. package/dist/cli/experiments/transfer/types.d.ts +48 -0
  24. package/dist/cli/experiments/transfer/types.js +1 -0
  25. package/dist/cli/experiments/transfer/upload.d.ts +58 -0
  26. package/dist/cli/experiments/transfer/upload.js +665 -0
  27. package/dist/cli/experiments/transfer/util/ansi.d.ts +24 -0
  28. package/dist/cli/experiments/transfer/util/ansi.js +70 -0
  29. package/dist/cli/experiments/transfer/util/glob.d.ts +4 -0
  30. package/dist/cli/experiments/transfer/util/glob.js +39 -0
  31. package/dist/cli/experiments/transfer/util/json.d.ts +6 -0
  32. package/dist/cli/experiments/transfer/util/json.js +58 -0
  33. package/dist/cli/experiments/transfer/util/pool.d.ts +5 -0
  34. package/dist/cli/experiments/transfer/util/pool.js +21 -0
  35. package/dist/cli/help-examples.generated.js +12 -0
  36. package/dist/cli/version.d.ts +1 -1
  37. package/dist/cli/version.js +1 -1
  38. package/package.json +9 -9
@@ -0,0 +1,70 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ const enabled = () => {
3
+ if (process.env.NO_COLOR !== undefined)
4
+ return false;
5
+ if (process.env.FORCE_COLOR !== undefined)
6
+ return true;
7
+ return process.stdout.isTTY === true;
8
+ };
9
+ const wrap = (code, close) => (s) => enabled() ? `\u001b[${code}m${s}\u001b[${close}m` : s;
10
+ export const bold = wrap(1, 22);
11
+ export const dim = wrap(2, 22);
12
+ export const red = wrap(31, 39);
13
+ export const green = wrap(32, 39);
14
+ export const yellow = wrap(33, 39);
15
+ export const blue = wrap(34, 39);
16
+ export const cyan = wrap(36, 39);
17
+ /** Visible width, ignoring the escape sequences the styles above insert. */
18
+ export const visibleWidth = (s) =>
19
+ // eslint-disable-next-line no-control-regex
20
+ s.replace(/\u001b\[[0-9;]*m/g, "").length;
21
+ const pad = (s, width, align) => {
22
+ const gap = Math.max(0, width - visibleWidth(s));
23
+ if (align === "right")
24
+ return " ".repeat(gap) + s;
25
+ if (align === "center") {
26
+ const l = Math.floor(gap / 2);
27
+ return " ".repeat(l) + s + " ".repeat(gap - l);
28
+ }
29
+ return s + " ".repeat(gap);
30
+ };
31
+ /** Rounded-box table, the same shape `rich.box.ROUNDED` produced. */
32
+ export function renderTable(columns, rows, opts = {}) {
33
+ const widths = columns.map((c, i) => Math.max(visibleWidth(c.header), ...rows.map((r) => visibleWidth(r[i] ?? ""))));
34
+ const line = (l, m, r) => l + widths.map((w) => "─".repeat(w + 2)).join(m) + r;
35
+ const out = [];
36
+ if (opts.title)
37
+ out.push(bold(opts.title));
38
+ out.push(line("╭", "┬", "╮"));
39
+ out.push("│ " + columns.map((c, i) => pad(bold(c.header), widths[i], c.align ?? "left")).join(" │ ") + " │");
40
+ out.push(line("├", "┼", "┤"));
41
+ for (const row of rows) {
42
+ out.push("│ " + columns.map((c, i) => pad(row[i] ?? "", widths[i], c.align ?? "left")).join(" │ ") + " │");
43
+ }
44
+ out.push(line("╰", "┴", "╯"));
45
+ if (opts.caption)
46
+ out.push(dim(opts.caption));
47
+ return out.join("\n");
48
+ }
49
+ /** Bordered panel, the shape `rich.panel.Panel` produced. */
50
+ export function renderPanel(body, opts = {}) {
51
+ const lines = body.split("\n");
52
+ const width = Math.max(...lines.map(visibleWidth), opts.title ? visibleWidth(opts.title) + 2 : 0);
53
+ const top = opts.title
54
+ ? "╭─ " + opts.title + " " + "─".repeat(Math.max(0, width - visibleWidth(opts.title) - 1)) + "╮"
55
+ : "╭" + "─".repeat(width + 2) + "╮";
56
+ const out = [top];
57
+ for (const l of lines)
58
+ out.push("│ " + pad(l, width, "left") + " │");
59
+ out.push("╰" + "─".repeat(width + 2) + "╯");
60
+ return out.join("\n");
61
+ }
62
+ export function formatBytes(n) {
63
+ let v = n;
64
+ for (const unit of ["B", "KB", "MB", "GB"]) {
65
+ if (v < 1024)
66
+ return `${v.toFixed(2)} ${unit}`;
67
+ v /= 1024;
68
+ }
69
+ return `${v.toFixed(2)} TB`;
70
+ }
@@ -0,0 +1,4 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ export declare function fnmatch(name: string, pattern: string): boolean;
3
+ export declare function fnmatchToRegExp(pattern: string): RegExp;
4
+ export declare const hasWildcard: (s: string) => boolean;
@@ -0,0 +1,39 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ export function fnmatch(name, pattern) {
3
+ return fnmatchToRegExp(pattern).test(name);
4
+ }
5
+ export function fnmatchToRegExp(pattern) {
6
+ let out = "";
7
+ let i = 0;
8
+ while (i < pattern.length) {
9
+ const c = pattern[i++];
10
+ if (c === "*")
11
+ out += ".*";
12
+ else if (c === "?")
13
+ out += ".";
14
+ else if (c === "[") {
15
+ let j = i;
16
+ if (j < pattern.length && (pattern[j] === "!" || pattern[j] === "^"))
17
+ j++;
18
+ if (j < pattern.length && pattern[j] === "]")
19
+ j++;
20
+ while (j < pattern.length && pattern[j] !== "]")
21
+ j++;
22
+ if (j >= pattern.length) {
23
+ out += "\\[";
24
+ }
25
+ else {
26
+ let body = pattern.slice(i, j);
27
+ if (body.startsWith("!") || body.startsWith("^"))
28
+ body = "^" + body.slice(1);
29
+ out += "[" + body.replace(/\\/g, "\\\\") + "]";
30
+ i = j + 1;
31
+ }
32
+ }
33
+ else {
34
+ out += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
35
+ }
36
+ }
37
+ return new RegExp(`^${out}$`, "s");
38
+ }
39
+ export const hasWildcard = (s) => /[*?[]/.test(s);
@@ -0,0 +1,6 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ /** Rewrite unsafe integer literals as strings, leaving strings and floats alone. */
3
+ export declare function preserveBigIntegers(text: string): string;
4
+ export declare function parseJson<T = any>(text: string): T;
5
+ /** Coerce whatever the server sent for an ID into a string, losslessly. */
6
+ export declare function asId(v: unknown): string | undefined;
@@ -0,0 +1,58 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ /** Rewrite unsafe integer literals as strings, leaving strings and floats alone. */
3
+ export function preserveBigIntegers(text) {
4
+ let out = "";
5
+ let i = 0;
6
+ const n = text.length;
7
+ while (i < n) {
8
+ const c = text[i];
9
+ if (c === '"') {
10
+ // Copy the string literal verbatim — digits inside it are not numbers.
11
+ const start = i++;
12
+ while (i < n) {
13
+ if (text[i] === "\\")
14
+ i += 2;
15
+ else if (text[i] === '"') {
16
+ i++;
17
+ break;
18
+ }
19
+ else
20
+ i++;
21
+ }
22
+ out += text.slice(start, i);
23
+ continue;
24
+ }
25
+ if (c === "-" || (c >= "0" && c <= "9")) {
26
+ const start = i;
27
+ if (text[i] === "-")
28
+ i++;
29
+ while (i < n && text[i] >= "0" && text[i] <= "9")
30
+ i++;
31
+ const isInteger = !(i < n && (text[i] === "." || text[i] === "e" || text[i] === "E"));
32
+ while (i < n && /[0-9.eE+-]/.test(text[i]))
33
+ i++;
34
+ const literal = text.slice(start, i);
35
+ // Only integers, and only those outside the exactly-representable range.
36
+ out += isInteger && !Number.isSafeInteger(Number(literal)) ? `"${literal}"` : literal;
37
+ continue;
38
+ }
39
+ out += c;
40
+ i++;
41
+ }
42
+ return out;
43
+ }
44
+ export function parseJson(text) {
45
+ return JSON.parse(preserveBigIntegers(text));
46
+ }
47
+ /** Coerce whatever the server sent for an ID into a string, losslessly. */
48
+ export function asId(v) {
49
+ if (v === null || v === undefined)
50
+ return undefined;
51
+ if (typeof v === "string")
52
+ return v;
53
+ if (typeof v === "number")
54
+ return String(v);
55
+ if (typeof v === "bigint")
56
+ return v.toString();
57
+ return String(v);
58
+ }
@@ -0,0 +1,5 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ export declare function runPool<T, R>(items: T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<{
3
+ value?: R;
4
+ error?: Error;
5
+ }[]>;
@@ -0,0 +1,21 @@
1
+ /** .dash format compatibility, ported from the MIT-licensed ml-dash-cli. */
2
+ export async function runPool(items, limit, worker) {
3
+ const results = new Array(items.length);
4
+ const width = Math.max(1, Math.min(limit, items.length));
5
+ let cursor = 0;
6
+ const runners = Array.from({ length: width }, async () => {
7
+ for (;;) {
8
+ const index = cursor++;
9
+ if (index >= items.length)
10
+ return;
11
+ try {
12
+ results[index] = { value: await worker(items[index], index) };
13
+ }
14
+ catch (e) {
15
+ results[index] = { error: e instanceof Error ? e : new Error(String(e)) };
16
+ }
17
+ }
18
+ });
19
+ await Promise.all(runners);
20
+ return results;
21
+ }
@@ -57,6 +57,18 @@ export const helpExamples = {
57
57
  "experiments binding": "dl experiments binding --namespace fortyfive --json",
58
58
  "experiments connect": "dl experiments connect research --namespace fortyfive --json\n# Apply only after reviewing the preview. Use its actual revision, not this example's 0.\ndl experiments connect \"$DASH_NAMESPACE_ID\" --namespace fortyfive --instance-id \"$DASH_INSTANCE_ID\" --apply --expected-revision 0 --json",
59
59
  "experiments disconnect": "dl experiments disconnect --namespace fortyfive --json\n# Replace 1 with the revision returned by this preview.\ndl experiments disconnect --namespace fortyfive --apply --expected-revision 1 --json",
60
+ "experiments upload": "dl experiments upload ./.dash --project 'fortyfive/research/*' --strict",
61
+ "experiments download": "dl experiments download ./experiment-copy --project fortyfive/research --experiment trial_1",
62
+ "experiments writers list": "dl experiments writers list --namespace fortyfive --project research",
63
+ "experiments writers create": "dl experiments writers create --namespace fortyfive --project research --idempotency-key \"$INTENT_UUID\" --run-id \"$RUN_ID\"",
64
+ "experiments writers inspect": "dl experiments writers inspect \"$WRITER_ID\" --namespace fortyfive --project research",
65
+ "experiments writers rotate": "dl experiments writers rotate \"$WRITER_ID\" --expected-generation 1 --namespace fortyfive --project research",
66
+ "experiments writers retire": "dl experiments writers retire \"$WRITER_ID\" --expected-generation 2 --namespace fortyfive --project research",
67
+ "experiments jobs submit": "dl experiments jobs submit --spec job.json --namespace fortyfive --project research",
68
+ "experiments jobs list": "dl experiments jobs list --namespace fortyfive --project research",
69
+ "experiments jobs show": "dl experiments jobs show \"$JOB_ID\" --namespace fortyfive --project research",
70
+ "experiments jobs logs": "dl experiments jobs logs \"$JOB_ID\" --namespace fortyfive --project research",
71
+ "experiments jobs cancel": "dl experiments jobs cancel \"$JOB_ID\" --namespace fortyfive --project research",
60
72
  "hosts list": "dl hosts list\ndl hosts list --namespace geyang --group workstations\ndl hosts list --json\ndl hosts list --all\ndl hosts list --wide\ndl hosts --fields\ndl hosts --format '{name} {user} {ips} {network_freshness}'\ndl hosts --probe --format '{name} {ip} {public_ip} {macs} {uptime}'",
61
73
  "hosts status": "dl hosts status geyang/workstations/worker\ndl hosts status HOST_ID --namespace geyang --json\ndl hosts status 'geyang/workstations/*' --page 2 --page-size 100 --json",
62
74
  "hosts lifecycle": "dl hosts lifecycle HOST_ID --namespace geyang --json",
@@ -1 +1 @@
1
- export declare const VERSION = "0.117.0";
1
+ export declare const VERSION = "0.118.0";
@@ -6,4 +6,4 @@
6
6
  // value means a binary that re-installs the same version forever.
7
7
  //
8
8
  // Editing this by hand does nothing for a release; bump package.json.
9
- export const VERSION = "0.117.0";
9
+ export const VERSION = "0.118.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.117.0",
3
+ "version": "0.118.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -37,13 +37,13 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.117.0",
41
- "@dreamlake/dreamlake-cli-darwin-x64": "0.117.0",
42
- "@dreamlake/dreamlake-cli-linux-x64": "0.117.0",
43
- "@dreamlake/dreamlake-cli-linux-arm64": "0.117.0",
44
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.117.0",
45
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.117.0",
46
- "@dreamlake/dreamlake-cli-win32-x64": "0.117.0",
47
- "@dreamlake/dreamlake-cli-win32-arm64": "0.117.0"
40
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.118.0",
41
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.118.0",
42
+ "@dreamlake/dreamlake-cli-linux-x64": "0.118.0",
43
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.118.0",
44
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.118.0",
45
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.118.0",
46
+ "@dreamlake/dreamlake-cli-win32-x64": "0.118.0",
47
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.118.0"
48
48
  }
49
49
  }