bazilion 0.15.0 → 0.17.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/cli.js +1138 -687
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +8401 -4401
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0001_init.sql +109 -0
- package/dist/web/client/assets/ChatPane-BI3QVX2A.js +76 -0
- package/dist/web/client/assets/{ConfirmDialog-CGZzom9E.js → ConfirmDialog-Qam6Ut08.js} +1 -1
- package/dist/web/client/assets/{FieldRow-DYNU9gWb.js → FieldRow-swJ5qn2h.js} +1 -1
- package/dist/web/client/assets/ProductionTeamPolicyEditor-LGw1UuF-.js +7 -0
- package/dist/web/client/assets/ProfileCommunicationEditor-raoau_YB.js +1 -0
- package/dist/web/client/assets/{ResultSourceConversation-CGhKTSTD.js → ResultSourceConversation-BEwkhFog.js} +1 -1
- package/dist/web/client/assets/TeamTabs-BDdTLGIf.js +1 -0
- package/dist/web/client/assets/TemplatesTabs-BX5hhEJ7.js +1 -0
- package/dist/web/client/assets/{UnsavedChangesGuard-CFQcKsrf.js → UnsavedChangesGuard-CVJtmR1D.js} +1 -1
- package/dist/web/client/assets/{_id-D_eKokkd.js → _id-BQPOE3gj.js} +1 -1
- package/dist/web/client/assets/{_id-9nCIhbVd.js → _id-BkYrUP0R.js} +1 -1
- package/dist/web/client/assets/_id-CriixlZD.js +1 -0
- package/dist/web/client/assets/_id-DHqq2W34.js +1 -0
- package/dist/web/client/assets/{_id-BSu3AqKA.js → _id-DmEVZIlx.js} +1 -1
- package/dist/web/client/assets/activity-Bzr8R18n.js +1 -0
- package/dist/web/client/assets/{agents-NY3VrZgB.js → agents-13oafeOA.js} +1 -1
- package/dist/web/client/assets/{agents-CCmiZek6.js → agents-DF4NALmJ.js} +1 -1
- package/dist/web/client/assets/{approvals-CPDAPgrM.js → approvals-DsG0Ijls.js} +1 -1
- package/dist/web/client/assets/{attention-Qra_9_OI.js → attention-DG7K25mz.js} +1 -1
- package/dist/web/client/assets/chevron-right-DFqFHtLy.js +1 -0
- package/dist/web/client/assets/config-DAaDbFhS.js +3 -0
- package/dist/web/client/assets/createServerFn-Dzfjt7mA.js +3 -0
- package/dist/web/client/assets/git-review-presentation-CzHQulDk.js +1 -0
- package/dist/web/client/assets/{inbox-C5W-sm1q.js → inbox-C9e7QjsX.js} +1 -1
- package/dist/web/client/assets/index-Dsstm2hf.js +50 -0
- package/dist/web/client/assets/{learning-Dr-7_7J4.js → learning-23arTd21.js} +1 -1
- package/dist/web/client/assets/login-BIXnBsuj.js +1 -0
- package/dist/web/client/assets/{mcp-BueuwQiv.js → mcp-Cdx9qAl8.js} +1 -1
- package/dist/web/client/assets/{members-ZikuYNcy.js → members-fotOz4rR.js} +1 -1
- package/dist/web/client/assets/{memory-1JUJlPrn.js → memory-C7UznVot.js} +1 -1
- package/dist/web/client/assets/policy-CactLW1X.js +1 -0
- package/dist/web/client/assets/{results-mMr8Ar2u.js → results-DqEuYnQH.js} +1 -1
- package/dist/web/client/assets/review-CnBSYclb.js +1 -0
- package/dist/web/client/assets/routes-COxMuwVz.js +1 -0
- package/dist/web/client/assets/{services-kfQA9cpJ.js → services-xEANwZAu.js} +1 -1
- package/dist/web/client/assets/{skills-C6pcgxaC.js → skills-CamV6wYM.js} +1 -1
- package/dist/web/client/assets/styles-C6br2xxl.css +2 -0
- package/dist/web/client/assets/{teams-LB0KBXY9.js → teams-B12dMSjW.js} +1 -1
- package/dist/web/client/assets/{teams-C6_Noz5X.js → teams-CbH43zSG.js} +1 -1
- package/dist/web/client/assets/{telegram-A2jaI1QM.js → telegram-muIql4u-.js} +1 -1
- package/dist/web/client/assets/{tokens-BGlUpJcL.js → tokens-DGFmApdF.js} +1 -1
- package/dist/web/client/assets/{triggers-C54_feGg.js → triggers-D8n3sCBW.js} +1 -1
- package/dist/web/client/assets/welcome-CMHWRZhs.js +1 -0
- package/dist/web/client/assets/x-BGCHwZOH.js +1 -0
- package/dist/web/server/assets/{ChatPane-DJ30FdFG.js → ChatPane-DybH39WK.js} +524 -15
- package/dist/web/server/assets/{ResultSourceConversation-zYogeOWp.js → ResultSourceConversation-BmXTcEOA.js} +1 -1
- package/dist/web/server/assets/{TeamTabs-TCKjCvMA.js → TeamTabs-DQXh-3ij.js} +4 -0
- package/dist/web/server/assets/{_id-1LwoHhJg.js → _id-BN1BPEDI.js} +1 -1
- package/dist/web/server/assets/{_id-DFHB9JFQ.js → _id-BYKpT2Tu.js} +1 -1
- package/dist/web/server/assets/{_id-B_-CDHOi2.js → _id-BqWTB8Wl.js} +1 -1
- package/dist/web/server/assets/{_id-BvSWsPI5.js → _id-CPfILjMa.js} +1 -1
- package/dist/web/server/assets/{_id-1hTvnKLN2.js → _id-C_2er0_G.js} +3 -3
- package/dist/web/server/assets/{_id-B2EEyStS.js → _id-DDyA9CGX.js} +1 -1
- package/dist/web/server/assets/{_id-DxFLSIio.js → _id-DSPFJMzf.js} +1 -1
- package/dist/web/server/assets/_id-DtJn-yzu.js +779 -0
- package/dist/web/server/assets/{_id-DDNVQx3y.js → _id-Dw3gKOGv.js} +1 -1
- package/dist/web/server/assets/{_id-T_8btpbB.js → _id-XkxlX036.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-DP4ZUBw3.js → _tanstack-start-manifest_v-vOXRfKJD.js} +97 -84
- package/dist/web/server/assets/{activity-C88qrNqv.js → activity-BX1jZBPQ.js} +1 -1
- package/dist/web/server/assets/{activity-5fWKPDxj.js → activity-bozPMU2v.js} +2 -2
- package/dist/web/server/assets/{activity-D73w4mkZ.js → activity-pYQPT3QT.js} +1 -1
- package/dist/web/server/assets/{agents-DRSo7lRX.js → agents-BKBfW700.js} +1 -1
- package/dist/web/server/assets/{agents-DB5hCSAI.js → agents-CVCfxnE2.js} +1 -1
- package/dist/web/server/assets/{approvals-4y9bZF4r.js → approvals-C3ya6B6U.js} +1 -1
- package/dist/web/server/assets/{attention-BFx8ZkmH.js → attention-l28hGCHS.js} +1 -1
- package/dist/web/server/assets/{auth-_eaCwhyq.js → auth-AvDFNeOv.js} +1 -1
- package/dist/web/server/assets/{config-B7JIfv_7.js → config-BWKn4XII.js} +1 -1
- package/dist/web/server/assets/{daemon-client-B06W1Qa2.js → daemon-client-Cgx-YW4l.js} +35 -0
- package/dist/web/server/assets/git-review-BB3M9nYg.js +26 -0
- package/dist/web/server/assets/git-review-f_uta4Mx.js +179 -0
- package/dist/web/server/assets/git-review-presentation-TJiHJhen.js +81 -0
- package/dist/web/server/assets/{inbox-YRpDQcvp.js → inbox-BBZiOOQs.js} +1 -1
- package/dist/web/server/assets/{learning-UBZb6h6M.js → learning-CheVay1i.js} +1 -1
- package/dist/web/server/assets/{mcp-Dv6RXMaS.js → mcp-DCBDmNtQ.js} +1 -1
- package/dist/web/server/assets/{members-BFTKSlOe.js → members-C2He8mrU.js} +1 -1
- package/dist/web/server/assets/{members-CD3GiTfF.js → members-C5FQruRZ.js} +1 -1
- package/dist/web/server/assets/{members-cc5SeEaW.js → members-C_2xB9pr.js} +2 -2
- package/dist/web/server/assets/{memory-CVqnyUaM.js → memory-4tI-UbOf.js} +1 -1
- package/dist/web/server/assets/{memory-C5i_GxlY.js → memory-BTcmf0sD.js} +2 -2
- package/dist/web/server/assets/{memory-D0PQgZAn.js → memory-rmiFNj7T.js} +1 -1
- package/dist/web/server/assets/{policy-Dgjb0_gK.js → policy-BGILKGHz.js} +2 -2
- package/dist/web/server/assets/{policy-bLKwvnja.js → policy-C3D2Q1EA.js} +1 -1
- package/dist/web/server/assets/{policy-C-p8HIhA.js → policy-DS7LGe--.js} +1 -1
- package/dist/web/server/assets/{results-Cfev4KNt.js → results-C6H42tjq.js} +1 -1
- package/dist/web/server/assets/{results-Cj-Dlw3C.js → results-Cgx7SrFt.js} +3 -3
- package/dist/web/server/assets/{results-CwEQ5EUL.js → results-_6K_zXQS.js} +1 -1
- package/dist/web/server/assets/review-DHhiL-JQ.js +393 -0
- package/dist/web/server/assets/review-DSTMCwP4.js +14 -0
- package/dist/web/server/assets/{router-d3sTMpMX.js → router-ElARvZzI.js} +34 -27
- package/dist/web/server/assets/{routes-B765DVhj.js → routes-B6x3pEW8.js} +1 -1
- package/dist/web/server/assets/{routes-cW4MWU18.js → routes-BgMvLvS-.js} +1 -1
- package/dist/web/server/assets/{routes-MIZz6uMr.js → routes-DsUzzxk4.js} +2 -2
- package/dist/web/server/assets/{services-BCbdn3R9.js → services-yHZroxsi.js} +1 -1
- package/dist/web/server/assets/{skills-Bpoa8MIp.js → skills--bIKID1Q.js} +1 -1
- package/dist/web/server/assets/{teams-hWGjbpUA.js → teams--a956vWL.js} +1 -1
- package/dist/web/server/assets/{teams-CXzwqzcE.js → teams-BbRfuVXY.js} +1 -1
- package/dist/web/server/assets/{telegram-DhpvtGUc.js → telegram-4kMxRtVZ.js} +1 -1
- package/dist/web/server/assets/{tokens-Bjp19Vkn.js → tokens-BYwTN9JZ.js} +1 -1
- package/dist/web/server/assets/{triggers-DJlcvXzn.js → triggers-BM6mzLuH.js} +1 -1
- package/dist/web/server/server.js +56 -28
- package/dist/worker.js +2214 -1132
- package/dist/worker.js.map +1 -1
- package/package.json +3 -3
- package/dist/web/client/assets/ChatPane-55j13bBj.js +0 -74
- package/dist/web/client/assets/ProductionTeamPolicyEditor-DT5Sl8jd.js +0 -7
- package/dist/web/client/assets/ProfileCommunicationEditor-TyCU5vXX.js +0 -1
- package/dist/web/client/assets/TeamTabs-BZHyRnbd.js +0 -1
- package/dist/web/client/assets/TemplatesTabs-BHzkPMRC.js +0 -1
- package/dist/web/client/assets/_id-CGd21j3k.js +0 -1
- package/dist/web/client/assets/_id-SRMFlIgP.js +0 -1
- package/dist/web/client/assets/activity-Cn2-9PpZ.js +0 -1
- package/dist/web/client/assets/chevron-right-DXE4CWf2.js +0 -1
- package/dist/web/client/assets/config-D8EO0LPB.js +0 -3
- package/dist/web/client/assets/index-BUhhk_u9.js +0 -52
- package/dist/web/client/assets/login-Bu5UxbJh.js +0 -1
- package/dist/web/client/assets/policy-DbkhsFNA.js +0 -1
- package/dist/web/client/assets/routes-DJYB-MS9.js +0 -1
- package/dist/web/client/assets/styles-CcNf8jT_.css +0 -2
- package/dist/web/client/assets/welcome-DyUIswRi.js +0 -1
- package/dist/web/client/assets/x-BY2MPLr9.js +0 -1
- package/dist/web/server/assets/_id-CDBtO_jL.js +0 -381
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand36, runCommand, showUsage } from "citty";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "bazilion",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.17.0",
|
|
10
10
|
description: "Multi-agent runtime CLI \u2014 spawn LLM agents, manage profiles/teams/skills, and run the local daemon.",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
repository: {
|
|
@@ -177,6 +177,58 @@ function createClient(cfg) {
|
|
|
177
177
|
return new Uint8Array(await res.arrayBuffer());
|
|
178
178
|
}
|
|
179
179
|
return {
|
|
180
|
+
codingEnvironment: {
|
|
181
|
+
show: (teamId) => request(
|
|
182
|
+
"GET",
|
|
183
|
+
`/api/teams/${encodeURIComponent(teamId)}/coding-environment`
|
|
184
|
+
),
|
|
185
|
+
configure: (teamId, input) => request(
|
|
186
|
+
"PUT",
|
|
187
|
+
`/api/teams/${encodeURIComponent(teamId)}/coding-environment`,
|
|
188
|
+
input
|
|
189
|
+
)
|
|
190
|
+
},
|
|
191
|
+
/** Read-only Git change review and bounded source snapshots (BAZ-042). */
|
|
192
|
+
repositoryReview: (teamId) => {
|
|
193
|
+
const base = `/api/teams/${encodeURIComponent(teamId)}/review`;
|
|
194
|
+
return {
|
|
195
|
+
changes: (options = {}) => {
|
|
196
|
+
const params = new URLSearchParams();
|
|
197
|
+
if (options.base !== void 0) params.set("base", options.base);
|
|
198
|
+
if (options.patches) params.set("patches", "1");
|
|
199
|
+
const suffix = params.size ? `?${params}` : "";
|
|
200
|
+
return request("GET", `${base}${suffix}`);
|
|
201
|
+
},
|
|
202
|
+
snapshots: () => request("GET", `${base}/snapshots`),
|
|
203
|
+
snapshot: (snapshotId) => request("GET", `${base}/snapshots/${encodeURIComponent(snapshotId)}`),
|
|
204
|
+
capture: (input) => request("POST", `${base}/snapshots`, input)
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
/** Operator retained-diagnostic access for BAZ-041 receipts. */
|
|
208
|
+
codingLogs: (teamId) => {
|
|
209
|
+
const base = `/api/teams/${encodeURIComponent(teamId)}/coding-commands`;
|
|
210
|
+
const item = (commandId) => `${base}/${encodeURIComponent(commandId)}/log`;
|
|
211
|
+
return {
|
|
212
|
+
page: (commandId, options = {}) => {
|
|
213
|
+
const params = new URLSearchParams();
|
|
214
|
+
if (options.offset !== void 0) params.set("offset", String(options.offset));
|
|
215
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
216
|
+
const suffix = params.size ? `?${params}` : "";
|
|
217
|
+
return request(
|
|
218
|
+
"GET",
|
|
219
|
+
`${item(commandId)}${suffix}`
|
|
220
|
+
);
|
|
221
|
+
},
|
|
222
|
+
search: (commandId, query) => request(
|
|
223
|
+
"GET",
|
|
224
|
+
`${item(commandId)}/search?q=${encodeURIComponent(query)}`
|
|
225
|
+
)
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
repositoryContext: (teamId, options = {}) => request(
|
|
229
|
+
"GET",
|
|
230
|
+
`/api/teams/${encodeURIComponent(teamId)}/repository-context${options.target !== void 0 ? `?target=${encodeURIComponent(options.target)}` : ""}`
|
|
231
|
+
),
|
|
180
232
|
notifications: {
|
|
181
233
|
settings: () => request("GET", "/api/notifications"),
|
|
182
234
|
configure: (input) => request("PUT", "/api/notifications", input),
|
|
@@ -318,12 +370,12 @@ var list = defineCommand({
|
|
|
318
370
|
offset: { type: "string", default: "0" },
|
|
319
371
|
json: { type: "boolean" }
|
|
320
372
|
},
|
|
321
|
-
async run({ args }) {
|
|
322
|
-
const query = new URLSearchParams({ limit:
|
|
373
|
+
async run({ args: args2 }) {
|
|
374
|
+
const query = new URLSearchParams({ limit: args2.limit, offset: args2.offset });
|
|
323
375
|
const body = await createClient2().get(
|
|
324
|
-
`${pathFor(
|
|
376
|
+
`${pathFor(args2.agent)}?${query}`
|
|
325
377
|
);
|
|
326
|
-
if (
|
|
378
|
+
if (args2.json) return console.log(JSON.stringify(body, null, 2));
|
|
327
379
|
if (!body.total) return console.log("(no conversations)");
|
|
328
380
|
for (const line of columnize([
|
|
329
381
|
["id", "title", "active"],
|
|
@@ -340,9 +392,9 @@ var list = defineCommand({
|
|
|
340
392
|
var show = defineCommand({
|
|
341
393
|
meta: { name: "show", description: "Read retained history without selecting it" },
|
|
342
394
|
args: { agent: positional, id: positional, json: { type: "boolean" } },
|
|
343
|
-
async run({ args }) {
|
|
344
|
-
const body = await createClient2().get(`${pathFor(
|
|
345
|
-
if (
|
|
395
|
+
async run({ args: args2 }) {
|
|
396
|
+
const body = await createClient2().get(`${pathFor(args2.agent)}/${encodeURIComponent(args2.id)}`);
|
|
397
|
+
if (args2.json) return console.log(JSON.stringify(body, null, 2));
|
|
346
398
|
console.log(body.conversation.title);
|
|
347
399
|
for (const message of body.messages) console.log(`[${message.role}] ${message.content}`);
|
|
348
400
|
}
|
|
@@ -366,32 +418,32 @@ var newConversation = defineCommand({
|
|
|
366
418
|
},
|
|
367
419
|
json: { type: "boolean" }
|
|
368
420
|
},
|
|
369
|
-
async run({ args }) {
|
|
421
|
+
async run({ args: args2 }) {
|
|
370
422
|
const client = createClient2();
|
|
371
|
-
const state = await client.get(`${pathFor(
|
|
372
|
-
const requestId =
|
|
373
|
-
const revision =
|
|
423
|
+
const state = await client.get(`${pathFor(args2.agent)}?limit=1`);
|
|
424
|
+
const requestId = args2["request-id"] ?? randomUUID();
|
|
425
|
+
const revision = args2["expected-revision"] === void 0 ? state.selection.revision : Number(args2["expected-revision"]);
|
|
374
426
|
if (!Number.isSafeInteger(revision) || revision < 0)
|
|
375
427
|
throw new Error("Invalid expected revision");
|
|
376
|
-
if (
|
|
428
|
+
if (args2["request-id"] && (args2["expected-revision"] === void 0 || args2["expected-conversation"] === void 0)) {
|
|
377
429
|
throw new Error(
|
|
378
430
|
"--request-id requires --expected-revision and --expected-conversation for an exact retry"
|
|
379
431
|
);
|
|
380
432
|
}
|
|
381
433
|
const expectedSelection = {
|
|
382
434
|
revision,
|
|
383
|
-
conversationId:
|
|
435
|
+
conversationId: args2["expected-conversation"] === void 0 ? state.selection.conversationId : args2["expected-conversation"] === "none" ? null : args2["expected-conversation"]
|
|
384
436
|
};
|
|
385
437
|
console.error(
|
|
386
438
|
`Create request: ${requestId}; retry with --request-id ${requestId} --expected-revision ${revision} --expected-conversation ${expectedSelection.conversationId ?? "none"} and the same title.`
|
|
387
439
|
);
|
|
388
|
-
const body = await client.post(pathFor(
|
|
440
|
+
const body = await client.post(pathFor(args2.agent), {
|
|
389
441
|
requestId,
|
|
390
442
|
expectedSelection,
|
|
391
|
-
...
|
|
443
|
+
...args2.title ? { title: args2.title } : {}
|
|
392
444
|
});
|
|
393
445
|
console.log(
|
|
394
|
-
|
|
446
|
+
args2.json ? JSON.stringify(body, null, 2) : `Conversation ${body.conversation.id}: ${body.conversation.title} (active: ${body.selection.conversationId})`
|
|
395
447
|
);
|
|
396
448
|
}
|
|
397
449
|
});
|
|
@@ -401,15 +453,15 @@ var rename = defineCommand({
|
|
|
401
453
|
description: "Rename a conversation without changing its selection or history"
|
|
402
454
|
},
|
|
403
455
|
args: { agent: positional, id: positional, title: positional, json: { type: "boolean" } },
|
|
404
|
-
async run({ args }) {
|
|
456
|
+
async run({ args: args2 }) {
|
|
405
457
|
const client = createClient2();
|
|
406
|
-
const path = `${pathFor(
|
|
458
|
+
const path = `${pathFor(args2.agent)}/${encodeURIComponent(args2.id)}`;
|
|
407
459
|
const current = await client.get(path);
|
|
408
460
|
const body = await client.patch(path, {
|
|
409
|
-
title:
|
|
461
|
+
title: args2.title,
|
|
410
462
|
expectedTitleRevision: current.conversation.titleRevision
|
|
411
463
|
});
|
|
412
|
-
console.log(
|
|
464
|
+
console.log(args2.json ? JSON.stringify(body, null, 2) : body.conversation.title);
|
|
413
465
|
}
|
|
414
466
|
});
|
|
415
467
|
var conversationCommand = defineCommand({
|
|
@@ -439,9 +491,9 @@ var notificationCommand = defineCommand2({
|
|
|
439
491
|
description: "Comma-separated Attention kinds; defaults to current selection"
|
|
440
492
|
}
|
|
441
493
|
},
|
|
442
|
-
async run({ args }) {
|
|
494
|
+
async run({ args: args2 }) {
|
|
443
495
|
const api = createClient2().notifications;
|
|
444
|
-
const kinds =
|
|
496
|
+
const kinds = args2.kinds ? args2.kinds.split(",") : (await api.settings()).settings.kinds;
|
|
445
497
|
output(await api.preview(kinds));
|
|
446
498
|
}
|
|
447
499
|
}),
|
|
@@ -464,44 +516,44 @@ var notificationCommand = defineCommand2({
|
|
|
464
516
|
},
|
|
465
517
|
"expected-revision": { type: "string" }
|
|
466
518
|
},
|
|
467
|
-
async run({ args }) {
|
|
468
|
-
if (
|
|
469
|
-
if (
|
|
519
|
+
async run({ args: args2 }) {
|
|
520
|
+
if (args2.enable && args2.disable) throw new Error("Choose --enable or --disable");
|
|
521
|
+
if (args2.enable && !args2["destination-id"])
|
|
470
522
|
throw new Error("--enable requires --destination-id from notification settings");
|
|
471
|
-
if (Boolean(
|
|
523
|
+
if (Boolean(args2["quiet-start"]) !== Boolean(args2["quiet-end"]))
|
|
472
524
|
throw new Error("Provide both --quiet-start and --quiet-end");
|
|
473
|
-
if (
|
|
525
|
+
if (args2["clear-quiet-hours"] && args2["quiet-start"])
|
|
474
526
|
throw new Error("Choose a quiet window or --clear-quiet-hours");
|
|
475
527
|
const api = createClient2().notifications;
|
|
476
528
|
const { settings } = await api.settings();
|
|
477
529
|
output(
|
|
478
530
|
await api.configure({
|
|
479
|
-
expectedRevision:
|
|
480
|
-
enabled:
|
|
481
|
-
destinationId:
|
|
482
|
-
kinds:
|
|
483
|
-
timezone:
|
|
484
|
-
quietHours:
|
|
485
|
-
includeOpenPreview:
|
|
531
|
+
expectedRevision: args2["expected-revision"] === void 0 ? settings.revision : Number(args2["expected-revision"]),
|
|
532
|
+
enabled: args2.enable ? true : args2.disable ? false : settings.enabled,
|
|
533
|
+
destinationId: args2["destination-id"] ?? settings.destination?.id,
|
|
534
|
+
kinds: args2.kinds ? args2.kinds.split(",") : settings.kinds,
|
|
535
|
+
timezone: args2.timezone ?? settings.timezone,
|
|
536
|
+
quietHours: args2["clear-quiet-hours"] ? null : args2["quiet-start"] && args2["quiet-end"] ? { start: args2["quiet-start"], end: args2["quiet-end"] } : settings.quietHours,
|
|
537
|
+
includeOpenPreview: args2["include-open-preview"]
|
|
486
538
|
})
|
|
487
539
|
);
|
|
488
540
|
}
|
|
489
541
|
}),
|
|
490
542
|
list: defineCommand2({
|
|
491
543
|
args: { cursor: { type: "string" }, limit: { type: "string" } },
|
|
492
|
-
async run({ args }) {
|
|
544
|
+
async run({ args: args2 }) {
|
|
493
545
|
output(
|
|
494
546
|
await createClient2().notifications.list({
|
|
495
|
-
cursor:
|
|
496
|
-
limit:
|
|
547
|
+
cursor: args2.cursor,
|
|
548
|
+
limit: args2.limit === void 0 ? void 0 : Number(args2.limit)
|
|
497
549
|
})
|
|
498
550
|
);
|
|
499
551
|
}
|
|
500
552
|
}),
|
|
501
553
|
show: defineCommand2({
|
|
502
554
|
args: { id: positional2 },
|
|
503
|
-
async run({ args }) {
|
|
504
|
-
output(await createClient2().notifications.get(
|
|
555
|
+
async run({ args: args2 }) {
|
|
556
|
+
output(await createClient2().notifications.get(args2.id));
|
|
505
557
|
}
|
|
506
558
|
}),
|
|
507
559
|
retry: defineCommand2({
|
|
@@ -512,13 +564,13 @@ var notificationCommand = defineCommand2({
|
|
|
512
564
|
description: "Telegram may already have received this notice"
|
|
513
565
|
}
|
|
514
566
|
},
|
|
515
|
-
async run({ args }) {
|
|
516
|
-
if (!
|
|
567
|
+
async run({ args: args2 }) {
|
|
568
|
+
if (!args2["acknowledge-possible-duplicate"])
|
|
517
569
|
throw new Error("Explicit retry requires --acknowledge-possible-duplicate");
|
|
518
570
|
const api = createClient2().notifications;
|
|
519
|
-
const receipt = await api.get(
|
|
571
|
+
const receipt = await api.get(args2.id);
|
|
520
572
|
output(
|
|
521
|
-
await api.retry(
|
|
573
|
+
await api.retry(args2.id, {
|
|
522
574
|
expectedUpdatedAt: receipt.updatedAt,
|
|
523
575
|
acknowledgePossibleDuplicate: true
|
|
524
576
|
})
|
|
@@ -533,17 +585,17 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
533
585
|
import { defineCommand as defineCommand3 } from "citty";
|
|
534
586
|
var positional3 = { type: "positional", required: true };
|
|
535
587
|
var output2 = (value) => console.log(JSON.stringify(value, null, 2));
|
|
536
|
-
function questionAnswer(
|
|
537
|
-
const count = Number(
|
|
588
|
+
function questionAnswer(args2) {
|
|
589
|
+
const count = Number(args2.choice !== void 0) + Number(args2.text !== void 0) + Number(args2.skip === true);
|
|
538
590
|
if (count !== 1) throw new Error("Specify exactly one of --choice, --text, or --skip");
|
|
539
|
-
if (
|
|
540
|
-
if (
|
|
541
|
-
if (!
|
|
591
|
+
if (args2.skip) return { kind: "skip" };
|
|
592
|
+
if (args2.text !== void 0) {
|
|
593
|
+
if (!args2.text.trim() || Buffer.byteLength(args2.text, "utf8") > 4096)
|
|
542
594
|
throw new Error("Answer text must contain 1\u20134096 UTF-8 bytes");
|
|
543
|
-
return { kind: "text", text:
|
|
595
|
+
return { kind: "text", text: args2.text };
|
|
544
596
|
}
|
|
545
|
-
if (!/^[1-4]$/.test(
|
|
546
|
-
return { kind: "choice", index: Number(
|
|
597
|
+
if (!/^[1-4]$/.test(args2.choice ?? "")) throw new Error("--choice must be a number from 1 to 4");
|
|
598
|
+
return { kind: "choice", index: Number(args2.choice) - 1 };
|
|
547
599
|
}
|
|
548
600
|
var questionCommand = defineCommand3({
|
|
549
601
|
meta: {
|
|
@@ -553,14 +605,14 @@ var questionCommand = defineCommand3({
|
|
|
553
605
|
subCommands: {
|
|
554
606
|
list: defineCommand3({
|
|
555
607
|
args: { agent: positional3, conversation: { type: "string" } },
|
|
556
|
-
async run({ args }) {
|
|
557
|
-
output2(await createClient2().questions(
|
|
608
|
+
async run({ args: args2 }) {
|
|
609
|
+
output2(await createClient2().questions(args2.agent).list(args2.conversation));
|
|
558
610
|
}
|
|
559
611
|
}),
|
|
560
612
|
show: defineCommand3({
|
|
561
613
|
args: { agent: positional3, id: positional3 },
|
|
562
|
-
async run({ args }) {
|
|
563
|
-
output2(await createClient2().questions(
|
|
614
|
+
async run({ args: args2 }) {
|
|
615
|
+
output2(await createClient2().questions(args2.agent).get(args2.id));
|
|
564
616
|
}
|
|
565
617
|
}),
|
|
566
618
|
answer: defineCommand3({
|
|
@@ -576,22 +628,22 @@ var questionCommand = defineCommand3({
|
|
|
576
628
|
description: "Original conversation ID; required for retries"
|
|
577
629
|
}
|
|
578
630
|
},
|
|
579
|
-
async run({ args }) {
|
|
580
|
-
const answer = questionAnswer(
|
|
581
|
-
if (
|
|
631
|
+
async run({ args: args2 }) {
|
|
632
|
+
const answer = questionAnswer(args2);
|
|
633
|
+
if (args2["request-id"] && !args2.conversation)
|
|
582
634
|
throw new Error("Retry requires the original --conversation and identical answer");
|
|
583
|
-
const client = createClient2().questions(
|
|
584
|
-
const observed = await client.get(
|
|
585
|
-
const conversationId =
|
|
635
|
+
const client = createClient2().questions(args2.agent);
|
|
636
|
+
const observed = await client.get(args2.id);
|
|
637
|
+
const conversationId = args2.conversation ?? observed.conversationId;
|
|
586
638
|
if (conversationId !== observed.conversationId)
|
|
587
639
|
throw new Error("Question conversation differs");
|
|
588
640
|
if (answer.kind === "choice" && answer.index >= observed.question.choices.length)
|
|
589
641
|
throw new Error("That choice does not exist for this question");
|
|
590
|
-
const requestId =
|
|
642
|
+
const requestId = args2["request-id"] ?? randomUUID2();
|
|
591
643
|
console.error(
|
|
592
644
|
`Question request: ${requestId}; exact retry uses --request-id ${requestId} --conversation ${conversationId} and the same answer. Acceptance does not prove consumption or task completion.`
|
|
593
645
|
);
|
|
594
|
-
output2(await client.answer(
|
|
646
|
+
output2(await client.answer(args2.id, { requestId, conversationId, answer }));
|
|
595
647
|
}
|
|
596
648
|
})
|
|
597
649
|
}
|
|
@@ -613,14 +665,14 @@ var expected = {
|
|
|
613
665
|
};
|
|
614
666
|
var list2 = defineCommand4({
|
|
615
667
|
args: { ...common, all: { type: "boolean" }, offset: { type: "string", default: "0" } },
|
|
616
|
-
async run({ args }) {
|
|
617
|
-
output3(await createClient2().queue(
|
|
668
|
+
async run({ args: args2 }) {
|
|
669
|
+
output3(await createClient2().queue(args2.agent).list(args2.all, Number(args2.offset)));
|
|
618
670
|
}
|
|
619
671
|
});
|
|
620
672
|
var show2 = defineCommand4({
|
|
621
673
|
args: entry,
|
|
622
|
-
async run({ args }) {
|
|
623
|
-
output3(await createClient2().queue(
|
|
674
|
+
async run({ args: args2 }) {
|
|
675
|
+
output3(await createClient2().queue(args2.agent).get(args2.id));
|
|
624
676
|
}
|
|
625
677
|
});
|
|
626
678
|
var enqueueArgs = {
|
|
@@ -640,27 +692,27 @@ var enqueueArgs = {
|
|
|
640
692
|
description: "Original selection revision; required for retries"
|
|
641
693
|
}
|
|
642
694
|
};
|
|
643
|
-
async function submit(
|
|
695
|
+
async function submit(args2, replacement) {
|
|
644
696
|
const client = createClient2();
|
|
645
|
-
const agentId = String(
|
|
646
|
-
if (
|
|
697
|
+
const agentId = String(args2.agent);
|
|
698
|
+
if (args2["request-id"] && (args2["expected-conversation"] === void 0 || args2["expected-selection-revision"] === void 0))
|
|
647
699
|
throw new Error(
|
|
648
700
|
"Exact retry requires --expected-conversation and --expected-selection-revision"
|
|
649
701
|
);
|
|
650
702
|
const observed = await client.get(
|
|
651
703
|
`/api/agents/${encodeURIComponent(agentId)}/conversations?limit=1`
|
|
652
704
|
);
|
|
653
|
-
const requestId = typeof
|
|
705
|
+
const requestId = typeof args2["request-id"] === "string" ? args2["request-id"] : randomUUID3();
|
|
654
706
|
const expectedSelection = {
|
|
655
|
-
conversationId:
|
|
656
|
-
revision:
|
|
707
|
+
conversationId: args2["expected-conversation"] === void 0 ? observed.selection.conversationId : args2["expected-conversation"] === "none" ? null : String(args2["expected-conversation"]),
|
|
708
|
+
revision: args2["expected-selection-revision"] === void 0 ? observed.selection.revision : Number(args2["expected-selection-revision"])
|
|
657
709
|
};
|
|
658
|
-
const paths =
|
|
710
|
+
const paths = args2.files ? JSON.parse(String(args2.files)) : [];
|
|
659
711
|
if (!Array.isArray(paths) || paths.length > 16 || paths.some((p) => typeof p !== "string"))
|
|
660
712
|
throw new Error("--files must be a JSON array of at most 16 paths");
|
|
661
713
|
let bytes = 0;
|
|
662
|
-
const original = replacement && (
|
|
663
|
-
const attachments =
|
|
714
|
+
const original = replacement && (args2.files === void 0 || args2.message === void 0) ? await client.queue(agentId).input(replacement.id) : void 0;
|
|
715
|
+
const attachments = args2.files === void 0 && original ? original.attachments : paths.map((path) => {
|
|
664
716
|
const stat = statSync(path);
|
|
665
717
|
bytes += stat.size;
|
|
666
718
|
if (!stat.isFile() || bytes > 25 * 1024 * 1024)
|
|
@@ -686,7 +738,7 @@ async function submit(args, replacement) {
|
|
|
686
738
|
const input = {
|
|
687
739
|
requestId,
|
|
688
740
|
expectedSelection,
|
|
689
|
-
message: String(
|
|
741
|
+
message: String(args2.message ?? original?.message ?? ""),
|
|
690
742
|
attachments
|
|
691
743
|
};
|
|
692
744
|
output3(
|
|
@@ -695,36 +747,36 @@ async function submit(args, replacement) {
|
|
|
695
747
|
}
|
|
696
748
|
var add = defineCommand4({
|
|
697
749
|
args: enqueueArgs,
|
|
698
|
-
async run({ args }) {
|
|
699
|
-
await submit(
|
|
750
|
+
async run({ args: args2 }) {
|
|
751
|
+
await submit(args2);
|
|
700
752
|
}
|
|
701
753
|
});
|
|
702
754
|
var edit = defineCommand4({
|
|
703
755
|
args: { ...enqueueArgs, id: positional4, "expected-revision": expected },
|
|
704
|
-
async run({ args }) {
|
|
705
|
-
await submit(
|
|
756
|
+
async run({ args: args2 }) {
|
|
757
|
+
await submit(args2, { id: args2.id, expectedRevision: Number(args2["expected-revision"]) });
|
|
706
758
|
}
|
|
707
759
|
});
|
|
708
760
|
var remove = defineCommand4({
|
|
709
761
|
args: { ...entry, "expected-revision": expected },
|
|
710
|
-
async run({ args }) {
|
|
762
|
+
async run({ args: args2 }) {
|
|
711
763
|
output3(
|
|
712
|
-
await createClient2().queue(
|
|
764
|
+
await createClient2().queue(args2.agent).remove(args2.id, Number(args2["expected-revision"]))
|
|
713
765
|
);
|
|
714
766
|
}
|
|
715
767
|
});
|
|
716
768
|
var control = (paused) => defineCommand4({
|
|
717
769
|
args: { ...common, "expected-revision": expected },
|
|
718
|
-
async run({ args }) {
|
|
770
|
+
async run({ args: args2 }) {
|
|
719
771
|
output3(
|
|
720
|
-
await createClient2().queue(
|
|
772
|
+
await createClient2().queue(args2.agent).pause(paused, Number(args2["expected-revision"]))
|
|
721
773
|
);
|
|
722
774
|
}
|
|
723
775
|
});
|
|
724
776
|
var stop = defineCommand4({
|
|
725
777
|
args: { ...common, "expected-revision": expected },
|
|
726
|
-
async run({ args }) {
|
|
727
|
-
output3(await createClient2().queue(
|
|
778
|
+
async run({ args: args2 }) {
|
|
779
|
+
output3(await createClient2().queue(args2.agent).stop(Number(args2["expected-revision"])));
|
|
728
780
|
}
|
|
729
781
|
});
|
|
730
782
|
var reconcile = defineCommand4({
|
|
@@ -736,11 +788,11 @@ var reconcile = defineCommand4({
|
|
|
736
788
|
description: "Acknowledge this input may already have acted; close without replay"
|
|
737
789
|
}
|
|
738
790
|
},
|
|
739
|
-
async run({ args }) {
|
|
740
|
-
if (!
|
|
791
|
+
async run({ args: args2 }) {
|
|
792
|
+
if (!args2.acknowledge)
|
|
741
793
|
throw new Error("--acknowledge is required; this input may already have acted");
|
|
742
794
|
output3(
|
|
743
|
-
await createClient2().queue(
|
|
795
|
+
await createClient2().queue(args2.agent).reconcile(args2.id, Number(args2["expected-revision"]))
|
|
744
796
|
);
|
|
745
797
|
}
|
|
746
798
|
});
|
|
@@ -821,6 +873,30 @@ async function promptForQuestion(item, prompt) {
|
|
|
821
873
|
}
|
|
822
874
|
}
|
|
823
875
|
|
|
876
|
+
// src/repeatable-args.ts
|
|
877
|
+
function collectFlagValues(rawArgs, name) {
|
|
878
|
+
const values = [];
|
|
879
|
+
const long = `--${name}`;
|
|
880
|
+
for (let i = 0; i < rawArgs.length; i++) {
|
|
881
|
+
const arg = rawArgs[i];
|
|
882
|
+
if (arg === void 0) continue;
|
|
883
|
+
if (arg === "--") break;
|
|
884
|
+
if (arg === long) {
|
|
885
|
+
const next = rawArgs[i + 1];
|
|
886
|
+
if (next !== void 0 && next !== "--") {
|
|
887
|
+
values.push(next);
|
|
888
|
+
i++;
|
|
889
|
+
}
|
|
890
|
+
continue;
|
|
891
|
+
}
|
|
892
|
+
if (arg.startsWith(`${long}=`)) {
|
|
893
|
+
const value = arg.slice(long.length + 1);
|
|
894
|
+
if (value.length > 0) values.push(value);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return values;
|
|
898
|
+
}
|
|
899
|
+
|
|
824
900
|
// src/commands/agent.ts
|
|
825
901
|
var IMAGE_MIME = {
|
|
826
902
|
".png": "image/png",
|
|
@@ -852,9 +928,6 @@ function loadFiles(paths) {
|
|
|
852
928
|
data: readFileSync3(p).toString("base64")
|
|
853
929
|
}));
|
|
854
930
|
}
|
|
855
|
-
function asPaths(v) {
|
|
856
|
-
return v ? Array.isArray(v) ? v : [v] : [];
|
|
857
|
-
}
|
|
858
931
|
var spawnCmd = defineCommand5({
|
|
859
932
|
meta: { name: "spawn", description: "Spawn an agent from a profile into a team" },
|
|
860
933
|
args: {
|
|
@@ -870,17 +943,17 @@ var spawnCmd = defineCommand5({
|
|
|
870
943
|
description: "Reasoning level: off|minimal|low|medium|high|xhigh (default: medium)"
|
|
871
944
|
}
|
|
872
945
|
},
|
|
873
|
-
async run({ args }) {
|
|
946
|
+
async run({ args: args2 }) {
|
|
874
947
|
const client = createClient2();
|
|
875
|
-
const teamId =
|
|
948
|
+
const teamId = args2.team ?? "default";
|
|
876
949
|
const policy = await client.get(
|
|
877
950
|
`/api/teams/${encodeURIComponent(teamId)}/policy`
|
|
878
951
|
);
|
|
879
952
|
const body = {
|
|
880
|
-
profileId:
|
|
881
|
-
name:
|
|
882
|
-
model:
|
|
883
|
-
reasoningLevel:
|
|
953
|
+
profileId: args2.profile,
|
|
954
|
+
name: args2.name,
|
|
955
|
+
model: args2.model,
|
|
956
|
+
reasoningLevel: args2.reasoning,
|
|
884
957
|
teamId,
|
|
885
958
|
teamExpectedRevision: policy.teamPolicy.revision,
|
|
886
959
|
placement: "profile_defaults"
|
|
@@ -913,8 +986,8 @@ var editCmd = defineCommand5({
|
|
|
913
986
|
description: 'Telegram topic emoji (e.g. \u{1F4DA}). Use --topic-icon "" to clear.'
|
|
914
987
|
}
|
|
915
988
|
},
|
|
916
|
-
async run({ args }) {
|
|
917
|
-
if (
|
|
989
|
+
async run({ args: args2 }) {
|
|
990
|
+
if (args2.name === void 0 && args2.model === void 0 && args2.reasoning === void 0 && args2.mirror === void 0 && args2["topic-icon"] === void 0) {
|
|
918
991
|
console.error(
|
|
919
992
|
"agent edit: specify at least one of --name, --model, --reasoning, --mirror, --topic-icon"
|
|
920
993
|
);
|
|
@@ -922,22 +995,22 @@ var editCmd = defineCommand5({
|
|
|
922
995
|
}
|
|
923
996
|
const client = createClient2();
|
|
924
997
|
const body = {};
|
|
925
|
-
if (
|
|
926
|
-
if (
|
|
927
|
-
body.modelOverride =
|
|
998
|
+
if (args2.name !== void 0) body.name = args2.name;
|
|
999
|
+
if (args2.model !== void 0) {
|
|
1000
|
+
body.modelOverride = args2.model === "" ? null : args2.model;
|
|
928
1001
|
}
|
|
929
|
-
if (
|
|
930
|
-
if (
|
|
931
|
-
if (
|
|
1002
|
+
if (args2.reasoning !== void 0) body.reasoningLevel = args2.reasoning;
|
|
1003
|
+
if (args2.mirror !== void 0) {
|
|
1004
|
+
if (args2.mirror !== "minimal" && args2.mirror !== "verbose") {
|
|
932
1005
|
console.error(`agent edit: --mirror must be 'minimal' or 'verbose'`);
|
|
933
1006
|
process.exit(2);
|
|
934
1007
|
}
|
|
935
|
-
body.telegramMirrorMode =
|
|
1008
|
+
body.telegramMirrorMode = args2.mirror;
|
|
936
1009
|
}
|
|
937
|
-
if (
|
|
938
|
-
body.telegramIconEmoji =
|
|
1010
|
+
if (args2["topic-icon"] !== void 0) {
|
|
1011
|
+
body.telegramIconEmoji = args2["topic-icon"] === "" ? null : args2["topic-icon"];
|
|
939
1012
|
}
|
|
940
|
-
const agent = await client.patch(`/api/agents/${
|
|
1013
|
+
const agent = await client.patch(`/api/agents/${args2.id}`, body);
|
|
941
1014
|
console.log(`updated agent ${agent.id} (${agent.name})`);
|
|
942
1015
|
}
|
|
943
1016
|
});
|
|
@@ -947,16 +1020,16 @@ var listCmd = defineCommand5({
|
|
|
947
1020
|
all: { type: "boolean", description: "Include archived agents" },
|
|
948
1021
|
long: { type: "boolean", alias: "l", description: "Show profile + full UUID columns" }
|
|
949
1022
|
},
|
|
950
|
-
async run({ args }) {
|
|
1023
|
+
async run({ args: args2 }) {
|
|
951
1024
|
const client = createClient2();
|
|
952
|
-
const q =
|
|
1025
|
+
const q = args2.all ? "?includeArchived=true" : "";
|
|
953
1026
|
const list8 = await client.get(`/api/agents${q}`);
|
|
954
1027
|
if (list8.length === 0) {
|
|
955
1028
|
console.log("(no agents)");
|
|
956
1029
|
return;
|
|
957
1030
|
}
|
|
958
1031
|
const rows = list8.map(
|
|
959
|
-
(a) =>
|
|
1032
|
+
(a) => args2.long ? [a.id, a.status, a.name, a.profileId] : (
|
|
960
1033
|
// Short UUID prefix — all CLI commands accept 4+ char prefixes now.
|
|
961
1034
|
[a.id.slice(0, 8), a.status, a.name]
|
|
962
1035
|
)
|
|
@@ -969,9 +1042,9 @@ var showCmd = defineCommand5({
|
|
|
969
1042
|
args: {
|
|
970
1043
|
id: { type: "positional", required: true }
|
|
971
1044
|
},
|
|
972
|
-
async run({ args }) {
|
|
1045
|
+
async run({ args: args2 }) {
|
|
973
1046
|
const client = createClient2();
|
|
974
|
-
const r = await client.get(`/api/agents/${
|
|
1047
|
+
const r = await client.get(`/api/agents/${args2.id}`);
|
|
975
1048
|
console.log(`# ${r.agent.id}`);
|
|
976
1049
|
console.log(`name: ${r.agent.name}`);
|
|
977
1050
|
console.log(`status: ${r.agent.status}`);
|
|
@@ -992,10 +1065,10 @@ var archiveCmd = defineCommand5({
|
|
|
992
1065
|
args: {
|
|
993
1066
|
id: { type: "positional", required: true }
|
|
994
1067
|
},
|
|
995
|
-
async run({ args }) {
|
|
1068
|
+
async run({ args: args2 }) {
|
|
996
1069
|
const client = createClient2();
|
|
997
|
-
await client.post(`/api/agents/${
|
|
998
|
-
console.log(`archived agent ${
|
|
1070
|
+
await client.post(`/api/agents/${args2.id}/archive`);
|
|
1071
|
+
console.log(`archived agent ${args2.id}`);
|
|
999
1072
|
}
|
|
1000
1073
|
});
|
|
1001
1074
|
var unarchiveCmd = defineCommand5({
|
|
@@ -1003,10 +1076,10 @@ var unarchiveCmd = defineCommand5({
|
|
|
1003
1076
|
args: {
|
|
1004
1077
|
id: { type: "positional", required: true }
|
|
1005
1078
|
},
|
|
1006
|
-
async run({ args }) {
|
|
1079
|
+
async run({ args: args2 }) {
|
|
1007
1080
|
const client = createClient2();
|
|
1008
|
-
await client.post(`/api/agents/${
|
|
1009
|
-
console.log(`unarchived agent ${
|
|
1081
|
+
await client.post(`/api/agents/${args2.id}/unarchive`);
|
|
1082
|
+
console.log(`unarchived agent ${args2.id}`);
|
|
1010
1083
|
}
|
|
1011
1084
|
});
|
|
1012
1085
|
var deleteCmd = defineCommand5({
|
|
@@ -1014,16 +1087,16 @@ var deleteCmd = defineCommand5({
|
|
|
1014
1087
|
args: {
|
|
1015
1088
|
id: { type: "positional", required: true }
|
|
1016
1089
|
},
|
|
1017
|
-
async run({ args }) {
|
|
1090
|
+
async run({ args: args2 }) {
|
|
1018
1091
|
const client = createClient2();
|
|
1019
|
-
const agent = await client.get(`/api/agents/${encodeURIComponent(
|
|
1092
|
+
const agent = await client.get(`/api/agents/${encodeURIComponent(args2.id)}`);
|
|
1020
1093
|
const policy = await client.get(
|
|
1021
1094
|
`/api/teams/${encodeURIComponent(agent.team.id)}/policy`
|
|
1022
1095
|
);
|
|
1023
1096
|
await client.del(
|
|
1024
|
-
`/api/agents/${encodeURIComponent(
|
|
1097
|
+
`/api/agents/${encodeURIComponent(args2.id)}?expectedTeamRevision=${policy.teamPolicy.revision}`
|
|
1025
1098
|
);
|
|
1026
|
-
console.log(`deleted agent ${
|
|
1099
|
+
console.log(`deleted agent ${args2.id}`);
|
|
1027
1100
|
}
|
|
1028
1101
|
});
|
|
1029
1102
|
function bashApprovalModeForTty(inputIsTty, outputIsTty) {
|
|
@@ -1209,25 +1282,25 @@ var chatCmd = defineCommand5({
|
|
|
1209
1282
|
},
|
|
1210
1283
|
image: {
|
|
1211
1284
|
type: "string",
|
|
1212
|
-
description: "Attach an image file (png/jpg/gif/webp;
|
|
1285
|
+
description: "Attach an image file (png/jpg/gif/webp; repeat the flag for more). One-shot mode."
|
|
1213
1286
|
},
|
|
1214
1287
|
file: {
|
|
1215
1288
|
type: "string",
|
|
1216
|
-
description: "Attach any file \u2014 the agent gets a path reference (
|
|
1289
|
+
description: "Attach any file \u2014 the agent gets a path reference (repeat the flag for more). One-shot mode."
|
|
1217
1290
|
}
|
|
1218
1291
|
},
|
|
1219
|
-
async run({ args }) {
|
|
1292
|
+
async run({ args: args2, rawArgs }) {
|
|
1220
1293
|
const client = createClient2();
|
|
1221
|
-
const resolved = await client.get(`/api/agents/${
|
|
1294
|
+
const resolved = await client.get(`/api/agents/${args2.id}`);
|
|
1222
1295
|
const bashApprovalMode = bashApprovalModeForTty(stdin.isTTY, stdout.isTTY);
|
|
1223
1296
|
const attachments = [
|
|
1224
|
-
...loadImages(
|
|
1225
|
-
...loadFiles(
|
|
1297
|
+
...loadImages(collectFlagValues(rawArgs, "image")),
|
|
1298
|
+
...loadFiles(collectFlagValues(rawArgs, "file"))
|
|
1226
1299
|
];
|
|
1227
|
-
if (
|
|
1300
|
+
if (args2.message || attachments.length > 0) {
|
|
1228
1301
|
const rl2 = bashApprovalMode === "interactive" ? createInterface({ input: stdin, output: stdout }) : null;
|
|
1229
1302
|
try {
|
|
1230
|
-
await streamTurn(client, resolved.agent.id,
|
|
1303
|
+
await streamTurn(client, resolved.agent.id, args2.message ?? "", attachments, {
|
|
1231
1304
|
bashApprovalMode,
|
|
1232
1305
|
...rl2 ? {
|
|
1233
1306
|
approvalPrompt: {
|
|
@@ -1323,16 +1396,16 @@ var chatTrimCmd = defineCommand5({
|
|
|
1323
1396
|
id: { type: "positional", required: true },
|
|
1324
1397
|
keep: { type: "string", required: true, description: "Number of leading messages to keep" }
|
|
1325
1398
|
},
|
|
1326
|
-
async run({ args }) {
|
|
1327
|
-
const n = Number(
|
|
1399
|
+
async run({ args: args2 }) {
|
|
1400
|
+
const n = Number(args2.keep);
|
|
1328
1401
|
if (!Number.isFinite(n) || n < 0 || !Number.isInteger(n)) {
|
|
1329
1402
|
throw new Error("--keep must be a non-negative integer");
|
|
1330
1403
|
}
|
|
1331
1404
|
const client = createClient2();
|
|
1332
|
-
const head = await client.get(`/api/agents/${
|
|
1405
|
+
const head = await client.get(`/api/agents/${args2.id}/sessions/head`);
|
|
1333
1406
|
const body = { keepCount: n, expectedSelection: head.selection };
|
|
1334
1407
|
const res = await client.post(
|
|
1335
|
-
`/api/agents/${
|
|
1408
|
+
`/api/agents/${args2.id}/chat/truncate`,
|
|
1336
1409
|
body
|
|
1337
1410
|
);
|
|
1338
1411
|
console.log(
|
|
@@ -1358,11 +1431,11 @@ var chatContextCmd = defineCommand5({
|
|
|
1358
1431
|
},
|
|
1359
1432
|
json: { type: "boolean", description: "Emit raw JSON instead of a human report" }
|
|
1360
1433
|
},
|
|
1361
|
-
async run({ args }) {
|
|
1434
|
+
async run({ args: args2 }) {
|
|
1362
1435
|
const client = createClient2();
|
|
1363
|
-
const query =
|
|
1364
|
-
const ctx = await client.get(`/api/agents/${
|
|
1365
|
-
if (
|
|
1436
|
+
const query = args2.detail || args2.json ? "?detail=1" : "";
|
|
1437
|
+
const ctx = await client.get(`/api/agents/${args2.id}/chat/context${query}`);
|
|
1438
|
+
if (args2.json) {
|
|
1366
1439
|
console.log(JSON.stringify(ctx, null, 2));
|
|
1367
1440
|
return;
|
|
1368
1441
|
}
|
|
@@ -1446,20 +1519,20 @@ var chatCompactCmd = defineCommand5({
|
|
|
1446
1519
|
},
|
|
1447
1520
|
force: { type: "boolean", description: "Skip the y/N prompt" }
|
|
1448
1521
|
},
|
|
1449
|
-
async run({ args }) {
|
|
1450
|
-
if (!
|
|
1522
|
+
async run({ args: args2 }) {
|
|
1523
|
+
if (!args2.force) {
|
|
1451
1524
|
process.stdout.write(
|
|
1452
|
-
`compact chat history for ${
|
|
1525
|
+
`compact chat history for ${args2.id}? head turns become a summary; tail is preserved. [y/N] `
|
|
1453
1526
|
);
|
|
1454
|
-
const answer = await new Promise((
|
|
1455
|
-
process.stdin.once("data", (d) =>
|
|
1527
|
+
const answer = await new Promise((resolve6) => {
|
|
1528
|
+
process.stdin.once("data", (d) => resolve6(String(d).trim().toLowerCase()));
|
|
1456
1529
|
});
|
|
1457
1530
|
if (answer !== "y" && answer !== "yes") {
|
|
1458
1531
|
console.log("aborted");
|
|
1459
1532
|
return;
|
|
1460
1533
|
}
|
|
1461
1534
|
}
|
|
1462
|
-
const keepTailNum =
|
|
1535
|
+
const keepTailNum = args2["keep-tail"] ? Number(args2["keep-tail"]) : void 0;
|
|
1463
1536
|
if (keepTailNum !== void 0 && (!Number.isFinite(keepTailNum) || keepTailNum < 0)) {
|
|
1464
1537
|
console.error("--keep-tail must be a non-negative integer");
|
|
1465
1538
|
process.exitCode = 1;
|
|
@@ -1467,11 +1540,11 @@ var chatCompactCmd = defineCommand5({
|
|
|
1467
1540
|
}
|
|
1468
1541
|
const body = {};
|
|
1469
1542
|
if (keepTailNum !== void 0) body.keepTail = Math.floor(keepTailNum);
|
|
1470
|
-
if (
|
|
1543
|
+
if (args2.instructions) body.customInstructions = args2.instructions;
|
|
1471
1544
|
const client = createClient2();
|
|
1472
|
-
const head = await client.get(`/api/agents/${
|
|
1545
|
+
const head = await client.get(`/api/agents/${args2.id}/sessions/head`);
|
|
1473
1546
|
body.expectedSelection = head.selection;
|
|
1474
|
-
const res = await client.post(`/api/agents/${
|
|
1547
|
+
const res = await client.post(`/api/agents/${args2.id}/chat/compact`, body);
|
|
1475
1548
|
console.log(
|
|
1476
1549
|
`compacted: ${res.before} \u2192 ${res.after} entries (${res.summarized} summarized, ${res.keptTail} tail kept verbatim)`
|
|
1477
1550
|
);
|
|
@@ -1493,11 +1566,11 @@ var skillAddCmd = defineCommand5({
|
|
|
1493
1566
|
description: "Attach even when the static skill scan reports findings"
|
|
1494
1567
|
}
|
|
1495
1568
|
},
|
|
1496
|
-
async run({ args }) {
|
|
1569
|
+
async run({ args: args2 }) {
|
|
1497
1570
|
const client = createClient2();
|
|
1498
|
-
const body = { skill:
|
|
1571
|
+
const body = { skill: args2.skill, allowFindings: args2["allow-warnings"] };
|
|
1499
1572
|
try {
|
|
1500
|
-
await client.post(`/api/agents/${
|
|
1573
|
+
await client.post(`/api/agents/${args2.agent}/skills`, body);
|
|
1501
1574
|
} catch (err) {
|
|
1502
1575
|
if (err instanceof ApiClientError && err.body.code === "skill_scan_blocked") {
|
|
1503
1576
|
console.error(`error: ${err.body.error}`);
|
|
@@ -1508,7 +1581,7 @@ var skillAddCmd = defineCommand5({
|
|
|
1508
1581
|
}
|
|
1509
1582
|
throw err;
|
|
1510
1583
|
}
|
|
1511
|
-
console.log(`attached skill ${
|
|
1584
|
+
console.log(`attached skill ${args2.skill} to ${args2.agent}`);
|
|
1512
1585
|
}
|
|
1513
1586
|
});
|
|
1514
1587
|
function printSkillFindings(findings) {
|
|
@@ -1525,10 +1598,10 @@ var skillRmCmd = defineCommand5({
|
|
|
1525
1598
|
agent: { type: "positional", required: true },
|
|
1526
1599
|
skill: { type: "positional", required: true }
|
|
1527
1600
|
},
|
|
1528
|
-
async run({ args }) {
|
|
1601
|
+
async run({ args: args2 }) {
|
|
1529
1602
|
const client = createClient2();
|
|
1530
|
-
await client.del(`/api/agents/${
|
|
1531
|
-
console.log(`detached skill ${
|
|
1603
|
+
await client.del(`/api/agents/${args2.agent}/skills/${encodeURIComponent(args2.skill)}`);
|
|
1604
|
+
console.log(`detached skill ${args2.skill} from ${args2.agent}`);
|
|
1532
1605
|
}
|
|
1533
1606
|
});
|
|
1534
1607
|
var skillCmd = defineCommand5({
|
|
@@ -1544,23 +1617,23 @@ var moveCmd = defineCommand5({
|
|
|
1544
1617
|
agent: { type: "positional", required: true },
|
|
1545
1618
|
team: { type: "positional", required: true }
|
|
1546
1619
|
},
|
|
1547
|
-
async run({ args }) {
|
|
1620
|
+
async run({ args: args2 }) {
|
|
1548
1621
|
const client = createClient2();
|
|
1549
1622
|
const [agent, destination] = await Promise.all([
|
|
1550
|
-
client.get(`/api/agents/${encodeURIComponent(
|
|
1551
|
-
client.get(`/api/teams/${encodeURIComponent(
|
|
1623
|
+
client.get(`/api/agents/${encodeURIComponent(args2.agent)}`),
|
|
1624
|
+
client.get(`/api/teams/${encodeURIComponent(args2.team)}/policy`)
|
|
1552
1625
|
]);
|
|
1553
1626
|
const source = await client.get(
|
|
1554
1627
|
`/api/teams/${encodeURIComponent(agent.team.id)}/policy`
|
|
1555
1628
|
);
|
|
1556
1629
|
const body = {
|
|
1557
|
-
teamId:
|
|
1630
|
+
teamId: args2.team,
|
|
1558
1631
|
sourceExpectedRevision: source.teamPolicy.revision,
|
|
1559
1632
|
destinationExpectedRevision: destination.teamPolicy.revision,
|
|
1560
1633
|
placement: "profile_defaults"
|
|
1561
1634
|
};
|
|
1562
|
-
await client.patch(`/api/agents/${
|
|
1563
|
-
console.log(`moved ${
|
|
1635
|
+
await client.patch(`/api/agents/${args2.agent}/team`, body);
|
|
1636
|
+
console.log(`moved ${args2.agent} to team ${args2.team}`);
|
|
1564
1637
|
}
|
|
1565
1638
|
});
|
|
1566
1639
|
var sessionHeadCmd = defineCommand5({
|
|
@@ -1572,10 +1645,10 @@ var sessionHeadCmd = defineCommand5({
|
|
|
1572
1645
|
id: { type: "positional", required: true },
|
|
1573
1646
|
json: { type: "boolean", description: "Emit raw JSON instead of a human line" }
|
|
1574
1647
|
},
|
|
1575
|
-
async run({ args }) {
|
|
1648
|
+
async run({ args: args2 }) {
|
|
1576
1649
|
const client = createClient2();
|
|
1577
|
-
const head = await client.get(`/api/agents/${
|
|
1578
|
-
if (
|
|
1650
|
+
const head = await client.get(`/api/agents/${args2.id}/sessions/head`);
|
|
1651
|
+
if (args2.json) {
|
|
1579
1652
|
console.log(JSON.stringify(head));
|
|
1580
1653
|
return;
|
|
1581
1654
|
}
|
|
@@ -1587,10 +1660,10 @@ var cancelCmd = defineCommand5({
|
|
|
1587
1660
|
args: {
|
|
1588
1661
|
id: { type: "positional", required: true }
|
|
1589
1662
|
},
|
|
1590
|
-
async run({ args }) {
|
|
1663
|
+
async run({ args: args2 }) {
|
|
1591
1664
|
const client = createClient2();
|
|
1592
|
-
await client.post(`/api/agents/${
|
|
1593
|
-
console.log(`cancelled active turn for ${
|
|
1665
|
+
await client.post(`/api/agents/${args2.id}/cancel`);
|
|
1666
|
+
console.log(`cancelled active turn for ${args2.id}`);
|
|
1594
1667
|
}
|
|
1595
1668
|
});
|
|
1596
1669
|
var reviewConfigCmd = defineCommand5({
|
|
@@ -1603,24 +1676,24 @@ var reviewConfigCmd = defineCommand5({
|
|
|
1603
1676
|
model: { type: "string", description: "Review model, or 'agent' to use the Agent model" },
|
|
1604
1677
|
reasoning: { type: "string", description: "Review reasoning level" }
|
|
1605
1678
|
},
|
|
1606
|
-
async run({ args }) {
|
|
1607
|
-
if (
|
|
1679
|
+
async run({ args: args2 }) {
|
|
1680
|
+
if (args2.enable && args2.disable) throw new Error("choose either --enable or --disable");
|
|
1608
1681
|
const client = createClient2();
|
|
1609
1682
|
const body = {};
|
|
1610
|
-
if (
|
|
1611
|
-
if (
|
|
1612
|
-
const value = Number(
|
|
1683
|
+
if (args2.enable || args2.disable) body.enabled = Boolean(args2.enable);
|
|
1684
|
+
if (args2.every !== void 0) {
|
|
1685
|
+
const value = Number(args2.every);
|
|
1613
1686
|
if (!Number.isInteger(value) || value < 1 || value > 100) {
|
|
1614
1687
|
throw new Error("--every must be an integer from 1 to 100");
|
|
1615
1688
|
}
|
|
1616
1689
|
body.everyNTurns = value;
|
|
1617
1690
|
}
|
|
1618
|
-
if (
|
|
1619
|
-
if (
|
|
1620
|
-
body.reasoningLevel =
|
|
1691
|
+
if (args2.model !== void 0) body.model = args2.model === "agent" ? null : args2.model;
|
|
1692
|
+
if (args2.reasoning !== void 0) {
|
|
1693
|
+
body.reasoningLevel = args2.reasoning;
|
|
1621
1694
|
}
|
|
1622
1695
|
const hasChanges = Object.keys(body).length > 0;
|
|
1623
|
-
const config = hasChanges ? await client.patch(`/api/agents/${
|
|
1696
|
+
const config = hasChanges ? await client.patch(`/api/agents/${args2.id}/review-config`, body) : await client.get(`/api/agents/${args2.id}/review-config`);
|
|
1624
1697
|
console.log(`review: ${config.enabled ? "enabled" : "disabled"}`);
|
|
1625
1698
|
console.log(`cadence: every ${config.everyNTurns} successful user turns`);
|
|
1626
1699
|
console.log(`model: ${config.model ?? "agent model"}`);
|
|
@@ -1631,9 +1704,9 @@ var reviewConfigCmd = defineCommand5({
|
|
|
1631
1704
|
var reviewCmd = defineCommand5({
|
|
1632
1705
|
meta: { name: "review", description: "Enqueue a reviewed-learning pass" },
|
|
1633
1706
|
args: { id: { type: "positional", required: true, description: "Agent id or prefix" } },
|
|
1634
|
-
async run({ args }) {
|
|
1707
|
+
async run({ args: args2 }) {
|
|
1635
1708
|
const response = await createClient2().post(
|
|
1636
|
-
`/api/agents/${
|
|
1709
|
+
`/api/agents/${args2.id}/reviews`
|
|
1637
1710
|
);
|
|
1638
1711
|
console.log(`review ${response.review.id} ${response.review.status}`);
|
|
1639
1712
|
}
|
|
@@ -1644,11 +1717,11 @@ var reviewsCmd = defineCommand5({
|
|
|
1644
1717
|
id: { type: "positional", required: true, description: "Agent id or prefix" },
|
|
1645
1718
|
status: { type: "string", description: "pending|running|retrying|completed|failed|cancelled" }
|
|
1646
1719
|
},
|
|
1647
|
-
async run({ args }) {
|
|
1720
|
+
async run({ args: args2 }) {
|
|
1648
1721
|
const response = await createClient2().get(
|
|
1649
|
-
`/api/agents/${
|
|
1722
|
+
`/api/agents/${args2.id}/reviews`
|
|
1650
1723
|
);
|
|
1651
|
-
const reviews =
|
|
1724
|
+
const reviews = args2.status ? response.reviews.filter((review) => review.status === args2.status) : response.reviews;
|
|
1652
1725
|
if (reviews.length === 0) return console.log("(no reviews)");
|
|
1653
1726
|
for (const line of columnize(
|
|
1654
1727
|
reviews.map((review) => [
|
|
@@ -1669,11 +1742,11 @@ var lessonsCmd = defineCommand5({
|
|
|
1669
1742
|
id: { type: "positional", required: true, description: "Agent id or prefix" },
|
|
1670
1743
|
status: { type: "string", description: "pending|approved|rejected|revoked" }
|
|
1671
1744
|
},
|
|
1672
|
-
async run({ args }) {
|
|
1673
|
-
const status =
|
|
1745
|
+
async run({ args: args2 }) {
|
|
1746
|
+
const status = args2.status;
|
|
1674
1747
|
const query = status ? `?status=${encodeURIComponent(status)}` : "";
|
|
1675
1748
|
const response = await createClient2().get(
|
|
1676
|
-
`/api/agents/${
|
|
1749
|
+
`/api/agents/${args2.id}/lesson-proposals${query}`
|
|
1677
1750
|
);
|
|
1678
1751
|
if (response.proposals.length === 0) return console.log("(no lesson proposals)");
|
|
1679
1752
|
for (const line of columnize(
|
|
@@ -1707,9 +1780,9 @@ function lessonDecisionCmd(decision2) {
|
|
|
1707
1780
|
id: { type: "positional", required: true, description: "Proposal id or prefix" },
|
|
1708
1781
|
yes: { type: "boolean", description: `Confirm ${decision2}` }
|
|
1709
1782
|
},
|
|
1710
|
-
async run({ args }) {
|
|
1711
|
-
if (!
|
|
1712
|
-
const { agent, proposal } = await locateProposal(
|
|
1783
|
+
async run({ args: args2 }) {
|
|
1784
|
+
if (!args2.yes) throw new Error(`${decision2} requires --yes`);
|
|
1785
|
+
const { agent, proposal } = await locateProposal(args2.id);
|
|
1713
1786
|
const response = await createClient2().post(
|
|
1714
1787
|
`/api/agents/${agent.id}/lesson-proposals/${proposal.id}/${decision2}`,
|
|
1715
1788
|
{ version: proposal.version }
|
|
@@ -1725,14 +1798,14 @@ var lessonEditCmd = defineCommand5({
|
|
|
1725
1798
|
text: { type: "string", description: "Replacement lesson text" },
|
|
1726
1799
|
scope: { type: "string", description: "private|shared" }
|
|
1727
1800
|
},
|
|
1728
|
-
async run({ args }) {
|
|
1729
|
-
if (
|
|
1801
|
+
async run({ args: args2 }) {
|
|
1802
|
+
if (args2.text === void 0 && args2.scope === void 0) {
|
|
1730
1803
|
throw new Error("lesson edit requires --text or --scope");
|
|
1731
1804
|
}
|
|
1732
|
-
const { agent, proposal } = await locateProposal(
|
|
1805
|
+
const { agent, proposal } = await locateProposal(args2.id);
|
|
1733
1806
|
const response = await createClient2().patch(
|
|
1734
1807
|
`/api/agents/${agent.id}/lesson-proposals/${proposal.id}`,
|
|
1735
|
-
{ version: proposal.version, text:
|
|
1808
|
+
{ version: proposal.version, text: args2.text, scope: args2.scope }
|
|
1736
1809
|
);
|
|
1737
1810
|
console.log(`updated ${response.proposal.id} v${response.proposal.version}`);
|
|
1738
1811
|
}
|
|
@@ -1781,13 +1854,13 @@ var list3 = defineCommand6({
|
|
|
1781
1854
|
team: { type: "string" },
|
|
1782
1855
|
json: { type: "boolean" }
|
|
1783
1856
|
},
|
|
1784
|
-
async run({ args }) {
|
|
1785
|
-
const query = new URLSearchParams({ status:
|
|
1786
|
-
if (
|
|
1857
|
+
async run({ args: args2 }) {
|
|
1858
|
+
const query = new URLSearchParams({ status: args2.status, limit: "100" });
|
|
1859
|
+
if (args2.team) query.set("teamId", args2.team);
|
|
1787
1860
|
const body = await createClient2().get(
|
|
1788
1861
|
`/api/approvals?${query}`
|
|
1789
1862
|
);
|
|
1790
|
-
if (
|
|
1863
|
+
if (args2.json) return console.log(JSON.stringify(body, null, 2));
|
|
1791
1864
|
if (!body.approvals.length) return console.log("(no approvals)");
|
|
1792
1865
|
for (const line of columnize([
|
|
1793
1866
|
["id", "status", "path", "origin", "expires"],
|
|
@@ -1805,11 +1878,11 @@ var list3 = defineCommand6({
|
|
|
1805
1878
|
var show3 = defineCommand6({
|
|
1806
1879
|
meta: { name: "show", description: "Show one approval including payload and audit events" },
|
|
1807
1880
|
args: { id: { type: "positional", required: true }, json: { type: "boolean" } },
|
|
1808
|
-
async run({ args }) {
|
|
1881
|
+
async run({ args: args2 }) {
|
|
1809
1882
|
const item = await createClient2().get(
|
|
1810
|
-
`/api/approvals/${encodeURIComponent(
|
|
1883
|
+
`/api/approvals/${encodeURIComponent(args2.id)}`
|
|
1811
1884
|
);
|
|
1812
|
-
if (
|
|
1885
|
+
if (args2.json) return console.log(JSON.stringify(item, null, 2));
|
|
1813
1886
|
console.log(`# ${item.id}`);
|
|
1814
1887
|
console.log(`status: ${item.status}`);
|
|
1815
1888
|
console.log(`attempt: ${item.attemptKind}:${item.attemptId}`);
|
|
@@ -1834,13 +1907,13 @@ function decision(name) {
|
|
|
1834
1907
|
yes: { type: "boolean", description: "Required explicit non-interactive confirmation" },
|
|
1835
1908
|
json: { type: "boolean" }
|
|
1836
1909
|
},
|
|
1837
|
-
async run({ args }) {
|
|
1838
|
-
if (!
|
|
1910
|
+
async run({ args: args2 }) {
|
|
1911
|
+
if (!args2.yes) throw new Error(`refusing ${name}: review with approval show, then pass --yes`);
|
|
1839
1912
|
const item = await createClient2().post(
|
|
1840
|
-
`/api/approvals/${encodeURIComponent(
|
|
1841
|
-
|
|
1913
|
+
`/api/approvals/${encodeURIComponent(args2.id)}/${name}`,
|
|
1914
|
+
args2.reason ? { reason: args2.reason } : {}
|
|
1842
1915
|
);
|
|
1843
|
-
if (
|
|
1916
|
+
if (args2.json) console.log(JSON.stringify(item, null, 2));
|
|
1844
1917
|
else console.log(`${item.id}: ${item.status}`);
|
|
1845
1918
|
}
|
|
1846
1919
|
});
|
|
@@ -1868,11 +1941,11 @@ var list4 = defineCommand7({
|
|
|
1868
1941
|
kind: { type: "string" },
|
|
1869
1942
|
json: { type: "boolean" }
|
|
1870
1943
|
},
|
|
1871
|
-
async run({ args }) {
|
|
1872
|
-
const query = new URLSearchParams({ state:
|
|
1873
|
-
if (
|
|
1944
|
+
async run({ args: args2 }) {
|
|
1945
|
+
const query = new URLSearchParams({ state: args2.state, limit: "200" });
|
|
1946
|
+
if (args2.kind) query.set("kind", args2.kind);
|
|
1874
1947
|
const body = await createClient2().get(`/api/attention?${query}`);
|
|
1875
|
-
if (
|
|
1948
|
+
if (args2.json) return console.log(JSON.stringify(body, null, 2));
|
|
1876
1949
|
if (!body.items.length) console.log("(nothing needs attention)");
|
|
1877
1950
|
else
|
|
1878
1951
|
for (const line of columnize([
|
|
@@ -1893,9 +1966,9 @@ var list4 = defineCommand7({
|
|
|
1893
1966
|
var summary = defineCommand7({
|
|
1894
1967
|
meta: { name: "summary", description: "Summarize open attention items" },
|
|
1895
1968
|
args: { json: { type: "boolean" } },
|
|
1896
|
-
async run({ args }) {
|
|
1969
|
+
async run({ args: args2 }) {
|
|
1897
1970
|
const body = await createClient2().get("/api/attention/summary");
|
|
1898
|
-
if (
|
|
1971
|
+
if (args2.json) console.log(JSON.stringify(body, null, 2));
|
|
1899
1972
|
else
|
|
1900
1973
|
console.log(
|
|
1901
1974
|
`${body.openTotal} open \xB7 ${body.bySeverity.action_required} action required \xB7 ${body.bySeverity.error} errors \xB7 ${body.bySeverity.warning} warnings`
|
|
@@ -1910,11 +1983,11 @@ function mutation(name) {
|
|
|
1910
1983
|
yes: { type: "boolean", description: "Required confirmation" },
|
|
1911
1984
|
json: { type: "boolean" }
|
|
1912
1985
|
},
|
|
1913
|
-
async run({ args }) {
|
|
1914
|
-
if (!
|
|
1915
|
-
const path = `/api/attention/${encodeURIComponent(
|
|
1986
|
+
async run({ args: args2 }) {
|
|
1987
|
+
if (!args2.yes) throw new Error(`refusing mutation: pass --yes to ${name}`);
|
|
1988
|
+
const path = `/api/attention/${encodeURIComponent(args2.key)}/${name === "acknowledge" ? "acknowledge" : "acknowledgement"}`;
|
|
1916
1989
|
const body = name === "acknowledge" ? await createClient2().post(path) : await createClient2().del(path);
|
|
1917
|
-
if (
|
|
1990
|
+
if (args2.json) console.log(JSON.stringify(body, null, 2));
|
|
1918
1991
|
else console.log(`${body.item.key}: ${body.item.acknowledgedAt ? "acknowledged" : "open"}`);
|
|
1919
1992
|
}
|
|
1920
1993
|
});
|
|
@@ -1922,12 +1995,12 @@ function mutation(name) {
|
|
|
1922
1995
|
var acknowledgeAll = defineCommand7({
|
|
1923
1996
|
meta: { name: "acknowledge-all", description: "Acknowledge all open informational items" },
|
|
1924
1997
|
args: { yes: { type: "boolean" }, json: { type: "boolean" } },
|
|
1925
|
-
async run({ args }) {
|
|
1926
|
-
if (!
|
|
1998
|
+
async run({ args: args2 }) {
|
|
1999
|
+
if (!args2.yes) throw new Error("refusing mutation: pass --yes to acknowledge-all");
|
|
1927
2000
|
const body = await createClient2().post(
|
|
1928
2001
|
"/api/attention/acknowledge-all"
|
|
1929
2002
|
);
|
|
1930
|
-
if (
|
|
2003
|
+
if (args2.json) console.log(JSON.stringify(body, null, 2));
|
|
1931
2004
|
else console.log(`acknowledged ${body.acknowledged} informational item(s)`);
|
|
1932
2005
|
}
|
|
1933
2006
|
});
|
|
@@ -1979,7 +2052,7 @@ function answerCliOpenAIPrompt(prompt, input = process.stdin, output4 = process.
|
|
|
1979
2052
|
);
|
|
1980
2053
|
}
|
|
1981
2054
|
output4.write(`${prompt.message}: `);
|
|
1982
|
-
return new Promise((
|
|
2055
|
+
return new Promise((resolve6, reject) => {
|
|
1983
2056
|
let settled = false;
|
|
1984
2057
|
const signal = prompt.signal;
|
|
1985
2058
|
let readingInput = true;
|
|
@@ -2000,7 +2073,7 @@ function answerCliOpenAIPrompt(prompt, input = process.stdin, output4 = process.
|
|
|
2000
2073
|
if (settled) return;
|
|
2001
2074
|
settled = true;
|
|
2002
2075
|
cleanup();
|
|
2003
|
-
|
|
2076
|
+
resolve6(String(data).trim());
|
|
2004
2077
|
};
|
|
2005
2078
|
const onAbort = () => {
|
|
2006
2079
|
if (settled || !signal) return;
|
|
@@ -2049,9 +2122,9 @@ var openaiLoginCmd = defineCommand8({
|
|
|
2049
2122
|
description: "Use headless device-code login instead of the localhost browser callback"
|
|
2050
2123
|
}
|
|
2051
2124
|
},
|
|
2052
|
-
async run({ args }) {
|
|
2125
|
+
async run({ args: args2 }) {
|
|
2053
2126
|
const client = createClient2();
|
|
2054
|
-
const loginMethod =
|
|
2127
|
+
const loginMethod = args2["device-code"] ? "device_code" : "browser";
|
|
2055
2128
|
if (loginMethod === "device_code") {
|
|
2056
2129
|
console.log("starting OpenAI device-code sign-in...");
|
|
2057
2130
|
} else {
|
|
@@ -2172,7 +2245,7 @@ import {
|
|
|
2172
2245
|
createWriteStream,
|
|
2173
2246
|
existsSync as existsSync2,
|
|
2174
2247
|
fsyncSync as fsyncSync2,
|
|
2175
|
-
lstatSync as
|
|
2248
|
+
lstatSync as lstatSync3,
|
|
2176
2249
|
mkdirSync as mkdirSync2,
|
|
2177
2250
|
mkdtempSync,
|
|
2178
2251
|
openSync as openSync2,
|
|
@@ -2184,7 +2257,7 @@ import {
|
|
|
2184
2257
|
writeFileSync as writeFileSync2
|
|
2185
2258
|
} from "fs";
|
|
2186
2259
|
import { tmpdir } from "os";
|
|
2187
|
-
import { basename as basename4, dirname as dirname2, isAbsolute, parse, posix, relative, resolve as
|
|
2260
|
+
import { basename as basename4, dirname as dirname2, isAbsolute, parse, posix, relative, resolve as resolve3 } from "path";
|
|
2188
2261
|
import { DatabaseSync as DatabaseSync2, backup as sqliteBackup } from "node:sqlite";
|
|
2189
2262
|
import { Readable } from "stream";
|
|
2190
2263
|
import { pipeline } from "stream/promises";
|
|
@@ -2192,6 +2265,40 @@ import { Decrypter, Encrypter } from "age-encryption";
|
|
|
2192
2265
|
import { defineCommand as defineCommand9 } from "citty";
|
|
2193
2266
|
import { extract, list as list5 } from "tar";
|
|
2194
2267
|
|
|
2268
|
+
// src/backup-coding-recovery.ts
|
|
2269
|
+
import { lstatSync } from "fs";
|
|
2270
|
+
import { resolve } from "path";
|
|
2271
|
+
function invalidateRestoredCodingEvidence(db, payload, targetHome) {
|
|
2272
|
+
const rows = db.prepare("SELECT id, receipt_json FROM coding_commands").all();
|
|
2273
|
+
for (const row2 of rows) {
|
|
2274
|
+
const receipt = JSON.parse(row2.receipt_json);
|
|
2275
|
+
receipt.environment.inputFingerprint = null;
|
|
2276
|
+
if (!receipt.finishedAt) {
|
|
2277
|
+
receipt.state = "interrupted";
|
|
2278
|
+
receipt.reason = "backup_restored";
|
|
2279
|
+
receipt.finishedAt = Date.now();
|
|
2280
|
+
}
|
|
2281
|
+
db.prepare("UPDATE coding_commands SET state = ?, receipt_json = ? WHERE id = ?").run(
|
|
2282
|
+
receipt.state,
|
|
2283
|
+
JSON.stringify(receipt),
|
|
2284
|
+
row2.id
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
const restoredAt = Date.now();
|
|
2288
|
+
db.prepare(
|
|
2289
|
+
`UPDATE coding_command_logs SET state = 'expired', text = NULL, byte_length = 0, retired_at = ?
|
|
2290
|
+
WHERE state = 'retained' AND expires_at <= ?`
|
|
2291
|
+
).run(restoredAt, restoredAt);
|
|
2292
|
+
db.prepare("DELETE FROM source_snapshots WHERE expires_at <= ?").run(restoredAt);
|
|
2293
|
+
db.prepare("UPDATE workspace_writers SET state = 'recovery', recovery_mode = 'restored'").run();
|
|
2294
|
+
const teams = db.prepare("SELECT id FROM teams").all();
|
|
2295
|
+
const rebase = db.prepare("UPDATE workspace_writers SET root_path = ? WHERE team_id = ?");
|
|
2296
|
+
for (const team of teams) {
|
|
2297
|
+
if (lstatSync(resolve(payload, "teams", team.id)).isDirectory())
|
|
2298
|
+
rebase.run(resolve(targetHome, "teams", team.id), team.id);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2195
2302
|
// src/backup-queue-recovery.ts
|
|
2196
2303
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
2197
2304
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -2264,8 +2371,19 @@ function pauseRestoredUserQueue(database) {
|
|
|
2264
2371
|
// src/backup-schema.ts
|
|
2265
2372
|
import { createHash } from "crypto";
|
|
2266
2373
|
var CANONICAL_MIGRATION = "0001_init";
|
|
2267
|
-
var CANONICAL_SCHEMA_HASH = "
|
|
2374
|
+
var CANONICAL_SCHEMA_HASH = "8454a37b1985d248bb25c6588d81b5f00506e13387600c4441ba01727d10bcaf";
|
|
2268
2375
|
var CANONICAL_OBJECTS = [
|
|
2376
|
+
["table", "team_coding_environments"],
|
|
2377
|
+
["table", "workspace_writers"],
|
|
2378
|
+
["table", "workspace_resources"],
|
|
2379
|
+
["table", "coding_commands"],
|
|
2380
|
+
["index", "coding_command_history"],
|
|
2381
|
+
["table", "coding_command_logs"],
|
|
2382
|
+
["index", "coding_command_logs_retention"],
|
|
2383
|
+
["index", "coding_command_logs_team_time"],
|
|
2384
|
+
["table", "source_snapshots"],
|
|
2385
|
+
["index", "source_snapshots_retention"],
|
|
2386
|
+
["index", "source_snapshots_team_time"],
|
|
2269
2387
|
["table", "notification_settings"],
|
|
2270
2388
|
["table", "notification_receipts"],
|
|
2271
2389
|
["index", "notification_receipts_state"],
|
|
@@ -2408,7 +2526,7 @@ import {
|
|
|
2408
2526
|
fsyncSync,
|
|
2409
2527
|
ftruncateSync,
|
|
2410
2528
|
futimesSync,
|
|
2411
|
-
lstatSync,
|
|
2529
|
+
lstatSync as lstatSync2,
|
|
2412
2530
|
mkdirSync,
|
|
2413
2531
|
openSync,
|
|
2414
2532
|
readFileSync as readFileSync4,
|
|
@@ -2417,12 +2535,12 @@ import {
|
|
|
2417
2535
|
rmSync,
|
|
2418
2536
|
writeSync
|
|
2419
2537
|
} from "fs";
|
|
2420
|
-
import { basename as basename3, dirname, join as join2, resolve } from "path";
|
|
2538
|
+
import { basename as basename3, dirname, join as join2, resolve as resolve2 } from "path";
|
|
2421
2539
|
var DAEMON_LIVENESS_FILENAME = "daemon-runtime.json";
|
|
2422
2540
|
var STALE_AFTER_MS = 6e4;
|
|
2423
2541
|
var PROBE_TIMEOUT_MS = 750;
|
|
2424
2542
|
function canonicalHomeIdentity(home) {
|
|
2425
|
-
const absolute =
|
|
2543
|
+
const absolute = resolve2(home);
|
|
2426
2544
|
try {
|
|
2427
2545
|
return realpathSync.native(absolute);
|
|
2428
2546
|
} catch (error) {
|
|
@@ -2472,7 +2590,7 @@ function parseRecord(raw) {
|
|
|
2472
2590
|
}
|
|
2473
2591
|
function readRecord(path) {
|
|
2474
2592
|
try {
|
|
2475
|
-
const stat =
|
|
2593
|
+
const stat = lstatSync2(path);
|
|
2476
2594
|
const raw = stat.isFile() ? readFileSync4(path, "utf8") : "";
|
|
2477
2595
|
return { raw, stat, record: stat.isFile() ? parseRecord(raw) : null };
|
|
2478
2596
|
} catch (error) {
|
|
@@ -2560,7 +2678,7 @@ function reclaimRecord(path, existing) {
|
|
|
2560
2678
|
}
|
|
2561
2679
|
}
|
|
2562
2680
|
async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
2563
|
-
const targetHome =
|
|
2681
|
+
const targetHome = resolve2(home);
|
|
2564
2682
|
mkdirSync(dirname(targetHome), { recursive: true });
|
|
2565
2683
|
const path = daemonLivenessPath(targetHome);
|
|
2566
2684
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -2652,7 +2770,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
|
2652
2770
|
closeSync(fd);
|
|
2653
2771
|
fd = null;
|
|
2654
2772
|
try {
|
|
2655
|
-
if (sameFile(
|
|
2773
|
+
if (sameFile(lstatSync2(path), ownedStat)) rmSync(path, { force: true });
|
|
2656
2774
|
} catch {
|
|
2657
2775
|
}
|
|
2658
2776
|
throw error;
|
|
@@ -2661,7 +2779,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
|
2661
2779
|
let uninstallComplete = false;
|
|
2662
2780
|
const stillOwnsPath = () => {
|
|
2663
2781
|
try {
|
|
2664
|
-
return sameFile(
|
|
2782
|
+
return sameFile(lstatSync2(path), ownedStat);
|
|
2665
2783
|
} catch {
|
|
2666
2784
|
return false;
|
|
2667
2785
|
}
|
|
@@ -2689,7 +2807,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
|
2689
2807
|
markSwapping(recoveryPath, hadPrevious) {
|
|
2690
2808
|
if (released || !stillOwnsPath()) throw new Error("restore ownership was lost");
|
|
2691
2809
|
record.state = "swapping";
|
|
2692
|
-
record.recoveryPath =
|
|
2810
|
+
record.recoveryPath = resolve2(recoveryPath);
|
|
2693
2811
|
record.hadPrevious = hadPrevious;
|
|
2694
2812
|
writeRecord(fd, record);
|
|
2695
2813
|
fsyncParentDirectory(path);
|
|
@@ -2704,7 +2822,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
|
2704
2822
|
markRecoveryRequired(recoveryPath, hadPrevious) {
|
|
2705
2823
|
if (released || !stillOwnsPath()) throw new Error("restore ownership was lost");
|
|
2706
2824
|
record.state = "recovery-required";
|
|
2707
|
-
record.recoveryPath =
|
|
2825
|
+
record.recoveryPath = resolve2(recoveryPath);
|
|
2708
2826
|
record.hadPrevious = hadPrevious;
|
|
2709
2827
|
writeRecord(fd, record);
|
|
2710
2828
|
},
|
|
@@ -2746,29 +2864,29 @@ var createCmd = defineCommand9({
|
|
|
2746
2864
|
description: "Explicitly permit a sensitive unencrypted .tar.gz backup"
|
|
2747
2865
|
}
|
|
2748
2866
|
},
|
|
2749
|
-
async run({ args }) {
|
|
2750
|
-
if (
|
|
2867
|
+
async run({ args: args2 }) {
|
|
2868
|
+
if (args2.recipient && args2.plaintext) {
|
|
2751
2869
|
throw new Error("--recipient and --plaintext are mutually exclusive");
|
|
2752
2870
|
}
|
|
2753
|
-
if (!
|
|
2871
|
+
if (!args2.recipient && !args2.plaintext) {
|
|
2754
2872
|
throw new Error("choose --recipient <age1\u2026> for encryption or explicitly pass --plaintext");
|
|
2755
2873
|
}
|
|
2756
2874
|
const cfg = loadClientConfig();
|
|
2757
2875
|
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2758
|
-
const defaultSuffix =
|
|
2759
|
-
const outAbs =
|
|
2876
|
+
const defaultSuffix = args2.recipient ? ".tar.gz.age" : ".tar.gz";
|
|
2877
|
+
const outAbs = resolve3(args2.output ?? `bazilion-backup-${date}${defaultSuffix}`);
|
|
2760
2878
|
if (existsSync2(outAbs)) throw new Error(`refusing to overwrite existing backup: ${outAbs}`);
|
|
2761
|
-
const configuredHome =
|
|
2879
|
+
const configuredHome = resolve3(resolveCliPaths().home);
|
|
2762
2880
|
const outputFromHome = relative(configuredHome, outAbs);
|
|
2763
2881
|
if (!outputFromHome || !outputFromHome.startsWith("..") && !isAbsolute(outputFromHome)) {
|
|
2764
2882
|
throw new Error(
|
|
2765
2883
|
`backup output must be outside BAZILION_HOME (${configuredHome}) to avoid nesting backups`
|
|
2766
2884
|
);
|
|
2767
2885
|
}
|
|
2768
|
-
if (!
|
|
2886
|
+
if (!args2.recipient) {
|
|
2769
2887
|
console.warn("warning: creating a plaintext backup containing all Bazilion credentials");
|
|
2770
2888
|
}
|
|
2771
|
-
console.log(`${
|
|
2889
|
+
console.log(`${args2.recipient ? "encrypting" : "downloading"} backup \u2192 ${outAbs}`);
|
|
2772
2890
|
const res = await fetch(`${cfg.serverUrl}/api/backup`, {
|
|
2773
2891
|
headers: { authorization: `Bearer ${cfg.token}`, origin: cfg.serverUrl }
|
|
2774
2892
|
});
|
|
@@ -2781,13 +2899,13 @@ var createCmd = defineCommand9({
|
|
|
2781
2899
|
}
|
|
2782
2900
|
throw new Error(`backup failed: ${err}`);
|
|
2783
2901
|
}
|
|
2784
|
-
const downloadDir = mkdtempSync(
|
|
2785
|
-
const partial =
|
|
2902
|
+
const downloadDir = mkdtempSync(resolve3(tmpdir(), "bazilion-download-"));
|
|
2903
|
+
const partial = resolve3(downloadDir, "backup.tar.gz");
|
|
2786
2904
|
try {
|
|
2787
|
-
if (
|
|
2905
|
+
if (args2.recipient) {
|
|
2788
2906
|
const [encryptSource, validateSource] = res.body.tee();
|
|
2789
2907
|
const encrypter = new Encrypter();
|
|
2790
|
-
encrypter.addRecipient(
|
|
2908
|
+
encrypter.addRecipient(args2.recipient);
|
|
2791
2909
|
const encrypted = await encrypter.encrypt(encryptSource);
|
|
2792
2910
|
await Promise.all([
|
|
2793
2911
|
pipeline(
|
|
@@ -2802,12 +2920,12 @@ var createCmd = defineCommand9({
|
|
|
2802
2920
|
createWriteStream(partial, { flags: "wx", mode: 384 })
|
|
2803
2921
|
);
|
|
2804
2922
|
}
|
|
2805
|
-
if (!
|
|
2923
|
+
if (!args2.recipient) await validateArchive(partial);
|
|
2806
2924
|
try {
|
|
2807
2925
|
renameSync2(partial, outAbs);
|
|
2808
2926
|
} catch (error) {
|
|
2809
2927
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "EXDEV") throw error;
|
|
2810
|
-
const installPartial =
|
|
2928
|
+
const installPartial = resolve3(
|
|
2811
2929
|
dirname2(outAbs),
|
|
2812
2930
|
`.${basename4(outAbs)}.${randomUUID7()}.installing`
|
|
2813
2931
|
);
|
|
@@ -3047,7 +3165,7 @@ function validateEntityId(id, pattern, entity) {
|
|
|
3047
3165
|
return id;
|
|
3048
3166
|
}
|
|
3049
3167
|
function containedChildDirectory(root, id, rowLabel) {
|
|
3050
|
-
const child =
|
|
3168
|
+
const child = resolve3(root, id);
|
|
3051
3169
|
const fromRoot = relative(root, child);
|
|
3052
3170
|
if (!fromRoot || fromRoot.startsWith("..") || isAbsolute(fromRoot)) {
|
|
3053
3171
|
throw new Error(`${rowLabel} directory escapes its canonical root: ${JSON.stringify(id)}`);
|
|
@@ -3056,14 +3174,14 @@ function containedChildDirectory(root, id, rowLabel) {
|
|
|
3056
3174
|
}
|
|
3057
3175
|
function requireExtractedDirectory(path, rowLabel) {
|
|
3058
3176
|
try {
|
|
3059
|
-
if (
|
|
3177
|
+
if (lstatSync3(path).isDirectory()) return;
|
|
3060
3178
|
} catch {
|
|
3061
3179
|
}
|
|
3062
3180
|
throw new Error(`${rowLabel} is missing its canonical directory in the backup`);
|
|
3063
3181
|
}
|
|
3064
3182
|
function requireExtractedTeamSlot(path, rowLabel) {
|
|
3065
3183
|
try {
|
|
3066
|
-
const entry3 =
|
|
3184
|
+
const entry3 = lstatSync3(path);
|
|
3067
3185
|
if (entry3.isDirectory() || entry3.isSymbolicLink()) return;
|
|
3068
3186
|
} catch {
|
|
3069
3187
|
}
|
|
@@ -3083,8 +3201,8 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
|
|
|
3083
3201
|
["agents", agents, AGENT_ID]
|
|
3084
3202
|
]) {
|
|
3085
3203
|
const collection = table;
|
|
3086
|
-
const stagedRoot =
|
|
3087
|
-
const targetRoot =
|
|
3204
|
+
const stagedRoot = resolve3(payload, collection);
|
|
3205
|
+
const targetRoot = resolve3(targetHome, collection);
|
|
3088
3206
|
for (const row2 of rows) {
|
|
3089
3207
|
const id = validateEntityId(row2.id, idPattern, `${table} row`);
|
|
3090
3208
|
const rowLabel = `${table} row ${JSON.stringify(id)}`;
|
|
@@ -3097,7 +3215,7 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
|
|
|
3097
3215
|
});
|
|
3098
3216
|
}
|
|
3099
3217
|
}
|
|
3100
|
-
const stagedTeamsRoot =
|
|
3218
|
+
const stagedTeamsRoot = resolve3(payload, "teams");
|
|
3101
3219
|
for (const row2 of teams) {
|
|
3102
3220
|
const id = validateEntityId(row2.id, SLUG_ID, "teams row");
|
|
3103
3221
|
const rowLabel = `teams row ${JSON.stringify(id)}`;
|
|
@@ -3127,6 +3245,7 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
|
|
|
3127
3245
|
);
|
|
3128
3246
|
}
|
|
3129
3247
|
}
|
|
3248
|
+
invalidateRestoredCodingEvidence(db, payload, targetHome);
|
|
3130
3249
|
db.exec("COMMIT");
|
|
3131
3250
|
transactionOpen = false;
|
|
3132
3251
|
} catch (error) {
|
|
@@ -3146,15 +3265,15 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
|
|
|
3146
3265
|
}
|
|
3147
3266
|
}
|
|
3148
3267
|
function removeRebuildableQmdIndexes(payload) {
|
|
3149
|
-
const teamsDir =
|
|
3150
|
-
if (!existsSync2(teamsDir) || !
|
|
3268
|
+
const teamsDir = resolve3(payload, "teams");
|
|
3269
|
+
if (!existsSync2(teamsDir) || !lstatSync3(teamsDir).isDirectory()) return;
|
|
3151
3270
|
for (const team of readdirSync(teamsDir, { withFileTypes: true })) {
|
|
3152
3271
|
if (!team.isDirectory() || team.isSymbolicLink()) continue;
|
|
3153
|
-
const memoryDir =
|
|
3154
|
-
if (!existsSync2(memoryDir) || !
|
|
3272
|
+
const memoryDir = resolve3(teamsDir, team.name, "memory");
|
|
3273
|
+
if (!existsSync2(memoryDir) || !lstatSync3(memoryDir).isDirectory()) continue;
|
|
3155
3274
|
for (const entry3 of readdirSync(memoryDir, { withFileTypes: true })) {
|
|
3156
3275
|
if (entry3.isFile() && entry3.name.startsWith(".qmd-index.sqlite")) {
|
|
3157
|
-
rmSync2(
|
|
3276
|
+
rmSync2(resolve3(memoryDir, entry3.name), { force: true });
|
|
3158
3277
|
}
|
|
3159
3278
|
}
|
|
3160
3279
|
}
|
|
@@ -3168,7 +3287,7 @@ function revokeRestoredBrowserSessions(database) {
|
|
|
3168
3287
|
}
|
|
3169
3288
|
}
|
|
3170
3289
|
function installValidatedPayload(payload, targetHome, staging, lifecycle, operations = { rename: renameSync2 }) {
|
|
3171
|
-
const previous =
|
|
3290
|
+
const previous = resolve3(staging, "previous-home");
|
|
3172
3291
|
const hadPrevious = existsSync2(targetHome);
|
|
3173
3292
|
const targetParent = dirname2(targetHome);
|
|
3174
3293
|
const syncDirectory = operations.fsyncDirectory ?? fsyncDirectory;
|
|
@@ -3299,8 +3418,8 @@ function isAgeEncrypted(path) {
|
|
|
3299
3418
|
}
|
|
3300
3419
|
}
|
|
3301
3420
|
function readAgeIdentity(rawPath) {
|
|
3302
|
-
const path =
|
|
3303
|
-
const entry3 =
|
|
3421
|
+
const path = resolve3(rawPath);
|
|
3422
|
+
const entry3 = lstatSync3(path);
|
|
3304
3423
|
if (!entry3.isFile()) throw new Error(`age identity is not a regular file: ${path}`);
|
|
3305
3424
|
if (process.platform !== "win32" && (entry3.mode & 63) !== 0) {
|
|
3306
3425
|
throw new Error(`age identity must be owner-only (chmod 600): ${path}`);
|
|
@@ -3332,11 +3451,11 @@ var restoreCmd = defineCommand9({
|
|
|
3332
3451
|
description: "Path to an age identity file required for encrypted backups"
|
|
3333
3452
|
}
|
|
3334
3453
|
},
|
|
3335
|
-
async run({ args }) {
|
|
3336
|
-
const file =
|
|
3454
|
+
async run({ args: args2 }) {
|
|
3455
|
+
const file = resolve3(args2.file);
|
|
3337
3456
|
if (!existsSync2(file)) throw new Error(`backup file not found: ${file}`);
|
|
3338
|
-
const paths = resolveCliPaths(
|
|
3339
|
-
const targetHome =
|
|
3457
|
+
const paths = resolveCliPaths(args2.home);
|
|
3458
|
+
const targetHome = resolve3(paths.home);
|
|
3340
3459
|
if (targetHome === parse(targetHome).root) {
|
|
3341
3460
|
throw new Error(`refusing to restore over filesystem root: ${targetHome}`);
|
|
3342
3461
|
}
|
|
@@ -3344,7 +3463,7 @@ var restoreCmd = defineCommand9({
|
|
|
3344
3463
|
mkdirSync2(targetParent, { recursive: true });
|
|
3345
3464
|
const restoreLock = await acquireHomeRestoreLock(targetHome);
|
|
3346
3465
|
try {
|
|
3347
|
-
const targetsConfiguredHome = targetHome ===
|
|
3466
|
+
const targetsConfiguredHome = targetHome === resolve3(resolveCliPaths().home);
|
|
3348
3467
|
if (targetsConfiguredHome) {
|
|
3349
3468
|
for (const serverUrl of configuredLoopbackUrls()) {
|
|
3350
3469
|
if (await probeServerRunning(serverUrl)) {
|
|
@@ -3355,26 +3474,26 @@ var restoreCmd = defineCommand9({
|
|
|
3355
3474
|
}
|
|
3356
3475
|
}
|
|
3357
3476
|
if (existsSync2(targetHome)) {
|
|
3358
|
-
if (!
|
|
3477
|
+
if (!lstatSync3(targetHome).isDirectory()) {
|
|
3359
3478
|
throw new Error(`${targetHome} exists and is not a directory`);
|
|
3360
3479
|
}
|
|
3361
3480
|
const entries = readdirSync(targetHome);
|
|
3362
|
-
if (entries.length > 0 && !
|
|
3481
|
+
if (entries.length > 0 && !args2.force) {
|
|
3363
3482
|
throw new Error(
|
|
3364
3483
|
`${targetHome} is not empty. Pass --force to overwrite (destroys existing data).`
|
|
3365
3484
|
);
|
|
3366
3485
|
}
|
|
3367
3486
|
}
|
|
3368
|
-
const staging = mkdtempSync(
|
|
3369
|
-
const stagedArchive =
|
|
3370
|
-
const payload =
|
|
3487
|
+
const staging = mkdtempSync(resolve3(targetParent, ".bazilion-restore-"));
|
|
3488
|
+
const stagedArchive = resolve3(staging, "backup.tar.gz");
|
|
3489
|
+
const payload = resolve3(staging, "payload");
|
|
3371
3490
|
let preserveStaging = false;
|
|
3372
3491
|
try {
|
|
3373
3492
|
if (isAgeEncrypted(file)) {
|
|
3374
|
-
if (!
|
|
3493
|
+
if (!args2.identity) {
|
|
3375
3494
|
throw new Error("encrypted backup requires --identity <owner-only age identity file>");
|
|
3376
3495
|
}
|
|
3377
|
-
const identity = readAgeIdentity(
|
|
3496
|
+
const identity = readAgeIdentity(args2.identity);
|
|
3378
3497
|
const decrypter = new Decrypter();
|
|
3379
3498
|
decrypter.addIdentity(identity);
|
|
3380
3499
|
let decrypted;
|
|
@@ -3394,7 +3513,7 @@ var restoreCmd = defineCommand9({
|
|
|
3394
3513
|
throw new Error("backup decryption failed: ciphertext is truncated or modified");
|
|
3395
3514
|
}
|
|
3396
3515
|
} else {
|
|
3397
|
-
if (
|
|
3516
|
+
if (args2.identity) {
|
|
3398
3517
|
throw new Error("encrypted-only restore requested, but the backup is plaintext");
|
|
3399
3518
|
}
|
|
3400
3519
|
copyFileSync(file, stagedArchive);
|
|
@@ -3413,9 +3532,9 @@ var restoreCmd = defineCommand9({
|
|
|
3413
3532
|
// payload-relative path by npm-tar.
|
|
3414
3533
|
preservePaths: true
|
|
3415
3534
|
});
|
|
3416
|
-
const database =
|
|
3417
|
-
const authFile =
|
|
3418
|
-
if (!
|
|
3535
|
+
const database = resolve3(payload, "bazilion.db");
|
|
3536
|
+
const authFile = resolve3(payload, "auth.json");
|
|
3537
|
+
if (!lstatSync3(database).isFile() || !lstatSync3(authFile).isFile()) {
|
|
3419
3538
|
throw new Error("backup required files did not extract as regular files");
|
|
3420
3539
|
}
|
|
3421
3540
|
const authToken = validateAuthFile(authFile);
|
|
@@ -3477,8 +3596,8 @@ function encryptSecretEnvelope(value, password) {
|
|
|
3477
3596
|
});
|
|
3478
3597
|
}
|
|
3479
3598
|
function credentialInventory(home) {
|
|
3480
|
-
const authFile =
|
|
3481
|
-
const database =
|
|
3599
|
+
const authFile = resolve3(home, "auth.json");
|
|
3600
|
+
const database = resolve3(home, "bazilion.db");
|
|
3482
3601
|
const token = validateAuthFile(authFile);
|
|
3483
3602
|
validateDatabase(database, token);
|
|
3484
3603
|
const db = new DatabaseSync2(database, { readOnly: true });
|
|
@@ -3495,8 +3614,8 @@ function credentialInventory(home) {
|
|
|
3495
3614
|
var inventoryCmd = defineCommand9({
|
|
3496
3615
|
meta: { name: "inventory", description: "List credential classes captured by a backup/home" },
|
|
3497
3616
|
args: { home: { type: "string", description: "Override BAZILION_HOME" } },
|
|
3498
|
-
run({ args }) {
|
|
3499
|
-
const home =
|
|
3617
|
+
run({ args: args2 }) {
|
|
3618
|
+
const home = resolve3(resolveCliPaths(args2.home).home);
|
|
3500
3619
|
const inventory = credentialInventory(home);
|
|
3501
3620
|
console.log("credential classes present (values are never shown):");
|
|
3502
3621
|
console.log(` bootstrap token: ${inventory.bootstrap ? "present" : "missing"}`);
|
|
@@ -3532,17 +3651,17 @@ var rotateBootstrapCmd = defineCommand9({
|
|
|
3532
3651
|
home: { type: "string", description: "Override BAZILION_HOME" },
|
|
3533
3652
|
yes: { type: "boolean", required: true, description: "Confirm token revocation and home swap" }
|
|
3534
3653
|
},
|
|
3535
|
-
async run({ args }) {
|
|
3536
|
-
if (!
|
|
3537
|
-
const paths = resolveCliPaths(
|
|
3538
|
-
const targetHome =
|
|
3654
|
+
async run({ args: args2 }) {
|
|
3655
|
+
if (!args2.yes) throw new Error("--yes is required");
|
|
3656
|
+
const paths = resolveCliPaths(args2.home);
|
|
3657
|
+
const targetHome = resolve3(paths.home);
|
|
3539
3658
|
if (targetHome === parse(targetHome).root) {
|
|
3540
3659
|
throw new Error(`refusing to rotate filesystem root: ${targetHome}`);
|
|
3541
3660
|
}
|
|
3542
3661
|
const lock = await acquireHomeRestoreLock(targetHome);
|
|
3543
3662
|
const parent = dirname2(targetHome);
|
|
3544
|
-
const staging = mkdtempSync(
|
|
3545
|
-
const payload =
|
|
3663
|
+
const staging = mkdtempSync(resolve3(parent, ".bazilion-rotate-"));
|
|
3664
|
+
const payload = resolve3(staging, "payload");
|
|
3546
3665
|
let preserveStaging = false;
|
|
3547
3666
|
try {
|
|
3548
3667
|
for (const serverUrl of configuredLoopbackUrls()) {
|
|
@@ -3554,16 +3673,16 @@ var rotateBootstrapCmd = defineCommand9({
|
|
|
3554
3673
|
if (typeof oldAuth.token !== "string" || !oldAuth.token) {
|
|
3555
3674
|
throw new Error("auth.json is missing the bootstrap token");
|
|
3556
3675
|
}
|
|
3557
|
-
validateDatabase(
|
|
3676
|
+
validateDatabase(resolve3(targetHome, "bazilion.db"), oldAuth.token);
|
|
3558
3677
|
cpSync(targetHome, payload, {
|
|
3559
3678
|
recursive: true,
|
|
3560
3679
|
dereference: false,
|
|
3561
3680
|
verbatimSymlinks: true,
|
|
3562
3681
|
preserveTimestamps: true
|
|
3563
3682
|
});
|
|
3564
|
-
const stagedDb =
|
|
3683
|
+
const stagedDb = resolve3(payload, "bazilion.db");
|
|
3565
3684
|
rmSync2(stagedDb, { force: true });
|
|
3566
|
-
const sourceDb = new DatabaseSync2(
|
|
3685
|
+
const sourceDb = new DatabaseSync2(resolve3(targetHome, "bazilion.db"), { readOnly: true });
|
|
3567
3686
|
try {
|
|
3568
3687
|
await sqliteBackup(sourceDb, stagedDb);
|
|
3569
3688
|
} finally {
|
|
@@ -3610,8 +3729,8 @@ var rotateBootstrapCmd = defineCommand9({
|
|
|
3610
3729
|
} finally {
|
|
3611
3730
|
db.close();
|
|
3612
3731
|
}
|
|
3613
|
-
const stagedAuth =
|
|
3614
|
-
const authPartial =
|
|
3732
|
+
const stagedAuth = resolve3(payload, "auth.json");
|
|
3733
|
+
const authPartial = resolve3(payload, `.auth.json.${randomUUID7()}.installing`);
|
|
3615
3734
|
writeFileSync2(authPartial, `${JSON.stringify({ ...oldAuth, token: newToken }, null, 2)}
|
|
3616
3735
|
`, {
|
|
3617
3736
|
mode: 384,
|
|
@@ -3668,9 +3787,9 @@ async function walk(cmd, path, out) {
|
|
|
3668
3787
|
await walk(sub, [...path, name], out);
|
|
3669
3788
|
}
|
|
3670
3789
|
}
|
|
3671
|
-
function flagsOf(
|
|
3790
|
+
function flagsOf(args2) {
|
|
3672
3791
|
const out = [];
|
|
3673
|
-
for (const [name, def] of Object.entries(
|
|
3792
|
+
for (const [name, def] of Object.entries(args2)) {
|
|
3674
3793
|
if (def.type === "positional") continue;
|
|
3675
3794
|
out.push(`--${name}`);
|
|
3676
3795
|
const aliases = Array.isArray(def.alias) ? def.alias : def.alias ? [def.alias] : [];
|
|
@@ -3773,14 +3892,14 @@ function completionCommand(main2) {
|
|
|
3773
3892
|
description: "bash | zsh | fish"
|
|
3774
3893
|
}
|
|
3775
3894
|
},
|
|
3776
|
-
async run({ args }) {
|
|
3895
|
+
async run({ args: args2 }) {
|
|
3777
3896
|
const flat = [];
|
|
3778
3897
|
await walk(main2, [], flat);
|
|
3779
|
-
const shell = String(
|
|
3898
|
+
const shell = String(args2.shell).toLowerCase();
|
|
3780
3899
|
if (shell === "bash") console.log(bashScript(flat));
|
|
3781
3900
|
else if (shell === "zsh") console.log(zshScript(flat));
|
|
3782
3901
|
else if (shell === "fish") console.log(fishScript(flat));
|
|
3783
|
-
else throw new Error(`unsupported shell: ${
|
|
3902
|
+
else throw new Error(`unsupported shell: ${args2.shell} (want bash | zsh | fish)`);
|
|
3784
3903
|
}
|
|
3785
3904
|
});
|
|
3786
3905
|
}
|
|
@@ -3832,11 +3951,11 @@ var setCmd = defineCommand11({
|
|
|
3832
3951
|
description: "New value (empty string clears the field)"
|
|
3833
3952
|
}
|
|
3834
3953
|
},
|
|
3835
|
-
async run({ args }) {
|
|
3954
|
+
async run({ args: args2 }) {
|
|
3836
3955
|
const client = createClient2();
|
|
3837
|
-
const body = { value:
|
|
3956
|
+
const body = { value: args2.value };
|
|
3838
3957
|
const state = await client.put(
|
|
3839
|
-
`/api/config/fields/${encodeURIComponent(
|
|
3958
|
+
`/api/config/fields/${encodeURIComponent(args2.envVar)}`,
|
|
3840
3959
|
body
|
|
3841
3960
|
);
|
|
3842
3961
|
console.log(`${state.envVar} (${state.kind}): ${displayValue(state)}`);
|
|
@@ -3847,10 +3966,10 @@ var rmCmd = defineCommand11({
|
|
|
3847
3966
|
args: {
|
|
3848
3967
|
envVar: { type: "positional", required: true, description: "Env var name to clear" }
|
|
3849
3968
|
},
|
|
3850
|
-
async run({ args }) {
|
|
3969
|
+
async run({ args: args2 }) {
|
|
3851
3970
|
const client = createClient2();
|
|
3852
|
-
await client.del(`/api/config/fields/${encodeURIComponent(
|
|
3853
|
-
console.log(`removed ${
|
|
3971
|
+
await client.del(`/api/config/fields/${encodeURIComponent(args2.envVar)}`);
|
|
3972
|
+
console.log(`removed ${args2.envVar}`);
|
|
3854
3973
|
}
|
|
3855
3974
|
});
|
|
3856
3975
|
var configCommand = defineCommand11({
|
|
@@ -3897,12 +4016,12 @@ function probeHost(host) {
|
|
|
3897
4016
|
return host;
|
|
3898
4017
|
}
|
|
3899
4018
|
function isTcpPortOpen(host, port) {
|
|
3900
|
-
return new Promise((
|
|
4019
|
+
return new Promise((resolve6) => {
|
|
3901
4020
|
const socket = connect({ host: probeHost(host), port: Number(port) });
|
|
3902
4021
|
const done = (open) => {
|
|
3903
4022
|
socket.removeAllListeners();
|
|
3904
4023
|
socket.destroy();
|
|
3905
|
-
|
|
4024
|
+
resolve6(open);
|
|
3906
4025
|
};
|
|
3907
4026
|
socket.setTimeout(600);
|
|
3908
4027
|
socket.once("connect", () => done(true));
|
|
@@ -3951,8 +4070,8 @@ async function waitFor(url, label, timeoutMs = 2e4) {
|
|
|
3951
4070
|
function openBrowser(url) {
|
|
3952
4071
|
const platform = process.platform;
|
|
3953
4072
|
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : process.env.BROWSER || "xdg-open";
|
|
3954
|
-
const
|
|
3955
|
-
const proc = spawn(cmd,
|
|
4073
|
+
const args2 = platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
4074
|
+
const proc = spawn(cmd, args2, { detached: true, stdio: "ignore" });
|
|
3956
4075
|
proc.unref();
|
|
3957
4076
|
}
|
|
3958
4077
|
function spawnProcess(label, entry3, env) {
|
|
@@ -3986,11 +4105,11 @@ var dashboardCommand = defineCommand12({
|
|
|
3986
4105
|
default: true
|
|
3987
4106
|
}
|
|
3988
4107
|
},
|
|
3989
|
-
async run({ args }) {
|
|
3990
|
-
const webHost =
|
|
3991
|
-
const webPort =
|
|
3992
|
-
const daemonHost =
|
|
3993
|
-
const daemonPort =
|
|
4108
|
+
async run({ args: args2 }) {
|
|
4109
|
+
const webHost = args2.host ?? "127.0.0.1";
|
|
4110
|
+
const webPort = args2.port ?? "4322";
|
|
4111
|
+
const daemonHost = args2["daemon-host"] ?? "127.0.0.1";
|
|
4112
|
+
const daemonPort = args2["daemon-port"] ?? "4321";
|
|
3994
4113
|
const daemonUrl = `http://${daemonHost}:${daemonPort}`;
|
|
3995
4114
|
const webUrl = `http://${webHost}:${webPort}`;
|
|
3996
4115
|
const authFile = resolveCliPaths().authFile;
|
|
@@ -4060,7 +4179,7 @@ var dashboardCommand = defineCommand12({
|
|
|
4060
4179
|
console.log("");
|
|
4061
4180
|
console.log(`dashboard: ${webUrl}`);
|
|
4062
4181
|
console.log(`token: ${authFile}`);
|
|
4063
|
-
if (
|
|
4182
|
+
if (args2.open) openBrowser(webUrl);
|
|
4064
4183
|
} catch (err) {
|
|
4065
4184
|
terminateChildren();
|
|
4066
4185
|
throw err;
|
|
@@ -4068,13 +4187,13 @@ var dashboardCommand = defineCommand12({
|
|
|
4068
4187
|
if (children.length === 0) return;
|
|
4069
4188
|
process.on("SIGINT", terminateChildren);
|
|
4070
4189
|
process.on("SIGTERM", terminateChildren);
|
|
4071
|
-
await new Promise((
|
|
4190
|
+
await new Promise((resolve6) => {
|
|
4072
4191
|
let remaining = children.length;
|
|
4073
4192
|
for (const child of children) {
|
|
4074
4193
|
child.on("close", (code) => {
|
|
4075
4194
|
remaining--;
|
|
4076
4195
|
if (!signalled && code && code !== 0) process.exitCode = code;
|
|
4077
|
-
if (remaining === 0)
|
|
4196
|
+
if (remaining === 0) resolve6();
|
|
4078
4197
|
});
|
|
4079
4198
|
}
|
|
4080
4199
|
});
|
|
@@ -4363,14 +4482,14 @@ var listCmd3 = defineCommand15({
|
|
|
4363
4482
|
agent: { type: "positional", required: true, description: "Recipient agent id" },
|
|
4364
4483
|
unread: { type: "boolean", description: "Only show unread messages" }
|
|
4365
4484
|
},
|
|
4366
|
-
async run({ args }) {
|
|
4485
|
+
async run({ args: args2 }) {
|
|
4367
4486
|
const client = createClient2();
|
|
4368
|
-
const qs =
|
|
4487
|
+
const qs = args2.unread ? "?unread=1" : "";
|
|
4369
4488
|
const { messages } = await client.get(
|
|
4370
|
-
`/api/agents/${
|
|
4489
|
+
`/api/agents/${args2.agent}/messages${qs}`
|
|
4371
4490
|
);
|
|
4372
4491
|
if (messages.length === 0) {
|
|
4373
|
-
console.log(
|
|
4492
|
+
console.log(args2.unread ? "(no unread messages)" : "(inbox empty)");
|
|
4374
4493
|
return;
|
|
4375
4494
|
}
|
|
4376
4495
|
for (const line of columnize(messages.map(messageRow))) console.log(line);
|
|
@@ -4381,9 +4500,9 @@ var showCmd2 = defineCommand15({
|
|
|
4381
4500
|
args: {
|
|
4382
4501
|
id: { type: "positional", required: true, description: "Message id" }
|
|
4383
4502
|
},
|
|
4384
|
-
async run({ args }) {
|
|
4503
|
+
async run({ args: args2 }) {
|
|
4385
4504
|
const client = createClient2();
|
|
4386
|
-
const m = await client.get(`/api/messages/${
|
|
4505
|
+
const m = await client.get(`/api/messages/${args2.id}`);
|
|
4387
4506
|
const when = new Date(m.createdAt).toISOString();
|
|
4388
4507
|
const read = m.readAt ? new Date(m.readAt).toISOString() : "(unread)";
|
|
4389
4508
|
console.log(`id: ${m.id}`);
|
|
@@ -4401,10 +4520,10 @@ var readCmd = defineCommand15({
|
|
|
4401
4520
|
args: {
|
|
4402
4521
|
id: { type: "positional", required: true, description: "Message id" }
|
|
4403
4522
|
},
|
|
4404
|
-
async run({ args }) {
|
|
4523
|
+
async run({ args: args2 }) {
|
|
4405
4524
|
const client = createClient2();
|
|
4406
|
-
await client.patch(`/api/messages/${
|
|
4407
|
-
console.log(`marked read: ${
|
|
4525
|
+
await client.patch(`/api/messages/${args2.id}`, { read: true });
|
|
4526
|
+
console.log(`marked read: ${args2.id}`);
|
|
4408
4527
|
}
|
|
4409
4528
|
});
|
|
4410
4529
|
var loopBreaksCmd = defineCommand15({
|
|
@@ -4413,11 +4532,11 @@ var loopBreaksCmd = defineCommand15({
|
|
|
4413
4532
|
agent: { type: "positional", required: true, description: "Agent id" },
|
|
4414
4533
|
limit: { type: "string", description: "Maximum events to show (default 25)" }
|
|
4415
4534
|
},
|
|
4416
|
-
async run({ args }) {
|
|
4535
|
+
async run({ args: args2 }) {
|
|
4417
4536
|
const client = createClient2();
|
|
4418
|
-
const limit =
|
|
4537
|
+
const limit = args2.limit ? `?limit=${encodeURIComponent(args2.limit)}` : "";
|
|
4419
4538
|
const { events } = await client.get(
|
|
4420
|
-
`/api/agents/${
|
|
4539
|
+
`/api/agents/${args2.agent}/loop-breaks${limit}`
|
|
4421
4540
|
);
|
|
4422
4541
|
if (events.length === 0) {
|
|
4423
4542
|
console.log("(no agent-message chains stopped)");
|
|
@@ -4482,7 +4601,7 @@ var loginCommand = defineCommand16({
|
|
|
4482
4601
|
skipVerify: { type: "boolean", description: "Don't verify /api/auth/whoami before saving" },
|
|
4483
4602
|
clear: { type: "boolean", description: "Remove the stored remote instead of setting one" }
|
|
4484
4603
|
},
|
|
4485
|
-
async run({ args }) {
|
|
4604
|
+
async run({ args: args2 }) {
|
|
4486
4605
|
const paths = resolveCliPaths();
|
|
4487
4606
|
if (!existsSync4(paths.authFile)) {
|
|
4488
4607
|
throw new Error(
|
|
@@ -4490,7 +4609,7 @@ var loginCommand = defineCommand16({
|
|
|
4490
4609
|
);
|
|
4491
4610
|
}
|
|
4492
4611
|
const auth = JSON.parse(readFileSync6(paths.authFile, "utf8"));
|
|
4493
|
-
if (
|
|
4612
|
+
if (args2.clear) {
|
|
4494
4613
|
if (!auth.remote) {
|
|
4495
4614
|
console.log("no remote stored \u2014 nothing to clear");
|
|
4496
4615
|
return;
|
|
@@ -4501,16 +4620,16 @@ var loginCommand = defineCommand16({
|
|
|
4501
4620
|
console.log("cleared stored remote; CLI will fall back to the local daemon");
|
|
4502
4621
|
return;
|
|
4503
4622
|
}
|
|
4504
|
-
if (!
|
|
4623
|
+
if (!args2.server || !args2.token) {
|
|
4505
4624
|
throw new Error(
|
|
4506
4625
|
"--server and --token are required (or pass --clear to remove the stored remote)"
|
|
4507
4626
|
);
|
|
4508
4627
|
}
|
|
4509
|
-
const server = normalizeServer(
|
|
4510
|
-
if (!
|
|
4511
|
-
await verifyToken(server,
|
|
4628
|
+
const server = normalizeServer(args2.server);
|
|
4629
|
+
if (!args2.skipVerify) {
|
|
4630
|
+
await verifyToken(server, args2.token);
|
|
4512
4631
|
}
|
|
4513
|
-
auth.remote = { server, token:
|
|
4632
|
+
auth.remote = { server, token: args2.token };
|
|
4514
4633
|
writeFileSync3(paths.authFile, `${JSON.stringify(auth, null, 2)}
|
|
4515
4634
|
`, { mode: 384 });
|
|
4516
4635
|
console.log(`saved remote: ${server}`);
|
|
@@ -4542,16 +4661,16 @@ var addCmd = defineCommand17({
|
|
|
4542
4661
|
token: { type: "string", description: "http/sse: bearer token (stored encrypted)" },
|
|
4543
4662
|
disabled: { type: "boolean", description: "Create disabled" }
|
|
4544
4663
|
},
|
|
4545
|
-
async run({ args }) {
|
|
4546
|
-
const transport =
|
|
4664
|
+
async run({ args: args2 }) {
|
|
4665
|
+
const transport = args2.transport ?? "stdio";
|
|
4547
4666
|
const body = {
|
|
4548
|
-
name:
|
|
4667
|
+
name: args2.name,
|
|
4549
4668
|
transport,
|
|
4550
|
-
command:
|
|
4551
|
-
args:
|
|
4552
|
-
url:
|
|
4553
|
-
authToken:
|
|
4554
|
-
enabled: !
|
|
4669
|
+
command: args2.command ?? null,
|
|
4670
|
+
args: args2.args ? args2.args.split(" ").filter(Boolean) : [],
|
|
4671
|
+
url: args2.url ?? null,
|
|
4672
|
+
authToken: args2.token ?? void 0,
|
|
4673
|
+
enabled: !args2.disabled
|
|
4555
4674
|
};
|
|
4556
4675
|
const client = createClient2();
|
|
4557
4676
|
const { server } = await client.post("/api/mcp-servers", body);
|
|
@@ -4573,46 +4692,46 @@ var listCmd4 = defineCommand17({
|
|
|
4573
4692
|
var showCmd3 = defineCommand17({
|
|
4574
4693
|
meta: { name: "show", description: "Show one MCP server" },
|
|
4575
4694
|
args: { id: { type: "positional", required: true } },
|
|
4576
|
-
async run({ args }) {
|
|
4695
|
+
async run({ args: args2 }) {
|
|
4577
4696
|
const client = createClient2();
|
|
4578
|
-
const { server } = await client.get(`/api/mcp-servers/${
|
|
4697
|
+
const { server } = await client.get(`/api/mcp-servers/${args2.id}`);
|
|
4579
4698
|
console.log(JSON.stringify(server, null, 2));
|
|
4580
4699
|
}
|
|
4581
4700
|
});
|
|
4582
4701
|
var rmCmd2 = defineCommand17({
|
|
4583
4702
|
meta: { name: "rm", description: "Delete an MCP server" },
|
|
4584
4703
|
args: { id: { type: "positional", required: true } },
|
|
4585
|
-
async run({ args }) {
|
|
4704
|
+
async run({ args: args2 }) {
|
|
4586
4705
|
const client = createClient2();
|
|
4587
|
-
await client.del(`/api/mcp-servers/${
|
|
4588
|
-
console.log(`removed MCP server ${
|
|
4706
|
+
await client.del(`/api/mcp-servers/${args2.id}`);
|
|
4707
|
+
console.log(`removed MCP server ${args2.id}`);
|
|
4589
4708
|
}
|
|
4590
4709
|
});
|
|
4591
4710
|
var enableCmd = defineCommand17({
|
|
4592
4711
|
meta: { name: "enable", description: "Enable an MCP server" },
|
|
4593
4712
|
args: { id: { type: "positional", required: true } },
|
|
4594
|
-
async run({ args }) {
|
|
4713
|
+
async run({ args: args2 }) {
|
|
4595
4714
|
const client = createClient2();
|
|
4596
|
-
await client.patch(`/api/mcp-servers/${
|
|
4597
|
-
console.log(`enabled MCP server ${
|
|
4715
|
+
await client.patch(`/api/mcp-servers/${args2.id}`, { enabled: true });
|
|
4716
|
+
console.log(`enabled MCP server ${args2.id}`);
|
|
4598
4717
|
}
|
|
4599
4718
|
});
|
|
4600
4719
|
var disableCmd = defineCommand17({
|
|
4601
4720
|
meta: { name: "disable", description: "Disable an MCP server" },
|
|
4602
4721
|
args: { id: { type: "positional", required: true } },
|
|
4603
|
-
async run({ args }) {
|
|
4722
|
+
async run({ args: args2 }) {
|
|
4604
4723
|
const client = createClient2();
|
|
4605
|
-
await client.patch(`/api/mcp-servers/${
|
|
4606
|
-
console.log(`disabled MCP server ${
|
|
4724
|
+
await client.patch(`/api/mcp-servers/${args2.id}`, { enabled: false });
|
|
4725
|
+
console.log(`disabled MCP server ${args2.id}`);
|
|
4607
4726
|
}
|
|
4608
4727
|
});
|
|
4609
4728
|
var testCmd = defineCommand17({
|
|
4610
4729
|
meta: { name: "test", description: "Connect to a server and list its tools" },
|
|
4611
4730
|
args: { id: { type: "positional", required: true } },
|
|
4612
|
-
async run({ args }) {
|
|
4731
|
+
async run({ args: args2 }) {
|
|
4613
4732
|
const client = createClient2();
|
|
4614
4733
|
const res = await client.post(
|
|
4615
|
-
`/api/mcp-servers/${
|
|
4734
|
+
`/api/mcp-servers/${args2.id}/test`
|
|
4616
4735
|
);
|
|
4617
4736
|
if (!res.ok) {
|
|
4618
4737
|
console.error(`connection failed: ${res.error}`);
|
|
@@ -4649,11 +4768,11 @@ var writeCmd = defineCommand18({
|
|
|
4649
4768
|
key: { type: "positional", required: true, description: "Memory key (path under memory/)" },
|
|
4650
4769
|
content: { type: "positional", required: true, description: "Content to write" }
|
|
4651
4770
|
},
|
|
4652
|
-
async run({ args }) {
|
|
4771
|
+
async run({ args: args2 }) {
|
|
4653
4772
|
const client = createClient2();
|
|
4654
4773
|
const entry3 = await client.put(
|
|
4655
|
-
`/api/teams/${
|
|
4656
|
-
{ content:
|
|
4774
|
+
`/api/teams/${args2.team}/memory/${encodeKey(args2.key)}`,
|
|
4775
|
+
{ content: args2.content }
|
|
4657
4776
|
);
|
|
4658
4777
|
console.log(`wrote ${entry3.key} (${entry3.content.length} bytes)`);
|
|
4659
4778
|
}
|
|
@@ -4664,10 +4783,10 @@ var readCmd2 = defineCommand18({
|
|
|
4664
4783
|
team: { type: "positional", required: true, description: "Team slug" },
|
|
4665
4784
|
key: { type: "positional", required: true }
|
|
4666
4785
|
},
|
|
4667
|
-
async run({ args }) {
|
|
4786
|
+
async run({ args: args2 }) {
|
|
4668
4787
|
const client = createClient2();
|
|
4669
4788
|
const entry3 = await client.get(
|
|
4670
|
-
`/api/teams/${
|
|
4789
|
+
`/api/teams/${args2.team}/memory/${encodeKey(args2.key)}`
|
|
4671
4790
|
);
|
|
4672
4791
|
console.log(entry3.content);
|
|
4673
4792
|
}
|
|
@@ -4679,11 +4798,11 @@ var searchCmd = defineCommand18({
|
|
|
4679
4798
|
query: { type: "positional", required: true },
|
|
4680
4799
|
limit: { type: "string", description: "Max results (default 10)" }
|
|
4681
4800
|
},
|
|
4682
|
-
async run({ args }) {
|
|
4801
|
+
async run({ args: args2 }) {
|
|
4683
4802
|
const client = createClient2();
|
|
4684
|
-
const limit =
|
|
4685
|
-
const params = new URLSearchParams({ q:
|
|
4686
|
-
const hits = await client.get(`/api/teams/${
|
|
4803
|
+
const limit = args2.limit ? Number.parseInt(args2.limit, 10) : 10;
|
|
4804
|
+
const params = new URLSearchParams({ q: args2.query, limit: String(limit) });
|
|
4805
|
+
const hits = await client.get(`/api/teams/${args2.team}/memory/search?${params}`);
|
|
4687
4806
|
if (hits.length === 0) {
|
|
4688
4807
|
console.log("(no matches)");
|
|
4689
4808
|
return;
|
|
@@ -4698,9 +4817,9 @@ var listCmd5 = defineCommand18({
|
|
|
4698
4817
|
args: {
|
|
4699
4818
|
team: { type: "positional", required: true, description: "Team slug" }
|
|
4700
4819
|
},
|
|
4701
|
-
async run({ args }) {
|
|
4820
|
+
async run({ args: args2 }) {
|
|
4702
4821
|
const client = createClient2();
|
|
4703
|
-
const all = await client.get(`/api/teams/${
|
|
4822
|
+
const all = await client.get(`/api/teams/${args2.team}/memory`);
|
|
4704
4823
|
if (all.length === 0) {
|
|
4705
4824
|
console.log("(no memory entries)");
|
|
4706
4825
|
return;
|
|
@@ -4716,10 +4835,10 @@ var rmCmd3 = defineCommand18({
|
|
|
4716
4835
|
team: { type: "positional", required: true, description: "Team slug" },
|
|
4717
4836
|
key: { type: "positional", required: true }
|
|
4718
4837
|
},
|
|
4719
|
-
async run({ args }) {
|
|
4838
|
+
async run({ args: args2 }) {
|
|
4720
4839
|
const client = createClient2();
|
|
4721
|
-
await client.del(`/api/teams/${
|
|
4722
|
-
console.log(`removed ${
|
|
4840
|
+
await client.del(`/api/teams/${args2.team}/memory/${encodeKey(args2.key)}`);
|
|
4841
|
+
console.log(`removed ${args2.key}`);
|
|
4723
4842
|
}
|
|
4724
4843
|
});
|
|
4725
4844
|
var memoryCommand = defineCommand18({
|
|
@@ -4743,6 +4862,14 @@ import { readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writ
|
|
|
4743
4862
|
import { tmpdir as tmpdir2 } from "os";
|
|
4744
4863
|
import { join as join4 } from "path";
|
|
4745
4864
|
|
|
4865
|
+
// ../../packages/api-types/src/git-review.ts
|
|
4866
|
+
var REVIEW_LIMITS = {
|
|
4867
|
+
files: 1e3,
|
|
4868
|
+
fileBytes: 1024 * 1024,
|
|
4869
|
+
totalBytes: 16 * 1024 * 1024,
|
|
4870
|
+
patchBytes: 256 * 1024
|
|
4871
|
+
};
|
|
4872
|
+
|
|
4746
4873
|
// ../../packages/api-types/src/index.ts
|
|
4747
4874
|
var PROFILE_FILES = [
|
|
4748
4875
|
"profile.json",
|
|
@@ -4808,20 +4935,20 @@ var createCmd2 = defineCommand19({
|
|
|
4808
4935
|
description: "Path to TOOLS.md content (optional; omit to skip)"
|
|
4809
4936
|
}
|
|
4810
4937
|
},
|
|
4811
|
-
async run({ args }) {
|
|
4812
|
-
const skillsMode = parseSkillsMode(
|
|
4938
|
+
async run({ args: args2 }) {
|
|
4939
|
+
const skillsMode = parseSkillsMode(args2["skills-mode"]);
|
|
4813
4940
|
const readTemplate = (path) => path ? readFileSync7(path, "utf8") : void 0;
|
|
4814
4941
|
const body = {
|
|
4815
|
-
id:
|
|
4816
|
-
name:
|
|
4817
|
-
defaultModel:
|
|
4942
|
+
id: args2.id,
|
|
4943
|
+
name: args2.name,
|
|
4944
|
+
defaultModel: args2.model,
|
|
4818
4945
|
skillsMode,
|
|
4819
|
-
defaultSkills: splitCsv(
|
|
4820
|
-
soul: readTemplate(
|
|
4821
|
-
identity: readTemplate(
|
|
4822
|
-
bootstrap:
|
|
4823
|
-
agents: readTemplate(
|
|
4824
|
-
tools: readTemplate(
|
|
4946
|
+
defaultSkills: splitCsv(args2.skills),
|
|
4947
|
+
soul: readTemplate(args2["soul-file"]),
|
|
4948
|
+
identity: readTemplate(args2["identity-file"]),
|
|
4949
|
+
bootstrap: args2["skip-bootstrap"] ? null : readTemplate(args2["bootstrap-file"]) ?? void 0,
|
|
4950
|
+
agents: readTemplate(args2["agents-file"]),
|
|
4951
|
+
tools: readTemplate(args2["tools-file"])
|
|
4825
4952
|
};
|
|
4826
4953
|
const client = createClient2();
|
|
4827
4954
|
const profile = await client.post("/api/profiles", body);
|
|
@@ -4846,9 +4973,9 @@ var showCmd4 = defineCommand19({
|
|
|
4846
4973
|
args: {
|
|
4847
4974
|
id: { type: "positional", required: true }
|
|
4848
4975
|
},
|
|
4849
|
-
async run({ args }) {
|
|
4976
|
+
async run({ args: args2 }) {
|
|
4850
4977
|
const client = createClient2();
|
|
4851
|
-
const loaded = await client.get(`/api/profiles/${
|
|
4978
|
+
const loaded = await client.get(`/api/profiles/${args2.id}`);
|
|
4852
4979
|
console.log(`# ${loaded.profile.id}`);
|
|
4853
4980
|
console.log(`name: ${loaded.profile.name}`);
|
|
4854
4981
|
console.log(`dir: ${loaded.profile.dir}`);
|
|
@@ -4876,23 +5003,23 @@ var editCmd2 = defineCommand19({
|
|
|
4876
5003
|
description: `File: ${PROFILE_FILES.join(", ")}`
|
|
4877
5004
|
}
|
|
4878
5005
|
},
|
|
4879
|
-
async run({ args }) {
|
|
4880
|
-
if (!PROFILE_FILES.includes(
|
|
4881
|
-
throw new Error(`unsupported file: ${
|
|
5006
|
+
async run({ args: args2 }) {
|
|
5007
|
+
if (!PROFILE_FILES.includes(args2.file)) {
|
|
5008
|
+
throw new Error(`unsupported file: ${args2.file}. Allowed: ${PROFILE_FILES.join(", ")}`);
|
|
4882
5009
|
}
|
|
4883
|
-
const file =
|
|
5010
|
+
const file = args2.file;
|
|
4884
5011
|
const client = createClient2();
|
|
4885
5012
|
const { content } = await client.get(
|
|
4886
|
-
`/api/profiles/${
|
|
5013
|
+
`/api/profiles/${args2.id}/files/${file}`
|
|
4887
5014
|
);
|
|
4888
|
-
const tmpPath = join4(tmpdir2(), `bazilion-${
|
|
5015
|
+
const tmpPath = join4(tmpdir2(), `bazilion-${args2.id}-${file}-${randomBytes2(4).toString("hex")}`);
|
|
4889
5016
|
writeFileSync4(tmpPath, content);
|
|
4890
5017
|
try {
|
|
4891
5018
|
const editor = process.env.EDITOR ?? process.env.VISUAL ?? "vi";
|
|
4892
|
-
const code = await new Promise((
|
|
5019
|
+
const code = await new Promise((resolve6, reject) => {
|
|
4893
5020
|
const child = spawn2(editor, [tmpPath], { stdio: "inherit" });
|
|
4894
5021
|
child.on("error", reject);
|
|
4895
|
-
child.on("close", (c) =>
|
|
5022
|
+
child.on("close", (c) => resolve6(c ?? 0));
|
|
4896
5023
|
});
|
|
4897
5024
|
if (code !== 0) throw new Error(`editor exited with code ${code}`);
|
|
4898
5025
|
const updated = readFileSync7(tmpPath, "utf8");
|
|
@@ -4901,7 +5028,7 @@ var editCmd2 = defineCommand19({
|
|
|
4901
5028
|
return;
|
|
4902
5029
|
}
|
|
4903
5030
|
const body = { content: updated };
|
|
4904
|
-
await client.put(`/api/profiles/${
|
|
5031
|
+
await client.put(`/api/profiles/${args2.id}/files/${file}`, body);
|
|
4905
5032
|
console.log(`saved ${file}`);
|
|
4906
5033
|
} finally {
|
|
4907
5034
|
try {
|
|
@@ -4926,14 +5053,14 @@ var updateCmd = defineCommand19({
|
|
|
4926
5053
|
},
|
|
4927
5054
|
skills: { type: "string", description: "Replacement default skills, comma-separated" }
|
|
4928
5055
|
},
|
|
4929
|
-
async run({ args }) {
|
|
5056
|
+
async run({ args: args2 }) {
|
|
4930
5057
|
const body = {};
|
|
4931
|
-
if (
|
|
4932
|
-
if (
|
|
4933
|
-
const mode = parseSkillsMode(
|
|
5058
|
+
if (args2.name !== void 0) body.name = args2.name;
|
|
5059
|
+
if (args2.model !== void 0) body.defaultModel = args2.model;
|
|
5060
|
+
const mode = parseSkillsMode(args2["skills-mode"]);
|
|
4934
5061
|
if (mode !== void 0) body.skillsMode = mode;
|
|
4935
|
-
if (
|
|
4936
|
-
body.defaultSkills =
|
|
5062
|
+
if (args2.skills !== void 0) {
|
|
5063
|
+
body.defaultSkills = args2.skills.split(",").map((s) => s.trim()).filter(Boolean);
|
|
4937
5064
|
}
|
|
4938
5065
|
if (Object.keys(body).length === 0) {
|
|
4939
5066
|
throw new Error(
|
|
@@ -4941,7 +5068,7 @@ var updateCmd = defineCommand19({
|
|
|
4941
5068
|
);
|
|
4942
5069
|
}
|
|
4943
5070
|
const client = createClient2();
|
|
4944
|
-
const profile = await client.patch(`/api/profiles/${
|
|
5071
|
+
const profile = await client.patch(`/api/profiles/${args2.id}`, body);
|
|
4945
5072
|
console.log(`updated profile ${profile.id}`);
|
|
4946
5073
|
}
|
|
4947
5074
|
});
|
|
@@ -4950,10 +5077,10 @@ var deleteCmd2 = defineCommand19({
|
|
|
4950
5077
|
args: {
|
|
4951
5078
|
id: { type: "positional", required: true }
|
|
4952
5079
|
},
|
|
4953
|
-
async run({ args }) {
|
|
5080
|
+
async run({ args: args2 }) {
|
|
4954
5081
|
const client = createClient2();
|
|
4955
|
-
await client.del(`/api/profiles/${
|
|
4956
|
-
console.log(`deleted profile ${
|
|
5082
|
+
await client.del(`/api/profiles/${args2.id}`);
|
|
5083
|
+
console.log(`deleted profile ${args2.id}`);
|
|
4957
5084
|
}
|
|
4958
5085
|
});
|
|
4959
5086
|
var profileCommand = defineCommand19({
|
|
@@ -4978,10 +5105,10 @@ var listCmd7 = defineCommand20({
|
|
|
4978
5105
|
args: {
|
|
4979
5106
|
enabled: { type: "boolean", description: "Show only enabled providers" }
|
|
4980
5107
|
},
|
|
4981
|
-
async run({ args }) {
|
|
5108
|
+
async run({ args: args2 }) {
|
|
4982
5109
|
const client = createClient2();
|
|
4983
5110
|
const { providers } = await client.get("/api/config/providers");
|
|
4984
|
-
const filtered =
|
|
5111
|
+
const filtered = args2.enabled ? providers.filter((p) => p.enabled) : providers;
|
|
4985
5112
|
if (filtered.length === 0) {
|
|
4986
5113
|
console.log("(no providers to show)");
|
|
4987
5114
|
return;
|
|
@@ -5004,12 +5131,12 @@ var modelsCmd = defineCommand20({
|
|
|
5004
5131
|
args: {
|
|
5005
5132
|
name: { type: "positional", required: true, description: "Provider name" }
|
|
5006
5133
|
},
|
|
5007
|
-
async run({ args }) {
|
|
5134
|
+
async run({ args: args2 }) {
|
|
5008
5135
|
const client = createClient2();
|
|
5009
5136
|
const { providers } = await client.get("/api/config/providers");
|
|
5010
|
-
const p = providers.find((x) => x.id ===
|
|
5137
|
+
const p = providers.find((x) => x.id === args2.name);
|
|
5011
5138
|
if (!p) {
|
|
5012
|
-
console.error(`unknown provider: ${
|
|
5139
|
+
console.error(`unknown provider: ${args2.name}`);
|
|
5013
5140
|
process.exit(1);
|
|
5014
5141
|
}
|
|
5015
5142
|
console.log(`# ${p.id} (${p.enabled ? "enabled" : "disabled"})`);
|
|
@@ -5041,15 +5168,15 @@ var modelsSetCmd = defineCommand20({
|
|
|
5041
5168
|
description: "Comma-separated model list (empty string clears the list)"
|
|
5042
5169
|
}
|
|
5043
5170
|
},
|
|
5044
|
-
async run({ args }) {
|
|
5171
|
+
async run({ args: args2 }) {
|
|
5045
5172
|
const client = createClient2();
|
|
5046
|
-
const models =
|
|
5173
|
+
const models = args2.models.split(",").map((s) => s.trim()).filter(Boolean);
|
|
5047
5174
|
const body = { models };
|
|
5048
5175
|
const saved = await client.put(
|
|
5049
|
-
`/api/config/providers/${encodeURIComponent(
|
|
5176
|
+
`/api/config/providers/${encodeURIComponent(args2.name)}/models`,
|
|
5050
5177
|
body
|
|
5051
5178
|
);
|
|
5052
|
-
console.log(`saved ${saved.models.length} curated model(s) for ${
|
|
5179
|
+
console.log(`saved ${saved.models.length} curated model(s) for ${args2.name}`);
|
|
5053
5180
|
for (const m of saved.models) console.log(` ${m}`);
|
|
5054
5181
|
}
|
|
5055
5182
|
});
|
|
@@ -5058,10 +5185,10 @@ var enableCmd2 = defineCommand20({
|
|
|
5058
5185
|
args: {
|
|
5059
5186
|
name: { type: "positional", required: true, description: "Provider id (e.g. anthropic)" }
|
|
5060
5187
|
},
|
|
5061
|
-
async run({ args }) {
|
|
5188
|
+
async run({ args: args2 }) {
|
|
5062
5189
|
const client = createClient2();
|
|
5063
5190
|
const res = await client.put(
|
|
5064
|
-
`/api/config/providers/${encodeURIComponent(
|
|
5191
|
+
`/api/config/providers/${encodeURIComponent(args2.name)}/enabled`,
|
|
5065
5192
|
{ enabled: true }
|
|
5066
5193
|
);
|
|
5067
5194
|
console.log(`${res.name}: enabled`);
|
|
@@ -5075,10 +5202,10 @@ var disableCmd2 = defineCommand20({
|
|
|
5075
5202
|
args: {
|
|
5076
5203
|
name: { type: "positional", required: true, description: "Provider id" }
|
|
5077
5204
|
},
|
|
5078
|
-
async run({ args }) {
|
|
5205
|
+
async run({ args: args2 }) {
|
|
5079
5206
|
const client = createClient2();
|
|
5080
5207
|
const res = await client.put(
|
|
5081
|
-
`/api/config/providers/${encodeURIComponent(
|
|
5208
|
+
`/api/config/providers/${encodeURIComponent(args2.name)}/enabled`,
|
|
5082
5209
|
{ enabled: false }
|
|
5083
5210
|
);
|
|
5084
5211
|
console.log(`${res.name}: disabled`);
|
|
@@ -5094,10 +5221,10 @@ var testCmd2 = defineCommand20({
|
|
|
5094
5221
|
},
|
|
5095
5222
|
message: { type: "string", description: 'Message text (default "say hi briefly")' }
|
|
5096
5223
|
},
|
|
5097
|
-
async run({ args }) {
|
|
5224
|
+
async run({ args: args2 }) {
|
|
5098
5225
|
const client = createClient2();
|
|
5099
|
-
const body = { model:
|
|
5100
|
-
console.log(`-> ${
|
|
5226
|
+
const body = { model: args2.model, message: args2.message };
|
|
5227
|
+
console.log(`-> ${args2.model}: ${args2.message ?? "say hi briefly"}`);
|
|
5101
5228
|
const res = await client.post("/api/providers/test", body);
|
|
5102
5229
|
console.log(`<- ${res.content}`);
|
|
5103
5230
|
if (res.usage) {
|
|
@@ -5130,12 +5257,12 @@ var list6 = defineCommand21({
|
|
|
5130
5257
|
offset: { type: "string", default: "0" },
|
|
5131
5258
|
json: { type: "boolean" }
|
|
5132
5259
|
},
|
|
5133
|
-
async run({ args }) {
|
|
5134
|
-
const query = new URLSearchParams({ limit:
|
|
5135
|
-
if (
|
|
5136
|
-
if (
|
|
5260
|
+
async run({ args: args2 }) {
|
|
5261
|
+
const query = new URLSearchParams({ limit: args2.limit, offset: args2.offset });
|
|
5262
|
+
if (args2.team) query.set("teamId", args2.team);
|
|
5263
|
+
if (args2.agent) query.set("agentId", args2.agent);
|
|
5137
5264
|
const body = await createClient2().get(`/api/results?${query}`);
|
|
5138
|
-
if (
|
|
5265
|
+
if (args2.json) return console.log(JSON.stringify(body, null, 2));
|
|
5139
5266
|
if (!body.results.length) return console.log("(no saved results)");
|
|
5140
5267
|
for (const line of columnize([
|
|
5141
5268
|
["id", "filename", "bytes", "team", "agent", "created"],
|
|
@@ -5155,9 +5282,9 @@ var list6 = defineCommand21({
|
|
|
5155
5282
|
var show4 = defineCommand21({
|
|
5156
5283
|
meta: { name: "show", description: "Inspect a saved result and its provenance" },
|
|
5157
5284
|
args: { id: idArg, json: { type: "boolean" } },
|
|
5158
|
-
async run({ args }) {
|
|
5285
|
+
async run({ args: args2 }) {
|
|
5159
5286
|
const { result } = await createClient2().get(
|
|
5160
|
-
`/api/results/${encodeURIComponent(
|
|
5287
|
+
`/api/results/${encodeURIComponent(args2.id)}`
|
|
5161
5288
|
);
|
|
5162
5289
|
console.log(JSON.stringify(result, null, 2));
|
|
5163
5290
|
}
|
|
@@ -5172,21 +5299,21 @@ var download = defineCommand21({
|
|
|
5172
5299
|
description: "Destination path; existing files are never overwritten"
|
|
5173
5300
|
}
|
|
5174
5301
|
},
|
|
5175
|
-
async run({ args }) {
|
|
5302
|
+
async run({ args: args2 }) {
|
|
5176
5303
|
const bytes = await createClient2().binary(
|
|
5177
|
-
`/api/results/${encodeURIComponent(
|
|
5304
|
+
`/api/results/${encodeURIComponent(args2.id)}/download`
|
|
5178
5305
|
);
|
|
5179
|
-
const fd = openSync3(
|
|
5306
|
+
const fd = openSync3(args2.output, "wx", 384);
|
|
5180
5307
|
try {
|
|
5181
5308
|
writeFileSync5(fd, bytes);
|
|
5182
5309
|
fsyncSync3(fd);
|
|
5183
5310
|
} catch (error) {
|
|
5184
5311
|
closeSync3(fd);
|
|
5185
|
-
unlinkSync(
|
|
5312
|
+
unlinkSync(args2.output);
|
|
5186
5313
|
throw error;
|
|
5187
5314
|
}
|
|
5188
5315
|
closeSync3(fd);
|
|
5189
|
-
console.log(`Saved ${bytes.byteLength} bytes to ${
|
|
5316
|
+
console.log(`Saved ${bytes.byteLength} bytes to ${args2.output}`);
|
|
5190
5317
|
}
|
|
5191
5318
|
});
|
|
5192
5319
|
var rm = defineCommand21({
|
|
@@ -5195,9 +5322,9 @@ var rm = defineCommand21({
|
|
|
5195
5322
|
description: "Delete saved bytes; retained history will report the result as deleted"
|
|
5196
5323
|
},
|
|
5197
5324
|
args: { id: idArg, yes: { type: "boolean" } },
|
|
5198
|
-
async run({ args }) {
|
|
5199
|
-
if (!
|
|
5200
|
-
await createClient2().del(`/api/results/${encodeURIComponent(
|
|
5325
|
+
async run({ args: args2 }) {
|
|
5326
|
+
if (!args2.yes) throw new Error("Pass --yes to permanently delete the saved file bytes");
|
|
5327
|
+
await createClient2().del(`/api/results/${encodeURIComponent(args2.id)}`);
|
|
5201
5328
|
console.log("Saved file deleted; historical references retain a deletion receipt.");
|
|
5202
5329
|
}
|
|
5203
5330
|
});
|
|
@@ -5218,14 +5345,14 @@ var sendCommand = defineCommand22({
|
|
|
5218
5345
|
to: { type: "positional", required: true, description: "Recipient agent id" },
|
|
5219
5346
|
message: { type: "positional", required: true, description: "Message text" }
|
|
5220
5347
|
},
|
|
5221
|
-
async run({ args }) {
|
|
5348
|
+
async run({ args: args2 }) {
|
|
5222
5349
|
const client = createClient2();
|
|
5223
5350
|
const body = {
|
|
5224
|
-
from:
|
|
5225
|
-
payload: { text:
|
|
5351
|
+
from: args2.from,
|
|
5352
|
+
payload: { text: args2.message }
|
|
5226
5353
|
};
|
|
5227
5354
|
const result = await client.post(
|
|
5228
|
-
`/api/agents/${
|
|
5355
|
+
`/api/agents/${args2.to}/messages`,
|
|
5229
5356
|
body
|
|
5230
5357
|
);
|
|
5231
5358
|
if ("approvalId" in result) {
|
|
@@ -5258,17 +5385,17 @@ var serveCommand = defineCommand23({
|
|
|
5258
5385
|
description: "Host (default 127.0.0.1). Put a TLS proxy in front before binding 0.0.0.0"
|
|
5259
5386
|
}
|
|
5260
5387
|
},
|
|
5261
|
-
async run({ args }) {
|
|
5388
|
+
async run({ args: args2 }) {
|
|
5262
5389
|
if (!existsSync5(daemonEntry2)) {
|
|
5263
5390
|
throw new Error(
|
|
5264
5391
|
`bazilion daemon not found at ${daemonEntry2}. Are you running from a development checkout?`
|
|
5265
5392
|
);
|
|
5266
5393
|
}
|
|
5267
5394
|
const env = { ...process.env };
|
|
5268
|
-
if (
|
|
5269
|
-
if (
|
|
5270
|
-
const host =
|
|
5271
|
-
const port =
|
|
5395
|
+
if (args2.port) env.PORT = args2.port;
|
|
5396
|
+
if (args2.host) env.HOST = args2.host;
|
|
5397
|
+
const host = args2.host ?? "127.0.0.1";
|
|
5398
|
+
const port = args2.port ?? "4321";
|
|
5272
5399
|
if (host !== "127.0.0.1" && host !== "localhost" && host !== "::1") {
|
|
5273
5400
|
console.error("");
|
|
5274
5401
|
console.error(`\u26A0 binding to ${host} \u2014 the daemon is now reachable beyond loopback.`);
|
|
@@ -5295,17 +5422,17 @@ var serveCommand = defineCommand23({
|
|
|
5295
5422
|
signalled = true;
|
|
5296
5423
|
});
|
|
5297
5424
|
process.on("SIGTERM", onSigterm);
|
|
5298
|
-
await new Promise((
|
|
5425
|
+
await new Promise((resolve6, reject) => {
|
|
5299
5426
|
proc.on("error", (err) => reject(err));
|
|
5300
5427
|
proc.on("close", (code) => {
|
|
5301
5428
|
if (signalled) {
|
|
5302
5429
|
process.exitCode = 0;
|
|
5303
|
-
|
|
5430
|
+
resolve6();
|
|
5304
5431
|
} else if (code === 0 || code === null) {
|
|
5305
|
-
|
|
5432
|
+
resolve6();
|
|
5306
5433
|
} else {
|
|
5307
5434
|
process.exitCode = code;
|
|
5308
|
-
|
|
5435
|
+
resolve6();
|
|
5309
5436
|
}
|
|
5310
5437
|
});
|
|
5311
5438
|
});
|
|
@@ -5339,9 +5466,9 @@ var listCmd8 = defineCommand24({
|
|
|
5339
5466
|
var revokeCmd = defineCommand24({
|
|
5340
5467
|
meta: { name: "revoke", description: "Revoke one browser session" },
|
|
5341
5468
|
args: { id: { type: "positional", required: true } },
|
|
5342
|
-
async run({ args }) {
|
|
5343
|
-
await createClient2().del(`/api/sessions/${encodeURIComponent(
|
|
5344
|
-
console.log(`revoked browser session ${
|
|
5469
|
+
async run({ args: args2 }) {
|
|
5470
|
+
await createClient2().del(`/api/sessions/${encodeURIComponent(args2.id)}`);
|
|
5471
|
+
console.log(`revoked browser session ${args2.id}`);
|
|
5345
5472
|
}
|
|
5346
5473
|
});
|
|
5347
5474
|
var sessionCommand = defineCommand24({
|
|
@@ -5351,7 +5478,7 @@ var sessionCommand = defineCommand24({
|
|
|
5351
5478
|
|
|
5352
5479
|
// src/commands/skill.ts
|
|
5353
5480
|
import { existsSync as existsSync6, readFileSync as readFileSync8, statSync as statSync2 } from "fs";
|
|
5354
|
-
import { basename as basename5, resolve as
|
|
5481
|
+
import { basename as basename5, resolve as resolve4 } from "path";
|
|
5355
5482
|
import { defineCommand as defineCommand25 } from "citty";
|
|
5356
5483
|
function printFindings(findings, prefix = " ") {
|
|
5357
5484
|
for (const f of findings) {
|
|
@@ -5364,10 +5491,10 @@ var listCmd9 = defineCommand25({
|
|
|
5364
5491
|
args: {
|
|
5365
5492
|
agent: { type: "string", description: "Filter to skills attached to this agent" }
|
|
5366
5493
|
},
|
|
5367
|
-
async run({ args }) {
|
|
5494
|
+
async run({ args: args2 }) {
|
|
5368
5495
|
const client = createClient2();
|
|
5369
|
-
if (
|
|
5370
|
-
const set = await client.get(`/api/agents/${
|
|
5496
|
+
if (args2.agent) {
|
|
5497
|
+
const set = await client.get(`/api/agents/${args2.agent}/skills`);
|
|
5371
5498
|
if (set.resolved.length === 0 && set.missing.length === 0) {
|
|
5372
5499
|
console.log("(no skills attached to this agent)");
|
|
5373
5500
|
return;
|
|
@@ -5413,10 +5540,10 @@ var importCmd = defineCommand25({
|
|
|
5413
5540
|
},
|
|
5414
5541
|
force: { type: "boolean", description: "Overwrite existing skills" }
|
|
5415
5542
|
},
|
|
5416
|
-
async run({ args }) {
|
|
5543
|
+
async run({ args: args2 }) {
|
|
5417
5544
|
const client = createClient2();
|
|
5418
|
-
const absFrom =
|
|
5419
|
-
const isLocalZip =
|
|
5545
|
+
const absFrom = resolve4(args2.from);
|
|
5546
|
+
const isLocalZip = args2.from.toLowerCase().endsWith(".zip") && existsSync6(absFrom) && statSync2(absFrom).isFile();
|
|
5420
5547
|
let result;
|
|
5421
5548
|
try {
|
|
5422
5549
|
if (isLocalZip) {
|
|
@@ -5424,12 +5551,12 @@ var importCmd = defineCommand25({
|
|
|
5424
5551
|
const file = new File([bytes], basename5(absFrom), { type: "application/zip" });
|
|
5425
5552
|
const fd = new FormData();
|
|
5426
5553
|
fd.set("file", file);
|
|
5427
|
-
if (
|
|
5554
|
+
if (args2.force) fd.set("force", "true");
|
|
5428
5555
|
result = await client.postMultipart("/api/skills/import", fd);
|
|
5429
5556
|
} else {
|
|
5430
5557
|
const body = {
|
|
5431
|
-
source:
|
|
5432
|
-
force:
|
|
5558
|
+
source: args2.from,
|
|
5559
|
+
force: args2.force
|
|
5433
5560
|
};
|
|
5434
5561
|
result = await client.post("/api/skills/import", body);
|
|
5435
5562
|
}
|
|
@@ -5474,10 +5601,10 @@ var rmCmd4 = defineCommand25({
|
|
|
5474
5601
|
args: {
|
|
5475
5602
|
name: { type: "positional", required: true }
|
|
5476
5603
|
},
|
|
5477
|
-
async run({ args }) {
|
|
5604
|
+
async run({ args: args2 }) {
|
|
5478
5605
|
const client = createClient2();
|
|
5479
|
-
await client.del(`/api/skills/${encodeURIComponent(
|
|
5480
|
-
console.log(`removed skill ${
|
|
5606
|
+
await client.del(`/api/skills/${encodeURIComponent(args2.name)}`);
|
|
5607
|
+
console.log(`removed skill ${args2.name}`);
|
|
5481
5608
|
}
|
|
5482
5609
|
});
|
|
5483
5610
|
var skillCommand = defineCommand25({
|
|
@@ -5490,13 +5617,107 @@ var skillCommand = defineCommand25({
|
|
|
5490
5617
|
});
|
|
5491
5618
|
|
|
5492
5619
|
// src/commands/team.ts
|
|
5493
|
-
import { readFileSync as
|
|
5620
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
5494
5621
|
import { stdin as stdin2 } from "process";
|
|
5622
|
+
import { defineCommand as defineCommand30 } from "citty";
|
|
5623
|
+
|
|
5624
|
+
// src/commands/team-coding-log.ts
|
|
5625
|
+
import { defineCommand as defineCommand26 } from "citty";
|
|
5626
|
+
var teamCodingLogCommand = defineCommand26({
|
|
5627
|
+
meta: {
|
|
5628
|
+
name: "log",
|
|
5629
|
+
description: "Read retained diagnostics for a shared coding command receipt"
|
|
5630
|
+
},
|
|
5631
|
+
args: {
|
|
5632
|
+
team: { type: "positional", required: true, description: "Team slug" },
|
|
5633
|
+
commandId: { type: "positional", required: true, description: "Coding command id" },
|
|
5634
|
+
offset: { type: "string", description: "UTF-8 byte offset into the retained tail" },
|
|
5635
|
+
limit: { type: "string", description: "Maximum bytes to read (default 64 KiB)" },
|
|
5636
|
+
search: { type: "string", description: "Literal search instead of a page read" }
|
|
5637
|
+
},
|
|
5638
|
+
async run({ args: args2 }) {
|
|
5639
|
+
const client = createClient2().codingLogs(args2.team);
|
|
5640
|
+
if (args2.search !== void 0) {
|
|
5641
|
+
const { view: view2, result } = await client.search(args2.commandId, args2.search);
|
|
5642
|
+
if (!result) {
|
|
5643
|
+
console.log(`Coding log withheld (${view2.availability}); not shared for disclosure.`);
|
|
5644
|
+
return;
|
|
5645
|
+
}
|
|
5646
|
+
console.log(
|
|
5647
|
+
`${view2.availability}${result.bounded ? " \xB7 bounded scan" : ""} \xB7 ${result.matches.length} match(es)`
|
|
5648
|
+
);
|
|
5649
|
+
for (const match of result.matches) {
|
|
5650
|
+
console.log(`${match.line}:${match.offset} ${match.excerpt.replace(/\n/g, "\\n")}`);
|
|
5651
|
+
}
|
|
5652
|
+
return;
|
|
5653
|
+
}
|
|
5654
|
+
const offset = args2.offset === void 0 ? void 0 : Number(args2.offset);
|
|
5655
|
+
const limit = args2.limit === void 0 ? void 0 : Number(args2.limit);
|
|
5656
|
+
if (offset !== void 0 && (!Number.isSafeInteger(offset) || offset < 0) || limit !== void 0 && !Number.isSafeInteger(limit)) {
|
|
5657
|
+
console.error("offset and limit must be non-negative integers");
|
|
5658
|
+
process.exitCode = 1;
|
|
5659
|
+
return;
|
|
5660
|
+
}
|
|
5661
|
+
const { view, page } = await client.page(args2.commandId, {
|
|
5662
|
+
...offset !== void 0 ? { offset } : {},
|
|
5663
|
+
...limit !== void 0 ? { limit } : {}
|
|
5664
|
+
});
|
|
5665
|
+
if (!page) {
|
|
5666
|
+
console.log(`Coding log withheld (${view.availability}); not shared for disclosure.`);
|
|
5667
|
+
return;
|
|
5668
|
+
}
|
|
5669
|
+
console.log(
|
|
5670
|
+
`${view.availability} \xB7 ${view.byteLength} retained byte(s) of ${view.observedBytes} observed` + (view.redacted ? " \xB7 redacted" : "") + ` \xB7 expires ${new Date(view.expiresAt).toISOString()}`
|
|
5671
|
+
);
|
|
5672
|
+
process.stdout.write(page.text);
|
|
5673
|
+
if (page.hasMore)
|
|
5674
|
+
console.log(
|
|
5675
|
+
`
|
|
5676
|
+
\u2026 truncated; continue with --offset ${page.offset + Buffer.byteLength(page.text)}`
|
|
5677
|
+
);
|
|
5678
|
+
}
|
|
5679
|
+
});
|
|
5680
|
+
|
|
5681
|
+
// src/commands/team-environment.ts
|
|
5682
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
5495
5683
|
import { defineCommand as defineCommand27 } from "citty";
|
|
5684
|
+
var args = { id: { type: "positional", required: true, description: "Team slug" } };
|
|
5685
|
+
var teamEnvironmentCommand = defineCommand27({
|
|
5686
|
+
meta: {
|
|
5687
|
+
name: "environment",
|
|
5688
|
+
description: "Optional Team runtime defaults; Agents discover and run commands during tasks"
|
|
5689
|
+
},
|
|
5690
|
+
subCommands: {
|
|
5691
|
+
show: defineCommand27({
|
|
5692
|
+
args,
|
|
5693
|
+
async run({ args: args2 }) {
|
|
5694
|
+
console.log(JSON.stringify(await createClient2().codingEnvironment.show(args2.id), null, 2));
|
|
5695
|
+
}
|
|
5696
|
+
}),
|
|
5697
|
+
configure: defineCommand27({
|
|
5698
|
+
args: {
|
|
5699
|
+
...args,
|
|
5700
|
+
file: {
|
|
5701
|
+
type: "string",
|
|
5702
|
+
required: true,
|
|
5703
|
+
description: "JSON {expectedRevision,config:{image,cwd,env}}"
|
|
5704
|
+
}
|
|
5705
|
+
},
|
|
5706
|
+
async run({ args: args2 }) {
|
|
5707
|
+
const input = JSON.parse(
|
|
5708
|
+
readFileSync9(args2.file, "utf8")
|
|
5709
|
+
);
|
|
5710
|
+
console.log(
|
|
5711
|
+
JSON.stringify(await createClient2().codingEnvironment.configure(args2.id, input), null, 2)
|
|
5712
|
+
);
|
|
5713
|
+
}
|
|
5714
|
+
})
|
|
5715
|
+
}
|
|
5716
|
+
});
|
|
5496
5717
|
|
|
5497
5718
|
// src/commands/team-policy.ts
|
|
5498
|
-
import { readFileSync as
|
|
5499
|
-
import { defineCommand as
|
|
5719
|
+
import { readFileSync as readFileSync10 } from "fs";
|
|
5720
|
+
import { defineCommand as defineCommand28 } from "citty";
|
|
5500
5721
|
|
|
5501
5722
|
// src/team-interchange.ts
|
|
5502
5723
|
var TEAM_POLICY_INTERCHANGE_VERSION = 1;
|
|
@@ -5712,7 +5933,7 @@ function edgeDiff(before, after) {
|
|
|
5712
5933
|
// src/commands/team-policy.ts
|
|
5713
5934
|
function readJson(path) {
|
|
5714
5935
|
try {
|
|
5715
|
-
return JSON.parse(
|
|
5936
|
+
return JSON.parse(readFileSync10(path, "utf8"));
|
|
5716
5937
|
} catch (error) {
|
|
5717
5938
|
throw new Error(`invalid JSON: ${error.message}`);
|
|
5718
5939
|
}
|
|
@@ -5744,30 +5965,30 @@ function printPolicy(detail) {
|
|
|
5744
5965
|
console.log(line);
|
|
5745
5966
|
}
|
|
5746
5967
|
}
|
|
5747
|
-
var show5 =
|
|
5968
|
+
var show5 = defineCommand28({
|
|
5748
5969
|
meta: { name: "show", description: "Show the one effective live policy for a Team" },
|
|
5749
5970
|
args: {
|
|
5750
5971
|
team: { type: "positional", required: true },
|
|
5751
5972
|
json: { type: "boolean", description: "Emit the canonical aggregate as JSON" }
|
|
5752
5973
|
},
|
|
5753
|
-
async run({ args }) {
|
|
5974
|
+
async run({ args: args2 }) {
|
|
5754
5975
|
const detail = await createClient2().get(
|
|
5755
|
-
`/api/teams/${encodeURIComponent(
|
|
5976
|
+
`/api/teams/${encodeURIComponent(args2.team)}/policy`
|
|
5756
5977
|
);
|
|
5757
|
-
if (
|
|
5978
|
+
if (args2.json) console.log(JSON.stringify(detail, null, 2));
|
|
5758
5979
|
else printPolicy(detail);
|
|
5759
5980
|
}
|
|
5760
5981
|
});
|
|
5761
|
-
var exportCommand =
|
|
5982
|
+
var exportCommand = defineCommand28({
|
|
5762
5983
|
meta: { name: "export", description: "Export a revisioned Team policy document" },
|
|
5763
5984
|
args: { team: { type: "positional", required: true } },
|
|
5764
|
-
async run({ args }) {
|
|
5985
|
+
async run({ args: args2 }) {
|
|
5765
5986
|
const detail = await createClient2().get(
|
|
5766
|
-
`/api/teams/${encodeURIComponent(
|
|
5987
|
+
`/api/teams/${encodeURIComponent(args2.team)}/policy`
|
|
5767
5988
|
);
|
|
5768
5989
|
console.log(
|
|
5769
5990
|
JSON.stringify(
|
|
5770
|
-
exportTeamPolicy(
|
|
5991
|
+
exportTeamPolicy(args2.team, detail.teamPolicy.revision, detail.edges),
|
|
5771
5992
|
null,
|
|
5772
5993
|
2
|
|
5773
5994
|
)
|
|
@@ -5782,7 +6003,7 @@ function printEdgeDiff(current, edges) {
|
|
|
5782
6003
|
for (const value of diff2.added) console.log(` + ${value}`);
|
|
5783
6004
|
for (const value of diff2.removed) console.log(` - ${value}`);
|
|
5784
6005
|
}
|
|
5785
|
-
var importCommand =
|
|
6006
|
+
var importCommand = defineCommand28({
|
|
5786
6007
|
meta: {
|
|
5787
6008
|
name: "import",
|
|
5788
6009
|
description: "Validate, diff, and explicitly replace a Team policy"
|
|
@@ -5805,22 +6026,22 @@ var importCommand = defineCommand26({
|
|
|
5805
6026
|
description: "Second force confirmation: the freshly displayed current revision"
|
|
5806
6027
|
}
|
|
5807
6028
|
},
|
|
5808
|
-
async run({ args }) {
|
|
5809
|
-
if (
|
|
6029
|
+
async run({ args: args2 }) {
|
|
6030
|
+
if (args2.force && !args2.apply)
|
|
5810
6031
|
throw new Error("--force requires --apply (interactive force is intentionally unsupported)");
|
|
5811
|
-
const document = parseTeamPolicyDocument(readJson(
|
|
5812
|
-
if (document.teamId !==
|
|
5813
|
-
throw new Error(`document belongs to Team ${document.teamId}, not ${
|
|
6032
|
+
const document = parseTeamPolicyDocument(readJson(args2.file));
|
|
6033
|
+
if (document.teamId !== args2.team)
|
|
6034
|
+
throw new Error(`document belongs to Team ${document.teamId}, not ${args2.team}`);
|
|
5814
6035
|
const client = createClient2();
|
|
5815
6036
|
const current = await client.get(
|
|
5816
|
-
`/api/teams/${encodeURIComponent(
|
|
6037
|
+
`/api/teams/${encodeURIComponent(args2.team)}/policy`
|
|
5817
6038
|
);
|
|
5818
6039
|
printEdgeDiff(current, document.edges);
|
|
5819
|
-
if (
|
|
5820
|
-
if (!
|
|
5821
|
-
const supplied =
|
|
5822
|
-
const expectedRevision =
|
|
5823
|
-
if (
|
|
6040
|
+
if (args2["dry-run"]) return console.log("valid: no changes applied");
|
|
6041
|
+
if (!args2.apply) throw new Error("refusing mutation: review the diff, then pass --apply");
|
|
6042
|
+
const supplied = args2["expected-revision"] ? Number.parseInt(args2["expected-revision"], 10) : document.expectedRevision;
|
|
6043
|
+
const expectedRevision = args2.force ? current.teamPolicy.revision : supplied;
|
|
6044
|
+
if (args2.force && Number.parseInt(args2["confirm-current-revision"] ?? "", 10) !== current.teamPolicy.revision)
|
|
5824
6045
|
throw new Error(
|
|
5825
6046
|
`--force requires --confirm-current-revision ${current.teamPolicy.revision} after reviewing the fresh diff`
|
|
5826
6047
|
);
|
|
@@ -5831,24 +6052,24 @@ var importCommand = defineCommand26({
|
|
|
5831
6052
|
edges: document.edges
|
|
5832
6053
|
};
|
|
5833
6054
|
const updated = await client.put(
|
|
5834
|
-
`/api/teams/${encodeURIComponent(
|
|
6055
|
+
`/api/teams/${encodeURIComponent(args2.team)}/policy`,
|
|
5835
6056
|
body
|
|
5836
6057
|
);
|
|
5837
|
-
console.log(`updated Team ${
|
|
6058
|
+
console.log(`updated Team ${args2.team} policy to revision ${updated.teamPolicy.revision}`);
|
|
5838
6059
|
}
|
|
5839
6060
|
});
|
|
5840
|
-
var diff =
|
|
6061
|
+
var diff = defineCommand28({
|
|
5841
6062
|
meta: { name: "diff", description: "Compare live policy with its retained baseline source" },
|
|
5842
6063
|
args: {
|
|
5843
6064
|
team: { type: "positional", required: true },
|
|
5844
6065
|
json: { type: "boolean", description: "Emit canonical diff JSON" }
|
|
5845
6066
|
},
|
|
5846
|
-
async run({ args }) {
|
|
6067
|
+
async run({ args: args2 }) {
|
|
5847
6068
|
const result = await createClient2().get(
|
|
5848
|
-
`/api/teams/${encodeURIComponent(
|
|
6069
|
+
`/api/teams/${encodeURIComponent(args2.team)}/policy/diff`
|
|
5849
6070
|
);
|
|
5850
|
-
if (
|
|
5851
|
-
console.log(`# Team ${
|
|
6071
|
+
if (args2.json) return console.log(JSON.stringify(result, null, 2));
|
|
6072
|
+
console.log(`# Team ${args2.team} source diff`);
|
|
5852
6073
|
console.log(
|
|
5853
6074
|
`status: ${result.baseline ? result.sourceDiverged ? "source diverged" : "source current" : "no baseline"}`
|
|
5854
6075
|
);
|
|
@@ -5861,7 +6082,7 @@ var diff = defineCommand26({
|
|
|
5861
6082
|
);
|
|
5862
6083
|
}
|
|
5863
6084
|
});
|
|
5864
|
-
var evaluate =
|
|
6085
|
+
var evaluate = defineCommand28({
|
|
5865
6086
|
meta: {
|
|
5866
6087
|
name: "evaluate",
|
|
5867
6088
|
description: "Evaluate a communication path without sending or recording a block"
|
|
@@ -5873,18 +6094,18 @@ var evaluate = defineCommand26({
|
|
|
5873
6094
|
origin: { type: "string", default: "cli-diagnostic" },
|
|
5874
6095
|
json: { type: "boolean", description: "Emit decision JSON" }
|
|
5875
6096
|
},
|
|
5876
|
-
async run({ args }) {
|
|
6097
|
+
async run({ args: args2 }) {
|
|
5877
6098
|
const result = await createClient2().post(
|
|
5878
6099
|
"/api/communication/evaluate",
|
|
5879
6100
|
{
|
|
5880
|
-
source: endpoint2(
|
|
5881
|
-
target: endpoint2(
|
|
5882
|
-
origin:
|
|
6101
|
+
source: endpoint2(args2.source, args2.team),
|
|
6102
|
+
target: endpoint2(args2.target, args2.team),
|
|
6103
|
+
origin: args2.origin,
|
|
5883
6104
|
attemptKind: "cli_evaluate",
|
|
5884
|
-
attemptId: `diagnostic:${
|
|
6105
|
+
attemptId: `diagnostic:${args2.team}`
|
|
5885
6106
|
}
|
|
5886
6107
|
);
|
|
5887
|
-
if (
|
|
6108
|
+
if (args2.json) return console.log(JSON.stringify(result, null, 2));
|
|
5888
6109
|
console.log(`${result.decision.toUpperCase()} ${result.channel}: ${result.reasonCode}`);
|
|
5889
6110
|
console.log(result.reason);
|
|
5890
6111
|
console.log(
|
|
@@ -5892,7 +6113,7 @@ var evaluate = defineCommand26({
|
|
|
5892
6113
|
);
|
|
5893
6114
|
}
|
|
5894
6115
|
});
|
|
5895
|
-
var blocks =
|
|
6116
|
+
var blocks = defineCommand28({
|
|
5896
6117
|
meta: { name: "blocks", description: "List paginated durable communication denials" },
|
|
5897
6118
|
args: {
|
|
5898
6119
|
team: { type: "positional", required: true },
|
|
@@ -5907,23 +6128,23 @@ var blocks = defineCommand26({
|
|
|
5907
6128
|
to: { type: "string", description: "Epoch milliseconds or ISO timestamp" },
|
|
5908
6129
|
json: { type: "boolean", description: "Emit page JSON including nextCursor" }
|
|
5909
6130
|
},
|
|
5910
|
-
async run({ args }) {
|
|
5911
|
-
const query = new URLSearchParams({ limit:
|
|
6131
|
+
async run({ args: args2 }) {
|
|
6132
|
+
const query = new URLSearchParams({ limit: args2.limit });
|
|
5912
6133
|
for (const [key, value] of [
|
|
5913
|
-
["cursor",
|
|
5914
|
-
["source",
|
|
5915
|
-
["target",
|
|
5916
|
-
["channel",
|
|
5917
|
-
["origin",
|
|
5918
|
-
["reasonCode",
|
|
5919
|
-
["from",
|
|
5920
|
-
["to",
|
|
6134
|
+
["cursor", args2.cursor],
|
|
6135
|
+
["source", args2.source],
|
|
6136
|
+
["target", args2.target],
|
|
6137
|
+
["channel", args2.channel],
|
|
6138
|
+
["origin", args2.origin],
|
|
6139
|
+
["reasonCode", args2.reason],
|
|
6140
|
+
["from", args2.from],
|
|
6141
|
+
["to", args2.to]
|
|
5921
6142
|
])
|
|
5922
6143
|
if (value) query.set(key, value);
|
|
5923
6144
|
const page = await createClient2().get(
|
|
5924
|
-
`/api/teams/${encodeURIComponent(
|
|
6145
|
+
`/api/teams/${encodeURIComponent(args2.team)}/policy/blocks?${query}`
|
|
5925
6146
|
);
|
|
5926
|
-
if (
|
|
6147
|
+
if (args2.json) return console.log(JSON.stringify(page, null, 2));
|
|
5927
6148
|
if (!page.blocks.length) console.log("(no blocks)");
|
|
5928
6149
|
else
|
|
5929
6150
|
for (const line of columnize([
|
|
@@ -5941,7 +6162,7 @@ var blocks = defineCommand26({
|
|
|
5941
6162
|
if (page.nextCursor) console.log(`next cursor: ${page.nextCursor}`);
|
|
5942
6163
|
}
|
|
5943
6164
|
});
|
|
5944
|
-
var teamPolicyCommand =
|
|
6165
|
+
var teamPolicyCommand = defineCommand28({
|
|
5945
6166
|
meta: { name: "policy", description: "Inspect and manage the Team-owned live policy" },
|
|
5946
6167
|
subCommands: {
|
|
5947
6168
|
show: show5,
|
|
@@ -5953,8 +6174,187 @@ var teamPolicyCommand = defineCommand26({
|
|
|
5953
6174
|
}
|
|
5954
6175
|
});
|
|
5955
6176
|
|
|
6177
|
+
// src/commands/team-review.ts
|
|
6178
|
+
import { defineCommand as defineCommand29 } from "citty";
|
|
6179
|
+
var slug = {
|
|
6180
|
+
id: { type: "positional", required: true, description: "Team slug" }
|
|
6181
|
+
};
|
|
6182
|
+
function printIssues(changes) {
|
|
6183
|
+
for (const issue of changes.issues) console.log(`note: ${issue.code}: ${issue.message}`);
|
|
6184
|
+
}
|
|
6185
|
+
var showCmd5 = defineCommand29({
|
|
6186
|
+
meta: {
|
|
6187
|
+
name: "show",
|
|
6188
|
+
description: "List changes since a baseline (read-only)"
|
|
6189
|
+
},
|
|
6190
|
+
args: {
|
|
6191
|
+
...slug,
|
|
6192
|
+
base: {
|
|
6193
|
+
type: "string",
|
|
6194
|
+
description: "Comparison base: branch, tag or commit id (default HEAD)"
|
|
6195
|
+
},
|
|
6196
|
+
patch: {
|
|
6197
|
+
type: "string",
|
|
6198
|
+
description: "Print the unified diff for one changed path instead of the list"
|
|
6199
|
+
},
|
|
6200
|
+
json: { type: "boolean", description: "Emit the complete review as JSON" }
|
|
6201
|
+
},
|
|
6202
|
+
async run({ args: args2 }) {
|
|
6203
|
+
const client = createClient2();
|
|
6204
|
+
const review = await client.repositoryReview(args2.id).changes({
|
|
6205
|
+
...args2.base ? { base: args2.base } : {},
|
|
6206
|
+
patches: true
|
|
6207
|
+
});
|
|
6208
|
+
if (args2.json) {
|
|
6209
|
+
console.log(JSON.stringify(review, null, 2));
|
|
6210
|
+
return;
|
|
6211
|
+
}
|
|
6212
|
+
const changes = review.changes;
|
|
6213
|
+
if (args2.patch) {
|
|
6214
|
+
const entry3 = changes.changes.find((change) => change.path === args2.patch);
|
|
6215
|
+
if (!entry3) {
|
|
6216
|
+
console.error(`no change for path: ${args2.patch}`);
|
|
6217
|
+
process.exit(1);
|
|
6218
|
+
}
|
|
6219
|
+
if (!entry3.patch) {
|
|
6220
|
+
console.log(
|
|
6221
|
+
`${entry3.path}: ${entry3.status}${entry3.contentOmitted ? ` (${entry3.contentOmitted})` : " (no content)"}`
|
|
6222
|
+
);
|
|
6223
|
+
return;
|
|
6224
|
+
}
|
|
6225
|
+
console.log(entry3.patch);
|
|
6226
|
+
if (entry3.patchTruncated) console.log("(diff truncated at the configured patch cap)");
|
|
6227
|
+
return;
|
|
6228
|
+
}
|
|
6229
|
+
console.log(
|
|
6230
|
+
`# ${changes.identity.branch ?? `detached ${changes.identity.head ?? "unborn"}`} \xB7 base ${changes.base.requestedRef} (${changes.base.resolvedOid.slice(0, 12)})`
|
|
6231
|
+
);
|
|
6232
|
+
if (changes.changes.length === 0) console.log("(no changes since baseline)");
|
|
6233
|
+
const rows = changes.changes.map((change) => [
|
|
6234
|
+
change.status,
|
|
6235
|
+
change.previousPath ? `${change.previousPath} -> ${change.path}` : change.path,
|
|
6236
|
+
change.binary ? "binary" : `${change.addedLines ?? 0}+ ${change.deletedLines ?? 0}-`,
|
|
6237
|
+
change.contentOmitted ?? ""
|
|
6238
|
+
]);
|
|
6239
|
+
for (const line of columnize(rows)) console.log(line);
|
|
6240
|
+
if (changes.truncated) console.log("note: the change list is incomplete (file limit)");
|
|
6241
|
+
const withheld = changes.withheld;
|
|
6242
|
+
if (withheld.excluded + withheld.untracked > 0) {
|
|
6243
|
+
console.log(
|
|
6244
|
+
`note: ${withheld.excluded} excluded and ${withheld.untracked} untracked path(s) withheld`
|
|
6245
|
+
);
|
|
6246
|
+
}
|
|
6247
|
+
printIssues(changes);
|
|
6248
|
+
}
|
|
6249
|
+
});
|
|
6250
|
+
var captureCmd = defineCommand29({
|
|
6251
|
+
meta: {
|
|
6252
|
+
name: "capture",
|
|
6253
|
+
description: "Capture a bounded source snapshot for a Team (read-only)"
|
|
6254
|
+
},
|
|
6255
|
+
args: {
|
|
6256
|
+
...slug,
|
|
6257
|
+
base: { type: "string", description: "Comparison base (default HEAD)" },
|
|
6258
|
+
include: {
|
|
6259
|
+
type: "string",
|
|
6260
|
+
// Read from raw arguments: citty keeps only the last value of a repeated flag.
|
|
6261
|
+
description: "Untracked path to include by content (repeat the flag for more)"
|
|
6262
|
+
},
|
|
6263
|
+
json: { type: "boolean", description: "Emit the complete snapshot as JSON" }
|
|
6264
|
+
},
|
|
6265
|
+
async run({ args: args2, rawArgs }) {
|
|
6266
|
+
const client = createClient2();
|
|
6267
|
+
const includeUntracked = collectFlagValues(rawArgs, "include");
|
|
6268
|
+
if (includeUntracked.length > 1e3) {
|
|
6269
|
+
console.error("team review capture: too many paths to include");
|
|
6270
|
+
process.exit(1);
|
|
6271
|
+
}
|
|
6272
|
+
const captured = await client.repositoryReview(args2.id).capture({
|
|
6273
|
+
...args2.base ? { base: args2.base } : {},
|
|
6274
|
+
...includeUntracked.length > 0 ? { includeUntracked } : {}
|
|
6275
|
+
});
|
|
6276
|
+
if (args2.json) {
|
|
6277
|
+
console.log(JSON.stringify(captured, null, 2));
|
|
6278
|
+
return;
|
|
6279
|
+
}
|
|
6280
|
+
const { snapshot, reference } = captured;
|
|
6281
|
+
console.log(`snapshot ${reference.id}`);
|
|
6282
|
+
console.log(` complete: ${reference.complete ? "yes" : "no (applicability is unknown)"}`);
|
|
6283
|
+
console.log(` head: ${snapshot.head ?? "(unborn)"}`);
|
|
6284
|
+
console.log(
|
|
6285
|
+
` entries: ${snapshot.entries.length} \xB7 included untracked: ${snapshot.untrackedIncluded.length}`
|
|
6286
|
+
);
|
|
6287
|
+
if (snapshot.exclusions.length > 0) {
|
|
6288
|
+
console.log(` excluded: ${snapshot.exclusions.map((item) => item.path).join(", ")}`);
|
|
6289
|
+
}
|
|
6290
|
+
for (const issue of snapshot.issues) console.log(` note: ${issue.code}: ${issue.message}`);
|
|
6291
|
+
}
|
|
6292
|
+
});
|
|
6293
|
+
var snapshotsCmd = defineCommand29({
|
|
6294
|
+
meta: { name: "snapshots", description: "List retained source snapshots for a Team" },
|
|
6295
|
+
args: { ...slug, json: { type: "boolean", description: "Emit JSON" } },
|
|
6296
|
+
async run({ args: args2 }) {
|
|
6297
|
+
const client = createClient2();
|
|
6298
|
+
const list8 = await client.repositoryReview(args2.id).snapshots();
|
|
6299
|
+
if (args2.json) {
|
|
6300
|
+
console.log(JSON.stringify(list8, null, 2));
|
|
6301
|
+
return;
|
|
6302
|
+
}
|
|
6303
|
+
if (list8.snapshots.length === 0) {
|
|
6304
|
+
console.log("(no retained snapshots)");
|
|
6305
|
+
return;
|
|
6306
|
+
}
|
|
6307
|
+
const rows = list8.snapshots.map((snapshot) => [
|
|
6308
|
+
snapshot.snapshotId.slice(0, 12),
|
|
6309
|
+
snapshot.complete ? "complete" : "incomplete",
|
|
6310
|
+
snapshot.capturedBy,
|
|
6311
|
+
new Date(snapshot.createdAt).toISOString(),
|
|
6312
|
+
`${snapshot.entryCount} entries`
|
|
6313
|
+
]);
|
|
6314
|
+
for (const line of columnize(rows)) console.log(line);
|
|
6315
|
+
}
|
|
6316
|
+
});
|
|
6317
|
+
var snapshotCmd = defineCommand29({
|
|
6318
|
+
meta: { name: "snapshot", description: "Show one retained source snapshot" },
|
|
6319
|
+
args: {
|
|
6320
|
+
...slug,
|
|
6321
|
+
snapshot: { type: "positional", required: true, description: "Snapshot id" },
|
|
6322
|
+
json: { type: "boolean", description: "Emit JSON" }
|
|
6323
|
+
},
|
|
6324
|
+
async run({ args: args2 }) {
|
|
6325
|
+
const client = createClient2();
|
|
6326
|
+
const { snapshot } = await client.repositoryReview(args2.id).snapshot(args2.snapshot);
|
|
6327
|
+
if (args2.json) {
|
|
6328
|
+
console.log(JSON.stringify(snapshot, null, 2));
|
|
6329
|
+
return;
|
|
6330
|
+
}
|
|
6331
|
+
console.log(`snapshot ${snapshot.id} \xB7 ${snapshot.complete ? "complete" : "incomplete"}`);
|
|
6332
|
+
console.log(` head: ${snapshot.head ?? "(unborn)"} \xB7 base: ${snapshot.base.resolvedOid}`);
|
|
6333
|
+
const rows = snapshot.entries.map((entry3) => [
|
|
6334
|
+
entry3.layer,
|
|
6335
|
+
entry3.kind,
|
|
6336
|
+
entry3.path,
|
|
6337
|
+
entry3.bytes === null ? "-" : `${entry3.bytes}B`,
|
|
6338
|
+
entry3.digest === null ? "" : entry3.digest.slice(0, 12)
|
|
6339
|
+
]);
|
|
6340
|
+
for (const line of columnize(rows)) console.log(line);
|
|
6341
|
+
}
|
|
6342
|
+
});
|
|
6343
|
+
var teamReviewCommand = defineCommand29({
|
|
6344
|
+
meta: {
|
|
6345
|
+
name: "review",
|
|
6346
|
+
description: "Read-only Git change review and bounded source snapshots"
|
|
6347
|
+
},
|
|
6348
|
+
subCommands: {
|
|
6349
|
+
show: showCmd5,
|
|
6350
|
+
capture: captureCmd,
|
|
6351
|
+
snapshots: snapshotsCmd,
|
|
6352
|
+
snapshot: snapshotCmd
|
|
6353
|
+
}
|
|
6354
|
+
});
|
|
6355
|
+
|
|
5956
6356
|
// src/commands/team.ts
|
|
5957
|
-
var addCmd2 =
|
|
6357
|
+
var addCmd2 = defineCommand30({
|
|
5958
6358
|
meta: {
|
|
5959
6359
|
name: "add",
|
|
5960
6360
|
description: "Register a team at ~/.bazilion/teams/<slug>/ (use --link to point at an existing tree)"
|
|
@@ -5967,18 +6367,18 @@ var addCmd2 = defineCommand27({
|
|
|
5967
6367
|
description: "Absolute path of an existing directory; the team slot becomes a symlink to it"
|
|
5968
6368
|
}
|
|
5969
6369
|
},
|
|
5970
|
-
async run({ args }) {
|
|
6370
|
+
async run({ args: args2 }) {
|
|
5971
6371
|
const client = createClient2();
|
|
5972
6372
|
const body = {
|
|
5973
|
-
id:
|
|
5974
|
-
...
|
|
5975
|
-
...
|
|
6373
|
+
id: args2.id,
|
|
6374
|
+
...args2.name ? { name: args2.name } : {},
|
|
6375
|
+
...args2.link ? { link: args2.link } : {}
|
|
5976
6376
|
};
|
|
5977
6377
|
const g = await client.post("/api/teams", body);
|
|
5978
6378
|
console.log(`registered team ${g.id} at ${g.path}`);
|
|
5979
6379
|
}
|
|
5980
6380
|
});
|
|
5981
|
-
var listCmd10 =
|
|
6381
|
+
var listCmd10 = defineCommand30({
|
|
5982
6382
|
meta: { name: "list", description: "List teams" },
|
|
5983
6383
|
async run() {
|
|
5984
6384
|
const client = createClient2();
|
|
@@ -5991,20 +6391,20 @@ var listCmd10 = defineCommand27({
|
|
|
5991
6391
|
for (const line of columnize(rows)) console.log(line);
|
|
5992
6392
|
}
|
|
5993
6393
|
});
|
|
5994
|
-
var rmCmd5 =
|
|
6394
|
+
var rmCmd5 = defineCommand30({
|
|
5995
6395
|
meta: { name: "rm", description: "Remove a team registration" },
|
|
5996
6396
|
args: {
|
|
5997
6397
|
id: { type: "positional", required: true }
|
|
5998
6398
|
},
|
|
5999
|
-
async run({ args }) {
|
|
6399
|
+
async run({ args: args2 }) {
|
|
6000
6400
|
const client = createClient2();
|
|
6001
6401
|
const policy = await client.get(
|
|
6002
|
-
`/api/teams/${encodeURIComponent(
|
|
6402
|
+
`/api/teams/${encodeURIComponent(args2.id)}/policy`
|
|
6003
6403
|
);
|
|
6004
6404
|
await client.del(
|
|
6005
|
-
`/api/teams/${encodeURIComponent(
|
|
6405
|
+
`/api/teams/${encodeURIComponent(args2.id)}?expectedTeamPolicyRevision=${policy.teamPolicy.revision}`
|
|
6006
6406
|
);
|
|
6007
|
-
console.log(`removed team ${
|
|
6407
|
+
console.log(`removed team ${args2.id}`);
|
|
6008
6408
|
}
|
|
6009
6409
|
});
|
|
6010
6410
|
async function readStdin() {
|
|
@@ -6012,17 +6412,17 @@ async function readStdin() {
|
|
|
6012
6412
|
for await (const chunk of stdin2) chunks.push(chunk);
|
|
6013
6413
|
return Buffer.concat(chunks).toString("utf8");
|
|
6014
6414
|
}
|
|
6015
|
-
var userMdShowCmd =
|
|
6415
|
+
var userMdShowCmd = defineCommand30({
|
|
6016
6416
|
meta: { name: "show", description: "Print the team's USER.md" },
|
|
6017
6417
|
args: { id: { type: "positional", required: true } },
|
|
6018
|
-
async run({ args }) {
|
|
6418
|
+
async run({ args: args2 }) {
|
|
6019
6419
|
const client = createClient2();
|
|
6020
|
-
const g = await client.get(`/api/teams/${
|
|
6420
|
+
const g = await client.get(`/api/teams/${args2.id}`);
|
|
6021
6421
|
process.stdout.write(g.userMd);
|
|
6022
6422
|
if (g.userMd && !g.userMd.endsWith("\n")) process.stdout.write("\n");
|
|
6023
6423
|
}
|
|
6024
6424
|
});
|
|
6025
|
-
var userMdSetCmd =
|
|
6425
|
+
var userMdSetCmd = defineCommand30({
|
|
6026
6426
|
meta: {
|
|
6027
6427
|
name: "set",
|
|
6028
6428
|
description: "Replace the team's USER.md (from --file, --from-stdin, or inline text)"
|
|
@@ -6033,32 +6433,32 @@ var userMdSetCmd = defineCommand27({
|
|
|
6033
6433
|
"from-stdin": { type: "boolean", description: "Read content from stdin" },
|
|
6034
6434
|
text: { type: "string", description: "Inline content" }
|
|
6035
6435
|
},
|
|
6036
|
-
async run({ args }) {
|
|
6436
|
+
async run({ args: args2 }) {
|
|
6037
6437
|
let content;
|
|
6038
|
-
if (
|
|
6039
|
-
else if (
|
|
6040
|
-
else if (
|
|
6438
|
+
if (args2["from-stdin"]) content = await readStdin();
|
|
6439
|
+
else if (args2.file) content = readFileSync11(args2.file, "utf8");
|
|
6440
|
+
else if (args2.text !== void 0) content = args2.text;
|
|
6041
6441
|
else {
|
|
6042
6442
|
console.error("team user-md set: provide --file, --from-stdin, or --text");
|
|
6043
6443
|
process.exit(2);
|
|
6044
6444
|
}
|
|
6045
6445
|
const client = createClient2();
|
|
6046
6446
|
const body = { userMd: content };
|
|
6047
|
-
await client.put(`/api/teams/${
|
|
6048
|
-
console.log(`updated USER.md for team ${
|
|
6447
|
+
await client.put(`/api/teams/${args2.id}/user-md`, body);
|
|
6448
|
+
console.log(`updated USER.md for team ${args2.id} (${content.length} bytes)`);
|
|
6049
6449
|
}
|
|
6050
6450
|
});
|
|
6051
|
-
var userMdClearCmd =
|
|
6451
|
+
var userMdClearCmd = defineCommand30({
|
|
6052
6452
|
meta: { name: "clear", description: "Clear the team's USER.md to empty" },
|
|
6053
6453
|
args: { id: { type: "positional", required: true } },
|
|
6054
|
-
async run({ args }) {
|
|
6454
|
+
async run({ args: args2 }) {
|
|
6055
6455
|
const client = createClient2();
|
|
6056
6456
|
const body = { userMd: "" };
|
|
6057
|
-
await client.put(`/api/teams/${
|
|
6058
|
-
console.log(`cleared USER.md for team ${
|
|
6457
|
+
await client.put(`/api/teams/${args2.id}/user-md`, body);
|
|
6458
|
+
console.log(`cleared USER.md for team ${args2.id}`);
|
|
6059
6459
|
}
|
|
6060
6460
|
});
|
|
6061
|
-
var userMdCmd =
|
|
6461
|
+
var userMdCmd = defineCommand30({
|
|
6062
6462
|
meta: { name: "user-md", description: "View or edit a team's USER.md" },
|
|
6063
6463
|
subCommands: {
|
|
6064
6464
|
show: userMdShowCmd,
|
|
@@ -6066,16 +6466,16 @@ var userMdCmd = defineCommand27({
|
|
|
6066
6466
|
clear: userMdClearCmd
|
|
6067
6467
|
}
|
|
6068
6468
|
});
|
|
6069
|
-
var topicFormatShowCmd =
|
|
6469
|
+
var topicFormatShowCmd = defineCommand30({
|
|
6070
6470
|
meta: { name: "show", description: "Print the team's Telegram topic-name template" },
|
|
6071
6471
|
args: { id: { type: "positional", required: true } },
|
|
6072
|
-
async run({ args }) {
|
|
6472
|
+
async run({ args: args2 }) {
|
|
6073
6473
|
const client = createClient2();
|
|
6074
|
-
const g = await client.get(`/api/teams/${
|
|
6474
|
+
const g = await client.get(`/api/teams/${args2.id}`);
|
|
6075
6475
|
console.log(g.telegramTopicNameFormat ?? "(default naming)");
|
|
6076
6476
|
}
|
|
6077
6477
|
});
|
|
6078
|
-
var topicFormatSetCmd =
|
|
6478
|
+
var topicFormatSetCmd = defineCommand30({
|
|
6079
6479
|
meta: {
|
|
6080
6480
|
name: "set",
|
|
6081
6481
|
description: "Set the topic-name template. Tokens: {agent.name} {team.name} {team.slug} (must include {agent.name})"
|
|
@@ -6088,24 +6488,24 @@ var topicFormatSetCmd = defineCommand27({
|
|
|
6088
6488
|
description: 'e.g. "{team.name} / {agent.name}"'
|
|
6089
6489
|
}
|
|
6090
6490
|
},
|
|
6091
|
-
async run({ args }) {
|
|
6491
|
+
async run({ args: args2 }) {
|
|
6092
6492
|
const client = createClient2();
|
|
6093
|
-
const body = { format:
|
|
6094
|
-
const g = await client.put(`/api/teams/${
|
|
6095
|
-
console.log(`set topic-name template for team ${
|
|
6493
|
+
const body = { format: args2.format };
|
|
6494
|
+
const g = await client.put(`/api/teams/${args2.id}/topic-format`, body);
|
|
6495
|
+
console.log(`set topic-name template for team ${args2.id}: ${g.telegramTopicNameFormat}`);
|
|
6096
6496
|
}
|
|
6097
6497
|
});
|
|
6098
|
-
var topicFormatClearCmd =
|
|
6498
|
+
var topicFormatClearCmd = defineCommand30({
|
|
6099
6499
|
meta: { name: "clear", description: "Clear the template (revert to built-in naming)" },
|
|
6100
6500
|
args: { id: { type: "positional", required: true } },
|
|
6101
|
-
async run({ args }) {
|
|
6501
|
+
async run({ args: args2 }) {
|
|
6102
6502
|
const client = createClient2();
|
|
6103
6503
|
const body = { format: null };
|
|
6104
|
-
await client.put(`/api/teams/${
|
|
6105
|
-
console.log(`cleared topic-name template for team ${
|
|
6504
|
+
await client.put(`/api/teams/${args2.id}/topic-format`, body);
|
|
6505
|
+
console.log(`cleared topic-name template for team ${args2.id}`);
|
|
6106
6506
|
}
|
|
6107
6507
|
});
|
|
6108
|
-
var topicFormatCmd =
|
|
6508
|
+
var topicFormatCmd = defineCommand30({
|
|
6109
6509
|
meta: {
|
|
6110
6510
|
name: "topic-format",
|
|
6111
6511
|
description: "View or edit a team's Telegram forum-topic name template"
|
|
@@ -6116,9 +6516,60 @@ var topicFormatCmd = defineCommand27({
|
|
|
6116
6516
|
clear: topicFormatClearCmd
|
|
6117
6517
|
}
|
|
6118
6518
|
});
|
|
6119
|
-
var
|
|
6519
|
+
var contextCmd = defineCommand30({
|
|
6520
|
+
meta: {
|
|
6521
|
+
name: "context",
|
|
6522
|
+
description: "Inspect repository instructions, Git state and command suggestions"
|
|
6523
|
+
},
|
|
6524
|
+
args: {
|
|
6525
|
+
id: { type: "positional", required: true, description: "Team slug" },
|
|
6526
|
+
target: { type: "string", description: "Contained relative file or directory" },
|
|
6527
|
+
json: { type: "boolean", description: "Print the complete captured report as JSON" }
|
|
6528
|
+
},
|
|
6529
|
+
async run({ args: args2 }) {
|
|
6530
|
+
const report = await createClient2().repositoryContext(args2.id, { target: args2.target });
|
|
6531
|
+
if (args2.json) {
|
|
6532
|
+
console.log(JSON.stringify(report, null, 2));
|
|
6533
|
+
return;
|
|
6534
|
+
}
|
|
6535
|
+
const safe2 = (value) => [...value].map(
|
|
6536
|
+
(char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127 ? JSON.stringify(char).slice(1, -1) : char
|
|
6537
|
+
).join("");
|
|
6538
|
+
console.log(
|
|
6539
|
+
`Team ${safe2(report.teamId)} \xB7 target ${safe2(report.target)} \xB7 captured ${new Date(report.capturedAt).toISOString()}`
|
|
6540
|
+
);
|
|
6541
|
+
console.log(`Repository instructions: ${report.instructions.state}`);
|
|
6542
|
+
for (const file of report.instructions.files)
|
|
6543
|
+
console.log(
|
|
6544
|
+
` ${safe2(file.path)} (scope ${safe2(file.scope)}, precedence ${file.precedence}, SHA-256 ${file.sha256})`
|
|
6545
|
+
);
|
|
6546
|
+
console.log(
|
|
6547
|
+
`Git: ${report.git.state}${report.git.headState ? ` \xB7 ${report.git.headState} ${safe2(report.git.branch ?? report.git.head ?? "")}` : ""}`
|
|
6548
|
+
);
|
|
6549
|
+
if (report.git.state === "available")
|
|
6550
|
+
console.log(
|
|
6551
|
+
` staged ${report.git.staged}, unstaged ${report.git.unstaged}, untracked ${report.git.untracked}, conflicted ${report.git.conflicted}`
|
|
6552
|
+
);
|
|
6553
|
+
console.log(`Command suggestions: ${report.commands.state} (not executed)`);
|
|
6554
|
+
for (const candidate of report.commands.candidates)
|
|
6555
|
+
console.log(
|
|
6556
|
+
` ${safe2(candidate.command)} \u2014 ${safe2(candidate.source)} ${safe2(candidate.location)}, cwd ${safe2(candidate.cwd)}`
|
|
6557
|
+
);
|
|
6558
|
+
for (const issue of [
|
|
6559
|
+
...report.instructions.issues,
|
|
6560
|
+
...report.commands.issues,
|
|
6561
|
+
...report.git.issues
|
|
6562
|
+
])
|
|
6563
|
+
console.log(` ${issue.code}${issue.path ? `: ${safe2(issue.path)}` : ""} \u2014 ${issue.message}`);
|
|
6564
|
+
}
|
|
6565
|
+
});
|
|
6566
|
+
var teamCommand = defineCommand30({
|
|
6120
6567
|
meta: { name: "team", description: "Manage teams (collaboration contexts)" },
|
|
6121
6568
|
subCommands: {
|
|
6569
|
+
environment: teamEnvironmentCommand,
|
|
6570
|
+
log: teamCodingLogCommand,
|
|
6571
|
+
review: teamReviewCommand,
|
|
6572
|
+
context: contextCmd,
|
|
6122
6573
|
add: addCmd2,
|
|
6123
6574
|
list: listCmd10,
|
|
6124
6575
|
rm: rmCmd5,
|
|
@@ -6129,11 +6580,11 @@ var teamCommand = defineCommand27({
|
|
|
6129
6580
|
});
|
|
6130
6581
|
|
|
6131
6582
|
// src/commands/team-template.ts
|
|
6132
|
-
import { readFileSync as
|
|
6133
|
-
import { defineCommand as
|
|
6583
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
6584
|
+
import { defineCommand as defineCommand31 } from "citty";
|
|
6134
6585
|
function jsonFile(path) {
|
|
6135
6586
|
try {
|
|
6136
|
-
return JSON.parse(
|
|
6587
|
+
return JSON.parse(readFileSync12(path, "utf8"));
|
|
6137
6588
|
} catch (error) {
|
|
6138
6589
|
throw new Error(`invalid JSON: ${error.message}`);
|
|
6139
6590
|
}
|
|
@@ -6158,12 +6609,12 @@ function printTeam(detail) {
|
|
|
6158
6609
|
console.log(line);
|
|
6159
6610
|
}
|
|
6160
6611
|
}
|
|
6161
|
-
var list7 =
|
|
6612
|
+
var list7 = defineCommand31({
|
|
6162
6613
|
meta: { name: "list", description: "List canonical Team templates" },
|
|
6163
6614
|
args: { json: { type: "boolean", description: "Emit stable JSON" } },
|
|
6164
|
-
async run({ args }) {
|
|
6615
|
+
async run({ args: args2 }) {
|
|
6165
6616
|
const rows = await createClient2().get("/api/team-templates");
|
|
6166
|
-
if (
|
|
6617
|
+
if (args2.json) return console.log(JSON.stringify(rows, null, 2));
|
|
6167
6618
|
if (!rows.length) return console.log("(no Team templates)");
|
|
6168
6619
|
for (const line of columnize([
|
|
6169
6620
|
["id", "revision", "slots", "name"],
|
|
@@ -6172,29 +6623,29 @@ var list7 = defineCommand28({
|
|
|
6172
6623
|
console.log(line);
|
|
6173
6624
|
}
|
|
6174
6625
|
});
|
|
6175
|
-
var show6 =
|
|
6626
|
+
var show6 = defineCommand31({
|
|
6176
6627
|
meta: { name: "show", description: "Show a canonical Team template" },
|
|
6177
6628
|
args: {
|
|
6178
6629
|
id: { type: "positional", required: true },
|
|
6179
6630
|
json: { type: "boolean", description: "Emit the canonical API aggregate" }
|
|
6180
6631
|
},
|
|
6181
|
-
async run({ args }) {
|
|
6632
|
+
async run({ args: args2 }) {
|
|
6182
6633
|
const detail = await createClient2().get(
|
|
6183
|
-
`/api/team-templates/${encodeURIComponent(
|
|
6634
|
+
`/api/team-templates/${encodeURIComponent(args2.id)}`
|
|
6184
6635
|
);
|
|
6185
|
-
if (
|
|
6636
|
+
if (args2.json) console.log(JSON.stringify(detail, null, 2));
|
|
6186
6637
|
else printTeam(detail);
|
|
6187
6638
|
}
|
|
6188
6639
|
});
|
|
6189
|
-
var exportCommand2 =
|
|
6640
|
+
var exportCommand2 = defineCommand31({
|
|
6190
6641
|
meta: {
|
|
6191
6642
|
name: "export",
|
|
6192
6643
|
description: "Export a portable versioned Team-template document to stdout"
|
|
6193
6644
|
},
|
|
6194
6645
|
args: { id: { type: "positional", required: true } },
|
|
6195
|
-
async run({ args }) {
|
|
6646
|
+
async run({ args: args2 }) {
|
|
6196
6647
|
const detail = await createClient2().get(
|
|
6197
|
-
`/api/team-templates/${encodeURIComponent(
|
|
6648
|
+
`/api/team-templates/${encodeURIComponent(args2.id)}`
|
|
6198
6649
|
);
|
|
6199
6650
|
console.log(JSON.stringify(exportTeamDocument(detail), null, 2));
|
|
6200
6651
|
}
|
|
@@ -6226,7 +6677,7 @@ function printImportDiff(current, document) {
|
|
|
6226
6677
|
for (const value of diff2.added) console.log(` + ${value}`);
|
|
6227
6678
|
for (const value of diff2.removed) console.log(` - ${value}`);
|
|
6228
6679
|
}
|
|
6229
|
-
var importCommand2 =
|
|
6680
|
+
var importCommand2 = defineCommand31({
|
|
6230
6681
|
meta: {
|
|
6231
6682
|
name: "import",
|
|
6232
6683
|
description: "Validate, diff, and explicitly apply a portable Team-template document"
|
|
@@ -6248,10 +6699,10 @@ var importCommand2 = defineCommand28({
|
|
|
6248
6699
|
description: "Second force confirmation: the freshly displayed current revision"
|
|
6249
6700
|
}
|
|
6250
6701
|
},
|
|
6251
|
-
async run({ args }) {
|
|
6252
|
-
if (
|
|
6702
|
+
async run({ args: args2 }) {
|
|
6703
|
+
if (args2.force && !args2.apply)
|
|
6253
6704
|
throw new Error("--force requires --apply (interactive force is intentionally unsupported)");
|
|
6254
|
-
const document = parseTeamDocument(jsonFile(
|
|
6705
|
+
const document = parseTeamDocument(jsonFile(args2.file));
|
|
6255
6706
|
const client = createClient2();
|
|
6256
6707
|
let current = null;
|
|
6257
6708
|
try {
|
|
@@ -6262,11 +6713,11 @@ var importCommand2 = defineCommand28({
|
|
|
6262
6713
|
if (!(error instanceof ApiClientError) || error.status !== 404) throw error;
|
|
6263
6714
|
}
|
|
6264
6715
|
printImportDiff(current, document);
|
|
6265
|
-
if (
|
|
6716
|
+
if (args2["dry-run"]) {
|
|
6266
6717
|
console.log("valid: no changes applied");
|
|
6267
6718
|
return;
|
|
6268
6719
|
}
|
|
6269
|
-
if (!
|
|
6720
|
+
if (!args2.apply) throw new Error("refusing mutation: review the diff, then pass --apply");
|
|
6270
6721
|
if (!current) {
|
|
6271
6722
|
const body2 = teamImportBody(document);
|
|
6272
6723
|
const created = await client.post("/api/team-templates/import", {
|
|
@@ -6288,9 +6739,9 @@ var importCommand2 = defineCommand28({
|
|
|
6288
6739
|
throw new Error(
|
|
6289
6740
|
"replacement document metadata differs; update Team name/USER.md separately before import"
|
|
6290
6741
|
);
|
|
6291
|
-
const supplied = Number.parseInt(
|
|
6292
|
-
const expectedRevision =
|
|
6293
|
-
if (
|
|
6742
|
+
const supplied = Number.parseInt(args2["expected-revision"] ?? "", 10);
|
|
6743
|
+
const expectedRevision = args2.force ? current.template.currentRevision : supplied;
|
|
6744
|
+
if (args2.force && Number.parseInt(args2["confirm-current-revision"] ?? "", 10) !== current.template.currentRevision)
|
|
6294
6745
|
throw new Error(
|
|
6295
6746
|
`--force requires --confirm-current-revision ${current.template.currentRevision} after reviewing the fresh diff`
|
|
6296
6747
|
);
|
|
@@ -6307,7 +6758,7 @@ var importCommand2 = defineCommand28({
|
|
|
6307
6758
|
);
|
|
6308
6759
|
}
|
|
6309
6760
|
});
|
|
6310
|
-
var teamTemplateCommand =
|
|
6761
|
+
var teamTemplateCommand = defineCommand31({
|
|
6311
6762
|
meta: {
|
|
6312
6763
|
name: "team-template",
|
|
6313
6764
|
description: "Inspect and exchange canonical Team templates"
|
|
@@ -6316,8 +6767,8 @@ var teamTemplateCommand = defineCommand28({
|
|
|
6316
6767
|
});
|
|
6317
6768
|
|
|
6318
6769
|
// src/commands/telegram.ts
|
|
6319
|
-
import { defineCommand as
|
|
6320
|
-
var setCmd2 =
|
|
6770
|
+
import { defineCommand as defineCommand32 } from "citty";
|
|
6771
|
+
var setCmd2 = defineCommand32({
|
|
6321
6772
|
meta: {
|
|
6322
6773
|
name: "set",
|
|
6323
6774
|
description: "Save bot token + supergroup chat ID (paired write)"
|
|
@@ -6326,16 +6777,16 @@ var setCmd2 = defineCommand29({
|
|
|
6326
6777
|
token: { type: "string", required: true, description: "Bot token from @BotFather" },
|
|
6327
6778
|
chat: { type: "string", required: true, description: "Numeric supergroup chat ID" }
|
|
6328
6779
|
},
|
|
6329
|
-
async run({ args }) {
|
|
6780
|
+
async run({ args: args2 }) {
|
|
6330
6781
|
const client = createClient2();
|
|
6331
6782
|
const state = await client.put("/api/config/telegram", {
|
|
6332
|
-
botToken:
|
|
6333
|
-
chatId:
|
|
6783
|
+
botToken: args2.token,
|
|
6784
|
+
chatId: args2.chat
|
|
6334
6785
|
});
|
|
6335
6786
|
console.log(`saved \xB7 token ${state.botTokenPreview} \xB7 chat ${state.chatId}`);
|
|
6336
6787
|
}
|
|
6337
6788
|
});
|
|
6338
|
-
var clearCmd =
|
|
6789
|
+
var clearCmd = defineCommand32({
|
|
6339
6790
|
meta: {
|
|
6340
6791
|
name: "clear",
|
|
6341
6792
|
description: "Remove stored bot token + chat ID"
|
|
@@ -6346,7 +6797,7 @@ var clearCmd = defineCommand29({
|
|
|
6346
6797
|
console.log("cleared");
|
|
6347
6798
|
}
|
|
6348
6799
|
});
|
|
6349
|
-
var
|
|
6800
|
+
var showCmd6 = defineCommand32({
|
|
6350
6801
|
meta: {
|
|
6351
6802
|
name: "show",
|
|
6352
6803
|
description: "Show what credentials are stored (token is masked)"
|
|
@@ -6367,7 +6818,7 @@ var showCmd5 = defineCommand29({
|
|
|
6367
6818
|
}
|
|
6368
6819
|
}
|
|
6369
6820
|
});
|
|
6370
|
-
var reconnectCmd =
|
|
6821
|
+
var reconnectCmd = defineCommand32({
|
|
6371
6822
|
meta: {
|
|
6372
6823
|
name: "reconnect",
|
|
6373
6824
|
description: "Apply a pending supergroup chat-id migration + re-activate the bot"
|
|
@@ -6378,7 +6829,7 @@ var reconnectCmd = defineCommand29({
|
|
|
6378
6829
|
console.log(`reconnected \xB7 chat ${state.chatId}`);
|
|
6379
6830
|
}
|
|
6380
6831
|
});
|
|
6381
|
-
var configCmd =
|
|
6832
|
+
var configCmd = defineCommand32({
|
|
6382
6833
|
meta: {
|
|
6383
6834
|
name: "config",
|
|
6384
6835
|
description: "Manage Telegram credentials (bot token + chat ID)"
|
|
@@ -6386,10 +6837,10 @@ var configCmd = defineCommand29({
|
|
|
6386
6837
|
subCommands: {
|
|
6387
6838
|
set: setCmd2,
|
|
6388
6839
|
clear: clearCmd,
|
|
6389
|
-
show:
|
|
6840
|
+
show: showCmd6
|
|
6390
6841
|
}
|
|
6391
6842
|
});
|
|
6392
|
-
var healthCmd =
|
|
6843
|
+
var healthCmd = defineCommand32({
|
|
6393
6844
|
meta: {
|
|
6394
6845
|
name: "health",
|
|
6395
6846
|
description: "Run the four-step preflight against the Telegram Bot API"
|
|
@@ -6428,7 +6879,7 @@ var healthCmd = defineCommand29({
|
|
|
6428
6879
|
if (!allOk) process.exitCode = 1;
|
|
6429
6880
|
}
|
|
6430
6881
|
});
|
|
6431
|
-
var botStatusCmd =
|
|
6882
|
+
var botStatusCmd = defineCommand32({
|
|
6432
6883
|
meta: {
|
|
6433
6884
|
name: "status",
|
|
6434
6885
|
description: "Show polling state of the live bot"
|
|
@@ -6453,7 +6904,7 @@ var botStatusCmd = defineCommand29({
|
|
|
6453
6904
|
if (!p.running) process.exitCode = 1;
|
|
6454
6905
|
}
|
|
6455
6906
|
});
|
|
6456
|
-
var botRestartCmd =
|
|
6907
|
+
var botRestartCmd = defineCommand32({
|
|
6457
6908
|
meta: {
|
|
6458
6909
|
name: "restart",
|
|
6459
6910
|
description: "Force-restart the bot (tears down + brings up from current creds)"
|
|
@@ -6464,7 +6915,7 @@ var botRestartCmd = defineCommand29({
|
|
|
6464
6915
|
console.log("restart requested");
|
|
6465
6916
|
}
|
|
6466
6917
|
});
|
|
6467
|
-
var botCmd =
|
|
6918
|
+
var botCmd = defineCommand32({
|
|
6468
6919
|
meta: {
|
|
6469
6920
|
name: "bot",
|
|
6470
6921
|
description: "Inspect / control the live polling bot"
|
|
@@ -6474,7 +6925,7 @@ var botCmd = defineCommand29({
|
|
|
6474
6925
|
restart: botRestartCmd
|
|
6475
6926
|
}
|
|
6476
6927
|
});
|
|
6477
|
-
var bindCmd =
|
|
6928
|
+
var bindCmd = defineCommand32({
|
|
6478
6929
|
meta: {
|
|
6479
6930
|
name: "bind",
|
|
6480
6931
|
description: "Create a Telegram topic for an agent (manual fallback for /talk)"
|
|
@@ -6482,17 +6933,17 @@ var bindCmd = defineCommand29({
|
|
|
6482
6933
|
args: {
|
|
6483
6934
|
agent: { type: "positional", required: true, description: "Agent id or prefix" }
|
|
6484
6935
|
},
|
|
6485
|
-
async run({ args }) {
|
|
6936
|
+
async run({ args: args2 }) {
|
|
6486
6937
|
const client = createClient2();
|
|
6487
6938
|
const result = await client.post(
|
|
6488
|
-
`/api/agents/${
|
|
6939
|
+
`/api/agents/${args2.agent}/telegram/bind`
|
|
6489
6940
|
);
|
|
6490
6941
|
const verb = result.created ? "created topic" : "already bound to";
|
|
6491
6942
|
console.log(`${verb} #${result.topicId} for agent ${result.agent.name} (${result.agent.id})`);
|
|
6492
6943
|
console.log(` ${result.deepLink}`);
|
|
6493
6944
|
}
|
|
6494
6945
|
});
|
|
6495
|
-
var unbindCmd =
|
|
6946
|
+
var unbindCmd = defineCommand32({
|
|
6496
6947
|
meta: {
|
|
6497
6948
|
name: "unbind",
|
|
6498
6949
|
description: "Clear an agent's Telegram topic binding (topic stays in Telegram as orphan)"
|
|
@@ -6500,13 +6951,13 @@ var unbindCmd = defineCommand29({
|
|
|
6500
6951
|
args: {
|
|
6501
6952
|
agent: { type: "positional", required: true, description: "Agent id or prefix" }
|
|
6502
6953
|
},
|
|
6503
|
-
async run({ args }) {
|
|
6954
|
+
async run({ args: args2 }) {
|
|
6504
6955
|
const client = createClient2();
|
|
6505
|
-
await client.del(`/api/agents/${
|
|
6506
|
-
console.log(`unbound agent ${
|
|
6956
|
+
await client.del(`/api/agents/${args2.agent}/telegram/binding`);
|
|
6957
|
+
console.log(`unbound agent ${args2.agent}`);
|
|
6507
6958
|
}
|
|
6508
6959
|
});
|
|
6509
|
-
var listBindingsCmd =
|
|
6960
|
+
var listBindingsCmd = defineCommand32({
|
|
6510
6961
|
meta: {
|
|
6511
6962
|
name: "list",
|
|
6512
6963
|
description: "List agents and their Telegram topic bindings"
|
|
@@ -6534,32 +6985,32 @@ var listBindingsCmd = defineCommand29({
|
|
|
6534
6985
|
}
|
|
6535
6986
|
}
|
|
6536
6987
|
});
|
|
6537
|
-
var allowCmd =
|
|
6988
|
+
var allowCmd = defineCommand32({
|
|
6538
6989
|
meta: { name: "allow", description: "Add a Telegram user id to the allowlist" },
|
|
6539
6990
|
args: {
|
|
6540
6991
|
userId: { type: "positional", required: true, description: "Numeric Telegram user id" },
|
|
6541
6992
|
label: { type: "string", description: "Optional human label" }
|
|
6542
6993
|
},
|
|
6543
|
-
async run({ args }) {
|
|
6994
|
+
async run({ args: args2 }) {
|
|
6544
6995
|
const client = createClient2();
|
|
6545
6996
|
const u = await client.post("/api/config/telegram/acl", {
|
|
6546
|
-
userId: Number(
|
|
6547
|
-
label:
|
|
6997
|
+
userId: Number(args2.userId),
|
|
6998
|
+
label: args2.label ?? null,
|
|
6548
6999
|
role: "member"
|
|
6549
7000
|
});
|
|
6550
7001
|
console.log(`allowed ${u.userId} (${u.role})`);
|
|
6551
7002
|
}
|
|
6552
7003
|
});
|
|
6553
|
-
var denyCmd =
|
|
7004
|
+
var denyCmd = defineCommand32({
|
|
6554
7005
|
meta: { name: "deny", description: "Remove a Telegram user id from the allowlist" },
|
|
6555
7006
|
args: { userId: { type: "positional", required: true } },
|
|
6556
|
-
async run({ args }) {
|
|
7007
|
+
async run({ args: args2 }) {
|
|
6557
7008
|
const client = createClient2();
|
|
6558
|
-
await client.del(`/api/config/telegram/acl/${Number(
|
|
6559
|
-
console.log(`removed ${
|
|
7009
|
+
await client.del(`/api/config/telegram/acl/${Number(args2.userId)}`);
|
|
7010
|
+
console.log(`removed ${args2.userId}`);
|
|
6560
7011
|
}
|
|
6561
7012
|
});
|
|
6562
|
-
var allowedCmd =
|
|
7013
|
+
var allowedCmd = defineCommand32({
|
|
6563
7014
|
meta: { name: "allowed", description: "List allowlisted Telegram users" },
|
|
6564
7015
|
async run() {
|
|
6565
7016
|
const client = createClient2();
|
|
@@ -6574,7 +7025,7 @@ var allowedCmd = defineCommand29({
|
|
|
6574
7025
|
}
|
|
6575
7026
|
}
|
|
6576
7027
|
});
|
|
6577
|
-
var pairingCreateCmd =
|
|
7028
|
+
var pairingCreateCmd = defineCommand32({
|
|
6578
7029
|
meta: { name: "create", description: "Generate a one-time Telegram owner pairing code" },
|
|
6579
7030
|
async run() {
|
|
6580
7031
|
const result = await createClient2().post(
|
|
@@ -6585,7 +7036,7 @@ var pairingCreateCmd = defineCommand29({
|
|
|
6585
7036
|
console.log("send `/pair <code>` in the configured \u2699 bazilion service topic");
|
|
6586
7037
|
}
|
|
6587
7038
|
});
|
|
6588
|
-
var pairingStatusCmd =
|
|
7039
|
+
var pairingStatusCmd = defineCommand32({
|
|
6589
7040
|
meta: { name: "status", description: "Show Telegram owner pairing status" },
|
|
6590
7041
|
async run() {
|
|
6591
7042
|
const result = await createClient2().get("/api/config/telegram/pairing");
|
|
@@ -6596,25 +7047,25 @@ var pairingStatusCmd = defineCommand29({
|
|
|
6596
7047
|
console.log(`expires: ${new Date(result.challengeExpiresAt).toISOString()}`);
|
|
6597
7048
|
}
|
|
6598
7049
|
});
|
|
6599
|
-
var pairingCancelCmd =
|
|
7050
|
+
var pairingCancelCmd = defineCommand32({
|
|
6600
7051
|
meta: { name: "cancel", description: "Cancel the active Telegram pairing code" },
|
|
6601
7052
|
async run() {
|
|
6602
7053
|
await createClient2().del("/api/config/telegram/pairing/challenge");
|
|
6603
7054
|
console.log("pairing challenge cancelled");
|
|
6604
7055
|
}
|
|
6605
7056
|
});
|
|
6606
|
-
var pairingResetCmd =
|
|
7057
|
+
var pairingResetCmd = defineCommand32({
|
|
6607
7058
|
meta: { name: "reset", description: "Revoke the Telegram owner and require re-pairing" },
|
|
6608
7059
|
args: {
|
|
6609
7060
|
yes: { type: "boolean", description: "Confirm destructive owner reset", required: true }
|
|
6610
7061
|
},
|
|
6611
|
-
async run({ args }) {
|
|
6612
|
-
if (!
|
|
7062
|
+
async run({ args: args2 }) {
|
|
7063
|
+
if (!args2.yes) throw new Error("--yes is required");
|
|
6613
7064
|
await createClient2().post("/api/config/telegram/pairing/reset", { confirm: true });
|
|
6614
7065
|
console.log("Telegram owner reset; ingress is closed until re-paired");
|
|
6615
7066
|
}
|
|
6616
7067
|
});
|
|
6617
|
-
var pairingCmd =
|
|
7068
|
+
var pairingCmd = defineCommand32({
|
|
6618
7069
|
meta: { name: "pairing", description: "Manage single-owner Telegram pairing" },
|
|
6619
7070
|
subCommands: {
|
|
6620
7071
|
create: pairingCreateCmd,
|
|
@@ -6623,7 +7074,7 @@ var pairingCmd = defineCommand29({
|
|
|
6623
7074
|
reset: pairingResetCmd
|
|
6624
7075
|
}
|
|
6625
7076
|
});
|
|
6626
|
-
var telegramCommand =
|
|
7077
|
+
var telegramCommand = defineCommand32({
|
|
6627
7078
|
meta: {
|
|
6628
7079
|
name: "telegram",
|
|
6629
7080
|
description: "Telegram integration: credentials, health, bot lifecycle, bindings, access"
|
|
@@ -6644,7 +7095,7 @@ var telegramCommand = defineCommand29({
|
|
|
6644
7095
|
});
|
|
6645
7096
|
|
|
6646
7097
|
// src/commands/token.ts
|
|
6647
|
-
import { defineCommand as
|
|
7098
|
+
import { defineCommand as defineCommand33 } from "citty";
|
|
6648
7099
|
import qrcode from "qrcode-terminal";
|
|
6649
7100
|
function tokenRow(t) {
|
|
6650
7101
|
const last = t.lastUsedAt ? new Date(t.lastUsedAt).toISOString() : "(never)";
|
|
@@ -6673,7 +7124,7 @@ function resolveQrServer(override) {
|
|
|
6673
7124
|
}
|
|
6674
7125
|
return url.origin;
|
|
6675
7126
|
}
|
|
6676
|
-
var createCmd3 =
|
|
7127
|
+
var createCmd3 = defineCommand33({
|
|
6677
7128
|
meta: { name: "create", description: "Mint a new web token (shown once)" },
|
|
6678
7129
|
args: {
|
|
6679
7130
|
label: { type: "positional", required: true, description: "Human-readable label" },
|
|
@@ -6690,13 +7141,13 @@ var createCmd3 = defineCommand30({
|
|
|
6690
7141
|
description: "Device lifetime in days (default 90, maximum 365)"
|
|
6691
7142
|
}
|
|
6692
7143
|
},
|
|
6693
|
-
async run({ args }) {
|
|
7144
|
+
async run({ args: args2 }) {
|
|
6694
7145
|
const client = createClient2();
|
|
6695
|
-
const expiresInDays =
|
|
7146
|
+
const expiresInDays = args2.expiresDays === void 0 ? void 0 : Number(args2.expiresDays);
|
|
6696
7147
|
if (expiresInDays !== void 0 && !Number.isInteger(expiresInDays)) {
|
|
6697
7148
|
throw new Error("--expires-days must be an integer");
|
|
6698
7149
|
}
|
|
6699
|
-
const body = { label:
|
|
7150
|
+
const body = { label: args2.label, expiresInDays };
|
|
6700
7151
|
const res = await client.post("/api/tokens", body);
|
|
6701
7152
|
console.log(`id: ${res.meta.id}`);
|
|
6702
7153
|
console.log(`label: ${res.meta.label}`);
|
|
@@ -6707,8 +7158,8 @@ var createCmd3 = defineCommand30({
|
|
|
6707
7158
|
console.log(`token: ${res.token}`);
|
|
6708
7159
|
console.log("");
|
|
6709
7160
|
console.log("store the token now \u2014 it is not recoverable later.");
|
|
6710
|
-
if (!
|
|
6711
|
-
const serverUrl = resolveQrServer(
|
|
7161
|
+
if (!args2.qr) return;
|
|
7162
|
+
const serverUrl = resolveQrServer(args2.server);
|
|
6712
7163
|
const pairUrl = `bazilion://pair?server=${encodeURIComponent(serverUrl)}&token=${encodeURIComponent(res.token)}`;
|
|
6713
7164
|
console.log("");
|
|
6714
7165
|
console.log(`pairing URL: ${pairUrl}`);
|
|
@@ -6716,14 +7167,14 @@ var createCmd3 = defineCommand30({
|
|
|
6716
7167
|
qrcode.generate(pairUrl, { small: true }, (qr) => console.log(qr));
|
|
6717
7168
|
}
|
|
6718
7169
|
});
|
|
6719
|
-
var listCmd11 =
|
|
7170
|
+
var listCmd11 = defineCommand33({
|
|
6720
7171
|
meta: { name: "list", description: "List web tokens" },
|
|
6721
7172
|
args: {
|
|
6722
7173
|
all: { type: "boolean", description: "Include revoked tokens" }
|
|
6723
7174
|
},
|
|
6724
|
-
async run({ args }) {
|
|
7175
|
+
async run({ args: args2 }) {
|
|
6725
7176
|
const client = createClient2();
|
|
6726
|
-
const qs =
|
|
7177
|
+
const qs = args2.all ? "?includeRevoked=1" : "";
|
|
6727
7178
|
const { tokens } = await client.get(`/api/tokens${qs}`);
|
|
6728
7179
|
if (tokens.length === 0) {
|
|
6729
7180
|
console.log("(no tokens)");
|
|
@@ -6732,7 +7183,7 @@ var listCmd11 = defineCommand30({
|
|
|
6732
7183
|
for (const line of columnize(tokens.map(tokenRow))) console.log(line);
|
|
6733
7184
|
}
|
|
6734
7185
|
});
|
|
6735
|
-
var showLocalCmd =
|
|
7186
|
+
var showLocalCmd = defineCommand33({
|
|
6736
7187
|
meta: {
|
|
6737
7188
|
name: "show-local",
|
|
6738
7189
|
description: "Print the bootstrap web token stored in ~/.bazilion/auth.json"
|
|
@@ -6742,18 +7193,18 @@ var showLocalCmd = defineCommand30({
|
|
|
6742
7193
|
console.log(readAuthFile(paths.authFile).token);
|
|
6743
7194
|
}
|
|
6744
7195
|
});
|
|
6745
|
-
var revokeCmd2 =
|
|
7196
|
+
var revokeCmd2 = defineCommand33({
|
|
6746
7197
|
meta: { name: "revoke", description: "Revoke a web token" },
|
|
6747
7198
|
args: {
|
|
6748
7199
|
id: { type: "positional", required: true }
|
|
6749
7200
|
},
|
|
6750
|
-
async run({ args }) {
|
|
7201
|
+
async run({ args: args2 }) {
|
|
6751
7202
|
const client = createClient2();
|
|
6752
|
-
await client.del(`/api/tokens/${
|
|
6753
|
-
console.log(`revoked token ${
|
|
7203
|
+
await client.del(`/api/tokens/${args2.id}`);
|
|
7204
|
+
console.log(`revoked token ${args2.id}`);
|
|
6754
7205
|
}
|
|
6755
7206
|
});
|
|
6756
|
-
var tokenCommand =
|
|
7207
|
+
var tokenCommand = defineCommand33({
|
|
6757
7208
|
meta: { name: "token", description: "Manage web tokens for API/CLI clients" },
|
|
6758
7209
|
subCommands: {
|
|
6759
7210
|
create: createCmd3,
|
|
@@ -6764,8 +7215,8 @@ var tokenCommand = defineCommand30({
|
|
|
6764
7215
|
});
|
|
6765
7216
|
|
|
6766
7217
|
// src/commands/trigger.ts
|
|
6767
|
-
import { defineCommand as
|
|
6768
|
-
var addCmd3 =
|
|
7218
|
+
import { defineCommand as defineCommand34 } from "citty";
|
|
7219
|
+
var addCmd3 = defineCommand34({
|
|
6769
7220
|
meta: { name: "add", description: "Add an interval / cron trigger to an agent" },
|
|
6770
7221
|
args: {
|
|
6771
7222
|
agent: { type: "positional", required: true },
|
|
@@ -6784,23 +7235,23 @@ var addCmd3 = defineCommand31({
|
|
|
6784
7235
|
},
|
|
6785
7236
|
disabled: { type: "boolean", description: "Create in disabled state" }
|
|
6786
7237
|
},
|
|
6787
|
-
async run({ args }) {
|
|
6788
|
-
if (!
|
|
7238
|
+
async run({ args: args2 }) {
|
|
7239
|
+
if (!args2.every === !args2.cron) {
|
|
6789
7240
|
throw new Error('specify exactly one of --every <seconds> or --cron "<expr>"');
|
|
6790
7241
|
}
|
|
6791
7242
|
const client = createClient2();
|
|
6792
|
-
const body =
|
|
7243
|
+
const body = args2.every ? {
|
|
6793
7244
|
kind: "interval",
|
|
6794
|
-
intervalSec: Number(
|
|
6795
|
-
message:
|
|
6796
|
-
enabled: !
|
|
7245
|
+
intervalSec: Number(args2.every),
|
|
7246
|
+
message: args2.message,
|
|
7247
|
+
enabled: !args2.disabled
|
|
6797
7248
|
} : {
|
|
6798
7249
|
kind: "cron",
|
|
6799
|
-
cronExpr:
|
|
6800
|
-
message:
|
|
6801
|
-
enabled: !
|
|
7250
|
+
cronExpr: args2.cron,
|
|
7251
|
+
message: args2.message,
|
|
7252
|
+
enabled: !args2.disabled
|
|
6802
7253
|
};
|
|
6803
|
-
const res = await client.post(`/api/agents/${
|
|
7254
|
+
const res = await client.post(`/api/agents/${args2.agent}/triggers`, body);
|
|
6804
7255
|
const t = res.trigger;
|
|
6805
7256
|
const spec = t.kind === "interval" ? `every ${t.intervalSec}s` : `cron "${t.cronExpr}"`;
|
|
6806
7257
|
console.log(`${t.id} ${spec} ${t.enabled ? "enabled" : "disabled"}`);
|
|
@@ -6813,15 +7264,15 @@ function triggerRow(t) {
|
|
|
6813
7264
|
const msgPreview = t.message.length > 60 ? `${t.message.slice(0, 60)}\u2026` : t.message;
|
|
6814
7265
|
return [t.id, state, spec, `last: ${last}`, `"${msgPreview}"`];
|
|
6815
7266
|
}
|
|
6816
|
-
var listCmd12 =
|
|
7267
|
+
var listCmd12 = defineCommand34({
|
|
6817
7268
|
meta: { name: "list", description: "List triggers for an agent" },
|
|
6818
7269
|
args: {
|
|
6819
7270
|
agent: { type: "positional", required: true }
|
|
6820
7271
|
},
|
|
6821
|
-
async run({ args }) {
|
|
7272
|
+
async run({ args: args2 }) {
|
|
6822
7273
|
const client = createClient2();
|
|
6823
7274
|
const { triggers } = await client.get(
|
|
6824
|
-
`/api/agents/${
|
|
7275
|
+
`/api/agents/${args2.agent}/triggers`
|
|
6825
7276
|
);
|
|
6826
7277
|
if (triggers.length === 0) {
|
|
6827
7278
|
console.log("(no triggers)");
|
|
@@ -6830,55 +7281,55 @@ var listCmd12 = defineCommand31({
|
|
|
6830
7281
|
for (const line of columnize(triggers.map(triggerRow))) console.log(line);
|
|
6831
7282
|
}
|
|
6832
7283
|
});
|
|
6833
|
-
var rmCmd6 =
|
|
7284
|
+
var rmCmd6 = defineCommand34({
|
|
6834
7285
|
meta: { name: "rm", description: "Delete a trigger" },
|
|
6835
7286
|
args: {
|
|
6836
7287
|
id: { type: "positional", required: true }
|
|
6837
7288
|
},
|
|
6838
|
-
async run({ args }) {
|
|
7289
|
+
async run({ args: args2 }) {
|
|
6839
7290
|
const client = createClient2();
|
|
6840
|
-
await client.del(`/api/triggers/${
|
|
6841
|
-
console.log(`removed trigger ${
|
|
7291
|
+
await client.del(`/api/triggers/${args2.id}`);
|
|
7292
|
+
console.log(`removed trigger ${args2.id}`);
|
|
6842
7293
|
}
|
|
6843
7294
|
});
|
|
6844
|
-
var enableCmd3 =
|
|
7295
|
+
var enableCmd3 = defineCommand34({
|
|
6845
7296
|
meta: { name: "enable", description: "Enable a trigger" },
|
|
6846
7297
|
args: {
|
|
6847
7298
|
id: { type: "positional", required: true }
|
|
6848
7299
|
},
|
|
6849
|
-
async run({ args }) {
|
|
7300
|
+
async run({ args: args2 }) {
|
|
6850
7301
|
const client = createClient2();
|
|
6851
7302
|
const body = { enabled: true };
|
|
6852
|
-
await client.patch(`/api/triggers/${
|
|
6853
|
-
console.log(`enabled trigger ${
|
|
7303
|
+
await client.patch(`/api/triggers/${args2.id}`, body);
|
|
7304
|
+
console.log(`enabled trigger ${args2.id}`);
|
|
6854
7305
|
}
|
|
6855
7306
|
});
|
|
6856
|
-
var disableCmd3 =
|
|
7307
|
+
var disableCmd3 = defineCommand34({
|
|
6857
7308
|
meta: { name: "disable", description: "Disable a trigger" },
|
|
6858
7309
|
args: {
|
|
6859
7310
|
id: { type: "positional", required: true }
|
|
6860
7311
|
},
|
|
6861
|
-
async run({ args }) {
|
|
7312
|
+
async run({ args: args2 }) {
|
|
6862
7313
|
const client = createClient2();
|
|
6863
7314
|
const body = { enabled: false };
|
|
6864
|
-
await client.patch(`/api/triggers/${
|
|
6865
|
-
console.log(`disabled trigger ${
|
|
7315
|
+
await client.patch(`/api/triggers/${args2.id}`, body);
|
|
7316
|
+
console.log(`disabled trigger ${args2.id}`);
|
|
6866
7317
|
}
|
|
6867
7318
|
});
|
|
6868
|
-
var historyCmd =
|
|
7319
|
+
var historyCmd = defineCommand34({
|
|
6869
7320
|
meta: { name: "history", description: "Show recent dispatches for a trigger" },
|
|
6870
7321
|
args: {
|
|
6871
7322
|
id: { type: "positional", required: true },
|
|
6872
7323
|
limit: { type: "string", description: "Maximum rows (default 20)" }
|
|
6873
7324
|
},
|
|
6874
|
-
async run({ args }) {
|
|
6875
|
-
const limit =
|
|
7325
|
+
async run({ args: args2 }) {
|
|
7326
|
+
const limit = args2.limit ? Number(args2.limit) : 20;
|
|
6876
7327
|
if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
|
|
6877
7328
|
throw new Error("--limit must be an integer from 1 to 100");
|
|
6878
7329
|
}
|
|
6879
7330
|
const client = createClient2();
|
|
6880
7331
|
const { dispatches } = await client.get(
|
|
6881
|
-
`/api/triggers/${
|
|
7332
|
+
`/api/triggers/${args2.id}/dispatches?limit=${limit}`
|
|
6882
7333
|
);
|
|
6883
7334
|
if (dispatches.length === 0) {
|
|
6884
7335
|
console.log("(no dispatches)");
|
|
@@ -6893,7 +7344,7 @@ var historyCmd = defineCommand31({
|
|
|
6893
7344
|
for (const line of columnize(rows)) console.log(line);
|
|
6894
7345
|
}
|
|
6895
7346
|
});
|
|
6896
|
-
var triggerCommand =
|
|
7347
|
+
var triggerCommand = defineCommand34({
|
|
6897
7348
|
meta: { name: "trigger", description: "Manage scheduled agent triggers" },
|
|
6898
7349
|
subCommands: {
|
|
6899
7350
|
add: addCmd3,
|
|
@@ -6906,10 +7357,10 @@ var triggerCommand = defineCommand31({
|
|
|
6906
7357
|
});
|
|
6907
7358
|
|
|
6908
7359
|
// src/commands/uninstall.ts
|
|
6909
|
-
import { existsSync as existsSync7, lstatSync as
|
|
7360
|
+
import { existsSync as existsSync7, lstatSync as lstatSync4, readdirSync as readdirSync2, realpathSync as realpathSync2, rmSync as rmSync4 } from "fs";
|
|
6910
7361
|
import { homedir as homedir2 } from "os";
|
|
6911
|
-
import { isAbsolute as isAbsolute2, join as join6, parse as parse2, relative as relative2, resolve as
|
|
6912
|
-
import { defineCommand as
|
|
7362
|
+
import { isAbsolute as isAbsolute2, join as join6, parse as parse2, relative as relative2, resolve as resolve5, sep } from "path";
|
|
7363
|
+
import { defineCommand as defineCommand35 } from "citty";
|
|
6913
7364
|
function makeLineReader() {
|
|
6914
7365
|
let buffer = "";
|
|
6915
7366
|
let ended = false;
|
|
@@ -6919,8 +7370,8 @@ function makeLineReader() {
|
|
|
6919
7370
|
const nlIdx = buffer.indexOf("\n");
|
|
6920
7371
|
if (nlIdx === -1) {
|
|
6921
7372
|
if (ended) {
|
|
6922
|
-
const
|
|
6923
|
-
|
|
7373
|
+
const resolve6 = queue.shift();
|
|
7374
|
+
resolve6?.(buffer);
|
|
6924
7375
|
buffer = "";
|
|
6925
7376
|
} else {
|
|
6926
7377
|
return;
|
|
@@ -6928,8 +7379,8 @@ function makeLineReader() {
|
|
|
6928
7379
|
} else {
|
|
6929
7380
|
const line = buffer.slice(0, nlIdx);
|
|
6930
7381
|
buffer = buffer.slice(nlIdx + 1);
|
|
6931
|
-
const
|
|
6932
|
-
|
|
7382
|
+
const resolve6 = queue.shift();
|
|
7383
|
+
resolve6?.(line);
|
|
6933
7384
|
}
|
|
6934
7385
|
}
|
|
6935
7386
|
};
|
|
@@ -6942,8 +7393,8 @@ function makeLineReader() {
|
|
|
6942
7393
|
ended = true;
|
|
6943
7394
|
tryDeliver();
|
|
6944
7395
|
});
|
|
6945
|
-
return () => new Promise((
|
|
6946
|
-
queue.push(
|
|
7396
|
+
return () => new Promise((resolve6) => {
|
|
7397
|
+
queue.push(resolve6);
|
|
6947
7398
|
tryDeliver();
|
|
6948
7399
|
});
|
|
6949
7400
|
}
|
|
@@ -6954,7 +7405,7 @@ async function askYes(readLine, prompt) {
|
|
|
6954
7405
|
}
|
|
6955
7406
|
function removePath(p) {
|
|
6956
7407
|
try {
|
|
6957
|
-
|
|
7408
|
+
lstatSync4(p);
|
|
6958
7409
|
} catch (error) {
|
|
6959
7410
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
|
|
6960
7411
|
throw error;
|
|
@@ -6967,7 +7418,7 @@ function canonicalExistingPath(path) {
|
|
|
6967
7418
|
return realpathSync2.native(path);
|
|
6968
7419
|
} catch (error) {
|
|
6969
7420
|
if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
|
|
6970
|
-
return
|
|
7421
|
+
return resolve5(path);
|
|
6971
7422
|
}
|
|
6972
7423
|
}
|
|
6973
7424
|
function containsPath(container, candidate) {
|
|
@@ -6975,7 +7426,7 @@ function containsPath(container, candidate) {
|
|
|
6975
7426
|
return nested === "" || nested !== ".." && !nested.startsWith(`..${sep}`) && !isAbsolute2(nested);
|
|
6976
7427
|
}
|
|
6977
7428
|
function assertSafeUninstallHome(home) {
|
|
6978
|
-
const target =
|
|
7429
|
+
const target = resolve5(home);
|
|
6979
7430
|
const canonical = canonicalExistingPath(target);
|
|
6980
7431
|
const userHome = canonicalExistingPath(homedir2());
|
|
6981
7432
|
const workingDirectory = canonicalExistingPath(process.cwd());
|
|
@@ -6996,7 +7447,7 @@ function assertSafeUninstallHome(home) {
|
|
|
6996
7447
|
}
|
|
6997
7448
|
return target;
|
|
6998
7449
|
}
|
|
6999
|
-
var uninstallCommand =
|
|
7450
|
+
var uninstallCommand = defineCommand35({
|
|
7000
7451
|
meta: {
|
|
7001
7452
|
name: "uninstall",
|
|
7002
7453
|
description: "Wipe bazilion state from ~/.bazilion (or BAZILION_HOME)"
|
|
@@ -7012,8 +7463,8 @@ var uninstallCommand = defineCommand32({
|
|
|
7012
7463
|
description: "Also remove logs and skills (full wipe)"
|
|
7013
7464
|
}
|
|
7014
7465
|
},
|
|
7015
|
-
async run({ args }) {
|
|
7016
|
-
const paths = resolveCliPaths(
|
|
7466
|
+
async run({ args: args2 }) {
|
|
7467
|
+
const paths = resolveCliPaths(args2.home);
|
|
7017
7468
|
const targetHome = assertSafeUninstallHome(paths.home);
|
|
7018
7469
|
const dbFile = join6(targetHome, "bazilion.db");
|
|
7019
7470
|
const profilesDir = join6(targetHome, "profiles");
|
|
@@ -7034,7 +7485,7 @@ var uninstallCommand = defineCommand32({
|
|
|
7034
7485
|
}
|
|
7035
7486
|
return;
|
|
7036
7487
|
}
|
|
7037
|
-
const homeIsSymlink =
|
|
7488
|
+
const homeIsSymlink = lstatSync4(targetHome).isSymbolicLink();
|
|
7038
7489
|
console.log(`about to uninstall bazilion at ${targetHome}`);
|
|
7039
7490
|
console.log("");
|
|
7040
7491
|
const resetTargets = [
|
|
@@ -7050,9 +7501,9 @@ var uninstallCommand = defineCommand32({
|
|
|
7050
7501
|
teamsDir,
|
|
7051
7502
|
legacyGroupsDir
|
|
7052
7503
|
];
|
|
7053
|
-
const needsPrompt = !
|
|
7504
|
+
const needsPrompt = !args2.yes;
|
|
7054
7505
|
const readLine = needsPrompt ? makeLineReader() : null;
|
|
7055
|
-
const wipeData =
|
|
7506
|
+
const wipeData = args2.yes || await askYes(
|
|
7056
7507
|
readLine,
|
|
7057
7508
|
"remove DB + auth/config + agent / profile / team data?"
|
|
7058
7509
|
);
|
|
@@ -7061,7 +7512,7 @@ var uninstallCommand = defineCommand32({
|
|
|
7061
7512
|
process.stdin.pause();
|
|
7062
7513
|
return;
|
|
7063
7514
|
}
|
|
7064
|
-
const wipeAll =
|
|
7515
|
+
const wipeAll = args2.all || (args2.yes ? false : await askYes(
|
|
7065
7516
|
readLine,
|
|
7066
7517
|
`also remove logs and skills? (full wipe of ${targetHome})`
|
|
7067
7518
|
));
|
|
@@ -7100,7 +7551,7 @@ var uninstallCommand = defineCommand32({
|
|
|
7100
7551
|
|
|
7101
7552
|
// src/index.ts
|
|
7102
7553
|
var VERSION = package_default.version;
|
|
7103
|
-
var main =
|
|
7554
|
+
var main = defineCommand36({
|
|
7104
7555
|
meta: {
|
|
7105
7556
|
name: "bazilion",
|
|
7106
7557
|
version: VERSION,
|