@foleo/cli 0.1.36 → 0.1.45
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/README.md +24 -0
- package/dist/encoded-image-cache.d.ts +14 -0
- package/dist/encoded-image-cache.d.ts.map +1 -0
- package/dist/encoded-image-cache.js +123 -0
- package/dist/encoded-image-cache.js.map +1 -0
- package/dist/image-encoder.d.ts +16 -0
- package/dist/image-encoder.d.ts.map +1 -0
- package/dist/image-encoder.js +142 -0
- package/dist/image-encoder.js.map +1 -0
- package/dist/images.d.ts +85 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +411 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +983 -166
- package/dist/index.js.map +1 -1
- package/dist/workspaces.d.ts +10 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +533 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +1 -1
- package/skills/foleo/SKILL.md +208 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const WORKSPACE_HELP = "Managed workspaces (staging/local; explicit workspace grant required):\n foleo workspace list [--json]\n foleo workspace items <workspaceId> [--parent <id>] [--state live|trashed] [--cursor <cursor>] [--limit <1-100>] [--json]\n foleo workspace get <workspaceId> <itemId> [--json]\n foleo workspace read <workspaceId> <itemId> --output <path> [--revision <id>] [--json]\n foleo workspace history <workspaceId> <itemId> [--cursor <cursor>] [--limit <1-100>] [--json]\n foleo workspace capabilities [--json]\n foleo capabilities [--json]\n foleo workspace create <name> [--mutation-id <id>] [--json]\n foleo workspace put <workspaceId> <path> (--parent <id> [--name <name>] | --item <id>) [--mutation-id <id>] [--json]\n foleo workspace mkdir <workspaceId> --parent <id> --name <name> [--mutation-id <id>] [--json]\n foleo workspace move <workspaceId> <itemId> --parent <id> --name <name> [--mutation-id <id>] [--json]\n foleo workspace trash <workspaceId> <itemId> [--mutation-id <id>] [--json]\n foleo workspace restore <workspaceId> <itemId> --parent <id> --name <name> [--mutation-id <id>] [--json]\n foleo workspace commit <workspaceId> --input <json-file> [--json]\n foleo workspace commit-status <workspaceId> <mutationId> [--json]\n foleo workspace upload-status <workspaceId> <uploadId> [--json]\n foleo workspace upload-cancel <workspaceId> <uploadId> [--json]\n foleo workspace share get <workspaceId> <itemId> [--json]\n foleo workspace share set <workspaceId> <itemId> --mode private|link|password|public|inherit [--password-stdin] [--mutation-id <id>] [--json]\n foleo approval get <approvalId> [--json]\n foleo approval commit <approvalId> --idempotency-key <key> [--json]\nWrites require workspaces:read + workspaces:write. Sharing requires workspaces:read + workspaces:share.\nNew items are Private. Widening requires human approval in Foleo, then approval commit; narrowing applies immediately.\nHash-first put uploads zero bytes when unchanged (32 MiB/file). Batches accept eight operations.\nOn response loss retry the exact commit payload and mutation ID, or use commit-status. Never mint a new ID just because a response was lost.\nSaves do not publish files or change sharing.\n";
|
|
2
|
+
type WorkspaceDeps = {
|
|
3
|
+
request(path: string, init?: RequestInit): Promise<Response>;
|
|
4
|
+
stdout(value: string): void;
|
|
5
|
+
readStdin?(): Promise<string>;
|
|
6
|
+
};
|
|
7
|
+
/** Read-only adapters; the server owns authorization, pagination and bytes. */
|
|
8
|
+
export declare function workspaceCommand(args: string[], deps: WorkspaceDeps): Promise<number>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,irEA2B1B,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF,+EAA+E;AAC/E,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,mBA6HzE"}
|
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { createHash, randomUUID, randomBytes, pbkdf2Sync } from "node:crypto";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { open, readFile } from "node:fs/promises";
|
|
4
|
+
import { basename } from "node:path";
|
|
5
|
+
import { LocalError, FoleoError } from "./errors.js";
|
|
6
|
+
import { createWriteStream } from "node:fs";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
import { pipeline } from "node:stream/promises";
|
|
9
|
+
import { UsageError } from "./errors.js";
|
|
10
|
+
export const WORKSPACE_HELP = `Managed workspaces (staging/local; explicit workspace grant required):
|
|
11
|
+
foleo workspace list [--json]
|
|
12
|
+
foleo workspace items <workspaceId> [--parent <id>] [--state live|trashed] [--cursor <cursor>] [--limit <1-100>] [--json]
|
|
13
|
+
foleo workspace get <workspaceId> <itemId> [--json]
|
|
14
|
+
foleo workspace read <workspaceId> <itemId> --output <path> [--revision <id>] [--json]
|
|
15
|
+
foleo workspace history <workspaceId> <itemId> [--cursor <cursor>] [--limit <1-100>] [--json]
|
|
16
|
+
foleo workspace capabilities [--json]
|
|
17
|
+
foleo capabilities [--json]
|
|
18
|
+
foleo workspace create <name> [--mutation-id <id>] [--json]
|
|
19
|
+
foleo workspace put <workspaceId> <path> (--parent <id> [--name <name>] | --item <id>) [--mutation-id <id>] [--json]
|
|
20
|
+
foleo workspace mkdir <workspaceId> --parent <id> --name <name> [--mutation-id <id>] [--json]
|
|
21
|
+
foleo workspace move <workspaceId> <itemId> --parent <id> --name <name> [--mutation-id <id>] [--json]
|
|
22
|
+
foleo workspace trash <workspaceId> <itemId> [--mutation-id <id>] [--json]
|
|
23
|
+
foleo workspace restore <workspaceId> <itemId> --parent <id> --name <name> [--mutation-id <id>] [--json]
|
|
24
|
+
foleo workspace commit <workspaceId> --input <json-file> [--json]
|
|
25
|
+
foleo workspace commit-status <workspaceId> <mutationId> [--json]
|
|
26
|
+
foleo workspace upload-status <workspaceId> <uploadId> [--json]
|
|
27
|
+
foleo workspace upload-cancel <workspaceId> <uploadId> [--json]
|
|
28
|
+
foleo workspace share get <workspaceId> <itemId> [--json]
|
|
29
|
+
foleo workspace share set <workspaceId> <itemId> --mode private|link|password|public|inherit [--password-stdin] [--mutation-id <id>] [--json]
|
|
30
|
+
foleo approval get <approvalId> [--json]
|
|
31
|
+
foleo approval commit <approvalId> --idempotency-key <key> [--json]
|
|
32
|
+
Writes require workspaces:read + workspaces:write. Sharing requires workspaces:read + workspaces:share.
|
|
33
|
+
New items are Private. Widening requires human approval in Foleo, then approval commit; narrowing applies immediately.
|
|
34
|
+
Hash-first put uploads zero bytes when unchanged (32 MiB/file). Batches accept eight operations.
|
|
35
|
+
On response loss retry the exact commit payload and mutation ID, or use commit-status. Never mint a new ID just because a response was lost.
|
|
36
|
+
Saves do not publish files or change sharing.
|
|
37
|
+
`;
|
|
38
|
+
/** Read-only adapters; the server owns authorization, pagination and bytes. */
|
|
39
|
+
export async function workspaceCommand(args, deps) {
|
|
40
|
+
const [command, ...rest] = args;
|
|
41
|
+
if (command === "share" || command === "approval")
|
|
42
|
+
return workspaceSharing(command, rest, deps);
|
|
43
|
+
if (!command || command === "--help" || command === "help") {
|
|
44
|
+
deps.stdout(WORKSPACE_HELP);
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
const positionals = [];
|
|
48
|
+
const flags = new Map();
|
|
49
|
+
const allowed = new Set([
|
|
50
|
+
"--parent",
|
|
51
|
+
"--state",
|
|
52
|
+
"--cursor",
|
|
53
|
+
"--limit",
|
|
54
|
+
"--output",
|
|
55
|
+
"--revision",
|
|
56
|
+
"--item",
|
|
57
|
+
"--name",
|
|
58
|
+
"--input",
|
|
59
|
+
"--mutation-id",
|
|
60
|
+
]);
|
|
61
|
+
for (let i = 0; i < rest.length; i++) {
|
|
62
|
+
const value = rest[i];
|
|
63
|
+
if (value === "--json")
|
|
64
|
+
continue;
|
|
65
|
+
if (value.startsWith("--")) {
|
|
66
|
+
const next = rest[++i];
|
|
67
|
+
if (!allowed.has(value) ||
|
|
68
|
+
!next ||
|
|
69
|
+
next.startsWith("--") ||
|
|
70
|
+
flags.has(value))
|
|
71
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
72
|
+
flags.set(value, next);
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
positionals.push(value);
|
|
76
|
+
}
|
|
77
|
+
if ([
|
|
78
|
+
"create",
|
|
79
|
+
"put",
|
|
80
|
+
"mkdir",
|
|
81
|
+
"move",
|
|
82
|
+
"trash",
|
|
83
|
+
"restore",
|
|
84
|
+
"commit",
|
|
85
|
+
"commit-status",
|
|
86
|
+
"upload-status",
|
|
87
|
+
"upload-cancel",
|
|
88
|
+
].includes(command))
|
|
89
|
+
return workspaceMutation(command, positionals, flags, deps);
|
|
90
|
+
const count = command === "list" || command === "capabilities"
|
|
91
|
+
? 0
|
|
92
|
+
: command === "items"
|
|
93
|
+
? 1
|
|
94
|
+
: 2;
|
|
95
|
+
const validFlags = command === "items"
|
|
96
|
+
? ["--parent", "--state", "--cursor", "--limit"]
|
|
97
|
+
: command === "history"
|
|
98
|
+
? ["--cursor", "--limit"]
|
|
99
|
+
: command === "read"
|
|
100
|
+
? ["--output", "--revision"]
|
|
101
|
+
: [];
|
|
102
|
+
if (!["list", "items", "get", "read", "history", "capabilities"].includes(command) ||
|
|
103
|
+
positionals.length !== count ||
|
|
104
|
+
[...flags.keys()].some((key) => !validFlags.includes(key)))
|
|
105
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
106
|
+
const limit = flags.get("--limit");
|
|
107
|
+
if (limit &&
|
|
108
|
+
(!/^\d+$/u.test(limit) || Number(limit) < 1 || Number(limit) > 100))
|
|
109
|
+
throw new UsageError("--limit must be between 1 and 100.");
|
|
110
|
+
if (command === "read" && !flags.has("--output"))
|
|
111
|
+
throw new UsageError("workspace read requires --output <path>.");
|
|
112
|
+
const [wid, iid] = positionals.map(encodeURIComponent);
|
|
113
|
+
const base = `/workspaces/${wid}/items`;
|
|
114
|
+
const path = command === "capabilities"
|
|
115
|
+
? "/capabilities"
|
|
116
|
+
: command === "list"
|
|
117
|
+
? "/workspaces"
|
|
118
|
+
: command === "items"
|
|
119
|
+
? base
|
|
120
|
+
: `${base}/${iid}${command === "read" ? "/content" : command === "history" ? "/revisions" : ""}`;
|
|
121
|
+
const query = new URLSearchParams();
|
|
122
|
+
for (const [flag, key] of [
|
|
123
|
+
["--parent", "parentId"],
|
|
124
|
+
["--state", "state"],
|
|
125
|
+
["--cursor", "cursor"],
|
|
126
|
+
["--limit", "limit"],
|
|
127
|
+
["--revision", "revisionId"],
|
|
128
|
+
]) {
|
|
129
|
+
if (flags.has(flag))
|
|
130
|
+
query.set(key, flags.get(flag));
|
|
131
|
+
}
|
|
132
|
+
const response = await deps.request(`${path}${query.size ? `?${query}` : ""}`);
|
|
133
|
+
if (command === "read") {
|
|
134
|
+
if (!response.body)
|
|
135
|
+
throw new Error("Workspace content response had no body.");
|
|
136
|
+
const output = flags.get("--output");
|
|
137
|
+
await pipeline(Readable.fromWeb(response.body), createWriteStream(output, { flags: "wx" }));
|
|
138
|
+
deps.stdout(`${JSON.stringify({ output, revisionId: response.headers.get("x-foleo-revision-id"), sha256: response.headers.get("x-foleo-sha256"), size: Number(response.headers.get("content-length")) }, null, 2)}\n`);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const value = (await response.json());
|
|
142
|
+
deps.stdout(`${JSON.stringify(command === "capabilities" ? value.workspaces : value, null, 2)}\n`);
|
|
143
|
+
}
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
/** Capture one bounded, stable file before hashing; never reopen it for upload. */
|
|
147
|
+
async function captureFile(path) {
|
|
148
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
149
|
+
const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
150
|
+
try {
|
|
151
|
+
const before = await handle.stat({ bigint: true });
|
|
152
|
+
if (!before.isFile() || before.size > 33554432n)
|
|
153
|
+
throw new UsageError("workspace put requires a regular file of at most 32 MiB.");
|
|
154
|
+
const chunks = [];
|
|
155
|
+
let size = 0;
|
|
156
|
+
for (;;) {
|
|
157
|
+
const buffer = Buffer.alloc(65536);
|
|
158
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, null);
|
|
159
|
+
if (!bytesRead)
|
|
160
|
+
break;
|
|
161
|
+
size += bytesRead;
|
|
162
|
+
if (size > 33554432)
|
|
163
|
+
throw new UsageError("workspace put requires a file of at most 32 MiB.");
|
|
164
|
+
chunks.push(buffer.subarray(0, bytesRead));
|
|
165
|
+
}
|
|
166
|
+
const after = await handle.stat({ bigint: true });
|
|
167
|
+
if (before.size !== after.size ||
|
|
168
|
+
before.mtimeNs !== after.mtimeNs ||
|
|
169
|
+
before.ctimeNs !== after.ctimeNs ||
|
|
170
|
+
BigInt(size) !== after.size)
|
|
171
|
+
continue;
|
|
172
|
+
const bytes = Buffer.concat(chunks, size);
|
|
173
|
+
return {
|
|
174
|
+
bytes,
|
|
175
|
+
size,
|
|
176
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
await handle.close();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
throw new LocalError("file_changed_during_capture", "File changed during capture; retry after it stops changing.");
|
|
184
|
+
}
|
|
185
|
+
async function workspaceMutation(command, positionals, flags, deps) {
|
|
186
|
+
const count = ["create", "mkdir", "commit"].includes(command) ? 1 : 2;
|
|
187
|
+
const allowed = command === "put"
|
|
188
|
+
? ["--parent", "--name", "--item", "--mutation-id"]
|
|
189
|
+
: command === "mkdir" || command === "move" || command === "restore"
|
|
190
|
+
? ["--parent", "--name", "--mutation-id"]
|
|
191
|
+
: command === "create" || command === "trash"
|
|
192
|
+
? ["--mutation-id"]
|
|
193
|
+
: command === "commit"
|
|
194
|
+
? ["--input"]
|
|
195
|
+
: [];
|
|
196
|
+
if (positionals.length !== count ||
|
|
197
|
+
[...flags.keys()].some((flag) => !allowed.includes(flag)))
|
|
198
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
199
|
+
if ((["mkdir", "move", "restore"].includes(command) &&
|
|
200
|
+
(!flags.has("--parent") || !flags.has("--name"))) ||
|
|
201
|
+
(command === "commit" && !flags.has("--input")) ||
|
|
202
|
+
(command === "put" &&
|
|
203
|
+
(flags.has("--item") === flags.has("--parent") ||
|
|
204
|
+
(flags.has("--item") && flags.has("--name")))))
|
|
205
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
206
|
+
const wid = encodeURIComponent(positionals[0]), iid = encodeURIComponent(positionals[1] ?? "");
|
|
207
|
+
const base = `/workspaces/${wid}`;
|
|
208
|
+
const json = async (path, init) => (await deps.request(path, init)).json();
|
|
209
|
+
const send = (path, value) => json(path, {
|
|
210
|
+
method: "POST",
|
|
211
|
+
headers: { "content-type": "application/json" },
|
|
212
|
+
body: JSON.stringify(value),
|
|
213
|
+
});
|
|
214
|
+
const print = (value) => deps.stdout(`${JSON.stringify(value, null, 2)}\n`);
|
|
215
|
+
if (command === "commit-status" ||
|
|
216
|
+
command === "upload-status" ||
|
|
217
|
+
command === "upload-cancel") {
|
|
218
|
+
print(await json(`${base}/${command === "commit-status" ? "commits" : "uploads"}/${iid}${command === "upload-cancel" ? "/cancel" : ""}`, command === "upload-cancel" ? { method: "POST" } : undefined));
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
if (command === "commit") {
|
|
222
|
+
const text = await readFile(flags.get("--input"), "utf8");
|
|
223
|
+
if (Buffer.byteLength(text) > 262144)
|
|
224
|
+
throw new UsageError("Commit metadata exceeds 256 KiB.");
|
|
225
|
+
const input = JSON.parse(text);
|
|
226
|
+
try {
|
|
227
|
+
print(await send(`${base}/commits`, input));
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
if (error instanceof FoleoError && (error.httpStatus ?? 0) < 500)
|
|
231
|
+
throw error;
|
|
232
|
+
const mutationId = input && typeof input === "object" && "clientMutationId" in input
|
|
233
|
+
? input.clientMutationId
|
|
234
|
+
: undefined;
|
|
235
|
+
if (typeof mutationId !== "string")
|
|
236
|
+
throw error;
|
|
237
|
+
try {
|
|
238
|
+
print(await json(`${base}/commits/${encodeURIComponent(mutationId)}`));
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
throw new LocalError("workspace_commit_unconfirmed", "Commit response unavailable. Recover using the original mutation ID.", {
|
|
242
|
+
next: `foleo workspace commit-status ${positionals[0]} ${mutationId} --json`,
|
|
243
|
+
context: { clientMutationId: mutationId, input },
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return 0;
|
|
248
|
+
}
|
|
249
|
+
const clientMutationId = flags.get("--mutation-id") ?? randomUUID();
|
|
250
|
+
if (command === "create") {
|
|
251
|
+
const payload = { clientMutationId, name: positionals[0] };
|
|
252
|
+
try {
|
|
253
|
+
print(await send("/workspaces", payload));
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
if (error instanceof FoleoError && (error.httpStatus ?? 0) < 500)
|
|
257
|
+
throw error;
|
|
258
|
+
try {
|
|
259
|
+
print(await send("/workspaces", payload));
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
throw new LocalError("workspace_create_unconfirmed", "Workspace creation response unavailable. Replay the same name and mutation ID.", {
|
|
263
|
+
next: `foleo workspace create ${JSON.stringify(positionals[0])} --mutation-id ${clientMutationId} --json`,
|
|
264
|
+
context: payload,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return 0;
|
|
269
|
+
}
|
|
270
|
+
const operations = [];
|
|
271
|
+
const metadata = async (id) => (await json(`${base}/items/${encodeURIComponent(id)}`));
|
|
272
|
+
const parent = flags.has("--parent")
|
|
273
|
+
? await metadata(flags.get("--parent"))
|
|
274
|
+
: undefined;
|
|
275
|
+
let uploadId;
|
|
276
|
+
let submitted = false;
|
|
277
|
+
const abort = new AbortController();
|
|
278
|
+
const interrupt = () => abort.abort(new Error("workspace_upload_interrupted"));
|
|
279
|
+
process.once("SIGINT", interrupt);
|
|
280
|
+
process.once("SIGTERM", interrupt);
|
|
281
|
+
try {
|
|
282
|
+
if (command === "put") {
|
|
283
|
+
const captured = await captureFile(positionals[1]);
|
|
284
|
+
const current = flags.has("--item")
|
|
285
|
+
? await metadata(flags.get("--item"))
|
|
286
|
+
: undefined;
|
|
287
|
+
if (current &&
|
|
288
|
+
current.sha256 === captured.sha256 &&
|
|
289
|
+
current.size === captured.size)
|
|
290
|
+
operations.push({
|
|
291
|
+
type: "sameContent",
|
|
292
|
+
itemId: current.id,
|
|
293
|
+
expectedRevisionId: current.revisionId,
|
|
294
|
+
sha256: captured.sha256,
|
|
295
|
+
size: captured.size,
|
|
296
|
+
});
|
|
297
|
+
else {
|
|
298
|
+
const upload = await send(`${base}/uploads`, {
|
|
299
|
+
clientMutationId,
|
|
300
|
+
size: captured.size,
|
|
301
|
+
sha256: captured.sha256,
|
|
302
|
+
mimeType: "application/octet-stream",
|
|
303
|
+
});
|
|
304
|
+
uploadId = upload.uploadId;
|
|
305
|
+
await deps.request(`${base}/uploads/${encodeURIComponent(uploadId)}/content`, {
|
|
306
|
+
method: "PUT",
|
|
307
|
+
headers: {
|
|
308
|
+
"content-length": String(captured.size),
|
|
309
|
+
"content-type": "application/octet-stream",
|
|
310
|
+
},
|
|
311
|
+
body: captured.bytes,
|
|
312
|
+
signal: abort.signal,
|
|
313
|
+
});
|
|
314
|
+
operations.push(current
|
|
315
|
+
? {
|
|
316
|
+
type: "replace",
|
|
317
|
+
itemId: current.id,
|
|
318
|
+
expectedRevisionId: current.revisionId,
|
|
319
|
+
expectedMetadataVersion: current.metadataVersion,
|
|
320
|
+
uploadId,
|
|
321
|
+
}
|
|
322
|
+
: {
|
|
323
|
+
type: "create",
|
|
324
|
+
clientOperationId: clientMutationId,
|
|
325
|
+
itemId: randomUUID(),
|
|
326
|
+
parentId: parent.id,
|
|
327
|
+
expectedParentMetadataVersion: parent.metadataVersion,
|
|
328
|
+
name: flags.get("--name") ?? basename(positionals[1]),
|
|
329
|
+
kind: "file",
|
|
330
|
+
uploadId,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
else if (command === "mkdir")
|
|
335
|
+
operations.push({
|
|
336
|
+
type: "create",
|
|
337
|
+
clientOperationId: clientMutationId,
|
|
338
|
+
itemId: randomUUID(),
|
|
339
|
+
parentId: parent.id,
|
|
340
|
+
expectedParentMetadataVersion: parent.metadataVersion,
|
|
341
|
+
name: flags.get("--name"),
|
|
342
|
+
kind: "folder",
|
|
343
|
+
});
|
|
344
|
+
else {
|
|
345
|
+
const item = await metadata(positionals[1]);
|
|
346
|
+
operations.push({
|
|
347
|
+
type: command,
|
|
348
|
+
itemId: item.id,
|
|
349
|
+
expectedMetadataVersion: item.metadataVersion,
|
|
350
|
+
...(command === "trash"
|
|
351
|
+
? { observedSubtreeToken: item.observedSubtreeToken }
|
|
352
|
+
: {
|
|
353
|
+
parentId: parent.id,
|
|
354
|
+
expectedParentMetadataVersion: parent.metadataVersion,
|
|
355
|
+
name: flags.get("--name"),
|
|
356
|
+
}),
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
if (abort.signal.aborted)
|
|
360
|
+
throw new LocalError("cancelled", "Upload cancelled; nothing was published.", { retryable: true });
|
|
361
|
+
// A lost response must never cause cancellation of a possibly committed upload.
|
|
362
|
+
submitted = true;
|
|
363
|
+
const input = { clientMutationId, operations };
|
|
364
|
+
let result;
|
|
365
|
+
try {
|
|
366
|
+
result = await send(`${base}/commits`, input);
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
if (error instanceof FoleoError && (error.httpStatus ?? 0) < 500) {
|
|
370
|
+
// A semantic conflict preserves staged bytes for the caller's decision.
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
result = await json(`${base}/commits/${encodeURIComponent(clientMutationId)}`);
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
throw new LocalError("workspace_commit_unconfirmed", "Commit response unavailable. Recover using the original mutation ID.", {
|
|
378
|
+
next: `foleo workspace commit-status ${positionals[0]} ${clientMutationId} --json`,
|
|
379
|
+
context: {
|
|
380
|
+
clientMutationId,
|
|
381
|
+
input,
|
|
382
|
+
cause: error instanceof Error ? error.message : "request_failed",
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// The kernel fences an unused no-op reservation atomically. An optional
|
|
388
|
+
// transport cleanup must never hide an accepted receipt.
|
|
389
|
+
print(result);
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
const interrupted = abort.signal.aborted && !submitted;
|
|
393
|
+
if (uploadId && !submitted)
|
|
394
|
+
try {
|
|
395
|
+
const cleanup = new AbortController();
|
|
396
|
+
let timer;
|
|
397
|
+
try {
|
|
398
|
+
await Promise.race([
|
|
399
|
+
deps.request(`${base}/uploads/${uploadId}/cancel`, {
|
|
400
|
+
method: "POST",
|
|
401
|
+
signal: cleanup.signal,
|
|
402
|
+
}),
|
|
403
|
+
new Promise((resolve) => {
|
|
404
|
+
timer = setTimeout(resolve, 2800);
|
|
405
|
+
}),
|
|
406
|
+
]);
|
|
407
|
+
}
|
|
408
|
+
finally {
|
|
409
|
+
clearTimeout(timer);
|
|
410
|
+
cleanup.abort();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
catch {
|
|
414
|
+
/* Preserve the original failure; upload-status allows recovery. */
|
|
415
|
+
}
|
|
416
|
+
if (interrupted)
|
|
417
|
+
throw new LocalError("cancelled", "Upload cancelled; nothing was published.", { retryable: true });
|
|
418
|
+
throw error;
|
|
419
|
+
}
|
|
420
|
+
finally {
|
|
421
|
+
process.removeListener("SIGINT", interrupt);
|
|
422
|
+
process.removeListener("SIGTERM", interrupt);
|
|
423
|
+
}
|
|
424
|
+
return 0;
|
|
425
|
+
}
|
|
426
|
+
async function workspaceSharing(family, args, deps) {
|
|
427
|
+
const [action, ...rest] = args;
|
|
428
|
+
const positionals = [], flags = new Map();
|
|
429
|
+
let passwordStdin = false;
|
|
430
|
+
for (let i = 0; i < rest.length; i++) {
|
|
431
|
+
const value = rest[i];
|
|
432
|
+
if (value === "--json")
|
|
433
|
+
continue;
|
|
434
|
+
if (value === "--password-stdin") {
|
|
435
|
+
if (passwordStdin)
|
|
436
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
437
|
+
passwordStdin = true;
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (value.startsWith("--")) {
|
|
441
|
+
if (!["--mode", "--mutation-id", "--idempotency-key"].includes(value) ||
|
|
442
|
+
flags.has(value) ||
|
|
443
|
+
!rest[i + 1] ||
|
|
444
|
+
rest[i + 1].startsWith("--"))
|
|
445
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
446
|
+
flags.set(value, rest[++i]);
|
|
447
|
+
}
|
|
448
|
+
else
|
|
449
|
+
positionals.push(value);
|
|
450
|
+
}
|
|
451
|
+
const approval = family === "approval";
|
|
452
|
+
if (!["get", approval ? "commit" : "set"].includes(action ?? "") ||
|
|
453
|
+
positionals.length !== (approval ? 1 : 2))
|
|
454
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
455
|
+
const allowed = action === "get"
|
|
456
|
+
? []
|
|
457
|
+
: approval
|
|
458
|
+
? ["--idempotency-key"]
|
|
459
|
+
: ["--mode", "--mutation-id"];
|
|
460
|
+
if ([...flags.keys()].some((flag) => !allowed.includes(flag)) ||
|
|
461
|
+
(passwordStdin &&
|
|
462
|
+
(approval || action !== "set" || flags.get("--mode") !== "password")))
|
|
463
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
464
|
+
const base = approval
|
|
465
|
+
? `/agent-approvals/${encodeURIComponent(positionals[0])}`
|
|
466
|
+
: `/workspaces/${encodeURIComponent(positionals[0])}/items/${encodeURIComponent(positionals[1])}`;
|
|
467
|
+
let path = approval ? base : `${base}/share`, init;
|
|
468
|
+
if (action === "commit") {
|
|
469
|
+
const key = flags.get("--idempotency-key");
|
|
470
|
+
if (!key || key.length < 8 || key.length > 200)
|
|
471
|
+
throw new UsageError("approval commit requires --idempotency-key (8–200 characters).");
|
|
472
|
+
path += "/commit";
|
|
473
|
+
init = { method: "POST", headers: { "idempotency-key": key } };
|
|
474
|
+
}
|
|
475
|
+
else if (action === "set") {
|
|
476
|
+
const mode = flags.get("--mode");
|
|
477
|
+
if (!mode ||
|
|
478
|
+
!["private", "link", "password", "public", "inherit"].includes(mode))
|
|
479
|
+
throw new UsageError(WORKSPACE_HELP);
|
|
480
|
+
if (mode === "password" && !passwordStdin)
|
|
481
|
+
throw new UsageError("Password mode requires --password-stdin; passwords are never accepted in argv.");
|
|
482
|
+
let passwordKey;
|
|
483
|
+
if (passwordStdin) {
|
|
484
|
+
if (!deps.readStdin)
|
|
485
|
+
throw new UsageError("Password stdin is unavailable.");
|
|
486
|
+
const password = (await deps.readStdin()).replace(/\r?\n$/u, "");
|
|
487
|
+
if (password.length < 8 || password.length > 256)
|
|
488
|
+
throw new UsageError("Use a password with 8–256 characters.");
|
|
489
|
+
const salt = randomBytes(16).toString("hex");
|
|
490
|
+
const bytes = Buffer.from(password, "utf8");
|
|
491
|
+
try {
|
|
492
|
+
passwordKey = {
|
|
493
|
+
version: 1,
|
|
494
|
+
algorithm: "PBKDF2-SHA256",
|
|
495
|
+
iterations: 600000,
|
|
496
|
+
salt,
|
|
497
|
+
derivedKey: pbkdf2Sync(bytes, Buffer.from(salt, "hex"), 600000, 32, "sha256").toString("hex"),
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
finally {
|
|
501
|
+
bytes.fill(0);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const metadata = (await (await deps.request(base)).json());
|
|
505
|
+
init = {
|
|
506
|
+
method: "POST",
|
|
507
|
+
headers: { "content-type": "application/json" },
|
|
508
|
+
body: JSON.stringify({
|
|
509
|
+
clientMutationId: flags.get("--mutation-id") ?? randomUUID(),
|
|
510
|
+
mode,
|
|
511
|
+
enabled: ["link", "password", "public"].includes(mode),
|
|
512
|
+
expectedMetadataVersion: metadata.metadataVersion,
|
|
513
|
+
expectedSequence: metadata.workspaceSequence,
|
|
514
|
+
...(passwordKey ? { passwordKey } : {}),
|
|
515
|
+
}),
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
let response;
|
|
519
|
+
try {
|
|
520
|
+
response = await deps.request(path, init);
|
|
521
|
+
}
|
|
522
|
+
catch (error) {
|
|
523
|
+
if (!init || (error instanceof FoleoError && (error.httpStatus ?? 0) < 500))
|
|
524
|
+
throw error;
|
|
525
|
+
// Retain the exact in-memory payload/key after response loss, including the
|
|
526
|
+
// stretched password. Never put secret-bearing recovery inputs in output.
|
|
527
|
+
response = await deps.request(path, init);
|
|
528
|
+
}
|
|
529
|
+
const result = await response.json();
|
|
530
|
+
deps.stdout(`${JSON.stringify(result, null, 2)}\n`);
|
|
531
|
+
return 0;
|
|
532
|
+
}
|
|
533
|
+
//# sourceMappingURL=workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC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