@dreamlake/dreamlake-cli 0.90.0 → 0.92.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.
- package/dist/api/execution.d.ts +2 -0
- package/dist/api/execution.js +3 -0
- package/dist/api/index.d.ts +9 -2
- package/dist/api/note-reading.d.ts +24 -0
- package/dist/api/note-reading.js +15 -0
- package/dist/api/notes.d.ts +2 -0
- package/dist/api/notes.js +2 -0
- package/dist/api/sessions.d.ts +6 -1
- package/dist/cli/help-examples.generated.js +1 -0
- package/dist/cli/notes/document.js +28 -3
- package/dist/cli/queues/index.d.ts +5 -0
- package/dist/cli/queues/index.js +36 -0
- package/dist/cli/sessions/index.js +15 -4
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
package/dist/api/execution.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ export declare function queuesApi(t: Transport, namespace: string): {
|
|
|
78
78
|
unmount: (prefix: string) => Promise<unknown>;
|
|
79
79
|
token: (prefix: string, token: string) => Promise<unknown>;
|
|
80
80
|
proxy: (prefix: string, lakeshoreNamespace: string, kind: "queues" | "workers" | "jobs" | "invocations", query?: Query) => Promise<unknown>;
|
|
81
|
+
worker: (prefix: string, lakeshoreNamespace: string, workerId: string) => Promise<unknown>;
|
|
82
|
+
setWorkerClaimJobs: (prefix: string, lakeshoreNamespace: string, workerId: string, enabled: boolean) => Promise<unknown>;
|
|
81
83
|
};
|
|
82
84
|
export declare function submitRun(t: Transport, namespace: string, input: RunInput): Promise<{
|
|
83
85
|
run: Record<string, unknown>;
|
package/dist/api/execution.js
CHANGED
|
@@ -53,6 +53,9 @@ export function queuesApi(t, namespace) {
|
|
|
53
53
|
seg(lakeshoreNamespace) +
|
|
54
54
|
"/" +
|
|
55
55
|
kind, undefined, query),
|
|
56
|
+
worker: (prefix, lakeshoreNamespace, workerId) => call(t, "GET", p(prefix) + "/proxy/v1/namespaces/" + seg(lakeshoreNamespace) + "/workers/" + seg(workerId)),
|
|
57
|
+
// Future business claims only; heartbeat, control and remote exec continue.
|
|
58
|
+
setWorkerClaimJobs: (prefix, lakeshoreNamespace, workerId, enabled) => call(t, "POST", p(prefix) + "/proxy/v1/namespaces/" + seg(lakeshoreNamespace) + "/workers/" + seg(workerId) + "/claim-jobs", { enabled }),
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
export async function submitRun(t, namespace, input) {
|
package/dist/api/index.d.ts
CHANGED
|
@@ -369,7 +369,7 @@ export declare function createApi(transport: Transport): {
|
|
|
369
369
|
id: string;
|
|
370
370
|
}) => Promise<unknown>;
|
|
371
371
|
list: (query?: import("./sessions.js").ListSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
|
|
372
|
-
available: (query?: import("./sessions.js").
|
|
372
|
+
available: (query?: import("./sessions.js").AvailableSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
|
|
373
373
|
get: (sessionId: string) => Promise<import("./sessions.js").Session>;
|
|
374
374
|
conversation: (sessionId: string) => Promise<{
|
|
375
375
|
conversation: import("./sessions.js").Conversation | null;
|
|
@@ -616,6 +616,7 @@ export declare function createApi(transport: Transport): {
|
|
|
616
616
|
};
|
|
617
617
|
media: (form: FormData) => Promise<import("./notes.js").NoteMediaReceipt>;
|
|
618
618
|
read: (noteId: string, query?: import("./common.js").Query) => Promise<import("./notes.js").NoteReadResult>;
|
|
619
|
+
readView: (noteId: string, options?: import("./note-reading.js").NoteReadingOptions) => Promise<import("./note-reading.js").NoteReadingPage>;
|
|
619
620
|
html: (noteId: string, options?: {
|
|
620
621
|
at?: string;
|
|
621
622
|
section?: string;
|
|
@@ -1135,6 +1136,8 @@ export declare function createApi(transport: Transport): {
|
|
|
1135
1136
|
unmount: (prefix: string) => Promise<unknown>;
|
|
1136
1137
|
token: (prefix: string, token: string) => Promise<unknown>;
|
|
1137
1138
|
proxy: (prefix: string, lakeshoreNamespace: string, kind: "queues" | "workers" | "jobs" | "invocations", query?: import("./common.js").Query) => Promise<unknown>;
|
|
1139
|
+
worker: (prefix: string, lakeshoreNamespace: string, workerId: string) => Promise<unknown>;
|
|
1140
|
+
setWorkerClaimJobs: (prefix: string, lakeshoreNamespace: string, workerId: string, enabled: boolean) => Promise<unknown>;
|
|
1138
1141
|
};
|
|
1139
1142
|
ownership: (namespace: string) => {
|
|
1140
1143
|
resource: (kind: "project" | "source", id: string, action?: "inspect" | "manifest" | "restore" | "transfer-plan") => Promise<unknown>;
|
|
@@ -1565,7 +1568,7 @@ export declare function createClient(options: ClientOptions): {
|
|
|
1565
1568
|
id: string;
|
|
1566
1569
|
}) => Promise<unknown>;
|
|
1567
1570
|
list: (query?: import("./sessions.js").ListSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
|
|
1568
|
-
available: (query?: import("./sessions.js").
|
|
1571
|
+
available: (query?: import("./sessions.js").AvailableSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
|
|
1569
1572
|
get: (sessionId: string) => Promise<import("./sessions.js").Session>;
|
|
1570
1573
|
conversation: (sessionId: string) => Promise<{
|
|
1571
1574
|
conversation: import("./sessions.js").Conversation | null;
|
|
@@ -1812,6 +1815,7 @@ export declare function createClient(options: ClientOptions): {
|
|
|
1812
1815
|
};
|
|
1813
1816
|
media: (form: FormData) => Promise<import("./notes.js").NoteMediaReceipt>;
|
|
1814
1817
|
read: (noteId: string, query?: import("./common.js").Query) => Promise<import("./notes.js").NoteReadResult>;
|
|
1818
|
+
readView: (noteId: string, options?: import("./note-reading.js").NoteReadingOptions) => Promise<import("./note-reading.js").NoteReadingPage>;
|
|
1815
1819
|
html: (noteId: string, options?: {
|
|
1816
1820
|
at?: string;
|
|
1817
1821
|
section?: string;
|
|
@@ -2331,6 +2335,8 @@ export declare function createClient(options: ClientOptions): {
|
|
|
2331
2335
|
unmount: (prefix: string) => Promise<unknown>;
|
|
2332
2336
|
token: (prefix: string, token: string) => Promise<unknown>;
|
|
2333
2337
|
proxy: (prefix: string, lakeshoreNamespace: string, kind: "queues" | "workers" | "jobs" | "invocations", query?: import("./common.js").Query) => Promise<unknown>;
|
|
2338
|
+
worker: (prefix: string, lakeshoreNamespace: string, workerId: string) => Promise<unknown>;
|
|
2339
|
+
setWorkerClaimJobs: (prefix: string, lakeshoreNamespace: string, workerId: string, enabled: boolean) => Promise<unknown>;
|
|
2334
2340
|
};
|
|
2335
2341
|
ownership: (namespace: string) => {
|
|
2336
2342
|
resource: (kind: "project" | "source", id: string, action?: "inspect" | "manifest" | "restore" | "transfer-plan") => Promise<unknown>;
|
|
@@ -2360,3 +2366,4 @@ export * from "./note-html-read.js";
|
|
|
2360
2366
|
export { characterDiff, NotePatchError, PATCH_LIMITS, } from "./note-character-plan.js";
|
|
2361
2367
|
export * from "./presigned-transfer.js";
|
|
2362
2368
|
export * from "./note-events.js";
|
|
2369
|
+
export type { NoteReadingOptions, NoteReadingPage } from "./note-reading.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Transport } from './client.js';
|
|
2
|
+
export interface NoteReadingOptions {
|
|
3
|
+
at?: string;
|
|
4
|
+
start?: number;
|
|
5
|
+
limit?: number;
|
|
6
|
+
section?: string;
|
|
7
|
+
tag?: string;
|
|
8
|
+
toc?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NoteReadingPage {
|
|
11
|
+
note: string;
|
|
12
|
+
hash: string;
|
|
13
|
+
revision: string;
|
|
14
|
+
text: string;
|
|
15
|
+
scope: string;
|
|
16
|
+
sourceType: 'markdown' | 'html';
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
total: number;
|
|
20
|
+
complete: boolean;
|
|
21
|
+
next: number | null;
|
|
22
|
+
}
|
|
23
|
+
/** Same addressed, revision-pinned reading contract as the built-in agent. */
|
|
24
|
+
export declare function readNoteView(t: Transport, namespace: string, note: string, options?: NoteReadingOptions): Promise<NoteReadingPage>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isObjectId, seg } from './client.js';
|
|
2
|
+
/** Same addressed, revision-pinned reading contract as the built-in agent. */
|
|
3
|
+
export async function readNoteView(t, namespace, note, options = {}) {
|
|
4
|
+
if (!isObjectId(note))
|
|
5
|
+
throw new Error('expected a 24-hex note id');
|
|
6
|
+
if ((options.start ?? 0) > 0 && !options.at)
|
|
7
|
+
throw new Error('reading continuation requires the original revision');
|
|
8
|
+
const page = await t.request('GET', `/namespaces/${seg(namespace)}/notes/${note}/body`, { query: { contract: 'v2', view: 'reading', ...options } });
|
|
9
|
+
if (page.note !== note || typeof page.revision !== 'string' || !page.revision || /[\r\n]/.test(page.revision) || options.at && page.revision !== options.at ||
|
|
10
|
+
!/^sha256:[a-f0-9]{64}$/.test(page.hash) || typeof page.text !== 'string' || !['markdown', 'html'].includes(page.sourceType) || typeof page.scope !== 'string' ||
|
|
11
|
+
![page.start, page.end, page.total].every(n => Number.isSafeInteger(n) && n >= 0) || page.start !== (options.start ?? 0) || page.end < page.start || page.end > page.total ||
|
|
12
|
+
Array.from(page.text).length !== page.end - page.start || page.complete !== (page.end === page.total) || page.next !== (page.complete ? null : page.end) || !page.complete && page.end === page.start)
|
|
13
|
+
throw new Error('invalid Note reading page');
|
|
14
|
+
return page;
|
|
15
|
+
}
|
package/dist/api/notes.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NoteReadingOptions } from "./note-reading.js";
|
|
1
2
|
import * as editing from "./note-editing.js";
|
|
2
3
|
import { type NoteLingerOptions, type NoteLingerEvent } from "./note-linger.js";
|
|
3
4
|
import type { Query } from "./common.js";
|
|
@@ -225,6 +226,7 @@ export declare function notesApi(t: Transport, namespace: string): {
|
|
|
225
226
|
};
|
|
226
227
|
media: (form: FormData) => Promise<NoteMediaReceipt>;
|
|
227
228
|
read: (noteId: string, query?: Query) => Promise<NoteReadResult>;
|
|
229
|
+
readView: (noteId: string, options?: NoteReadingOptions) => Promise<import("./note-reading.js").NoteReadingPage>;
|
|
228
230
|
html: (noteId: string, options?: {
|
|
229
231
|
at?: string;
|
|
230
232
|
section?: string;
|
package/dist/api/notes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readNoteView } from "./note-reading.js";
|
|
1
2
|
import { validateHtmlSnapshot } from "./note-html-read.js";
|
|
2
3
|
import { characterDiff } from "./note-character-plan.js";
|
|
3
4
|
import * as editing from "./note-editing.js";
|
|
@@ -129,6 +130,7 @@ export function notesApi(t, namespace) {
|
|
|
129
130
|
read: (noteId, query = {}) => t.request("GET", `${base}/${id(noteId)}/body`, {
|
|
130
131
|
query: { contract: "v2", ...query },
|
|
131
132
|
}),
|
|
133
|
+
readView: (noteId, options = {}) => readNoteView(t, namespace, id(noteId), options),
|
|
132
134
|
html: async (noteId, options = {}) => {
|
|
133
135
|
if (!t.raw)
|
|
134
136
|
throw new Error("transport_does_not_support_streaming");
|
package/dist/api/sessions.d.ts
CHANGED
|
@@ -52,6 +52,11 @@ export type ListSessionsQuery = {
|
|
|
52
52
|
archived?: "exclude" | "include" | "only";
|
|
53
53
|
machineId?: string;
|
|
54
54
|
};
|
|
55
|
+
/** Explicit cross-owner filters; never access grants. */
|
|
56
|
+
export type AvailableSessionsQuery = ListSessionsQuery & {
|
|
57
|
+
owner?: string;
|
|
58
|
+
team?: string;
|
|
59
|
+
};
|
|
55
60
|
export type ConversationMessage = {
|
|
56
61
|
role: "user" | "assistant" | "tool" | "system";
|
|
57
62
|
text: string;
|
|
@@ -189,7 +194,7 @@ export declare function sessionsApi(t: Transport, namespace: string): {
|
|
|
189
194
|
}) => Promise<unknown>;
|
|
190
195
|
list: (query?: ListSessionsQuery) => Promise<SessionPage>;
|
|
191
196
|
/** Every session the caller may read across namespaces: public, team-shared and their own. */
|
|
192
|
-
available: (query?:
|
|
197
|
+
available: (query?: AvailableSessionsQuery) => Promise<SessionPage>;
|
|
193
198
|
get: (sessionId: string) => Promise<Session>;
|
|
194
199
|
conversation: (sessionId: string) => Promise<{
|
|
195
200
|
conversation: Conversation | null;
|
|
@@ -126,6 +126,7 @@ export const helpExamples = {
|
|
|
126
126
|
"providers nodes": "dreamlake providers nodes team/333333333333333333333333 --json",
|
|
127
127
|
"providers instances logs": "dreamlake providers instances logs team/333333333333333333333333 --instance POD_NAME --tail 100 --json",
|
|
128
128
|
"providers instances terminate": "dreamlake providers instances terminate team/333333333333333333333333 --instance POD_NAME --request-id kube-delete-01 --json",
|
|
129
|
+
"queues worker-claims": "dreamlake queues worker-claims lab WORKER_ID --namespace geyang\ndreamlake queues worker-claims lab WORKER_ID --namespace geyang --disable\ndreamlake queues worker-claims lab WORKER_ID --namespace geyang --enable --json",
|
|
129
130
|
"queues slurm clusters": "dreamlake queues slurm clusters --namespace geyang",
|
|
130
131
|
"queues slurm jobs": "dreamlake queues slurm jobs CLUSTER_ID --namespace geyang\ndreamlake queues slurm jobs CLUSTER_ID --namespace geyang --details\ndreamlake queues slurm jobs CLUSTER_ID --namespace geyang --json",
|
|
131
132
|
"runnable run": "dreamlake runnable run udf/NAMESPACE/NAME@FULL_SHA256 \\\n --target NAMESPACE/GROUP/HOST --enrollment-id ENROLLMENT_ID \\\n --request-id YOUR_STABLE_REQUEST_ID --inputs inputs.json --json",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readNoteView } from "../../api/note-reading.js";
|
|
2
|
+
import { validateHtmlSnapshot } from "./html-read.js";
|
|
2
3
|
/** V2 transports exact source and opaque revisions; the backend owns patch parsing. */
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
import { readFileSync, fstatSync } from "node:fs";
|
|
@@ -162,7 +163,31 @@ export async function runDocumentRead(ref, opts) {
|
|
|
162
163
|
const query = new URLSearchParams({ contract: "v2" });
|
|
163
164
|
if (opts.at)
|
|
164
165
|
query.set("at", opts.at);
|
|
165
|
-
if (opts.view === "
|
|
166
|
+
if (opts.view === "markdown") {
|
|
167
|
+
const transport = { request: (method, path, options = {}) => { if (method !== "GET")
|
|
168
|
+
throw new Error("reading transport requires GET"); return requestJson(c.remote, path, { method, query: options.query, headers: options.headers, token: c.token, redirect: "error" }); } };
|
|
169
|
+
let at = opts.at, start = 0, hash, total;
|
|
170
|
+
do {
|
|
171
|
+
const page = await readNoteView(transport, c.ns, id, { at, start, section: opts.section, tag: opts.tag, toc: opts.toc });
|
|
172
|
+
if (page.sourceType !== 'markdown')
|
|
173
|
+
throw new Error('annotated Markdown requires a Markdown note; use --view html for HTML source');
|
|
174
|
+
if (opts.ifMatch && page.revision !== opts.ifMatch) {
|
|
175
|
+
fail("note changed since the acknowledged revision; keep the original draft and baseline");
|
|
176
|
+
return 3;
|
|
177
|
+
}
|
|
178
|
+
if (hash !== undefined && (hash !== page.hash || total !== page.total))
|
|
179
|
+
throw new Error('Note reading view changed during pagination');
|
|
180
|
+
hash = page.hash;
|
|
181
|
+
total = page.total;
|
|
182
|
+
at = page.revision;
|
|
183
|
+
process.stdout.write(page.text);
|
|
184
|
+
if (page.complete)
|
|
185
|
+
break;
|
|
186
|
+
start = page.next;
|
|
187
|
+
} while (true);
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
if (opts.view === "html") {
|
|
166
191
|
if (opts.section !== undefined)
|
|
167
192
|
query.set("section", opts.section);
|
|
168
193
|
if (opts.tag)
|
|
@@ -185,7 +210,7 @@ export async function runDocumentRead(ref, opts) {
|
|
|
185
210
|
fail("note changed since the acknowledged revision; keep the original draft and baseline");
|
|
186
211
|
return 3;
|
|
187
212
|
}
|
|
188
|
-
process.stdout.write(
|
|
213
|
+
process.stdout.write(bytes);
|
|
189
214
|
return 0;
|
|
190
215
|
}
|
|
191
216
|
if (opts.since !== undefined) {
|
|
@@ -30,4 +30,9 @@ export declare function runQueuesResources(prefix: string, resource: "workers" |
|
|
|
30
30
|
limit?: string;
|
|
31
31
|
offset?: string;
|
|
32
32
|
}): Promise<number>;
|
|
33
|
+
export interface WorkerClaimsOpts extends QueueOpts {
|
|
34
|
+
enable?: boolean;
|
|
35
|
+
disable?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function runQueuesWorkerClaims(prefix: string, workerId: string, opts: WorkerClaimsOpts): Promise<number>;
|
|
33
38
|
export declare function registerQueuesCommand(program: Command): void;
|
package/dist/cli/queues/index.js
CHANGED
|
@@ -219,6 +219,38 @@ export async function runQueuesResources(prefix, resource, opts) {
|
|
|
219
219
|
return error(err);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
+
// Shows or sets one worker's job-claim switch. Disabled workers keep heartbeat,
|
|
223
|
+
// control, setup and remote exec; already-claimed work is not cancelled.
|
|
224
|
+
export async function runQueuesWorkerClaims(prefix, workerId, opts) {
|
|
225
|
+
try {
|
|
226
|
+
if (opts.enable && opts.disable)
|
|
227
|
+
throw new Error("choose one of --enable or --disable");
|
|
228
|
+
if (!/^[a-f0-9]{24}$/.test(workerId))
|
|
229
|
+
throw new Error("worker ID must be the 24-character ID shown by 'dreamlake queues workers'");
|
|
230
|
+
const c = await context(opts);
|
|
231
|
+
const path = `${c.path}/${seg(prefix)}`;
|
|
232
|
+
const mount = await requestJson(c.remote, path, { token: c.token });
|
|
233
|
+
const worker = `${path}/proxy/v1/namespaces/${seg(mount.lakeshoreNs)}/workers/${seg(workerId)}`;
|
|
234
|
+
if (opts.enable || opts.disable) {
|
|
235
|
+
await requestJson(c.remote, `${worker}/claim-jobs`, { token: c.token, method: "POST", json: { enabled: !!opts.enable } });
|
|
236
|
+
}
|
|
237
|
+
// Report what the control plane stores, not what was requested.
|
|
238
|
+
const view = await requestJson(c.remote, worker, { token: c.token });
|
|
239
|
+
if (typeof view.claimJobs !== "boolean") {
|
|
240
|
+
throw new Error("this Lakeshore control plane does not report claimJobs; it predates the worker job-claim switch");
|
|
241
|
+
}
|
|
242
|
+
const result = { workerId: view.id ?? workerId, label: view.label ?? null, state: view.state ?? null, claimJobs: view.claimJobs };
|
|
243
|
+
if (opts.json)
|
|
244
|
+
emitJson(result);
|
|
245
|
+
else
|
|
246
|
+
process.stdout.write(`${result.label ?? result.workerId}: business job claims ${result.claimJobs ? "enabled" : "disabled"}`
|
|
247
|
+
+ (result.claimJobs ? "" : " (heartbeat, control and remote exec continue)") + "\n");
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
return error(err);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
222
254
|
export function registerQueuesCommand(program) {
|
|
223
255
|
const queues = program.command("queues").description("mount Lakeshore servers and view live queues through DreamLake");
|
|
224
256
|
registerSlurmCommands(queues);
|
|
@@ -241,6 +273,10 @@ export function registerQueuesCommand(program) {
|
|
|
241
273
|
.action(async (prefix, opts) => { process.exitCode = await runQueuesToken(prefix, opts); });
|
|
242
274
|
common(queues.command("workers <prefix>").description("view workers on a mounted server"))
|
|
243
275
|
.action(async (prefix, opts) => { process.exitCode = await runQueuesResources(prefix, "workers", opts); });
|
|
276
|
+
common(queues.command("worker-claims <prefix> <worker-id>").description("show or set whether one worker claims new jobs; exec and heartbeat continue")
|
|
277
|
+
.option("--disable", "stop claiming new jobs from every queue")
|
|
278
|
+
.option("--enable", "resume claiming jobs"))
|
|
279
|
+
.action(async (prefix, workerId, opts) => { process.exitCode = await runQueuesWorkerClaims(prefix, workerId, opts); });
|
|
244
280
|
common(queues.command("jobs <prefix>").description("view jobs on a mounted server").option("--limit <count>", "maximum jobs").option("--offset <count>", "pagination offset"))
|
|
245
281
|
.action(async (prefix, opts) => { process.exitCode = await runQueuesResources(prefix, "jobs", opts); });
|
|
246
282
|
common(collectionList(queues, "list <prefix>").description("list live queues on a mounted server"))
|
|
@@ -69,7 +69,10 @@ export function registerSessionsCommand(program) {
|
|
|
69
69
|
common(collectionList(group, 'list').description('list saved descriptors; this does not probe or start remote processes'))
|
|
70
70
|
.option('--page-size <count>', 'bounded registry page size, 1–100')
|
|
71
71
|
.option('--cursor <cursor>', 'continue a registry page using its nextCursor')
|
|
72
|
-
.option('--query <text>', 'search
|
|
72
|
+
.option('--query <text>', 'search session metadata and uploaded conversation text')
|
|
73
|
+
.option('--scope <scope>', 'mine (default) or available; never expands after no matches')
|
|
74
|
+
.option('--owner <namespace>', 'explicitly search readable sessions of this person')
|
|
75
|
+
.option('--team <slug-or-id>', 'explicitly search sessions shared with this organization')
|
|
73
76
|
.option('--machine <id...>', 'filter exact machine IDs')
|
|
74
77
|
.option('--sort <order>', 'created or recent observed activity')
|
|
75
78
|
.option('--archived <mode>', 'exclude (default), include, or only archived sessions')
|
|
@@ -86,18 +89,26 @@ export function registerSessionsCommand(program) {
|
|
|
86
89
|
throw new Error('--query must contain at most 200 printable characters');
|
|
87
90
|
if (opts.machine && (opts.machine.length > 32 || opts.machine.some((m) => !m || m.length > 512 || /[\x00-\x1f\x7f]/.test(m))))
|
|
88
91
|
throw new Error('Use up to 32 exact printable machine IDs');
|
|
92
|
+
if (opts.scope !== undefined && !['mine', 'available'].includes(opts.scope))
|
|
93
|
+
throw new Error('--scope must be mine or available');
|
|
94
|
+
if (opts.scope === 'mine' && (opts.owner || opts.team))
|
|
95
|
+
throw new Error('--owner/--team cannot combine with --scope mine');
|
|
96
|
+
for (const value of [opts.owner, opts.team])
|
|
97
|
+
if (value !== undefined && !/^@?[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value))
|
|
98
|
+
throw new Error('use an exact owner namespace or organization slug/id');
|
|
99
|
+
const expanded = opts.scope === 'available' || !!opts.owner || !!opts.team;
|
|
89
100
|
const query = new URLSearchParams();
|
|
90
|
-
for (const [name, value] of [['pageSize', opts.pageSize], ['cursor', opts.cursor], ['q', opts.query], ['sort', opts.sort], ['archived', opts.archived]])
|
|
101
|
+
for (const [name, value] of [['pageSize', opts.pageSize], ['cursor', opts.cursor], ['q', opts.query], ['sort', opts.sort], ['archived', opts.archived], ['owner', opts.owner?.replace(/^@/, '')], ['team', opts.team]])
|
|
91
102
|
if (value !== undefined)
|
|
92
103
|
query.set(name, value);
|
|
93
104
|
for (const machine of opts.machine ?? [])
|
|
94
105
|
query.append('machineId', machine);
|
|
95
|
-
const ns = await resolveHostNamespace(opts.namespace), result = await requestJson(connection(), sessionPath(ns) + (query.size ? '?' + query.toString() : ''));
|
|
106
|
+
const ns = await resolveHostNamespace(opts.namespace), result = await requestJson(connection(), (expanded ? '/terminal-sessions/available' : sessionPath(ns)) + (query.size ? '?' + query.toString() : ''));
|
|
96
107
|
if (!Array.isArray(result?.sessions))
|
|
97
108
|
throw new Error('Terminal API returned an invalid session list');
|
|
98
109
|
const sessions = result.sessions.map(readSession);
|
|
99
110
|
const nextCursor = typeof result.nextCursor === 'string' && /^[A-Za-z0-9_-]{1,1024}$/.test(result.nextCursor) ? result.nextCursor : null;
|
|
100
|
-
console.log(opts.json ? JSON.stringify({ namespace: ns, sessions, hasMore: result.hasMore === true, nextCursor }, null, 2) : (sessions.map(summary).join('\n') || 'No saved terminal sessions.') + (result.hasMore === true ? `\nAdditional saved sessions exist.${nextCursor ? ` Continue with --cursor ${nextCursor} and the same filters/sort.` : ' Server did not return a continuation cursor.'}` : ''));
|
|
111
|
+
console.log(opts.json ? JSON.stringify({ namespace: ns, scope: expanded ? 'available' : 'mine', owner: opts.owner ?? null, team: opts.team ?? null, sessions, hasMore: result.hasMore === true, nextCursor }, null, 2) : (sessions.map(summary).join('\n') || 'No saved terminal sessions.') + (result.hasMore === true ? `\nAdditional saved sessions exist.${nextCursor ? ` Continue with --cursor ${nextCursor} and the same filters/sort.` : ' Server did not return a continuation cursor.'}` : ''));
|
|
101
112
|
}));
|
|
102
113
|
common(group.command('show <id>').description('show one saved terminal descriptor')).option('--json').action((id, opts) => run(opts, async () => {
|
|
103
114
|
const ns = await resolveHostNamespace(opts.namespace), session = readSession((await requestJson(connection(), sessionPath(ns, id) + '/metadata')).session);
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.92.0";
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.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.
|
|
39
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.
|
|
40
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.
|
|
41
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.
|
|
42
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.
|
|
43
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.
|
|
44
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.
|
|
45
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.
|
|
38
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.92.0",
|
|
39
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.92.0",
|
|
40
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.92.0",
|
|
41
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.92.0",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.92.0",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.92.0",
|
|
44
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.92.0",
|
|
45
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.92.0"
|
|
46
46
|
}
|
|
47
47
|
}
|