bazilion 0.14.2 → 0.15.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 +1126 -334
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +8180 -3651
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0001_init.sql +171 -3
- package/dist/web/client/assets/ChatPane-55j13bBj.js +74 -0
- package/dist/web/client/assets/{ConfirmDialog-_bmG-wVG.js → ConfirmDialog-CGZzom9E.js} +1 -1
- package/dist/web/client/assets/{FieldRow-Do1cBkRc.js → FieldRow-DYNU9gWb.js} +1 -1
- package/dist/web/client/assets/{ProductionTeamPolicyEditor-XP-QJul4.js → ProductionTeamPolicyEditor-DT5Sl8jd.js} +1 -1
- package/dist/web/client/assets/{ProfileCommunicationEditor-CwdFPdpk.js → ProfileCommunicationEditor-TyCU5vXX.js} +1 -1
- package/dist/web/client/assets/ResultCard-Cps_lXVN.js +1 -0
- package/dist/web/client/assets/ResultSourceConversation-CGhKTSTD.js +1 -0
- package/dist/web/client/assets/TeamTabs-BZHyRnbd.js +1 -0
- package/dist/web/client/assets/{TemplatesTabs-D4WHvs6b.js → TemplatesTabs-BHzkPMRC.js} +1 -1
- package/dist/web/client/assets/{UnsavedChangesGuard-B1aLqiK5.js → UnsavedChangesGuard-CFQcKsrf.js} +1 -1
- package/dist/web/client/assets/_id-9nCIhbVd.js +1 -0
- package/dist/web/client/assets/{_id-3w4PFfma.js → _id-BSu3AqKA.js} +1 -1
- package/dist/web/client/assets/_id-CGd21j3k.js +1 -0
- package/dist/web/client/assets/{_id-BH3v_vI_.js → _id-D_eKokkd.js} +1 -1
- package/dist/web/client/assets/{_id-Cx7o4Zmf.js → _id-SRMFlIgP.js} +1 -1
- package/dist/web/client/assets/{activity-A_HrG1Tv.js → activity-Cn2-9PpZ.js} +1 -1
- package/dist/web/client/assets/{agents-BeeFCt2c.js → agents-CCmiZek6.js} +1 -1
- package/dist/web/client/assets/{agents-C8OVKq3N.js → agents-NY3VrZgB.js} +1 -1
- package/dist/web/client/assets/{approvals-BIdZ9BSn.js → approvals-CPDAPgrM.js} +1 -1
- package/dist/web/client/assets/{attention-B9bUrxiU.js → attention-Qra_9_OI.js} +1 -1
- package/dist/web/client/assets/chevron-right-DXE4CWf2.js +1 -0
- package/dist/web/client/assets/{config-By86S7k-.js → config-D8EO0LPB.js} +1 -1
- package/dist/web/client/assets/{inbox-DlXQCJLe.js → inbox-C5W-sm1q.js} +1 -1
- package/dist/web/client/assets/{index-CLdmsmiN.js → index-BUhhk_u9.js} +2 -2
- package/dist/web/client/assets/{learning-BqZIw2nA.js → learning-Dr-7_7J4.js} +1 -1
- package/dist/web/client/assets/login-Bu5UxbJh.js +1 -0
- package/dist/web/client/assets/{mcp-DKSY2yVa.js → mcp-BueuwQiv.js} +1 -1
- package/dist/web/client/assets/{members-9GuOiq6J.js → members-ZikuYNcy.js} +1 -1
- package/dist/web/client/assets/{memory-DiGMI6FC.js → memory-1JUJlPrn.js} +1 -1
- package/dist/web/client/assets/{policy-TBGQffw5.js → policy-DbkhsFNA.js} +1 -1
- package/dist/web/client/assets/results-mMr8Ar2u.js +1 -0
- package/dist/web/client/assets/routes-DJYB-MS9.js +1 -0
- package/dist/web/client/assets/{services-1Z398CES.js → services-kfQA9cpJ.js} +1 -1
- package/dist/web/client/assets/{skills-BP2gciFt.js → skills-C6pcgxaC.js} +1 -1
- package/dist/web/client/assets/styles-CcNf8jT_.css +2 -0
- package/dist/web/client/assets/{teams-tNoMDJ_M.js → teams-C6_Noz5X.js} +1 -1
- package/dist/web/client/assets/{teams-DBIivGT7.js → teams-LB0KBXY9.js} +1 -1
- package/dist/web/client/assets/telegram-A2jaI1QM.js +1 -0
- package/dist/web/client/assets/{tokens-eDWCGQQ2.js → tokens-BGlUpJcL.js} +1 -1
- package/dist/web/client/assets/{triggers-DZME3IcK.js → triggers-C54_feGg.js} +1 -1
- package/dist/web/client/assets/{welcome-B49sh_uf.js → welcome-DyUIswRi.js} +1 -1
- package/dist/web/client/assets/wire-constants-CBD-lTaa.js +1 -0
- package/dist/web/client/assets/{x-CHc7_-TH.js → x-BY2MPLr9.js} +1 -1
- package/dist/web/server/assets/{ChatPane-CgSe7tsy.js → ChatPane-DJ30FdFG.js} +1122 -107
- package/dist/web/server/assets/ResultCard-B3zD9N0t.js +143 -0
- package/dist/web/server/assets/ResultSourceConversation-zYogeOWp.js +64 -0
- package/dist/web/server/assets/{TeamTabs-Co3n2exj.js → TeamTabs-TCKjCvMA.js} +4 -0
- package/dist/web/server/assets/{_id-sNu5aXZt.js → _id-1LwoHhJg.js} +2 -1
- package/dist/web/server/assets/{_id-BeKhPKw3.js → _id-1hTvnKLN2.js} +7 -3
- package/dist/web/server/assets/{_id-BAA9KJBU.js → _id-B2EEyStS.js} +1 -1
- package/dist/web/server/assets/_id-BDEpe6k0.js +6 -0
- package/dist/web/server/assets/{_id-BqWTB8Wl.js → _id-B_-CDHOi2.js} +1 -1
- package/dist/web/server/assets/{_id-DxCnEFpm.js → _id-BvSWsPI5.js} +3 -4
- package/dist/web/server/assets/{_id-ndxFHx0t.js → _id-CDBtO_jL.js} +2 -2
- package/dist/web/server/assets/{_id-DvlDkk04.js → _id-DDNVQx3y.js} +1 -1
- package/dist/web/server/assets/{_id-BYKpT2Tu.js → _id-DFHB9JFQ.js} +1 -1
- package/dist/web/server/assets/{_id-HMy7jM3P.js → _id-DxFLSIio.js} +1 -1
- package/dist/web/server/assets/{_id-DYU6uIBx.js → _id-T_8btpbB.js} +1 -1
- package/dist/web/server/assets/_id-wyjrf0JG.js +17 -0
- package/dist/web/server/assets/{_tanstack-start-manifest_v-Duhf0z7H.js → _tanstack-start-manifest_v-DP4ZUBw3.js} +102 -75
- package/dist/web/server/assets/{activity-BWv1goK6.js → activity-5fWKPDxj.js} +2 -2
- package/dist/web/server/assets/{activity-LjpblbDL.js → activity-C88qrNqv.js} +1 -1
- package/dist/web/server/assets/{activity-9VP6QDTH.js → activity-D73w4mkZ.js} +1 -1
- package/dist/web/server/assets/{agents-DjyQk94u.js → agents-DB5hCSAI.js} +1 -1
- package/dist/web/server/assets/{agents-BJAv919x.js → agents-DRSo7lRX.js} +1 -1
- package/dist/web/server/assets/{approvals-BYi84gwl.js → approvals-4y9bZF4r.js} +1 -1
- package/dist/web/server/assets/{approvals-7JOoBchn.js → approvals-DTdrltyk.js} +1 -1
- package/dist/web/server/assets/{approvals-Bz123liE.js → approvals-DXoN-T57.js} +15 -1
- package/dist/web/server/assets/{attention-UhqPK_Ro.js → attention-BFx8ZkmH.js} +1 -1
- package/dist/web/server/assets/{auth-7BHTH-KS.js → auth-_eaCwhyq.js} +1 -1
- package/dist/web/server/assets/{config-BMiajTZP.js → config-B7JIfv_7.js} +1 -1
- package/dist/web/server/assets/{daemon-client-CI5NHwNC.js → daemon-client-B06W1Qa2.js} +54 -0
- package/dist/web/server/assets/{inbox-Dv55rGYq.js → inbox-YRpDQcvp.js} +1 -1
- package/dist/web/server/assets/{learning-C2upa1CE.js → learning-UBZb6h6M.js} +1 -1
- package/dist/web/server/assets/{login-BNj3U6ok.js → login-B_-9L8TU.js} +7 -2
- package/dist/web/server/assets/{login-Be8eP4Jp.js → login-rDox7PRD.js} +5 -2
- package/dist/web/server/assets/{mcp-BvnvlVFd.js → mcp-Dv6RXMaS.js} +1 -1
- package/dist/web/server/assets/{members-BP3UTqu1.js → members-BFTKSlOe.js} +1 -1
- package/dist/web/server/assets/{members-DiYtr-zm.js → members-CD3GiTfF.js} +1 -1
- package/dist/web/server/assets/{members-DHYTVgwb.js → members-cc5SeEaW.js} +2 -2
- package/dist/web/server/assets/{memory-CkXUgf5s.js → memory-C5i_GxlY.js} +2 -2
- package/dist/web/server/assets/{memory-DTFEmfF3.js → memory-CVqnyUaM.js} +1 -1
- package/dist/web/server/assets/{memory-BqV-Afy1.js → memory-D0PQgZAn.js} +1 -1
- package/dist/web/server/assets/{policy-18fdTFO4.js → policy-C-p8HIhA.js} +1 -1
- package/dist/web/server/assets/{policy-Bvvav8fh.js → policy-Dgjb0_gK.js} +2 -2
- package/dist/web/server/assets/{policy-BddK4xom.js → policy-bLKwvnja.js} +1 -1
- package/dist/web/server/assets/results-Cfev4KNt.js +12 -0
- package/dist/web/server/assets/results-Cj-Dlw3C.js +173 -0
- package/dist/web/server/assets/results-CwEQ5EUL.js +12 -0
- package/dist/web/server/assets/{router-CY_pCgP1.js → router-d3sTMpMX.js} +60 -43
- package/dist/web/server/assets/{routes-DAU2g7Uz.js → routes-B765DVhj.js} +1 -1
- package/dist/web/server/assets/{routes-BgHisAxH.js → routes-MIZz6uMr.js} +2 -2
- package/dist/web/server/assets/{routes-COtkyZG1.js → routes-cW4MWU18.js} +3 -3
- package/dist/web/server/assets/{services-DozuJtzX.js → services-BCbdn3R9.js} +1 -1
- package/dist/web/server/assets/{skills-DfGSJTCB.js → skills-Bpoa8MIp.js} +1 -1
- package/dist/web/server/assets/{teams-be05ci17.js → teams-CXzwqzcE.js} +1 -1
- package/dist/web/server/assets/{teams-DPnAX4wD.js → teams-hWGjbpUA.js} +1 -1
- package/dist/web/server/assets/{telegram-Dj4Wwhd6.js → telegram-CoNeOgqZ.js} +465 -1
- package/dist/web/server/assets/{telegram-1AWL6lFw.js → telegram-DhpvtGUc.js} +1 -1
- package/dist/web/server/assets/{telegram-DbOFpTFm.js → telegram-Zd1rIZxg.js} +1 -1
- package/dist/web/server/assets/{tokens-DjM8GsgS.js → tokens-Bjp19Vkn.js} +1 -1
- package/dist/web/server/assets/{triggers-Nezfw-Bd.js → triggers-DJlcvXzn.js} +1 -1
- package/dist/web/server/server.js +31 -27
- package/dist/worker.js +294 -104
- package/dist/worker.js.map +1 -1
- package/package.json +3 -3
- package/dist/web/client/assets/TeamTabs-DIRiKcqx.js +0 -1
- package/dist/web/client/assets/_id-DIiVVxBl.js +0 -1
- package/dist/web/client/assets/chevron-right-VWrk_dTX.js +0 -1
- package/dist/web/client/assets/login-CCMPXiny.js +0 -1
- package/dist/web/client/assets/routes-g3yUOhCb.js +0 -1
- package/dist/web/client/assets/styles-B5vcgXln.css +0 -2
- package/dist/web/client/assets/telegram-CJG_DFdI.js +0 -1
- package/dist/web/client/assets/wire-constants-zZ7Wjb9C.js +0 -74
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 defineCommand33, 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.15.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: {
|
|
@@ -165,7 +165,70 @@ function createClient(cfg) {
|
|
|
165
165
|
}
|
|
166
166
|
if (buffer.trim()) yield JSON.parse(buffer);
|
|
167
167
|
}
|
|
168
|
+
async function binary(path) {
|
|
169
|
+
const res = await fetch(`${cfg.serverUrl}${path}`, {
|
|
170
|
+
headers: await authHeaders(),
|
|
171
|
+
redirect: "error"
|
|
172
|
+
});
|
|
173
|
+
if (!res.ok) {
|
|
174
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
175
|
+
throw new ApiClientError(res.status, err);
|
|
176
|
+
}
|
|
177
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
178
|
+
}
|
|
168
179
|
return {
|
|
180
|
+
notifications: {
|
|
181
|
+
settings: () => request("GET", "/api/notifications"),
|
|
182
|
+
configure: (input) => request("PUT", "/api/notifications", input),
|
|
183
|
+
preview: (kinds) => request("POST", "/api/notifications/preview", { kinds }),
|
|
184
|
+
list: (options = {}) => {
|
|
185
|
+
const params = new URLSearchParams();
|
|
186
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
187
|
+
if (options.limit !== void 0) params.set("limit", String(options.limit));
|
|
188
|
+
return request("GET", `/api/notifications/receipts?${params}`);
|
|
189
|
+
},
|
|
190
|
+
get: (id) => request(
|
|
191
|
+
"GET",
|
|
192
|
+
`/api/notifications/receipts/${encodeURIComponent(id)}`
|
|
193
|
+
),
|
|
194
|
+
retry: (id, input) => request(
|
|
195
|
+
"POST",
|
|
196
|
+
`/api/notifications/receipts/${encodeURIComponent(id)}/retry`,
|
|
197
|
+
input
|
|
198
|
+
)
|
|
199
|
+
},
|
|
200
|
+
questions: (agentId) => {
|
|
201
|
+
const base = `/api/agents/${encodeURIComponent(agentId)}/questions`;
|
|
202
|
+
return {
|
|
203
|
+
list: (conversationId) => request(
|
|
204
|
+
"GET",
|
|
205
|
+
conversationId ? `${base}?conversationId=${encodeURIComponent(conversationId)}` : base
|
|
206
|
+
),
|
|
207
|
+
get: (id) => request("GET", `${base}/${encodeURIComponent(id)}`),
|
|
208
|
+
answer: (id, input) => request("POST", `${base}/${encodeURIComponent(id)}/answer`, input)
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
queue: (agentId) => {
|
|
212
|
+
const base = `/api/agents/${encodeURIComponent(agentId)}/queue`;
|
|
213
|
+
const item = (id) => `${base}/${encodeURIComponent(id)}`;
|
|
214
|
+
return {
|
|
215
|
+
list: (all = false, offset = 0) => request("GET", `${base}?all=${all ? 1 : 0}&offset=${offset}`),
|
|
216
|
+
get: (id) => request("GET", item(id)),
|
|
217
|
+
input: (id) => request("GET", `${item(id)}/input`),
|
|
218
|
+
enqueue: (input) => request("POST", base, input),
|
|
219
|
+
edit: (id, input) => request("PATCH", item(id), input),
|
|
220
|
+
remove: (id, expectedRevision) => request("DELETE", item(id), { expectedRevision }),
|
|
221
|
+
pause: (paused, expectedRevision) => request("POST", `${base}/control`, { paused, expectedRevision }),
|
|
222
|
+
stop: (expectedRevision) => request("POST", `${base}/stop`, {
|
|
223
|
+
expectedRevision
|
|
224
|
+
}),
|
|
225
|
+
reconcile: (id, expectedRevision) => request("POST", `${item(id)}/reconcile`, {
|
|
226
|
+
expectedRevision,
|
|
227
|
+
acknowledged: true
|
|
228
|
+
})
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
binary,
|
|
169
232
|
get: (p) => request("GET", p),
|
|
170
233
|
post: (p, b) => request("POST", p, b),
|
|
171
234
|
postMultipart,
|
|
@@ -220,11 +283,8 @@ function createClient2(cfg = loadClientConfig()) {
|
|
|
220
283
|
return createClient({ serverUrl: cfg.serverUrl, token: cfg.token });
|
|
221
284
|
}
|
|
222
285
|
|
|
223
|
-
// src/commands/
|
|
224
|
-
import {
|
|
225
|
-
import { basename, extname } from "path";
|
|
226
|
-
import { stdin, stdout } from "process";
|
|
227
|
-
import { createInterface } from "readline/promises";
|
|
286
|
+
// src/commands/conversation.ts
|
|
287
|
+
import { randomUUID } from "crypto";
|
|
228
288
|
import { defineCommand } from "citty";
|
|
229
289
|
|
|
230
290
|
// src/columnize.ts
|
|
@@ -247,6 +307,520 @@ function columnize(rows, gap = " ") {
|
|
|
247
307
|
);
|
|
248
308
|
}
|
|
249
309
|
|
|
310
|
+
// src/commands/conversation.ts
|
|
311
|
+
var positional = { type: "positional", required: true };
|
|
312
|
+
var pathFor = (agent) => `/api/agents/${encodeURIComponent(agent)}/conversations`;
|
|
313
|
+
var list = defineCommand({
|
|
314
|
+
meta: { name: "list", description: "List retained conversations and active selection" },
|
|
315
|
+
args: {
|
|
316
|
+
agent: positional,
|
|
317
|
+
limit: { type: "string", default: "20" },
|
|
318
|
+
offset: { type: "string", default: "0" },
|
|
319
|
+
json: { type: "boolean" }
|
|
320
|
+
},
|
|
321
|
+
async run({ args }) {
|
|
322
|
+
const query = new URLSearchParams({ limit: args.limit, offset: args.offset });
|
|
323
|
+
const body = await createClient2().get(
|
|
324
|
+
`${pathFor(args.agent)}?${query}`
|
|
325
|
+
);
|
|
326
|
+
if (args.json) return console.log(JSON.stringify(body, null, 2));
|
|
327
|
+
if (!body.total) return console.log("(no conversations)");
|
|
328
|
+
for (const line of columnize([
|
|
329
|
+
["id", "title", "active"],
|
|
330
|
+
...body.conversations.map((item) => [
|
|
331
|
+
item.id,
|
|
332
|
+
item.title,
|
|
333
|
+
item.id === body.selection.conversationId ? "yes" : ""
|
|
334
|
+
])
|
|
335
|
+
]))
|
|
336
|
+
console.log(line);
|
|
337
|
+
console.log(`Selection revision: ${body.selection.revision}`);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
var show = defineCommand({
|
|
341
|
+
meta: { name: "show", description: "Read retained history without selecting it" },
|
|
342
|
+
args: { agent: positional, id: positional, json: { type: "boolean" } },
|
|
343
|
+
async run({ args }) {
|
|
344
|
+
const body = await createClient2().get(`${pathFor(args.agent)}/${encodeURIComponent(args.id)}`);
|
|
345
|
+
if (args.json) return console.log(JSON.stringify(body, null, 2));
|
|
346
|
+
console.log(body.conversation.title);
|
|
347
|
+
for (const message of body.messages) console.log(`[${message.role}] ${message.content}`);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
var newConversation = defineCommand({
|
|
351
|
+
meta: {
|
|
352
|
+
name: "new",
|
|
353
|
+
description: "Start a new conversation, retaining existing history and files"
|
|
354
|
+
},
|
|
355
|
+
args: {
|
|
356
|
+
agent: positional,
|
|
357
|
+
title: { type: "string" },
|
|
358
|
+
"request-id": { type: "string", description: "UUID for reconciling a lost response" },
|
|
359
|
+
"expected-revision": {
|
|
360
|
+
type: "string",
|
|
361
|
+
description: "Original selection revision for an exact retry"
|
|
362
|
+
},
|
|
363
|
+
"expected-conversation": {
|
|
364
|
+
type: "string",
|
|
365
|
+
description: "Original selected ID, or none for an empty selection"
|
|
366
|
+
},
|
|
367
|
+
json: { type: "boolean" }
|
|
368
|
+
},
|
|
369
|
+
async run({ args }) {
|
|
370
|
+
const client = createClient2();
|
|
371
|
+
const state = await client.get(`${pathFor(args.agent)}?limit=1`);
|
|
372
|
+
const requestId = args["request-id"] ?? randomUUID();
|
|
373
|
+
const revision = args["expected-revision"] === void 0 ? state.selection.revision : Number(args["expected-revision"]);
|
|
374
|
+
if (!Number.isSafeInteger(revision) || revision < 0)
|
|
375
|
+
throw new Error("Invalid expected revision");
|
|
376
|
+
if (args["request-id"] && (args["expected-revision"] === void 0 || args["expected-conversation"] === void 0)) {
|
|
377
|
+
throw new Error(
|
|
378
|
+
"--request-id requires --expected-revision and --expected-conversation for an exact retry"
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
const expectedSelection = {
|
|
382
|
+
revision,
|
|
383
|
+
conversationId: args["expected-conversation"] === void 0 ? state.selection.conversationId : args["expected-conversation"] === "none" ? null : args["expected-conversation"]
|
|
384
|
+
};
|
|
385
|
+
console.error(
|
|
386
|
+
`Create request: ${requestId}; retry with --request-id ${requestId} --expected-revision ${revision} --expected-conversation ${expectedSelection.conversationId ?? "none"} and the same title.`
|
|
387
|
+
);
|
|
388
|
+
const body = await client.post(pathFor(args.agent), {
|
|
389
|
+
requestId,
|
|
390
|
+
expectedSelection,
|
|
391
|
+
...args.title ? { title: args.title } : {}
|
|
392
|
+
});
|
|
393
|
+
console.log(
|
|
394
|
+
args.json ? JSON.stringify(body, null, 2) : `Conversation ${body.conversation.id}: ${body.conversation.title} (active: ${body.selection.conversationId})`
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
var rename = defineCommand({
|
|
399
|
+
meta: {
|
|
400
|
+
name: "rename",
|
|
401
|
+
description: "Rename a conversation without changing its selection or history"
|
|
402
|
+
},
|
|
403
|
+
args: { agent: positional, id: positional, title: positional, json: { type: "boolean" } },
|
|
404
|
+
async run({ args }) {
|
|
405
|
+
const client = createClient2();
|
|
406
|
+
const path = `${pathFor(args.agent)}/${encodeURIComponent(args.id)}`;
|
|
407
|
+
const current = await client.get(path);
|
|
408
|
+
const body = await client.patch(path, {
|
|
409
|
+
title: args.title,
|
|
410
|
+
expectedTitleRevision: current.conversation.titleRevision
|
|
411
|
+
});
|
|
412
|
+
console.log(args.json ? JSON.stringify(body, null, 2) : body.conversation.title);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
var conversationCommand = defineCommand({
|
|
416
|
+
meta: { name: "conversation", description: "List, read, create and rename Agent conversations" },
|
|
417
|
+
subCommands: { list, show, new: newConversation, rename }
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// src/commands/notification.ts
|
|
421
|
+
import { defineCommand as defineCommand2 } from "citty";
|
|
422
|
+
var output = (value) => console.log(JSON.stringify(value, null, 2));
|
|
423
|
+
var positional2 = { type: "positional", required: true };
|
|
424
|
+
var notificationCommand = defineCommand2({
|
|
425
|
+
meta: {
|
|
426
|
+
name: "notification",
|
|
427
|
+
description: "Configure opt-in Telegram Attention notices and inspect delivery receipts"
|
|
428
|
+
},
|
|
429
|
+
subCommands: {
|
|
430
|
+
settings: defineCommand2({
|
|
431
|
+
async run() {
|
|
432
|
+
output(await createClient2().notifications.settings());
|
|
433
|
+
}
|
|
434
|
+
}),
|
|
435
|
+
preview: defineCommand2({
|
|
436
|
+
args: {
|
|
437
|
+
kinds: {
|
|
438
|
+
type: "string",
|
|
439
|
+
description: "Comma-separated Attention kinds; defaults to current selection"
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
async run({ args }) {
|
|
443
|
+
const api = createClient2().notifications;
|
|
444
|
+
const kinds = args.kinds ? args.kinds.split(",") : (await api.settings()).settings.kinds;
|
|
445
|
+
output(await api.preview(kinds));
|
|
446
|
+
}
|
|
447
|
+
}),
|
|
448
|
+
configure: defineCommand2({
|
|
449
|
+
args: {
|
|
450
|
+
enable: { type: "boolean" },
|
|
451
|
+
disable: { type: "boolean" },
|
|
452
|
+
"destination-id": {
|
|
453
|
+
type: "string",
|
|
454
|
+
description: "Explicit verified service destination ID from settings; required with --enable"
|
|
455
|
+
},
|
|
456
|
+
kinds: { type: "string", description: "Comma-separated Attention kinds" },
|
|
457
|
+
timezone: { type: "string", description: "IANA timezone, for example Europe/Warsaw" },
|
|
458
|
+
"quiet-start": { type: "string", description: "Quiet start, HH:mm" },
|
|
459
|
+
"quiet-end": { type: "string", description: "Quiet end, HH:mm" },
|
|
460
|
+
"clear-quiet-hours": { type: "boolean" },
|
|
461
|
+
"include-open-preview": {
|
|
462
|
+
type: "string",
|
|
463
|
+
description: "Explicitly include the captured preview; restored history may duplicate Telegram messages"
|
|
464
|
+
},
|
|
465
|
+
"expected-revision": { type: "string" }
|
|
466
|
+
},
|
|
467
|
+
async run({ args }) {
|
|
468
|
+
if (args.enable && args.disable) throw new Error("Choose --enable or --disable");
|
|
469
|
+
if (args.enable && !args["destination-id"])
|
|
470
|
+
throw new Error("--enable requires --destination-id from notification settings");
|
|
471
|
+
if (Boolean(args["quiet-start"]) !== Boolean(args["quiet-end"]))
|
|
472
|
+
throw new Error("Provide both --quiet-start and --quiet-end");
|
|
473
|
+
if (args["clear-quiet-hours"] && args["quiet-start"])
|
|
474
|
+
throw new Error("Choose a quiet window or --clear-quiet-hours");
|
|
475
|
+
const api = createClient2().notifications;
|
|
476
|
+
const { settings } = await api.settings();
|
|
477
|
+
output(
|
|
478
|
+
await api.configure({
|
|
479
|
+
expectedRevision: args["expected-revision"] === void 0 ? settings.revision : Number(args["expected-revision"]),
|
|
480
|
+
enabled: args.enable ? true : args.disable ? false : settings.enabled,
|
|
481
|
+
destinationId: args["destination-id"] ?? settings.destination?.id,
|
|
482
|
+
kinds: args.kinds ? args.kinds.split(",") : settings.kinds,
|
|
483
|
+
timezone: args.timezone ?? settings.timezone,
|
|
484
|
+
quietHours: args["clear-quiet-hours"] ? null : args["quiet-start"] && args["quiet-end"] ? { start: args["quiet-start"], end: args["quiet-end"] } : settings.quietHours,
|
|
485
|
+
includeOpenPreview: args["include-open-preview"]
|
|
486
|
+
})
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
}),
|
|
490
|
+
list: defineCommand2({
|
|
491
|
+
args: { cursor: { type: "string" }, limit: { type: "string" } },
|
|
492
|
+
async run({ args }) {
|
|
493
|
+
output(
|
|
494
|
+
await createClient2().notifications.list({
|
|
495
|
+
cursor: args.cursor,
|
|
496
|
+
limit: args.limit === void 0 ? void 0 : Number(args.limit)
|
|
497
|
+
})
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
}),
|
|
501
|
+
show: defineCommand2({
|
|
502
|
+
args: { id: positional2 },
|
|
503
|
+
async run({ args }) {
|
|
504
|
+
output(await createClient2().notifications.get(args.id));
|
|
505
|
+
}
|
|
506
|
+
}),
|
|
507
|
+
retry: defineCommand2({
|
|
508
|
+
args: {
|
|
509
|
+
id: positional2,
|
|
510
|
+
"acknowledge-possible-duplicate": {
|
|
511
|
+
type: "boolean",
|
|
512
|
+
description: "Telegram may already have received this notice"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
async run({ args }) {
|
|
516
|
+
if (!args["acknowledge-possible-duplicate"])
|
|
517
|
+
throw new Error("Explicit retry requires --acknowledge-possible-duplicate");
|
|
518
|
+
const api = createClient2().notifications;
|
|
519
|
+
const receipt = await api.get(args.id);
|
|
520
|
+
output(
|
|
521
|
+
await api.retry(args.id, {
|
|
522
|
+
expectedUpdatedAt: receipt.updatedAt,
|
|
523
|
+
acknowledgePossibleDuplicate: true
|
|
524
|
+
})
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// src/commands/question.ts
|
|
532
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
533
|
+
import { defineCommand as defineCommand3 } from "citty";
|
|
534
|
+
var positional3 = { type: "positional", required: true };
|
|
535
|
+
var output2 = (value) => console.log(JSON.stringify(value, null, 2));
|
|
536
|
+
function questionAnswer(args) {
|
|
537
|
+
const count = Number(args.choice !== void 0) + Number(args.text !== void 0) + Number(args.skip === true);
|
|
538
|
+
if (count !== 1) throw new Error("Specify exactly one of --choice, --text, or --skip");
|
|
539
|
+
if (args.skip) return { kind: "skip" };
|
|
540
|
+
if (args.text !== void 0) {
|
|
541
|
+
if (!args.text.trim() || Buffer.byteLength(args.text, "utf8") > 4096)
|
|
542
|
+
throw new Error("Answer text must contain 1\u20134096 UTF-8 bytes");
|
|
543
|
+
return { kind: "text", text: args.text };
|
|
544
|
+
}
|
|
545
|
+
if (!/^[1-4]$/.test(args.choice ?? "")) throw new Error("--choice must be a number from 1 to 4");
|
|
546
|
+
return { kind: "choice", index: Number(args.choice) - 1 };
|
|
547
|
+
}
|
|
548
|
+
var questionCommand = defineCommand3({
|
|
549
|
+
meta: {
|
|
550
|
+
name: "question",
|
|
551
|
+
description: "Inspect and answer an Agent clarification; answers grant no permissions"
|
|
552
|
+
},
|
|
553
|
+
subCommands: {
|
|
554
|
+
list: defineCommand3({
|
|
555
|
+
args: { agent: positional3, conversation: { type: "string" } },
|
|
556
|
+
async run({ args }) {
|
|
557
|
+
output2(await createClient2().questions(args.agent).list(args.conversation));
|
|
558
|
+
}
|
|
559
|
+
}),
|
|
560
|
+
show: defineCommand3({
|
|
561
|
+
args: { agent: positional3, id: positional3 },
|
|
562
|
+
async run({ args }) {
|
|
563
|
+
output2(await createClient2().questions(args.agent).get(args.id));
|
|
564
|
+
}
|
|
565
|
+
}),
|
|
566
|
+
answer: defineCommand3({
|
|
567
|
+
args: {
|
|
568
|
+
agent: positional3,
|
|
569
|
+
id: positional3,
|
|
570
|
+
choice: { type: "string", description: "Choice number, starting at 1" },
|
|
571
|
+
text: { type: "string", description: "Free-text answer" },
|
|
572
|
+
skip: { type: "boolean", description: "Continue without an answer" },
|
|
573
|
+
"request-id": { type: "string", description: "Reuse the original UUID for an exact retry" },
|
|
574
|
+
conversation: {
|
|
575
|
+
type: "string",
|
|
576
|
+
description: "Original conversation ID; required for retries"
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
async run({ args }) {
|
|
580
|
+
const answer = questionAnswer(args);
|
|
581
|
+
if (args["request-id"] && !args.conversation)
|
|
582
|
+
throw new Error("Retry requires the original --conversation and identical answer");
|
|
583
|
+
const client = createClient2().questions(args.agent);
|
|
584
|
+
const observed = await client.get(args.id);
|
|
585
|
+
const conversationId = args.conversation ?? observed.conversationId;
|
|
586
|
+
if (conversationId !== observed.conversationId)
|
|
587
|
+
throw new Error("Question conversation differs");
|
|
588
|
+
if (answer.kind === "choice" && answer.index >= observed.question.choices.length)
|
|
589
|
+
throw new Error("That choice does not exist for this question");
|
|
590
|
+
const requestId = args["request-id"] ?? randomUUID2();
|
|
591
|
+
console.error(
|
|
592
|
+
`Question request: ${requestId}; exact retry uses --request-id ${requestId} --conversation ${conversationId} and the same answer. Acceptance does not prove consumption or task completion.`
|
|
593
|
+
);
|
|
594
|
+
output2(await client.answer(args.id, { requestId, conversationId, answer }));
|
|
595
|
+
}
|
|
596
|
+
})
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
// src/commands/queue.ts
|
|
601
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
602
|
+
import { readFileSync as readFileSync2, statSync } from "fs";
|
|
603
|
+
import { basename, extname } from "path";
|
|
604
|
+
import { defineCommand as defineCommand4 } from "citty";
|
|
605
|
+
var positional4 = { type: "positional", required: true };
|
|
606
|
+
var output3 = (value) => console.log(JSON.stringify(value, null, 2));
|
|
607
|
+
var common = { agent: positional4 };
|
|
608
|
+
var entry = { ...common, id: positional4 };
|
|
609
|
+
var expected = {
|
|
610
|
+
type: "string",
|
|
611
|
+
required: true,
|
|
612
|
+
description: "Revision observed in queue list/show"
|
|
613
|
+
};
|
|
614
|
+
var list2 = defineCommand4({
|
|
615
|
+
args: { ...common, all: { type: "boolean" }, offset: { type: "string", default: "0" } },
|
|
616
|
+
async run({ args }) {
|
|
617
|
+
output3(await createClient2().queue(args.agent).list(args.all, Number(args.offset)));
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
var show2 = defineCommand4({
|
|
621
|
+
args: entry,
|
|
622
|
+
async run({ args }) {
|
|
623
|
+
output3(await createClient2().queue(args.agent).get(args.id));
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
var enqueueArgs = {
|
|
627
|
+
...common,
|
|
628
|
+
message: { type: "string" },
|
|
629
|
+
files: {
|
|
630
|
+
type: "string",
|
|
631
|
+
description: "JSON array of local file paths, at most 16 and 25 MiB combined"
|
|
632
|
+
},
|
|
633
|
+
"request-id": { type: "string" },
|
|
634
|
+
"expected-conversation": {
|
|
635
|
+
type: "string",
|
|
636
|
+
description: "Original target ID, or none; required for retries"
|
|
637
|
+
},
|
|
638
|
+
"expected-selection-revision": {
|
|
639
|
+
type: "string",
|
|
640
|
+
description: "Original selection revision; required for retries"
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
async function submit(args, replacement) {
|
|
644
|
+
const client = createClient2();
|
|
645
|
+
const agentId = String(args.agent);
|
|
646
|
+
if (args["request-id"] && (args["expected-conversation"] === void 0 || args["expected-selection-revision"] === void 0))
|
|
647
|
+
throw new Error(
|
|
648
|
+
"Exact retry requires --expected-conversation and --expected-selection-revision"
|
|
649
|
+
);
|
|
650
|
+
const observed = await client.get(
|
|
651
|
+
`/api/agents/${encodeURIComponent(agentId)}/conversations?limit=1`
|
|
652
|
+
);
|
|
653
|
+
const requestId = typeof args["request-id"] === "string" ? args["request-id"] : randomUUID3();
|
|
654
|
+
const expectedSelection = {
|
|
655
|
+
conversationId: args["expected-conversation"] === void 0 ? observed.selection.conversationId : args["expected-conversation"] === "none" ? null : String(args["expected-conversation"]),
|
|
656
|
+
revision: args["expected-selection-revision"] === void 0 ? observed.selection.revision : Number(args["expected-selection-revision"])
|
|
657
|
+
};
|
|
658
|
+
const paths = args.files ? JSON.parse(String(args.files)) : [];
|
|
659
|
+
if (!Array.isArray(paths) || paths.length > 16 || paths.some((p) => typeof p !== "string"))
|
|
660
|
+
throw new Error("--files must be a JSON array of at most 16 paths");
|
|
661
|
+
let bytes = 0;
|
|
662
|
+
const original = replacement && (args.files === void 0 || args.message === void 0) ? await client.queue(agentId).input(replacement.id) : void 0;
|
|
663
|
+
const attachments = args.files === void 0 && original ? original.attachments : paths.map((path) => {
|
|
664
|
+
const stat = statSync(path);
|
|
665
|
+
bytes += stat.size;
|
|
666
|
+
if (!stat.isFile() || bytes > 25 * 1024 * 1024)
|
|
667
|
+
throw new Error("Files must total at most 25 MiB");
|
|
668
|
+
const mime = {
|
|
669
|
+
".png": "image/png",
|
|
670
|
+
".jpg": "image/jpeg",
|
|
671
|
+
".jpeg": "image/jpeg",
|
|
672
|
+
".webp": "image/webp",
|
|
673
|
+
".gif": "image/gif",
|
|
674
|
+
".txt": "text/plain",
|
|
675
|
+
".pdf": "application/pdf"
|
|
676
|
+
};
|
|
677
|
+
return {
|
|
678
|
+
name: basename(path),
|
|
679
|
+
mimeType: mime[extname(path).toLowerCase()] ?? "application/octet-stream",
|
|
680
|
+
data: readFileSync2(path).toString("base64")
|
|
681
|
+
};
|
|
682
|
+
});
|
|
683
|
+
console.error(
|
|
684
|
+
`Queue request: ${requestId}; retry with --request-id ${requestId} --expected-conversation ${expectedSelection.conversationId ?? "none"} --expected-selection-revision ${expectedSelection.revision} and identical message/files${replacement ? " and original --expected-revision" : ""}.`
|
|
685
|
+
);
|
|
686
|
+
const input = {
|
|
687
|
+
requestId,
|
|
688
|
+
expectedSelection,
|
|
689
|
+
message: String(args.message ?? original?.message ?? ""),
|
|
690
|
+
attachments
|
|
691
|
+
};
|
|
692
|
+
output3(
|
|
693
|
+
replacement ? await client.queue(agentId).edit(replacement.id, { ...input, expectedRevision: replacement.expectedRevision }) : await client.queue(agentId).enqueue(input)
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
var add = defineCommand4({
|
|
697
|
+
args: enqueueArgs,
|
|
698
|
+
async run({ args }) {
|
|
699
|
+
await submit(args);
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
var edit = defineCommand4({
|
|
703
|
+
args: { ...enqueueArgs, id: positional4, "expected-revision": expected },
|
|
704
|
+
async run({ args }) {
|
|
705
|
+
await submit(args, { id: args.id, expectedRevision: Number(args["expected-revision"]) });
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
var remove = defineCommand4({
|
|
709
|
+
args: { ...entry, "expected-revision": expected },
|
|
710
|
+
async run({ args }) {
|
|
711
|
+
output3(
|
|
712
|
+
await createClient2().queue(args.agent).remove(args.id, Number(args["expected-revision"]))
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
var control = (paused) => defineCommand4({
|
|
717
|
+
args: { ...common, "expected-revision": expected },
|
|
718
|
+
async run({ args }) {
|
|
719
|
+
output3(
|
|
720
|
+
await createClient2().queue(args.agent).pause(paused, Number(args["expected-revision"]))
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
var stop = defineCommand4({
|
|
725
|
+
args: { ...common, "expected-revision": expected },
|
|
726
|
+
async run({ args }) {
|
|
727
|
+
output3(await createClient2().queue(args.agent).stop(Number(args["expected-revision"])));
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
var reconcile = defineCommand4({
|
|
731
|
+
args: {
|
|
732
|
+
...entry,
|
|
733
|
+
"expected-revision": expected,
|
|
734
|
+
acknowledge: {
|
|
735
|
+
type: "boolean",
|
|
736
|
+
description: "Acknowledge this input may already have acted; close without replay"
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
async run({ args }) {
|
|
740
|
+
if (!args.acknowledge)
|
|
741
|
+
throw new Error("--acknowledge is required; this input may already have acted");
|
|
742
|
+
output3(
|
|
743
|
+
await createClient2().queue(args.agent).reconcile(args.id, Number(args["expected-revision"]))
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
var queueCommand = defineCommand4({
|
|
748
|
+
meta: {
|
|
749
|
+
name: "queue",
|
|
750
|
+
description: "Retain follow-ups, inspect delivery and control future claims"
|
|
751
|
+
},
|
|
752
|
+
subCommands: {
|
|
753
|
+
list: list2,
|
|
754
|
+
show: show2,
|
|
755
|
+
add,
|
|
756
|
+
edit,
|
|
757
|
+
remove,
|
|
758
|
+
pause: control(true),
|
|
759
|
+
resume: control(false),
|
|
760
|
+
stop,
|
|
761
|
+
reconcile
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
// src/commands/agent.ts
|
|
766
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
767
|
+
import { readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
768
|
+
import { basename as basename2, extname as extname2 } from "path";
|
|
769
|
+
import { stdin, stdout } from "process";
|
|
770
|
+
import { createInterface } from "readline/promises";
|
|
771
|
+
import { defineCommand as defineCommand5 } from "citty";
|
|
772
|
+
|
|
773
|
+
// src/question-prompt.ts
|
|
774
|
+
function safe(text2) {
|
|
775
|
+
return Array.from(text2, (character) => {
|
|
776
|
+
const code = character.charCodeAt(0);
|
|
777
|
+
return code < 32 && code !== 10 || code >= 127 && code <= 159 ? `\\x${code.toString(16).padStart(2, "0")}` : character;
|
|
778
|
+
}).join("");
|
|
779
|
+
}
|
|
780
|
+
function hasAnswerControl(text2) {
|
|
781
|
+
return Array.from(text2).some((character) => {
|
|
782
|
+
const code = character.charCodeAt(0);
|
|
783
|
+
return code < 32 && ![9, 10, 13].includes(code) || code >= 127 && code <= 159;
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
async function promptForQuestion(item, prompt) {
|
|
787
|
+
if (item.status !== "pending" || item.expiresAt <= Date.now()) return null;
|
|
788
|
+
const controller = new AbortController();
|
|
789
|
+
const timer = setTimeout(() => controller.abort(), Math.max(1, item.expiresAt - Date.now()));
|
|
790
|
+
timer.unref();
|
|
791
|
+
try {
|
|
792
|
+
prompt.write(`Question ${item.id} (conversation ${item.conversationId})`);
|
|
793
|
+
prompt.write(safe(item.question.prompt));
|
|
794
|
+
item.question.choices.forEach((choice, index) => {
|
|
795
|
+
prompt.write(
|
|
796
|
+
`${index + 1}. ${safe(choice.label)}${index === item.question.recommendedIndex ? " (Recommended)" : ""}`
|
|
797
|
+
);
|
|
798
|
+
if (choice.description) prompt.write(` ${safe(choice.description)}`);
|
|
799
|
+
});
|
|
800
|
+
prompt.write("Choose a number, o for Other, or s to Skip. Answers do not grant permission.");
|
|
801
|
+
while (!controller.signal.aborted) {
|
|
802
|
+
const value = (await prompt.question("Answer: ", controller.signal)).trim();
|
|
803
|
+
if (controller.signal.aborted) return null;
|
|
804
|
+
if (value.toLowerCase() === "s") return { kind: "skip" };
|
|
805
|
+
if (/^[1-4]$/.test(value) && Number(value) <= item.question.choices.length)
|
|
806
|
+
return { kind: "choice", index: Number(value) - 1 };
|
|
807
|
+
if (value.toLowerCase() === "o") {
|
|
808
|
+
const text2 = await prompt.question("Your answer: ", controller.signal);
|
|
809
|
+
if (controller.signal.aborted) return null;
|
|
810
|
+
if (text2.trim() && Buffer.byteLength(text2, "utf8") <= 4096 && !hasAnswerControl(text2))
|
|
811
|
+
return { kind: "text", text: text2 };
|
|
812
|
+
prompt.write("Enter 1\u20134096 UTF-8 bytes without control characters.");
|
|
813
|
+
} else prompt.write("Choose an explicit number, o, or s; no answer is selected by default.");
|
|
814
|
+
}
|
|
815
|
+
return null;
|
|
816
|
+
} catch {
|
|
817
|
+
prompt.write("Question prompt closed or expired. No answer was submitted.");
|
|
818
|
+
return null;
|
|
819
|
+
} finally {
|
|
820
|
+
clearTimeout(timer);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
250
824
|
// src/commands/agent.ts
|
|
251
825
|
var IMAGE_MIME = {
|
|
252
826
|
".png": "image/png",
|
|
@@ -257,9 +831,9 @@ var IMAGE_MIME = {
|
|
|
257
831
|
};
|
|
258
832
|
function loadImages(paths) {
|
|
259
833
|
return paths.map((p) => {
|
|
260
|
-
const mimeType = IMAGE_MIME[
|
|
834
|
+
const mimeType = IMAGE_MIME[extname2(p).toLowerCase()];
|
|
261
835
|
if (!mimeType) throw new Error(`unsupported image type: ${p} (png/jpg/gif/webp only)`);
|
|
262
|
-
return { name:
|
|
836
|
+
return { name: basename2(p), mimeType, data: readFileSync3(p).toString("base64") };
|
|
263
837
|
});
|
|
264
838
|
}
|
|
265
839
|
var FILE_MIME = {
|
|
@@ -273,15 +847,15 @@ var FILE_MIME = {
|
|
|
273
847
|
};
|
|
274
848
|
function loadFiles(paths) {
|
|
275
849
|
return paths.map((p) => ({
|
|
276
|
-
name:
|
|
277
|
-
mimeType: FILE_MIME[
|
|
278
|
-
data:
|
|
850
|
+
name: basename2(p),
|
|
851
|
+
mimeType: FILE_MIME[extname2(p).toLowerCase()] ?? "application/octet-stream",
|
|
852
|
+
data: readFileSync3(p).toString("base64")
|
|
279
853
|
}));
|
|
280
854
|
}
|
|
281
855
|
function asPaths(v) {
|
|
282
856
|
return v ? Array.isArray(v) ? v : [v] : [];
|
|
283
857
|
}
|
|
284
|
-
var spawnCmd =
|
|
858
|
+
var spawnCmd = defineCommand5({
|
|
285
859
|
meta: { name: "spawn", description: "Spawn an agent from a profile into a team" },
|
|
286
860
|
args: {
|
|
287
861
|
profile: { type: "string", required: true, description: "Profile id" },
|
|
@@ -317,7 +891,7 @@ var spawnCmd = defineCommand({
|
|
|
317
891
|
console.log(`dir: ${agent.dir}`);
|
|
318
892
|
}
|
|
319
893
|
});
|
|
320
|
-
var editCmd =
|
|
894
|
+
var editCmd = defineCommand5({
|
|
321
895
|
meta: {
|
|
322
896
|
name: "edit",
|
|
323
897
|
description: "Edit agent settings (name, model override, reasoning level, telegram mirror)"
|
|
@@ -367,7 +941,7 @@ var editCmd = defineCommand({
|
|
|
367
941
|
console.log(`updated agent ${agent.id} (${agent.name})`);
|
|
368
942
|
}
|
|
369
943
|
});
|
|
370
|
-
var listCmd =
|
|
944
|
+
var listCmd = defineCommand5({
|
|
371
945
|
meta: { name: "list", description: "List agents" },
|
|
372
946
|
args: {
|
|
373
947
|
all: { type: "boolean", description: "Include archived agents" },
|
|
@@ -376,12 +950,12 @@ var listCmd = defineCommand({
|
|
|
376
950
|
async run({ args }) {
|
|
377
951
|
const client = createClient2();
|
|
378
952
|
const q = args.all ? "?includeArchived=true" : "";
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
953
|
+
const list8 = await client.get(`/api/agents${q}`);
|
|
954
|
+
if (list8.length === 0) {
|
|
381
955
|
console.log("(no agents)");
|
|
382
956
|
return;
|
|
383
957
|
}
|
|
384
|
-
const rows =
|
|
958
|
+
const rows = list8.map(
|
|
385
959
|
(a) => args.long ? [a.id, a.status, a.name, a.profileId] : (
|
|
386
960
|
// Short UUID prefix — all CLI commands accept 4+ char prefixes now.
|
|
387
961
|
[a.id.slice(0, 8), a.status, a.name]
|
|
@@ -390,7 +964,7 @@ var listCmd = defineCommand({
|
|
|
390
964
|
for (const line of columnize(rows)) console.log(line);
|
|
391
965
|
}
|
|
392
966
|
});
|
|
393
|
-
var showCmd =
|
|
967
|
+
var showCmd = defineCommand5({
|
|
394
968
|
meta: { name: "show", description: "Show agent details" },
|
|
395
969
|
args: {
|
|
396
970
|
id: { type: "positional", required: true }
|
|
@@ -413,7 +987,7 @@ var showCmd = defineCommand({
|
|
|
413
987
|
}
|
|
414
988
|
}
|
|
415
989
|
});
|
|
416
|
-
var archiveCmd =
|
|
990
|
+
var archiveCmd = defineCommand5({
|
|
417
991
|
meta: { name: "archive", description: "Archive an agent" },
|
|
418
992
|
args: {
|
|
419
993
|
id: { type: "positional", required: true }
|
|
@@ -424,7 +998,7 @@ var archiveCmd = defineCommand({
|
|
|
424
998
|
console.log(`archived agent ${args.id}`);
|
|
425
999
|
}
|
|
426
1000
|
});
|
|
427
|
-
var unarchiveCmd =
|
|
1001
|
+
var unarchiveCmd = defineCommand5({
|
|
428
1002
|
meta: { name: "unarchive", description: "Restore an archived agent to idle" },
|
|
429
1003
|
args: {
|
|
430
1004
|
id: { type: "positional", required: true }
|
|
@@ -435,7 +1009,7 @@ var unarchiveCmd = defineCommand({
|
|
|
435
1009
|
console.log(`unarchived agent ${args.id}`);
|
|
436
1010
|
}
|
|
437
1011
|
});
|
|
438
|
-
var deleteCmd =
|
|
1012
|
+
var deleteCmd = defineCommand5({
|
|
439
1013
|
meta: { name: "delete", description: "Permanently delete an agent and its data" },
|
|
440
1014
|
args: {
|
|
441
1015
|
id: { type: "positional", required: true }
|
|
@@ -463,13 +1037,13 @@ function buildChatRequest(message, attachments, bashApprovalMode) {
|
|
|
463
1037
|
};
|
|
464
1038
|
}
|
|
465
1039
|
function terminalSafe(value) {
|
|
466
|
-
let
|
|
1040
|
+
let safe2 = "";
|
|
467
1041
|
for (const character of value) {
|
|
468
1042
|
const code = character.charCodeAt(0);
|
|
469
1043
|
const isControl = code <= 9 || code >= 11 && code <= 31 || code >= 127 && code <= 159;
|
|
470
|
-
|
|
1044
|
+
safe2 += isControl ? `\\x${code.toString(16).padStart(2, "0")}` : character;
|
|
471
1045
|
}
|
|
472
|
-
return
|
|
1046
|
+
return safe2;
|
|
473
1047
|
}
|
|
474
1048
|
async function promptForCommandApproval(approval, prompt) {
|
|
475
1049
|
prompt.write(" [shell command approval required]");
|
|
@@ -552,7 +1126,7 @@ function printEvent(e, state) {
|
|
|
552
1126
|
process.stdout.write("\n");
|
|
553
1127
|
state.inDeltaStream = false;
|
|
554
1128
|
}
|
|
555
|
-
const out =
|
|
1129
|
+
const out = basename2(e.name).replace(/[^\w.-]/g, "_") || "file";
|
|
556
1130
|
writeFileSync(out, Buffer.from(e.data, "base64"));
|
|
557
1131
|
console.log(` [file received: saved to ./${out} (${e.mimeType})]`);
|
|
558
1132
|
break;
|
|
@@ -567,13 +1141,15 @@ function printEvent(e, state) {
|
|
|
567
1141
|
}
|
|
568
1142
|
}
|
|
569
1143
|
async function streamTurn(client, agentId, message, attachments, options = { bashApprovalMode: "auto_deny" }) {
|
|
1144
|
+
const head = await client.get(`/api/agents/${agentId}/sessions/head`);
|
|
570
1145
|
const state = { inDeltaStream: false };
|
|
571
1146
|
const respondedApprovalIds = /* @__PURE__ */ new Set();
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
1147
|
+
const promptedQuestionIds = /* @__PURE__ */ new Set();
|
|
1148
|
+
for await (const frame of client.stream("POST", `/api/agents/${agentId}/chat`, {
|
|
1149
|
+
...buildChatRequest(message, attachments, options.bashApprovalMode),
|
|
1150
|
+
...options.questionPrompt ? { questionMode: "tty" } : {},
|
|
1151
|
+
expectedSelection: options.expectedSelection ?? head.selection
|
|
1152
|
+
})) {
|
|
577
1153
|
if (frame.kind === "event") {
|
|
578
1154
|
const event = frame.event;
|
|
579
1155
|
if (event.type === "command_approval") {
|
|
@@ -587,6 +1163,33 @@ async function streamTurn(client, agentId, message, attachments, options = { bas
|
|
|
587
1163
|
} else {
|
|
588
1164
|
printCommandApprovalStatus(approval);
|
|
589
1165
|
}
|
|
1166
|
+
} else if (event.type === "agent_question") {
|
|
1167
|
+
closeDeltaLine(state);
|
|
1168
|
+
const item = event.question;
|
|
1169
|
+
if (item.agentId !== agentId || promptedQuestionIds.has(item.id)) continue;
|
|
1170
|
+
promptedQuestionIds.add(item.id);
|
|
1171
|
+
if (!options.questionPrompt) {
|
|
1172
|
+
console.log(
|
|
1173
|
+
`Question ${item.id}: use bazilion question show ${agentId} ${item.id} in a separate terminal.`
|
|
1174
|
+
);
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
const answer = await promptForQuestion(item, options.questionPrompt);
|
|
1178
|
+
if (!answer) continue;
|
|
1179
|
+
const requestId = randomUUID4();
|
|
1180
|
+
console.error(
|
|
1181
|
+
`Question request ${requestId}; exact retry uses bazilion question answer ${agentId} ${item.id} --request-id ${requestId} --conversation ${item.conversationId} and the same answer option.`
|
|
1182
|
+
);
|
|
1183
|
+
try {
|
|
1184
|
+
const result = await client.questions(agentId).answer(item.id, { requestId, conversationId: item.conversationId, answer });
|
|
1185
|
+
console.log(
|
|
1186
|
+
result.kind === "held" ? "Answer awaits communication approval; it has not reached the Agent." : "Answer accepted; consumption and task completion are separate."
|
|
1187
|
+
);
|
|
1188
|
+
} catch {
|
|
1189
|
+
console.error(
|
|
1190
|
+
"Answer acknowledgement unavailable. Inspect the question before retrying the exact request above."
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
590
1193
|
} else if (event.type !== "user_message") {
|
|
591
1194
|
printEvent(event, state);
|
|
592
1195
|
}
|
|
@@ -596,7 +1199,7 @@ async function streamTurn(client, agentId, message, attachments, options = { bas
|
|
|
596
1199
|
}
|
|
597
1200
|
}
|
|
598
1201
|
}
|
|
599
|
-
var chatCmd =
|
|
1202
|
+
var chatCmd = defineCommand5({
|
|
600
1203
|
meta: { name: "chat", description: "Chat with an agent" },
|
|
601
1204
|
args: {
|
|
602
1205
|
id: { type: "positional", required: true },
|
|
@@ -630,6 +1233,10 @@ var chatCmd = defineCommand({
|
|
|
630
1233
|
approvalPrompt: {
|
|
631
1234
|
question: (question) => rl2.question(question),
|
|
632
1235
|
write: (line) => console.log(line)
|
|
1236
|
+
},
|
|
1237
|
+
questionPrompt: {
|
|
1238
|
+
question: (text2, signal) => rl2.question(text2, { signal }),
|
|
1239
|
+
write: (line) => console.log(line)
|
|
633
1240
|
}
|
|
634
1241
|
} : {}
|
|
635
1242
|
});
|
|
@@ -643,10 +1250,19 @@ var chatCmd = defineCommand({
|
|
|
643
1250
|
const rl = createInterface({ input: stdin, output: stdout });
|
|
644
1251
|
try {
|
|
645
1252
|
if (bashApprovalMode === "interactive") {
|
|
1253
|
+
let retryDraft = "";
|
|
646
1254
|
while (true) {
|
|
1255
|
+
const observed = await client.get(
|
|
1256
|
+
`/api/agents/${resolved.agent.id}/sessions/head`
|
|
1257
|
+
);
|
|
647
1258
|
let line;
|
|
648
1259
|
try {
|
|
649
|
-
|
|
1260
|
+
const answer = rl.question("> ");
|
|
1261
|
+
if (retryDraft) {
|
|
1262
|
+
rl.write(retryDraft);
|
|
1263
|
+
retryDraft = "";
|
|
1264
|
+
}
|
|
1265
|
+
line = await answer;
|
|
650
1266
|
} catch {
|
|
651
1267
|
break;
|
|
652
1268
|
}
|
|
@@ -656,13 +1272,21 @@ var chatCmd = defineCommand({
|
|
|
656
1272
|
try {
|
|
657
1273
|
await streamTurn(client, resolved.agent.id, trimmed, void 0, {
|
|
658
1274
|
bashApprovalMode,
|
|
1275
|
+
expectedSelection: observed.selection,
|
|
1276
|
+
questionPrompt: {
|
|
1277
|
+
question: (text2, signal) => rl.question(text2, { signal }),
|
|
1278
|
+
write: (line2) => console.log(line2)
|
|
1279
|
+
},
|
|
659
1280
|
approvalPrompt: {
|
|
660
1281
|
question: (question) => rl.question(question),
|
|
661
|
-
write: (
|
|
1282
|
+
write: (output4) => console.log(output4)
|
|
662
1283
|
}
|
|
663
1284
|
});
|
|
664
1285
|
} catch (err) {
|
|
665
|
-
|
|
1286
|
+
retryDraft = trimmed;
|
|
1287
|
+
console.error(
|
|
1288
|
+
`error: ${err.message}. Review the preserved draft before retrying.`
|
|
1289
|
+
);
|
|
666
1290
|
}
|
|
667
1291
|
}
|
|
668
1292
|
} else {
|
|
@@ -690,29 +1314,7 @@ var chatCmd = defineCommand({
|
|
|
690
1314
|
}
|
|
691
1315
|
}
|
|
692
1316
|
});
|
|
693
|
-
var
|
|
694
|
-
meta: { name: "chat-reset", description: "Reset an agent's chat history to empty" },
|
|
695
|
-
args: {
|
|
696
|
-
id: { type: "positional", required: true },
|
|
697
|
-
force: { type: "boolean", description: "Skip the y/N prompt" }
|
|
698
|
-
},
|
|
699
|
-
async run({ args }) {
|
|
700
|
-
if (!args.force) {
|
|
701
|
-
process.stdout.write(`reset all chat history for ${args.id}? [y/N] `);
|
|
702
|
-
const answer = await new Promise((resolve5) => {
|
|
703
|
-
process.stdin.once("data", (d) => resolve5(String(d).trim().toLowerCase()));
|
|
704
|
-
});
|
|
705
|
-
if (answer !== "y" && answer !== "yes") {
|
|
706
|
-
console.log("aborted");
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
const client = createClient2();
|
|
711
|
-
await client.post(`/api/agents/${args.id}/chat/reset`);
|
|
712
|
-
console.log(`reset chat history for ${args.id}`);
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
var chatTrimCmd = defineCommand({
|
|
1317
|
+
var chatTrimCmd = defineCommand5({
|
|
716
1318
|
meta: {
|
|
717
1319
|
name: "chat-trim",
|
|
718
1320
|
description: "Keep the first N messages of an agent's chat history; drop the rest"
|
|
@@ -727,7 +1329,8 @@ var chatTrimCmd = defineCommand({
|
|
|
727
1329
|
throw new Error("--keep must be a non-negative integer");
|
|
728
1330
|
}
|
|
729
1331
|
const client = createClient2();
|
|
730
|
-
const
|
|
1332
|
+
const head = await client.get(`/api/agents/${args.id}/sessions/head`);
|
|
1333
|
+
const body = { keepCount: n, expectedSelection: head.selection };
|
|
731
1334
|
const res = await client.post(
|
|
732
1335
|
`/api/agents/${args.id}/chat/truncate`,
|
|
733
1336
|
body
|
|
@@ -742,7 +1345,7 @@ function formatBytes(n) {
|
|
|
742
1345
|
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KiB`;
|
|
743
1346
|
return `${(n / (1024 * 1024)).toFixed(2)} MiB`;
|
|
744
1347
|
}
|
|
745
|
-
var chatContextCmd =
|
|
1348
|
+
var chatContextCmd = defineCommand5({
|
|
746
1349
|
meta: {
|
|
747
1350
|
name: "chat-context",
|
|
748
1351
|
description: "Break down what consumes the agent's context window"
|
|
@@ -826,7 +1429,7 @@ var chatContextCmd = defineCommand({
|
|
|
826
1429
|
function estimate(chars) {
|
|
827
1430
|
return Math.ceil(Math.max(0, chars) / 4);
|
|
828
1431
|
}
|
|
829
|
-
var chatCompactCmd =
|
|
1432
|
+
var chatCompactCmd = defineCommand5({
|
|
830
1433
|
meta: {
|
|
831
1434
|
name: "chat-compact",
|
|
832
1435
|
description: "Summarize the head of an agent's chat log, preserving the tail verbatim"
|
|
@@ -866,6 +1469,8 @@ var chatCompactCmd = defineCommand({
|
|
|
866
1469
|
if (keepTailNum !== void 0) body.keepTail = Math.floor(keepTailNum);
|
|
867
1470
|
if (args.instructions) body.customInstructions = args.instructions;
|
|
868
1471
|
const client = createClient2();
|
|
1472
|
+
const head = await client.get(`/api/agents/${args.id}/sessions/head`);
|
|
1473
|
+
body.expectedSelection = head.selection;
|
|
869
1474
|
const res = await client.post(`/api/agents/${args.id}/chat/compact`, body);
|
|
870
1475
|
console.log(
|
|
871
1476
|
`compacted: ${res.before} \u2192 ${res.after} entries (${res.summarized} summarized, ${res.keptTail} tail kept verbatim)`
|
|
@@ -878,7 +1483,7 @@ var chatCompactCmd = defineCommand({
|
|
|
878
1483
|
console.log(res.summary);
|
|
879
1484
|
}
|
|
880
1485
|
});
|
|
881
|
-
var skillAddCmd =
|
|
1486
|
+
var skillAddCmd = defineCommand5({
|
|
882
1487
|
meta: { name: "add", description: "Attach a skill to an agent" },
|
|
883
1488
|
args: {
|
|
884
1489
|
agent: { type: "positional", required: true },
|
|
@@ -914,7 +1519,7 @@ function printSkillFindings(findings) {
|
|
|
914
1519
|
console.error(` ${f.severity}: ${f.code}${line} - ${f.message}`);
|
|
915
1520
|
}
|
|
916
1521
|
}
|
|
917
|
-
var skillRmCmd =
|
|
1522
|
+
var skillRmCmd = defineCommand5({
|
|
918
1523
|
meta: { name: "rm", description: "Detach a skill from an agent" },
|
|
919
1524
|
args: {
|
|
920
1525
|
agent: { type: "positional", required: true },
|
|
@@ -926,14 +1531,14 @@ var skillRmCmd = defineCommand({
|
|
|
926
1531
|
console.log(`detached skill ${args.skill} from ${args.agent}`);
|
|
927
1532
|
}
|
|
928
1533
|
});
|
|
929
|
-
var skillCmd =
|
|
1534
|
+
var skillCmd = defineCommand5({
|
|
930
1535
|
meta: { name: "skill", description: "Attach/detach skills on an agent" },
|
|
931
1536
|
subCommands: {
|
|
932
1537
|
add: skillAddCmd,
|
|
933
1538
|
rm: skillRmCmd
|
|
934
1539
|
}
|
|
935
1540
|
});
|
|
936
|
-
var moveCmd =
|
|
1541
|
+
var moveCmd = defineCommand5({
|
|
937
1542
|
meta: { name: "move", description: "Move an agent to a different team" },
|
|
938
1543
|
args: {
|
|
939
1544
|
agent: { type: "positional", required: true },
|
|
@@ -958,7 +1563,7 @@ var moveCmd = defineCommand({
|
|
|
958
1563
|
console.log(`moved ${args.agent} to team ${args.team}`);
|
|
959
1564
|
}
|
|
960
1565
|
});
|
|
961
|
-
var sessionHeadCmd =
|
|
1566
|
+
var sessionHeadCmd = defineCommand5({
|
|
962
1567
|
meta: {
|
|
963
1568
|
name: "session-head",
|
|
964
1569
|
description: "Print the agent's current session file head (for stale-tab checks)"
|
|
@@ -977,7 +1582,7 @@ var sessionHeadCmd = defineCommand({
|
|
|
977
1582
|
console.log(head.file ? `${head.file} (${head.size} bytes)` : "(no session yet)");
|
|
978
1583
|
}
|
|
979
1584
|
});
|
|
980
|
-
var cancelCmd =
|
|
1585
|
+
var cancelCmd = defineCommand5({
|
|
981
1586
|
meta: { name: "cancel", description: "Abort the agent's currently-running turn" },
|
|
982
1587
|
args: {
|
|
983
1588
|
id: { type: "positional", required: true }
|
|
@@ -988,7 +1593,7 @@ var cancelCmd = defineCommand({
|
|
|
988
1593
|
console.log(`cancelled active turn for ${args.id}`);
|
|
989
1594
|
}
|
|
990
1595
|
});
|
|
991
|
-
var reviewConfigCmd =
|
|
1596
|
+
var reviewConfigCmd = defineCommand5({
|
|
992
1597
|
meta: { name: "review-config", description: "Inspect or configure reviewed learning" },
|
|
993
1598
|
args: {
|
|
994
1599
|
id: { type: "positional", required: true, description: "Agent id or prefix" },
|
|
@@ -1023,7 +1628,7 @@ var reviewConfigCmd = defineCommand({
|
|
|
1023
1628
|
console.log(`turns since last review: ${config.turnsSinceLast}`);
|
|
1024
1629
|
}
|
|
1025
1630
|
});
|
|
1026
|
-
var reviewCmd =
|
|
1631
|
+
var reviewCmd = defineCommand5({
|
|
1027
1632
|
meta: { name: "review", description: "Enqueue a reviewed-learning pass" },
|
|
1028
1633
|
args: { id: { type: "positional", required: true, description: "Agent id or prefix" } },
|
|
1029
1634
|
async run({ args }) {
|
|
@@ -1033,7 +1638,7 @@ var reviewCmd = defineCommand({
|
|
|
1033
1638
|
console.log(`review ${response.review.id} ${response.review.status}`);
|
|
1034
1639
|
}
|
|
1035
1640
|
});
|
|
1036
|
-
var reviewsCmd =
|
|
1641
|
+
var reviewsCmd = defineCommand5({
|
|
1037
1642
|
meta: { name: "reviews", description: "List reviewed-learning history" },
|
|
1038
1643
|
args: {
|
|
1039
1644
|
id: { type: "positional", required: true, description: "Agent id or prefix" },
|
|
@@ -1058,7 +1663,7 @@ var reviewsCmd = defineCommand({
|
|
|
1058
1663
|
}
|
|
1059
1664
|
}
|
|
1060
1665
|
});
|
|
1061
|
-
var lessonsCmd =
|
|
1666
|
+
var lessonsCmd = defineCommand5({
|
|
1062
1667
|
meta: { name: "lessons", description: "List reviewed lesson proposals" },
|
|
1063
1668
|
args: {
|
|
1064
1669
|
id: { type: "positional", required: true, description: "Agent id or prefix" },
|
|
@@ -1096,7 +1701,7 @@ async function locateProposal(id) {
|
|
|
1096
1701
|
throw new Error(`lesson proposal not found: ${id}`);
|
|
1097
1702
|
}
|
|
1098
1703
|
function lessonDecisionCmd(decision2) {
|
|
1099
|
-
return
|
|
1704
|
+
return defineCommand5({
|
|
1100
1705
|
meta: { name: decision2, description: `${decision2} a reviewed lesson proposal` },
|
|
1101
1706
|
args: {
|
|
1102
1707
|
id: { type: "positional", required: true, description: "Proposal id or prefix" },
|
|
@@ -1113,7 +1718,7 @@ function lessonDecisionCmd(decision2) {
|
|
|
1113
1718
|
}
|
|
1114
1719
|
});
|
|
1115
1720
|
}
|
|
1116
|
-
var lessonEditCmd =
|
|
1721
|
+
var lessonEditCmd = defineCommand5({
|
|
1117
1722
|
meta: { name: "edit", description: "Edit a pending reviewed lesson proposal" },
|
|
1118
1723
|
args: {
|
|
1119
1724
|
id: { type: "positional", required: true, description: "Proposal id or prefix" },
|
|
@@ -1132,7 +1737,7 @@ var lessonEditCmd = defineCommand({
|
|
|
1132
1737
|
console.log(`updated ${response.proposal.id} v${response.proposal.version}`);
|
|
1133
1738
|
}
|
|
1134
1739
|
});
|
|
1135
|
-
var lessonCmd =
|
|
1740
|
+
var lessonCmd = defineCommand5({
|
|
1136
1741
|
meta: { name: "lesson", description: "Edit or decide a reviewed lesson proposal" },
|
|
1137
1742
|
subCommands: {
|
|
1138
1743
|
edit: lessonEditCmd,
|
|
@@ -1141,7 +1746,7 @@ var lessonCmd = defineCommand({
|
|
|
1141
1746
|
revoke: lessonDecisionCmd("revoke")
|
|
1142
1747
|
}
|
|
1143
1748
|
});
|
|
1144
|
-
var agentCommand =
|
|
1749
|
+
var agentCommand = defineCommand5({
|
|
1145
1750
|
meta: { name: "agent", description: "Manage agent instances" },
|
|
1146
1751
|
subCommands: {
|
|
1147
1752
|
spawn: spawnCmd,
|
|
@@ -1152,7 +1757,6 @@ var agentCommand = defineCommand({
|
|
|
1152
1757
|
unarchive: unarchiveCmd,
|
|
1153
1758
|
delete: deleteCmd,
|
|
1154
1759
|
chat: chatCmd,
|
|
1155
|
-
"chat-reset": chatResetCmd,
|
|
1156
1760
|
"chat-trim": chatTrimCmd,
|
|
1157
1761
|
"chat-context": chatContextCmd,
|
|
1158
1762
|
"chat-compact": chatCompactCmd,
|
|
@@ -1169,8 +1773,8 @@ var agentCommand = defineCommand({
|
|
|
1169
1773
|
});
|
|
1170
1774
|
|
|
1171
1775
|
// src/commands/approval.ts
|
|
1172
|
-
import { defineCommand as
|
|
1173
|
-
var
|
|
1776
|
+
import { defineCommand as defineCommand6 } from "citty";
|
|
1777
|
+
var list3 = defineCommand6({
|
|
1174
1778
|
meta: { name: "list", description: "List communication approval queue/history" },
|
|
1175
1779
|
args: {
|
|
1176
1780
|
status: { type: "string", default: "pending" },
|
|
@@ -1198,7 +1802,7 @@ var list = defineCommand2({
|
|
|
1198
1802
|
console.log(line);
|
|
1199
1803
|
}
|
|
1200
1804
|
});
|
|
1201
|
-
var
|
|
1805
|
+
var show3 = defineCommand6({
|
|
1202
1806
|
meta: { name: "show", description: "Show one approval including payload and audit events" },
|
|
1203
1807
|
args: { id: { type: "positional", required: true }, json: { type: "boolean" } },
|
|
1204
1808
|
async run({ args }) {
|
|
@@ -1219,7 +1823,7 @@ var show = defineCommand2({
|
|
|
1219
1823
|
}
|
|
1220
1824
|
});
|
|
1221
1825
|
function decision(name) {
|
|
1222
|
-
return
|
|
1826
|
+
return defineCommand6({
|
|
1223
1827
|
meta: {
|
|
1224
1828
|
name,
|
|
1225
1829
|
description: name === "approve" ? "Approve and deliver one captured attempt" : `${name === "deny" ? "Deny" : "Cancel"} one pending attempt`
|
|
@@ -1244,11 +1848,11 @@ function decision(name) {
|
|
|
1244
1848
|
function endpoint(value) {
|
|
1245
1849
|
return value.kind === "agent" ? `agent:${value.id}` : value.kind === "user" ? `user:${value.teamId}` : `outside:${value.teamId}`;
|
|
1246
1850
|
}
|
|
1247
|
-
var approvalCommand =
|
|
1851
|
+
var approvalCommand = defineCommand6({
|
|
1248
1852
|
meta: { name: "approval", description: "Manage communication approval queue and history" },
|
|
1249
1853
|
subCommands: {
|
|
1250
|
-
list,
|
|
1251
|
-
show,
|
|
1854
|
+
list: list3,
|
|
1855
|
+
show: show3,
|
|
1252
1856
|
approve: decision("approve"),
|
|
1253
1857
|
deny: decision("deny"),
|
|
1254
1858
|
cancel: decision("cancel")
|
|
@@ -1256,8 +1860,8 @@ var approvalCommand = defineCommand2({
|
|
|
1256
1860
|
});
|
|
1257
1861
|
|
|
1258
1862
|
// src/commands/attention.ts
|
|
1259
|
-
import { defineCommand as
|
|
1260
|
-
var
|
|
1863
|
+
import { defineCommand as defineCommand7 } from "citty";
|
|
1864
|
+
var list4 = defineCommand7({
|
|
1261
1865
|
meta: { name: "list", description: "List operator attention items" },
|
|
1262
1866
|
args: {
|
|
1263
1867
|
state: { type: "string", default: "open" },
|
|
@@ -1286,7 +1890,7 @@ var list2 = defineCommand3({
|
|
|
1286
1890
|
console.error(`warning: ${source.kind} unavailable: ${source.error}`);
|
|
1287
1891
|
}
|
|
1288
1892
|
});
|
|
1289
|
-
var summary =
|
|
1893
|
+
var summary = defineCommand7({
|
|
1290
1894
|
meta: { name: "summary", description: "Summarize open attention items" },
|
|
1291
1895
|
args: { json: { type: "boolean" } },
|
|
1292
1896
|
async run({ args }) {
|
|
@@ -1299,7 +1903,7 @@ var summary = defineCommand3({
|
|
|
1299
1903
|
}
|
|
1300
1904
|
});
|
|
1301
1905
|
function mutation(name) {
|
|
1302
|
-
return
|
|
1906
|
+
return defineCommand7({
|
|
1303
1907
|
meta: { name, description: `${name} one informational attention item` },
|
|
1304
1908
|
args: {
|
|
1305
1909
|
key: { type: "positional", required: true },
|
|
@@ -1315,7 +1919,7 @@ function mutation(name) {
|
|
|
1315
1919
|
}
|
|
1316
1920
|
});
|
|
1317
1921
|
}
|
|
1318
|
-
var acknowledgeAll =
|
|
1922
|
+
var acknowledgeAll = defineCommand7({
|
|
1319
1923
|
meta: { name: "acknowledge-all", description: "Acknowledge all open informational items" },
|
|
1320
1924
|
args: { yes: { type: "boolean" }, json: { type: "boolean" } },
|
|
1321
1925
|
async run({ args }) {
|
|
@@ -1330,10 +1934,10 @@ var acknowledgeAll = defineCommand3({
|
|
|
1330
1934
|
function context(item) {
|
|
1331
1935
|
return [item.agentName, item.teamName].filter(Boolean).join(" / ") || "system";
|
|
1332
1936
|
}
|
|
1333
|
-
var attentionCommand =
|
|
1937
|
+
var attentionCommand = defineCommand7({
|
|
1334
1938
|
meta: { name: "attention", description: "Inspect the operator attention center" },
|
|
1335
1939
|
subCommands: {
|
|
1336
|
-
list:
|
|
1940
|
+
list: list4,
|
|
1337
1941
|
summary,
|
|
1338
1942
|
acknowledge: mutation("acknowledge"),
|
|
1339
1943
|
unacknowledge: mutation("unacknowledge"),
|
|
@@ -1343,7 +1947,7 @@ var attentionCommand = defineCommand3({
|
|
|
1343
1947
|
|
|
1344
1948
|
// src/commands/auth.ts
|
|
1345
1949
|
import { openaiCodexProvider } from "@earendil-works/pi-ai/providers/openai-codex";
|
|
1346
|
-
import { defineCommand as
|
|
1950
|
+
import { defineCommand as defineCommand8 } from "citty";
|
|
1347
1951
|
var CLI_OPENAI_LOGIN_TIMEOUT_MS = 10 * 6e4;
|
|
1348
1952
|
function createCliOpenAILoginLifetime(timeoutMs = CLI_OPENAI_LOGIN_TIMEOUT_MS) {
|
|
1349
1953
|
const controller = new AbortController();
|
|
@@ -1365,7 +1969,7 @@ function createCliOpenAILoginLifetime(timeoutMs = CLI_OPENAI_LOGIN_TIMEOUT_MS) {
|
|
|
1365
1969
|
function promptAbortError(signal) {
|
|
1366
1970
|
return signal.reason instanceof Error ? signal.reason : new DOMException("OAuth prompt cancelled", "AbortError");
|
|
1367
1971
|
}
|
|
1368
|
-
function answerCliOpenAIPrompt(prompt, input = process.stdin,
|
|
1972
|
+
function answerCliOpenAIPrompt(prompt, input = process.stdin, output4 = process.stdout, loginMethod = "browser", loginSignal) {
|
|
1369
1973
|
if (prompt.type === "select") {
|
|
1370
1974
|
const option = prompt.options.find((candidate) => candidate.id === loginMethod);
|
|
1371
1975
|
return option ? Promise.resolve(option.id) : Promise.reject(
|
|
@@ -1374,7 +1978,7 @@ function answerCliOpenAIPrompt(prompt, input = process.stdin, output = process.s
|
|
|
1374
1978
|
)
|
|
1375
1979
|
);
|
|
1376
1980
|
}
|
|
1377
|
-
|
|
1981
|
+
output4.write(`${prompt.message}: `);
|
|
1378
1982
|
return new Promise((resolve5, reject) => {
|
|
1379
1983
|
let settled = false;
|
|
1380
1984
|
const signal = prompt.signal;
|
|
@@ -1434,7 +2038,7 @@ function formatExpiry(ms) {
|
|
|
1434
2038
|
const d = new Date(ms);
|
|
1435
2039
|
return d.toISOString().replace(/\.\d+Z$/, "Z");
|
|
1436
2040
|
}
|
|
1437
|
-
var openaiLoginCmd =
|
|
2041
|
+
var openaiLoginCmd = defineCommand8({
|
|
1438
2042
|
meta: {
|
|
1439
2043
|
name: "login",
|
|
1440
2044
|
description: "Connect your ChatGPT account via OAuth"
|
|
@@ -1501,7 +2105,7 @@ var openaiLoginCmd = defineCommand4({
|
|
|
1501
2105
|
console.log(" bazilion provider models-set openai-codex gpt-5.3-codex-spark");
|
|
1502
2106
|
}
|
|
1503
2107
|
});
|
|
1504
|
-
var openaiLogoutCmd =
|
|
2108
|
+
var openaiLogoutCmd = defineCommand8({
|
|
1505
2109
|
meta: {
|
|
1506
2110
|
name: "logout",
|
|
1507
2111
|
description: "Forget the stored ChatGPT OAuth credentials"
|
|
@@ -1512,7 +2116,7 @@ var openaiLogoutCmd = defineCommand4({
|
|
|
1512
2116
|
console.log("disconnected ChatGPT OAuth credentials");
|
|
1513
2117
|
}
|
|
1514
2118
|
});
|
|
1515
|
-
var openaiStatusCmd =
|
|
2119
|
+
var openaiStatusCmd = defineCommand8({
|
|
1516
2120
|
meta: {
|
|
1517
2121
|
name: "status",
|
|
1518
2122
|
description: "Show ChatGPT OAuth connection status"
|
|
@@ -1529,7 +2133,7 @@ var openaiStatusCmd = defineCommand4({
|
|
|
1529
2133
|
console.log(`access token expires: ${formatExpiry(status.expiresAt)}`);
|
|
1530
2134
|
}
|
|
1531
2135
|
});
|
|
1532
|
-
var openaiCmd =
|
|
2136
|
+
var openaiCmd = defineCommand8({
|
|
1533
2137
|
meta: {
|
|
1534
2138
|
name: "openai",
|
|
1535
2139
|
description: "Manage ChatGPT (OAuth) authentication"
|
|
@@ -1540,7 +2144,7 @@ var openaiCmd = defineCommand4({
|
|
|
1540
2144
|
status: openaiStatusCmd
|
|
1541
2145
|
}
|
|
1542
2146
|
});
|
|
1543
|
-
var authCommand =
|
|
2147
|
+
var authCommand = defineCommand8({
|
|
1544
2148
|
meta: {
|
|
1545
2149
|
name: "auth",
|
|
1546
2150
|
description: "OAuth-based provider authentication (ChatGPT account, etc.)"
|
|
@@ -1557,7 +2161,7 @@ import {
|
|
|
1557
2161
|
createHash as createHash3,
|
|
1558
2162
|
pbkdf2Sync,
|
|
1559
2163
|
randomBytes,
|
|
1560
|
-
randomUUID as
|
|
2164
|
+
randomUUID as randomUUID7
|
|
1561
2165
|
} from "crypto";
|
|
1562
2166
|
import {
|
|
1563
2167
|
chmodSync as chmodSync2,
|
|
@@ -1573,26 +2177,112 @@ import {
|
|
|
1573
2177
|
mkdtempSync,
|
|
1574
2178
|
openSync as openSync2,
|
|
1575
2179
|
readdirSync,
|
|
1576
|
-
readFileSync as
|
|
2180
|
+
readFileSync as readFileSync5,
|
|
1577
2181
|
readSync,
|
|
1578
2182
|
renameSync as renameSync2,
|
|
1579
2183
|
rmSync as rmSync2,
|
|
1580
2184
|
writeFileSync as writeFileSync2
|
|
1581
2185
|
} from "fs";
|
|
1582
2186
|
import { tmpdir } from "os";
|
|
1583
|
-
import { basename as
|
|
1584
|
-
import { DatabaseSync, backup as sqliteBackup } from "node:sqlite";
|
|
2187
|
+
import { basename as basename4, dirname as dirname2, isAbsolute, parse, posix, relative, resolve as resolve2 } from "path";
|
|
2188
|
+
import { DatabaseSync as DatabaseSync2, backup as sqliteBackup } from "node:sqlite";
|
|
1585
2189
|
import { Readable } from "stream";
|
|
1586
2190
|
import { pipeline } from "stream/promises";
|
|
1587
2191
|
import { Decrypter, Encrypter } from "age-encryption";
|
|
1588
|
-
import { defineCommand as
|
|
1589
|
-
import { extract, list as
|
|
2192
|
+
import { defineCommand as defineCommand9 } from "citty";
|
|
2193
|
+
import { extract, list as list5 } from "tar";
|
|
2194
|
+
|
|
2195
|
+
// src/backup-queue-recovery.ts
|
|
2196
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
2197
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2198
|
+
function pauseRestoredUserQueue(database) {
|
|
2199
|
+
const db = new DatabaseSync(database);
|
|
2200
|
+
try {
|
|
2201
|
+
db.exec("PRAGMA foreign_keys = ON");
|
|
2202
|
+
db.exec("PRAGMA journal_mode = DELETE");
|
|
2203
|
+
db.exec("PRAGMA synchronous = FULL");
|
|
2204
|
+
db.exec("BEGIN IMMEDIATE");
|
|
2205
|
+
try {
|
|
2206
|
+
const unresolved = "status IN ('pending','claimed','running','held','uncertain')";
|
|
2207
|
+
db.exec(`INSERT OR IGNORE INTO user_queue_controls (agent_id)
|
|
2208
|
+
SELECT DISTINCT agent_id FROM user_queue_items WHERE ${unresolved}`);
|
|
2209
|
+
db.exec(`UPDATE user_queue_controls SET paused = 1, revision = revision + 1,
|
|
2210
|
+
reason = 'restored_backup' WHERE agent_id IN
|
|
2211
|
+
(SELECT agent_id FROM user_queue_items WHERE ${unresolved})`);
|
|
2212
|
+
const now = Date.now();
|
|
2213
|
+
db.prepare(`INSERT INTO notification_settings
|
|
2214
|
+
(singleton, restore_paused, restore_history_uncertain, kinds_json, updated_at) VALUES (1, 1, 1, ?, ?)
|
|
2215
|
+
ON CONFLICT(singleton) DO UPDATE SET enabled=0, restore_paused=1, restore_history_uncertain=1,
|
|
2216
|
+
revision=revision+1, updated_at=MAX(updated_at+1, excluded.updated_at)`).run(
|
|
2217
|
+
JSON.stringify([
|
|
2218
|
+
"communication_approval",
|
|
2219
|
+
"lesson_proposal",
|
|
2220
|
+
"review_failure",
|
|
2221
|
+
"trigger_failure",
|
|
2222
|
+
"agent_loop_break"
|
|
2223
|
+
]),
|
|
2224
|
+
now
|
|
2225
|
+
);
|
|
2226
|
+
db.prepare(`UPDATE notification_receipts SET state='uncertain', diagnostic='restored_backup',
|
|
2227
|
+
updated_at=MAX(updated_at+1, ?) WHERE state='sending'`).run(now);
|
|
2228
|
+
db.prepare(`UPDATE notification_receipts SET state='suppressed', diagnostic='restore_paused',
|
|
2229
|
+
updated_at=MAX(updated_at+1, ?) WHERE state='deferred'`).run(now);
|
|
2230
|
+
db.prepare(`UPDATE agent_questions SET status = 'cancelled', no_answer_reason = 'restored_backup',
|
|
2231
|
+
settled_at = ?, continuation = 'interrupted', revision = revision + 1 WHERE status = 'pending'`).run(
|
|
2232
|
+
now
|
|
2233
|
+
);
|
|
2234
|
+
db.exec(`UPDATE agent_questions SET continuation = 'interrupted', revision = revision + 1
|
|
2235
|
+
WHERE continuation = 'unconfirmed'`);
|
|
2236
|
+
const questionApprovals = db.prepare(`SELECT DISTINCT a.id FROM communication_approvals a
|
|
2237
|
+
JOIN agent_questions q ON a.id IN (q.delivery_approval_id, q.answer_approval_id)
|
|
2238
|
+
WHERE q.status != 'pending' AND a.status = 'pending'
|
|
2239
|
+
AND a.payload_kind IN ('question_delivery', 'question_answer')`).all();
|
|
2240
|
+
for (const approval of questionApprovals) {
|
|
2241
|
+
db.prepare(`UPDATE communication_approvals SET status = 'cancelled', decided_at = ?,
|
|
2242
|
+
decided_by = 'system', decision_reason = 'Restored question has no live continuation',
|
|
2243
|
+
updated_at = ? WHERE id = ? AND status = 'pending'`).run(now, now, approval.id);
|
|
2244
|
+
db.prepare(`INSERT INTO communication_approval_events (id, approval_id, event, actor, detail, created_at)
|
|
2245
|
+
VALUES (?, ?, 'cancelled', 'system', 'Restored question has no live continuation', ?)`).run(
|
|
2246
|
+
randomUUID5(),
|
|
2247
|
+
approval.id,
|
|
2248
|
+
now
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
db.prepare(`UPDATE user_queue_items SET status = 'uncertain', revision = revision + 1,
|
|
2252
|
+
diagnostic = 'Restored backup: this input may already have acted; reconcile before resuming',
|
|
2253
|
+
updated_at = ?, finished_at = ? WHERE ${unresolved}`).run(now, now);
|
|
2254
|
+
db.exec("COMMIT");
|
|
2255
|
+
} catch (error) {
|
|
2256
|
+
db.exec("ROLLBACK");
|
|
2257
|
+
throw error;
|
|
2258
|
+
}
|
|
2259
|
+
} finally {
|
|
2260
|
+
db.close();
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
1590
2263
|
|
|
1591
2264
|
// src/backup-schema.ts
|
|
1592
2265
|
import { createHash } from "crypto";
|
|
1593
2266
|
var CANONICAL_MIGRATION = "0001_init";
|
|
1594
|
-
var CANONICAL_SCHEMA_HASH = "
|
|
2267
|
+
var CANONICAL_SCHEMA_HASH = "278a7649d6017011b97405306760af3fdd337f068693e24b18cab43421a0c723";
|
|
1595
2268
|
var CANONICAL_OBJECTS = [
|
|
2269
|
+
["table", "notification_settings"],
|
|
2270
|
+
["table", "notification_receipts"],
|
|
2271
|
+
["index", "notification_receipts_state"],
|
|
2272
|
+
["index", "notification_receipts_time"],
|
|
2273
|
+
["table", "agent_questions"],
|
|
2274
|
+
["table", "question_receipt_key"],
|
|
2275
|
+
["index", "agent_questions_one_pending"],
|
|
2276
|
+
["index", "agent_questions_agent_time"],
|
|
2277
|
+
["table", "user_queue_controls"],
|
|
2278
|
+
["table", "user_queue_items"],
|
|
2279
|
+
["table", "user_queue_attachments"],
|
|
2280
|
+
["index", "user_queue_agent_order"],
|
|
2281
|
+
["index", "user_queue_status"],
|
|
2282
|
+
["index", "agent_conversations_agent_time"],
|
|
2283
|
+
["table", "agent_conversations"],
|
|
2284
|
+
["table", "agent_conversation_selection"],
|
|
2285
|
+
["index", "agent_results_team_time"],
|
|
1596
2286
|
["index", "agent_triggers_agent"],
|
|
1597
2287
|
["index", "agent_triggers_enabled"],
|
|
1598
2288
|
["index", "agent_loop_break_events_agent_time"],
|
|
@@ -1618,6 +2308,7 @@ var CANONICAL_OBJECTS = [
|
|
|
1618
2308
|
["index", "web_tokens_active"],
|
|
1619
2309
|
["index", "web_sessions_active"],
|
|
1620
2310
|
["index", "web_sessions_device"],
|
|
2311
|
+
["table", "agent_results"],
|
|
1621
2312
|
["table", "agent_skills"],
|
|
1622
2313
|
["table", "agent_loop_break_events"],
|
|
1623
2314
|
["table", "agent_lesson_proposals"],
|
|
@@ -1700,10 +2391,16 @@ function assertCanonicalBackupSchema(db) {
|
|
|
1700
2391
|
"canonical schema fingerprint does not match this Bazilion release; restore a backup created from the current clean-install schema"
|
|
1701
2392
|
);
|
|
1702
2393
|
}
|
|
2394
|
+
for (const row2 of db.prepare("SELECT id, bytes, byte_length, sha256 FROM agent_results WHERE deleted_at IS NULL").iterate()) {
|
|
2395
|
+
const bytes = row2.bytes;
|
|
2396
|
+
if (!(bytes instanceof Uint8Array) || bytes.byteLength !== row2.byte_length || createHash("sha256").update(bytes).digest("hex") !== row2.sha256) {
|
|
2397
|
+
throw new Error(`Result snapshot integrity verification failed: ${row2.id}`);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
1703
2400
|
}
|
|
1704
2401
|
|
|
1705
2402
|
// src/daemon-liveness.ts
|
|
1706
|
-
import { createHash as createHash2, randomUUID } from "crypto";
|
|
2403
|
+
import { createHash as createHash2, randomUUID as randomUUID6 } from "crypto";
|
|
1707
2404
|
import {
|
|
1708
2405
|
chmodSync,
|
|
1709
2406
|
closeSync,
|
|
@@ -1714,13 +2411,13 @@ import {
|
|
|
1714
2411
|
lstatSync,
|
|
1715
2412
|
mkdirSync,
|
|
1716
2413
|
openSync,
|
|
1717
|
-
readFileSync as
|
|
2414
|
+
readFileSync as readFileSync4,
|
|
1718
2415
|
realpathSync,
|
|
1719
2416
|
renameSync,
|
|
1720
2417
|
rmSync,
|
|
1721
2418
|
writeSync
|
|
1722
2419
|
} from "fs";
|
|
1723
|
-
import { basename as
|
|
2420
|
+
import { basename as basename3, dirname, join as join2, resolve } from "path";
|
|
1724
2421
|
var DAEMON_LIVENESS_FILENAME = "daemon-runtime.json";
|
|
1725
2422
|
var STALE_AFTER_MS = 6e4;
|
|
1726
2423
|
var PROBE_TIMEOUT_MS = 750;
|
|
@@ -1732,7 +2429,7 @@ function canonicalHomeIdentity(home) {
|
|
|
1732
2429
|
if (errorCode(error) !== "ENOENT") throw error;
|
|
1733
2430
|
const parent = dirname(absolute);
|
|
1734
2431
|
if (parent === absolute) throw error;
|
|
1735
|
-
return join2(canonicalHomeIdentity(parent),
|
|
2432
|
+
return join2(canonicalHomeIdentity(parent), basename3(absolute));
|
|
1736
2433
|
}
|
|
1737
2434
|
}
|
|
1738
2435
|
function daemonLivenessPath(home) {
|
|
@@ -1776,7 +2473,7 @@ function parseRecord(raw) {
|
|
|
1776
2473
|
function readRecord(path) {
|
|
1777
2474
|
try {
|
|
1778
2475
|
const stat = lstatSync(path);
|
|
1779
|
-
const raw = stat.isFile() ?
|
|
2476
|
+
const raw = stat.isFile() ? readFileSync4(path, "utf8") : "";
|
|
1780
2477
|
return { raw, stat, record: stat.isFile() ? parseRecord(raw) : null };
|
|
1781
2478
|
} catch (error) {
|
|
1782
2479
|
if (errorCode(error) === "ENOENT") return null;
|
|
@@ -1867,7 +2564,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
|
1867
2564
|
mkdirSync(dirname(targetHome), { recursive: true });
|
|
1868
2565
|
const path = daemonLivenessPath(targetHome);
|
|
1869
2566
|
mkdirSync(dirname(path), { recursive: true });
|
|
1870
|
-
const instanceId =
|
|
2567
|
+
const instanceId = randomUUID6();
|
|
1871
2568
|
let fd = null;
|
|
1872
2569
|
let reclaimClaim = null;
|
|
1873
2570
|
for (let attempt = 0; attempt < 8 && fd === null; attempt++) {
|
|
@@ -2032,7 +2729,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
|
|
|
2032
2729
|
}
|
|
2033
2730
|
|
|
2034
2731
|
// src/commands/backup.ts
|
|
2035
|
-
var createCmd =
|
|
2732
|
+
var createCmd = defineCommand9({
|
|
2036
2733
|
meta: { name: "create", description: "Create a client-side encrypted backup of ~/.bazilion" },
|
|
2037
2734
|
args: {
|
|
2038
2735
|
output: {
|
|
@@ -2112,7 +2809,7 @@ var createCmd = defineCommand5({
|
|
|
2112
2809
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "EXDEV") throw error;
|
|
2113
2810
|
const installPartial = resolve2(
|
|
2114
2811
|
dirname2(outAbs),
|
|
2115
|
-
`.${
|
|
2812
|
+
`.${basename4(outAbs)}.${randomUUID7()}.installing`
|
|
2116
2813
|
);
|
|
2117
2814
|
try {
|
|
2118
2815
|
copyFileSync(partial, installPartial);
|
|
@@ -2219,37 +2916,37 @@ function validateArchiveSymbolicLink(path, rawTarget) {
|
|
|
2219
2916
|
}
|
|
2220
2917
|
async function validateArchive(file) {
|
|
2221
2918
|
const entries = [];
|
|
2222
|
-
await
|
|
2919
|
+
await list5({
|
|
2223
2920
|
file,
|
|
2224
2921
|
strict: true,
|
|
2225
|
-
onentry(
|
|
2226
|
-
if (
|
|
2227
|
-
const path = normalizeArchivePath(
|
|
2922
|
+
onentry(entry3) {
|
|
2923
|
+
if (entry3.meta) return;
|
|
2924
|
+
const path = normalizeArchivePath(entry3.path);
|
|
2228
2925
|
if (!path) return;
|
|
2229
|
-
if (!EXTRACTABLE_ENTRY_TYPES.has(
|
|
2230
|
-
throw new Error(`backup contains unsupported ${
|
|
2926
|
+
if (!EXTRACTABLE_ENTRY_TYPES.has(entry3.type)) {
|
|
2927
|
+
throw new Error(`backup contains unsupported ${entry3.type} entry: ${path}`);
|
|
2231
2928
|
}
|
|
2232
|
-
if (
|
|
2233
|
-
validateArchiveSymbolicLink(path,
|
|
2929
|
+
if (entry3.type === "SymbolicLink") {
|
|
2930
|
+
validateArchiveSymbolicLink(path, entry3.linkpath);
|
|
2234
2931
|
}
|
|
2235
|
-
entries.push({ path, type:
|
|
2932
|
+
entries.push({ path, type: entry3.type, linkpath: entry3.linkpath });
|
|
2236
2933
|
}
|
|
2237
2934
|
});
|
|
2238
2935
|
return validateArchiveEntries(entries);
|
|
2239
2936
|
}
|
|
2240
2937
|
async function validateArchiveReadable(stream) {
|
|
2241
2938
|
const entries = [];
|
|
2242
|
-
const parser =
|
|
2939
|
+
const parser = list5({
|
|
2243
2940
|
strict: true,
|
|
2244
|
-
onentry(
|
|
2245
|
-
if (
|
|
2246
|
-
const path = normalizeArchivePath(
|
|
2941
|
+
onentry(entry3) {
|
|
2942
|
+
if (entry3.meta) return;
|
|
2943
|
+
const path = normalizeArchivePath(entry3.path);
|
|
2247
2944
|
if (!path) return;
|
|
2248
|
-
if (!EXTRACTABLE_ENTRY_TYPES.has(
|
|
2249
|
-
throw new Error(`backup contains unsupported ${
|
|
2945
|
+
if (!EXTRACTABLE_ENTRY_TYPES.has(entry3.type)) {
|
|
2946
|
+
throw new Error(`backup contains unsupported ${entry3.type} entry: ${path}`);
|
|
2250
2947
|
}
|
|
2251
|
-
if (
|
|
2252
|
-
entries.push({ path, type:
|
|
2948
|
+
if (entry3.type === "SymbolicLink") validateArchiveSymbolicLink(path, entry3.linkpath);
|
|
2949
|
+
entries.push({ path, type: entry3.type, linkpath: entry3.linkpath });
|
|
2253
2950
|
}
|
|
2254
2951
|
});
|
|
2255
2952
|
await pipeline(stream, parser);
|
|
@@ -2257,29 +2954,29 @@ async function validateArchiveReadable(stream) {
|
|
|
2257
2954
|
}
|
|
2258
2955
|
function validateArchiveEntries(entries) {
|
|
2259
2956
|
const byPath = /* @__PURE__ */ new Map();
|
|
2260
|
-
for (const
|
|
2261
|
-
if (byPath.has(
|
|
2262
|
-
byPath.set(
|
|
2957
|
+
for (const entry3 of entries) {
|
|
2958
|
+
if (byPath.has(entry3.path)) throw new Error(`backup contains a duplicate path: ${entry3.path}`);
|
|
2959
|
+
byPath.set(entry3.path, entry3);
|
|
2263
2960
|
}
|
|
2264
2961
|
const symlinks = new Set(
|
|
2265
|
-
entries.filter((
|
|
2962
|
+
entries.filter((entry3) => entry3.type === "SymbolicLink").map((entry3) => entry3.path)
|
|
2266
2963
|
);
|
|
2267
|
-
for (const
|
|
2268
|
-
const segments =
|
|
2964
|
+
for (const entry3 of entries) {
|
|
2965
|
+
const segments = entry3.path.split("/");
|
|
2269
2966
|
for (let i = 1; i < segments.length; i++) {
|
|
2270
2967
|
const ancestor = segments.slice(0, i).join("/");
|
|
2271
2968
|
if (symlinks.has(ancestor)) {
|
|
2272
|
-
throw new Error(`backup entry traverses symbolic link ${ancestor}: ${
|
|
2969
|
+
throw new Error(`backup entry traverses symbolic link ${ancestor}: ${entry3.path}`);
|
|
2273
2970
|
}
|
|
2274
2971
|
const ancestorEntry = byPath.get(ancestor);
|
|
2275
2972
|
if (ancestorEntry && ancestorEntry.type !== "Directory") {
|
|
2276
|
-
throw new Error(`backup entry traverses non-directory ${ancestor}: ${
|
|
2973
|
+
throw new Error(`backup entry traverses non-directory ${ancestor}: ${entry3.path}`);
|
|
2277
2974
|
}
|
|
2278
2975
|
}
|
|
2279
2976
|
}
|
|
2280
2977
|
for (const required of ["bazilion.db", "auth.json"]) {
|
|
2281
|
-
const
|
|
2282
|
-
if (!
|
|
2978
|
+
const entry3 = byPath.get(required);
|
|
2979
|
+
if (!entry3 || entry3.type !== "File" && entry3.type !== "OldFile") {
|
|
2283
2980
|
throw new Error(`backup is missing required regular file: ${required}`);
|
|
2284
2981
|
}
|
|
2285
2982
|
}
|
|
@@ -2298,7 +2995,7 @@ function validateArchiveEntries(entries) {
|
|
|
2298
2995
|
function validateAuthFile(path) {
|
|
2299
2996
|
let parsed;
|
|
2300
2997
|
try {
|
|
2301
|
-
parsed = JSON.parse(
|
|
2998
|
+
parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
2302
2999
|
} catch (error) {
|
|
2303
3000
|
const detail = error instanceof Error ? error.message : String(error);
|
|
2304
3001
|
throw new Error(`backup auth.json is invalid: ${detail}`);
|
|
@@ -2311,7 +3008,7 @@ function validateAuthFile(path) {
|
|
|
2311
3008
|
function validateDatabase(path, authToken) {
|
|
2312
3009
|
let db = null;
|
|
2313
3010
|
try {
|
|
2314
|
-
db = new
|
|
3011
|
+
db = new DatabaseSync2(path, { readOnly: true });
|
|
2315
3012
|
const integrity = db.prepare("PRAGMA integrity_check").all();
|
|
2316
3013
|
if (integrity.length !== 1 || integrity[0]?.integrity_check !== "ok") {
|
|
2317
3014
|
const detail = integrity.map((row2) => row2.integrity_check).join("; ") || "no result";
|
|
@@ -2366,8 +3063,8 @@ function requireExtractedDirectory(path, rowLabel) {
|
|
|
2366
3063
|
}
|
|
2367
3064
|
function requireExtractedTeamSlot(path, rowLabel) {
|
|
2368
3065
|
try {
|
|
2369
|
-
const
|
|
2370
|
-
if (
|
|
3066
|
+
const entry3 = lstatSync2(path);
|
|
3067
|
+
if (entry3.isDirectory() || entry3.isSymbolicLink()) return;
|
|
2371
3068
|
} catch {
|
|
2372
3069
|
}
|
|
2373
3070
|
throw new Error(`${rowLabel} is missing its canonical Team slot in the backup`);
|
|
@@ -2375,7 +3072,7 @@ function requireExtractedTeamSlot(path, rowLabel) {
|
|
|
2375
3072
|
function rebaseRestoredHomeDirectories(database, payload, targetHome) {
|
|
2376
3073
|
let db = null;
|
|
2377
3074
|
try {
|
|
2378
|
-
db = new
|
|
3075
|
+
db = new DatabaseSync2(database);
|
|
2379
3076
|
db.exec("PRAGMA foreign_keys = ON");
|
|
2380
3077
|
const profiles = db.prepare("SELECT id FROM profiles ORDER BY id").all();
|
|
2381
3078
|
const agents = db.prepare("SELECT id FROM agents ORDER BY id").all();
|
|
@@ -2455,15 +3152,15 @@ function removeRebuildableQmdIndexes(payload) {
|
|
|
2455
3152
|
if (!team.isDirectory() || team.isSymbolicLink()) continue;
|
|
2456
3153
|
const memoryDir = resolve2(teamsDir, team.name, "memory");
|
|
2457
3154
|
if (!existsSync2(memoryDir) || !lstatSync2(memoryDir).isDirectory()) continue;
|
|
2458
|
-
for (const
|
|
2459
|
-
if (
|
|
2460
|
-
rmSync2(resolve2(memoryDir,
|
|
3155
|
+
for (const entry3 of readdirSync(memoryDir, { withFileTypes: true })) {
|
|
3156
|
+
if (entry3.isFile() && entry3.name.startsWith(".qmd-index.sqlite")) {
|
|
3157
|
+
rmSync2(resolve2(memoryDir, entry3.name), { force: true });
|
|
2461
3158
|
}
|
|
2462
3159
|
}
|
|
2463
3160
|
}
|
|
2464
3161
|
}
|
|
2465
3162
|
function revokeRestoredBrowserSessions(database) {
|
|
2466
|
-
const db = new
|
|
3163
|
+
const db = new DatabaseSync2(database);
|
|
2467
3164
|
try {
|
|
2468
3165
|
db.prepare("UPDATE web_sessions SET revoked_at = ? WHERE revoked_at IS NULL").run(Date.now());
|
|
2469
3166
|
} finally {
|
|
@@ -2603,18 +3300,18 @@ function isAgeEncrypted(path) {
|
|
|
2603
3300
|
}
|
|
2604
3301
|
function readAgeIdentity(rawPath) {
|
|
2605
3302
|
const path = resolve2(rawPath);
|
|
2606
|
-
const
|
|
2607
|
-
if (!
|
|
2608
|
-
if (process.platform !== "win32" && (
|
|
3303
|
+
const entry3 = lstatSync2(path);
|
|
3304
|
+
if (!entry3.isFile()) throw new Error(`age identity is not a regular file: ${path}`);
|
|
3305
|
+
if (process.platform !== "win32" && (entry3.mode & 63) !== 0) {
|
|
2609
3306
|
throw new Error(`age identity must be owner-only (chmod 600): ${path}`);
|
|
2610
3307
|
}
|
|
2611
|
-
const identities =
|
|
3308
|
+
const identities = readFileSync5(path, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
2612
3309
|
if (identities.length !== 1 || !identities[0]?.startsWith("AGE-SECRET-KEY-")) {
|
|
2613
3310
|
throw new Error("age identity file must contain exactly one supported AGE-SECRET-KEY entry");
|
|
2614
3311
|
}
|
|
2615
3312
|
return identities[0];
|
|
2616
3313
|
}
|
|
2617
|
-
var restoreCmd =
|
|
3314
|
+
var restoreCmd = defineCommand9({
|
|
2618
3315
|
meta: {
|
|
2619
3316
|
name: "restore",
|
|
2620
3317
|
description: "Extract a backup tar.gz into ~/.bazilion (offline; server must be stopped)"
|
|
@@ -2725,6 +3422,7 @@ var restoreCmd = defineCommand5({
|
|
|
2725
3422
|
validateDatabase(database, authToken);
|
|
2726
3423
|
rebaseRestoredHomeDirectories(database, payload, targetHome);
|
|
2727
3424
|
revokeRestoredBrowserSessions(database);
|
|
3425
|
+
pauseRestoredUserQueue(database);
|
|
2728
3426
|
validateDatabase(database, authToken);
|
|
2729
3427
|
removeRebuildableQmdIndexes(payload);
|
|
2730
3428
|
console.log(`installing validated backup ${file} \u2192 ${targetHome}`);
|
|
@@ -2783,7 +3481,7 @@ function credentialInventory(home) {
|
|
|
2783
3481
|
const database = resolve2(home, "bazilion.db");
|
|
2784
3482
|
const token = validateAuthFile(authFile);
|
|
2785
3483
|
validateDatabase(database, token);
|
|
2786
|
-
const db = new
|
|
3484
|
+
const db = new DatabaseSync2(database, { readOnly: true });
|
|
2787
3485
|
try {
|
|
2788
3486
|
const activeTokens = db.prepare(
|
|
2789
3487
|
"SELECT COUNT(*) AS count FROM web_tokens WHERE revoked_at IS NULL AND kind = 'device' AND expires_at > ?"
|
|
@@ -2794,7 +3492,7 @@ function credentialInventory(home) {
|
|
|
2794
3492
|
db.close();
|
|
2795
3493
|
}
|
|
2796
3494
|
}
|
|
2797
|
-
var inventoryCmd =
|
|
3495
|
+
var inventoryCmd = defineCommand9({
|
|
2798
3496
|
meta: { name: "inventory", description: "List credential classes captured by a backup/home" },
|
|
2799
3497
|
args: { home: { type: "string", description: "Override BAZILION_HOME" } },
|
|
2800
3498
|
run({ args }) {
|
|
@@ -2806,7 +3504,7 @@ var inventoryCmd = defineCommand5({
|
|
|
2806
3504
|
for (const key of inventory.secretKeys) console.log(` stored secret: ${key}`);
|
|
2807
3505
|
}
|
|
2808
3506
|
});
|
|
2809
|
-
var recoveryGuideCmd =
|
|
3507
|
+
var recoveryGuideCmd = defineCommand9({
|
|
2810
3508
|
meta: { name: "recovery-guide", description: "Print the credential-exposure recovery checklist" },
|
|
2811
3509
|
run() {
|
|
2812
3510
|
console.log("Bazilion credential exposure recovery:");
|
|
@@ -2825,7 +3523,7 @@ var recoveryGuideCmd = defineCommand5({
|
|
|
2825
3523
|
);
|
|
2826
3524
|
}
|
|
2827
3525
|
});
|
|
2828
|
-
var rotateBootstrapCmd =
|
|
3526
|
+
var rotateBootstrapCmd = defineCommand9({
|
|
2829
3527
|
meta: {
|
|
2830
3528
|
name: "rotate-bootstrap",
|
|
2831
3529
|
description: "Offline crash-safe bootstrap rotation; revokes every other local token"
|
|
@@ -2852,7 +3550,7 @@ var rotateBootstrapCmd = defineCommand5({
|
|
|
2852
3550
|
throw new Error(`bazilion server appears to be running at ${serverUrl} \u2014 stop it first.`);
|
|
2853
3551
|
}
|
|
2854
3552
|
}
|
|
2855
|
-
const oldAuth = JSON.parse(
|
|
3553
|
+
const oldAuth = JSON.parse(readFileSync5(paths.authFile, "utf8"));
|
|
2856
3554
|
if (typeof oldAuth.token !== "string" || !oldAuth.token) {
|
|
2857
3555
|
throw new Error("auth.json is missing the bootstrap token");
|
|
2858
3556
|
}
|
|
@@ -2865,7 +3563,7 @@ var rotateBootstrapCmd = defineCommand5({
|
|
|
2865
3563
|
});
|
|
2866
3564
|
const stagedDb = resolve2(payload, "bazilion.db");
|
|
2867
3565
|
rmSync2(stagedDb, { force: true });
|
|
2868
|
-
const sourceDb = new
|
|
3566
|
+
const sourceDb = new DatabaseSync2(resolve2(targetHome, "bazilion.db"), { readOnly: true });
|
|
2869
3567
|
try {
|
|
2870
3568
|
await sqliteBackup(sourceDb, stagedDb);
|
|
2871
3569
|
} finally {
|
|
@@ -2874,7 +3572,7 @@ var rotateBootstrapCmd = defineCommand5({
|
|
|
2874
3572
|
for (const suffix of ["-wal", "-shm", "-journal"])
|
|
2875
3573
|
rmSync2(`${stagedDb}${suffix}`, { force: true });
|
|
2876
3574
|
const newToken = randomBytes(24).toString("hex");
|
|
2877
|
-
const db = new
|
|
3575
|
+
const db = new DatabaseSync2(stagedDb);
|
|
2878
3576
|
try {
|
|
2879
3577
|
db.exec("PRAGMA foreign_keys = ON; BEGIN IMMEDIATE");
|
|
2880
3578
|
try {
|
|
@@ -2913,7 +3611,7 @@ var rotateBootstrapCmd = defineCommand5({
|
|
|
2913
3611
|
db.close();
|
|
2914
3612
|
}
|
|
2915
3613
|
const stagedAuth = resolve2(payload, "auth.json");
|
|
2916
|
-
const authPartial = resolve2(payload, `.auth.json.${
|
|
3614
|
+
const authPartial = resolve2(payload, `.auth.json.${randomUUID7()}.installing`);
|
|
2917
3615
|
writeFileSync2(authPartial, `${JSON.stringify({ ...oldAuth, token: newToken }, null, 2)}
|
|
2918
3616
|
`, {
|
|
2919
3617
|
mode: 384,
|
|
@@ -2941,7 +3639,7 @@ var rotateBootstrapCmd = defineCommand5({
|
|
|
2941
3639
|
}
|
|
2942
3640
|
}
|
|
2943
3641
|
});
|
|
2944
|
-
var backupCommand =
|
|
3642
|
+
var backupCommand = defineCommand9({
|
|
2945
3643
|
meta: { name: "backup", description: "Encrypted backup, restore, and credential recovery" },
|
|
2946
3644
|
subCommands: {
|
|
2947
3645
|
create: createCmd,
|
|
@@ -2958,7 +3656,7 @@ var backupCommand = defineCommand5({
|
|
|
2958
3656
|
});
|
|
2959
3657
|
|
|
2960
3658
|
// src/commands/completion.ts
|
|
2961
|
-
import { defineCommand as
|
|
3659
|
+
import { defineCommand as defineCommand10 } from "citty";
|
|
2962
3660
|
async function walk(cmd, path, out) {
|
|
2963
3661
|
const subsRaw = cmd.subCommands ?? {};
|
|
2964
3662
|
const subNames = Object.keys(subsRaw);
|
|
@@ -3063,7 +3761,7 @@ function fishScript(flat) {
|
|
|
3063
3761
|
`;
|
|
3064
3762
|
}
|
|
3065
3763
|
function completionCommand(main2) {
|
|
3066
|
-
return
|
|
3764
|
+
return defineCommand10({
|
|
3067
3765
|
meta: {
|
|
3068
3766
|
name: "completion",
|
|
3069
3767
|
description: "Print a shell completion script (bash, zsh, or fish)"
|
|
@@ -3088,13 +3786,13 @@ function completionCommand(main2) {
|
|
|
3088
3786
|
}
|
|
3089
3787
|
|
|
3090
3788
|
// src/commands/config.ts
|
|
3091
|
-
import { defineCommand as
|
|
3789
|
+
import { defineCommand as defineCommand11 } from "citty";
|
|
3092
3790
|
function displayValue(f) {
|
|
3093
3791
|
if (!f.set) return "(unset)";
|
|
3094
3792
|
if (f.kind === "secret") return f.preview ?? "(set)";
|
|
3095
3793
|
return f.value ?? "(set)";
|
|
3096
3794
|
}
|
|
3097
|
-
var listCmd2 =
|
|
3795
|
+
var listCmd2 = defineCommand11({
|
|
3098
3796
|
meta: {
|
|
3099
3797
|
name: "list",
|
|
3100
3798
|
description: "List every configurable field (credentials + URLs) across all services"
|
|
@@ -3117,7 +3815,7 @@ var listCmd2 = defineCommand7({
|
|
|
3117
3815
|
for (const line of columnize(rows)) console.log(line);
|
|
3118
3816
|
}
|
|
3119
3817
|
});
|
|
3120
|
-
var setCmd =
|
|
3818
|
+
var setCmd = defineCommand11({
|
|
3121
3819
|
meta: {
|
|
3122
3820
|
name: "set",
|
|
3123
3821
|
description: "Set a configurable field (auto-routes to secrets or plaintext store)"
|
|
@@ -3144,7 +3842,7 @@ var setCmd = defineCommand7({
|
|
|
3144
3842
|
console.log(`${state.envVar} (${state.kind}): ${displayValue(state)}`);
|
|
3145
3843
|
}
|
|
3146
3844
|
});
|
|
3147
|
-
var rmCmd =
|
|
3845
|
+
var rmCmd = defineCommand11({
|
|
3148
3846
|
meta: { name: "rm", description: "Remove a configurable field value" },
|
|
3149
3847
|
args: {
|
|
3150
3848
|
envVar: { type: "positional", required: true, description: "Env var name to clear" }
|
|
@@ -3155,7 +3853,7 @@ var rmCmd = defineCommand7({
|
|
|
3155
3853
|
console.log(`removed ${args.envVar}`);
|
|
3156
3854
|
}
|
|
3157
3855
|
});
|
|
3158
|
-
var configCommand =
|
|
3856
|
+
var configCommand = defineCommand11({
|
|
3159
3857
|
meta: {
|
|
3160
3858
|
name: "config",
|
|
3161
3859
|
description: "Manage service configuration \u2014 credentials (encrypted) and URLs/IDs (plaintext), unified under one CLI"
|
|
@@ -3172,7 +3870,7 @@ import { spawn } from "child_process";
|
|
|
3172
3870
|
import { existsSync as existsSync3 } from "fs";
|
|
3173
3871
|
import { connect } from "net";
|
|
3174
3872
|
import { join as join3 } from "path";
|
|
3175
|
-
import { defineCommand as
|
|
3873
|
+
import { defineCommand as defineCommand12 } from "citty";
|
|
3176
3874
|
var bundledDaemonEntry = join3(import.meta.dirname, "daemon.js");
|
|
3177
3875
|
var sourceDaemonEntry = join3(import.meta.dirname, "..", "..", "..", "daemon", "src", "index.ts");
|
|
3178
3876
|
var daemonEntry = existsSync3(bundledDaemonEntry) ? bundledDaemonEntry : sourceDaemonEntry;
|
|
@@ -3182,8 +3880,8 @@ var webServerEntry = existsSync3(bundledWebServerEntry) ? bundledWebServerEntry
|
|
|
3182
3880
|
var bundledWebDist = join3(import.meta.dirname, "web");
|
|
3183
3881
|
var sourceWebDist = join3(import.meta.dirname, "..", "..", "..", "web", "dist");
|
|
3184
3882
|
var webDist = existsSync3(bundledWebDist) ? bundledWebDist : sourceWebDist;
|
|
3185
|
-
function nodeArgs(
|
|
3186
|
-
return
|
|
3883
|
+
function nodeArgs(entry3) {
|
|
3884
|
+
return entry3.endsWith(".ts") ? ["--import", "tsx/esm", entry3] : [entry3];
|
|
3187
3885
|
}
|
|
3188
3886
|
async function responds(url) {
|
|
3189
3887
|
try {
|
|
@@ -3257,16 +3955,16 @@ function openBrowser(url) {
|
|
|
3257
3955
|
const proc = spawn(cmd, args, { detached: true, stdio: "ignore" });
|
|
3258
3956
|
proc.unref();
|
|
3259
3957
|
}
|
|
3260
|
-
function spawnProcess(label,
|
|
3261
|
-
if (!existsSync3(
|
|
3262
|
-
throw new Error(`${label} entry not found at ${
|
|
3958
|
+
function spawnProcess(label, entry3, env) {
|
|
3959
|
+
if (!existsSync3(entry3)) {
|
|
3960
|
+
throw new Error(`${label} entry not found at ${entry3}`);
|
|
3263
3961
|
}
|
|
3264
|
-
return spawn(process.execPath, nodeArgs(
|
|
3962
|
+
return spawn(process.execPath, nodeArgs(entry3), {
|
|
3265
3963
|
env,
|
|
3266
3964
|
stdio: "inherit"
|
|
3267
3965
|
});
|
|
3268
3966
|
}
|
|
3269
|
-
var dashboardCommand =
|
|
3967
|
+
var dashboardCommand = defineCommand12({
|
|
3270
3968
|
meta: {
|
|
3271
3969
|
name: "dashboard",
|
|
3272
3970
|
description: "Start the bazilion daemon and bundled web UI"
|
|
@@ -3385,8 +4083,8 @@ var dashboardCommand = defineCommand8({
|
|
|
3385
4083
|
});
|
|
3386
4084
|
|
|
3387
4085
|
// src/commands/doctor.ts
|
|
3388
|
-
import { defineCommand as
|
|
3389
|
-
var doctorCommand =
|
|
4086
|
+
import { defineCommand as defineCommand13 } from "citty";
|
|
4087
|
+
var doctorCommand = defineCommand13({
|
|
3390
4088
|
meta: { name: "doctor", description: "Diagnose your bazilion install" },
|
|
3391
4089
|
async run() {
|
|
3392
4090
|
const client = createClient2();
|
|
@@ -3574,7 +4272,7 @@ function checkLine(label, condition, hint) {
|
|
|
3574
4272
|
// src/commands/gateway.ts
|
|
3575
4273
|
import { execFile } from "child_process";
|
|
3576
4274
|
import { promisify } from "util";
|
|
3577
|
-
import { defineCommand as
|
|
4275
|
+
import { defineCommand as defineCommand14 } from "citty";
|
|
3578
4276
|
var execFileAsync = promisify(execFile);
|
|
3579
4277
|
function exactHttpsOrigin(raw) {
|
|
3580
4278
|
if (!raw) throw new Error("BAZILION_PUBLIC_ORIGIN is required");
|
|
@@ -3584,9 +4282,9 @@ function exactHttpsOrigin(raw) {
|
|
|
3584
4282
|
}
|
|
3585
4283
|
return url;
|
|
3586
4284
|
}
|
|
3587
|
-
function listenerIsLoopback(
|
|
4285
|
+
function listenerIsLoopback(output4, port) {
|
|
3588
4286
|
const suffix = `:${port}`;
|
|
3589
|
-
const listeners =
|
|
4287
|
+
const listeners = output4.split("\n").filter((line) => line.trim()).filter((line) => line.split(/\s+/).some((field) => field.endsWith(suffix)));
|
|
3590
4288
|
return listeners.length > 0 && listeners.every((line) => /(?:127\.0\.0\.1|\[?::1\]?):\d+/.test(line));
|
|
3591
4289
|
}
|
|
3592
4290
|
function hasFunnel(value) {
|
|
@@ -3596,7 +4294,7 @@ function hasFunnel(value) {
|
|
|
3596
4294
|
([key, nested]) => /funnel/i.test(key) && nested !== false && nested !== null || hasFunnel(nested)
|
|
3597
4295
|
);
|
|
3598
4296
|
}
|
|
3599
|
-
var preflightCmd =
|
|
4297
|
+
var preflightCmd = defineCommand14({
|
|
3600
4298
|
meta: { name: "preflight", description: "Read-only private Tailscale gateway safety check" },
|
|
3601
4299
|
async run() {
|
|
3602
4300
|
const publicOrigin = exactHttpsOrigin(process.env.BAZILION_PUBLIC_ORIGIN);
|
|
@@ -3637,13 +4335,13 @@ var preflightCmd = defineCommand10({
|
|
|
3637
4335
|
console.log("hosted Agent turns: protected baseline ready");
|
|
3638
4336
|
}
|
|
3639
4337
|
});
|
|
3640
|
-
var gatewayCommand =
|
|
4338
|
+
var gatewayCommand = defineCommand14({
|
|
3641
4339
|
meta: { name: "gateway", description: "Inspect the private web gateway posture" },
|
|
3642
4340
|
subCommands: { preflight: preflightCmd }
|
|
3643
4341
|
});
|
|
3644
4342
|
|
|
3645
4343
|
// src/commands/inbox.ts
|
|
3646
|
-
import { defineCommand as
|
|
4344
|
+
import { defineCommand as defineCommand15 } from "citty";
|
|
3647
4345
|
function decodeText(payload) {
|
|
3648
4346
|
try {
|
|
3649
4347
|
const obj = JSON.parse(payload);
|
|
@@ -3659,7 +4357,7 @@ function messageRow(m) {
|
|
|
3659
4357
|
const preview = text2.length > 60 ? `${text2.slice(0, 60)}\u2026` : text2;
|
|
3660
4358
|
return [m.id, state, when, `from:${m.fromAgentId.slice(0, 8)}`, `"${preview}"`];
|
|
3661
4359
|
}
|
|
3662
|
-
var listCmd3 =
|
|
4360
|
+
var listCmd3 = defineCommand15({
|
|
3663
4361
|
meta: { name: "list", description: "List messages in an agent inbox" },
|
|
3664
4362
|
args: {
|
|
3665
4363
|
agent: { type: "positional", required: true, description: "Recipient agent id" },
|
|
@@ -3678,7 +4376,7 @@ var listCmd3 = defineCommand11({
|
|
|
3678
4376
|
for (const line of columnize(messages.map(messageRow))) console.log(line);
|
|
3679
4377
|
}
|
|
3680
4378
|
});
|
|
3681
|
-
var showCmd2 =
|
|
4379
|
+
var showCmd2 = defineCommand15({
|
|
3682
4380
|
meta: { name: "show", description: "Show a single message in full" },
|
|
3683
4381
|
args: {
|
|
3684
4382
|
id: { type: "positional", required: true, description: "Message id" }
|
|
@@ -3698,7 +4396,7 @@ var showCmd2 = defineCommand11({
|
|
|
3698
4396
|
console.log(decodeText(m.payload));
|
|
3699
4397
|
}
|
|
3700
4398
|
});
|
|
3701
|
-
var readCmd =
|
|
4399
|
+
var readCmd = defineCommand15({
|
|
3702
4400
|
meta: { name: "read", description: "Mark a message as read" },
|
|
3703
4401
|
args: {
|
|
3704
4402
|
id: { type: "positional", required: true, description: "Message id" }
|
|
@@ -3709,7 +4407,7 @@ var readCmd = defineCommand11({
|
|
|
3709
4407
|
console.log(`marked read: ${args.id}`);
|
|
3710
4408
|
}
|
|
3711
4409
|
});
|
|
3712
|
-
var loopBreaksCmd =
|
|
4410
|
+
var loopBreaksCmd = defineCommand15({
|
|
3713
4411
|
meta: { name: "loop-breaks", description: "List stopped agent-message chains" },
|
|
3714
4412
|
args: {
|
|
3715
4413
|
agent: { type: "positional", required: true, description: "Agent id" },
|
|
@@ -3737,7 +4435,7 @@ var loopBreaksCmd = defineCommand11({
|
|
|
3737
4435
|
console.log(line);
|
|
3738
4436
|
}
|
|
3739
4437
|
});
|
|
3740
|
-
var inboxCommand =
|
|
4438
|
+
var inboxCommand = defineCommand15({
|
|
3741
4439
|
meta: { name: "inbox", description: "Inspect agent inboxes" },
|
|
3742
4440
|
subCommands: {
|
|
3743
4441
|
list: listCmd3,
|
|
@@ -3748,8 +4446,8 @@ var inboxCommand = defineCommand11({
|
|
|
3748
4446
|
});
|
|
3749
4447
|
|
|
3750
4448
|
// src/commands/login.ts
|
|
3751
|
-
import { existsSync as existsSync4, readFileSync as
|
|
3752
|
-
import { defineCommand as
|
|
4449
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
|
|
4450
|
+
import { defineCommand as defineCommand16 } from "citty";
|
|
3753
4451
|
function normalizeServer(raw) {
|
|
3754
4452
|
let url;
|
|
3755
4453
|
try {
|
|
@@ -3773,7 +4471,7 @@ async function verifyToken(server, token) {
|
|
|
3773
4471
|
throw new Error("server canonical private origin does not match --server");
|
|
3774
4472
|
}
|
|
3775
4473
|
}
|
|
3776
|
-
var loginCommand =
|
|
4474
|
+
var loginCommand = defineCommand16({
|
|
3777
4475
|
meta: {
|
|
3778
4476
|
name: "login",
|
|
3779
4477
|
description: "Save a remote bazilion server + token pair to auth.json"
|
|
@@ -3791,7 +4489,7 @@ var loginCommand = defineCommand12({
|
|
|
3791
4489
|
`${paths.authFile} not found. Start the daemon with "bazilion serve" first \u2014 login stores the remote there.`
|
|
3792
4490
|
);
|
|
3793
4491
|
}
|
|
3794
|
-
const auth = JSON.parse(
|
|
4492
|
+
const auth = JSON.parse(readFileSync6(paths.authFile, "utf8"));
|
|
3795
4493
|
if (args.clear) {
|
|
3796
4494
|
if (!auth.remote) {
|
|
3797
4495
|
console.log("no remote stored \u2014 nothing to clear");
|
|
@@ -3821,7 +4519,7 @@ var loginCommand = defineCommand12({
|
|
|
3821
4519
|
});
|
|
3822
4520
|
|
|
3823
4521
|
// src/commands/mcp.ts
|
|
3824
|
-
import { defineCommand as
|
|
4522
|
+
import { defineCommand as defineCommand17 } from "citty";
|
|
3825
4523
|
function serverRow(s) {
|
|
3826
4524
|
const where = s.transport === "stdio" ? `${s.command} ${s.args.join(" ")}`.trim() : s.url ?? "";
|
|
3827
4525
|
return [
|
|
@@ -3833,7 +4531,7 @@ function serverRow(s) {
|
|
|
3833
4531
|
where
|
|
3834
4532
|
];
|
|
3835
4533
|
}
|
|
3836
|
-
var addCmd =
|
|
4534
|
+
var addCmd = defineCommand17({
|
|
3837
4535
|
meta: { name: "add", description: "Register an MCP server" },
|
|
3838
4536
|
args: {
|
|
3839
4537
|
name: { type: "positional", required: true, description: "Unique name ([a-zA-Z0-9_])" },
|
|
@@ -3860,7 +4558,7 @@ var addCmd = defineCommand13({
|
|
|
3860
4558
|
console.log(`${server.id} ${server.name} ${server.transport}`);
|
|
3861
4559
|
}
|
|
3862
4560
|
});
|
|
3863
|
-
var listCmd4 =
|
|
4561
|
+
var listCmd4 = defineCommand17({
|
|
3864
4562
|
meta: { name: "list", description: "List MCP servers" },
|
|
3865
4563
|
async run() {
|
|
3866
4564
|
const client = createClient2();
|
|
@@ -3872,7 +4570,7 @@ var listCmd4 = defineCommand13({
|
|
|
3872
4570
|
for (const line of columnize(servers.map(serverRow))) console.log(line);
|
|
3873
4571
|
}
|
|
3874
4572
|
});
|
|
3875
|
-
var showCmd3 =
|
|
4573
|
+
var showCmd3 = defineCommand17({
|
|
3876
4574
|
meta: { name: "show", description: "Show one MCP server" },
|
|
3877
4575
|
args: { id: { type: "positional", required: true } },
|
|
3878
4576
|
async run({ args }) {
|
|
@@ -3881,7 +4579,7 @@ var showCmd3 = defineCommand13({
|
|
|
3881
4579
|
console.log(JSON.stringify(server, null, 2));
|
|
3882
4580
|
}
|
|
3883
4581
|
});
|
|
3884
|
-
var rmCmd2 =
|
|
4582
|
+
var rmCmd2 = defineCommand17({
|
|
3885
4583
|
meta: { name: "rm", description: "Delete an MCP server" },
|
|
3886
4584
|
args: { id: { type: "positional", required: true } },
|
|
3887
4585
|
async run({ args }) {
|
|
@@ -3890,7 +4588,7 @@ var rmCmd2 = defineCommand13({
|
|
|
3890
4588
|
console.log(`removed MCP server ${args.id}`);
|
|
3891
4589
|
}
|
|
3892
4590
|
});
|
|
3893
|
-
var enableCmd =
|
|
4591
|
+
var enableCmd = defineCommand17({
|
|
3894
4592
|
meta: { name: "enable", description: "Enable an MCP server" },
|
|
3895
4593
|
args: { id: { type: "positional", required: true } },
|
|
3896
4594
|
async run({ args }) {
|
|
@@ -3899,7 +4597,7 @@ var enableCmd = defineCommand13({
|
|
|
3899
4597
|
console.log(`enabled MCP server ${args.id}`);
|
|
3900
4598
|
}
|
|
3901
4599
|
});
|
|
3902
|
-
var disableCmd =
|
|
4600
|
+
var disableCmd = defineCommand17({
|
|
3903
4601
|
meta: { name: "disable", description: "Disable an MCP server" },
|
|
3904
4602
|
args: { id: { type: "positional", required: true } },
|
|
3905
4603
|
async run({ args }) {
|
|
@@ -3908,7 +4606,7 @@ var disableCmd = defineCommand13({
|
|
|
3908
4606
|
console.log(`disabled MCP server ${args.id}`);
|
|
3909
4607
|
}
|
|
3910
4608
|
});
|
|
3911
|
-
var testCmd =
|
|
4609
|
+
var testCmd = defineCommand17({
|
|
3912
4610
|
meta: { name: "test", description: "Connect to a server and list its tools" },
|
|
3913
4611
|
args: { id: { type: "positional", required: true } },
|
|
3914
4612
|
async run({ args }) {
|
|
@@ -3926,7 +4624,7 @@ var testCmd = defineCommand13({
|
|
|
3926
4624
|
for (const t of tools) console.log(` ${t.name} ${t.description}`);
|
|
3927
4625
|
}
|
|
3928
4626
|
});
|
|
3929
|
-
var mcpCommand =
|
|
4627
|
+
var mcpCommand = defineCommand17({
|
|
3930
4628
|
meta: { name: "mcp", description: "Manage MCP servers" },
|
|
3931
4629
|
subCommands: {
|
|
3932
4630
|
add: addCmd,
|
|
@@ -3940,11 +4638,11 @@ var mcpCommand = defineCommand13({
|
|
|
3940
4638
|
});
|
|
3941
4639
|
|
|
3942
4640
|
// src/commands/memory.ts
|
|
3943
|
-
import { defineCommand as
|
|
4641
|
+
import { defineCommand as defineCommand18 } from "citty";
|
|
3944
4642
|
function encodeKey(key) {
|
|
3945
4643
|
return key.split("/").map(encodeURIComponent).join("/");
|
|
3946
4644
|
}
|
|
3947
|
-
var writeCmd =
|
|
4645
|
+
var writeCmd = defineCommand18({
|
|
3948
4646
|
meta: { name: "write", description: "Write an entry into a team's shared memory" },
|
|
3949
4647
|
args: {
|
|
3950
4648
|
team: { type: "positional", required: true, description: "Team slug" },
|
|
@@ -3953,14 +4651,14 @@ var writeCmd = defineCommand14({
|
|
|
3953
4651
|
},
|
|
3954
4652
|
async run({ args }) {
|
|
3955
4653
|
const client = createClient2();
|
|
3956
|
-
const
|
|
4654
|
+
const entry3 = await client.put(
|
|
3957
4655
|
`/api/teams/${args.team}/memory/${encodeKey(args.key)}`,
|
|
3958
4656
|
{ content: args.content }
|
|
3959
4657
|
);
|
|
3960
|
-
console.log(`wrote ${
|
|
4658
|
+
console.log(`wrote ${entry3.key} (${entry3.content.length} bytes)`);
|
|
3961
4659
|
}
|
|
3962
4660
|
});
|
|
3963
|
-
var readCmd2 =
|
|
4661
|
+
var readCmd2 = defineCommand18({
|
|
3964
4662
|
meta: { name: "read", description: "Read an entry from a team's shared memory" },
|
|
3965
4663
|
args: {
|
|
3966
4664
|
team: { type: "positional", required: true, description: "Team slug" },
|
|
@@ -3968,13 +4666,13 @@ var readCmd2 = defineCommand14({
|
|
|
3968
4666
|
},
|
|
3969
4667
|
async run({ args }) {
|
|
3970
4668
|
const client = createClient2();
|
|
3971
|
-
const
|
|
4669
|
+
const entry3 = await client.get(
|
|
3972
4670
|
`/api/teams/${args.team}/memory/${encodeKey(args.key)}`
|
|
3973
4671
|
);
|
|
3974
|
-
console.log(
|
|
4672
|
+
console.log(entry3.content);
|
|
3975
4673
|
}
|
|
3976
4674
|
});
|
|
3977
|
-
var searchCmd =
|
|
4675
|
+
var searchCmd = defineCommand18({
|
|
3978
4676
|
meta: { name: "search", description: "Search a team's shared memory" },
|
|
3979
4677
|
args: {
|
|
3980
4678
|
team: { type: "positional", required: true, description: "Team slug" },
|
|
@@ -3995,7 +4693,7 @@ var searchCmd = defineCommand14({
|
|
|
3995
4693
|
}
|
|
3996
4694
|
}
|
|
3997
4695
|
});
|
|
3998
|
-
var listCmd5 =
|
|
4696
|
+
var listCmd5 = defineCommand18({
|
|
3999
4697
|
meta: { name: "list", description: "List all entries in a team's shared memory" },
|
|
4000
4698
|
args: {
|
|
4001
4699
|
team: { type: "positional", required: true, description: "Team slug" }
|
|
@@ -4012,7 +4710,7 @@ var listCmd5 = defineCommand14({
|
|
|
4012
4710
|
}
|
|
4013
4711
|
}
|
|
4014
4712
|
});
|
|
4015
|
-
var rmCmd3 =
|
|
4713
|
+
var rmCmd3 = defineCommand18({
|
|
4016
4714
|
meta: { name: "rm", description: "Remove an entry from a team's shared memory" },
|
|
4017
4715
|
args: {
|
|
4018
4716
|
team: { type: "positional", required: true, description: "Team slug" },
|
|
@@ -4024,7 +4722,7 @@ var rmCmd3 = defineCommand14({
|
|
|
4024
4722
|
console.log(`removed ${args.key}`);
|
|
4025
4723
|
}
|
|
4026
4724
|
});
|
|
4027
|
-
var memoryCommand =
|
|
4725
|
+
var memoryCommand = defineCommand18({
|
|
4028
4726
|
meta: {
|
|
4029
4727
|
name: "memory",
|
|
4030
4728
|
description: "Manage a team's shared memory (BM25-indexed markdown notes)"
|
|
@@ -4041,7 +4739,7 @@ var memoryCommand = defineCommand14({
|
|
|
4041
4739
|
// src/commands/profile.ts
|
|
4042
4740
|
import { spawn as spawn2 } from "child_process";
|
|
4043
4741
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
4044
|
-
import { readFileSync as
|
|
4742
|
+
import { readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
4045
4743
|
import { tmpdir as tmpdir2 } from "os";
|
|
4046
4744
|
import { join as join4 } from "path";
|
|
4047
4745
|
|
|
@@ -4056,7 +4754,7 @@ var PROFILE_FILES = [
|
|
|
4056
4754
|
];
|
|
4057
4755
|
|
|
4058
4756
|
// src/commands/profile.ts
|
|
4059
|
-
import { defineCommand as
|
|
4757
|
+
import { defineCommand as defineCommand19 } from "citty";
|
|
4060
4758
|
function splitCsv(v) {
|
|
4061
4759
|
if (!v) return void 0;
|
|
4062
4760
|
const out = v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -4067,7 +4765,7 @@ function parseSkillsMode(v) {
|
|
|
4067
4765
|
if (v === "all" || v === "selected") return v;
|
|
4068
4766
|
throw new Error(`--skills-mode must be 'all' or 'selected', got '${v}'`);
|
|
4069
4767
|
}
|
|
4070
|
-
var createCmd2 =
|
|
4768
|
+
var createCmd2 = defineCommand19({
|
|
4071
4769
|
meta: { name: "create", description: "Create a new profile" },
|
|
4072
4770
|
args: {
|
|
4073
4771
|
id: { type: "positional", required: true, description: "Profile slug" },
|
|
@@ -4112,7 +4810,7 @@ var createCmd2 = defineCommand15({
|
|
|
4112
4810
|
},
|
|
4113
4811
|
async run({ args }) {
|
|
4114
4812
|
const skillsMode = parseSkillsMode(args["skills-mode"]);
|
|
4115
|
-
const readTemplate = (path) => path ?
|
|
4813
|
+
const readTemplate = (path) => path ? readFileSync7(path, "utf8") : void 0;
|
|
4116
4814
|
const body = {
|
|
4117
4815
|
id: args.id,
|
|
4118
4816
|
name: args.name,
|
|
@@ -4130,20 +4828,20 @@ var createCmd2 = defineCommand15({
|
|
|
4130
4828
|
console.log(`created profile ${profile.id} at ${profile.dir}`);
|
|
4131
4829
|
}
|
|
4132
4830
|
});
|
|
4133
|
-
var listCmd6 =
|
|
4831
|
+
var listCmd6 = defineCommand19({
|
|
4134
4832
|
meta: { name: "list", description: "List profiles" },
|
|
4135
4833
|
async run() {
|
|
4136
4834
|
const client = createClient2();
|
|
4137
|
-
const
|
|
4138
|
-
if (
|
|
4835
|
+
const list8 = await client.get("/api/profiles");
|
|
4836
|
+
if (list8.length === 0) {
|
|
4139
4837
|
console.log("(no profiles)");
|
|
4140
4838
|
return;
|
|
4141
4839
|
}
|
|
4142
|
-
const rows =
|
|
4840
|
+
const rows = list8.map((p) => [p.id, p.defaultModel, p.name]);
|
|
4143
4841
|
for (const line of columnize(rows)) console.log(line);
|
|
4144
4842
|
}
|
|
4145
4843
|
});
|
|
4146
|
-
var showCmd4 =
|
|
4844
|
+
var showCmd4 = defineCommand19({
|
|
4147
4845
|
meta: { name: "show", description: "Show profile details" },
|
|
4148
4846
|
args: {
|
|
4149
4847
|
id: { type: "positional", required: true }
|
|
@@ -4168,7 +4866,7 @@ var showCmd4 = defineCommand15({
|
|
|
4168
4866
|
}
|
|
4169
4867
|
}
|
|
4170
4868
|
});
|
|
4171
|
-
var editCmd2 =
|
|
4869
|
+
var editCmd2 = defineCommand19({
|
|
4172
4870
|
meta: { name: "edit", description: "Open a profile file in $EDITOR" },
|
|
4173
4871
|
args: {
|
|
4174
4872
|
id: { type: "positional", required: true },
|
|
@@ -4197,7 +4895,7 @@ var editCmd2 = defineCommand15({
|
|
|
4197
4895
|
child.on("close", (c) => resolve5(c ?? 0));
|
|
4198
4896
|
});
|
|
4199
4897
|
if (code !== 0) throw new Error(`editor exited with code ${code}`);
|
|
4200
|
-
const updated =
|
|
4898
|
+
const updated = readFileSync7(tmpPath, "utf8");
|
|
4201
4899
|
if (updated === content) {
|
|
4202
4900
|
console.log("(no changes)");
|
|
4203
4901
|
return;
|
|
@@ -4213,7 +4911,7 @@ var editCmd2 = defineCommand15({
|
|
|
4213
4911
|
}
|
|
4214
4912
|
}
|
|
4215
4913
|
});
|
|
4216
|
-
var updateCmd =
|
|
4914
|
+
var updateCmd = defineCommand19({
|
|
4217
4915
|
meta: {
|
|
4218
4916
|
name: "update",
|
|
4219
4917
|
description: "Update profile settings (name, model, skills-mode, skills)"
|
|
@@ -4247,7 +4945,7 @@ var updateCmd = defineCommand15({
|
|
|
4247
4945
|
console.log(`updated profile ${profile.id}`);
|
|
4248
4946
|
}
|
|
4249
4947
|
});
|
|
4250
|
-
var deleteCmd2 =
|
|
4948
|
+
var deleteCmd2 = defineCommand19({
|
|
4251
4949
|
meta: { name: "delete", description: "Permanently delete a profile and its files" },
|
|
4252
4950
|
args: {
|
|
4253
4951
|
id: { type: "positional", required: true }
|
|
@@ -4258,7 +4956,7 @@ var deleteCmd2 = defineCommand15({
|
|
|
4258
4956
|
console.log(`deleted profile ${args.id}`);
|
|
4259
4957
|
}
|
|
4260
4958
|
});
|
|
4261
|
-
var profileCommand =
|
|
4959
|
+
var profileCommand = defineCommand19({
|
|
4262
4960
|
meta: { name: "profile", description: "Manage profiles" },
|
|
4263
4961
|
subCommands: {
|
|
4264
4962
|
create: createCmd2,
|
|
@@ -4271,8 +4969,8 @@ var profileCommand = defineCommand15({
|
|
|
4271
4969
|
});
|
|
4272
4970
|
|
|
4273
4971
|
// src/commands/provider.ts
|
|
4274
|
-
import { defineCommand as
|
|
4275
|
-
var listCmd7 =
|
|
4972
|
+
import { defineCommand as defineCommand20 } from "citty";
|
|
4973
|
+
var listCmd7 = defineCommand20({
|
|
4276
4974
|
meta: {
|
|
4277
4975
|
name: "list",
|
|
4278
4976
|
description: "List all providers with enabled/disabled state and curated model counts"
|
|
@@ -4298,7 +4996,7 @@ var listCmd7 = defineCommand16({
|
|
|
4298
4996
|
for (const line of columnize(rows)) console.log(line);
|
|
4299
4997
|
}
|
|
4300
4998
|
});
|
|
4301
|
-
var modelsCmd =
|
|
4999
|
+
var modelsCmd = defineCommand20({
|
|
4302
5000
|
meta: {
|
|
4303
5001
|
name: "models",
|
|
4304
5002
|
description: "Show curated + catalog + live models for one provider"
|
|
@@ -4330,7 +5028,7 @@ var modelsCmd = defineCommand16({
|
|
|
4330
5028
|
}
|
|
4331
5029
|
}
|
|
4332
5030
|
});
|
|
4333
|
-
var modelsSetCmd =
|
|
5031
|
+
var modelsSetCmd = defineCommand20({
|
|
4334
5032
|
meta: {
|
|
4335
5033
|
name: "models-set",
|
|
4336
5034
|
description: "Replace the curated model list for a provider (comma-separated)"
|
|
@@ -4355,7 +5053,7 @@ var modelsSetCmd = defineCommand16({
|
|
|
4355
5053
|
for (const m of saved.models) console.log(` ${m}`);
|
|
4356
5054
|
}
|
|
4357
5055
|
});
|
|
4358
|
-
var enableCmd2 =
|
|
5056
|
+
var enableCmd2 = defineCommand20({
|
|
4359
5057
|
meta: { name: "enable", description: "Toggle a provider on so agents can use it" },
|
|
4360
5058
|
args: {
|
|
4361
5059
|
name: { type: "positional", required: true, description: "Provider id (e.g. anthropic)" }
|
|
@@ -4369,7 +5067,7 @@ var enableCmd2 = defineCommand16({
|
|
|
4369
5067
|
console.log(`${res.name}: enabled`);
|
|
4370
5068
|
}
|
|
4371
5069
|
});
|
|
4372
|
-
var disableCmd2 =
|
|
5070
|
+
var disableCmd2 = defineCommand20({
|
|
4373
5071
|
meta: {
|
|
4374
5072
|
name: "disable",
|
|
4375
5073
|
description: "Toggle a provider off \u2014 agents will refuse its model strings"
|
|
@@ -4386,7 +5084,7 @@ var disableCmd2 = defineCommand16({
|
|
|
4386
5084
|
console.log(`${res.name}: disabled`);
|
|
4387
5085
|
}
|
|
4388
5086
|
});
|
|
4389
|
-
var testCmd2 =
|
|
5087
|
+
var testCmd2 = defineCommand20({
|
|
4390
5088
|
meta: { name: "test", description: "Send a single chat to a model and print the reply" },
|
|
4391
5089
|
args: {
|
|
4392
5090
|
model: {
|
|
@@ -4407,7 +5105,7 @@ var testCmd2 = defineCommand16({
|
|
|
4407
5105
|
}
|
|
4408
5106
|
}
|
|
4409
5107
|
});
|
|
4410
|
-
var providerCommand =
|
|
5108
|
+
var providerCommand = defineCommand20({
|
|
4411
5109
|
meta: { name: "provider", description: "Manage and test LLM providers" },
|
|
4412
5110
|
subCommands: {
|
|
4413
5111
|
list: listCmd7,
|
|
@@ -4419,9 +5117,98 @@ var providerCommand = defineCommand16({
|
|
|
4419
5117
|
}
|
|
4420
5118
|
});
|
|
4421
5119
|
|
|
5120
|
+
// src/commands/result.ts
|
|
5121
|
+
import { closeSync as closeSync3, fsyncSync as fsyncSync3, openSync as openSync3, unlinkSync, writeFileSync as writeFileSync5 } from "fs";
|
|
5122
|
+
import { defineCommand as defineCommand21 } from "citty";
|
|
5123
|
+
var idArg = { type: "positional", required: true };
|
|
5124
|
+
var list6 = defineCommand21({
|
|
5125
|
+
meta: { name: "list", description: "List saved results released to the operator" },
|
|
5126
|
+
args: {
|
|
5127
|
+
team: { type: "string" },
|
|
5128
|
+
agent: { type: "string" },
|
|
5129
|
+
limit: { type: "string", default: "50" },
|
|
5130
|
+
offset: { type: "string", default: "0" },
|
|
5131
|
+
json: { type: "boolean" }
|
|
5132
|
+
},
|
|
5133
|
+
async run({ args }) {
|
|
5134
|
+
const query = new URLSearchParams({ limit: args.limit, offset: args.offset });
|
|
5135
|
+
if (args.team) query.set("teamId", args.team);
|
|
5136
|
+
if (args.agent) query.set("agentId", args.agent);
|
|
5137
|
+
const body = await createClient2().get(`/api/results?${query}`);
|
|
5138
|
+
if (args.json) return console.log(JSON.stringify(body, null, 2));
|
|
5139
|
+
if (!body.results.length) return console.log("(no saved results)");
|
|
5140
|
+
for (const line of columnize([
|
|
5141
|
+
["id", "filename", "bytes", "team", "agent", "created"],
|
|
5142
|
+
...body.results.map((r) => [
|
|
5143
|
+
r.id,
|
|
5144
|
+
r.name,
|
|
5145
|
+
String(r.byteLength),
|
|
5146
|
+
r.teamId,
|
|
5147
|
+
r.agentId,
|
|
5148
|
+
new Date(r.createdAt).toISOString()
|
|
5149
|
+
])
|
|
5150
|
+
]))
|
|
5151
|
+
console.log(line);
|
|
5152
|
+
console.log(`${body.offset + 1}\u2013${body.offset + body.results.length} of ${body.total}`);
|
|
5153
|
+
}
|
|
5154
|
+
});
|
|
5155
|
+
var show4 = defineCommand21({
|
|
5156
|
+
meta: { name: "show", description: "Inspect a saved result and its provenance" },
|
|
5157
|
+
args: { id: idArg, json: { type: "boolean" } },
|
|
5158
|
+
async run({ args }) {
|
|
5159
|
+
const { result } = await createClient2().get(
|
|
5160
|
+
`/api/results/${encodeURIComponent(args.id)}`
|
|
5161
|
+
);
|
|
5162
|
+
console.log(JSON.stringify(result, null, 2));
|
|
5163
|
+
}
|
|
5164
|
+
});
|
|
5165
|
+
var download = defineCommand21({
|
|
5166
|
+
meta: { name: "download", description: "Download a saved result to an explicit new file" },
|
|
5167
|
+
args: {
|
|
5168
|
+
id: idArg,
|
|
5169
|
+
output: {
|
|
5170
|
+
type: "string",
|
|
5171
|
+
required: true,
|
|
5172
|
+
description: "Destination path; existing files are never overwritten"
|
|
5173
|
+
}
|
|
5174
|
+
},
|
|
5175
|
+
async run({ args }) {
|
|
5176
|
+
const bytes = await createClient2().binary(
|
|
5177
|
+
`/api/results/${encodeURIComponent(args.id)}/download`
|
|
5178
|
+
);
|
|
5179
|
+
const fd = openSync3(args.output, "wx", 384);
|
|
5180
|
+
try {
|
|
5181
|
+
writeFileSync5(fd, bytes);
|
|
5182
|
+
fsyncSync3(fd);
|
|
5183
|
+
} catch (error) {
|
|
5184
|
+
closeSync3(fd);
|
|
5185
|
+
unlinkSync(args.output);
|
|
5186
|
+
throw error;
|
|
5187
|
+
}
|
|
5188
|
+
closeSync3(fd);
|
|
5189
|
+
console.log(`Saved ${bytes.byteLength} bytes to ${args.output}`);
|
|
5190
|
+
}
|
|
5191
|
+
});
|
|
5192
|
+
var rm = defineCommand21({
|
|
5193
|
+
meta: {
|
|
5194
|
+
name: "rm",
|
|
5195
|
+
description: "Delete saved bytes; retained history will report the result as deleted"
|
|
5196
|
+
},
|
|
5197
|
+
args: { id: idArg, yes: { type: "boolean" } },
|
|
5198
|
+
async run({ args }) {
|
|
5199
|
+
if (!args.yes) throw new Error("Pass --yes to permanently delete the saved file bytes");
|
|
5200
|
+
await createClient2().del(`/api/results/${encodeURIComponent(args.id)}`);
|
|
5201
|
+
console.log("Saved file deleted; historical references retain a deletion receipt.");
|
|
5202
|
+
}
|
|
5203
|
+
});
|
|
5204
|
+
var resultCommand = defineCommand21({
|
|
5205
|
+
meta: { name: "result", description: "Find, download and delete saved Agent results" },
|
|
5206
|
+
subCommands: { list: list6, show: show4, download, rm }
|
|
5207
|
+
});
|
|
5208
|
+
|
|
4422
5209
|
// src/commands/send.ts
|
|
4423
|
-
import { defineCommand as
|
|
4424
|
-
var sendCommand =
|
|
5210
|
+
import { defineCommand as defineCommand22 } from "citty";
|
|
5211
|
+
var sendCommand = defineCommand22({
|
|
4425
5212
|
meta: {
|
|
4426
5213
|
name: "send",
|
|
4427
5214
|
description: "Send a message from one agent to another"
|
|
@@ -4455,11 +5242,11 @@ var sendCommand = defineCommand17({
|
|
|
4455
5242
|
import { spawn as spawn3 } from "child_process";
|
|
4456
5243
|
import { existsSync as existsSync5 } from "fs";
|
|
4457
5244
|
import { join as join5 } from "path";
|
|
4458
|
-
import { defineCommand as
|
|
5245
|
+
import { defineCommand as defineCommand23 } from "citty";
|
|
4459
5246
|
var bundledDaemonEntry2 = join5(import.meta.dirname, "daemon.js");
|
|
4460
5247
|
var sourceDaemonEntry2 = join5(import.meta.dirname, "..", "..", "..", "daemon", "src", "index.ts");
|
|
4461
5248
|
var daemonEntry2 = existsSync5(bundledDaemonEntry2) ? bundledDaemonEntry2 : sourceDaemonEntry2;
|
|
4462
|
-
var serveCommand =
|
|
5249
|
+
var serveCommand = defineCommand23({
|
|
4463
5250
|
meta: {
|
|
4464
5251
|
name: "serve",
|
|
4465
5252
|
description: "Start the bazilion daemon (HTTP API)"
|
|
@@ -4526,7 +5313,7 @@ var serveCommand = defineCommand18({
|
|
|
4526
5313
|
});
|
|
4527
5314
|
|
|
4528
5315
|
// src/commands/session.ts
|
|
4529
|
-
import { defineCommand as
|
|
5316
|
+
import { defineCommand as defineCommand24 } from "citty";
|
|
4530
5317
|
function row(session) {
|
|
4531
5318
|
const state = session.revokedAt ? "revoked" : session.absoluteExpiresAt <= Date.now() || session.idleExpiresAt <= Date.now() ? "expired" : "active";
|
|
4532
5319
|
return [
|
|
@@ -4538,7 +5325,7 @@ function row(session) {
|
|
|
4538
5325
|
`absolute: ${new Date(session.absoluteExpiresAt).toISOString()}`
|
|
4539
5326
|
];
|
|
4540
5327
|
}
|
|
4541
|
-
var listCmd8 =
|
|
5328
|
+
var listCmd8 = defineCommand24({
|
|
4542
5329
|
meta: { name: "list", description: "List browser sessions" },
|
|
4543
5330
|
async run() {
|
|
4544
5331
|
const { sessions } = await createClient2().get("/api/sessions");
|
|
@@ -4549,7 +5336,7 @@ var listCmd8 = defineCommand19({
|
|
|
4549
5336
|
for (const line of columnize(sessions.map(row))) console.log(line);
|
|
4550
5337
|
}
|
|
4551
5338
|
});
|
|
4552
|
-
var revokeCmd =
|
|
5339
|
+
var revokeCmd = defineCommand24({
|
|
4553
5340
|
meta: { name: "revoke", description: "Revoke one browser session" },
|
|
4554
5341
|
args: { id: { type: "positional", required: true } },
|
|
4555
5342
|
async run({ args }) {
|
|
@@ -4557,22 +5344,22 @@ var revokeCmd = defineCommand19({
|
|
|
4557
5344
|
console.log(`revoked browser session ${args.id}`);
|
|
4558
5345
|
}
|
|
4559
5346
|
});
|
|
4560
|
-
var sessionCommand =
|
|
5347
|
+
var sessionCommand = defineCommand24({
|
|
4561
5348
|
meta: { name: "session", description: "Manage browser sessions" },
|
|
4562
5349
|
subCommands: { list: listCmd8, revoke: revokeCmd }
|
|
4563
5350
|
});
|
|
4564
5351
|
|
|
4565
5352
|
// src/commands/skill.ts
|
|
4566
|
-
import { existsSync as existsSync6, readFileSync as
|
|
4567
|
-
import { basename as
|
|
4568
|
-
import { defineCommand as
|
|
5353
|
+
import { existsSync as existsSync6, readFileSync as readFileSync8, statSync as statSync2 } from "fs";
|
|
5354
|
+
import { basename as basename5, resolve as resolve3 } from "path";
|
|
5355
|
+
import { defineCommand as defineCommand25 } from "citty";
|
|
4569
5356
|
function printFindings(findings, prefix = " ") {
|
|
4570
5357
|
for (const f of findings) {
|
|
4571
5358
|
const line = f.line ? ` line ${f.line}` : "";
|
|
4572
5359
|
console.log(`${prefix}${f.severity}: ${f.code}${line} - ${f.message}`);
|
|
4573
5360
|
}
|
|
4574
5361
|
}
|
|
4575
|
-
var listCmd9 =
|
|
5362
|
+
var listCmd9 = defineCommand25({
|
|
4576
5363
|
meta: { name: "list", description: "List installed skills (or those attached to an agent)" },
|
|
4577
5364
|
args: {
|
|
4578
5365
|
agent: { type: "string", description: "Filter to skills attached to this agent" }
|
|
@@ -4613,7 +5400,7 @@ var listCmd9 = defineCommand20({
|
|
|
4613
5400
|
}
|
|
4614
5401
|
}
|
|
4615
5402
|
});
|
|
4616
|
-
var importCmd =
|
|
5403
|
+
var importCmd = defineCommand25({
|
|
4617
5404
|
meta: {
|
|
4618
5405
|
name: "import",
|
|
4619
5406
|
description: "Import skills from openclaw, a directory, or a local .zip archive"
|
|
@@ -4629,12 +5416,12 @@ var importCmd = defineCommand20({
|
|
|
4629
5416
|
async run({ args }) {
|
|
4630
5417
|
const client = createClient2();
|
|
4631
5418
|
const absFrom = resolve3(args.from);
|
|
4632
|
-
const isLocalZip = args.from.toLowerCase().endsWith(".zip") && existsSync6(absFrom) &&
|
|
5419
|
+
const isLocalZip = args.from.toLowerCase().endsWith(".zip") && existsSync6(absFrom) && statSync2(absFrom).isFile();
|
|
4633
5420
|
let result;
|
|
4634
5421
|
try {
|
|
4635
5422
|
if (isLocalZip) {
|
|
4636
|
-
const bytes =
|
|
4637
|
-
const file = new File([bytes],
|
|
5423
|
+
const bytes = readFileSync8(absFrom);
|
|
5424
|
+
const file = new File([bytes], basename5(absFrom), { type: "application/zip" });
|
|
4638
5425
|
const fd = new FormData();
|
|
4639
5426
|
fd.set("file", file);
|
|
4640
5427
|
if (args.force) fd.set("force", "true");
|
|
@@ -4682,7 +5469,7 @@ var importCmd = defineCommand20({
|
|
|
4682
5469
|
}
|
|
4683
5470
|
}
|
|
4684
5471
|
});
|
|
4685
|
-
var rmCmd4 =
|
|
5472
|
+
var rmCmd4 = defineCommand25({
|
|
4686
5473
|
meta: { name: "rm", description: "Remove an installed skill" },
|
|
4687
5474
|
args: {
|
|
4688
5475
|
name: { type: "positional", required: true }
|
|
@@ -4693,7 +5480,7 @@ var rmCmd4 = defineCommand20({
|
|
|
4693
5480
|
console.log(`removed skill ${args.name}`);
|
|
4694
5481
|
}
|
|
4695
5482
|
});
|
|
4696
|
-
var skillCommand =
|
|
5483
|
+
var skillCommand = defineCommand25({
|
|
4697
5484
|
meta: { name: "skill", description: "Manage the skill library" },
|
|
4698
5485
|
subCommands: {
|
|
4699
5486
|
list: listCmd9,
|
|
@@ -4703,13 +5490,13 @@ var skillCommand = defineCommand20({
|
|
|
4703
5490
|
});
|
|
4704
5491
|
|
|
4705
5492
|
// src/commands/team.ts
|
|
4706
|
-
import { readFileSync as
|
|
5493
|
+
import { readFileSync as readFileSync10 } from "fs";
|
|
4707
5494
|
import { stdin as stdin2 } from "process";
|
|
4708
|
-
import { defineCommand as
|
|
5495
|
+
import { defineCommand as defineCommand27 } from "citty";
|
|
4709
5496
|
|
|
4710
5497
|
// src/commands/team-policy.ts
|
|
4711
|
-
import { readFileSync as
|
|
4712
|
-
import { defineCommand as
|
|
5498
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
5499
|
+
import { defineCommand as defineCommand26 } from "citty";
|
|
4713
5500
|
|
|
4714
5501
|
// src/team-interchange.ts
|
|
4715
5502
|
var TEAM_POLICY_INTERCHANGE_VERSION = 1;
|
|
@@ -4925,7 +5712,7 @@ function edgeDiff(before, after) {
|
|
|
4925
5712
|
// src/commands/team-policy.ts
|
|
4926
5713
|
function readJson(path) {
|
|
4927
5714
|
try {
|
|
4928
|
-
return JSON.parse(
|
|
5715
|
+
return JSON.parse(readFileSync9(path, "utf8"));
|
|
4929
5716
|
} catch (error) {
|
|
4930
5717
|
throw new Error(`invalid JSON: ${error.message}`);
|
|
4931
5718
|
}
|
|
@@ -4957,7 +5744,7 @@ function printPolicy(detail) {
|
|
|
4957
5744
|
console.log(line);
|
|
4958
5745
|
}
|
|
4959
5746
|
}
|
|
4960
|
-
var
|
|
5747
|
+
var show5 = defineCommand26({
|
|
4961
5748
|
meta: { name: "show", description: "Show the one effective live policy for a Team" },
|
|
4962
5749
|
args: {
|
|
4963
5750
|
team: { type: "positional", required: true },
|
|
@@ -4971,7 +5758,7 @@ var show2 = defineCommand21({
|
|
|
4971
5758
|
else printPolicy(detail);
|
|
4972
5759
|
}
|
|
4973
5760
|
});
|
|
4974
|
-
var exportCommand =
|
|
5761
|
+
var exportCommand = defineCommand26({
|
|
4975
5762
|
meta: { name: "export", description: "Export a revisioned Team policy document" },
|
|
4976
5763
|
args: { team: { type: "positional", required: true } },
|
|
4977
5764
|
async run({ args }) {
|
|
@@ -4995,7 +5782,7 @@ function printEdgeDiff(current, edges) {
|
|
|
4995
5782
|
for (const value of diff2.added) console.log(` + ${value}`);
|
|
4996
5783
|
for (const value of diff2.removed) console.log(` - ${value}`);
|
|
4997
5784
|
}
|
|
4998
|
-
var importCommand =
|
|
5785
|
+
var importCommand = defineCommand26({
|
|
4999
5786
|
meta: {
|
|
5000
5787
|
name: "import",
|
|
5001
5788
|
description: "Validate, diff, and explicitly replace a Team policy"
|
|
@@ -5050,7 +5837,7 @@ var importCommand = defineCommand21({
|
|
|
5050
5837
|
console.log(`updated Team ${args.team} policy to revision ${updated.teamPolicy.revision}`);
|
|
5051
5838
|
}
|
|
5052
5839
|
});
|
|
5053
|
-
var diff =
|
|
5840
|
+
var diff = defineCommand26({
|
|
5054
5841
|
meta: { name: "diff", description: "Compare live policy with its retained baseline source" },
|
|
5055
5842
|
args: {
|
|
5056
5843
|
team: { type: "positional", required: true },
|
|
@@ -5074,7 +5861,7 @@ var diff = defineCommand21({
|
|
|
5074
5861
|
);
|
|
5075
5862
|
}
|
|
5076
5863
|
});
|
|
5077
|
-
var evaluate =
|
|
5864
|
+
var evaluate = defineCommand26({
|
|
5078
5865
|
meta: {
|
|
5079
5866
|
name: "evaluate",
|
|
5080
5867
|
description: "Evaluate a communication path without sending or recording a block"
|
|
@@ -5105,7 +5892,7 @@ var evaluate = defineCommand21({
|
|
|
5105
5892
|
);
|
|
5106
5893
|
}
|
|
5107
5894
|
});
|
|
5108
|
-
var blocks =
|
|
5895
|
+
var blocks = defineCommand26({
|
|
5109
5896
|
meta: { name: "blocks", description: "List paginated durable communication denials" },
|
|
5110
5897
|
args: {
|
|
5111
5898
|
team: { type: "positional", required: true },
|
|
@@ -5154,10 +5941,10 @@ var blocks = defineCommand21({
|
|
|
5154
5941
|
if (page.nextCursor) console.log(`next cursor: ${page.nextCursor}`);
|
|
5155
5942
|
}
|
|
5156
5943
|
});
|
|
5157
|
-
var teamPolicyCommand =
|
|
5944
|
+
var teamPolicyCommand = defineCommand26({
|
|
5158
5945
|
meta: { name: "policy", description: "Inspect and manage the Team-owned live policy" },
|
|
5159
5946
|
subCommands: {
|
|
5160
|
-
show:
|
|
5947
|
+
show: show5,
|
|
5161
5948
|
export: exportCommand,
|
|
5162
5949
|
import: importCommand,
|
|
5163
5950
|
diff,
|
|
@@ -5167,7 +5954,7 @@ var teamPolicyCommand = defineCommand21({
|
|
|
5167
5954
|
});
|
|
5168
5955
|
|
|
5169
5956
|
// src/commands/team.ts
|
|
5170
|
-
var addCmd2 =
|
|
5957
|
+
var addCmd2 = defineCommand27({
|
|
5171
5958
|
meta: {
|
|
5172
5959
|
name: "add",
|
|
5173
5960
|
description: "Register a team at ~/.bazilion/teams/<slug>/ (use --link to point at an existing tree)"
|
|
@@ -5191,20 +5978,20 @@ var addCmd2 = defineCommand22({
|
|
|
5191
5978
|
console.log(`registered team ${g.id} at ${g.path}`);
|
|
5192
5979
|
}
|
|
5193
5980
|
});
|
|
5194
|
-
var listCmd10 =
|
|
5981
|
+
var listCmd10 = defineCommand27({
|
|
5195
5982
|
meta: { name: "list", description: "List teams" },
|
|
5196
5983
|
async run() {
|
|
5197
5984
|
const client = createClient2();
|
|
5198
|
-
const
|
|
5199
|
-
if (
|
|
5985
|
+
const list8 = await client.get("/api/teams");
|
|
5986
|
+
if (list8.length === 0) {
|
|
5200
5987
|
console.log("(no teams)");
|
|
5201
5988
|
return;
|
|
5202
5989
|
}
|
|
5203
|
-
const rows =
|
|
5990
|
+
const rows = list8.map((g) => [g.id, g.path]);
|
|
5204
5991
|
for (const line of columnize(rows)) console.log(line);
|
|
5205
5992
|
}
|
|
5206
5993
|
});
|
|
5207
|
-
var rmCmd5 =
|
|
5994
|
+
var rmCmd5 = defineCommand27({
|
|
5208
5995
|
meta: { name: "rm", description: "Remove a team registration" },
|
|
5209
5996
|
args: {
|
|
5210
5997
|
id: { type: "positional", required: true }
|
|
@@ -5225,7 +6012,7 @@ async function readStdin() {
|
|
|
5225
6012
|
for await (const chunk of stdin2) chunks.push(chunk);
|
|
5226
6013
|
return Buffer.concat(chunks).toString("utf8");
|
|
5227
6014
|
}
|
|
5228
|
-
var userMdShowCmd =
|
|
6015
|
+
var userMdShowCmd = defineCommand27({
|
|
5229
6016
|
meta: { name: "show", description: "Print the team's USER.md" },
|
|
5230
6017
|
args: { id: { type: "positional", required: true } },
|
|
5231
6018
|
async run({ args }) {
|
|
@@ -5235,7 +6022,7 @@ var userMdShowCmd = defineCommand22({
|
|
|
5235
6022
|
if (g.userMd && !g.userMd.endsWith("\n")) process.stdout.write("\n");
|
|
5236
6023
|
}
|
|
5237
6024
|
});
|
|
5238
|
-
var userMdSetCmd =
|
|
6025
|
+
var userMdSetCmd = defineCommand27({
|
|
5239
6026
|
meta: {
|
|
5240
6027
|
name: "set",
|
|
5241
6028
|
description: "Replace the team's USER.md (from --file, --from-stdin, or inline text)"
|
|
@@ -5249,7 +6036,7 @@ var userMdSetCmd = defineCommand22({
|
|
|
5249
6036
|
async run({ args }) {
|
|
5250
6037
|
let content;
|
|
5251
6038
|
if (args["from-stdin"]) content = await readStdin();
|
|
5252
|
-
else if (args.file) content =
|
|
6039
|
+
else if (args.file) content = readFileSync10(args.file, "utf8");
|
|
5253
6040
|
else if (args.text !== void 0) content = args.text;
|
|
5254
6041
|
else {
|
|
5255
6042
|
console.error("team user-md set: provide --file, --from-stdin, or --text");
|
|
@@ -5261,7 +6048,7 @@ var userMdSetCmd = defineCommand22({
|
|
|
5261
6048
|
console.log(`updated USER.md for team ${args.id} (${content.length} bytes)`);
|
|
5262
6049
|
}
|
|
5263
6050
|
});
|
|
5264
|
-
var userMdClearCmd =
|
|
6051
|
+
var userMdClearCmd = defineCommand27({
|
|
5265
6052
|
meta: { name: "clear", description: "Clear the team's USER.md to empty" },
|
|
5266
6053
|
args: { id: { type: "positional", required: true } },
|
|
5267
6054
|
async run({ args }) {
|
|
@@ -5271,7 +6058,7 @@ var userMdClearCmd = defineCommand22({
|
|
|
5271
6058
|
console.log(`cleared USER.md for team ${args.id}`);
|
|
5272
6059
|
}
|
|
5273
6060
|
});
|
|
5274
|
-
var userMdCmd =
|
|
6061
|
+
var userMdCmd = defineCommand27({
|
|
5275
6062
|
meta: { name: "user-md", description: "View or edit a team's USER.md" },
|
|
5276
6063
|
subCommands: {
|
|
5277
6064
|
show: userMdShowCmd,
|
|
@@ -5279,7 +6066,7 @@ var userMdCmd = defineCommand22({
|
|
|
5279
6066
|
clear: userMdClearCmd
|
|
5280
6067
|
}
|
|
5281
6068
|
});
|
|
5282
|
-
var topicFormatShowCmd =
|
|
6069
|
+
var topicFormatShowCmd = defineCommand27({
|
|
5283
6070
|
meta: { name: "show", description: "Print the team's Telegram topic-name template" },
|
|
5284
6071
|
args: { id: { type: "positional", required: true } },
|
|
5285
6072
|
async run({ args }) {
|
|
@@ -5288,7 +6075,7 @@ var topicFormatShowCmd = defineCommand22({
|
|
|
5288
6075
|
console.log(g.telegramTopicNameFormat ?? "(default naming)");
|
|
5289
6076
|
}
|
|
5290
6077
|
});
|
|
5291
|
-
var topicFormatSetCmd =
|
|
6078
|
+
var topicFormatSetCmd = defineCommand27({
|
|
5292
6079
|
meta: {
|
|
5293
6080
|
name: "set",
|
|
5294
6081
|
description: "Set the topic-name template. Tokens: {agent.name} {team.name} {team.slug} (must include {agent.name})"
|
|
@@ -5308,7 +6095,7 @@ var topicFormatSetCmd = defineCommand22({
|
|
|
5308
6095
|
console.log(`set topic-name template for team ${args.id}: ${g.telegramTopicNameFormat}`);
|
|
5309
6096
|
}
|
|
5310
6097
|
});
|
|
5311
|
-
var topicFormatClearCmd =
|
|
6098
|
+
var topicFormatClearCmd = defineCommand27({
|
|
5312
6099
|
meta: { name: "clear", description: "Clear the template (revert to built-in naming)" },
|
|
5313
6100
|
args: { id: { type: "positional", required: true } },
|
|
5314
6101
|
async run({ args }) {
|
|
@@ -5318,7 +6105,7 @@ var topicFormatClearCmd = defineCommand22({
|
|
|
5318
6105
|
console.log(`cleared topic-name template for team ${args.id}`);
|
|
5319
6106
|
}
|
|
5320
6107
|
});
|
|
5321
|
-
var topicFormatCmd =
|
|
6108
|
+
var topicFormatCmd = defineCommand27({
|
|
5322
6109
|
meta: {
|
|
5323
6110
|
name: "topic-format",
|
|
5324
6111
|
description: "View or edit a team's Telegram forum-topic name template"
|
|
@@ -5329,7 +6116,7 @@ var topicFormatCmd = defineCommand22({
|
|
|
5329
6116
|
clear: topicFormatClearCmd
|
|
5330
6117
|
}
|
|
5331
6118
|
});
|
|
5332
|
-
var teamCommand =
|
|
6119
|
+
var teamCommand = defineCommand27({
|
|
5333
6120
|
meta: { name: "team", description: "Manage teams (collaboration contexts)" },
|
|
5334
6121
|
subCommands: {
|
|
5335
6122
|
add: addCmd2,
|
|
@@ -5342,11 +6129,11 @@ var teamCommand = defineCommand22({
|
|
|
5342
6129
|
});
|
|
5343
6130
|
|
|
5344
6131
|
// src/commands/team-template.ts
|
|
5345
|
-
import { readFileSync as
|
|
5346
|
-
import { defineCommand as
|
|
6132
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
6133
|
+
import { defineCommand as defineCommand28 } from "citty";
|
|
5347
6134
|
function jsonFile(path) {
|
|
5348
6135
|
try {
|
|
5349
|
-
return JSON.parse(
|
|
6136
|
+
return JSON.parse(readFileSync11(path, "utf8"));
|
|
5350
6137
|
} catch (error) {
|
|
5351
6138
|
throw new Error(`invalid JSON: ${error.message}`);
|
|
5352
6139
|
}
|
|
@@ -5371,7 +6158,7 @@ function printTeam(detail) {
|
|
|
5371
6158
|
console.log(line);
|
|
5372
6159
|
}
|
|
5373
6160
|
}
|
|
5374
|
-
var
|
|
6161
|
+
var list7 = defineCommand28({
|
|
5375
6162
|
meta: { name: "list", description: "List canonical Team templates" },
|
|
5376
6163
|
args: { json: { type: "boolean", description: "Emit stable JSON" } },
|
|
5377
6164
|
async run({ args }) {
|
|
@@ -5385,7 +6172,7 @@ var list4 = defineCommand23({
|
|
|
5385
6172
|
console.log(line);
|
|
5386
6173
|
}
|
|
5387
6174
|
});
|
|
5388
|
-
var
|
|
6175
|
+
var show6 = defineCommand28({
|
|
5389
6176
|
meta: { name: "show", description: "Show a canonical Team template" },
|
|
5390
6177
|
args: {
|
|
5391
6178
|
id: { type: "positional", required: true },
|
|
@@ -5399,7 +6186,7 @@ var show3 = defineCommand23({
|
|
|
5399
6186
|
else printTeam(detail);
|
|
5400
6187
|
}
|
|
5401
6188
|
});
|
|
5402
|
-
var exportCommand2 =
|
|
6189
|
+
var exportCommand2 = defineCommand28({
|
|
5403
6190
|
meta: {
|
|
5404
6191
|
name: "export",
|
|
5405
6192
|
description: "Export a portable versioned Team-template document to stdout"
|
|
@@ -5439,7 +6226,7 @@ function printImportDiff(current, document) {
|
|
|
5439
6226
|
for (const value of diff2.added) console.log(` + ${value}`);
|
|
5440
6227
|
for (const value of diff2.removed) console.log(` - ${value}`);
|
|
5441
6228
|
}
|
|
5442
|
-
var importCommand2 =
|
|
6229
|
+
var importCommand2 = defineCommand28({
|
|
5443
6230
|
meta: {
|
|
5444
6231
|
name: "import",
|
|
5445
6232
|
description: "Validate, diff, and explicitly apply a portable Team-template document"
|
|
@@ -5520,17 +6307,17 @@ var importCommand2 = defineCommand23({
|
|
|
5520
6307
|
);
|
|
5521
6308
|
}
|
|
5522
6309
|
});
|
|
5523
|
-
var teamTemplateCommand =
|
|
6310
|
+
var teamTemplateCommand = defineCommand28({
|
|
5524
6311
|
meta: {
|
|
5525
6312
|
name: "team-template",
|
|
5526
6313
|
description: "Inspect and exchange canonical Team templates"
|
|
5527
6314
|
},
|
|
5528
|
-
subCommands: { list:
|
|
6315
|
+
subCommands: { list: list7, show: show6, export: exportCommand2, import: importCommand2 }
|
|
5529
6316
|
});
|
|
5530
6317
|
|
|
5531
6318
|
// src/commands/telegram.ts
|
|
5532
|
-
import { defineCommand as
|
|
5533
|
-
var setCmd2 =
|
|
6319
|
+
import { defineCommand as defineCommand29 } from "citty";
|
|
6320
|
+
var setCmd2 = defineCommand29({
|
|
5534
6321
|
meta: {
|
|
5535
6322
|
name: "set",
|
|
5536
6323
|
description: "Save bot token + supergroup chat ID (paired write)"
|
|
@@ -5548,7 +6335,7 @@ var setCmd2 = defineCommand24({
|
|
|
5548
6335
|
console.log(`saved \xB7 token ${state.botTokenPreview} \xB7 chat ${state.chatId}`);
|
|
5549
6336
|
}
|
|
5550
6337
|
});
|
|
5551
|
-
var clearCmd =
|
|
6338
|
+
var clearCmd = defineCommand29({
|
|
5552
6339
|
meta: {
|
|
5553
6340
|
name: "clear",
|
|
5554
6341
|
description: "Remove stored bot token + chat ID"
|
|
@@ -5559,7 +6346,7 @@ var clearCmd = defineCommand24({
|
|
|
5559
6346
|
console.log("cleared");
|
|
5560
6347
|
}
|
|
5561
6348
|
});
|
|
5562
|
-
var showCmd5 =
|
|
6349
|
+
var showCmd5 = defineCommand29({
|
|
5563
6350
|
meta: {
|
|
5564
6351
|
name: "show",
|
|
5565
6352
|
description: "Show what credentials are stored (token is masked)"
|
|
@@ -5580,7 +6367,7 @@ var showCmd5 = defineCommand24({
|
|
|
5580
6367
|
}
|
|
5581
6368
|
}
|
|
5582
6369
|
});
|
|
5583
|
-
var reconnectCmd =
|
|
6370
|
+
var reconnectCmd = defineCommand29({
|
|
5584
6371
|
meta: {
|
|
5585
6372
|
name: "reconnect",
|
|
5586
6373
|
description: "Apply a pending supergroup chat-id migration + re-activate the bot"
|
|
@@ -5591,7 +6378,7 @@ var reconnectCmd = defineCommand24({
|
|
|
5591
6378
|
console.log(`reconnected \xB7 chat ${state.chatId}`);
|
|
5592
6379
|
}
|
|
5593
6380
|
});
|
|
5594
|
-
var configCmd =
|
|
6381
|
+
var configCmd = defineCommand29({
|
|
5595
6382
|
meta: {
|
|
5596
6383
|
name: "config",
|
|
5597
6384
|
description: "Manage Telegram credentials (bot token + chat ID)"
|
|
@@ -5602,7 +6389,7 @@ var configCmd = defineCommand24({
|
|
|
5602
6389
|
show: showCmd5
|
|
5603
6390
|
}
|
|
5604
6391
|
});
|
|
5605
|
-
var healthCmd =
|
|
6392
|
+
var healthCmd = defineCommand29({
|
|
5606
6393
|
meta: {
|
|
5607
6394
|
name: "health",
|
|
5608
6395
|
description: "Run the four-step preflight against the Telegram Bot API"
|
|
@@ -5641,7 +6428,7 @@ var healthCmd = defineCommand24({
|
|
|
5641
6428
|
if (!allOk) process.exitCode = 1;
|
|
5642
6429
|
}
|
|
5643
6430
|
});
|
|
5644
|
-
var botStatusCmd =
|
|
6431
|
+
var botStatusCmd = defineCommand29({
|
|
5645
6432
|
meta: {
|
|
5646
6433
|
name: "status",
|
|
5647
6434
|
description: "Show polling state of the live bot"
|
|
@@ -5666,7 +6453,7 @@ var botStatusCmd = defineCommand24({
|
|
|
5666
6453
|
if (!p.running) process.exitCode = 1;
|
|
5667
6454
|
}
|
|
5668
6455
|
});
|
|
5669
|
-
var botRestartCmd =
|
|
6456
|
+
var botRestartCmd = defineCommand29({
|
|
5670
6457
|
meta: {
|
|
5671
6458
|
name: "restart",
|
|
5672
6459
|
description: "Force-restart the bot (tears down + brings up from current creds)"
|
|
@@ -5677,7 +6464,7 @@ var botRestartCmd = defineCommand24({
|
|
|
5677
6464
|
console.log("restart requested");
|
|
5678
6465
|
}
|
|
5679
6466
|
});
|
|
5680
|
-
var botCmd =
|
|
6467
|
+
var botCmd = defineCommand29({
|
|
5681
6468
|
meta: {
|
|
5682
6469
|
name: "bot",
|
|
5683
6470
|
description: "Inspect / control the live polling bot"
|
|
@@ -5687,7 +6474,7 @@ var botCmd = defineCommand24({
|
|
|
5687
6474
|
restart: botRestartCmd
|
|
5688
6475
|
}
|
|
5689
6476
|
});
|
|
5690
|
-
var bindCmd =
|
|
6477
|
+
var bindCmd = defineCommand29({
|
|
5691
6478
|
meta: {
|
|
5692
6479
|
name: "bind",
|
|
5693
6480
|
description: "Create a Telegram topic for an agent (manual fallback for /talk)"
|
|
@@ -5705,7 +6492,7 @@ var bindCmd = defineCommand24({
|
|
|
5705
6492
|
console.log(` ${result.deepLink}`);
|
|
5706
6493
|
}
|
|
5707
6494
|
});
|
|
5708
|
-
var unbindCmd =
|
|
6495
|
+
var unbindCmd = defineCommand29({
|
|
5709
6496
|
meta: {
|
|
5710
6497
|
name: "unbind",
|
|
5711
6498
|
description: "Clear an agent's Telegram topic binding (topic stays in Telegram as orphan)"
|
|
@@ -5719,7 +6506,7 @@ var unbindCmd = defineCommand24({
|
|
|
5719
6506
|
console.log(`unbound agent ${args.agent}`);
|
|
5720
6507
|
}
|
|
5721
6508
|
});
|
|
5722
|
-
var listBindingsCmd =
|
|
6509
|
+
var listBindingsCmd = defineCommand29({
|
|
5723
6510
|
meta: {
|
|
5724
6511
|
name: "list",
|
|
5725
6512
|
description: "List agents and their Telegram topic bindings"
|
|
@@ -5747,7 +6534,7 @@ var listBindingsCmd = defineCommand24({
|
|
|
5747
6534
|
}
|
|
5748
6535
|
}
|
|
5749
6536
|
});
|
|
5750
|
-
var allowCmd =
|
|
6537
|
+
var allowCmd = defineCommand29({
|
|
5751
6538
|
meta: { name: "allow", description: "Add a Telegram user id to the allowlist" },
|
|
5752
6539
|
args: {
|
|
5753
6540
|
userId: { type: "positional", required: true, description: "Numeric Telegram user id" },
|
|
@@ -5763,7 +6550,7 @@ var allowCmd = defineCommand24({
|
|
|
5763
6550
|
console.log(`allowed ${u.userId} (${u.role})`);
|
|
5764
6551
|
}
|
|
5765
6552
|
});
|
|
5766
|
-
var denyCmd =
|
|
6553
|
+
var denyCmd = defineCommand29({
|
|
5767
6554
|
meta: { name: "deny", description: "Remove a Telegram user id from the allowlist" },
|
|
5768
6555
|
args: { userId: { type: "positional", required: true } },
|
|
5769
6556
|
async run({ args }) {
|
|
@@ -5772,7 +6559,7 @@ var denyCmd = defineCommand24({
|
|
|
5772
6559
|
console.log(`removed ${args.userId}`);
|
|
5773
6560
|
}
|
|
5774
6561
|
});
|
|
5775
|
-
var allowedCmd =
|
|
6562
|
+
var allowedCmd = defineCommand29({
|
|
5776
6563
|
meta: { name: "allowed", description: "List allowlisted Telegram users" },
|
|
5777
6564
|
async run() {
|
|
5778
6565
|
const client = createClient2();
|
|
@@ -5787,7 +6574,7 @@ var allowedCmd = defineCommand24({
|
|
|
5787
6574
|
}
|
|
5788
6575
|
}
|
|
5789
6576
|
});
|
|
5790
|
-
var pairingCreateCmd =
|
|
6577
|
+
var pairingCreateCmd = defineCommand29({
|
|
5791
6578
|
meta: { name: "create", description: "Generate a one-time Telegram owner pairing code" },
|
|
5792
6579
|
async run() {
|
|
5793
6580
|
const result = await createClient2().post(
|
|
@@ -5798,7 +6585,7 @@ var pairingCreateCmd = defineCommand24({
|
|
|
5798
6585
|
console.log("send `/pair <code>` in the configured \u2699 bazilion service topic");
|
|
5799
6586
|
}
|
|
5800
6587
|
});
|
|
5801
|
-
var pairingStatusCmd =
|
|
6588
|
+
var pairingStatusCmd = defineCommand29({
|
|
5802
6589
|
meta: { name: "status", description: "Show Telegram owner pairing status" },
|
|
5803
6590
|
async run() {
|
|
5804
6591
|
const result = await createClient2().get("/api/config/telegram/pairing");
|
|
@@ -5809,14 +6596,14 @@ var pairingStatusCmd = defineCommand24({
|
|
|
5809
6596
|
console.log(`expires: ${new Date(result.challengeExpiresAt).toISOString()}`);
|
|
5810
6597
|
}
|
|
5811
6598
|
});
|
|
5812
|
-
var pairingCancelCmd =
|
|
6599
|
+
var pairingCancelCmd = defineCommand29({
|
|
5813
6600
|
meta: { name: "cancel", description: "Cancel the active Telegram pairing code" },
|
|
5814
6601
|
async run() {
|
|
5815
6602
|
await createClient2().del("/api/config/telegram/pairing/challenge");
|
|
5816
6603
|
console.log("pairing challenge cancelled");
|
|
5817
6604
|
}
|
|
5818
6605
|
});
|
|
5819
|
-
var pairingResetCmd =
|
|
6606
|
+
var pairingResetCmd = defineCommand29({
|
|
5820
6607
|
meta: { name: "reset", description: "Revoke the Telegram owner and require re-pairing" },
|
|
5821
6608
|
args: {
|
|
5822
6609
|
yes: { type: "boolean", description: "Confirm destructive owner reset", required: true }
|
|
@@ -5827,7 +6614,7 @@ var pairingResetCmd = defineCommand24({
|
|
|
5827
6614
|
console.log("Telegram owner reset; ingress is closed until re-paired");
|
|
5828
6615
|
}
|
|
5829
6616
|
});
|
|
5830
|
-
var pairingCmd =
|
|
6617
|
+
var pairingCmd = defineCommand29({
|
|
5831
6618
|
meta: { name: "pairing", description: "Manage single-owner Telegram pairing" },
|
|
5832
6619
|
subCommands: {
|
|
5833
6620
|
create: pairingCreateCmd,
|
|
@@ -5836,7 +6623,7 @@ var pairingCmd = defineCommand24({
|
|
|
5836
6623
|
reset: pairingResetCmd
|
|
5837
6624
|
}
|
|
5838
6625
|
});
|
|
5839
|
-
var telegramCommand =
|
|
6626
|
+
var telegramCommand = defineCommand29({
|
|
5840
6627
|
meta: {
|
|
5841
6628
|
name: "telegram",
|
|
5842
6629
|
description: "Telegram integration: credentials, health, bot lifecycle, bindings, access"
|
|
@@ -5857,7 +6644,7 @@ var telegramCommand = defineCommand24({
|
|
|
5857
6644
|
});
|
|
5858
6645
|
|
|
5859
6646
|
// src/commands/token.ts
|
|
5860
|
-
import { defineCommand as
|
|
6647
|
+
import { defineCommand as defineCommand30 } from "citty";
|
|
5861
6648
|
import qrcode from "qrcode-terminal";
|
|
5862
6649
|
function tokenRow(t) {
|
|
5863
6650
|
const last = t.lastUsedAt ? new Date(t.lastUsedAt).toISOString() : "(never)";
|
|
@@ -5886,7 +6673,7 @@ function resolveQrServer(override) {
|
|
|
5886
6673
|
}
|
|
5887
6674
|
return url.origin;
|
|
5888
6675
|
}
|
|
5889
|
-
var createCmd3 =
|
|
6676
|
+
var createCmd3 = defineCommand30({
|
|
5890
6677
|
meta: { name: "create", description: "Mint a new web token (shown once)" },
|
|
5891
6678
|
args: {
|
|
5892
6679
|
label: { type: "positional", required: true, description: "Human-readable label" },
|
|
@@ -5929,7 +6716,7 @@ var createCmd3 = defineCommand25({
|
|
|
5929
6716
|
qrcode.generate(pairUrl, { small: true }, (qr) => console.log(qr));
|
|
5930
6717
|
}
|
|
5931
6718
|
});
|
|
5932
|
-
var listCmd11 =
|
|
6719
|
+
var listCmd11 = defineCommand30({
|
|
5933
6720
|
meta: { name: "list", description: "List web tokens" },
|
|
5934
6721
|
args: {
|
|
5935
6722
|
all: { type: "boolean", description: "Include revoked tokens" }
|
|
@@ -5945,7 +6732,7 @@ var listCmd11 = defineCommand25({
|
|
|
5945
6732
|
for (const line of columnize(tokens.map(tokenRow))) console.log(line);
|
|
5946
6733
|
}
|
|
5947
6734
|
});
|
|
5948
|
-
var showLocalCmd =
|
|
6735
|
+
var showLocalCmd = defineCommand30({
|
|
5949
6736
|
meta: {
|
|
5950
6737
|
name: "show-local",
|
|
5951
6738
|
description: "Print the bootstrap web token stored in ~/.bazilion/auth.json"
|
|
@@ -5955,7 +6742,7 @@ var showLocalCmd = defineCommand25({
|
|
|
5955
6742
|
console.log(readAuthFile(paths.authFile).token);
|
|
5956
6743
|
}
|
|
5957
6744
|
});
|
|
5958
|
-
var revokeCmd2 =
|
|
6745
|
+
var revokeCmd2 = defineCommand30({
|
|
5959
6746
|
meta: { name: "revoke", description: "Revoke a web token" },
|
|
5960
6747
|
args: {
|
|
5961
6748
|
id: { type: "positional", required: true }
|
|
@@ -5966,7 +6753,7 @@ var revokeCmd2 = defineCommand25({
|
|
|
5966
6753
|
console.log(`revoked token ${args.id}`);
|
|
5967
6754
|
}
|
|
5968
6755
|
});
|
|
5969
|
-
var tokenCommand =
|
|
6756
|
+
var tokenCommand = defineCommand30({
|
|
5970
6757
|
meta: { name: "token", description: "Manage web tokens for API/CLI clients" },
|
|
5971
6758
|
subCommands: {
|
|
5972
6759
|
create: createCmd3,
|
|
@@ -5977,8 +6764,8 @@ var tokenCommand = defineCommand25({
|
|
|
5977
6764
|
});
|
|
5978
6765
|
|
|
5979
6766
|
// src/commands/trigger.ts
|
|
5980
|
-
import { defineCommand as
|
|
5981
|
-
var addCmd3 =
|
|
6767
|
+
import { defineCommand as defineCommand31 } from "citty";
|
|
6768
|
+
var addCmd3 = defineCommand31({
|
|
5982
6769
|
meta: { name: "add", description: "Add an interval / cron trigger to an agent" },
|
|
5983
6770
|
args: {
|
|
5984
6771
|
agent: { type: "positional", required: true },
|
|
@@ -6026,7 +6813,7 @@ function triggerRow(t) {
|
|
|
6026
6813
|
const msgPreview = t.message.length > 60 ? `${t.message.slice(0, 60)}\u2026` : t.message;
|
|
6027
6814
|
return [t.id, state, spec, `last: ${last}`, `"${msgPreview}"`];
|
|
6028
6815
|
}
|
|
6029
|
-
var listCmd12 =
|
|
6816
|
+
var listCmd12 = defineCommand31({
|
|
6030
6817
|
meta: { name: "list", description: "List triggers for an agent" },
|
|
6031
6818
|
args: {
|
|
6032
6819
|
agent: { type: "positional", required: true }
|
|
@@ -6043,7 +6830,7 @@ var listCmd12 = defineCommand26({
|
|
|
6043
6830
|
for (const line of columnize(triggers.map(triggerRow))) console.log(line);
|
|
6044
6831
|
}
|
|
6045
6832
|
});
|
|
6046
|
-
var rmCmd6 =
|
|
6833
|
+
var rmCmd6 = defineCommand31({
|
|
6047
6834
|
meta: { name: "rm", description: "Delete a trigger" },
|
|
6048
6835
|
args: {
|
|
6049
6836
|
id: { type: "positional", required: true }
|
|
@@ -6054,7 +6841,7 @@ var rmCmd6 = defineCommand26({
|
|
|
6054
6841
|
console.log(`removed trigger ${args.id}`);
|
|
6055
6842
|
}
|
|
6056
6843
|
});
|
|
6057
|
-
var enableCmd3 =
|
|
6844
|
+
var enableCmd3 = defineCommand31({
|
|
6058
6845
|
meta: { name: "enable", description: "Enable a trigger" },
|
|
6059
6846
|
args: {
|
|
6060
6847
|
id: { type: "positional", required: true }
|
|
@@ -6066,7 +6853,7 @@ var enableCmd3 = defineCommand26({
|
|
|
6066
6853
|
console.log(`enabled trigger ${args.id}`);
|
|
6067
6854
|
}
|
|
6068
6855
|
});
|
|
6069
|
-
var disableCmd3 =
|
|
6856
|
+
var disableCmd3 = defineCommand31({
|
|
6070
6857
|
meta: { name: "disable", description: "Disable a trigger" },
|
|
6071
6858
|
args: {
|
|
6072
6859
|
id: { type: "positional", required: true }
|
|
@@ -6078,7 +6865,7 @@ var disableCmd3 = defineCommand26({
|
|
|
6078
6865
|
console.log(`disabled trigger ${args.id}`);
|
|
6079
6866
|
}
|
|
6080
6867
|
});
|
|
6081
|
-
var historyCmd =
|
|
6868
|
+
var historyCmd = defineCommand31({
|
|
6082
6869
|
meta: { name: "history", description: "Show recent dispatches for a trigger" },
|
|
6083
6870
|
args: {
|
|
6084
6871
|
id: { type: "positional", required: true },
|
|
@@ -6106,7 +6893,7 @@ var historyCmd = defineCommand26({
|
|
|
6106
6893
|
for (const line of columnize(rows)) console.log(line);
|
|
6107
6894
|
}
|
|
6108
6895
|
});
|
|
6109
|
-
var triggerCommand =
|
|
6896
|
+
var triggerCommand = defineCommand31({
|
|
6110
6897
|
meta: { name: "trigger", description: "Manage scheduled agent triggers" },
|
|
6111
6898
|
subCommands: {
|
|
6112
6899
|
add: addCmd3,
|
|
@@ -6122,7 +6909,7 @@ var triggerCommand = defineCommand26({
|
|
|
6122
6909
|
import { existsSync as existsSync7, lstatSync as lstatSync3, readdirSync as readdirSync2, realpathSync as realpathSync2, rmSync as rmSync4 } from "fs";
|
|
6123
6910
|
import { homedir as homedir2 } from "os";
|
|
6124
6911
|
import { isAbsolute as isAbsolute2, join as join6, parse as parse2, relative as relative2, resolve as resolve4, sep } from "path";
|
|
6125
|
-
import { defineCommand as
|
|
6912
|
+
import { defineCommand as defineCommand32 } from "citty";
|
|
6126
6913
|
function makeLineReader() {
|
|
6127
6914
|
let buffer = "";
|
|
6128
6915
|
let ended = false;
|
|
@@ -6209,7 +6996,7 @@ function assertSafeUninstallHome(home) {
|
|
|
6209
6996
|
}
|
|
6210
6997
|
return target;
|
|
6211
6998
|
}
|
|
6212
|
-
var uninstallCommand =
|
|
6999
|
+
var uninstallCommand = defineCommand32({
|
|
6213
7000
|
meta: {
|
|
6214
7001
|
name: "uninstall",
|
|
6215
7002
|
description: "Wipe bazilion state from ~/.bazilion (or BAZILION_HOME)"
|
|
@@ -6313,7 +7100,7 @@ var uninstallCommand = defineCommand27({
|
|
|
6313
7100
|
|
|
6314
7101
|
// src/index.ts
|
|
6315
7102
|
var VERSION = package_default.version;
|
|
6316
|
-
var main =
|
|
7103
|
+
var main = defineCommand33({
|
|
6317
7104
|
meta: {
|
|
6318
7105
|
name: "bazilion",
|
|
6319
7106
|
version: VERSION,
|
|
@@ -6327,6 +7114,11 @@ var main = defineCommand28({
|
|
|
6327
7114
|
agent: agentCommand,
|
|
6328
7115
|
approval: approvalCommand,
|
|
6329
7116
|
attention: attentionCommand,
|
|
7117
|
+
result: resultCommand,
|
|
7118
|
+
conversation: conversationCommand,
|
|
7119
|
+
queue: queueCommand,
|
|
7120
|
+
question: questionCommand,
|
|
7121
|
+
notification: notificationCommand,
|
|
6330
7122
|
skill: skillCommand,
|
|
6331
7123
|
memory: memoryCommand,
|
|
6332
7124
|
mcp: mcpCommand,
|
|
@@ -6462,7 +7254,7 @@ function printTopLevelHelp() {
|
|
|
6462
7254
|
}
|
|
6463
7255
|
console.log("Use `bazilion <command> --help` for more information about a command.");
|
|
6464
7256
|
}
|
|
6465
|
-
async function
|
|
7257
|
+
async function entry2() {
|
|
6466
7258
|
const rawArgs = process.argv.slice(2);
|
|
6467
7259
|
try {
|
|
6468
7260
|
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
@@ -6485,5 +7277,5 @@ async function entry() {
|
|
|
6485
7277
|
process.exit(exitCodeForError(err));
|
|
6486
7278
|
}
|
|
6487
7279
|
}
|
|
6488
|
-
|
|
7280
|
+
entry2();
|
|
6489
7281
|
//# sourceMappingURL=cli.js.map
|