@dreamlake/dreamlake-cli 0.97.2 → 0.99.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/client.d.ts +1 -1
- package/dist/api/client.js +4 -4
- package/dist/api/http.d.ts +48 -1
- package/dist/api/http.js +111 -4
- package/dist/api/index.d.ts +217 -511
- package/dist/api/index.js +12 -2
- package/dist/api/native-experiments.d.ts +77 -0
- package/dist/api/native-experiments.js +31 -0
- package/dist/api/note-edits.d.ts +40 -2
- package/dist/api/note-edits.js +197 -2
- package/dist/api/note-events.d.ts +40 -4
- package/dist/api/note-events.js +55 -2
- package/dist/api/note-facade.d.ts +268 -0
- package/dist/api/note-facade.js +376 -0
- package/dist/api/note-reading.d.ts +27 -0
- package/dist/api/note-reading.js +27 -0
- package/dist/api/note-write.d.ts +110 -0
- package/dist/api/note-write.js +217 -0
- package/dist/api/notes.d.ts +33 -44
- package/dist/api/notes.js +44 -34
- package/dist/api/sessions.d.ts +240 -7
- package/dist/api/sessions.js +56 -1
- package/dist/api/skills.d.ts +122 -0
- package/dist/api/skills.js +220 -0
- package/dist/cli/client.d.ts +2 -41
- package/dist/cli/client.js +13 -90
- package/dist/cli/experiments/index.js +2 -0
- package/dist/cli/experiments/native-commands.d.ts +13 -0
- package/dist/cli/experiments/native-commands.js +88 -0
- package/dist/cli/help-examples.generated.js +23 -6
- package/dist/cli/index.js +2 -0
- package/dist/cli/notes/api-transport.js +6 -6
- package/dist/cli/notes/document.d.ts +32 -26
- package/dist/cli/notes/document.js +150 -95
- package/dist/cli/notes/edit-commands.d.ts +26 -5
- package/dist/cli/notes/edit-commands.js +163 -36
- package/dist/cli/notes/events.d.ts +3 -33
- package/dist/cli/notes/events.js +4 -51
- package/dist/cli/notes/html-read.d.ts +6 -0
- package/dist/cli/notes/html-read.js +12 -0
- package/dist/cli/notes/index.d.ts +10 -1
- package/dist/cli/notes/index.js +98 -27
- package/dist/cli/notes/move-command.d.ts +4 -0
- package/dist/cli/notes/move-command.js +7 -0
- package/dist/cli/session-affiliation.js +3 -2
- package/dist/cli/sessions/affiliation.d.ts +12 -1
- package/dist/cli/sessions/affiliation.js +37 -0
- package/dist/cli/sessions/control.d.ts +11 -0
- package/dist/cli/sessions/control.js +49 -4
- package/dist/cli/sessions/index.js +70 -17
- package/dist/cli/sessions/live.d.ts +85 -0
- package/dist/cli/sessions/live.js +258 -0
- package/dist/cli/sessions/runner/exec.d.ts +118 -6
- package/dist/cli/sessions/runner/exec.js +298 -47
- package/dist/cli/sessions/runner/native.js +4 -1
- package/dist/cli/sessions/runner/serve.d.ts +37 -2
- package/dist/cli/sessions/runner/serve.js +273 -28
- package/dist/cli/sessions/wrap.d.ts +63 -0
- package/dist/cli/sessions/wrap.js +226 -0
- package/dist/cli/skill/index.d.ts +19 -1
- package/dist/cli/skill/index.js +65 -12
- package/dist/cli/skill/read.d.ts +25 -0
- package/dist/cli/skill/read.js +65 -0
- package/dist/cli/skill/registry.d.ts +95 -0
- package/dist/cli/skill/registry.js +284 -0
- package/dist/cli/skill/reminders.js +2 -1
- package/dist/cli/vault/sshTransfer.d.ts +1 -1
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/** Skills registry: the server's pinned dreamlake-skills bundle, read-only.
|
|
2
|
+
*
|
|
3
|
+
* One business operation shared by three surfaces — `client.skills.read`,
|
|
4
|
+
* `dreamlake skill read` and the built-in agent's `dreamlake_skills_read` —
|
|
5
|
+
* with the same inputs, the same output fields and the same error codes.
|
|
6
|
+
* Every answer carries the bundle's `{ tag, commit }` so a caller can say
|
|
7
|
+
* which revision it read, and every content hash is verified against the
|
|
8
|
+
* skill's file index before it is returned.
|
|
9
|
+
*
|
|
10
|
+
* Server routes (dreamlake-server `routes/skills.ts`):
|
|
11
|
+
* GET /skills → SkillsList (ETag = commit)
|
|
12
|
+
* GET /skills/:skill → SkillDetail (manifest, SKILL.md body, file index)
|
|
13
|
+
* GET /skills/:skill/files/* → text/plain; ETag = content sha256; 304 on If-None-Match; 415 when binary
|
|
14
|
+
*/
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
16
|
+
import { ApiError } from "./client.js";
|
|
17
|
+
/** Fields every read surface exposes. */
|
|
18
|
+
export const SKILL_READ_FIELDS = ["tag", "commit", "skill", "path", "sha256", "content", "files", "filesTotal", "filesTruncated"];
|
|
19
|
+
/** Present only when the request named a retired skill name. */
|
|
20
|
+
export const SKILL_READ_OPTIONAL_FIELDS = ["renamedFrom"];
|
|
21
|
+
/** Fields only the paged agent tool carries: the code-point window of the page. */
|
|
22
|
+
export const SKILL_READ_PAGING_FIELDS = ["start", "end", "total", "next", "complete"];
|
|
23
|
+
export const DEFAULT_SKILL_FILE = "SKILL.md";
|
|
24
|
+
/** The server's typed refusals and the status each one carries; the last two come only from the paged agent tool. */
|
|
25
|
+
export const SKILLS_ERROR_CODES = {
|
|
26
|
+
skills_unavailable: 503,
|
|
27
|
+
skills_lock_mismatch: 503,
|
|
28
|
+
skill_not_found: 404,
|
|
29
|
+
skill_file_not_found: 404,
|
|
30
|
+
skill_path_invalid: 400,
|
|
31
|
+
skill_file_binary: 415,
|
|
32
|
+
skill_result_too_large: 413,
|
|
33
|
+
skill_range_invalid: 400,
|
|
34
|
+
};
|
|
35
|
+
export const isSkillsErrorCode = (code) => typeof code === "string" && Object.hasOwn(SKILLS_ERROR_CODES, code);
|
|
36
|
+
/** A refusal the skills registry defines. `code` is the identity callers branch on. */
|
|
37
|
+
export class SkillsError extends ApiError {
|
|
38
|
+
code;
|
|
39
|
+
constructor(status, code, body = { error: code }, requestId) {
|
|
40
|
+
super(status, code, body, undefined, requestId);
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.name = "SkillsError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Map a transport failure onto the typed refusal when it is one; other failures pass through. */
|
|
46
|
+
export function skillsFailure(error) {
|
|
47
|
+
if (error instanceof SkillsError)
|
|
48
|
+
return error;
|
|
49
|
+
if (error instanceof ApiError && isSkillsErrorCode(error.code)) {
|
|
50
|
+
return new SkillsError(error.status, error.code, error.body, error.requestId);
|
|
51
|
+
}
|
|
52
|
+
return error;
|
|
53
|
+
}
|
|
54
|
+
/** Skill names as the server validates them (`services/skillsBundle.ts`). */
|
|
55
|
+
export const SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
56
|
+
/** A relative, forward-slash path inside a skill: no `..`, no leading `/`, no empty segment. */
|
|
57
|
+
export const SKILL_FILE_PATH = /^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/;
|
|
58
|
+
export const skillContentSha256 = (text) => createHash("sha256").update(text, "utf8").digest("hex");
|
|
59
|
+
const SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
60
|
+
/** `Response.text()` drops a leading byte order mark; the ETag and the index hash the bytes with it, so the body is decoded keeping it. */
|
|
61
|
+
const utf8KeepingBom = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
62
|
+
const responseText = async (response) => utf8KeepingBom.decode(await response.arrayBuffer());
|
|
63
|
+
const unquote = (etag) => (etag ?? "").replace(/^W\//, "").replace(/^"(.*)"$/, "$1");
|
|
64
|
+
export function requireSkillName(skill) {
|
|
65
|
+
if (!SKILL_NAME.test(skill))
|
|
66
|
+
throw new SkillsError(404, "skill_not_found");
|
|
67
|
+
return skill;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The path as the server resolves it (`services/skillsTar.ts` safeRelativePath):
|
|
71
|
+
* `.` segments dropped, `..` refused — so the `path` returned is the one the
|
|
72
|
+
* file index lists and the agent tool reports.
|
|
73
|
+
*/
|
|
74
|
+
export function requireSkillPath(path) {
|
|
75
|
+
if (!SKILL_FILE_PATH.test(path))
|
|
76
|
+
throw new SkillsError(400, "skill_path_invalid");
|
|
77
|
+
const parts = path.split("/").filter((segment) => segment !== ".");
|
|
78
|
+
if (parts.length === 0 || parts.includes(".."))
|
|
79
|
+
throw new SkillsError(400, "skill_path_invalid");
|
|
80
|
+
return parts.join("/");
|
|
81
|
+
}
|
|
82
|
+
function requireVersion(value) {
|
|
83
|
+
const v = value;
|
|
84
|
+
if (!v || typeof v.tag !== "string" || typeof v.commit !== "string" || !v.tag || !v.commit) {
|
|
85
|
+
throw new Error("skills registry answered without a version");
|
|
86
|
+
}
|
|
87
|
+
return { tag: v.tag, commit: v.commit };
|
|
88
|
+
}
|
|
89
|
+
function versionFromHeaders(headers, fallback) {
|
|
90
|
+
const tag = headers?.get("x-skills-tag"), commit = headers?.get("x-skills-commit");
|
|
91
|
+
if (tag && commit)
|
|
92
|
+
return { tag, commit };
|
|
93
|
+
if (fallback)
|
|
94
|
+
return fallback;
|
|
95
|
+
throw new Error("skills registry answered without a version");
|
|
96
|
+
}
|
|
97
|
+
const isPaged = (value) => !!value && typeof value === "object" && typeof value.content === "string";
|
|
98
|
+
export function skillsApi(t) {
|
|
99
|
+
const skillPath = (skill) => `/skills/${encodeURIComponent(requireSkillName(skill))}`;
|
|
100
|
+
const filePath = (skill, path) => `${skillPath(skill)}/files/${requireSkillPath(path).split("/").map(encodeURIComponent).join("/")}`;
|
|
101
|
+
/**
|
|
102
|
+
* GET one file. The route answers text/plain; a JSON answer in the agent
|
|
103
|
+
* tool's paged shape is followed through `next` so the result is always the
|
|
104
|
+
* whole file. The content is hashed and held to the ETag.
|
|
105
|
+
*/
|
|
106
|
+
async function fetchFile(skill, path, ifNoneMatch) {
|
|
107
|
+
if (!t.raw)
|
|
108
|
+
throw new Error("reading skill files needs a transport with raw responses");
|
|
109
|
+
const target = filePath(skill, path);
|
|
110
|
+
const headers = ifNoneMatch ? { "If-None-Match": ifNoneMatch } : undefined;
|
|
111
|
+
let seen;
|
|
112
|
+
const onHeaders = (h) => { seen = h; };
|
|
113
|
+
try {
|
|
114
|
+
let start = 0, content = "", etag = "";
|
|
115
|
+
let version;
|
|
116
|
+
for (;;) {
|
|
117
|
+
const response = await t.raw("GET", target, { headers, onHeaders, query: start > 0 ? { start } : undefined });
|
|
118
|
+
version = versionFromHeaders(response.headers, version);
|
|
119
|
+
etag ||= unquote(response.headers.get("etag"));
|
|
120
|
+
if (!/\bjson\b/i.test(response.headers.get("content-type") ?? "")) {
|
|
121
|
+
content += await responseText(response);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
const page = await response.json();
|
|
125
|
+
if (!isPaged(page))
|
|
126
|
+
throw new Error("skills registry answered with neither text nor a page");
|
|
127
|
+
content += page.content;
|
|
128
|
+
if (page.complete !== false || page.next === null || page.next === undefined)
|
|
129
|
+
break;
|
|
130
|
+
if (page.next <= start)
|
|
131
|
+
throw new Error("skills registry page did not advance");
|
|
132
|
+
start = page.next;
|
|
133
|
+
}
|
|
134
|
+
const digest = skillContentSha256(content);
|
|
135
|
+
if (etag && SHA256_HEX.test(etag) && etag !== digest)
|
|
136
|
+
throw new Error(`skill file ${path} does not hash to its ETag`);
|
|
137
|
+
return { status: 200, ...version, path, sha256: digest, content };
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (error instanceof ApiError && error.status === 304) {
|
|
141
|
+
return { status: 304, ...versionFromHeaders(seen), path, sha256: unquote(seen?.get("etag")) || unquote(ifNoneMatch), content: null };
|
|
142
|
+
}
|
|
143
|
+
throw skillsFailure(error);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** The pinned bundle's version, every skill's summary and the rename table. */
|
|
147
|
+
async function list() {
|
|
148
|
+
try {
|
|
149
|
+
const answer = await t.request("GET", "/skills");
|
|
150
|
+
if (!answer || !Array.isArray(answer.skills))
|
|
151
|
+
throw new Error("skills registry answered without a skill list");
|
|
152
|
+
return { version: requireVersion(answer.version), skills: answer.skills, renamed: answer.renamed ?? {} };
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
throw skillsFailure(error);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** One skill's manifest, SKILL.md body and file index. */
|
|
159
|
+
async function skill(name) {
|
|
160
|
+
try {
|
|
161
|
+
const answer = await t.request("GET", skillPath(name));
|
|
162
|
+
if (!answer || typeof answer.body !== "string" || !Array.isArray(answer.files)) {
|
|
163
|
+
throw new Error("skills registry answered without a skill body");
|
|
164
|
+
}
|
|
165
|
+
return { ...answer, version: requireVersion(answer.version) };
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
throw skillsFailure(error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Read one whole file of a skill — `SKILL.md` unless `path` names another —
|
|
173
|
+
* with the bundle version and the content's sha256, verified against the
|
|
174
|
+
* skill's file index. The body of `SKILL.md` comes with the index in one
|
|
175
|
+
* request; any other path is a second request for that file.
|
|
176
|
+
*/
|
|
177
|
+
async function read(input) {
|
|
178
|
+
const path = requireSkillPath(input.path ?? DEFAULT_SKILL_FILE);
|
|
179
|
+
const detail = await skill(input.skill);
|
|
180
|
+
const entry = detail.files.find((f) => f.path === path);
|
|
181
|
+
if (!entry)
|
|
182
|
+
throw new SkillsError(404, "skill_file_not_found");
|
|
183
|
+
if (!entry.text)
|
|
184
|
+
throw new SkillsError(415, "skill_file_binary");
|
|
185
|
+
let content, digest;
|
|
186
|
+
if (path === DEFAULT_SKILL_FILE) {
|
|
187
|
+
content = detail.body;
|
|
188
|
+
digest = skillContentSha256(content);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const file = await fetchFile(detail.name, path);
|
|
192
|
+
if (file.commit !== detail.version.commit) {
|
|
193
|
+
throw new Error(`skills bundle changed between requests (${detail.version.commit} → ${file.commit}); retry`);
|
|
194
|
+
}
|
|
195
|
+
content = file.content;
|
|
196
|
+
digest = file.sha256;
|
|
197
|
+
}
|
|
198
|
+
if (digest !== entry.sha256)
|
|
199
|
+
throw new Error(`skill file ${path} does not hash to the index sha256 ${entry.sha256}`);
|
|
200
|
+
return {
|
|
201
|
+
tag: detail.version.tag,
|
|
202
|
+
commit: detail.version.commit,
|
|
203
|
+
skill: detail.name,
|
|
204
|
+
...(detail.renamedFrom ? { renamedFrom: detail.renamedFrom } : {}),
|
|
205
|
+
path,
|
|
206
|
+
sha256: digest,
|
|
207
|
+
content,
|
|
208
|
+
files: detail.files.map((f) => f.path),
|
|
209
|
+
filesTotal: detail.files.length,
|
|
210
|
+
filesTruncated: false,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/** One file as text with its ETag, or `status: 304` when `ifNoneMatch` already names it. */
|
|
214
|
+
function file(input) {
|
|
215
|
+
const etag = input.ifNoneMatch === undefined ? undefined
|
|
216
|
+
: /^(W\/)?".*"$/.test(input.ifNoneMatch) ? input.ifNoneMatch : `"${input.ifNoneMatch}"`;
|
|
217
|
+
return fetchFile(input.skill, input.path, etag);
|
|
218
|
+
}
|
|
219
|
+
return { list, skill, read, file };
|
|
220
|
+
}
|
package/dist/cli/client.d.ts
CHANGED
|
@@ -1,44 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
body: string;
|
|
4
|
-
/**
|
|
5
|
-
* The typed fields of a Source v1 error envelope, absent on every other
|
|
6
|
-
* shape.
|
|
7
|
-
*
|
|
8
|
-
* Kept as fields rather than folded into the message because they are what a
|
|
9
|
-
* caller BRANCHES on. `code` is the stable identity of a failure — the
|
|
10
|
-
* message is a human sentence the server is free to reword — and `retryable`
|
|
11
|
-
* is the server's own answer to "would repeating this identical request
|
|
12
|
-
* help", which no client can derive from a status alone: a 503 from a rate
|
|
13
|
-
* limiter and a 503 from a misconfigured binding look the same on the wire.
|
|
14
|
-
*
|
|
15
|
-
* `undefined` means "this response was not a v1 envelope", never "the server
|
|
16
|
-
* said no". A caller that must fail closed has to treat undefined as
|
|
17
|
-
* unknown rather than as false.
|
|
18
|
-
*/
|
|
19
|
-
code?: string;
|
|
20
|
-
retryable?: boolean;
|
|
21
|
-
requestId?: string;
|
|
22
|
-
constructor(status: number, body: string);
|
|
23
|
-
/**
|
|
24
|
-
* Pull a human message, and any typed fields, out of an error body.
|
|
25
|
-
*
|
|
26
|
-
* Three shapes reach here and they are not variations of one another:
|
|
27
|
-
*
|
|
28
|
-
* Source v1 {"error": {"code", "message", "retryable", "requestId"}}
|
|
29
|
-
* legacy flat {"error": "..."} or {"message": "..."}
|
|
30
|
-
* not JSON an HTML 404 page, a proxy's plain-text 502
|
|
31
|
-
*
|
|
32
|
-
* The v1 branch is tested FIRST and by type, not by presence. Both envelopes
|
|
33
|
-
* key on `error`, so the old `if (parsed.error) return parsed.error` matched
|
|
34
|
-
* the v1 object too and interpolated it — a real defect, measured before this
|
|
35
|
-
* was written: a 503 carrying a code, a message and a requestId rendered as
|
|
36
|
-
* `(503) [object Object]`, and the three fields a caller could have acted on
|
|
37
|
-
* were gone. Ordering alone does not prevent that; the `typeof` check is what
|
|
38
|
-
* does, because it is the only thing that distinguishes the two.
|
|
39
|
-
*/
|
|
40
|
-
private static parse;
|
|
41
|
-
}
|
|
1
|
+
import { HttpError, RequestNotSent } from "../api/http.js";
|
|
2
|
+
export { HttpError, RequestNotSent };
|
|
42
3
|
export interface RequestOpts {
|
|
43
4
|
method?: "GET" | "POST" | "PATCH" | "DELETE" | "PUT";
|
|
44
5
|
/** JSON body — serialized and sent with Content-Type: application/json. */
|
package/dist/cli/client.js
CHANGED
|
@@ -9,98 +9,17 @@ import { affiliateSuccessfulWrite } from './session-affiliation.js';
|
|
|
9
9
|
// clean message (matching lakeshore's auth/commands.ts error style).
|
|
10
10
|
// Callers that need to branch on status (404/409) catch HttpError and
|
|
11
11
|
// inspect `.status`.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* Kept as fields rather than folded into the message because they are what a
|
|
20
|
-
* caller BRANCHES on. `code` is the stable identity of a failure — the
|
|
21
|
-
* message is a human sentence the server is free to reword — and `retryable`
|
|
22
|
-
* is the server's own answer to "would repeating this identical request
|
|
23
|
-
* help", which no client can derive from a status alone: a 503 from a rate
|
|
24
|
-
* limiter and a 503 from a misconfigured binding look the same on the wire.
|
|
25
|
-
*
|
|
26
|
-
* `undefined` means "this response was not a v1 envelope", never "the server
|
|
27
|
-
* said no". A caller that must fail closed has to treat undefined as
|
|
28
|
-
* unknown rather than as false.
|
|
29
|
-
*/
|
|
30
|
-
code;
|
|
31
|
-
retryable;
|
|
32
|
-
requestId;
|
|
33
|
-
constructor(status, body) {
|
|
34
|
-
const parsed = HttpError.parse(body);
|
|
35
|
-
super(`(${status}) ${parsed.message}`);
|
|
36
|
-
this.name = "HttpError";
|
|
37
|
-
this.status = status;
|
|
38
|
-
this.body = body;
|
|
39
|
-
this.code = parsed.code;
|
|
40
|
-
this.retryable = parsed.retryable;
|
|
41
|
-
this.requestId = parsed.requestId;
|
|
12
|
+
import { HttpError, RequestNotSent } from "../api/http.js";
|
|
13
|
+
export { HttpError, RequestNotSent };
|
|
14
|
+
function buildUrl(base, path, query) {
|
|
15
|
+
let url;
|
|
16
|
+
try {
|
|
17
|
+
url = new URL(base.replace(/\/+$/, "") + path);
|
|
42
18
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* Three shapes reach here and they are not variations of one another:
|
|
47
|
-
*
|
|
48
|
-
* Source v1 {"error": {"code", "message", "retryable", "requestId"}}
|
|
49
|
-
* legacy flat {"error": "..."} or {"message": "..."}
|
|
50
|
-
* not JSON an HTML 404 page, a proxy's plain-text 502
|
|
51
|
-
*
|
|
52
|
-
* The v1 branch is tested FIRST and by type, not by presence. Both envelopes
|
|
53
|
-
* key on `error`, so the old `if (parsed.error) return parsed.error` matched
|
|
54
|
-
* the v1 object too and interpolated it — a real defect, measured before this
|
|
55
|
-
* was written: a 503 carrying a code, a message and a requestId rendered as
|
|
56
|
-
* `(503) [object Object]`, and the three fields a caller could have acted on
|
|
57
|
-
* were gone. Ordering alone does not prevent that; the `typeof` check is what
|
|
58
|
-
* does, because it is the only thing that distinguishes the two.
|
|
59
|
-
*/
|
|
60
|
-
static parse(body) {
|
|
61
|
-
if (!body)
|
|
62
|
-
return { message: "request failed" };
|
|
63
|
-
try {
|
|
64
|
-
const parsed = JSON.parse(body);
|
|
65
|
-
// Source v1 (§15): one nested envelope for every Source route.
|
|
66
|
-
if (typeof parsed.error === "object" && parsed.error !== null) {
|
|
67
|
-
const e = parsed.error;
|
|
68
|
-
// Each field is carried only when it has the type the contract gives
|
|
69
|
-
// it. A malformed envelope degrades to whatever it did supply rather
|
|
70
|
-
// than to a wrong value of the right shape.
|
|
71
|
-
const out = {
|
|
72
|
-
message: typeof e.message === "string" && e.message !== "" ? e.message : "request failed",
|
|
73
|
-
};
|
|
74
|
-
if (typeof e.code === "string")
|
|
75
|
-
out.code = e.code;
|
|
76
|
-
if (typeof e.retryable === "boolean")
|
|
77
|
-
out.retryable = e.retryable;
|
|
78
|
-
if (typeof e.requestId === "string")
|
|
79
|
-
out.requestId = e.requestId;
|
|
80
|
-
return out;
|
|
81
|
-
}
|
|
82
|
-
// Email-allowlist rejections put the human text in `message`
|
|
83
|
-
// (`error` is just "Forbidden").
|
|
84
|
-
if (parsed.code === "email_domain_not_allowed" && parsed.message) {
|
|
85
|
-
return { message: parsed.message };
|
|
86
|
-
}
|
|
87
|
-
if (typeof parsed.error === "string" && parsed.error) {
|
|
88
|
-
const detail = typeof parsed.message === "string" && parsed.message && parsed.message !== parsed.error
|
|
89
|
-
? `: ${parsed.message}` : "";
|
|
90
|
-
return { message: parsed.error + detail };
|
|
91
|
-
}
|
|
92
|
-
if (parsed.message)
|
|
93
|
-
return { message: parsed.message };
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
// not JSON
|
|
97
|
-
}
|
|
98
|
-
const oneLine = body.replace(/\s+/g, " ").trim();
|
|
99
|
-
return { message: oneLine.length > 200 ? oneLine.slice(0, 200) + "\u2026" : oneLine };
|
|
19
|
+
catch (error) {
|
|
20
|
+
// Nothing has left the process: callers deciding "was this sent?" must not treat it as uncertain.
|
|
21
|
+
throw new RequestNotSent(`invalid request URL: ${base.replace(/\/+$/, "")}${path}`, { cause: error });
|
|
100
22
|
}
|
|
101
|
-
}
|
|
102
|
-
function buildUrl(base, path, query) {
|
|
103
|
-
const url = new URL(base.replace(/\/+$/, "") + path);
|
|
104
23
|
if (query) {
|
|
105
24
|
for (const [k, v] of Object.entries(query)) {
|
|
106
25
|
if (v === undefined || v === null)
|
|
@@ -119,6 +38,8 @@ function authHeaders(token) {
|
|
|
119
38
|
*/
|
|
120
39
|
export async function requestJson(base, path, opts = {}) {
|
|
121
40
|
const { method = "GET", json, query, token, headers = {}, timeoutMs = 30000, redirect = "follow" } = opts;
|
|
41
|
+
if (!(Number.isSafeInteger(timeoutMs) && timeoutMs > 0 && timeoutMs <= 2 ** 31 - 1))
|
|
42
|
+
throw new RequestNotSent(`timeoutMs must be an integer between 1 and ${2 ** 31 - 1}, got ${timeoutMs}`);
|
|
122
43
|
const init = {
|
|
123
44
|
method,
|
|
124
45
|
headers: {
|
|
@@ -184,6 +105,8 @@ export async function requestJson(base, path, opts = {}) {
|
|
|
184
105
|
*/
|
|
185
106
|
export async function requestRaw(url, opts = {}) {
|
|
186
107
|
const { method = "GET", token, timeoutMs = 300000, headers = {}, signal, followRedirects = true, } = opts;
|
|
108
|
+
if (!(Number.isSafeInteger(timeoutMs) && timeoutMs > 0 && timeoutMs <= 2 ** 31 - 1))
|
|
109
|
+
throw new RequestNotSent(`timeoutMs must be an integer between 1 and ${2 ** 31 - 1}, got ${timeoutMs}`);
|
|
187
110
|
const res = await fetch(url, {
|
|
188
111
|
method,
|
|
189
112
|
headers: { ...authHeaders(token), ...noteAgentHeaders(new URL(url).pathname), ...resourceSessionHeaders(new URL(url).pathname), ...headers, ...telemetryHeaders() },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HttpError, requestJson } from "../client.js";
|
|
2
2
|
import { resolveRemote, resolveToken } from "../config.js";
|
|
3
3
|
import { emitJson, fail } from "../helpers.js";
|
|
4
|
+
import { registerNativeExperimentCommands } from "./native-commands.js";
|
|
4
5
|
class BindingError extends Error {
|
|
5
6
|
code;
|
|
6
7
|
remediation;
|
|
@@ -147,6 +148,7 @@ export async function runExperiments(action, opts, selection) {
|
|
|
147
148
|
}
|
|
148
149
|
export function registerExperimentsCommand(program) {
|
|
149
150
|
const command = program.command("experiments").description("discover and explicitly bind an existing managed Dash workspace (JSON receipts)");
|
|
151
|
+
registerNativeExperimentCommands(command);
|
|
150
152
|
for (const action of ["workspaces", "binding", "connect", "disconnect"]) {
|
|
151
153
|
const sub = command.command(action)
|
|
152
154
|
.description({ workspaces: "list verified eligible Dash organization workspaces", binding: "inspect the current binding and revision", connect: "preview a workspace binding; --apply commits it", disconnect: "preview detaching; remote experiments and SDK access are retained" }[action])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
type Action = "list" | "create" | "archive" | "restore" | "log" | "trash-list" | "delete" | "trash-restore";
|
|
3
|
+
interface Options {
|
|
4
|
+
namespace: string;
|
|
5
|
+
project: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
limit?: string;
|
|
8
|
+
cursor?: string;
|
|
9
|
+
level?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function runNativeExperiment(action: Action, opts: Options, subject?: string, message?: string): Promise<number>;
|
|
12
|
+
export declare function registerNativeExperimentCommands(parent: Command): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { HttpError, requestJson } from "../client.js";
|
|
2
|
+
import { resolveRemote, resolveToken } from "../config.js";
|
|
3
|
+
import { emitJson, fail } from "../helpers.js";
|
|
4
|
+
const id = /^[0-9a-f]{24}$/;
|
|
5
|
+
const key = /^[A-Za-z0-9_-]{1,128}$/;
|
|
6
|
+
export async function runNativeExperiment(action, opts, subject, message) {
|
|
7
|
+
try {
|
|
8
|
+
const token = resolveToken();
|
|
9
|
+
if (!token)
|
|
10
|
+
throw new Error("DreamLake login is required; run dreamlake login.");
|
|
11
|
+
if (!opts.namespace || !opts.project)
|
|
12
|
+
throw new Error("--namespace and --project are required.");
|
|
13
|
+
const base = `/native-experiments/ns/${encodeURIComponent(opts.namespace)}/projects/${encodeURIComponent(opts.project)}`;
|
|
14
|
+
const remote = resolveRemote();
|
|
15
|
+
if (action === "list" || action === "trash-list") {
|
|
16
|
+
const limit = opts.limit === undefined ? 50 : Number(opts.limit);
|
|
17
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100 ||
|
|
18
|
+
opts.limit !== undefined && !/^[1-9][0-9]*$/.test(opts.limit) ||
|
|
19
|
+
opts.cursor !== undefined && !id.test(opts.cursor))
|
|
20
|
+
throw new Error("Invalid list limit or cursor.");
|
|
21
|
+
emitJson(await requestJson(remote, `${base}/${action === "trash-list" ? "trash" : "runs"}`, { token, query: { limit,
|
|
22
|
+
...(opts.cursor ? { cursor: opts.cursor } : {}) }, redirect: "error" }));
|
|
23
|
+
return 0;
|
|
24
|
+
}
|
|
25
|
+
if (!subject || !(action === "create" ? key : id).test(subject))
|
|
26
|
+
throw new Error(action === "create"
|
|
27
|
+
? "Run key must contain 1-128 letters, digits, underscores or hyphens."
|
|
28
|
+
: "Run ID must be a DreamLake native Experiment ID.");
|
|
29
|
+
if (action === "create") {
|
|
30
|
+
emitJson(await requestJson(remote, `${base}/runs/${encodeURIComponent(subject)}`, { token, method: "PUT", redirect: "error" }));
|
|
31
|
+
}
|
|
32
|
+
else if (action === "delete" || action === "trash-restore") {
|
|
33
|
+
emitJson(await requestJson(remote, `${base}/runs/${subject}${action === "trash-restore" ? "/restore" : ""}`, {
|
|
34
|
+
token, method: action === "delete" ? "DELETE" : "POST", redirect: "error"
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
else if (action === "archive" || action === "restore") {
|
|
38
|
+
emitJson(await requestJson(remote, `${base}/runs/${subject}`, { token, method: "PATCH",
|
|
39
|
+
json: { archived: action === "archive" }, redirect: "error" }));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (!message || !["info", "warn", "error", "debug", "fatal"].includes(opts.level ?? "info"))
|
|
43
|
+
throw new Error("Log requires a message and a valid --level.");
|
|
44
|
+
emitJson(await requestJson(remote, `${base}/runs/${subject}/logs`, { token, method: "POST", redirect: "error",
|
|
45
|
+
json: { entries: [{ timestamp: new Date().toISOString(), level: opts.level ?? "info", message }] } }));
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const code = error instanceof HttpError ? `NATIVE_HTTP_${error.status}` : "NATIVE_INVALID_REQUEST";
|
|
51
|
+
const message = error instanceof HttpError ? `Experiment request failed (HTTP ${error.status}). Inspect the run before retrying a write.` :
|
|
52
|
+
error instanceof Error ? error.message : "Experiment request failed.";
|
|
53
|
+
if (opts.json)
|
|
54
|
+
emitJson({ ok: false, error: { code, message } });
|
|
55
|
+
else
|
|
56
|
+
fail(`${code}: ${message}`);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function registerNativeExperimentCommands(parent) {
|
|
61
|
+
const runs = parent.command("runs").description("DreamLake-native project Experiment runs");
|
|
62
|
+
const common = (command) => command.requiredOption("--namespace <slug>", "DreamLake namespace")
|
|
63
|
+
.requiredOption("--project <slug>", "DreamLake project")
|
|
64
|
+
.option("--json", "emit structured errors (success is JSON)");
|
|
65
|
+
common(runs.command("list").description("list active native runs"))
|
|
66
|
+
.option("--limit <count>", "page size, 1-100")
|
|
67
|
+
.option("--cursor <id>", "nextCursor from the previous page")
|
|
68
|
+
.action(async (opts) => { process.exitCode = await runNativeExperiment("list", opts); });
|
|
69
|
+
common(runs.command("create").description("create an idempotent native run by key").argument("<key>"))
|
|
70
|
+
.action(async (subject, opts) => { process.exitCode = await runNativeExperiment("create", opts, subject); });
|
|
71
|
+
for (const action of ["archive", "restore"])
|
|
72
|
+
common(runs.command(action).description(`${action} a native run`).argument("<run-id>"))
|
|
73
|
+
.action(async (subject, opts) => { process.exitCode = await runNativeExperiment(action, opts, subject); });
|
|
74
|
+
common(runs.command("delete").description("move a terminal native run to trash").argument("<run-id>"))
|
|
75
|
+
.action(async (subject, opts) => { process.exitCode = await runNativeExperiment("delete", opts, subject); });
|
|
76
|
+
const trash = runs.command("trash").description("list and restore deleted native runs");
|
|
77
|
+
common(trash.command("list").description("list deleted native runs"))
|
|
78
|
+
.option("--limit <count>", "page size, 1-100")
|
|
79
|
+
.option("--cursor <id>", "nextCursor from the previous page")
|
|
80
|
+
.action(async (opts) => { process.exitCode = await runNativeExperiment("trash-list", opts); });
|
|
81
|
+
common(trash.command("restore").description("restore a deleted native run").argument("<run-id>"))
|
|
82
|
+
.action(async (subject, opts) => { process.exitCode = await runNativeExperiment("trash-restore", opts, subject); });
|
|
83
|
+
common(runs.command("log").description("append one log entry to a native run").argument("<run-id>").argument("<message>"))
|
|
84
|
+
.option("--level <level>", "info, warn, error, debug or fatal", "info")
|
|
85
|
+
.action(async (subject, message, opts) => {
|
|
86
|
+
process.exitCode = await runNativeExperiment("log", opts, subject, message);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -20,6 +20,14 @@ export const helpExamples = {
|
|
|
20
20
|
"nymph access grant": "dreamlake nymph access grant upload --name alice/computers/laptop\ndreamlake nymph access grant command-execution --name alice/computers/laptop",
|
|
21
21
|
"nymph access revoke": "dreamlake nymph access revoke upload --name alice/computers/laptop\ndreamlake nymph access revoke command-execution --name alice/computers/laptop",
|
|
22
22
|
"nymph restart": "dreamlake nymph restart --name alice/computers/laptop",
|
|
23
|
+
"experiments runs list": "dreamlake experiments runs list --namespace fortyfive --project research",
|
|
24
|
+
"experiments runs create": "dreamlake experiments runs create trial_1 --namespace fortyfive --project research",
|
|
25
|
+
"experiments runs log": "dreamlake experiments runs log \"$RUN_ID\" \"training started\" --level info --namespace fortyfive --project research",
|
|
26
|
+
"experiments runs archive": "dreamlake experiments runs archive \"$RUN_ID\" --namespace fortyfive --project research",
|
|
27
|
+
"experiments runs restore": "dreamlake experiments runs restore \"$RUN_ID\" --namespace fortyfive --project research",
|
|
28
|
+
"experiments runs delete": "dreamlake experiments runs delete \"$RUN_ID\" --namespace fortyfive --project research",
|
|
29
|
+
"experiments runs trash list": "dreamlake experiments runs trash list --namespace fortyfive --project research",
|
|
30
|
+
"experiments runs trash restore": "dreamlake experiments runs trash restore \"$RUN_ID\" --namespace fortyfive --project research",
|
|
23
31
|
"experiments workspaces": "dreamlake experiments workspaces --namespace fortyfive --json",
|
|
24
32
|
"experiments binding": "dreamlake experiments binding --namespace fortyfive --json",
|
|
25
33
|
"experiments connect": "dreamlake experiments connect research --namespace fortyfive --json\n# Apply only after reviewing the preview. Use its actual revision, not this example's 0.\ndreamlake experiments connect \"$DASH_NAMESPACE_ID\" --namespace fortyfive --instance-id \"$DASH_INSTANCE_ID\" --apply --expected-revision 0 --json",
|
|
@@ -83,7 +91,7 @@ export const helpExamples = {
|
|
|
83
91
|
"notes presence": "# Read the participant roster without joining. Text is the default.\nNOTE_ID=release-plan\ndreamlake notes presence \"$NOTE_ID\"",
|
|
84
92
|
"notes select": "export DREAMLAKE_AGENT_ID=\"review-session-42\"\nexport DREAMLAKE_AGENT_NAME=\"Codex\"\nNOTE_ID=\"your-note-id\"\ndreamlake notes select --text \"The next step is tested in simulation.\" --note \"$NOTE_ID\"\n# Select the last occurrence of a repeated passage.\ndreamlake notes select --text \"simulation\" --note \"$NOTE_ID\" -o -1",
|
|
85
93
|
"notes rm": "# Read it first and confirm it is the note you mean.\ndreamlake notes read NOTE_ID\n# Asks for confirmation, showing the title and owning namespace.\ndreamlake notes rm NOTE_ID\n# Scripts and agents: skip the prompt and take a JSON receipt.\ndreamlake notes rm NOTE_ID --yes --json\n# Afterwards a read reports not found.\ndreamlake notes read NOTE_ID",
|
|
86
|
-
"notes patch": "set -euo pipefail\ndreamlake notes create \"Patch tutorial\" --text 'Hello world.' > created.txt\nNOTE_ID=$(sed -n 's/^ id //p' created.txt)\ndreamlake notes read \"$NOTE_ID\" > baseline.
|
|
94
|
+
"notes patch": "set -euo pipefail\ndreamlake notes create \"Patch tutorial\" --text 'Hello world.' > created.txt\nNOTE_ID=$(sed -n 's/^ id //p' created.txt)\ndreamlake notes read \"$NOTE_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)\ndreamlake notes patch \"$NOTE_ID\" --file - --base-revision \"$BASE\" --json > receipt.json <<'PATCH'\n@@ chars 0:12 @@\n~ Hello [-world-]{+team+}.\nPATCH\nACK=$(jq -er .revision receipt.json)\ndreamlake notes read \"$NOTE_ID\" --if-match \"$ACK\"\n# Expect Hello team. Inspect the result; do not repeat a successful patch.",
|
|
87
95
|
"notes append": "dreamlake notes append \"$NOTE_ID\" --file addition.md --base-revision \"$BASE\" --json\n# ACK is the revision in the successful append receipt.\ndreamlake notes read \"$NOTE_ID\" --at \"$ACK\"",
|
|
88
96
|
"notes insert": "dreamlake notes insert --note \"$NOTE_ID\" --ind 0 --text 'Review: ' \\\n --base-revision \"$BASE\" --json\n# ACK is the revision returned by the insertion receipt.\ndreamlake notes read \"$NOTE_ID\" --at \"$ACK\"",
|
|
89
97
|
"notes delete": "dreamlake notes delete 'obsolete paragraph' --note \"$NOTE_ID\" \\\n --base-revision \"$BASE\" --json\n# Pin verification to the receipt's acknowledged revision.\ndreamlake notes read \"$NOTE_ID\" --at \"$ACK\"",
|
|
@@ -159,7 +167,9 @@ export const helpExamples = {
|
|
|
159
167
|
"service-accounts bind": "dreamlake service-accounts bind my-team/0123456789abcdef01234567 --enrollment 444444444444444444444444",
|
|
160
168
|
"service-accounts revoke": "dreamlake service-accounts revoke my-team/0123456789abcdef01234567",
|
|
161
169
|
"sessions visibility": "dreamlake sessions visibility <saved-id> --namespace <personal-namespace> --visibility private",
|
|
162
|
-
"sessions register": "dreamlake sessions register --provider codex --session <native-uuid> --cwd /absolute/repository --json\n# Explicit private override for a new registration:\ndreamlake sessions register --provider claude --session <native-uuid> --cwd /absolute/repository --visibility private --json",
|
|
170
|
+
"sessions register": "dreamlake sessions register --provider codex --session <native-uuid> --cwd /absolute/repository --json\n# Explicit private override for a new registration:\ndreamlake sessions register --provider claude --session <native-uuid> --cwd /absolute/repository --visibility private --json\n# From inside a Claude Code session: register it, print the saved ID and the control send recipe,\n# and write an env file other shells can source so their note/artifact writes link to it:\ndreamlake sessions register --provider claude --session \"${CLAUDE_SESSION_ID:-$CLAUDE_CODE_SESSION_ID}\" --cwd \"$PWD\" --visibility private --write-env \"$HOME/.dreamlake/sessions/current.env\"",
|
|
171
|
+
"claude": "# Interactive Claude Code, registered private before it starts, acceptEdits (workspace-write):\ndreamlake claude\n# One headless turn at plan level; everything after the wrapper's flags goes to claude unchanged:\ndreamlake claude --permission read-only -p \"Summarize the open PRs\" --model opus",
|
|
172
|
+
"codex": "dreamlake codex --permission full-access \"Fix the failing test\"",
|
|
163
173
|
"sessions link": "dreamlake sessions link SESSION_ID --namespace geyang \\\n --resource-namespace fortyfive --note NOTE_ID --json\ndreamlake sessions link SESSION_ID --namespace geyang \\\n --resource-namespace fortyfive --artifact loss-plot --json",
|
|
164
174
|
"sessions unlink": "dreamlake sessions unlink SESSION_ID --namespace geyang \\\n --resource-namespace fortyfive --artifact loss-plot --json",
|
|
165
175
|
"sessions resources": "dreamlake sessions resources SESSION_ID --namespace geyang --page-size 25 --json",
|
|
@@ -176,22 +186,29 @@ export const helpExamples = {
|
|
|
176
186
|
"sessions stop": "dreamlake sessions stop SESSION_ID --namespace geyang --yes --json",
|
|
177
187
|
"sessions sync": "dreamlake sessions sync --namespace geyang --target TARGET_ID --json\ndreamlake sessions sync --namespace geyang --all --json",
|
|
178
188
|
"sessions upload-conversation": "dreamlake sessions upload-conversation SESSION_ID --namespace geyang \\\n --file /absolute/path/to/conversation.jsonl --json",
|
|
179
|
-
"sessions serve": "dreamlake sessions serve\n# Handle one command and exit (useful in scripts and tests):\ndreamlake sessions serve --once --json",
|
|
189
|
+
"sessions serve": "dreamlake sessions serve\n# Handle one command and exit (useful in scripts and tests):\ndreamlake sessions serve --once --json\n# Let a person raise sessions on this runner up to full access (control restart --raise):\ndreamlake sessions serve --max-human-permission full-access",
|
|
180
190
|
"sessions runners": "dreamlake sessions runners",
|
|
181
191
|
"sessions control start": "dreamlake 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:\ndreamlake sessions control start --provider codex --repo /abs/repo --isolation repo --permission read-only --mode headless --prompt \"Summarize open TODOs\"",
|
|
182
|
-
"sessions control send": "dreamlake sessions control send <session-id> \"Please rebase on main and rerun CI\"\n# A
|
|
192
|
+
"sessions control send": "dreamlake sessions control send <session-id> \"Please rebase on main and rerun CI\"\n# A turn under a lower ceiling than the recorded level, for this turn only:\ndreamlake sessions control send <session-id> \"Summarize your state\" --permission read-only\n# A session registered without a level (sessions register, dreamlake claude) is refused until one is recorded:\ndreamlake sessions control restart <session-id> --permission workspace-write --raise",
|
|
183
193
|
"sessions control broadcast": "dreamlake sessions control broadcast \"Stop and summarize your state\" --session <id-1> <id-2>",
|
|
184
194
|
"sessions control resume": "dreamlake sessions control resume <session-id> --prompt \"Continue\"",
|
|
195
|
+
"sessions control restart": "# Lower a session to read-only and continue the same conversation:\ndreamlake sessions control restart <session-id> --permission read-only\n# Raising is the person's explicit ask; the runner must have been started with --max-human-permission:\ndreamlake sessions control restart <session-id> --permission full-access --raise --reason \"needs to run the deploy\"",
|
|
196
|
+
"sessions permission": "dreamlake sessions permission <session-id> read-only --reason \"review only\"",
|
|
185
197
|
"sessions control stop": "dreamlake sessions control stop <session-id> --yes",
|
|
186
198
|
"sessions control status": "dreamlake sessions control status <session-id>\ndreamlake sessions control sync <session-id>\ndreamlake sessions control subagents <session-id>",
|
|
187
199
|
"sessions control list": "dreamlake sessions control list --session <session-id>\ndreamlake sessions control wait <command-id> --wait 120\ndreamlake sessions control cancel <command-id>",
|
|
200
|
+
"sessions heartbeat": "# From a Claude Code hook (settings.json): the hook JSON on stdin names the session and the tool.\ndreamlake sessions heartbeat --state running --hook-stdin\n# From a script or another relay, for an explicit saved session:\ndreamlake sessions heartbeat --session <session-id> --state waiting-for-user --tool Bash",
|
|
201
|
+
"sessions event": "dreamlake sessions event --kind SubagentStart --hook-stdin\ndreamlake sessions event --session <session-id> --kind SubagentStop --subagent agent-abc --finished --tokens 1200",
|
|
202
|
+
"sessions tree": "dreamlake sessions tree <session-id>",
|
|
203
|
+
"sessions watch": "# One session, readable lines:\ndreamlake sessions watch --session <session-id>\n# Everything in the namespace, one JSON frame per line:\ndreamlake sessions watch --json",
|
|
188
204
|
"sessions archive": "dreamlake sessions rename <session-id> \"Flaky test hunt\"\ndreamlake sessions archive <session-id>\ndreamlake sessions unarchive <session-id>",
|
|
189
205
|
"sessions chat": "dreamlake sessions chat \"Which of my sessions need attention?\"\n# Allow lifecycle and messaging tools this turn:\ndreamlake sessions chat --control \"Send 'rebase on main' to the two Claude sessions working on notes\"",
|
|
190
206
|
"sessions tool-calls": "dreamlake sessions tool-calls <conversation-id>",
|
|
191
207
|
"dreamlake": "# Guided agent setup: choose agent and scope, install dreamlake-cli offline\ndreamlake init\n# Install more skills from the public release\ndreamlake skill install dreamlake-notes\n# Keep installed skills current\ndreamlake skill update",
|
|
192
208
|
"init": "dreamlake init\ndreamlake init --agent codex\ndreamlake init --agent claude --global\n# Claude Code and Codex: one copy in each agent's directory\ndreamlake init --agent all --global",
|
|
193
|
-
"skill": "dreamlake skill list\ndreamlake skill install dreamlake-notes\ndreamlake skill update\ndreamlake skill remove dreamlake-notes",
|
|
194
|
-
"skill list": "
|
|
209
|
+
"skill": "dreamlake skill list\ndreamlake skill read dreamlake-notes\ndreamlake skill install dreamlake-notes\ndreamlake skill update\ndreamlake skill remove dreamlake-notes",
|
|
210
|
+
"skill list": "# The server's registry when logged in, else the embedded snapshot\ndreamlake skill list\n# Choose the source; --local never uses the network\ndreamlake skill list --local\ndreamlake skill list --remote\n# Fetch the latest catalog and show it next to the installed versions\ndreamlake skill list --refresh\ndreamlake skill list --agent codex --json",
|
|
211
|
+
"skill read": "# SKILL.md, from the server's registry when logged in, else the embedded bundle\ndreamlake skill read dreamlake-notes\n# One file inside the skill\ndreamlake skill read dreamlake-notes --file actions/read.md\n# Choose the source; --json carries the same fields as the agent's dreamlake_skills_read\ndreamlake skill read dreamlake-cli --local --json\ndreamlake skill read dreamlake-scenes --remote",
|
|
195
212
|
"skill install": "# The embedded dreamlake-cli skill; offline when it matches the release\ndreamlake skill install dreamlake-cli\n# A catalog skill plus whatever it requires, from the latest release\ndreamlake skill install dreamlake-notes --agent codex\n# One copy for Claude Code and one for Codex\ndreamlake skill install dreamlake-notes --agent all --global\n# Replace files you edited with the release copies\ndreamlake skill install dreamlake-notes --force",
|
|
196
213
|
"skill update": "# Every skill with a manifest in the selected scope\ndreamlake skill update\ndreamlake skill update dreamlake-cli --global\n# Overwrite edited files; retired files you edited are still kept\ndreamlake skill update dreamlake-notes --force\n# Go back to an older release, or replace a copy whose version cannot be ordered\ndreamlake skill update dreamlake-notes --allow-downgrade",
|
|
197
214
|
"skill remove": "dreamlake skill remove dreamlake-notes\ndreamlake skill remove dreamlake-notes --agent codex --global --json",
|
package/dist/cli/index.js
CHANGED
|
@@ -39,6 +39,7 @@ import { registerNotesCommand } from "./notes/index.js";
|
|
|
39
39
|
import { registerDeclareCommand } from "./declare/index.js";
|
|
40
40
|
import { registerHostsCommand } from "./hosts/index.js";
|
|
41
41
|
import { registerSessionsCommand } from "./sessions/index.js";
|
|
42
|
+
import { registerAgentWrappers } from "./sessions/wrap.js";
|
|
42
43
|
import { registerInfraCommand } from "./infra/index.js";
|
|
43
44
|
import { registerVaultCommand } from "./vault/index.js";
|
|
44
45
|
import { registerAgentsCommand } from "./agents/index.js";
|
|
@@ -228,6 +229,7 @@ async function main(argv) {
|
|
|
228
229
|
registerNymphCommand(program);
|
|
229
230
|
registerHostsCommand(program);
|
|
230
231
|
registerSessionsCommand(program);
|
|
232
|
+
registerAgentWrappers(program);
|
|
231
233
|
registerInfraCommand(program);
|
|
232
234
|
registerRunsCommands(program);
|
|
233
235
|
registerJobsCommand(program);
|