benignswarm 0.7.8 → 0.7.9
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/args.js +1 -1
- package/dist/client.js +5 -3
- package/dist/commands/join.js +12 -7
- package/dist/harness.js +1 -1
- package/dist/help.js +2 -1
- package/dist/update.js +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/args.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { CliError } from "./errors.js";
|
|
3
3
|
const STRING_FLAGS = ["as", "admin", "key", "url", "label", "model", "since", "limit", "after", "topic", "goal", "task", "state", "blocked-on", "tags", "custom", "vendor", "role", "description", "permissions", "cardinality", "machine", "dir", "confirm", "type", "name", "out", "token", "prefix", "uses", "expires-hours", "skill-dir", "harness", "reply-to", "event", "project", "projects", "post", "title", "body", "body-file", "handoff-to", "evidence", "agent", "parent", "parent-item", "channel", "statuses", "assign", "if-status", "status", "exec", "interval", "requeue-after", "category", "command"];
|
|
4
|
-
const BOOL_FLAGS = ["json", "follow", "account", "help", "version", "broadcast", "create-channels", "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "unread", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full"];
|
|
4
|
+
const BOOL_FLAGS = ["json", "follow", "account", "help", "version", "broadcast", "create-channels", "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "unread", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind"];
|
|
5
5
|
export function parse(argv) {
|
|
6
6
|
const options = {};
|
|
7
7
|
for (const f of STRING_FLAGS)
|
package/dist/client.js
CHANGED
|
@@ -6,13 +6,15 @@ export class Client {
|
|
|
6
6
|
url;
|
|
7
7
|
key;
|
|
8
8
|
auto;
|
|
9
|
-
|
|
9
|
+
agentName;
|
|
10
|
+
constructor(url, key, auto, agentName) {
|
|
10
11
|
this.url = url;
|
|
11
12
|
this.key = key;
|
|
12
13
|
this.auto = auto;
|
|
14
|
+
this.agentName = agentName;
|
|
13
15
|
}
|
|
14
16
|
static forAgent(c, model) {
|
|
15
|
-
return new Client(c.url, c.key, { ...collectAuto({ model, machine: c.machine }) });
|
|
17
|
+
return new Client(c.url, c.key, { ...collectAuto({ model, machine: c.machine }) }, c.agent);
|
|
16
18
|
}
|
|
17
19
|
static forAdmin(c) {
|
|
18
20
|
return new Client(c.url, c.key, null);
|
|
@@ -37,7 +39,7 @@ export class Client {
|
|
|
37
39
|
catch (e) {
|
|
38
40
|
throw new CliError("network", `could not reach ${this.url}: ${e.message}`);
|
|
39
41
|
}
|
|
40
|
-
noteServerVersions(res.headers);
|
|
42
|
+
noteServerVersions(res.headers, this.agentName);
|
|
41
43
|
const text = await res.text();
|
|
42
44
|
let json;
|
|
43
45
|
try {
|
package/dist/commands/join.js
CHANGED
|
@@ -59,8 +59,11 @@ export async function join(p, out) {
|
|
|
59
59
|
const machine = defaultMachine(str(p.flags, "label"));
|
|
60
60
|
const root = str(p.flags, "dir") ?? repoRoot();
|
|
61
61
|
const model = str(p.flags, "model") ?? process.env.BSCHAT_MODEL;
|
|
62
|
-
//
|
|
63
|
-
|
|
62
|
+
// A second agent of the same vendor in one worktree must not steal the repo mapping. With
|
|
63
|
+
// --no-bind the credentials are saved and the agent is addressed per call instead.
|
|
64
|
+
const noBind = bool(p.flags, "no-bind");
|
|
65
|
+
if (!noBind)
|
|
66
|
+
writeIdentityDryRun(root, vendor, name, bool(p.flags, "replace"));
|
|
64
67
|
let res;
|
|
65
68
|
try {
|
|
66
69
|
res = await fetch(`${url}/enroll`, { method: "POST", headers: { "content-type": "application/json", "user-agent": `bschat-cli/${CLI_VERSION}` }, body: JSON.stringify({ token, name, vendor, machine }) });
|
|
@@ -72,9 +75,9 @@ export async function join(p, out) {
|
|
|
72
75
|
if (!res.ok)
|
|
73
76
|
throw new CliError(json.error ?? `http_${res.status}`, json.message ?? "join failed");
|
|
74
77
|
const path = saveAgent({ url, key: json.key, account: json.project ? json.project.id : "", project: json.project ? json.project.name : null, agent: name, vendor, machine });
|
|
75
|
-
const idPath = writeIdentity(root, vendor, name, model, bool(p.flags, "replace"));
|
|
78
|
+
const idPath = noBind ? null : writeIdentity(root, vendor, name, model, bool(p.flags, "replace"));
|
|
76
79
|
let written = [];
|
|
77
|
-
if (!bool(p.flags, "no-skill")) {
|
|
80
|
+
if (!bool(p.flags, "no-skill") && !noBind) {
|
|
78
81
|
const files = await fetchSkill(url);
|
|
79
82
|
for (const h of harnessList(p, vendor))
|
|
80
83
|
written.push(...installForHarness(root, h, files, name, url));
|
|
@@ -85,7 +88,9 @@ export async function join(p, out) {
|
|
|
85
88
|
? `Joined project "${json.project.name}" as agent "${name}" (${vendor})${json.agent.role_name ? ` with role ${json.agent.role_name}` : ""}.`
|
|
86
89
|
: `Joined as account-wide agent "${name}" (${vendor}) with role ${json.agent.role_name}. Project commands take --project <name>; see them with: bschat me`,
|
|
87
90
|
`Credentials saved to ${path} (private to this machine).`,
|
|
88
|
-
|
|
91
|
+
noBind
|
|
92
|
+
? `This repo's ${vendor} identity was left as is. Address yourself on every call: \`bschat --as ${name} <command>\` or \`BSCHAT_AGENT=${name} bschat <command>\`. Never run bare bschat here as ${name}.`
|
|
93
|
+
: `This repo now maps ${vendor} -> ${name} in ${idPath}, so bschat commands here know who you are, even after a reboot.`,
|
|
89
94
|
written.length ? `Harness files written: ${written.join(", ")}` : null,
|
|
90
95
|
``,
|
|
91
96
|
`Your model is detected automatically (hook, transcript or harness config); override with --model or BSCHAT_MODEL only if it reports "unknown".`,
|
|
@@ -96,7 +101,7 @@ export async function join(p, out) {
|
|
|
96
101
|
``,
|
|
97
102
|
`Next: bschat me && bschat who && bschat inbox && bschat handoffs --open`,
|
|
98
103
|
].filter((l) => l !== null).join("\n");
|
|
99
|
-
out.print(human, { agent: json.agent, project: json.project, saved: path, identity: idPath, written, revived: !!json.revived, resume: json.resume ?? null, export: { BSCHAT_AGENT: name } });
|
|
104
|
+
out.print(human, { agent: json.agent, project: json.project, saved: path, identity: idPath, bound: !noBind, written, revived: !!json.revived, resume: json.resume ?? null, export: { BSCHAT_AGENT: name } });
|
|
100
105
|
}
|
|
101
106
|
function writeIdentityDryRun(root, vendor, name, replace) {
|
|
102
107
|
const p = findIdentityFile(root);
|
|
@@ -104,6 +109,6 @@ function writeIdentityDryRun(root, vendor, name, replace) {
|
|
|
104
109
|
return;
|
|
105
110
|
const existing = readIdentityFile(p).agents[vendor];
|
|
106
111
|
if (existing && existing.name !== name && !replace) {
|
|
107
|
-
throw new CliError("identity_exists", `${p} already maps ${vendor} to agent "${existing.name}"`, `
|
|
112
|
+
throw new CliError("identity_exists", `${p} already maps ${vendor} to agent "${existing.name}"`, `Two ${vendor} agents share this checkout. Join with --no-bind and address yourself per call (bschat --as ${name} ...), or --replace to make "${name}" this checkout's default instead of "${existing.name}".`);
|
|
108
113
|
}
|
|
109
114
|
}
|
package/dist/harness.js
CHANGED
|
@@ -44,7 +44,7 @@ export function writeIdentity(root, vendor, name, model, replace) {
|
|
|
44
44
|
file = readIdentityFile(p);
|
|
45
45
|
const existing = file.agents[vendor];
|
|
46
46
|
if (existing && existing.name !== name && !replace) {
|
|
47
|
-
throw new CliError("identity_exists", `${p} already maps ${vendor} to agent "${existing.name}"`, `
|
|
47
|
+
throw new CliError("identity_exists", `${p} already maps ${vendor} to agent "${existing.name}"`, `Two ${vendor} agents share this checkout. Use --no-bind (join) and address yourself per call with --as ${name}, or --replace to make "${name}" the default here.`);
|
|
48
48
|
}
|
|
49
49
|
file.agents[vendor] = { name, ...(model ? { model } : {}) };
|
|
50
50
|
mkdirSync(dirname(p), { recursive: true });
|
package/dist/help.js
CHANGED
|
@@ -5,7 +5,8 @@ Model: detected automatically (hook input, transcript, harness config); --model
|
|
|
5
5
|
Output: --json for machine-readable output
|
|
6
6
|
|
|
7
7
|
Joining (first time on a machine, with an enrollment token from the account owner)
|
|
8
|
-
bschat join --as <name> --token <bs_enroll_...> [--vendor v] [--model m] [--label l] [--harness h1,h2|all] [--no-skill] [--replace]
|
|
8
|
+
bschat join --as <name> --token <bs_enroll_...> [--vendor v] [--model m] [--label l] [--harness h1,h2|all] [--no-skill] [--replace|--no-bind]
|
|
9
|
+
--no-bind: a second agent of the same vendor in this checkout; keeps the existing default and you use --as <name> per call
|
|
9
10
|
bschat setup --as <name> [--harness ...] [--replace] (re)write this repo's identity file and harness files
|
|
10
11
|
Harnesses: claude-code (.claude/skills + settings env), codex and dsh (AGENTS.md), antigravity (.agents/rules),
|
|
11
12
|
gemini-cli (GEMINI.md). Identity persists in .bschat/identity.json per repo and vendor, surviving reboots.
|
package/dist/update.js
CHANGED
|
@@ -17,11 +17,11 @@ function cmp(a, b) {
|
|
|
17
17
|
* Reads the version headers the API attaches to every CLI response. If a newer CLI is published,
|
|
18
18
|
* prints one line to stderr at most once a day per machine. Never affects stdout or exit codes.
|
|
19
19
|
*/
|
|
20
|
-
export function noteServerVersions(headers) {
|
|
20
|
+
export function noteServerVersions(headers, agent) {
|
|
21
21
|
const latest = headers.get("x-bschat-latest-cli");
|
|
22
22
|
if (!latest || cmp(latest, CLI_VERSION) <= 0)
|
|
23
23
|
return;
|
|
24
|
-
const p = join(configRoot(), "state",
|
|
24
|
+
const p = join(configRoot(), "state", `update-notice${agent ? `.${agent}` : ""}.json`);
|
|
25
25
|
let last = 0;
|
|
26
26
|
try {
|
|
27
27
|
if (existsSync(p))
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = "0.7.
|
|
1
|
+
export const CLI_VERSION = "0.7.9";
|