@dreamlake/dreamlake-cli 0.99.0 → 0.101.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.
@@ -29,6 +29,8 @@ export declare function hostsApi(t: Transport, namespace: string): {
29
29
  durationSeconds: number;
30
30
  }) => Promise<unknown>;
31
31
  launch: (id: string) => Promise<unknown>;
32
+ movePreview(hostId: string, destinationNamespace: string): Promise<import("./host-moves.js").HostMovePreview>;
33
+ move(hostId: string, request: import("./host-moves.js").HostMoveRequest): Promise<import("./host-moves.js").HostMoveReceipt>;
32
34
  };
33
35
  export declare function serviceAccountsApi(t: Transport, namespace: string): {
34
36
  list: (query?: {
@@ -1,8 +1,10 @@
1
+ import { hostMoveApi } from "./host-moves.js";
1
2
  import { seg } from "./client.js";
2
3
  import { call, namespacePath } from "./common.js";
3
4
  export function hostsApi(t, namespace) {
4
5
  const base = namespacePath(namespace) + "/hosts", p = (id) => base + "/" + seg(id);
5
6
  return {
7
+ ...hostMoveApi(t, namespace),
6
8
  list: (query = {}) => call(t, "GET", base, undefined, query),
7
9
  status: (id) => call(t, "GET", p(id)),
8
10
  enroll: (input) => call(t, "POST", base + "/enrollments", input),
@@ -7,6 +7,9 @@ export type TurnCapabilities = {
7
7
  layoutActions?: 1;
8
8
  sessionControl?: 1;
9
9
  notesWrite?: 1;
10
+ hostMove?: 1;
11
+ toolsWrite?: 1;
12
+ memoryWrite?: 1;
10
13
  };
11
14
  export type AgentEvent = {
12
15
  type: "context";
@@ -64,6 +67,11 @@ export interface ConversationSummary {
64
67
  /** Parse `data: {...}` server-sent events; a frame that is not JSON is dropped, never guessed. */
65
68
  export declare function readAgentEvents(body: ReadableStream<Uint8Array>): AsyncGenerator<AgentEvent>;
66
69
  export declare function agentApi(t: Transport, options: Pick<ClientOptions, "remote" | "token" | "fetch">): {
70
+ namespaceScope: (namespace: string) => Promise<{
71
+ apiVersion: 1;
72
+ namespace: string;
73
+ allowed: true;
74
+ }>;
67
75
  browserActions: (conversationId: string) => Promise<{
68
76
  actions: unknown[];
69
77
  }>;
@@ -79,6 +87,7 @@ export declare function agentApi(t: Transport, options: Pick<ClientOptions, "rem
79
87
  restore: (conversationId: string) => Promise<{
80
88
  sessionId: string;
81
89
  status: string;
90
+ actingNamespace?: string;
82
91
  messages: {
83
92
  role: "user" | "assistant";
84
93
  content: string;
@@ -96,6 +105,7 @@ export declare function agentApi(t: Transport, options: Pick<ClientOptions, "rem
96
105
  chat(input: {
97
106
  message: string;
98
107
  sessionId?: string;
108
+ actingNamespace?: string;
99
109
  capabilities?: TurnCapabilities;
100
110
  page?: {
101
111
  pathname: string;
package/dist/api/agent.js CHANGED
@@ -38,6 +38,14 @@ export async function* readAgentEvents(body) {
38
38
  export function agentApi(t, options) {
39
39
  return {
40
40
  ...projectToolsApi(t),
41
+ namespaceScope: async (namespace) => {
42
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(namespace))
43
+ throw new Error('invalid agent namespace');
44
+ const result = await t.request('GET', '/agent/namespace-scope', { query: { namespace } });
45
+ if (result?.apiVersion !== 1 || result.namespace !== namespace || result.allowed !== true)
46
+ throw new Error('Agent namespace scope could not be verified');
47
+ return result;
48
+ },
41
49
  browserActions: (conversationId) => {
42
50
  if (!isObjectId(conversationId))
43
51
  throw new Error("expected a 24-hex conversation id");
@@ -58,6 +66,8 @@ export function agentApi(t, options) {
58
66
  },
59
67
  /** One turn as a stream of events. `page` is the browser context; a CLI passes a pathname only. */
60
68
  async *chat(input) {
69
+ if (input.actingNamespace !== undefined && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(input.actingNamespace))
70
+ throw new Error('invalid agent namespace');
61
71
  const doFetch = options.fetch ?? fetch;
62
72
  const response = await doFetch(options.remote.replace(/\/+$/, "") + "/agent/chat", {
63
73
  method: "POST",
@@ -71,6 +81,7 @@ export function agentApi(t, options) {
71
81
  body: JSON.stringify({
72
82
  message: input.message,
73
83
  ...(input.sessionId ? { sessionId: input.sessionId } : {}),
84
+ ...(input.actingNamespace !== undefined ? { actingNamespace: input.actingNamespace } : {}),
74
85
  ...(input.capabilities ? { capabilities: input.capabilities } : {}),
75
86
  page: input.page ?? { pathname: "/", layouts: [] },
76
87
  }),
@@ -0,0 +1,34 @@
1
+ import { type Transport } from './client.js';
2
+ export type HostMovePreview = {
3
+ apiVersion: 1;
4
+ hostId: string;
5
+ sourceNamespaceId: string;
6
+ destinationNamespaceId: string;
7
+ destinationNamespace: string;
8
+ name: string;
9
+ ownerUserId: string;
10
+ visibility: 'private';
11
+ revision: number;
12
+ previewHash: string;
13
+ blockers: string[];
14
+ executable: boolean;
15
+ };
16
+ export type HostMoveRequest = {
17
+ destinationNamespace: string;
18
+ requestId: string;
19
+ expectedRevision: number;
20
+ previewHash: string;
21
+ };
22
+ export type HostMoveReceipt = Omit<HostMovePreview, 'previewHash' | 'blockers' | 'executable'> & {
23
+ operationId: string;
24
+ requestId: string;
25
+ recordedAt: string;
26
+ replayed: boolean;
27
+ };
28
+ export declare function validateHostMovePreview(value: unknown, hostId: string, destinationNamespace: string): HostMovePreview;
29
+ export declare function validateHostMoveReceipt(value: unknown, hostId: string, request: HostMoveRequest): HostMoveReceipt;
30
+ export declare function hostMoveApi(t: Transport, namespace: string): {
31
+ movePreview(hostId: string, destinationNamespace: string): Promise<HostMovePreview>;
32
+ /** After uncertainty replay exactly this request; no new key, preview or automatic retry. */
33
+ move(hostId: string, request: HostMoveRequest): Promise<HostMoveReceipt>;
34
+ };
@@ -0,0 +1,48 @@
1
+ import { seg } from './client.js';
2
+ const nonempty = (v) => typeof v === 'string' && v.length > 0 && v.length <= 256 && !/[\x00-\x1f\x7f]/.test(v);
3
+ const invalid = () => { throw new Error('Host move response could not be verified. Keep the same request and reconcile before retrying.'); };
4
+ const base = (namespace, hostId) => {
5
+ if (!nonempty(namespace) || !/^[a-f0-9]{24}$/.test(hostId))
6
+ invalid();
7
+ return `/namespaces/${seg(namespace)}/hosts/${hostId}/move`;
8
+ };
9
+ function common(v, hostId, destinationNamespace) {
10
+ if (!v || v.apiVersion !== 1 || v.hostId !== hostId || v.destinationNamespace !== destinationNamespace ||
11
+ ![v.sourceNamespaceId, v.destinationNamespaceId, v.ownerUserId, v.name].every(nonempty) ||
12
+ v.visibility !== 'private' || !Number.isSafeInteger(v.revision) || v.revision < 0)
13
+ invalid();
14
+ }
15
+ export function validateHostMovePreview(value, hostId, destinationNamespace) {
16
+ const v = value;
17
+ common(v, hostId, destinationNamespace);
18
+ if (!/^[a-f0-9]{64}$/.test(v.previewHash) || !Array.isArray(v.blockers) ||
19
+ v.blockers.some(b => !nonempty(b)) || typeof v.executable !== 'boolean' || v.executable !== (v.blockers.length === 0))
20
+ invalid();
21
+ return v;
22
+ }
23
+ export function validateHostMoveReceipt(value, hostId, request) {
24
+ const v = value;
25
+ common(v, hostId, request.destinationNamespace);
26
+ if (v.requestId !== request.requestId || !nonempty(v.operationId) || v.revision !== request.expectedRevision + 1 ||
27
+ !nonempty(v.recordedAt) || !Number.isFinite(Date.parse(v.recordedAt)) || typeof v.replayed !== 'boolean')
28
+ invalid();
29
+ return v;
30
+ }
31
+ export function hostMoveApi(t, namespace) {
32
+ return {
33
+ async movePreview(hostId, destinationNamespace) {
34
+ if (!nonempty(destinationNamespace) || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(destinationNamespace))
35
+ invalid();
36
+ const result = await t.request('POST', `${base(namespace, hostId)}/preview`, { json: { destinationNamespace } });
37
+ return validateHostMovePreview(result, hostId, destinationNamespace);
38
+ },
39
+ /** After uncertainty replay exactly this request; no new key, preview or automatic retry. */
40
+ async move(hostId, request) {
41
+ if (!request || !nonempty(request.destinationNamespace) || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(request.destinationNamespace) || !nonempty(request.requestId) || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(request.requestId) ||
42
+ !Number.isSafeInteger(request.expectedRevision) || request.expectedRevision < 0 || request.expectedRevision >= 2147483647 || !/^[a-f0-9]{64}$/.test(request.previewHash) ||
43
+ Object.keys(request).some(k => !['destinationNamespace', 'requestId', 'expectedRevision', 'previewHash'].includes(k)))
44
+ invalid();
45
+ return validateHostMoveReceipt(await t.request('POST', base(namespace, hostId), { json: request }), hostId, request);
46
+ },
47
+ };
48
+ }
@@ -374,6 +374,8 @@ export declare function createApi(transport: Transport): {
374
374
  durationSeconds: number;
375
375
  }) => Promise<unknown>;
376
376
  launch: (id: string) => Promise<unknown>;
377
+ movePreview(hostId: string, destinationNamespace: string): Promise<import("./host-moves.js").HostMovePreview>;
378
+ move(hostId: string, request: import("./host-moves.js").HostMoveRequest): Promise<import("./host-moves.js").HostMoveReceipt>;
377
379
  };
378
380
  serviceAccounts: (namespace: string) => {
379
381
  list: (query?: {
@@ -1033,6 +1035,11 @@ export declare function createApi(transport: Transport): {
1033
1035
  export type DreamLakeClient = ReturnType<typeof createClient>;
1034
1036
  export declare function createClient(options: ClientOptions): {
1035
1037
  agent: {
1038
+ namespaceScope: (namespace: string) => Promise<{
1039
+ apiVersion: 1;
1040
+ namespace: string;
1041
+ allowed: true;
1042
+ }>;
1036
1043
  browserActions: (conversationId: string) => Promise<{
1037
1044
  actions: unknown[];
1038
1045
  }>;
@@ -1048,6 +1055,7 @@ export declare function createClient(options: ClientOptions): {
1048
1055
  restore: (conversationId: string) => Promise<{
1049
1056
  sessionId: string;
1050
1057
  status: string;
1058
+ actingNamespace?: string;
1051
1059
  messages: {
1052
1060
  role: "user" | "assistant";
1053
1061
  content: string;
@@ -1064,6 +1072,7 @@ export declare function createClient(options: ClientOptions): {
1064
1072
  chat(input: {
1065
1073
  message: string;
1066
1074
  sessionId?: string;
1075
+ actingNamespace?: string;
1067
1076
  capabilities?: import("./agent.js").TurnCapabilities;
1068
1077
  page?: {
1069
1078
  pathname: string;
@@ -1442,6 +1451,8 @@ export declare function createClient(options: ClientOptions): {
1442
1451
  durationSeconds: number;
1443
1452
  }) => Promise<unknown>;
1444
1453
  launch: (id: string) => Promise<unknown>;
1454
+ movePreview(hostId: string, destinationNamespace: string): Promise<import("./host-moves.js").HostMovePreview>;
1455
+ move(hostId: string, request: import("./host-moves.js").HostMoveRequest): Promise<import("./host-moves.js").HostMoveReceipt>;
1445
1456
  };
1446
1457
  serviceAccounts: (namespace: string) => {
1447
1458
  list: (query?: {
@@ -2111,3 +2122,4 @@ export { documentEdits, documentInsertion } from "./note-edits.js";
2111
2122
  export * from "./note-facade.js";
2112
2123
  export type { NoteReadingOptions, NoteReadingPage, NoteFocusedRead } from "./note-reading.js";
2113
2124
  export { lineRange, focusedRead, InvalidLineRange } from "./note-reading.js";
2125
+ export type { HostMovePreview, HostMoveRequest, HostMoveReceipt } from "./host-moves.js";
@@ -11,6 +11,8 @@ export declare function detectKind(file: string, override?: string): string | nu
11
11
  export interface ArtifactPushArgs extends DreamlakeOpts {
12
12
  file: string;
13
13
  entry?: string;
14
+ site?: boolean;
15
+ spa?: boolean;
14
16
  title?: string;
15
17
  kind?: string;
16
18
  artifactId?: string;
@@ -11,6 +11,7 @@ import { readFileSync, statSync } from "node:fs";
11
11
  import path from "node:path";
12
12
  import { uploadIncremental, MAX_SIZE } from "./incremental.js";
13
13
  import { packPages } from "./pages.js";
14
+ import { collectSite, uploadSite } from "./site.js";
14
15
  import { metaError, putArtifactCover, readCoverFile, registerArtifactMetaCommand } from "./meta.js";
15
16
  // ../prompt.js, NOT @inquirer/prompts directly. This file used to import the
16
17
  // inquirer prompt straight, which bypassed prompt.ts's `!process.stdin.isTTY`
@@ -86,10 +87,15 @@ function shellQuote(value) {
86
87
  export async function runDreamlakeArtifactPush(args, deps = {}) {
87
88
  const incremental = !args.full && args.incremental !== false;
88
89
  let content;
90
+ let site;
89
91
  let directory = false;
90
92
  try {
91
93
  const stat = statSync(args.file);
92
94
  directory = stat.isDirectory();
95
+ if (args.site && !directory)
96
+ throw new Error('--site requires a built static directory');
97
+ if (args.spa && !args.site)
98
+ throw new Error('--spa requires --site');
93
99
  if (!directory && !stat.isFile())
94
100
  throw new Error("not a file or directory");
95
101
  if (!directory && args.entry !== undefined)
@@ -100,7 +106,8 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
100
106
  fail("incremental artifacts are limited to 512 MiB");
101
107
  return 1;
102
108
  }
103
- content = directory ? packPages(args.file, args.entry) : readFileSync(args.file);
109
+ site = args.site ? collectSite(args.file, args.entry, args.spa) : undefined;
110
+ content = site ? site.content : directory ? packPages(args.file, args.entry) : readFileSync(args.file);
104
111
  }
105
112
  catch (error) {
106
113
  const missing = error.code === 'ENOENT';
@@ -141,6 +148,13 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
141
148
  const namespace = await requireNamespace(ctx, args.namespace);
142
149
  if (!namespace)
143
150
  return 1;
151
+ if (site) {
152
+ const capability = await jsonRequest('GET', `${ctx.remote}/artifacts/site-capabilities`, token);
153
+ if (capability.status !== 200 || capability.body?.schema !== 'dreamlake-artifact-files/1') {
154
+ fail('Static artifact hosting is unavailable on this server; no files were uploaded.');
155
+ return 1;
156
+ }
157
+ }
144
158
  // A title the user set once must survive every later push. Without
145
159
  // --title, ask the catalog first: an existing row keeps its title (the
146
160
  // registration below then carries none), a new one gets the file stem.
@@ -195,10 +209,14 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
195
209
  process.stdout.write(`Uploading ${path.basename(args.file)} (${kind})\n`);
196
210
  process.stdout.write(` namespace: ${namespace}\n`);
197
211
  process.stdout.write(` artifact: ${artifactId} v${version}\n`);
198
- process.stdout.write(` size: ${content.length} bytes\n`);
212
+ process.stdout.write(` size: ${site?.bytes ?? content.length} bytes\n`);
199
213
  try {
200
214
  let storedContent = content;
201
- if (incremental) {
215
+ if (site) {
216
+ const result = await uploadSite(site, backend);
217
+ process.stdout.write(` site: ${site.manifest.files.length} files, ${result.uploadedFiles} new files, ${result.uploadedBytes} bytes uploaded\n`);
218
+ }
219
+ else if (incremental) {
202
220
  const result = await uploadIncremental(content, backend);
203
221
  storedContent = result.content;
204
222
  process.stdout.write(` incremental: ${result.uploadedChunks} new chunks, ${result.uploadedBytes} compressed bytes uploaded, ${result.reusedBytes} source bytes reused\n`);
@@ -374,6 +392,8 @@ export function registerArtifactCommand(program) {
374
392
  .description("push a renderable artifact — a new version of --id (written straight to storage)")
375
393
  .argument("<file>", "file or self-contained HTML page directory to push")
376
394
  .option("--entry <path>", "entry page for a directory (default: index.html)")
395
+ .option("--site", "upload a static build with files loaded on demand (requires site hosting)")
396
+ .option("--spa", "serve the site entry for extensionless client routes (requires --site)")
377
397
  .option("--title <title>", "human title (default: file stem)")
378
398
  .option("--kind <kind>", "html, react, markdown, svg, code, mermaid (default: auto)")
379
399
  .option("--id <artifact-id>", "stable artifact id for versioning (default: slug of title)")
@@ -0,0 +1,16 @@
1
+ import { type DreamdbBackend, type UploadFile } from '../compat/s3-backend.js';
2
+ import { type SiteManifest } from './siteFormat.js';
3
+ /** Snapshot the manifest before any network writes; retain file metadata, not media buffers. */
4
+ export declare function collectSite(directory: string, entry?: string, spa?: boolean): {
5
+ manifest: SiteManifest;
6
+ objects: Map<string, UploadFile>;
7
+ json: Buffer<ArrayBuffer>;
8
+ hash: string;
9
+ content: Buffer<ArrayBuffer>;
10
+ bytes: number;
11
+ };
12
+ /** Conditional immutable writes; publish the manifest only after every file exists. */
13
+ export declare function uploadSite(site: ReturnType<typeof collectSite>, backend: DreamdbBackend): Promise<{
14
+ uploadedBytes: number;
15
+ uploadedFiles: number;
16
+ }>;
@@ -0,0 +1,125 @@
1
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readdirSync, readSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createHash } from 'node:crypto';
4
+ import { S3_SINGLE_PUT_MAX_BYTES } from '../compat/s3-backend.js';
5
+ import { encodeSiteDescriptor, SITE_MAX_FILES, SITE_MANIFEST_MAX_BYTES, siteFileKey, siteManifestKey, validSitePath, validateSiteManifest } from './siteFormat.js';
6
+ const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
7
+ /** Hash with bounded memory; a signed upload rejects source changes before publication. */
8
+ function inspectFile(file, html) {
9
+ const fd = openSync(file, constants.O_RDONLY | constants.O_NOFOLLOW);
10
+ try {
11
+ const before = fstatSync(fd);
12
+ if (!before.isFile() || !Number.isSafeInteger(before.size) || before.size > S3_SINGLE_PUT_MAX_BYTES)
13
+ throw new Error('A site file exceeds the 5 GiB single-PUT transport limit');
14
+ if (html && before.size > 32 * 1024 * 1024)
15
+ throw new Error('A site HTML page exceeds 32 MiB; move large assets into separate files');
16
+ const hash = createHash('sha256'), buffer = Buffer.allocUnsafe(1024 * 1024);
17
+ const decoder = html ? new TextDecoder('utf-8', { fatal: true }) : undefined;
18
+ let size = 0, count;
19
+ while ((count = readSync(fd, buffer, 0, buffer.length, null)) > 0) {
20
+ size += count;
21
+ if (size > before.size)
22
+ throw new Error('Site file changed while hashing; retry the push');
23
+ hash.update(buffer.subarray(0, count));
24
+ decoder?.decode(buffer.subarray(0, count), { stream: true });
25
+ }
26
+ decoder?.decode();
27
+ const after = fstatSync(fd);
28
+ if (size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs)
29
+ throw new Error('Site file changed while hashing; retry the push');
30
+ return { path: file, size, sha256: hash.digest('hex'), mtimeMs: after.mtimeMs, ctimeMs: after.ctimeMs,
31
+ dev: after.dev, ino: after.ino };
32
+ }
33
+ finally {
34
+ closeSync(fd);
35
+ }
36
+ }
37
+ /** Snapshot the manifest before any network writes; retain file metadata, not media buffers. */
38
+ export function collectSite(directory, entry = 'index.html', spa = false) {
39
+ if (!lstatSync(directory).isDirectory())
40
+ throw new Error('Site must be a directory, not a symlink');
41
+ const manifest = { schema: 'dreamlake-artifact-files/1', entry, spa, files: [] };
42
+ const objects = new Map();
43
+ let bytes = 0;
44
+ let visited = 0;
45
+ function walk(relative, depth) {
46
+ if (depth > 32)
47
+ throw new Error('Artifact site nesting exceeds 32 directories');
48
+ for (const name of readdirSync(path.join(directory, relative)).sort()) {
49
+ if (++visited > SITE_MAX_FILES * 2)
50
+ throw new Error('Too many site directory entries');
51
+ const file = path.join(directory, relative, name);
52
+ const stat = lstatSync(file);
53
+ if (stat.isSymbolicLink())
54
+ throw new Error(`Symlinks are not supported: ${file}`);
55
+ if (name.startsWith('.'))
56
+ continue;
57
+ const local = relative ? `${relative}/${name}` : name;
58
+ if (!validSitePath(local))
59
+ throw new Error(`Invalid artifact path: ${local}`);
60
+ if (stat.isDirectory()) {
61
+ walk(local, depth + 1);
62
+ continue;
63
+ }
64
+ if (!stat.isFile())
65
+ throw new Error(`Not a regular file: ${local}`);
66
+ if (manifest.files.length >= SITE_MAX_FILES)
67
+ throw new Error('Artifact site exceeds 4096 files');
68
+ const data = inspectFile(file, /\.html?$/i.test(local));
69
+ bytes += data.size;
70
+ if (!Number.isSafeInteger(bytes))
71
+ throw new Error('Artifact site size exceeds safe integer accounting');
72
+ objects.set(data.sha256, data);
73
+ manifest.files.push({ path: local, sha256: data.sha256, size: data.size });
74
+ }
75
+ }
76
+ walk('', 0);
77
+ validateSiteManifest(manifest);
78
+ const json = Buffer.from(JSON.stringify(manifest));
79
+ if (json.length > SITE_MANIFEST_MAX_BYTES)
80
+ throw new Error('Artifact manifest exceeds 2 MiB');
81
+ const hash = sha(json);
82
+ return { manifest, objects, json, hash, content: Buffer.from(encodeSiteDescriptor(hash)), bytes };
83
+ }
84
+ /** Conditional immutable writes; publish the manifest only after every file exists. */
85
+ export async function uploadSite(site, backend) {
86
+ if (!backend.putFile)
87
+ throw new Error('Artifact site uploads require a streaming file backend');
88
+ let uploadedBytes = 0;
89
+ let uploadedFiles = 0;
90
+ let next = 0;
91
+ const entries = [...site.objects];
92
+ let failure;
93
+ async function put(key, bytes) {
94
+ if ((await backend.head(key)).exists)
95
+ return false;
96
+ const result = await backend.put(key, bytes, { ifNoneMatchStar: true });
97
+ if (result.status !== 'created' && !(await backend.head(key)).exists)
98
+ throw new Error('Artifact file upload conflict; retry the push');
99
+ return result.status === 'created';
100
+ }
101
+ await Promise.all(Array.from({ length: Math.min(8, entries.length) }, async () => {
102
+ while (next < entries.length && !failure) {
103
+ const [hash, data] = entries[next++];
104
+ try {
105
+ const key = siteFileKey(hash);
106
+ if ((await backend.head(key)).exists)
107
+ continue;
108
+ const result = await backend.putFile(key, data, { ifNoneMatchStar: true });
109
+ if (result.status !== 'created' && !(await backend.head(key)).exists)
110
+ throw new Error('Artifact file upload conflict; retry the push');
111
+ if (result.status === 'created') {
112
+ uploadedBytes += data.size;
113
+ uploadedFiles++;
114
+ }
115
+ }
116
+ catch (error) {
117
+ failure = error;
118
+ }
119
+ }
120
+ }));
121
+ if (failure)
122
+ throw failure;
123
+ await put(siteManifestKey(site.hash), site.json);
124
+ return { uploadedBytes, uploadedFiles };
125
+ }
@@ -0,0 +1,25 @@
1
+ export declare const SITE_PREFIX = "<!--DREAMLAKE-ARTIFACT-FILES/1-->\n<script type=\"application/json\" id=\"dreamlake-artifact-files\">";
2
+ export declare const SITE_SUFFIX = "</script>\n<p>This artifact requires a viewer with static-site support.</p>";
3
+ export declare const SITE_MAX_FILES = 4096;
4
+ export declare const SITE_MANIFEST_MAX_BYTES: number;
5
+ export interface SiteFile {
6
+ path: string;
7
+ sha256: string;
8
+ size: number;
9
+ }
10
+ export interface SiteManifest {
11
+ schema: 'dreamlake-artifact-files/1';
12
+ entry: string;
13
+ spa: boolean;
14
+ files: SiteFile[];
15
+ }
16
+ export interface SiteDescriptor {
17
+ manifest: string;
18
+ }
19
+ export declare const isHash: (s: unknown) => s is string;
20
+ export declare function validSitePath(s: unknown): s is string;
21
+ export declare function validateSiteManifest(value: unknown): SiteManifest;
22
+ export declare function encodeSiteDescriptor(manifest: string): string;
23
+ export declare function decodeSiteDescriptor(content: string): SiteDescriptor | null;
24
+ export declare const siteManifestKey: (hash: string) => string;
25
+ export declare const siteFileKey: (hash: string) => string;
@@ -0,0 +1,53 @@
1
+ // Wire contract shared with dreamlake-server/src/services/artifactSiteFormat.ts
2
+ // and dreamlake-ai/frame/siteFormat.ts. Never change v1 in place.
3
+ export const SITE_PREFIX = '<!--DREAMLAKE-ARTIFACT-FILES/1-->\n<script type="application/json" id="dreamlake-artifact-files">';
4
+ export const SITE_SUFFIX = '</script>\n<p>This artifact requires a viewer with static-site support.</p>';
5
+ export const SITE_MAX_FILES = 4096;
6
+ export const SITE_MANIFEST_MAX_BYTES = 2 * 1024 * 1024;
7
+ export const isHash = (s) => typeof s === 'string' && /^[a-f0-9]{64}$/.test(s);
8
+ export function validSitePath(s) {
9
+ return typeof s === 'string' && s.length > 0 && s.length <= 512 && s === s.normalize('NFC') &&
10
+ !/[\\%?#:\u0000-\u0020\u007f]/.test(s) &&
11
+ !s.startsWith('_dreamlake/') && s !== '_dreamlake' &&
12
+ s.split('/').every(p => !!p && !p.startsWith('.'));
13
+ }
14
+ export function validateSiteManifest(value) {
15
+ const m = value;
16
+ if (!m || m.schema !== 'dreamlake-artifact-files/1' || !validSitePath(m.entry) ||
17
+ !/\.html?$/i.test(m.entry) || typeof m.spa !== 'boolean' || !Array.isArray(m.files) ||
18
+ !m.files.length || m.files.length > SITE_MAX_FILES)
19
+ throw new Error('Invalid artifact site manifest');
20
+ const paths = new Set();
21
+ let total = 0;
22
+ for (const f of m.files) {
23
+ if (!f || !validSitePath(f.path) || !isHash(f.sha256) || !Number.isSafeInteger(f.size) || f.size < 0 ||
24
+ paths.has(f.path.toLowerCase()))
25
+ throw new Error('Invalid or duplicate artifact file');
26
+ paths.add(f.path.toLowerCase());
27
+ total += f.size;
28
+ if (!Number.isSafeInteger(total))
29
+ throw new Error('Artifact site size exceeds safe integer accounting');
30
+ if (/\.html?$/i.test(f.path) && f.size > 32 * 1024 * 1024)
31
+ throw new Error('A site HTML page exceeds 32 MiB; move large assets into separate files');
32
+ }
33
+ if (!m.files.some(f => f.path === m.entry))
34
+ throw new Error('Artifact entry page is missing');
35
+ return m;
36
+ }
37
+ export function encodeSiteDescriptor(manifest) {
38
+ if (!isHash(manifest))
39
+ throw new Error('Invalid artifact manifest hash');
40
+ return SITE_PREFIX + JSON.stringify({ manifest }) + SITE_SUFFIX;
41
+ }
42
+ export function decodeSiteDescriptor(content) {
43
+ if (!content.startsWith('<!--DREAMLAKE-ARTIFACT-FILES/'))
44
+ return null;
45
+ if (!content.startsWith(SITE_PREFIX) || !content.endsWith(SITE_SUFFIX) || content.length > 4096)
46
+ throw new Error('Unsupported artifact site format');
47
+ const value = JSON.parse(content.slice(SITE_PREFIX.length, -SITE_SUFFIX.length));
48
+ if (!isHash(value?.manifest))
49
+ throw new Error('Invalid artifact manifest hash');
50
+ return { manifest: value.manifest };
51
+ }
52
+ export const siteManifestKey = (hash) => `artifact-files/v1/manifests/${hash}.json`;
53
+ export const siteFileKey = (hash) => `artifact-files/v1/objects/${hash}`;
@@ -1,3 +1,13 @@
1
+ export declare const S3_SINGLE_PUT_MAX_BYTES: number;
2
+ export interface UploadFile {
3
+ path: string;
4
+ size: number;
5
+ sha256: string;
6
+ mtimeMs: number;
7
+ ctimeMs: number;
8
+ dev: number;
9
+ ino: number;
10
+ }
1
11
  /** Result of a conditional PUT, as DreamDB's connector expects it. */
2
12
  export type PutStatus = "created" | "exists" | "casFailed";
3
13
  /**
@@ -25,6 +35,12 @@ export interface DreamdbBackend {
25
35
  status: PutStatus;
26
36
  etag?: string;
27
37
  }>;
38
+ putFile?(key: string, file: UploadFile, opts?: {
39
+ ifNoneMatchStar?: boolean;
40
+ }): Promise<{
41
+ status: PutStatus;
42
+ etag?: string;
43
+ }>;
28
44
  list(prefix: string): Promise<string[]>;
29
45
  }
30
46
  export interface S3Credentials {
@@ -68,6 +84,16 @@ export declare class S3Backend {
68
84
  status: PutStatus;
69
85
  etag?: string;
70
86
  }>;
87
+ /** Stream a pre-hashed file, binding its expected bytes into the S3 signature/checksum. */
88
+ putFile(key: string, file: UploadFile, opts?: {
89
+ ifNoneMatchStar?: boolean;
90
+ }): Promise<{
91
+ status: "exists" | "casFailed";
92
+ etag?: undefined;
93
+ } | {
94
+ status: "created";
95
+ etag: string | undefined;
96
+ }>;
71
97
  /** Keys under `prefix`, relative to the dataset base (ListObjectsV2). */
72
98
  list(prefix: string): Promise<string[]>;
73
99
  }
@@ -13,6 +13,11 @@
13
13
  // (POST .../upload-credentials) and are short-lived and prefix-scoped, so
14
14
  // they never touch disk.
15
15
  import { AwsClient } from "aws4fetch";
16
+ import { constants } from "node:fs";
17
+ import { open } from "node:fs/promises";
18
+ import { Readable } from "node:stream";
19
+ // S3's single PutObject ceiling; larger individual objects require multipart.
20
+ export const S3_SINGLE_PUT_MAX_BYTES = 5 * 1024 * 1024 * 1024;
16
21
  /**
17
22
  * S3 ETags come back quoted (`"abc123"`), but DreamDB hands them straight
18
23
  * back as `ifMatch` unquoted. Comparing the two raw forms makes every
@@ -99,6 +104,46 @@ export class S3Backend {
99
104
  }
100
105
  return { status: "created", etag: unquote(res.headers.get("etag")) };
101
106
  }
107
+ /** Stream a pre-hashed file, binding its expected bytes into the S3 signature/checksum. */
108
+ async putFile(key, file, opts = {}) {
109
+ if (!Number.isSafeInteger(file.size) || file.size < 0 || file.size > S3_SINGLE_PUT_MAX_BYTES ||
110
+ !/^[a-f0-9]{64}$/.test(file.sha256))
111
+ throw new Error('Invalid streaming S3 file');
112
+ const handle = await open(file.path, constants.O_RDONLY | constants.O_NOFOLLOW);
113
+ let source;
114
+ try {
115
+ const stat = await handle.stat();
116
+ if (!stat.isFile() || stat.size !== file.size || stat.dev !== file.dev || stat.ino !== file.ino ||
117
+ stat.mtimeMs !== file.mtimeMs || stat.ctimeMs !== file.ctimeMs)
118
+ throw new Error('Site file changed after hashing; retry the push');
119
+ const headers = {
120
+ 'Content-Length': String(file.size),
121
+ 'X-Amz-Content-Sha256': file.sha256,
122
+ 'X-Amz-Checksum-Sha256': Buffer.from(file.sha256, 'hex').toString('base64'),
123
+ };
124
+ if (opts.ifNoneMatchStar)
125
+ headers['If-None-Match'] = '*';
126
+ source = file.size ? handle.createReadStream({ autoClose: false, highWaterMark: 256 * 1024 }) : undefined;
127
+ const request = await this.client.sign(this.url(key), {
128
+ method: 'PUT', headers,
129
+ body: source ? Readable.toWeb(source, {
130
+ strategy: { highWaterMark: 256 * 1024, size: chunk => chunk.byteLength },
131
+ }) : new Uint8Array(),
132
+ duplex: 'half',
133
+ });
134
+ // A consumed stream cannot be retried by aws4fetch; a failed push can safely reuse completed objects.
135
+ const res = await fetch(request);
136
+ if (res.status === 412 || res.status === 409)
137
+ return { status: opts.ifNoneMatchStar ? 'exists' : 'casFailed' };
138
+ if (!res.ok)
139
+ throw new Error(`PUT ${key} → ${res.status} ${await res.text().catch(() => '')}`.slice(0, 300));
140
+ return { status: 'created', etag: unquote(res.headers.get('etag')) };
141
+ }
142
+ finally {
143
+ source?.destroy();
144
+ await handle.close();
145
+ }
146
+ }
102
147
  /** Keys under `prefix`, relative to the dataset base (ListObjectsV2). */
103
148
  async list(prefix) {
104
149
  // The bucket root is one level above the dataset prefix in a path-style
@@ -4,7 +4,7 @@ export const helpExamples = {
4
4
  "agents show": "dreamlake agents show my_repo.tri --namespace my-workspace",
5
5
  "agents edit": "dreamlake agents edit my_repo.tri --namespace my-workspace\n# Browser form: follow the localhost URL printed by the command.\ndreamlake agents edit my_repo.tri --namespace my-workspace --web",
6
6
  "telemetry": "dreamlake telemetry disable --quiet\ndreamlake telemetry status\ndreamlake telemetry enable --quiet",
7
- "artifact push": "dreamlake artifact push ./dashboard.html --id q1-dashboard\n# Edit the file, then repeat the same command to upload only new chunks.\n\n# Compatibility with older self-hosted viewers:\ndreamlake artifact push ./dashboard.html --id q1-dashboard --full\n\n# Multiple self-contained HTML pages (requires an updated viewer):\ndreamlake artifact push ./report --entry index.html --id quarterly-report",
7
+ "artifact push": "dreamlake artifact push ./dashboard.html --id q1-dashboard\n# Edit the file, then repeat the same command to upload only new chunks.\n\n# Static build with on-demand assets (CLI 0.101.0+; requires site hosting):\ndreamlake artifact push ./dist/client --site --id simulation\n\n# Compatibility with older self-hosted viewers:\ndreamlake artifact push ./dashboard.html --id q1-dashboard --full\n\n# Multiple self-contained HTML pages (requires an updated viewer):\ndreamlake artifact push ./report --entry index.html --id quarterly-report",
8
8
  "artifact meta set": "# At push time:\ndreamlake artifact push ./report.html --id q1-dashboard \\\n --description \"Revenue, churn and pipeline for the quarter\" \\\n --cover ./cover.png\n\n# Or after the fact, for an artifact that already exists:\ndreamlake artifact meta set q1-dashboard --description \"Revenue, churn and pipeline\"\ndreamlake artifact meta set q1-dashboard --cover ./cover.png\ndreamlake artifact meta show q1-dashboard\n\n# Back to the automatic description / the generated cover:\ndreamlake artifact meta set q1-dashboard --clear-description --clear-cover",
9
9
  "artifact share": "# Find the dashboard you already uploaded; no new version is needed.\ndreamlake artifact list\nARTIFACT=\"q1-dashboard\" # Replace with the id from list.\ndreamlake artifact share get \"$ARTIFACT\"\n\n# Give signed-in recipients read access, then verify the returned link.\ndreamlake artifact share create \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"\n\n# When link access is no longer needed, revoke it and verify.\ndreamlake artifact share revoke \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"",
10
10
  "artifact visibility": "ARTIFACT=\"q1-dashboard\" # Your existing artifact id.\ndreamlake artifact visibility \"$ARTIFACT\" public\ndreamlake artifact visibility \"$ARTIFACT\" private",
@@ -53,6 +53,7 @@ export const helpExamples = {
53
53
  "hosts exec": "dreamlake hosts exec geyang/dev/worker -- python3 -c 'print(\"hello\")'",
54
54
  "hosts upgrade": "dreamlake hosts upgrade geyang/dev/worker --nymph-version 0.1.32 --dry-run\ndreamlake hosts upgrade geyang/dev/worker --nymph-version 0.1.32\ndreamlake hosts upgrade 'geyang/lab/*' --nymph-version 0.1.32 --concurrency 4 --max-failures 2\ndreamlake hosts upgrade --all --namespace geyang --nymph-version 0.1.32 --json",
55
55
  "hosts rollback": "dreamlake hosts rollback geyang/dev/worker\ndreamlake hosts rollback geyang/dev/worker --upgrade-id 20261029-001 --json",
56
+ "hosts move": "dreamlake hosts move HOST_ID --namespace alice --to acme --dry-run --json",
56
57
  "infra list": "dreamlake infra list --namespace fortyfive --project dreamlake-infra --json",
57
58
  "infra status": "dreamlake infra status da8e49cf-1b37-446f-9494-9620faf3192d --json",
58
59
  "infra connect": "dreamlake infra connect da8e49cf-1b37-446f-9494-9620faf3192d",
@@ -1,5 +1,6 @@
1
1
  import { resolveRemote, resolveToken } from "../config.js";
2
2
  const SAFE_POWER_CODES = new Set([
3
+ "host_move_blocked", "move_preview_conflict", "catalog_revision_conflict", "move_conflict", "move_busy", "enrollment_moved", "connection_access_denied",
3
4
  "host_power_unsupported", "provider_binding_ambiguous", "enrollment_not_provider_bound",
4
5
  "provider_binding_revoked", "enrollment_revoked", "active_work_present", "request_id_conflict",
5
6
  "invalid_power_request", "invalid_request_id", "volume_disposition_required", "host_lifecycle_unavailable",
@@ -1,3 +1,4 @@
1
+ import { registerHostMoveCommand } from './move.js';
1
2
  import { collectionList } from "../collection-list.js";
2
3
  import { inspectHostCatalog, changeHostCatalog, formatHostCatalog } from "./catalog.js";
3
4
  import { registerHostLifecycleCommands } from "./lifecycle.js";
@@ -276,6 +277,7 @@ export function registerHostsCommand(program) {
276
277
  }
277
278
  });
278
279
  registerHostSshCommands(group, program);
280
+ registerHostMoveCommand(group);
279
281
  registerHostLifecycleCommands(group);
280
282
  registerHostUpgradeCommands(group);
281
283
  }
@@ -9,6 +9,9 @@ export interface HostEnrollmentStatus {
9
9
  lastSeenAt?: string | null;
10
10
  }
11
11
  export interface HostSummary {
12
+ namespaceId?: string;
13
+ ownerUserId?: string;
14
+ visibility?: "private";
12
15
  id: string;
13
16
  name: string;
14
17
  enrollments?: HostEnrollmentStatus[];
@@ -33,8 +36,36 @@ export declare function listHosts(opts: {
33
36
  }, request?: typeof hostRequest): Promise<HostInventory>;
34
37
  /** A stored state without a verified runtime observation is not availability. */
35
38
  export declare function hostConnection(enrollments?: HostEnrollmentStatus[]): string;
39
+ export declare function cell(value: unknown): string;
40
+ /** Column widths come from the plain text; `decorate` runs after padding so escape codes never shift columns. */
41
+ export declare function table(rows: string[][], decorate?: (value: string, row: number, column: number) => string): string;
36
42
  export declare function formatHostsList(result: HostInventory, all?: boolean): string;
37
43
  export declare function formatHostStatus(result: {
38
44
  host: HostSummary;
39
45
  enrollments?: HostEnrollmentStatus[];
40
46
  }): string;
47
+ /**
48
+ * Bold and underline every case-insensitive occurrence; the surrounding text keeps the terminal's own
49
+ * colors. `reset` ends each highlight; a caller drawing inside another attribute passes `\x1b[22;24m`.
50
+ */
51
+ export declare function highlightMatches(value: string, keyword: string, reset?: string): string;
52
+ export interface HostMatches {
53
+ keyword: string;
54
+ hosts: HostSummary[];
55
+ }
56
+ /**
57
+ * Hosts whose ID or name contains the keyword, case-insensitively, best match first. A
58
+ * `namespace/group/host` selector that matches nothing as a whole falls back to its last segment.
59
+ */
60
+ export declare function matchHosts(hosts: HostSummary[], selector: string): HostMatches;
61
+ /**
62
+ * Shell-style completion of a typed host toward `name`: the next `/`-terminated prefix of `name` that
63
+ * is longer than `query` and still contains it (case-insensitively), or the whole name when none does.
64
+ * `bos14` → `team/bos14/` → `team/bos14/bos14-ctrl`; `te` → `team/` → `team/bos14/` → ….
65
+ */
66
+ export declare function completeHostSegment(query: string, name: string): string;
67
+ export declare const HOST_MATCH_LIMIT = 20;
68
+ /** The `hosts list` columns for a set of hosts: header row first. */
69
+ export declare function hostRows(hosts: HostSummary[]): string[][];
70
+ /** The `hosts list` table restricted to keyword matches, for a terminal reader; `color` adds the highlight. */
71
+ export declare function formatHostMatches(result: HostInventory, matches: HostMatches, color: boolean, command?: string, limit?: number): string;
@@ -61,12 +61,13 @@ export function hostConnection(enrollments = []) {
61
61
  return "unknown";
62
62
  return enrollments.every(e => e.state === "offline") ? "offline" : "unknown";
63
63
  }
64
- function cell(value) {
64
+ export function cell(value) {
65
65
  return typeof value === "string" && value ? value.replace(/[\x00-\x1f\x7f-\x9f]/g, " ") : "unknown";
66
66
  }
67
- function table(rows) {
67
+ /** Column widths come from the plain text; `decorate` runs after padding so escape codes never shift columns. */
68
+ export function table(rows, decorate = value => value) {
68
69
  const widths = rows[0].map((_, i) => rows.reduce((width, row) => Math.max(width, row[i].length), 0));
69
- return rows.map(row => row.map((value, i) => i === row.length - 1 ? value : value.padEnd(widths[i])).join(" ")).join("\n");
70
+ return rows.map((row, r) => row.map((value, i) => decorate(i === row.length - 1 ? value : value.padEnd(widths[i]), r, i)).join(" ")).join("\n");
70
71
  }
71
72
  export function formatHostsList(result, all = false) {
72
73
  const rows = [["ID", "NAME", "CATALOG", "CONNECTION"], ...result.hosts.map(host => [cell(host.id), cell(host.name), cell(host.catalog?.catalogState), hostConnection(host.enrollments)])];
@@ -89,3 +90,67 @@ export function formatHostStatus(result) {
89
90
  lines.push("No enrollments.");
90
91
  return lines.join("\n");
91
92
  }
93
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
94
+ /**
95
+ * Bold and underline every case-insensitive occurrence; the surrounding text keeps the terminal's own
96
+ * colors. `reset` ends each highlight; a caller drawing inside another attribute passes `\x1b[22;24m`.
97
+ */
98
+ export function highlightMatches(value, keyword, reset = "\x1b[0m") {
99
+ if (!keyword)
100
+ return value;
101
+ return value.replace(new RegExp(escapeRegExp(keyword), "gi"), match => `\x1b[1;4m${match}${reset}`);
102
+ }
103
+ /** Exact name or host segment first, then names or host segments the keyword starts, then containing names, then IDs; inventory order within each. */
104
+ function matchRank(host, needle) {
105
+ const name = host.name.toLowerCase(), last = name.split("/").at(-1);
106
+ return name === needle || last === needle ? 0 : name.startsWith(needle) || last.startsWith(needle) ? 1 : name.includes(needle) ? 2 : 3;
107
+ }
108
+ /**
109
+ * Hosts whose ID or name contains the keyword, case-insensitively, best match first. A
110
+ * `namespace/group/host` selector that matches nothing as a whole falls back to its last segment.
111
+ */
112
+ export function matchHosts(hosts, selector) {
113
+ const keywords = [...new Set([selector, selector.split("/").filter(Boolean).at(-1) ?? ""].filter(Boolean))];
114
+ for (const keyword of keywords) {
115
+ const needle = keyword.toLowerCase();
116
+ const matched = hosts.filter(host => host.id.toLowerCase().includes(needle) || host.name.toLowerCase().includes(needle))
117
+ .sort((a, b) => matchRank(a, needle) - matchRank(b, needle));
118
+ if (matched.length)
119
+ return { keyword, hosts: matched };
120
+ }
121
+ // Nothing matched even the broadest keyword tried; report that one.
122
+ return { keyword: keywords.at(-1) ?? selector, hosts: [] };
123
+ }
124
+ /**
125
+ * Shell-style completion of a typed host toward `name`: the next `/`-terminated prefix of `name` that
126
+ * is longer than `query` and still contains it (case-insensitively), or the whole name when none does.
127
+ * `bos14` → `team/bos14/` → `team/bos14/bos14-ctrl`; `te` → `team/` → `team/bos14/` → ….
128
+ */
129
+ export function completeHostSegment(query, name) {
130
+ const needle = query.toLowerCase();
131
+ const segments = name.split("/");
132
+ for (let i = 1; i < segments.length; i++) {
133
+ const prefix = segments.slice(0, i).join("/") + "/";
134
+ if (prefix.length > query.length && prefix.toLowerCase().includes(needle))
135
+ return prefix;
136
+ }
137
+ return name;
138
+ }
139
+ export const HOST_MATCH_LIMIT = 20;
140
+ /** The `hosts list` columns for a set of hosts: header row first. */
141
+ export function hostRows(hosts) {
142
+ return [["ID", "NAME", "CATALOG", "CONNECTION"], ...hosts.map(host => [cell(host.id), cell(host.name), cell(host.catalog?.catalogState), hostConnection(host.enrollments)])];
143
+ }
144
+ /** The `hosts list` table restricted to keyword matches, for a terminal reader; `color` adds the highlight. */
145
+ export function formatHostMatches(result, matches, color, command = "ssh", limit = HOST_MATCH_LIMIT) {
146
+ const quoted = JSON.stringify(matches.keyword);
147
+ if (!matches.hosts.length)
148
+ return `No hosts match ${quoted} in namespace ${result.namespace}. Run dreamlake hosts list --all to see every host.`;
149
+ const shown = matches.hosts.slice(0, limit);
150
+ const rows = hostRows(shown);
151
+ const decorate = (value, row, column) => color && row > 0 && column < 2 ? highlightMatches(value, matches.keyword) : value;
152
+ const more = matches.hosts.length > shown.length ? ` Showing ${shown.length}; narrow the keyword to see the rest.` : "";
153
+ const next = matches.hosts.length === 1 ? `Connect with: dreamlake ${command} ${cell(matches.hosts[0].name)}` : "Connect with the full NAME or ID.";
154
+ return [`Hosts matching ${quoted} in namespace ${result.namespace}:`, table(rows, decorate),
155
+ `${matches.hosts.length} of ${result.total} hosts match.${more} ${next}`].join("\n");
156
+ }
@@ -0,0 +1,36 @@
1
+ import type { Command } from 'commander';
2
+ import { hostRequest } from './api.js';
3
+ export interface HostMovePreview {
4
+ apiVersion: 1;
5
+ hostId: string;
6
+ sourceNamespaceId: string;
7
+ destinationNamespaceId: string;
8
+ destinationNamespace: string;
9
+ name: string;
10
+ ownerUserId: string;
11
+ visibility: 'private';
12
+ revision: number;
13
+ previewHash: string;
14
+ blockers: string[];
15
+ executable: boolean;
16
+ }
17
+ export interface HostMoveReceipt extends Omit<HostMovePreview, 'previewHash' | 'blockers' | 'executable'> {
18
+ operationId: string;
19
+ requestId: string;
20
+ recordedAt: string;
21
+ replayed: boolean;
22
+ }
23
+ type Options = {
24
+ namespace?: string;
25
+ to: string;
26
+ dryRun?: boolean;
27
+ confirm?: boolean;
28
+ requestId?: string;
29
+ expectedRevision?: string;
30
+ previewHash?: string;
31
+ json?: boolean;
32
+ };
33
+ export declare function previewHostMove(hostId: string, opts: Pick<Options, 'namespace' | 'to'>, request?: typeof hostRequest): Promise<HostMovePreview>;
34
+ export declare function applyHostMove(hostId: string, opts: Pick<Options, 'namespace' | 'to' | 'requestId' | 'expectedRevision' | 'previewHash'>, request?: typeof hostRequest): Promise<HostMoveReceipt>;
35
+ export declare function registerHostMoveCommand(group: Command): void;
36
+ export {};
@@ -0,0 +1,72 @@
1
+ import { hostApiPath, hostRequest } from './api.js';
2
+ import { resolveHostNamespace } from './inventory.js';
3
+ function input(hostId, to) {
4
+ if (!/^[a-f0-9]{24}$/.test(hostId) || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(to))
5
+ throw new Error('Use one exact lowercase Host ID and a destination namespace slug');
6
+ }
7
+ function common(value, hostId, to) {
8
+ if (!value || value.apiVersion !== 1 || value.hostId !== hostId || value.destinationNamespace !== to ||
9
+ typeof value.sourceNamespaceId !== 'string' || !value.sourceNamespaceId || typeof value.destinationNamespaceId !== 'string' || !value.destinationNamespaceId ||
10
+ value.sourceNamespaceId === value.destinationNamespaceId || typeof value.name !== 'string' || !value.name.startsWith(`${to}/`) ||
11
+ typeof value.ownerUserId !== 'string' || !value.ownerUserId || value.visibility !== 'private' || !Number.isSafeInteger(value.revision) || value.revision < 0 || value.revision > 2147483647)
12
+ throw new Error('Host API returned an invalid private move response');
13
+ }
14
+ export async function previewHostMove(hostId, opts, request = hostRequest) {
15
+ input(hostId, opts.to);
16
+ const namespace = await resolveHostNamespace(opts.namespace);
17
+ const result = await request(`${hostApiPath(namespace)}/${hostId}/move/preview`, 'POST', { destinationNamespace: opts.to });
18
+ common(result, hostId, opts.to);
19
+ if (typeof result.previewHash !== 'string' || !/^[a-f0-9]{64}$/.test(result.previewHash) || !Array.isArray(result.blockers) ||
20
+ result.blockers.some((b) => typeof b !== 'string' || !/^[a-z_]+$/.test(b)) || result.executable !== (result.blockers.length === 0))
21
+ throw new Error('Host API returned an invalid move preview');
22
+ return result;
23
+ }
24
+ export async function applyHostMove(hostId, opts, request = hostRequest) {
25
+ input(hostId, opts.to);
26
+ if (typeof opts.requestId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/.test(opts.requestId) ||
27
+ typeof opts.expectedRevision !== 'string' || !/^(0|[1-9][0-9]*)$/.test(opts.expectedRevision) || Number(opts.expectedRevision) >= 2147483647 ||
28
+ typeof opts.previewHash !== 'string' || !/^[a-f0-9]{64}$/.test(opts.previewHash))
29
+ throw new Error('Apply requires the reviewed --preview-hash, --expected-revision, and a stable --request-id');
30
+ const namespace = await resolveHostNamespace(opts.namespace);
31
+ // Submit exactly once. After uncertainty retry these exact inputs, never refresh the plan implicitly.
32
+ const result = await request(`${hostApiPath(namespace)}/${hostId}/move`, 'POST', { destinationNamespace: opts.to,
33
+ requestId: opts.requestId, expectedRevision: Number(opts.expectedRevision), previewHash: opts.previewHash });
34
+ common(result, hostId, opts.to);
35
+ if (result.requestId !== opts.requestId || typeof result.operationId !== 'string' || !/^[a-f0-9]{64}$/.test(result.operationId) ||
36
+ result.revision !== Number(opts.expectedRevision) + 1 || typeof result.replayed !== 'boolean' ||
37
+ typeof result.recordedAt !== 'string' || !Number.isFinite(Date.parse(result.recordedAt)))
38
+ throw new Error('Host API returned an invalid move receipt');
39
+ return result;
40
+ }
41
+ export function registerHostMoveCommand(group) {
42
+ group.command('move').description('preview or apply an owner-private Host namespace move without re-enrolling')
43
+ .argument('<host-id>', 'exact lowercase Host ID').requiredOption('--to <namespace>', 'destination namespace slug')
44
+ .option('--namespace <namespace>', 'source namespace slug').option('--dry-run', 'read a server preview; do not move')
45
+ .option('--confirm', 'apply the exact reviewed preview').option('--request-id <id>', 'stable mutation request ID')
46
+ .option('--expected-revision <revision>', 'revision from the reviewed preview').option('--preview-hash <hash>', 'hash from the reviewed preview')
47
+ .option('--json', 'emit structured preview or receipt').action(async (hostId, opts) => {
48
+ try {
49
+ if (Boolean(opts.dryRun) === Boolean(opts.confirm))
50
+ throw new Error('Choose --dry-run to review or --confirm with the exact reviewed inputs');
51
+ if (opts.dryRun && (opts.requestId !== undefined || opts.expectedRevision !== undefined || opts.previewHash !== undefined))
52
+ throw new Error('Mutation inputs belong with --confirm');
53
+ const result = opts.dryRun ? await previewHostMove(hostId, opts) : await applyHostMove(hostId, opts);
54
+ if (opts.json)
55
+ console.log(JSON.stringify(result, null, 2));
56
+ else
57
+ console.log([`Host: ${result.name}`, 'Access: Private — only you', `Revision: ${result.revision}`,
58
+ ...('previewHash' in result ? [`Preview hash: ${result.previewHash}`, result.executable ? 'Ready to move. Apply with --confirm and these reviewed inputs.' : `Blocked: ${result.blockers.join(', ')}`]
59
+ : [`Operation ID: ${result.operationId}`, `Request ID: ${result.requestId}`, result.replayed ? 'Stored original receipt; inspect the host for its current location.' : 'Move committed.'])].join('\n'));
60
+ if ('executable' in result && !result.executable)
61
+ process.exitCode = 1;
62
+ }
63
+ catch (error) {
64
+ const message = error instanceof Error ? error.message : 'Host move failed';
65
+ if (opts.json)
66
+ console.log(JSON.stringify({ status: 'error', error: message }));
67
+ else
68
+ console.error(message);
69
+ process.exitCode = 1;
70
+ }
71
+ });
72
+ }
@@ -0,0 +1,34 @@
1
+ import { type HostInventory, type HostMatches } from "./inventory.js";
2
+ /** The terminal a person is typing into. `process.stdin`/`process.stderr` in the CLI; any pair of streams in tests. */
3
+ export interface PickerIO {
4
+ input: NodeJS.ReadableStream & {
5
+ isTTY?: boolean;
6
+ setRawMode?: (mode: boolean) => unknown;
7
+ };
8
+ output: {
9
+ write(text: string): unknown;
10
+ columns?: number;
11
+ };
12
+ color: boolean;
13
+ }
14
+ export interface PickerState {
15
+ query: string;
16
+ cursor: number;
17
+ }
18
+ /** Matches for what is typed so far; an empty query lists the whole inventory. */
19
+ export declare function pickerMatches(inventory: HostInventory, query: string): HostMatches;
20
+ /** One frame of the picker: the command being built, the match table with the cursor row marked, and a count. */
21
+ export declare function renderPicker(inventory: HostInventory, selector: string, command: "ssh" | "exec", state: PickerState, color: boolean, limit?: number): string;
22
+ /** Pure key handling, so the loop and the tests share one definition. */
23
+ export declare function reducePicker(inventory: HostInventory, state: PickerState, key: string): {
24
+ state: PickerState;
25
+ done?: "pick" | "cancel";
26
+ };
27
+ /** Split a raw-mode chunk into keys: arrow sequences stay whole, everything else is one character per key. */
28
+ export declare function splitKeys(chunk: string): string[];
29
+ /**
30
+ * Interactive host picker for a selector that named no host. Lists keyword matches with the best one
31
+ * highlighted; typing filters, Tab completes toward the highlighted host one segment at a time, Enter
32
+ * resolves to that host's full name, and Esc or Ctrl-C resolves to undefined. Draws on `io.output`.
33
+ */
34
+ export declare function pickHost(inventory: HostInventory, selector: string, command: "ssh" | "exec", io: PickerIO): Promise<string | undefined>;
@@ -0,0 +1,116 @@
1
+ import { HOST_MATCH_LIMIT, completeHostSegment, highlightMatches, hostRows, matchHosts, table } from "./inventory.js";
2
+ const ESC = "\x1b", INVERSE = "\x1b[7m", DIM = "\x1b[2m", RESET = "\x1b[0m";
3
+ const plainLength = (text) => text.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").length;
4
+ /** Matches for what is typed so far; an empty query lists the whole inventory. */
5
+ export function pickerMatches(inventory, query) {
6
+ return query ? matchHosts(inventory.hosts, query) : { keyword: "", hosts: inventory.hosts };
7
+ }
8
+ /** One frame of the picker: the command being built, the match table with the cursor row marked, and a count. */
9
+ export function renderPicker(inventory, selector, command, state, color, limit = HOST_MATCH_LIMIT) {
10
+ const matches = pickerMatches(inventory, state.query);
11
+ const paint = (text, code) => color ? `${code}${text}${RESET}` : text;
12
+ const lines = [
13
+ paint(`Host ${JSON.stringify(selector)} not found. ↑↓ move · Tab complete · Enter connect · Esc cancel`, DIM),
14
+ `> dreamlake ${command} ${state.query}${paint("▏", DIM)}`,
15
+ ];
16
+ if (!matches.hosts.length) {
17
+ lines.push(`No hosts match ${JSON.stringify(matches.keyword)} in namespace ${inventory.namespace}. Keep typing or press Esc.`);
18
+ return lines.join("\n");
19
+ }
20
+ const start = Math.max(0, Math.min(state.cursor - Math.floor(limit / 2), matches.hosts.length - limit));
21
+ const shown = matches.hosts.slice(start, start + limit);
22
+ const selectedRow = (row) => row > 0 && start + row - 1 === state.cursor;
23
+ // Inside the inverse cursor row the highlight ends with "bold/underline off" so the inverse survives.
24
+ const decorate = (value, row, column) => color && row > 0 && column < 2 ? highlightMatches(value, matches.keyword, selectedRow(row) ? "\x1b[22;24m" : RESET) : value;
25
+ lines.push(...table(hostRows(shown), decorate).split("\n").map((line, row) => selectedRow(row) ? `${paint("❯", "\x1b[32m")} ${color ? `${INVERSE}${line}${RESET}` : line}` : ` ${line}`));
26
+ const hidden = matches.hosts.length - shown.length;
27
+ lines.push(`${matches.hosts.length} of ${inventory.total} hosts match.${hidden ? ` Showing ${shown.length}; type more to narrow.` : ""}`);
28
+ return lines.join("\n");
29
+ }
30
+ /** Pure key handling, so the loop and the tests share one definition. */
31
+ export function reducePicker(inventory, state, key) {
32
+ const count = pickerMatches(inventory, state.query).hosts.length;
33
+ const clamp = (cursor) => Math.max(0, Math.min(cursor, count - 1));
34
+ if (key === `${ESC}[A`)
35
+ return { state: { ...state, cursor: clamp(state.cursor - 1) } };
36
+ if (key === `${ESC}[B`)
37
+ return { state: { ...state, cursor: clamp(state.cursor + 1) } };
38
+ if (key === ESC || key === "\x03" || key === "\x04")
39
+ return { state, done: "cancel" };
40
+ if (key === "\r" || key === "\n")
41
+ return count ? { state, done: "pick" } : { state };
42
+ if (key === "\t") {
43
+ const target = pickerMatches(inventory, state.query).hosts[clamp(state.cursor)];
44
+ return target ? { state: { query: completeHostSegment(state.query, target.name), cursor: 0 } } : { state };
45
+ }
46
+ if (key === "\x7f" || key === "\b")
47
+ return { state: { query: state.query.slice(0, -1), cursor: 0 } };
48
+ if (key === "\x15")
49
+ return { state: { query: "", cursor: 0 } };
50
+ if (key.length === 1 && key >= " " && key !== "\x7f")
51
+ return { state: { query: state.query + key, cursor: 0 } };
52
+ return { state };
53
+ }
54
+ /** Split a raw-mode chunk into keys: arrow sequences stay whole, everything else is one character per key. */
55
+ export function splitKeys(chunk) {
56
+ const keys = [];
57
+ for (let i = 0; i < chunk.length; i++) {
58
+ if (chunk[i] === ESC && chunk[i + 1] === "[" && /[A-D]/.test(chunk[i + 2] ?? "")) {
59
+ keys.push(chunk.slice(i, i + 3));
60
+ i += 2;
61
+ }
62
+ else if (chunk[i] === ESC && chunk[i + 1] === "[") {
63
+ i = chunk.length;
64
+ } // An unknown CSI sequence; drop the rest of the chunk.
65
+ else
66
+ keys.push(chunk[i]);
67
+ }
68
+ return keys;
69
+ }
70
+ /**
71
+ * Interactive host picker for a selector that named no host. Lists keyword matches with the best one
72
+ * highlighted; typing filters, Tab completes toward the highlighted host one segment at a time, Enter
73
+ * resolves to that host's full name, and Esc or Ctrl-C resolves to undefined. Draws on `io.output`.
74
+ */
75
+ export function pickHost(inventory, selector, command, io) {
76
+ let state = { query: selector, cursor: 0 };
77
+ let drawn = 0;
78
+ const draw = () => {
79
+ const width = io.output.columns;
80
+ const lines = renderPicker(inventory, selector, command, state, io.color).split("\n")
81
+ .map(line => width && plainLength(line) >= width ? line.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").slice(0, width - 1) : line);
82
+ io.output.write(`${drawn > 1 ? `${ESC}[${drawn - 1}A` : ""}\r${ESC}[0J${lines.join("\n")}`);
83
+ drawn = lines.length;
84
+ };
85
+ const clear = () => { io.output.write(`${drawn > 1 ? `${ESC}[${drawn - 1}A` : ""}\r${ESC}[0J${ESC}[?25h`); drawn = 0; };
86
+ const raw = io.input.isTTY && typeof io.input.setRawMode === "function";
87
+ return new Promise(resolve => {
88
+ const finish = (picked) => {
89
+ io.input.off("data", onData);
90
+ if (raw)
91
+ io.input.setRawMode(false);
92
+ io.input.pause();
93
+ clear();
94
+ if (picked !== undefined)
95
+ io.output.write(`dreamlake ${command} ${picked}\n`);
96
+ resolve(picked);
97
+ };
98
+ const onData = (chunk) => {
99
+ for (const key of splitKeys(chunk.toString())) {
100
+ const next = reducePicker(inventory, state, key);
101
+ state = next.state;
102
+ if (next.done === "cancel")
103
+ return finish(undefined);
104
+ if (next.done === "pick")
105
+ return finish(pickerMatches(inventory, state.query).hosts[state.cursor].name);
106
+ }
107
+ draw();
108
+ };
109
+ if (raw)
110
+ io.input.setRawMode(true);
111
+ io.input.on("data", onData);
112
+ io.input.resume();
113
+ io.output.write(`${ESC}[?25l`);
114
+ draw();
115
+ });
116
+ }
@@ -3,6 +3,7 @@ import { Duplex } from 'node:stream';
3
3
  import WebSocket from 'ws';
4
4
  import type { Command } from 'commander';
5
5
  import { hostRequest } from './api.js';
6
+ import { type HostInventory } from './inventory.js';
6
7
  /** Wait the server's Retry-After (capped at 5s) or exponential backoff, whichever is longer. */
7
8
  export declare function busyRetryDelay(attempt: number, retryAt?: string, now?: number): number;
8
9
  export interface SshTarget {
@@ -46,8 +47,23 @@ export interface SshIO {
46
47
  socket: (url: string, ticket: string) => WebSocket;
47
48
  spawn: (args: string[]) => ChildProcess;
48
49
  chooseTarget?: (targets: SshTarget[]) => Promise<string>;
50
+ /** Whether a person is reading stderr; host suggestions and their highlight are terminal-only. */
51
+ terminal?: () => boolean;
52
+ /** Whether a person can also type (stdin is a terminal); only then does the picker replace the static list. */
53
+ interactive?: () => boolean;
54
+ /** The interactive picker: resolves to a full host name, or undefined when the person cancels. */
55
+ pick?: (inventory: HostInventory, selector: string, command: 'ssh' | 'exec') => Promise<string | undefined>;
49
56
  }
50
57
  export declare const defaultSshIO: SshIO;
58
+ /** Only a selector that named no host earns suggestions; auth, namespace and transport errors pass through unchanged. */
59
+ export declare function isHostLookupMiss(error: unknown): boolean;
60
+ /**
61
+ * Every host in the namespace the selector points at (its first segment, else the configured one),
62
+ * for suggesting what a partial or misspelled selector meant. Throws when the inventory cannot be read.
63
+ */
64
+ export declare function suggestionInventory(selector: string, opts: SshOptions, io?: SshIO): Promise<HostInventory>;
65
+ /** The `hosts list` table filtered to the selector's keyword, with every match highlighted, for a terminal reader who cannot type back. */
66
+ export declare function suggestHosts(selector: string, opts: SshOptions, command: 'ssh' | 'exec', io?: SshIO): Promise<string>;
51
67
  export declare function chooseSshTarget(targets: SshTarget[], selector: string, opts: SshOptions, argv: string[] | undefined, choose?: SshIO['chooseTarget']): Promise<SshTarget>;
52
68
  export declare function sshPublicKey(value: string): string;
53
69
  export declare function validateSshTarget(t: SshTarget, hostId: string, namespace: string): void;
@@ -11,7 +11,8 @@ import WebSocket from 'ws';
11
11
  import { select } from '@inquirer/prompts';
12
12
  import { HostApiError, hostApiPath, hostRequest } from './api.js';
13
13
  import { hostStatus } from './enroll.js';
14
- import { resolveHostNamespace } from './inventory.js';
14
+ import { formatHostMatches, listHosts, matchHosts, resolveHostNamespace } from './inventory.js';
15
+ import { pickHost } from './picker.js';
15
16
  const ID = /^[a-f0-9]{24}$/;
16
17
  // Same budget as the browser relay: 4 delegation attempts within 25s.
17
18
  const BUSY_MAX_ATTEMPTS = 4, BUSY_RETRY_BUDGET_MS = 25000;
@@ -21,11 +22,34 @@ export function busyRetryDelay(attempt, retryAt, now = Date.now()) {
21
22
  return Math.max(Number.isFinite(hinted) ? hinted : 0, 1000 * 2 ** (attempt - 1));
22
23
  }
23
24
  export const defaultSshIO = {
24
- request: hostRequest, fetch: (...args) => fetch(...args),
25
+ request: hostRequest, fetch: (...args) => fetch(...args), terminal: () => Boolean(process.stderr.isTTY),
26
+ interactive: () => Boolean(process.stdin.isTTY && process.stderr.isTTY),
27
+ pick: (inventory, selector, command) => pickHost(inventory, selector, command, { input: process.stdin, output: process.stderr, color: !process.env.NO_COLOR }),
25
28
  socket: (url, ticket) => new WebSocket(url, 'nymph-ssh.v1', { headers: { Authorization: `Bearer ${ticket}` },
26
29
  perMessageDeflate: false, maxPayload: 65537, handshakeTimeout: 10000, followRedirects: false }),
27
30
  spawn: args => spawn('ssh', args, { stdio: 'inherit' }),
28
31
  };
32
+ /** Only a selector that named no host earns suggestions; auth, namespace and transport errors pass through unchanged. */
33
+ export function isHostLookupMiss(error) {
34
+ if (error instanceof HostApiError)
35
+ return error.status === 403 || error.status === 404;
36
+ const message = error instanceof Error ? error.message : '';
37
+ return message.startsWith('Host selector must be') || message.startsWith('Host not found');
38
+ }
39
+ /**
40
+ * Every host in the namespace the selector points at (its first segment, else the configured one),
41
+ * for suggesting what a partial or misspelled selector meant. Throws when the inventory cannot be read.
42
+ */
43
+ export async function suggestionInventory(selector, opts, io = defaultSshIO) {
44
+ const parts = selector.split('/');
45
+ const namespace = parts.length === 3 && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(parts[0]) && !opts.namespace ? parts[0] : await resolveHostNamespace(opts.namespace);
46
+ return listHosts({ namespace, all: true }, io.request);
47
+ }
48
+ /** The `hosts list` table filtered to the selector's keyword, with every match highlighted, for a terminal reader who cannot type back. */
49
+ export async function suggestHosts(selector, opts, command, io = defaultSshIO) {
50
+ const inventory = await suggestionInventory(selector, opts, io);
51
+ return formatHostMatches(inventory, matchHosts(inventory.hosts, selector), !process.env.NO_COLOR, command);
52
+ }
29
53
  export async function chooseSshTarget(targets, selector, opts, argv, choose) {
30
54
  if (targets.length === 0)
31
55
  throw new Error('No ready SSH enrollment for this host');
@@ -108,7 +132,8 @@ export class SshRelay extends Duplex {
108
132
  this.push(null);
109
133
  return;
110
134
  }
111
- if (b[0] !== 0 || b.length < 2 || this.readableLength + b.length > 262144)
135
+ // The stream retains payload only; already-decoded frames may follow pause.
136
+ if (b[0] !== 0 || b.length < 2 || this.readableLength + b.length - 1 > 262144)
112
137
  return this.destroy(new Error('Invalid SSH relay frame'));
113
138
  if (!this.push(b.subarray(1)))
114
139
  ws.pause();
@@ -145,7 +170,27 @@ export async function runHostSsh(selector, opts, argv, io = defaultSshIO) {
145
170
  throw new Error('--timeout must be 1–duration seconds');
146
171
  if (opts.enrollment !== undefined && !ID.test(opts.enrollment))
147
172
  throw new Error('Use an exact enrollment ID');
148
- const detail = await hostStatus(selector, opts, io.request);
173
+ let detail;
174
+ try {
175
+ detail = await hostStatus(selector, opts, io.request);
176
+ }
177
+ catch (error) {
178
+ if (!isHostLookupMiss(error) || !io.terminal?.())
179
+ throw error;
180
+ const command = argv === undefined ? 'ssh' : 'exec';
181
+ const inventory = await suggestionInventory(selector, opts, io).catch(() => undefined);
182
+ if (!inventory)
183
+ throw error;
184
+ if (!io.interactive?.() || !io.pick) {
185
+ throw new Error(`${error instanceof Error ? error.message : 'Host lookup failed'}\n${formatHostMatches(inventory, matchHosts(inventory.hosts, selector), !process.env.NO_COLOR, command)}`);
186
+ }
187
+ // A person is typing: let them pick the host they meant. Cancelling keeps the original error and exit code.
188
+ const picked = await io.pick(inventory, selector, command);
189
+ if (picked === undefined)
190
+ throw error;
191
+ selector = picked;
192
+ detail = await hostStatus(selector, opts, io.request);
193
+ }
149
194
  const namespace = selector.includes('/') ? selector.split('/')[0] : await resolveHostNamespace(opts.namespace);
150
195
  if (!ID.test(detail?.host?.id) || !Array.isArray(detail.enrollments))
151
196
  throw new Error('Invalid host response');
@@ -1 +1 @@
1
- export declare const VERSION = "0.99.0";
1
+ export declare const VERSION = "0.101.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.99.0";
9
+ export const VERSION = "0.101.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.99.0",
3
+ "version": "0.101.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -35,13 +35,13 @@
35
35
  "node": ">=18"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.99.0",
39
- "@dreamlake/dreamlake-cli-darwin-x64": "0.99.0",
40
- "@dreamlake/dreamlake-cli-linux-x64": "0.99.0",
41
- "@dreamlake/dreamlake-cli-linux-arm64": "0.99.0",
42
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.99.0",
43
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.99.0",
44
- "@dreamlake/dreamlake-cli-win32-x64": "0.99.0",
45
- "@dreamlake/dreamlake-cli-win32-arm64": "0.99.0"
38
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.101.0",
39
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.101.0",
40
+ "@dreamlake/dreamlake-cli-linux-x64": "0.101.0",
41
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.101.0",
42
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.101.0",
43
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.101.0",
44
+ "@dreamlake/dreamlake-cli-win32-x64": "0.101.0",
45
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.101.0"
46
46
  }
47
47
  }