@dreamlake/dreamlake-cli 0.90.0 → 0.91.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.
@@ -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").ListSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
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;
@@ -1565,7 +1566,7 @@ export declare function createClient(options: ClientOptions): {
1565
1566
  id: string;
1566
1567
  }) => Promise<unknown>;
1567
1568
  list: (query?: import("./sessions.js").ListSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
1568
- available: (query?: import("./sessions.js").ListSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
1569
+ available: (query?: import("./sessions.js").AvailableSessionsQuery) => Promise<import("./sessions.js").SessionPage>;
1569
1570
  get: (sessionId: string) => Promise<import("./sessions.js").Session>;
1570
1571
  conversation: (sessionId: string) => Promise<{
1571
1572
  conversation: import("./sessions.js").Conversation | null;
@@ -1812,6 +1813,7 @@ export declare function createClient(options: ClientOptions): {
1812
1813
  };
1813
1814
  media: (form: FormData) => Promise<import("./notes.js").NoteMediaReceipt>;
1814
1815
  read: (noteId: string, query?: import("./common.js").Query) => Promise<import("./notes.js").NoteReadResult>;
1816
+ readView: (noteId: string, options?: import("./note-reading.js").NoteReadingOptions) => Promise<import("./note-reading.js").NoteReadingPage>;
1815
1817
  html: (noteId: string, options?: {
1816
1818
  at?: string;
1817
1819
  section?: string;
@@ -2360,3 +2362,4 @@ export * from "./note-html-read.js";
2360
2362
  export { characterDiff, NotePatchError, PATCH_LIMITS, } from "./note-character-plan.js";
2361
2363
  export * from "./presigned-transfer.js";
2362
2364
  export * from "./note-events.js";
2365
+ 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
+ }
@@ -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");
@@ -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?: ListSessionsQuery) => Promise<SessionPage>;
197
+ available: (query?: AvailableSessionsQuery) => Promise<SessionPage>;
193
198
  get: (sessionId: string) => Promise<Session>;
194
199
  conversation: (sessionId: string) => Promise<{
195
200
  conversation: Conversation | null;
@@ -1,4 +1,5 @@
1
- import { validateHtmlSnapshot, annotatedMarkdown } from "./html-read.js";
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 === "html" || opts.view === "markdown") {
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(opts.view === "markdown" ? annotatedMarkdown(html) : bytes);
213
+ process.stdout.write(bytes);
189
214
  return 0;
190
215
  }
191
216
  if (opts.since !== undefined) {
@@ -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 saved session and repository metadata')
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);
@@ -1 +1 @@
1
- export declare const VERSION = "0.90.0";
1
+ export declare const VERSION = "0.91.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.90.0";
9
+ export const VERSION = "0.91.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.90.0",
3
+ "version": "0.91.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.90.0",
39
- "@dreamlake/dreamlake-cli-darwin-x64": "0.90.0",
40
- "@dreamlake/dreamlake-cli-linux-x64": "0.90.0",
41
- "@dreamlake/dreamlake-cli-linux-arm64": "0.90.0",
42
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.90.0",
43
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.90.0",
44
- "@dreamlake/dreamlake-cli-win32-x64": "0.90.0",
45
- "@dreamlake/dreamlake-cli-win32-arm64": "0.90.0"
38
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.91.0",
39
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.91.0",
40
+ "@dreamlake/dreamlake-cli-linux-x64": "0.91.0",
41
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.91.0",
42
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.91.0",
43
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.91.0",
44
+ "@dreamlake/dreamlake-cli-win32-x64": "0.91.0",
45
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.91.0"
46
46
  }
47
47
  }