@dreamlake/dreamlake-cli 0.113.0 → 0.115.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.
@@ -674,6 +674,7 @@ export declare function createApi(transport: Transport): {
674
674
  visibility?: string;
675
675
  provider?: import("./sessions.js").Provider;
676
676
  claudeConfigDir?: string;
677
+ codexHome?: string;
677
678
  }) => Promise<unknown>;
678
679
  get: (id: string) => Promise<unknown>;
679
680
  metadata: (id: string, input: Record<string, unknown>) => Promise<unknown>;
@@ -1961,6 +1962,7 @@ export declare function createClient(options: ClientOptions): {
1961
1962
  visibility?: string;
1962
1963
  provider?: import("./sessions.js").Provider;
1963
1964
  claudeConfigDir?: string;
1965
+ codexHome?: string;
1964
1966
  }) => Promise<unknown>;
1965
1967
  get: (id: string) => Promise<unknown>;
1966
1968
  metadata: (id: string, input: Record<string, unknown>) => Promise<unknown>;
@@ -178,9 +178,21 @@ export interface Session {
178
178
  provider: Provider | "dreamlake-agent";
179
179
  cwd: string;
180
180
  codexSessionId: string;
181
+ /** Canonical absolute Codex state root on the enrolled host. Absent/null keeps legacy binding. */
182
+ codexHome?: string | null;
181
183
  vendorSessionId?: string;
182
184
  runState: RunState;
183
185
  runStateObservedAt: string | null;
186
+ /** Last observed state and outstanding attention remain available when runState becomes stale. */
187
+ lastRunState?: RunState | null;
188
+ attention?: "needs_input" | "error" | null;
189
+ metadataObservedAt?: string | null;
190
+ targetId?: string | null;
191
+ enrollmentId?: string | null;
192
+ hostId?: string | null;
193
+ machineId?: string | null;
194
+ username?: string | null;
195
+ tmuxSession?: string | null;
184
196
  lastActivityAt: string | null;
185
197
  createdAt: string;
186
198
  repositoryRoot: string | null;
@@ -228,6 +240,7 @@ export type ListSessionsQuery = {
228
240
  pageSize?: number;
229
241
  cursor?: string;
230
242
  q?: string;
243
+ searchIn?: "title" | "all";
231
244
  provider?: Provider | "dreamlake-agent";
232
245
  sort?: "created" | "recent";
233
246
  archived?: "exclude" | "include" | "only";
@@ -521,6 +534,8 @@ export declare function terminalApi(t: Transport, namespace: string): {
521
534
  visibility?: string;
522
535
  provider?: Provider;
523
536
  claudeConfigDir?: string;
537
+ /** Codex only: canonical absolute root owned by the enrolled Unix user; requires API support. */
538
+ codexHome?: string;
524
539
  }) => Promise<unknown>;
525
540
  get: (id: string) => Promise<unknown>;
526
541
  metadata: (id: string, input: Record<string, unknown>) => Promise<unknown>;
@@ -123,6 +123,7 @@ export const helpExamples = {
123
123
  "memos select": "export DREAMLAKE_AGENT_ID=\"review-session-42\"\nexport DREAMLAKE_AGENT_NAME=\"Codex\"\nMEMO_ID=\"your-note-id\"\ndl memos select --text \"The next step is tested in simulation.\" --note \"$MEMO_ID\"\n# Select the last occurrence of a repeated passage.\ndl memos select --text \"simulation\" --note \"$MEMO_ID\" -o -1",
124
124
  "memos contributors": "dl memos contributors release-plan --namespace geyang --json\n# If hasMore is true, continue with the returned nextCursor:\ndl memos contributors release-plan --namespace geyang --cursor LINK_CURSOR --json",
125
125
  "memos rm": "# Read it first and confirm it is the note you mean.\ndl memos read MEMO_ID\n# Asks for confirmation, showing the title and owning namespace.\ndl memos rm MEMO_ID\n# Scripts and agents: skip the prompt and take a JSON receipt.\ndl memos rm MEMO_ID --yes --json\n# Afterwards a read reports not found.\ndl memos read MEMO_ID",
126
+ "memos revise": "dl memos read MEMO_ID --json > baseline.json\n# Review baseline.json and prepare proposed.md from its exact content.\ndl memos revise MEMO_ID --baseline baseline.json --file proposed.md \\\n --intent \"Clarify the proposed evaluation criteria.\" --label evaluation-criteria \\\n --receipt revision-receipt.json",
126
127
  "memos patch": "set -euo pipefail\ndl memos create \"Patch tutorial\" --text 'Hello world.' > created.txt\nMEMO_ID=$(sed -n 's/^ id //p' created.txt)\ndl memos read \"$MEMO_ID\" --view source --json > baseline.json\n# A plain text read is the mapped reading view and --view source is bytes only;\n# --json is the structured snapshot with note, hash and revision.\nBASE=$(jq -er .revision baseline.json)\ndl memos patch \"$MEMO_ID\" --file - --base-revision \"$BASE\" --json > receipt.json <<'PATCH'\n@@ chars 0:12 @@\n~ Hello [-world-]{+team+}.\nPATCH\nACK=$(jq -er .revision receipt.json)\ndl memos read \"$MEMO_ID\" --if-match \"$ACK\"\n# Expect Hello team. Inspect the result; do not repeat a successful patch.",
127
128
  "memos append": "dl memos append \"$MEMO_ID\" --file addition.md --base-revision \"$BASE\" --json\n# ACK is the revision in the successful append receipt.\ndl memos read \"$MEMO_ID\" --at \"$ACK\"",
128
129
  "memos insert": "dl memos insert --note \"$MEMO_ID\" --ind 0 --text 'Review: ' \\\n --base-revision \"$BASE\" --json\n# ACK is the revision returned by the insertion receipt.\ndl memos read \"$MEMO_ID\" --at \"$ACK\"",
@@ -220,6 +221,7 @@ export const helpExamples = {
220
221
  "sessions stop": "dl sessions stop SESSION_ID --namespace geyang --yes --json",
221
222
  "sessions sync": "dl sessions sync --namespace geyang --target TARGET_ID --json\ndl sessions sync --namespace geyang --all --json",
222
223
  "sessions upload-conversation": "dl sessions upload-conversation SESSION_ID --namespace geyang \\\n --file /absolute/path/to/conversation.jsonl --json",
224
+ "sessions search": "dl sess search \"tmux\"\ndl session search \"release\" --machine MACHINE_ID --sort recent\ndl sess search \"release\" --search-in title\ndl sessions search \"RTC\" --owner geyang --page-size 25 --json",
223
225
  "sessions serve": "dl sessions serve\n# Handle one command and exit (useful in scripts and tests):\ndl sessions serve --once --json\n# Let a person raise sessions on this runner up to full access (control restart --raise):\ndl sessions serve --max-human-permission full-access",
224
226
  "sessions runners": "dl sessions runners",
225
227
  "sessions control start": "dl sessions control start --provider claude --repo /abs/repo --isolation worktree --branch feat/x --permission workspace-write --prompt \"Run the tests and report\" --name \"Test runner\"\n# Reuse the checkout as is, headless:\ndl sessions control start --provider codex --repo /abs/repo --isolation repo --permission read-only --mode headless --prompt \"Summarize open TODOs\"",
@@ -8,6 +8,7 @@ import { registerCoverCommand } from "./cover-command.js";
8
8
  import { registerPermalinkCommand } from "./permalink-command.js";
9
9
  import { registerArchiveCommands } from "./archive-command.js";
10
10
  import { registerRmCommand } from "./rm-command.js";
11
+ import { registerReviseCommand } from "./revise.js";
11
12
  import { registerSuggestDiffCommand } from "./suggest-diff.js";
12
13
  import { registerShareCommands } from "../share.js";
13
14
  import { runMemosTextSelect } from "./select-command.js";
@@ -206,6 +207,7 @@ export function registerMemosCommand(program) {
206
207
  registerPermalinkCommand(notes);
207
208
  registerCoverCommand(notes);
208
209
  registerSuggestDiffCommand(notes);
210
+ registerReviseCommand(notes);
209
211
  // Same connection flags as the other ported groups, so --debug/--remote
210
212
  // behave identically across the CLI.
211
213
  const strict = (cmd) => withConnFlags(cmd.allowExcessArguments(false));
@@ -0,0 +1,22 @@
1
+ import type { Command } from 'commander';
2
+ import { type ConnOpts } from './index.js';
3
+ import type { MemoSource } from '../../api/memo-edits.js';
4
+ export interface ReviseOptions extends ConnOpts {
5
+ baseline: string;
6
+ file: string;
7
+ label: string;
8
+ intent: string;
9
+ receipt: string;
10
+ direct?: boolean;
11
+ allowReferenceChanges?: boolean;
12
+ dryRun?: boolean;
13
+ json?: boolean;
14
+ }
15
+ export declare function resourceAtoms(text: string): string[];
16
+ export declare function revisionBody(source: MemoSource, draft: string, options: {
17
+ direct?: boolean;
18
+ allowReferenceChanges?: boolean;
19
+ }): string;
20
+ /** Durable stages are evidence, never an automatic replay instruction. */
21
+ export declare function runMemosRevise(ref: string, opts: ReviseOptions): Promise<number>;
22
+ export declare function registerReviseCommand(memos: Command): void;
@@ -0,0 +1,154 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { readFileSync, writeFileSync, openSync, fsyncSync, closeSync, renameSync } from 'node:fs';
3
+ import { withConnFlags } from '../compat/flags.js';
4
+ import { requestJson } from '../client.js';
5
+ import { emitJson, fail } from '../helpers.js';
6
+ import { ctx, resolveNote, seg } from './index.js';
7
+ import { tokens, readDocumentSnapshot, submitDocumentPatch } from './document.js';
8
+ import { writePlan } from '../../api/memo-write.js';
9
+ import { memoPresenceApi, memoPresenceIntent } from '../../api/memo-presence.js';
10
+ import { memoTransport } from './api-transport.js';
11
+ import { suggestDiff } from './suggest-diff.js';
12
+ const hash = (text) => 'sha256:' + createHash('sha256').update(text, 'utf8').digest('hex');
13
+ // Keep resource atoms byte-for-byte, including attributes/fragments and legacy forms.
14
+ // Conservative even inside code: intentional changes use the explicit override.
15
+ export function resourceAtoms(text) {
16
+ return text.match(/:(?:note|artifact|dashboard|experiment|project|folder|bindr|asset-reference)\[(?:\\.|[^\]\\])*\](?:\{(?:\\.|[^}\\])*\})?|:(?:note|artifact)\{(?:\\.|[^}\\])*\}|#(?:note|artifact):[^\s)<>]+/g) ?? [];
17
+ }
18
+ export function revisionBody(source, draft, options) {
19
+ tokens(source, source.note);
20
+ if (hash(source.content) !== source.hash)
21
+ throw new Error('baseline content does not match its hash');
22
+ if (!options.allowReferenceChanges) {
23
+ const available = resourceAtoms(draft);
24
+ for (const atom of resourceAtoms(source.content)) {
25
+ const index = available.indexOf(atom);
26
+ if (index < 0)
27
+ throw new Error('draft removes or rewrites a native resource reference; preserve its exact source or use --allow-reference-changes for an intentional change');
28
+ available.splice(index, 1);
29
+ }
30
+ }
31
+ return options.direct ? draft : suggestDiff(source.content, draft, { inPlace: true }).markdown;
32
+ }
33
+ /** Durable stages are evidence, never an automatic replay instruction. */
34
+ export async function runMemosRevise(ref, opts) {
35
+ let journal;
36
+ const persist = (stage, fields = {}) => {
37
+ Object.assign(journal, fields, { stage });
38
+ const temporary = opts.receipt + '.' + randomUUID() + '.tmp';
39
+ const fd = openSync(temporary, 'wx', 0o600);
40
+ try {
41
+ writeFileSync(fd, JSON.stringify(journal, null, 2) + '\n');
42
+ fsyncSync(fd);
43
+ }
44
+ finally {
45
+ closeSync(fd);
46
+ }
47
+ renameSync(temporary, opts.receipt);
48
+ };
49
+ try {
50
+ if (!process.env.DREAMLAKE_AGENT_ID)
51
+ throw new Error('set DREAMLAKE_AGENT_ID to a stable task identity');
52
+ if (!memoPresenceIntent(opts.intent))
53
+ throw new Error('--intent is required');
54
+ if (!opts.label?.trim() || [...opts.label].length > 70)
55
+ throw new Error('--label requires 1–70 characters (before/after suffixes are added)');
56
+ const source = JSON.parse(readFileSync(opts.baseline, 'utf8'));
57
+ const body = revisionBody(source, new TextDecoder('utf-8', { fatal: true }).decode(readFileSync(opts.file)), opts);
58
+ const payload = { ...writePlan(source, body, 'exact'), commandId: 'revise:' + randomUUID() };
59
+ if (!payload.patch) {
60
+ emitJson({ noChange: true, note: source.note });
61
+ return 0;
62
+ }
63
+ const c = await ctx(opts);
64
+ if (!c)
65
+ return 1;
66
+ const id = await resolveNote(c, ref);
67
+ if (!id)
68
+ return 1;
69
+ if (id !== source.note)
70
+ throw new Error('baseline belongs to a different memo');
71
+ if (opts.dryRun) {
72
+ emitJson({ dryRun: true, body, payload });
73
+ return 0;
74
+ }
75
+ // Exclusive creation makes rerunning an accepted/ambiguous invocation fail closed.
76
+ // No remote side effects occur until this record exists.
77
+ const initial = { note: id, namespace: c.ns, remote: c.remote, baseline: source, intendedHash: hash(body), payload, stage: 'prepared' };
78
+ const fd = openSync(opts.receipt, 'wx', 0o600);
79
+ try {
80
+ writeFileSync(fd, JSON.stringify(initial, null, 2) + '\n');
81
+ fsyncSync(fd);
82
+ }
83
+ finally {
84
+ closeSync(fd);
85
+ }
86
+ journal = initial;
87
+ await memoPresenceApi(memoTransport(c), `/namespaces/${seg(c.ns)}/notes`).visit(id, { intent: opts.intent });
88
+ const live = await readDocumentSnapshot(c, id);
89
+ if (live.revision !== source.revision || live.hash !== source.hash)
90
+ throw new Error('memo changed since the reviewed baseline; reconcile before revising');
91
+ const path = `/namespaces/${seg(c.ns)}/notes/${seg(id)}/versions`;
92
+ const checkpoint = async (snapshot, suffix, parentId) => {
93
+ const version = await requestJson(c.remote, path, {
94
+ token: c.token, method: 'POST', redirect: 'error', json: {
95
+ revision: snapshot.revision, hash: snapshot.hash.slice(7), tag: opts.label + '-' + suffix,
96
+ summary: opts.intent, ...(parentId ? { parentId } : {}),
97
+ },
98
+ });
99
+ persist(suffix + '-saved', { [suffix]: version });
100
+ if (!/^v_[0-9]{13}_[a-f0-9-]{36}$/.test(version.id) || version.hash !== snapshot.hash.slice(7) || version.revision !== snapshot.revision)
101
+ throw new Error('version receipt does not identify the reviewed revision; this server must preserve the requested opaque revision in version provenance');
102
+ const saved = await requestJson(c.remote, path + '/' + seg(version.id), { token: c.token });
103
+ if (saved.id !== version.id || saved.revision !== snapshot.revision || saved.text !== snapshot.content || hash(saved.text) !== snapshot.hash || saved.hash !== version.hash)
104
+ throw new Error('immutable version readback differs from reviewed source');
105
+ return version.id;
106
+ };
107
+ persist('before-saving');
108
+ const before = await checkpoint(source, 'before');
109
+ persist('write-submitting');
110
+ const receipt = await submitDocumentPatch(c, id, payload);
111
+ persist('write-acknowledged', { write: receipt });
112
+ const result = await readDocumentSnapshot(c, id, receipt.revision);
113
+ if (result.content !== body || result.hash !== hash(body))
114
+ throw new Error('acknowledged source differs from the intended revision');
115
+ // Do not checkpoint a concurrent later draft under this operation's label.
116
+ const current = await readDocumentSnapshot(c, id);
117
+ if (current.revision !== result.revision)
118
+ throw new Error('another edit followed the acknowledged write; preserve the receipt and recover its retained revision separately');
119
+ persist('after-saving');
120
+ await checkpoint(result, 'after', before);
121
+ persist('complete');
122
+ emitJson(journal);
123
+ return 0;
124
+ }
125
+ catch (error) {
126
+ const message = error instanceof Error ? error.message : String(error);
127
+ if (journal) {
128
+ try {
129
+ persist(String(journal.stage), { error: message });
130
+ }
131
+ catch {
132
+ fail('Could not update the receipt; preserve the existing file and inspect remote state before another operation.');
133
+ }
134
+ emitJson(journal);
135
+ fail(`Revision stopped; inspect ${opts.receipt}. Never rerun the content write to recover metadata. For write-submitting inspect memos command-status with the recorded commandId; for version stages inspect memos hist and read immutable IDs before saving anything else.`);
136
+ }
137
+ else
138
+ fail(message);
139
+ return 1;
140
+ }
141
+ }
142
+ export function registerReviseCommand(memos) {
143
+ withConnFlags(memos.command('revise').description('revise reviewed source with pending redlines, intent and verified before/after versions')
144
+ .argument('<memo>')
145
+ .requiredOption('--baseline <path>', 'reviewed complete memos read --json snapshot')
146
+ .requiredOption('--file <path>', 'proposed complete Markdown source')
147
+ .requiredOption('--label <text>', 'meaningful checkpoint label; adds -before and -after')
148
+ .requiredOption('--intent <text>', 'concrete purpose published to presence and version summaries')
149
+ .requiredOption('--receipt <path>', 'new durable local receipt file; existing files are never replayed')
150
+ .option('--direct', 'apply wording directly when the current instruction authorizes it')
151
+ .option('--allow-reference-changes', 'allow intentional resource directive changes')
152
+ .option('--namespace <slug>', 'memo owner namespace').option('--dry-run', 'preview without presence, versions or writes').option('--json', 'emit JSON'))
153
+ .action(async (ref, opts) => { process.exitCode = await runMemosRevise(ref, opts); });
154
+ }
@@ -1,6 +1,7 @@
1
1
  export interface SessionInput {
2
2
  provider?: 'codex' | 'claude';
3
3
  claudeConfigDir?: string;
4
+ codexHome?: string;
4
5
  targetId: string;
5
6
  enrollmentId: string;
6
7
  cwd: string;
@@ -18,9 +19,14 @@ export interface TerminalSession extends SessionInput {
18
19
  modelProvider?: string;
19
20
  runState?: 'unknown' | 'running' | 'working' | 'waiting' | 'idle' | 'error' | 'stopped';
20
21
  runStateObservedAt?: string | null;
22
+ lastRunState?: TerminalSession['runState'] | null;
23
+ attention?: 'needs_input' | 'error' | null;
24
+ metadataObservedAt?: string | null;
25
+ lastActivityAt?: string | null;
21
26
  launch: {
22
27
  kind: 'codex' | 'claude';
23
28
  claudeConfigDir?: string;
29
+ codexHome?: string;
24
30
  cwd: string;
25
31
  codexSessionId: string;
26
32
  enrollmentId: string;
@@ -10,6 +10,12 @@ export function sessionPath(namespace, id) {
10
10
  export function validateSessionInput(input) {
11
11
  if (input.provider !== undefined && !['codex', 'claude'].includes(input.provider))
12
12
  throw new Error('--provider must be codex or claude');
13
+ // This is a remote path: do not resolve it against the CLI user's filesystem or environment.
14
+ if (input.codexHome !== undefined && ((input.provider ?? 'codex') !== 'codex' || typeof input.codexHome !== 'string' ||
15
+ !input.codexHome.startsWith('/') || Buffer.byteLength(input.codexHome) > 4096 || /[\x00-\x1f\x7f]/.test(input.codexHome) ||
16
+ (input.codexHome !== '/' && input.codexHome.slice(1).split('/').some(part => !part || part === '.' || part === '..')))) {
17
+ throw new Error('codexHome requires Codex and a canonical absolute target-host path');
18
+ }
13
19
  if (input.claudeConfigDir !== undefined && (input.provider !== 'claude' || typeof input.claudeConfigDir !== 'string' || !input.claudeConfigDir.startsWith('/') || Buffer.byteLength(input.claudeConfigDir) > 4096 || /[\x00-\x1f\x7f]/.test(input.claudeConfigDir)))
14
20
  throw new Error('--claude-config-dir requires Claude and an absolute path');
15
21
  if (!/^[A-Za-z0-9_-]{1,128}$/.test(input.targetId))
@@ -79,10 +85,12 @@ export function readSession(value) {
79
85
  if (!value || !validId(value.id) || !validId(value.enrollmentId) || typeof value.targetId !== 'string' ||
80
86
  typeof value.name !== 'string' || typeof value.username !== 'string' || typeof value.machineId !== 'string' ||
81
87
  typeof value.cwd !== 'string' || typeof value.codexSessionId !== 'string' || typeof value.tmuxSession !== 'string' ||
82
- value.launch?.kind !== (value.provider ?? 'codex') || (value.launch?.claudeConfigDir ?? null) !== (value.claudeConfigDir ?? null) || value.launch.cwd !== value.cwd || value.launch.codexSessionId !== value.codexSessionId || value.launch.enrollmentId !== value.enrollmentId) {
88
+ value.launch?.kind !== (value.provider ?? 'codex') || (value.launch?.claudeConfigDir ?? null) !== (value.claudeConfigDir ?? null) ||
89
+ value.launch?.codexHome === null || (value.launch?.codexHome ?? null) !== (value.codexHome ?? null) ||
90
+ value.launch.cwd !== value.cwd || value.launch.codexSessionId !== value.codexSessionId || value.launch.enrollmentId !== value.enrollmentId) {
83
91
  throw new Error('Terminal API returned an invalid session descriptor');
84
92
  }
85
- validateSessionInput({ ...value, ...(value.claudeConfigDir === null ? { claudeConfigDir: undefined } : {}) });
93
+ validateSessionInput({ ...value, ...(value.claudeConfigDir === null ? { claudeConfigDir: undefined } : {}), ...(value.codexHome === null ? { codexHome: undefined } : {}) });
86
94
  // Do not forward unknown launch fields into an execution request.
87
- return { ...value, launch: { kind: value.provider ?? 'codex', ...(value.claudeConfigDir === undefined || value.claudeConfigDir === null ? {} : { claudeConfigDir: value.claudeConfigDir }), cwd: value.cwd, codexSessionId: value.codexSessionId, enrollmentId: value.enrollmentId } };
95
+ return { ...value, launch: { kind: value.provider ?? 'codex', ...(value.claudeConfigDir === undefined || value.claudeConfigDir === null ? {} : { claudeConfigDir: value.claudeConfigDir }), ...(value.codexHome === undefined || value.codexHome === null ? {} : { codexHome: value.codexHome }), cwd: value.cwd, codexSessionId: value.codexSessionId, enrollmentId: value.enrollmentId } };
88
96
  }
@@ -126,7 +126,7 @@ export function registerSessionControl(group) {
126
126
  throw new Error('Stopping ends the agent process. Pass --yes to confirm'); return submit(opts, 'stop', { sessionId: needId(id) }); }));
127
127
  waitOption(common(control.command('send <id> <text>').description('send a message to a session (typed into tmux, or one headless resumed turn)'))).option('--permission <level>', 'permission ceiling for a headless turn (default: the level recorded at start)')
128
128
  .action((id, text, opts) => guard(opts, () => submit(opts, 'send', { sessionId: needId(id), text, ...level(opts.permission) })));
129
- common(control.command('broadcast <text>').description('send the same message to several sessions')).requiredOption('--session <id...>', 'session ids')
129
+ common(control.command('broadcast <text>').description('send the same message to several sessions')).requiredOption('--sess, --session <id...>', 'session ids')
130
130
  .action((text, opts) => guard(opts, async () => {
131
131
  const ns = await resolveHostNamespace(opts.namespace);
132
132
  const ids = opts.session.map(needId);
@@ -138,7 +138,7 @@ export function registerSessionControl(group) {
138
138
  common(control.command('wait <command-id>').description('wait for a command receipt')).option('--wait <seconds>', 'seconds', '60')
139
139
  .action((id, opts) => guard(opts, async () => { const ns = await resolveHostNamespace(opts.namespace); emit({ namespace: ns, command: await client().sessions(ns).commands.wait(needId(id), Number(opts.wait)) }, !!opts.json); }));
140
140
  common(control.command('cancel <command-id>').description('cancel pending work or request interruption of running work')).action((id, opts) => guard(opts, async () => { const ns = await resolveHostNamespace(opts.namespace); emit({ namespace: ns, command: await client().sessions(ns).commands.cancel(needId(id)) }, !!opts.json); }));
141
- common(control.command('list').description('list recent commands and their receipts')).option('--session <id>').option('--status <status>').option('--limit <n>', 'max 100', '25')
141
+ common(control.command('list').description('list recent commands and their receipts')).option('--sess, --session <id>').option('--status <status>').option('--limit <n>', 'max 100', '25')
142
142
  .action(opts => guard(opts, async () => { const ns = await resolveHostNamespace(opts.namespace); emit({ namespace: ns, ...(await client().sessions(ns).commands.list({ ...(opts.session ? { sessionId: needId(opts.session) } : {}), ...(opts.status ? { status: opts.status } : {}), limit: Number(opts.limit) })) }, !!opts.json); }));
143
143
  common(group.command('children <id>').description('list managed child sessions; control each child by its stable session ID')).option('--cursor <cursor>').action((id, opts) => guard(opts, async () => { const ns = await resolveHostNamespace(opts.namespace); emit(await client().sessions(ns).list({ parentSessionId: needId(id), cursor: opts.cursor, archived: 'include' }), !!opts.json); }));
144
144
  common(group.command('permission <id> <level>').description('move the recorded permission level of a session without a runner round-trip; the running process keeps its level until the next resume or restart'))
@@ -10,7 +10,7 @@ import { registerSessionControl } from './control.js';
10
10
  import { registerSessionLive } from './live.js';
11
11
  // Tolerates the fields a registered (host-less) descriptor leaves empty.
12
12
  const cell = (value) => String(value ?? '').replace(/[\x00-\x1f\x7f-\x9f]/g, ' ');
13
- const summary = (s) => `${cell(s.id)} ${cell(s.name)}\n ${cell(s.username)}@${cell(s.machineId)} ${cell(s.cwd)}\n ${s.provider === 'claude' ? 'Claude' : 'Codex'} ${cell(s.codexSessionId)}${s.runState ? ` · ${cell(s.runState)}` : ''}`;
13
+ const summary = (s) => `${cell(s.id)} ${cell(s.name)}\n ${cell(s.username)}@${cell(s.machineId)} ${cell(s.cwd)}\n ${s.provider === 'claude' ? 'Claude' : 'Codex'} ${cell(s.codexSessionId)}${s.runState ? ` · ${cell(s.runState)}` : ''}${s.lastRunState && s.lastRunState !== s.runState ? ` (last observed ${cell(s.lastRunState)})` : ''}${s.runStateObservedAt ? ` at ${cell(s.runStateObservedAt)}` : ''}${s.attention ? `\n Attention: ${cell(s.attention)}` : ''}`;
14
14
  const runtimeSummary = (s, r) => `${summary(s)}\n Runtime: ${r.kind === 'direct' ? 'Direct' : `tmux ${cell(s.tmuxSession)}`}\n State: ${r.status}${r.reason ? ` (${r.reason})` : ''} · managed: ${r.managed ? 'yes' : 'no'} · viewers: ${r.clients ?? 'unknown'}\n Observed: ${r.observedAt}${r.pane ? ` · pane ${r.pane.id} · PID ${r.pane.pid}` : ''}`;
15
15
  /** What the session is doing now, from its hooks or runner (`liveState`), next to the Nymph/runner `runState`. */
16
16
  const liveSummary = (s) => {
@@ -23,7 +23,7 @@ const openingMessage = (id, kind) => kind === 'direct'
23
23
  ? `Opening session ${id} directly. Ctrl-] disconnects; disconnecting may end the process. Use sessions open to resume explicitly.`
24
24
  : `Opening session ${id}. Ctrl-] detaches; reopen the same ID to reattach.`;
25
25
  export function registerSessionsCommand(program) {
26
- const group = program.command('sessions').description('save and reopen agent terminal sessions on an explicitly selected enrolled host');
26
+ const group = program.command('sessions').aliases(['session', 'sess']).description('save and reopen agent terminal sessions on an explicitly selected enrolled host');
27
27
  registerSessionAffiliations(group);
28
28
  registerSessionConversation(group);
29
29
  registerSessionControl(group);
@@ -45,7 +45,7 @@ export function registerSessionsCommand(program) {
45
45
  }
46
46
  };
47
47
  group.command('register').description('register native session metadata without an enrolled host or terminal launch; idempotent for the same provider and native UUID')
48
- .requiredOption('--provider <provider>', 'codex or claude').requiredOption('--session <uuid>', 'native conversation UUID')
48
+ .requiredOption('--provider <provider>', 'codex or claude').requiredOption('--sess, --session <uuid>', 'native conversation UUID')
49
49
  .requiredOption('--cwd <path>', 'original absolute working directory').option('--name <name>')
50
50
  .option('--visibility <visibility>', 'public (default for new sessions) or private')
51
51
  .option('--write-env <path>', 'write DREAMLAKE_TERMINAL_SESSION_ID and DREAMLAKE_SESSION_NAMESPACE (mode 600) so a shell that sources it links its memo and artifact writes to this session')
@@ -101,17 +101,20 @@ export function registerSessionsCommand(program) {
101
101
  throw new Error('Terminal API returned an invalid target');
102
102
  console.log(opts.json ? JSON.stringify({ namespace: ns, targets }, null, 2) : targets.map(t => `${cell(t.id)} ${cell(t.name)} ${cell(t.username)}@${cell(t.machineId)}\n enrollment: ${cell(t.enrollmentId ?? 'unavailable (cannot save session)')}`).join('\n') || 'No available terminal targets.');
103
103
  }));
104
- common(collectionList(group, 'list').description('list saved descriptors; this does not probe or start remote processes'))
104
+ const listing = (command) => common(command)
105
+ .option('--search-in <scope>', 'title or all; default all includes metadata and uploaded conversation text')
105
106
  .option('--page-size <count>', 'bounded registry page size, 1–100')
106
107
  .option('--cursor <cursor>', 'continue a registry page using its nextCursor')
107
- .option('--query <text>', 'search session metadata and uploaded conversation text')
108
108
  .option('--scope <scope>', 'mine (default) or available; never expands after no matches')
109
109
  .option('--owner <namespace>', 'explicitly search readable sessions of this person')
110
110
  .option('--team <slug-or-id>', 'explicitly search sessions shared with this organization')
111
111
  .option('--machine <id...>', 'filter exact machine IDs')
112
112
  .option('--sort <order>', 'created or recent observed activity')
113
113
  .option('--archived <mode>', 'exclude (default), include, or only archived sessions')
114
- .option('--json').action(opts => run(opts, async () => {
114
+ .option('--json');
115
+ const listSessions = (opts) => run(opts, async () => {
116
+ if (opts.searchIn !== undefined && !['title', 'all'].includes(opts.searchIn))
117
+ throw new Error('--search-in must be title or all');
115
118
  if (opts.pageSize !== undefined && (!/^\d+$/.test(opts.pageSize) || Number(opts.pageSize) < 1 || Number(opts.pageSize) > 100))
116
119
  throw new Error('--page-size must be 1–100');
117
120
  if (opts.sort !== undefined && !['created', 'recent'].includes(opts.sort))
@@ -133,7 +136,7 @@ export function registerSessionsCommand(program) {
133
136
  throw new Error('use an exact owner namespace or organization slug/id');
134
137
  const expanded = opts.scope === 'available' || !!opts.owner || !!opts.team;
135
138
  const query = new URLSearchParams();
136
- 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]])
139
+ for (const [name, value] of [['pageSize', opts.pageSize], ['cursor', opts.cursor], ['q', opts.query], ['searchIn', opts.searchIn], ['sort', opts.sort], ['archived', opts.archived], ['owner', opts.owner?.replace(/^@/, '')], ['team', opts.team]])
137
140
  if (value !== undefined)
138
141
  query.set(name, value);
139
142
  for (const machine of opts.machine ?? [])
@@ -144,7 +147,16 @@ export function registerSessionsCommand(program) {
144
147
  const sessions = result.sessions.map(readSession);
145
148
  const nextCursor = typeof result.nextCursor === 'string' && /^[A-Za-z0-9_-]{1,1024}$/.test(result.nextCursor) ? result.nextCursor : null;
146
149
  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.'}` : ''));
147
- }));
150
+ });
151
+ listing(collectionList(group, 'list').description('list saved descriptors; this does not probe or start remote processes'))
152
+ .option('--query <text>', 'search session metadata and uploaded conversation text').action(listSessions);
153
+ listing(group.command('search <query>').description('search saved session metadata and uploaded conversation text; never starts or attaches'))
154
+ .allowExcessArguments(false)
155
+ .action((query, opts, command) => {
156
+ if (!query.trim())
157
+ command.error('Search query must not be empty', { exitCode: 1 });
158
+ return listSessions({ ...opts, query });
159
+ });
148
160
  common(group.command('show <id>').description('show one saved terminal descriptor')).option('--json').action((id, opts) => run(opts, async () => {
149
161
  const ns = await resolveHostNamespace(opts.namespace), session = readSession((await requestJson(connection(), sessionPath(ns, id) + '/metadata')).session);
150
162
  console.log(opts.json ? JSON.stringify({ session }, null, 2) : summary(session));
@@ -180,7 +192,7 @@ export function registerSessionsCommand(program) {
180
192
  await attachSession(conn, endpoint, ns, session, kind);
181
193
  }
182
194
  };
183
- gateway(target(common(group.command('create').description('save or find a matching session without starting it')))).option('--visibility <visibility>', 'public (new session default) or private').option('--session <uuid>', 'existing session UUID for the selected provider').option('--codex-session <uuid>', 'existing Codex session UUID (legacy alias)').option('--json').action(opts => run(opts, () => { if (opts.session && opts.codexSession && opts.session !== opts.codexSession)
195
+ gateway(target(common(group.command('create').description('save or find a matching session without starting it')))).option('--visibility <visibility>', 'public (new session default) or private').option('--sess, --session <uuid>', 'existing session UUID for the selected provider').option('--codex-session <uuid>', 'existing Codex session UUID (legacy alias)').option('--json').action(opts => run(opts, () => { if (opts.session && opts.codexSession && opts.session !== opts.codexSession)
184
196
  throw new Error('Provide one session UUID'); return save(opts.session ?? opts.codexSession, opts, false); }));
185
197
  gateway(target(common(group.command('resume <session-id>').description('save/find the exact agent session and attach; --json saves only')))).option('--json', 'save descriptor only; never start or attach to a process').action((id, opts) => run(opts, () => save(id, opts, !opts.json)));
186
198
  gateway(common(group.command('open <id>').description('open an interactive terminal for a saved session; Ctrl-] detaches'))).action((id, opts) => run(opts, async () => {
@@ -180,7 +180,7 @@ export function registerSessionLive(group) {
180
180
  process.exitCode = 1;
181
181
  }
182
182
  };
183
- const common = (c) => c.option('--session <id>', 'saved 24-hex session id (default: the env file sessions register --write-env left for the native session this process belongs to (CLAUDE_CODE_SESSION_ID), else the sourced DREAMLAKE_TERMINAL_SESSION_ID pair)')
183
+ const common = (c) => c.option('--sess, --session <id>', 'saved 24-hex session id (default: the env file sessions register --write-env left for the native session this process belongs to (CLAUDE_CODE_SESSION_ID), else the sourced DREAMLAKE_TERMINAL_SESSION_ID pair)')
184
184
  .option('--namespace <namespace>', 'personal namespace (default: from the env file or the signed-in personal namespace)')
185
185
  .option('--hook-stdin', 'read a Claude Code hook JSON from stdin: tool_name / prompt / agent_id / agent_type fill the fields not given explicitly; its session_id must match the native identity in the environment')
186
186
  .option('--at <iso>', 'when it happened (default: now)').option('--source <source>', 'hook (default) or runner; runner needs --runner').option('--runner <id>', 'report as this runner (the session must be bound to it)').option('--json', 'emit the receipt as JSON');
@@ -215,7 +215,7 @@ export function registerSessionLive(group) {
215
215
  console.log(opts.json ? JSON.stringify({ namespace: ns, ...tree }, null, 2) : renderTree(tree));
216
216
  }));
217
217
  group.command('watch').description('follow live state, subagent events, receipts and permission changes as they happen (SSE); one session or all of yours; exits 0 when the server ends the stream after 15 minutes')
218
- .option('--session <id>', 'one saved session (default: every session of the namespace)').option('--namespace <namespace>', 'personal namespace (default: signed-in personal namespace)').option('--json', 'NDJSON: one typed frame per line')
218
+ .option('--sess, --session <id>', 'one saved session (default: every session of the namespace)').option('--namespace <namespace>', 'personal namespace (default: signed-in personal namespace)').option('--json', 'NDJSON: one typed frame per line')
219
219
  .action(opts => guard(opts, async () => {
220
220
  if (opts.session !== undefined && !isObjectId(opts.session))
221
221
  throw new Error('--session takes the 24-hex saved session id');
@@ -1 +1 @@
1
- export declare const VERSION = "0.113.0";
1
+ export declare const VERSION = "0.115.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.113.0";
9
+ export const VERSION = "0.115.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.113.0",
3
+ "version": "0.115.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -37,13 +37,13 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.113.0",
41
- "@dreamlake/dreamlake-cli-darwin-x64": "0.113.0",
42
- "@dreamlake/dreamlake-cli-linux-x64": "0.113.0",
43
- "@dreamlake/dreamlake-cli-linux-arm64": "0.113.0",
44
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.113.0",
45
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.113.0",
46
- "@dreamlake/dreamlake-cli-win32-x64": "0.113.0",
47
- "@dreamlake/dreamlake-cli-win32-arm64": "0.113.0"
40
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.115.0",
41
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.115.0",
42
+ "@dreamlake/dreamlake-cli-linux-x64": "0.115.0",
43
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.115.0",
44
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.115.0",
45
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.115.0",
46
+ "@dreamlake/dreamlake-cli-win32-x64": "0.115.0",
47
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.115.0"
48
48
  }
49
49
  }