@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,6 @@
1
+ export interface FileMultipart {
2
+ body: Blob;
3
+ contentType: string;
4
+ }
5
+ /** Keep filenames literal: FormData percent-escapes quotes, which multipart receivers retain. */
6
+ export declare function fileMultipart(fields: Record<string, string>, file: Blob, filename: string): FileMultipart;
@@ -0,0 +1,11 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ /** Keep filenames literal: FormData percent-escapes quotes, which multipart receivers retain. */
3
+ export function fileMultipart(fields, file, filename) {
4
+ const boundary = `dreamlake-${randomUUID()}`;
5
+ const parts = [];
6
+ for (const [name, value] of Object.entries(fields))
7
+ parts.push(`--${boundary}\r\nContent-Disposition: form-data; name="${name}"\r\n\r\n${value}\r\n`);
8
+ const encoded = encodeURIComponent(filename).replace(/['()*]/g, c => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
9
+ parts.push(`--${boundary}\r\nContent-Disposition: form-data; name="file"; filename="file"; filename*=UTF-8''${encoded}\r\nContent-Type: ${file.type || 'application/octet-stream'}\r\n\r\n`, file, `\r\n--${boundary}--\r\n`);
10
+ return { body: new Blob(parts), contentType: `multipart/form-data; boundary=${boundary}` };
11
+ }
@@ -343,6 +343,28 @@ export declare function createApi(transport: Transport): {
343
343
  signal?: AbortSignal;
344
344
  }) => Promise<Response>;
345
345
  };
346
+ writers: {
347
+ list: (query?: {
348
+ limit?: number;
349
+ cursor?: string;
350
+ }) => Promise<unknown>;
351
+ get: (id: string) => Promise<unknown>;
352
+ create: (idempotencyKey: string, runId?: string) => Promise<unknown>;
353
+ rotate: (credentialId: string, expectedGeneration: number) => Promise<unknown>;
354
+ retire: (credentialId: string, expectedGeneration: number) => Promise<unknown>;
355
+ };
356
+ jobs: {
357
+ submit: (input: import("./execution.js").RunInput) => Promise<unknown>;
358
+ list: (query?: {
359
+ limit?: number;
360
+ cursor?: string;
361
+ }) => Promise<unknown>;
362
+ summary: (id: string) => Promise<unknown>;
363
+ cancel: (id: string) => Promise<unknown>;
364
+ logs: (id: string, query?: {
365
+ cursor?: string;
366
+ }) => Promise<unknown>;
367
+ };
346
368
  setStatus: (id: string, status: import("./native-experiments.js").NativeRunStatus) => Promise<unknown>;
347
369
  };
348
370
  machine: {
@@ -1642,6 +1664,28 @@ export declare function createClient(options: ClientOptions): {
1642
1664
  signal?: AbortSignal;
1643
1665
  }) => Promise<Response>;
1644
1666
  };
1667
+ writers: {
1668
+ list: (query?: {
1669
+ limit?: number;
1670
+ cursor?: string;
1671
+ }) => Promise<unknown>;
1672
+ get: (id: string) => Promise<unknown>;
1673
+ create: (idempotencyKey: string, runId?: string) => Promise<unknown>;
1674
+ rotate: (credentialId: string, expectedGeneration: number) => Promise<unknown>;
1675
+ retire: (credentialId: string, expectedGeneration: number) => Promise<unknown>;
1676
+ };
1677
+ jobs: {
1678
+ submit: (input: import("./execution.js").RunInput) => Promise<unknown>;
1679
+ list: (query?: {
1680
+ limit?: number;
1681
+ cursor?: string;
1682
+ }) => Promise<unknown>;
1683
+ summary: (id: string) => Promise<unknown>;
1684
+ cancel: (id: string) => Promise<unknown>;
1685
+ logs: (id: string, query?: {
1686
+ cursor?: string;
1687
+ }) => Promise<unknown>;
1688
+ };
1645
1689
  setStatus: (id: string, status: import("./native-experiments.js").NativeRunStatus) => Promise<unknown>;
1646
1690
  };
1647
1691
  machine: {
@@ -1,3 +1,4 @@
1
+ import { type FileMultipart } from "./file-multipart.js";
1
2
  import { type Transport } from "./client.js";
2
3
  import { type Query } from "./common.js";
3
4
  export interface NativeExperimentRun {
@@ -94,6 +95,8 @@ export declare function nativeLogQuery(query?: NativeLogQuery): Query;
94
95
  * The multipart body of a file upload. Text fields precede the file part: the server reads
95
96
  * only the fields received before the file, and verifies `sizeBytes` and `checksum` against it.
96
97
  */
98
+ export declare function nativeFileMultipart(upload: NativeFileUpload): Promise<FileMultipart>;
99
+ /** @deprecated Prefer nativeFileMultipart for filenames containing quotes. Kept for source compatibility. */
97
100
  export declare function nativeFileForm(upload: NativeFileUpload): Promise<FormData>;
98
101
  export declare function nativeExperimentsApi(t: Transport, namespace: string, project: string): {
99
102
  status: () => Promise<unknown>;
@@ -284,5 +287,27 @@ export declare function nativeExperimentsApi(t: Transport, namespace: string, pr
284
287
  signal?: AbortSignal;
285
288
  }) => Promise<Response>;
286
289
  };
290
+ writers: {
291
+ list: (query?: {
292
+ limit?: number;
293
+ cursor?: string;
294
+ }) => Promise<unknown>;
295
+ get: (id: string) => Promise<unknown>;
296
+ create: (idempotencyKey: string, runId?: string) => Promise<unknown>;
297
+ rotate: (credentialId: string, expectedGeneration: number) => Promise<unknown>;
298
+ retire: (credentialId: string, expectedGeneration: number) => Promise<unknown>;
299
+ };
300
+ jobs: {
301
+ submit: (input: import("./execution.js").RunInput) => Promise<unknown>;
302
+ list: (query?: {
303
+ limit?: number;
304
+ cursor?: string;
305
+ }) => Promise<unknown>;
306
+ summary: (id: string) => Promise<unknown>;
307
+ cancel: (id: string) => Promise<unknown>;
308
+ logs: (id: string, query?: {
309
+ cursor?: string;
310
+ }) => Promise<unknown>;
311
+ };
287
312
  setStatus: (id: string, status: NativeRunStatus) => Promise<unknown>;
288
313
  };
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { fileMultipart } from "./file-multipart.js";
2
3
  import { namespaceSeg, seg } from "./client.js";
3
4
  import { call } from "./common.js";
4
5
  function trackQuery(q) {
@@ -37,6 +38,27 @@ async function sha256(data) {
37
38
  * The multipart body of a file upload. Text fields precede the file part: the server reads
38
39
  * only the fields received before the file, and verifies `sizeBytes` and `checksum` against it.
39
40
  */
41
+ export async function nativeFileMultipart(upload) {
42
+ const blob = upload.data instanceof Uint8Array
43
+ ? new Blob([upload.data], { type: upload.contentType ?? "application/octet-stream" })
44
+ : upload.data;
45
+ const fields = {
46
+ sizeBytes: String(blob.size), checksum: upload.checksum ?? await sha256(upload.data),
47
+ };
48
+ if (upload.prefix !== undefined)
49
+ fields.prefix = upload.prefix;
50
+ if (upload.description !== undefined)
51
+ fields.description = upload.description;
52
+ if (upload.tags?.length)
53
+ fields.tags = upload.tags.join(",");
54
+ if (upload.metadata !== undefined)
55
+ fields.metadata = JSON.stringify(upload.metadata);
56
+ if (upload.folderId !== undefined)
57
+ fields.folderId = upload.folderId;
58
+ const typed = upload.contentType && blob.type !== upload.contentType ? new Blob([blob], { type: upload.contentType }) : blob;
59
+ return fileMultipart(fields, typed, upload.filename);
60
+ }
61
+ /** @deprecated Prefer nativeFileMultipart for filenames containing quotes. Kept for source compatibility. */
40
62
  export async function nativeFileForm(upload) {
41
63
  const blob = upload.data instanceof Uint8Array
42
64
  ? new Blob([upload.data], { type: upload.contentType ?? "application/octet-stream" })
@@ -61,6 +83,10 @@ export async function nativeFileForm(upload) {
61
83
  export function nativeExperimentsApi(t, namespace, project) {
62
84
  const p = nativeExperimentPaths(namespace, project);
63
85
  const { base, run } = p;
86
+ const sendFile = async (method, path, upload) => {
87
+ const form = await nativeFileMultipart(upload);
88
+ return t.request(method, path, { body: form.body, headers: { "content-type": form.contentType } });
89
+ };
64
90
  return {
65
91
  status: () => call(t, "GET", `${base}/status`),
66
92
  session: (mode) => call(t, "POST", `${base}/session`, { mode }),
@@ -114,7 +140,7 @@ export function nativeExperimentsApi(t, namespace, project) {
114
140
  files: {
115
141
  list: (id, query = {}) => call(t, "GET", p.files(id), undefined, { prefix: query.prefix, tags: query.tags?.join(",") }),
116
142
  get: (id, fileId) => call(t, "GET", p.file(id, fileId)),
117
- upload: async (id, upload) => t.request("POST", p.files(id), { body: await nativeFileForm(upload) }),
143
+ upload: async (id, upload) => sendFile("POST", p.files(id), upload),
118
144
  /** The file's bytes from the central API; redirects are refused, so the bearer never leaves it. */
119
145
  download: (id, fileId, options = {}) => {
120
146
  if (!t.raw)
@@ -129,7 +155,7 @@ export function nativeExperimentsApi(t, namespace, project) {
129
155
  /** Project and folder files (README.md, `.dashrc`): not a run's. `folderId` absent or "root": the project root. */
130
156
  projectFiles: {
131
157
  list: (query = {}) => call(t, "GET", `${base}/project-files`, undefined, query),
132
- upload: async (upload) => t.request("POST", `${base}/project-files`, { body: await nativeFileForm(upload) }),
158
+ upload: async (upload) => sendFile("POST", `${base}/project-files`, upload),
133
159
  get: (fileId) => call(t, "GET", `${base}/project-files/${seg(fileId)}`),
134
160
  /** UTF-8 text, at most 512 KiB (larger: 413, never truncated). */
135
161
  text: (fileId) => call(t, "GET", `${base}/project-files/${seg(fileId)}/text`),
@@ -140,7 +166,7 @@ export function nativeExperimentsApi(t, namespace, project) {
140
166
  },
141
167
  media: (fileId) => call(t, "GET", `${base}/project-files/${seg(fileId)}/media`),
142
168
  /** New bytes for the same file: its id, name and metadata stay. */
143
- replace: async (fileId, upload) => t.request("PUT", `${base}/project-files/${seg(fileId)}/content`, { body: await nativeFileForm(upload) }),
169
+ replace: async (fileId, upload) => sendFile("PUT", `${base}/project-files/${seg(fileId)}/content`, upload),
144
170
  /** description/tags/metadata, and/or `filename` and `folderId` (null: the root) to rename or move. */
145
171
  update: (fileId, patch) => call(t, "PATCH", `${base}/project-files/${seg(fileId)}`, patch),
146
172
  delete: (fileId) => call(t, "DELETE", `${base}/project-files/${seg(fileId)}`),
@@ -171,6 +197,26 @@ export function nativeExperimentsApi(t, namespace, project) {
171
197
  ...(options.signal ? { signal: options.signal, timeoutMs: null } : {}) });
172
198
  },
173
199
  },
200
+ writers: {
201
+ list: (query = {}) => call(t, "GET", `${base}/credentials`, undefined, query),
202
+ get: (id) => call(t, "GET", `${base}/credentials/${seg(id)}`),
203
+ create: (idempotencyKey, runId) => call(t, "POST", `${base}/credentials`, { operation: "create", idempotencyKey, ...(runId ? { runId } : {}) }),
204
+ rotate: (credentialId, expectedGeneration) => call(t, "POST", `${base}/credentials`, { operation: "rotate", credentialId, expectedGeneration }),
205
+ retire: (credentialId, expectedGeneration) => call(t, "POST", `${base}/credentials`, { operation: "retire", credentialId, expectedGeneration }),
206
+ },
207
+ jobs: {
208
+ submit: (input) => call(t, "POST", `${base}/jobs`, input),
209
+ list: (query = {}) => call(t, "GET", `${base}/jobs`, undefined, query),
210
+ summary: (id) => call(t, "GET", `${base}/jobs/${seg(id)}/summary`),
211
+ cancel: async (id) => {
212
+ await call(t, "GET", `${base}/jobs/${seg(id)}/summary`);
213
+ return call(t, "POST", `/namespaces/${namespaceSeg(namespace)}/runs/${seg(id)}/cancel`);
214
+ },
215
+ logs: async (id, query = {}) => {
216
+ await call(t, "GET", `${base}/jobs/${seg(id)}/summary`);
217
+ return call(t, "GET", `/namespaces/${namespaceSeg(namespace)}/runs/${seg(id)}/logs`, undefined, query);
218
+ },
219
+ },
174
220
  setStatus: (id, status) => call(t, "POST", `${run(id)}/status`, { status }),
175
221
  };
176
222
  }
@@ -2,6 +2,8 @@ import { HttpError, requestJson } from "../client.js";
2
2
  import { resolveRemote, resolveToken } from "../config.js";
3
3
  import { emitJson, fail } from "../helpers.js";
4
4
  import { registerNativeExperimentCommands } from "./native-commands.js";
5
+ import { registerExperimentManagementCommands } from "./management.js";
6
+ import { registerExperimentTransferCommands } from "./transfer/index.js";
5
7
  class BindingError extends Error {
6
8
  code;
7
9
  remediation;
@@ -149,6 +151,8 @@ export async function runExperiments(action, opts, selection) {
149
151
  export function registerExperimentsCommand(program) {
150
152
  const command = program.command("experiments").description("discover and explicitly bind an existing managed Dash workspace (JSON receipts)");
151
153
  registerNativeExperimentCommands(command);
154
+ registerExperimentTransferCommands(command);
155
+ registerExperimentManagementCommands(command);
152
156
  for (const action of ["workspaces", "binding", "connect", "disconnect"]) {
153
157
  const sub = command.command(action)
154
158
  .description({ workspaces: "list verified eligible Dash organization workspaces", binding: "inspect the current binding and revision", connect: "preview a workspace binding; --apply commits it", disconnect: "preview detaching; remote experiments and SDK access are retained" }[action])
@@ -0,0 +1,16 @@
1
+ /** Native project writer metadata and compute jobs. All actions use the selected DreamLake login. */
2
+ import type { Command } from 'commander';
3
+ interface Options {
4
+ namespace: string;
5
+ project: string;
6
+ json?: boolean;
7
+ limit?: string;
8
+ cursor?: string;
9
+ runId?: string;
10
+ idempotencyKey?: string;
11
+ expectedGeneration?: string;
12
+ spec?: string;
13
+ }
14
+ export declare function runExperimentManagement(group: 'writers' | 'jobs', action: string, opts: Options, subject?: string): Promise<number>;
15
+ export declare function registerExperimentManagementCommands(parent: Command): void;
16
+ export {};
@@ -0,0 +1,82 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { createTransport, ApiError } from '../../api/client.js';
3
+ import { nativeExperimentsApi } from '../../api/native-experiments.js';
4
+ import { resolveRemote, resolveToken } from '../config.js';
5
+ import { emitJson, fail } from '../helpers.js';
6
+ const id = (v) => { if (!/^[a-f0-9]{24}$/.test(v))
7
+ throw Error('Expected a native run or job ID (24 hex characters).'); return v; };
8
+ const uuid = (v) => { if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(v))
9
+ throw Error('Expected a UUID writer or idempotency key.'); return v.toLowerCase(); };
10
+ export async function runExperimentManagement(group, action, opts, subject) {
11
+ try {
12
+ const token = resolveToken();
13
+ if (!token)
14
+ throw Error('DreamLake login is required; run dl login.');
15
+ const api = nativeExperimentsApi(createTransport({ remote: resolveRemote(), token }), opts.namespace, opts.project);
16
+ let result;
17
+ const query = { ...(opts.limit !== undefined ? { limit: Number(opts.limit) } : {}), ...(opts.cursor !== undefined ? { cursor: opts.cursor } : {}) };
18
+ if (opts.limit !== undefined && (!/^[1-9][0-9]*$/.test(opts.limit) || !Number.isSafeInteger(query.limit) || query.limit > 100))
19
+ throw Error('--limit must be 1-100.');
20
+ if (group === 'writers') {
21
+ if (action === 'list')
22
+ result = await api.writers.list(query);
23
+ else if (action === 'create')
24
+ result = await api.writers.create(uuid(opts.idempotencyKey), opts.runId === undefined ? undefined : id(opts.runId));
25
+ else if (action === 'inspect')
26
+ result = await api.writers.get(uuid(subject));
27
+ else {
28
+ const generation = Number(opts.expectedGeneration);
29
+ if (!/^[1-9][0-9]*$/.test(opts.expectedGeneration ?? '') || !Number.isSafeInteger(generation))
30
+ throw Error('--expected-generation must be the writer generation you inspected.');
31
+ result = await api.writers[action](uuid(subject), generation);
32
+ }
33
+ }
34
+ else {
35
+ if (action === 'submit') {
36
+ const spec = JSON.parse(readFileSync(opts.spec, 'utf8'));
37
+ if (!spec || typeof spec !== 'object' || Array.isArray(spec) || typeof spec.requestId !== 'string' || typeof spec.target !== 'string' || !spec.execution || !spec.source)
38
+ throw Error('--spec must contain requestId, target, execution and explicit source.files.');
39
+ result = await api.jobs.submit(spec);
40
+ }
41
+ else if (action === 'list')
42
+ result = await api.jobs.list(query);
43
+ else if (action === 'logs')
44
+ result = await api.jobs.logs(id(subject), { cursor: opts.cursor });
45
+ else if (action === 'cancel')
46
+ result = await api.jobs.cancel(id(subject));
47
+ else
48
+ result = await api.jobs.summary(id(subject));
49
+ }
50
+ emitJson(result);
51
+ return 0;
52
+ }
53
+ catch (error) {
54
+ const code = error instanceof ApiError ? error.code : 'NATIVE_INVALID_REQUEST';
55
+ const message = error instanceof ApiError ? `Experiment request failed (HTTP ${error.status}); inspect the original operation before retrying.` : error instanceof Error ? error.message : 'Experiment request failed.';
56
+ if (opts.json)
57
+ emitJson({ ok: false, error: { code, message } });
58
+ else
59
+ fail(`${code}: ${message}`);
60
+ return 1;
61
+ }
62
+ }
63
+ export function registerExperimentManagementCommands(parent) {
64
+ const common = (c) => c.requiredOption('--namespace <slug>', 'DreamLake namespace').requiredOption('--project <slug>', 'DreamLake project').option('--json', 'structured errors (success is JSON)');
65
+ for (const group of ['writers', 'jobs']) {
66
+ const root = parent.command(group).description(group === 'writers' ? 'native project writer metadata and session lifecycle' : 'native project compute jobs on configured hosts');
67
+ const act = (action) => (...input) => { const options = input.find(v => v && typeof v === 'object' && !v.commands); return runExperimentManagement(group, action, options, input.find(v => typeof v === 'string')).then(code => { process.exitCode = code; }); };
68
+ common(root.command('list').description(`list project ${group}`)).option('--limit <count>', 'page size, 1-100').option('--cursor <cursor>', 'server nextCursor').action(act('list'));
69
+ if (group === 'writers') {
70
+ common(root.command('create').description('register or recover one writer intent')).requiredOption('--idempotency-key <uuid>', 'stable creation intent UUID').option('--run-id <id>', 'bind to exactly this existing run').action(act('create'));
71
+ common(root.command('inspect <writer-id>').description('inspect one writer')).action(act('inspect'));
72
+ for (const action of ['rotate', 'retire'])
73
+ common(root.command(`${action} <writer-id>`).description(`${action} the inspected writer generation`)).requiredOption('--expected-generation <number>', 'generation from inspect').action(act(action));
74
+ }
75
+ else {
76
+ common(root.command('submit').description('submit an explicit native job manifest')).requiredOption('--spec <path>', 'JSON manifest: requestId, target, enrollmentId?, execution, source, timeoutSeconds?').action(act('submit'));
77
+ common(root.command('show <job-id>').description('show job receipt and native run binding')).action(act('summary'));
78
+ common(root.command('cancel <job-id>').description('request cancellation of a job in this project')).action(act('cancel'));
79
+ common(root.command('logs <job-id>').description('read job output after checking project binding')).option('--cursor <cursor>', 'server output cursor').action(act('logs'));
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,86 @@
1
+ import type { ParsedArgs } from './types.js';
2
+ import type { LocalStorage } from './local/storage.js';
3
+ import type { ExperimentInfo, ExperimentUploadClient } from './upload.js';
4
+ import type { ExperimentDownloadClient, RemoteExperiment } from './download.js';
5
+ import { type Context } from './context.js';
6
+ import { validName } from './transport.js';
7
+ /**
8
+ * Make sure a canonical DreamLake project exists, creating it PRIVATE when it does not, as the old
9
+ * uploader's upsert did. A readable project is used as is; a slug held by a project the caller cannot
10
+ * see is reported, never taken over; a missing namespace is never created. Auth, network and other
11
+ * errors propagate unchanged, so only a real "not found" leads to a create.
12
+ */
13
+ export declare function ensureProject(c: Context, ns: string, project: string, description?: string): Promise<{
14
+ created: boolean;
15
+ project: Record<string, any>;
16
+ }>;
17
+ export { validName };
18
+ /** RemoteClient's upload surface over native REST. Run IDs map to their project route. */
19
+ declare class NativeUploadClient implements ExperimentUploadClient {
20
+ readonly c: Context;
21
+ private readonly bases;
22
+ /** Capabilities per `namespace/project`, read in the preflight (after the project exists). */
23
+ readonly caps: Map<string, string[]>;
24
+ personal: string | null;
25
+ constructor(c: Context);
26
+ private run;
27
+ createOrUpdateExperiment(args: Parameters<ExperimentUploadClient['createOrUpdateExperiment']>[0]): Promise<any>;
28
+ /** `write_protected`: a person's protection, set last (PATCH `writeProtected: true`), after all data was written. */
29
+ protectExperiment(id: string): Promise<void>;
30
+ setParameters(id: string, data: Record<string, unknown>): Promise<any>;
31
+ createLogEntries(id: string, logs: Record<string, unknown>[]): Promise<any>;
32
+ appendBatchToMetric(id: string, name: string, points: unknown[]): Promise<any>;
33
+ uploadFile(args: Parameters<ExperimentUploadClient['uploadFile']>[0]): Promise<any>;
34
+ }
35
+ interface PreflightItem {
36
+ info: ExperimentInfo;
37
+ validation: {
38
+ metadata?: Record<string, any>;
39
+ };
40
+ fullPrefix: string;
41
+ targetProject: string;
42
+ }
43
+ /** The upload pipeline's native target: its client, state identity and pre-write check. */
44
+ export declare function nativeUploadTarget(args: ParsedArgs): {
45
+ client: NativeUploadClient;
46
+ server: string;
47
+ stateIdentity: string;
48
+ preflight: (storage: LocalStorage, items: PreflightItem[], skipLogs: boolean, skipMetrics: boolean) => Promise<string[]>;
49
+ };
50
+ /** RemoteClient's download surface over native REST, for one DreamLake project. */
51
+ declare class NativeDownloadClient implements ExperimentDownloadClient {
52
+ private readonly c;
53
+ private readonly fileRuns;
54
+ private readonly bindrSupport;
55
+ /** The project route of each discovered run: a glob may select runs of several projects. */
56
+ readonly bases: Map<string, string>;
57
+ constructor(c: Context);
58
+ private run;
59
+ getParameters(id: string): Promise<Record<string, unknown>>;
60
+ queryLogs(id: string, opts?: Parameters<ExperimentDownloadClient['queryLogs']>[1]): Promise<any>;
61
+ listMetrics(id: string): Promise<any[]>;
62
+ /** Native metrics have no chunk index: the pipeline reads them by index pages instead. */
63
+ getMetricStats(): Promise<any>;
64
+ downloadMetricChunk(): Promise<any>;
65
+ getMetricData(id: string, name: string, opts?: {
66
+ startIndex?: number;
67
+ limit?: number;
68
+ bufferOnly?: boolean;
69
+ }): Promise<any>;
70
+ /** Native file listing is one response: the first page holds every file. */
71
+ listFiles(id: string, _limit?: number, offset?: number): Promise<any>;
72
+ bindrs(id: string, itemKind?: string, itemId?: string): Promise<string[]>;
73
+ downloadFileStreaming(fileId: string, destPath: string): Promise<string>;
74
+ }
75
+ /** The download pipeline's native source: `-p namespace/project[/folder…|/glob]` (globs anywhere), every page of runs. */
76
+ export declare function nativeDownloadSource(args: ParsedArgs): {
77
+ client: NativeDownloadClient;
78
+ stateIdentity: string;
79
+ discover(experiment?: string): Promise<RemoteExperiment[]>;
80
+ };
81
+ export declare function reportNativeError(e: unknown): number;
82
+ /** `upload --tracks FILE --remote-path ns/project/run/topic --backend native` */
83
+ export declare function uploadTrackNative(args: ParsedArgs): Promise<number>;
84
+ /** `download --tracks ns/project/run/topic [--format F] [-o FILE] --backend native` */
85
+ export declare function downloadTrackNative(args: ParsedArgs): Promise<number>;
86
+ export declare function runNativeTransfer(work: () => Promise<number>): Promise<number>;