@dreamlake/dreamlake-cli 0.107.1 → 0.108.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/apps.d.ts +56 -0
- package/dist/api/apps.js +23 -0
- package/dist/api/bindrs.d.ts +76 -0
- package/dist/api/bindrs.js +83 -0
- package/dist/api/client.d.ts +3 -0
- package/dist/api/client.js +4 -1
- package/dist/api/common.js +2 -2
- package/dist/api/execution.js +4 -4
- package/dist/api/host-moves.js +2 -2
- package/dist/api/index.d.ts +157 -14
- package/dist/api/index.js +3 -0
- package/dist/api/memo-facade.js +2 -2
- package/dist/api/memo-reading.js +2 -2
- package/dist/api/memos.js +3 -3
- package/dist/api/native-experiments.js +2 -2
- package/dist/api/platform.js +6 -6
- package/dist/api/sessions.js +5 -5
- package/dist/api/workspace.d.ts +64 -7
- package/dist/api/workspace.js +4 -10
- package/dist/cli/apps/index.d.ts +14 -0
- package/dist/cli/apps/index.js +205 -0
- package/dist/cli/connection/oauth.d.ts +2 -0
- package/dist/cli/connection/oauth.js +4 -2
- package/dist/cli/create/index.d.ts +1 -0
- package/dist/cli/create/index.js +23 -9
- package/dist/cli/delete/index.js +13 -4
- package/dist/cli/help-examples.generated.js +12 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/list/index.js +5 -7
- package/dist/cli/resources.d.ts +2 -0
- package/dist/cli/resources.js +17 -3
- package/dist/cli/self-update/index.js +6 -4
- package/dist/cli/self-update/install.d.ts +5 -1
- package/dist/cli/self-update/install.js +28 -86
- package/dist/cli/self-update/shell-path.d.ts +4 -0
- package/dist/cli/self-update/shell-path.js +135 -0
- package/dist/cli/update/index.js +29 -65
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
package/dist/api/sessions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Agent sessions and the session control plane. Mirrors
|
|
2
2
|
* dreamlake-server `routes/terminal-sessions.ts` and `session-control/`. */
|
|
3
|
-
import { isObjectId, seg } from "./client.js";
|
|
3
|
+
import { isObjectId, namespaceSeg, seg } from "./client.js";
|
|
4
4
|
import { serverEvents } from "./streams.js";
|
|
5
5
|
/** Ordered: each level includes the ones before it. */
|
|
6
6
|
export const PERMISSION_LEVELS = ["read-only", "workspace-write", "full-access"];
|
|
@@ -32,7 +32,7 @@ export const TERMINAL = new Set([
|
|
|
32
32
|
/** Seconds the server will hold a wait; longer waits are client loops. */
|
|
33
33
|
export const MAX_WAIT_SECONDS = 25;
|
|
34
34
|
export function sessionsApi(t, namespace) {
|
|
35
|
-
const ns =
|
|
35
|
+
const ns = namespaceSeg(namespace), base = `/namespaces/${ns}/terminal-sessions`, commands = `/namespaces/${ns}/session-commands`, runners = `/namespaces/${ns}/session-runners`;
|
|
36
36
|
const id = (value) => {
|
|
37
37
|
if (!isObjectId(value))
|
|
38
38
|
throw new Error("expected a 24-hex id");
|
|
@@ -41,8 +41,8 @@ export function sessionsApi(t, namespace) {
|
|
|
41
41
|
const long = (seconds) => ({ timeoutMs: (seconds + 10) * 1000 });
|
|
42
42
|
return {
|
|
43
43
|
namespace,
|
|
44
|
-
link: (sessionId, resource) => t.request("PUT", `/namespaces/${
|
|
45
|
-
unlink: (sessionId, resource) => t.request("DELETE", `/namespaces/${
|
|
44
|
+
link: (sessionId, resource) => t.request("PUT", `/namespaces/${namespaceSeg(resource.namespace)}/resources/${resource.type}/${seg(resource.id)}/sessions/${id(sessionId)}`, { json: { sessionNamespaceSlug: namespace } }),
|
|
45
|
+
unlink: (sessionId, resource) => t.request("DELETE", `/namespaces/${namespaceSeg(resource.namespace)}/resources/${resource.type}/${seg(resource.id)}/sessions/${id(sessionId)}`, { json: { sessionNamespaceSlug: namespace } }),
|
|
46
46
|
list: (query = {}) => t.request("GET", base, { query }),
|
|
47
47
|
/** Every session the caller may read across namespaces: public, team-shared and their own. */
|
|
48
48
|
available: (query = {}) => t.request("GET", "/terminal-sessions/available", { query }),
|
|
@@ -140,7 +140,7 @@ export function sessionsApi(t, namespace) {
|
|
|
140
140
|
}
|
|
141
141
|
/** Gateway operations are separate from runner command execution; callers supply the configured gateway transport. */
|
|
142
142
|
export function terminalApi(t, namespace) {
|
|
143
|
-
const ns =
|
|
143
|
+
const ns = namespaceSeg(namespace), base = `/namespaces/${ns}/terminal`, sessions = `/namespaces/${ns}/terminal-sessions`;
|
|
144
144
|
return {
|
|
145
145
|
targets: () => t.request("GET", base + "/targets"),
|
|
146
146
|
discovery: (input) => t.request("POST", base + "/discovery", { json: input }),
|
package/dist/api/workspace.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./bindrs.js";
|
|
1
2
|
/** Workspace resource APIs. Authentication/ACLs stay in the existing service routes. */
|
|
2
3
|
import { type Transport } from "./client.js";
|
|
3
4
|
import { type JsonObject, type Query, type Resource } from "./common.js";
|
|
@@ -35,6 +36,39 @@ export declare function projectsApi(t: Transport, namespace: string): {
|
|
|
35
36
|
totalPages: number;
|
|
36
37
|
}>;
|
|
37
38
|
resources: (project: string, kind: "bindrs" | "datasets" | "episodes") => {
|
|
39
|
+
list: (query?: Query) => Promise<{
|
|
40
|
+
bindrs: import("./bindrs.js").Bindr[];
|
|
41
|
+
}>;
|
|
42
|
+
create: (input: import("./bindrs.js").BindrInput) => Promise<{
|
|
43
|
+
bindr: import("./bindrs.js").Bindr;
|
|
44
|
+
}>;
|
|
45
|
+
get: (nameOrId: string, query?: Query) => Promise<import("./bindrs.js").BindrDetail>;
|
|
46
|
+
summary: (nameOrId: string) => Promise<{
|
|
47
|
+
bindr: import("./bindrs.js").Bindr;
|
|
48
|
+
}>;
|
|
49
|
+
update: (nameOrId: string, input: Partial<Omit<import("./bindrs.js").BindrInput, "member" | "members">>) => Promise<{
|
|
50
|
+
bindr: import("./bindrs.js").Bindr;
|
|
51
|
+
}>;
|
|
52
|
+
delete: (nameOrId: string) => Promise<{
|
|
53
|
+
deleted: boolean;
|
|
54
|
+
}>;
|
|
55
|
+
addMember: (nameOrId: string, nodeId: string) => Promise<{
|
|
56
|
+
added: boolean;
|
|
57
|
+
memberCount: number;
|
|
58
|
+
}>;
|
|
59
|
+
removeMember: (nameOrId: string, nodeId: string) => Promise<{
|
|
60
|
+
removed: boolean;
|
|
61
|
+
memberCount: number;
|
|
62
|
+
}>;
|
|
63
|
+
addMembers: (nameOrId: string, nodeIds: string[]) => Promise<{
|
|
64
|
+
completedNodeIds: string[];
|
|
65
|
+
memberCount: number | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
removeMembers: (nameOrId: string, nodeIds: string[]) => Promise<{
|
|
68
|
+
completedNodeIds: string[];
|
|
69
|
+
memberCount: number | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
} | {
|
|
38
72
|
list: (query?: Query) => Promise<{
|
|
39
73
|
[key: string]: unknown;
|
|
40
74
|
}>;
|
|
@@ -44,15 +78,38 @@ export declare function projectsApi(t: Transport, namespace: string): {
|
|
|
44
78
|
delete: (id: string) => Promise<unknown>;
|
|
45
79
|
};
|
|
46
80
|
bindrs: (project: string) => {
|
|
47
|
-
addMembers: (name: string, add: string[]) => Promise<unknown>;
|
|
48
|
-
removeMembers: (name: string, remove: string[]) => Promise<unknown>;
|
|
49
81
|
list: (query?: Query) => Promise<{
|
|
50
|
-
|
|
82
|
+
bindrs: import("./bindrs.js").Bindr[];
|
|
83
|
+
}>;
|
|
84
|
+
create: (input: import("./bindrs.js").BindrInput) => Promise<{
|
|
85
|
+
bindr: import("./bindrs.js").Bindr;
|
|
86
|
+
}>;
|
|
87
|
+
get: (nameOrId: string, query?: Query) => Promise<import("./bindrs.js").BindrDetail>;
|
|
88
|
+
summary: (nameOrId: string) => Promise<{
|
|
89
|
+
bindr: import("./bindrs.js").Bindr;
|
|
90
|
+
}>;
|
|
91
|
+
update: (nameOrId: string, input: Partial<Omit<import("./bindrs.js").BindrInput, "member" | "members">>) => Promise<{
|
|
92
|
+
bindr: import("./bindrs.js").Bindr;
|
|
93
|
+
}>;
|
|
94
|
+
delete: (nameOrId: string) => Promise<{
|
|
95
|
+
deleted: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
addMember: (nameOrId: string, nodeId: string) => Promise<{
|
|
98
|
+
added: boolean;
|
|
99
|
+
memberCount: number;
|
|
100
|
+
}>;
|
|
101
|
+
removeMember: (nameOrId: string, nodeId: string) => Promise<{
|
|
102
|
+
removed: boolean;
|
|
103
|
+
memberCount: number;
|
|
104
|
+
}>;
|
|
105
|
+
addMembers: (nameOrId: string, nodeIds: string[]) => Promise<{
|
|
106
|
+
completedNodeIds: string[];
|
|
107
|
+
memberCount: number | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
removeMembers: (nameOrId: string, nodeIds: string[]) => Promise<{
|
|
110
|
+
completedNodeIds: string[];
|
|
111
|
+
memberCount: number | undefined;
|
|
51
112
|
}>;
|
|
52
|
-
get: (id: string) => Promise<Resource>;
|
|
53
|
-
create: (input: JsonObject) => Promise<Resource>;
|
|
54
|
-
update: (id: string, input: Partial<JsonObject>) => Promise<Resource>;
|
|
55
|
-
delete: (id: string) => Promise<unknown>;
|
|
56
113
|
};
|
|
57
114
|
datasets: (project: string) => {
|
|
58
115
|
addBindrs: (name: string, add: string[]) => Promise<unknown>;
|
package/dist/api/workspace.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bindrsApi } from "./bindrs.js";
|
|
2
|
+
export * from "./bindrs.js";
|
|
1
3
|
/** Workspace resource APIs. Authentication/ACLs stay in the existing service routes. */
|
|
2
4
|
import { seg } from "./client.js";
|
|
3
5
|
import { namespacePath, resourceApi, call, } from "./common.js";
|
|
@@ -46,16 +48,8 @@ export function projectsApi(t, namespace) {
|
|
|
46
48
|
},
|
|
47
49
|
/** Mixed project resources, or one bindr's members via the bindr filter. */
|
|
48
50
|
resourceList: (project, query = {}) => call(t, "GET", path(project) + "/resources", undefined, query),
|
|
49
|
-
resources: (project, kind) => resourceApi(t, path(project) + "/" + kind),
|
|
50
|
-
bindrs: (project) => (
|
|
51
|
-
...resourceApi(t, path(project) + "/bindrs"),
|
|
52
|
-
addMembers: (name, add) => call(t, "POST", path(project) + "/bindrs/" + seg(name) + "/members", {
|
|
53
|
-
add,
|
|
54
|
-
}),
|
|
55
|
-
removeMembers: (name, remove) => call(t, "DELETE", path(project) + "/bindrs/" + seg(name) + "/members", {
|
|
56
|
-
remove,
|
|
57
|
-
}),
|
|
58
|
-
}),
|
|
51
|
+
resources: (project, kind) => kind === "bindrs" ? bindrsApi(t, namespace, project) : resourceApi(t, path(project) + "/" + kind),
|
|
52
|
+
bindrs: (project) => bindrsApi(t, namespace, project),
|
|
59
53
|
datasets: (project) => ({
|
|
60
54
|
...resourceApi(t, path(project) + "/datasets"),
|
|
61
55
|
addBindrs: (name, add) => call(t, "POST", path(project) + "/datasets/" + seg(name) + "/bindrs", {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { type AppAction } from "../../api/apps.js";
|
|
3
|
+
interface Options {
|
|
4
|
+
namespace?: string;
|
|
5
|
+
json?: boolean;
|
|
6
|
+
inputFile?: string;
|
|
7
|
+
send?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function validAction(value: unknown): asserts value is AppAction;
|
|
10
|
+
export declare function appInput(path?: string): Promise<Record<string, unknown>>;
|
|
11
|
+
export declare const display: (value: unknown) => string;
|
|
12
|
+
export declare function runApps(operation: string, id: string | undefined, tool: string | undefined, opts: Options): Promise<number>;
|
|
13
|
+
export declare function registerAppsCommand(program: Command): void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { confirm } from "@inquirer/prompts";
|
|
3
|
+
import { appsApi } from "../../api/apps.js";
|
|
4
|
+
import { requestJson } from "../client.js";
|
|
5
|
+
import { ctx, strictArgs } from "../connection/index.js";
|
|
6
|
+
import { emitJson, fail } from "../helpers.js";
|
|
7
|
+
export function validAction(value) {
|
|
8
|
+
const a = value;
|
|
9
|
+
if (!a ||
|
|
10
|
+
typeof a.actionId !== "string" ||
|
|
11
|
+
!/^[a-f0-9]{24}$/.test(a.actionId) ||
|
|
12
|
+
typeof a.payloadHash !== "string" ||
|
|
13
|
+
!/^[a-f0-9]{64}$/.test(a.payloadHash) ||
|
|
14
|
+
!a.arguments ||
|
|
15
|
+
typeof a.arguments !== "object" ||
|
|
16
|
+
Array.isArray(a.arguments) ||
|
|
17
|
+
typeof a.label !== "string" ||
|
|
18
|
+
typeof a.accountLabel !== "string" ||
|
|
19
|
+
typeof a.tool !== "string" ||
|
|
20
|
+
![
|
|
21
|
+
"prepared",
|
|
22
|
+
"sending",
|
|
23
|
+
"completed",
|
|
24
|
+
"failed",
|
|
25
|
+
"cancelled",
|
|
26
|
+
"uncertain",
|
|
27
|
+
].includes(a.state) ||
|
|
28
|
+
!Number.isFinite(Date.parse(a.expiresAt)))
|
|
29
|
+
throw new Error("Invalid app action response; nothing was confirmed.");
|
|
30
|
+
}
|
|
31
|
+
export async function appInput(path) {
|
|
32
|
+
if (!path)
|
|
33
|
+
throw new Error("--input-file is required");
|
|
34
|
+
const info = await stat(path);
|
|
35
|
+
if (!info.isFile() || info.size > 16_384)
|
|
36
|
+
throw new Error("Input must be a JSON file of at most 16 KiB.");
|
|
37
|
+
const raw = await readFile(path, "utf8");
|
|
38
|
+
if (Buffer.byteLength(raw) > 16_384)
|
|
39
|
+
throw new Error("Input exceeds 16 KiB.");
|
|
40
|
+
const args = JSON.parse(raw);
|
|
41
|
+
if (!args || typeof args !== "object" || Array.isArray(args))
|
|
42
|
+
throw new Error("Input must be a JSON object.");
|
|
43
|
+
return args;
|
|
44
|
+
}
|
|
45
|
+
// JSON escaping also makes terminal control characters and bidirectional overrides visible.
|
|
46
|
+
export const display = (value) => JSON.stringify(value, null, 2).replace(/[\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
47
|
+
export async function runApps(operation, id, tool, opts) {
|
|
48
|
+
// Neither a pipe nor --json is a way to bypass human review.
|
|
49
|
+
if (operation === "confirm" &&
|
|
50
|
+
(!process.stdin.isTTY || !process.stdout.isTTY || opts.json)) {
|
|
51
|
+
fail("Confirmation requires an interactive terminal. Review the action in Assistant connections → Apps for your agent (/go My connections), or run this command interactively.");
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const args = ["read", "prepare"].includes(operation)
|
|
56
|
+
? await appInput(opts.inputFile)
|
|
57
|
+
: undefined;
|
|
58
|
+
const c = await ctx(opts.namespace);
|
|
59
|
+
if (!c)
|
|
60
|
+
return 1;
|
|
61
|
+
const api = appsApi({
|
|
62
|
+
request: (method, path, options) => requestJson(c.remote, path, {
|
|
63
|
+
method: method === "HEAD" ? "GET" : method,
|
|
64
|
+
json: options?.json,
|
|
65
|
+
signal: options?.signal,
|
|
66
|
+
token: c.token,
|
|
67
|
+
}),
|
|
68
|
+
}, c.ns);
|
|
69
|
+
let result;
|
|
70
|
+
switch (operation) {
|
|
71
|
+
case "list":
|
|
72
|
+
result = await api.list();
|
|
73
|
+
break;
|
|
74
|
+
case "tools":
|
|
75
|
+
result = await api.tools(id);
|
|
76
|
+
break;
|
|
77
|
+
case "check":
|
|
78
|
+
result = await api.check(id);
|
|
79
|
+
break;
|
|
80
|
+
case "read":
|
|
81
|
+
result = await api.read(id, tool, args);
|
|
82
|
+
break;
|
|
83
|
+
case "prepare":
|
|
84
|
+
result = await api.prepare(id, tool, args);
|
|
85
|
+
break;
|
|
86
|
+
case "receipt":
|
|
87
|
+
result = await api.receipt(id);
|
|
88
|
+
validAction(result);
|
|
89
|
+
break;
|
|
90
|
+
case "cancel":
|
|
91
|
+
result = await api.cancel(id);
|
|
92
|
+
validAction(result);
|
|
93
|
+
break;
|
|
94
|
+
case "grant":
|
|
95
|
+
case "revoke": {
|
|
96
|
+
const catalog = await api.list();
|
|
97
|
+
const row = catalog.connections.find((x) => x.id === id);
|
|
98
|
+
if (!row ||
|
|
99
|
+
!Number.isSafeInteger(row.grantRevision) ||
|
|
100
|
+
row.grantRevision < 0)
|
|
101
|
+
throw new Error("Connection not found or invalid grant revision.");
|
|
102
|
+
result = await api.grant(id, {
|
|
103
|
+
enabled: operation === "grant",
|
|
104
|
+
writeEnabled: operation === "grant" && !!opts.send,
|
|
105
|
+
expectedRevision: row.grantRevision,
|
|
106
|
+
});
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case "confirm": {
|
|
110
|
+
const action = await api.receipt(id);
|
|
111
|
+
validAction(action);
|
|
112
|
+
if (action.actionId !== id)
|
|
113
|
+
throw new Error("Action identity changed; nothing was confirmed.");
|
|
114
|
+
if (action.state !== "prepared") {
|
|
115
|
+
result = action;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (Date.parse(action.expiresAt) <= Date.now())
|
|
119
|
+
throw new Error("This proposal expired. Prepare a new action.");
|
|
120
|
+
process.stdout.write(display({
|
|
121
|
+
account: action.accountLabel,
|
|
122
|
+
connection: action.label,
|
|
123
|
+
tool: action.tool,
|
|
124
|
+
arguments: action.arguments,
|
|
125
|
+
}) + "\n");
|
|
126
|
+
if (!(await confirm({
|
|
127
|
+
message: "Send this exact Slack message?",
|
|
128
|
+
default: false,
|
|
129
|
+
})))
|
|
130
|
+
return 0;
|
|
131
|
+
result = await api.confirm(id, action.payloadHash, "send-exact-action");
|
|
132
|
+
validAction(result);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
default:
|
|
136
|
+
throw new Error("Unknown app operation");
|
|
137
|
+
}
|
|
138
|
+
if (opts.json)
|
|
139
|
+
emitJson(result);
|
|
140
|
+
else
|
|
141
|
+
process.stdout.write(display(result) + "\n");
|
|
142
|
+
if (operation === "confirm" &&
|
|
143
|
+
result.state !== "completed") {
|
|
144
|
+
fail("Sending is not confirmed. Check the receipt and Slack before preparing another action.");
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
// Do not print request bodies or raw provider errors.
|
|
151
|
+
fail(e instanceof Error ? e.message : "App request failed");
|
|
152
|
+
if (operation === "confirm")
|
|
153
|
+
fail("Do not retry the send blindly. Read the action receipt and check Slack.");
|
|
154
|
+
return 1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function registerAppsCommand(program) {
|
|
158
|
+
const apps = program
|
|
159
|
+
.command("apps")
|
|
160
|
+
.description("connect personal apps to the built-in agent; review external actions");
|
|
161
|
+
for (const operation of [
|
|
162
|
+
"list",
|
|
163
|
+
"grant",
|
|
164
|
+
"revoke",
|
|
165
|
+
"tools",
|
|
166
|
+
"check",
|
|
167
|
+
"read",
|
|
168
|
+
"prepare",
|
|
169
|
+
"receipt",
|
|
170
|
+
"confirm",
|
|
171
|
+
"cancel",
|
|
172
|
+
]) {
|
|
173
|
+
let cmd = strictArgs(apps.command(operation)).description({
|
|
174
|
+
list: "list app connections and recent actions",
|
|
175
|
+
grant: "allow built-in agent reads (optionally reviewed sends)",
|
|
176
|
+
revoke: "remove built-in agent access",
|
|
177
|
+
tools: "discover allowed tools",
|
|
178
|
+
check: "verify sign-in and tool discovery without reading content",
|
|
179
|
+
read: "call an allowed read tool",
|
|
180
|
+
prepare: "prepare a Slack message for review without sending",
|
|
181
|
+
receipt: "review an action and its saved outcome",
|
|
182
|
+
confirm: "interactively review and send one exact action",
|
|
183
|
+
cancel: "cancel a prepared action",
|
|
184
|
+
}[operation]);
|
|
185
|
+
if (operation !== "list")
|
|
186
|
+
cmd = cmd.argument("<id>", ["receipt", "confirm", "cancel"].includes(operation)
|
|
187
|
+
? "action id"
|
|
188
|
+
: "connection id");
|
|
189
|
+
if (["read", "prepare"].includes(operation))
|
|
190
|
+
cmd = cmd
|
|
191
|
+
.argument("<tool>", "discovered tool name")
|
|
192
|
+
.requiredOption("--input-file <path>", "JSON argument object (16 KiB maximum)");
|
|
193
|
+
if (operation === "grant")
|
|
194
|
+
cmd.option("--send", "also allow preparing reviewed sends; requires Slack send consent");
|
|
195
|
+
cmd
|
|
196
|
+
.option("--namespace <slug>", "personal namespace (default: active login)")
|
|
197
|
+
.option("--json", "emit JSON (unavailable for confirm)");
|
|
198
|
+
cmd.action(async (...args) => {
|
|
199
|
+
const opts = args[args.length - 2];
|
|
200
|
+
process.exitCode = await runApps(operation, operation === "list" ? undefined : args[0], ["read", "prepare"].includes(operation)
|
|
201
|
+
? args[1]
|
|
202
|
+
: undefined, opts);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -11,6 +11,7 @@ export declare function runOAuthCreate(opts: {
|
|
|
11
11
|
wait?: boolean;
|
|
12
12
|
json?: boolean;
|
|
13
13
|
timeoutMs?: number;
|
|
14
|
+
access?: string;
|
|
14
15
|
}): Promise<number>;
|
|
15
16
|
export declare function runOAuthReconnect(id: string, opts: {
|
|
16
17
|
connector: string;
|
|
@@ -19,5 +20,6 @@ export declare function runOAuthReconnect(id: string, opts: {
|
|
|
19
20
|
wait?: boolean;
|
|
20
21
|
json?: boolean;
|
|
21
22
|
timeoutMs?: number;
|
|
23
|
+
access?: string;
|
|
22
24
|
}): Promise<number>;
|
|
23
25
|
export declare function registerConnectionOAuthCommands(connection: Command): void;
|
|
@@ -72,7 +72,7 @@ async function begin(c, body) {
|
|
|
72
72
|
const res = await requestJson(c.remote, operationsPath(c), {
|
|
73
73
|
method: "POST",
|
|
74
74
|
token: c.token,
|
|
75
|
-
json: { ...body, returnTo: RETURN_TO },
|
|
75
|
+
json: { ...body, returnTo: ["slack-mcp", "plaud-mcp"].includes(String(body.connectorKind)) ? `/${seg(c.ns)}/settings?apps=1` : RETURN_TO },
|
|
76
76
|
});
|
|
77
77
|
return parseBegin(res, "begin");
|
|
78
78
|
}
|
|
@@ -235,7 +235,7 @@ export async function runOAuthCreate(opts) {
|
|
|
235
235
|
const c = await ctx(opts.namespace);
|
|
236
236
|
if (!c)
|
|
237
237
|
return 1;
|
|
238
|
-
return flow(c, { intent: "create", connectorKind: opts.connector, label: opts.label }, opts);
|
|
238
|
+
return flow(c, { intent: "create", connectorKind: opts.connector, label: opts.label, ...(opts.access ? { oauthProfile: opts.access } : {}) }, opts);
|
|
239
239
|
}
|
|
240
240
|
export async function runOAuthReconnect(id, opts) {
|
|
241
241
|
const c = await ctx(opts.namespace);
|
|
@@ -258,6 +258,7 @@ export async function runOAuthReconnect(id, opts) {
|
|
|
258
258
|
return 1;
|
|
259
259
|
return flow(c, {
|
|
260
260
|
intent: "reconnect",
|
|
261
|
+
...(opts.access ? { oauthProfile: opts.access } : {}),
|
|
261
262
|
connectorKind: opts.connector,
|
|
262
263
|
connectionId: id,
|
|
263
264
|
expectedSettingsRevision: one.settingsRevision,
|
|
@@ -269,6 +270,7 @@ export function registerConnectionOAuthCommands(connection) {
|
|
|
269
270
|
.command("oauth")
|
|
270
271
|
.description("authorize a connection through a provider's browser flow");
|
|
271
272
|
const shared = (cmd) => cmd
|
|
273
|
+
.option("--access <profile>", "provider access profile (app providers: read or read-write)")
|
|
272
274
|
.option("--no-browser", "print the URL instead of opening a browser")
|
|
273
275
|
.option("--no-wait", "print the operation id and exit without watching")
|
|
274
276
|
.option("--namespace <slug>", "namespace slug (default: active login)")
|
|
@@ -4,6 +4,7 @@ interface CreateOpts {
|
|
|
4
4
|
episode?: string;
|
|
5
5
|
description?: string;
|
|
6
6
|
tags?: string;
|
|
7
|
+
yes?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare function runCreateBindr(name: string, opts: CreateOpts): Promise<number>;
|
|
9
10
|
export declare function runCreateDataset(name: string, opts: CreateOpts): Promise<number>;
|
package/dist/cli/create/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
// bindr — members are EPISODES matched by `--episode <glob>` (node path)
|
|
5
|
-
// dataset — created empty; add bindrs later via `update dataset`
|
|
1
|
+
import { bindrsApi, BindrMembersError } from "../../api/bindrs.js";
|
|
2
|
+
import { createTransport, namespaceSeg, seg } from "../../api/client.js";
|
|
6
3
|
import { HttpError, requestJson } from "../client.js";
|
|
7
4
|
import { resolveNamespace, resolveRemote, resolveToken } from "../config.js";
|
|
8
5
|
import { fail, ok, splitCsv } from "../helpers.js";
|
|
@@ -18,7 +15,7 @@ export async function runCreateBindr(name, opts) {
|
|
|
18
15
|
if (!ctx)
|
|
19
16
|
return 1;
|
|
20
17
|
const { s, token, remote } = ctx;
|
|
21
|
-
const base = `/namespaces/${s.namespace}/projects/${s.project}/bindrs`;
|
|
18
|
+
const base = `/namespaces/${namespaceSeg(s.namespace)}/projects/${seg(s.project)}/bindrs`;
|
|
22
19
|
let members = [];
|
|
23
20
|
if (opts.episode) {
|
|
24
21
|
const episodes = await fetchAllEpisodes(remote, s.namespace, s.project, token, { includeArchived: true });
|
|
@@ -30,21 +27,27 @@ export async function runCreateBindr(name, opts) {
|
|
|
30
27
|
process.stdout.write(`Matched ${matched.length} episode(s):\n`);
|
|
31
28
|
for (const ep of matched)
|
|
32
29
|
process.stdout.write(` ${ep.nodePath ?? ep.name ?? ""}\n`);
|
|
33
|
-
const proceed = await confirm(`Create bindr '${name}' with ${matched.length} episodes?`, false);
|
|
30
|
+
const proceed = opts.yes || await confirm(`Create bindr '${name}' with ${matched.length} episodes?`, false);
|
|
34
31
|
if (!proceed) {
|
|
35
32
|
process.stdout.write("Cancelled.\n");
|
|
36
33
|
return 0;
|
|
37
34
|
}
|
|
38
35
|
members = matched.map((ep) => ep.id);
|
|
39
36
|
}
|
|
40
|
-
const body = { name
|
|
37
|
+
const body = { name };
|
|
41
38
|
if (opts.description)
|
|
42
39
|
body.description = opts.description;
|
|
43
40
|
const tags = splitCsv(opts.tags);
|
|
44
41
|
if (tags.length)
|
|
45
42
|
body.tags = tags;
|
|
43
|
+
let bindrId;
|
|
46
44
|
try {
|
|
47
|
-
await requestJson(remote, base, { method: "POST", token, json: body });
|
|
45
|
+
const created = await requestJson(remote, base, { method: "POST", token, json: body });
|
|
46
|
+
if (!created?.bindr || typeof created.bindr.id !== "string" || !created.bindr.id.trim()) {
|
|
47
|
+
fail(`Bindr creation returned success without a usable Bindr ID. '${name}' may have been created in ${formatProject(s)}; inspect the project before retrying. No episode tagging requests were sent.`);
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
bindrId = created.bindr.id;
|
|
48
51
|
}
|
|
49
52
|
catch (err) {
|
|
50
53
|
if (err instanceof HttpError && err.status === 409) {
|
|
@@ -58,7 +61,17 @@ export async function runCreateBindr(name, opts) {
|
|
|
58
61
|
fail(err.message);
|
|
59
62
|
return 1;
|
|
60
63
|
}
|
|
64
|
+
if (members.length) {
|
|
65
|
+
try {
|
|
66
|
+
await bindrsApi(createTransport({ remote, token }), s.namespace, s.project).addMembers(bindrId, members);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
fail(`Created bindr '${name}' (${bindrId}), but episode tagging did not complete. ${err instanceof BindrMembersError ? err.message : String(err)}. Inspect this bindr before retrying; it was not deleted.`);
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
61
73
|
ok(`Created bindr: ${name} in ${formatProject(s)}`);
|
|
74
|
+
process.stdout.write(` id: ${bindrId}\n`);
|
|
62
75
|
if (members.length)
|
|
63
76
|
process.stdout.write(` episodes: ${members.length}\n`);
|
|
64
77
|
if (opts.description)
|
|
@@ -191,6 +204,7 @@ export function registerCreateCommand(program) {
|
|
|
191
204
|
.argument("<name>", "bindr name")
|
|
192
205
|
.requiredOption("--project <target>", "project scope: space[@namespace]")
|
|
193
206
|
.option("--episode <glob>", "glob to match episodes by node path")
|
|
207
|
+
.option("--yes", "skip the confirmation prompt")
|
|
194
208
|
.option("--description <text>", "description")
|
|
195
209
|
.option("--tags <list>", "comma-separated tags")
|
|
196
210
|
.action(async (name, opts) => {
|
package/dist/cli/delete/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
// Port of dreamlake-py's cli/commands/delete.py.
|
|
1
|
+
import { seg } from "../../api/client.js";
|
|
3
2
|
import { HttpError, requestJson } from "../client.js";
|
|
4
3
|
import { resolveNamespace, resolveRemote, resolveToken } from "../config.js";
|
|
5
4
|
import { fail, ok } from "../helpers.js";
|
|
6
5
|
import { confirm } from "../prompt.js";
|
|
7
|
-
import { fetchAllEpisodes, fetchProjects, lookupNode, resolveProjectCtx, } from "../resources.js";
|
|
6
|
+
import { fetchAllEpisodes, fetchProjects, lookupNode, resolveProjectCtx, resolveBindr, } from "../resources.js";
|
|
8
7
|
import { formatProject, parseTarget } from "../target.js";
|
|
9
8
|
async function runDelete(kind, name, opts) {
|
|
10
9
|
if (!opts.project) {
|
|
@@ -16,6 +15,16 @@ async function runDelete(kind, name, opts) {
|
|
|
16
15
|
return 1;
|
|
17
16
|
const { s, token, remote } = ctx;
|
|
18
17
|
const proj = formatProject(s);
|
|
18
|
+
let bindrId;
|
|
19
|
+
if (kind === "bindr") {
|
|
20
|
+
try {
|
|
21
|
+
bindrId = (await resolveBindr(ctx, name)).id;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
fail(err.message);
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
19
28
|
if (!opts.yes) {
|
|
20
29
|
const proceed = await confirm(`Delete ${kind} '${name}' from ${proj}?`, false);
|
|
21
30
|
if (!proceed) {
|
|
@@ -25,7 +34,7 @@ async function runDelete(kind, name, opts) {
|
|
|
25
34
|
}
|
|
26
35
|
const collection = kind === "bindr" ? "bindrs" : "datasets";
|
|
27
36
|
try {
|
|
28
|
-
await requestJson(remote, `/namespaces/${s.namespace}/projects/${s.project}/${collection}/${name}`, { method: "DELETE", token });
|
|
37
|
+
await requestJson(remote, bindrId ? `/bindrs/${seg(bindrId)}` : `/namespaces/${seg(s.namespace)}/projects/${seg(s.project)}/${collection}/${seg(name)}`, { method: "DELETE", token });
|
|
29
38
|
}
|
|
30
39
|
catch (err) {
|
|
31
40
|
if (err instanceof HttpError && err.status === 404) {
|
|
@@ -5,6 +5,16 @@ export const helpExamples = {
|
|
|
5
5
|
"agents show": "dreamlake agents show my_repo.tri --namespace my-workspace",
|
|
6
6
|
"agents edit": "dreamlake agents edit my_repo.tri --namespace my-workspace\n# Browser form: follow the localhost URL printed by the command.\ndreamlake agents edit my_repo.tri --namespace my-workspace --web",
|
|
7
7
|
"telemetry": "dreamlake telemetry disable --quiet\ndreamlake telemetry status\ndreamlake telemetry enable --quiet",
|
|
8
|
+
"apps": "dreamlake apps list --json\ndreamlake connection oauth create --connector slack-mcp --label \"Work Slack\" --access read\ndreamlake connection oauth create --connector plaud-mcp --label \"My Plaud\" --access read",
|
|
9
|
+
"apps grant": "dreamlake apps grant <connection-id>",
|
|
10
|
+
"apps check": "dreamlake apps check <connection-id> --json",
|
|
11
|
+
"apps tools": "dreamlake apps tools <connection-id> --json",
|
|
12
|
+
"apps read": "dreamlake apps read <connection-id> <read-tool> --input-file query.json --json",
|
|
13
|
+
"apps prepare": "dreamlake apps prepare <connection-id> slack_send_message --input-file message.json --json",
|
|
14
|
+
"apps receipt": "dreamlake apps receipt <action-id> --json",
|
|
15
|
+
"apps confirm": "dreamlake apps confirm <action-id>",
|
|
16
|
+
"apps cancel": "dreamlake apps cancel <action-id> --json",
|
|
17
|
+
"apps revoke": "dreamlake apps revoke <connection-id>",
|
|
8
18
|
"artifact push": "dreamlake artifact push ./dashboard.html --id q1-dashboard\n# Edit the file, then repeat the same command to upload only new chunks.\n\n# Static build with on-demand assets (CLI 0.101.0+; requires site hosting):\ndreamlake artifact push ./dist/client --site --id simulation\n\n# Compatibility with older self-hosted viewers:\ndreamlake artifact push ./dashboard.html --id q1-dashboard --full\n\n# Multiple self-contained HTML pages (requires an updated viewer):\ndreamlake artifact push ./report --entry index.html --id quarterly-report",
|
|
9
19
|
"artifact meta set": "# At push time:\ndreamlake artifact push ./report.html --id q1-dashboard \\\n --description \"Revenue, churn and pipeline for the quarter\" \\\n --cover ./cover.png\n\n# Or after the fact, for an artifact that already exists:\ndreamlake artifact meta set q1-dashboard --description \"Revenue, churn and pipeline\"\ndreamlake artifact meta set q1-dashboard --cover ./cover.png\ndreamlake artifact meta show q1-dashboard\n\n# Back to the automatic description / the generated cover:\ndreamlake artifact meta set q1-dashboard --clear-description --clear-cover",
|
|
10
20
|
"artifact share": "# Find the dashboard you already uploaded; no new version is needed.\ndreamlake artifact list\nARTIFACT=\"q1-dashboard\" # Replace with the id from list.\ndreamlake artifact share get \"$ARTIFACT\"\n\n# Give signed-in recipients read access, then verify the returned link.\ndreamlake artifact share create \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"\n\n# When link access is no longer needed, revoke it and verify.\ndreamlake artifact share revoke \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"",
|
|
@@ -80,6 +90,7 @@ export const helpExamples = {
|
|
|
80
90
|
"infra transfer create": "dreamlake infra transfer create 616658fd-531c-4bb9-8f52-7ebcbaa350b9 \\\n --request-file stack-transfer.json --confirm --accept-if-authorized",
|
|
81
91
|
"infra transfer status": "dreamlake infra transfer status 616658fd-531c-4bb9-8f52-7ebcbaa350b1 \\\n --out stack-transfer-acceptance.json",
|
|
82
92
|
"infra transfer accept": "dreamlake infra transfer accept 616658fd-531c-4bb9-8f52-7ebcbaa350b1 \\\n --request-file stack-transfer-acceptance.json --confirm",
|
|
93
|
+
"install": "# Reinstall and configure the shell selected by SHELL.\ndreamlake install\n# Install a channel without editing shell startup files or user PATH.\ndreamlake install stable --no-modify-path",
|
|
83
94
|
"jobs register": "dreamlake jobs register --namespace geyang --name train-baseline \\\n --host 0123456789abcdef01234567 --request-id train-baseline-01",
|
|
84
95
|
"jobs report": "dreamlake jobs report 89abcdef0123456789abcdef --namespace geyang --state running\ndreamlake jobs report 89abcdef0123456789abcdef --namespace geyang \\\n --state succeeded --exit-code 0\ndreamlake jobs report fedcba9876543210fedcba98 --namespace geyang \\\n --state failed --exit-code 7 --message 'Training process exited with an error'",
|
|
85
96
|
"jobs list": "dreamlake jobs list --namespace geyang\ndreamlake jobs list --namespace geyang --host 0123456789abcdef01234567 --state running\ndreamlake jobs list --namespace geyang --page 2 --page-size 50 --json",
|
|
@@ -149,6 +160,7 @@ export const helpExamples = {
|
|
|
149
160
|
"ownership snapshot": "dreamlake ownership snapshot 000000000000000000000001 --namespace acme",
|
|
150
161
|
"ownership snapshot-cleanup": "# Inspect eligibility without deleting anything (the default).\ndreamlake ownership snapshot-cleanup 000000000000000000000001 --namespace acme\n# Delete only after server retention and recovery checks pass.\ndreamlake ownership snapshot-cleanup 000000000000000000000001 --namespace acme --execute",
|
|
151
162
|
"project move": "# Save a read-only streaming review with its stable request/key.\ndreamlake project move research --namespace personal --to acme --dry-run --out project-move-review.json\n# Confirm that exact saved review; the recipient must accept separately.\ndreamlake project move research --namespace personal --to acme --confirm --request-file project-move-review.json\n# Accept only with verified destination namespace authority, then wait a bounded time.\ndreamlake project move research --namespace personal --to acme --confirm --request-file project-move-review.json --accept-if-authorized --wait",
|
|
163
|
+
"create bindr": "# Seed a Bindr with matching episodes without an interactive prompt.\ndreamlake create bindr front-cam --project my-robots --episode \"camera/front/*\" --yes",
|
|
152
164
|
"project inspect": "dreamlake project inspect research --namespace acme",
|
|
153
165
|
"project grants": "dreamlake project grants research --namespace acme",
|
|
154
166
|
"project grant": "dreamlake project grant research --namespace acme --user teammate --role WRITE\ndreamlake project grant research --namespace acme --team TEAM_ID --role READ",
|
package/dist/cli/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { registerTeamCommand } from "./team/index.js";
|
|
|
33
33
|
import { registerPipelineCommand } from "./pipeline/index.js";
|
|
34
34
|
import { registerWorkflowCommand } from "./workflow/index.js";
|
|
35
35
|
import { registerPageCommand } from "./page/index.js";
|
|
36
|
+
import { registerAppsCommand } from "./apps/index.js";
|
|
36
37
|
import { registerConnectionCommand } from "./connection/index.js";
|
|
37
38
|
import { registerSourceCommand } from "./source/index.js";
|
|
38
39
|
import { registerTasksCommand } from "./tasks/index.js";
|
|
@@ -205,6 +206,7 @@ async function main(argv) {
|
|
|
205
206
|
registerProjectCommand(program);
|
|
206
207
|
registerTasksCommand(program);
|
|
207
208
|
registerConnectionCommand(program);
|
|
209
|
+
registerAppsCommand(program);
|
|
208
210
|
// ─── declaration collections ─────────────────────────────────────
|
|
209
211
|
//
|
|
210
212
|
// `declare` writes the five head collections; `runnable` and
|
package/dist/cli/list/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Port of dreamlake-py's cli/commands/list.py. Where the Python CLI used
|
|
3
|
-
// an interactive 20-per-page pager, we fetch all pages and render one
|
|
4
|
-
// table (more script-friendly); `--json` emits raw JSON.
|
|
1
|
+
import { seg } from "../../api/client.js";
|
|
5
2
|
import { resolveNamespace, resolveRemote, resolveToken } from "../config.js";
|
|
6
3
|
import { emitJson, fail, humanSize, renderTable } from "../helpers.js";
|
|
7
4
|
import { fetchAllContents, fetchAllEpisodes, fetchAllPages, fetchProjects, nodePathToCommaPrefix, relPathUnder, resolveProjectCtx, } from "../resources.js";
|
|
@@ -126,7 +123,7 @@ export async function runListBindrs(opts) {
|
|
|
126
123
|
if (!ctx)
|
|
127
124
|
return 1;
|
|
128
125
|
const { s, token, remote } = ctx;
|
|
129
|
-
const result = await fetchAllPages(remote, `/namespaces/${s.namespace}/projects/${s.project}/bindrs`, token, "bindrs");
|
|
126
|
+
const result = await fetchAllPages(remote, `/namespaces/${seg(s.namespace)}/projects/${seg(s.project)}/bindrs`, token, "bindrs");
|
|
130
127
|
if (result === "not-found") {
|
|
131
128
|
process.stdout.write(" (project not found)\n");
|
|
132
129
|
return 0;
|
|
@@ -138,12 +135,13 @@ export async function runListBindrs(opts) {
|
|
|
138
135
|
process.stdout.write(`Listing bindrs in ${formatProject(s)}\n\n`);
|
|
139
136
|
const rows = result.items.map((d) => ({
|
|
140
137
|
name: String(d.name ?? ""),
|
|
141
|
-
|
|
138
|
+
id: String(d.id ?? ""),
|
|
139
|
+
members: typeof d.memberCount === "number" ? d.memberCount : "?",
|
|
142
140
|
tags: Array.isArray(d.tags) ? d.tags.join(", ") : "",
|
|
143
141
|
description: String(d.description ?? "").slice(0, 40),
|
|
144
142
|
created: String(d.createdAt ?? "").slice(0, 10),
|
|
145
143
|
}));
|
|
146
|
-
process.stdout.write(renderTable(rows, ["name", "
|
|
144
|
+
process.stdout.write(renderTable(rows, ["name", "id", "members", "tags", "description", "created"]));
|
|
147
145
|
process.stdout.write(`\n ${result.total} bindr(s)\n`);
|
|
148
146
|
return 0;
|
|
149
147
|
}
|
package/dist/cli/resources.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export declare function fetchAllEpisodes(remote: string, namespace: string, proj
|
|
|
26
26
|
}): Promise<EpisodeRec[]>;
|
|
27
27
|
/** Fetch all bindrs in a project (throws on error). */
|
|
28
28
|
export declare function fetchAllBindrs(remote: string, namespace: string, project: string, token: string): Promise<BindrRec[]>;
|
|
29
|
+
/** Resolve once before a mutation or confirmation; never silently pick a duplicate name. */
|
|
30
|
+
export declare function resolveBindr(ctx: ProjectCtx, nameOrId: string): Promise<BindrRec>;
|
|
29
31
|
/** Match episodes by glob against their name OR node path (leading "/" stripped). */
|
|
30
32
|
export declare function matchEpisodes(episodes: EpisodeRec[], pattern: string): EpisodeRec[];
|
|
31
33
|
/** Match bindrs by glob against their name. */
|