@cogitator-ai/cli 0.20.0 → 0.22.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/README.md +23 -4
- package/dist/commands/bridge-install.d.ts +53 -0
- package/dist/commands/bridge-install.d.ts.map +1 -0
- package/dist/commands/bridge-install.js +239 -0
- package/dist/commands/bridge-install.js.map +1 -0
- package/dist/commands/bridge-session.d.ts +17 -1
- package/dist/commands/bridge-session.d.ts.map +1 -1
- package/dist/commands/bridge-session.js +175 -3
- package/dist/commands/bridge-session.js.map +1 -1
- package/dist/commands/bridge-tools.d.ts +48 -0
- package/dist/commands/bridge-tools.d.ts.map +1 -0
- package/dist/commands/bridge-tools.js +103 -0
- package/dist/commands/bridge-tools.js.map +1 -0
- package/dist/commands/bridge.d.ts +3 -0
- package/dist/commands/bridge.d.ts.map +1 -1
- package/dist/commands/bridge.js +106 -3
- package/dist/commands/bridge.js.map +1 -1
- package/dist/utils/bridge-adapters.d.ts +24 -1
- package/dist/utils/bridge-adapters.d.ts.map +1 -1
- package/dist/utils/bridge-adapters.js +55 -2
- package/dist/utils/bridge-adapters.js.map +1 -1
- package/dist/utils/bridge-host.d.ts.map +1 -1
- package/dist/utils/bridge-host.js +7 -1
- package/dist/utils/bridge-host.js.map +1 -1
- package/dist/utils/bridge-person.d.ts +38 -0
- package/dist/utils/bridge-person.d.ts.map +1 -0
- package/dist/utils/bridge-person.js +60 -0
- package/dist/utils/bridge-person.js.map +1 -0
- package/dist/utils/cli.d.ts +5 -3
- package/dist/utils/cli.d.ts.map +1 -1
- package/dist/utils/cli.js +9 -5
- package/dist/utils/cli.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -381,6 +381,8 @@ The PID file (`.cogitator/daemon.pid`) records the launched script, so `stop` ne
|
|
|
381
381
|
The agent bridge (experimental): Claude Code, Codex and other agents hand each other jobs, ask questions on the way and report back, each in its own window. The bridge is a dispatcher, one per machine, shared by every project. See [`@cogitator-ai/bridge`](https://www.npmjs.com/package/@cogitator-ai/bridge).
|
|
382
382
|
|
|
383
383
|
```bash
|
|
384
|
+
cogitator bridge install [harness] # give Claude Code and Codex the bridge in this project
|
|
385
|
+
cogitator bridge uninstall [harness] # take out what install put in
|
|
384
386
|
cogitator bridge serve # the dispatcher in the foreground, until Ctrl+C
|
|
385
387
|
cogitator bridge status [--json] # the dispatcher, the sessions it knows, the jobs in progress
|
|
386
388
|
cogitator bridge log # the last 50 entries of the journal
|
|
@@ -391,13 +393,15 @@ cogitator bridge log --json # one line of JSON per entry
|
|
|
391
393
|
cogitator bridge doctor [--json] # whether Claude Code and Codex can be reached, and what to fix
|
|
392
394
|
```
|
|
393
395
|
|
|
394
|
-
`serve` reaches Claude Code and Codex sessions through their own commands: it starts a session for a job (`claude --bg`, `codex exec`), hands letters to Codex threads (`codex queue`) and answers the hooks of Claude Code sessions that wait for mail. With `--home <dir>` the sessions it starts are told that folder, so they call this dispatcher. A hook runs the command line the way `serve` itself was run, by absolute paths, so it does not depend on the `PATH` of a session. `COGITATOR_BRIDGE_COMMAND` names another way, such as `cogitator bridge`. A Codex thread it starts works in the `workspace-write` sandbox, which keeps
|
|
396
|
+
`serve` reaches Claude Code and Codex sessions through their own commands: it starts a session for a job (`claude --bg`, `codex exec`), hands letters to Codex threads (`codex queue`) and answers the hooks of Claude Code sessions that wait for mail. With `--home <dir>` the sessions it starts are told that folder, so they call this dispatcher. A hook runs the command line the way `serve` itself was run, by absolute paths, so it does not depend on the `PATH` of a session. `COGITATOR_BRIDGE_COMMAND` names another way, such as `cogitator bridge`. The sessions it starts get the bridge's tools with them, so they ask, answer and report whatever their sandbox. A Codex thread it starts works in the `workspace-write` sandbox, which keeps its shell commands from the bridge's socket and its tools from nothing, and a thread whose turn ends without a report gets its final answer taken as one. `--codex-sandbox <mode>` or `COGITATOR_BRIDGE_CODEX_SANDBOX` names another sandbox (`read-only`, `danger-full-access`) for what the thread itself may do: `danger-full-access` holds nothing back. What a Codex thread it started prints is kept in `sessions/` of the bridge's folder. It refuses to start while another dispatcher runs and names its PID. `status` exits 0 when a dispatcher runs and 1 when none does. `log` reads the store itself, so it works after the dispatcher stopped, and prints what agents wrote on one line each without control characters. The files live in `~/.cogitator/bridge` (`bridge.db`, `bridge.sock`), `COGITATOR_BRIDGE_HOME` or `--home <dir>` moves them.
|
|
395
397
|
|
|
396
398
|
With `cogitator daemon start --bridge` the assistant daemon hosts the dispatcher, so no second process is needed.
|
|
397
399
|
|
|
398
|
-
`doctor` checks the dispatcher, then each harness: its version, the commands the bridge needs from it, whether Claude Code trusts the folder (`--cwd <dir>`, the current one by default), whether sessions opened in it carry the wake hook, and whether Codex's local daemon runs. Every finding that is not fine comes with what to do. It exits 1 when something the bridge needs is missing, 0 when at most warnings are left.
|
|
400
|
+
`doctor` checks the dispatcher, then each harness: its version, the commands the bridge needs from it, whether Claude Code trusts the folder (`--cwd <dir>`, the current one by default), whether sessions opened in it carry the wake hook and have the bridge's tools, whether a hook tells the tools which session calls, and whether Codex's local daemon runs. Every finding that is not fine comes with what to do. It exits 1 when something the bridge needs is missing, 0 when at most warnings are left.
|
|
399
401
|
|
|
400
|
-
|
|
402
|
+
`install` sets the harnesses up for the sessions you open: `claude`, `codex`, or both when none is named, leaving out one that is not installed. It lists every change, asks once, and makes them: the server of tools (`claude mcp add --scope local`, `codex mcp add`), for Claude Code the hooks and the rule for the tools in the project's `.claude/settings.local.json`, and the notes in `CLAUDE.md` and `AGENTS.md`. `--dry-run` only lists, `-y` does not ask, and without a terminal nothing is changed unless `-y` is there. `--user` sets every project of yours up, `--take-jobs` lets sessions carry out the jobs of other agents without asking you first, `--no-notes` leaves the instructions files alone and `--no-allow` keeps Claude Code's permission prompt for the bridge tools. `--cwd <dir>` names another project, `--json` prints the changes. Running it again changes only what is out of date. `uninstall` takes the same out again, and leaves Codex its server unless `--user` is there, since Codex keeps its servers for every project.
|
|
403
|
+
|
|
404
|
+
A session with the tools needs no command line. One without them, and you at a terminal inside one, calls the bridge from a shell, known by the id its harness put into the environment (`CLAUDE_CODE_SESSION_ID`, `CODEX_THREAD_ID`):
|
|
401
405
|
|
|
402
406
|
```bash
|
|
403
407
|
cogitator bridge delegate <to> [text...] # hand a job over: --title, --cwd, --check <command>, --parent <job>
|
|
@@ -405,11 +409,26 @@ cogitator bridge send [text...] --job <n> --kind <question|answer|report|note|pe
|
|
|
405
409
|
cogitator bridge inbox # the letters that wait: --job <n>, --peek, --unhandled
|
|
406
410
|
cogitator bridge cancel <job> [reason...] # take back a job this session handed over
|
|
407
411
|
cogitator bridge wait # wait for mail and exit with 2 when it comes
|
|
412
|
+
cogitator bridge mcp # serve the bridge tools over MCP (stdio)
|
|
413
|
+
cogitator bridge caller --hook claude-code # tell the tools which session calls
|
|
408
414
|
```
|
|
409
415
|
|
|
416
|
+
What waits for your own word is answered from a terminal that is not a session of an agent:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
cogitator bridge asks # permission requests and questions left to you
|
|
420
|
+
cogitator bridge allow <job-or-letter> [reason...] # allow the call an agent asks leave for
|
|
421
|
+
cogitator bridge deny <job-or-letter> [reason...] # refuse it
|
|
422
|
+
cogitator bridge reply <job-or-letter> [text...] # answer a question
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
A call an agent asks leave for is yours to decide when the rules of the agent that handed the job over would have it ask you too, and a question is yours when an agent left it to you. A session that got a permission request decides it with `send --kind answer --decision allow` or `deny`, and leaves it or a question to you with `--decision person`. `serve` and the daemon also keep these letters in `inbox.json` in the folder of the bridge, and send them to a Telegram chat when `COGITATOR_BRIDGE_TELEGRAM_TOKEN` and `COGITATOR_BRIDGE_TELEGRAM_CHAT` are set: a request with Allow and Refuse buttons, a question to reply to. `COGITATOR_BRIDGE_TELEGRAM_USERS` names who in that chat may answer.
|
|
426
|
+
|
|
410
427
|
`delegate` prints the number of the job and returns at once, the answer arrives as a letter. `<to>` is `codex`, `claude`, the name of an agent, or `codex:new` for a fresh session. The text of `delegate` and `send` is the arguments, or stdin when there are none or they are `-`. A text that starts with a dash goes after `--`. `send --kind report --failed` reports a job that could not be done, `--reply-to <letter>` names the letter an answer is for. All three take `--json`.
|
|
411
428
|
|
|
412
|
-
`wait` is what the wake hook of a Claude Code session runs: it waits for the mail of the session (`--timeout <seconds>`, 600 by default), and when a letter comes writes it to stderr and exits with code 2, which makes Claude Code wake the session with it. With `--hook claude-code` it takes the session from what Claude Code wrote to the hook's stdin, and `--agent <name>` is the name the bridge gave a session it started. Under the letters it adds one line saying how to answer through the bridge. Without mail it exits with 0 and prints nothing. A failure, a mistyped option included, exits with 1 and never with 2, so an error cannot wake a session. See the [`@cogitator-ai/bridge`](https://www.npmjs.com/package/@cogitator-ai/bridge#claude-code-and-codex) for the hook itself.
|
|
429
|
+
`wait` is what the wake hook of a Claude Code session runs: it waits for the mail of the session (`--timeout <seconds>`, 600 by default), and when a letter comes writes it to stderr and exits with code 2, which makes Claude Code wake the session with it. With `--hook claude-code` it takes the session from what Claude Code wrote to the hook's stdin, and `--agent <name>` is the name the bridge gave a session it started. Under the letters it adds one line saying how to answer through the bridge: with the tools when `--tools` says the session has them, with the command line otherwise. Without mail it exits with 0 and prints nothing. A failure, a mistyped option included, exits with 1 and never with 2, so an error cannot wake a session. See the [`@cogitator-ai/bridge`](https://www.npmjs.com/package/@cogitator-ai/bridge#claude-code-and-codex) for the hook itself.
|
|
430
|
+
|
|
431
|
+
`mcp` is the server of the bridge's tools, started by a harness for a session, not by you: `delegate`, `ask`, `answer`, `report`, `note`, `inbox`, `job`, `jobs`, `cancel` and `agents`. It connects to the dispatcher for each call, so it may start before the dispatcher does. `caller` is the hook Claude Code runs before a call of one of these tools: it adds the session to the arguments of the call, since Claude Code keeps one server across `/clear`. It never exits with 2, which Claude Code would read as a refusal of the tool call. A folder of the bridge that is not the default one (`--home`, `COGITATOR_BRIDGE_HOME`) is written into the command of the server and of the hooks, since a harness does not always hand its environment on.
|
|
413
432
|
|
|
414
433
|
---
|
|
415
434
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cogitator bridge install | uninstall - give the sessions a person opens in Claude Code and
|
|
3
|
+
* Codex the bridge, and take it away again
|
|
4
|
+
*/
|
|
5
|
+
import { type AdapterSetup } from '@cogitator-ai/bridge';
|
|
6
|
+
import { type InstallTarget } from '../utils/bridge-adapters.js';
|
|
7
|
+
/** How the commands talk to the person */
|
|
8
|
+
export interface BridgeInstallIo {
|
|
9
|
+
print(line: string): void;
|
|
10
|
+
/** Asks a yes or no question. Undefined when nobody is there to answer */
|
|
11
|
+
confirm(question: string): Promise<boolean | undefined>;
|
|
12
|
+
}
|
|
13
|
+
/** What the commands work with */
|
|
14
|
+
export interface BridgeInstallContext {
|
|
15
|
+
io: BridgeInstallIo;
|
|
16
|
+
env: NodeJS.ProcessEnv;
|
|
17
|
+
cwd: string;
|
|
18
|
+
/** How each harness is set up, those of this command line by default */
|
|
19
|
+
setups?: Partial<Record<InstallTarget, AdapterSetup>>;
|
|
20
|
+
}
|
|
21
|
+
interface SharedFlags {
|
|
22
|
+
home?: string;
|
|
23
|
+
/** The project to set up, the one the current folder is in by default */
|
|
24
|
+
cwd?: string;
|
|
25
|
+
/** For every project of this person, not for this one only */
|
|
26
|
+
user?: boolean;
|
|
27
|
+
dryRun?: boolean;
|
|
28
|
+
yes?: boolean;
|
|
29
|
+
json?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface BridgeInstallFlags extends SharedFlags {
|
|
32
|
+
/** False with `--no-notes`: the instructions files stay as they are */
|
|
33
|
+
notes?: boolean;
|
|
34
|
+
/** False with `--no-allow`: Claude Code goes on asking before a session calls a bridge tool */
|
|
35
|
+
allow?: boolean;
|
|
36
|
+
/** Sessions carry out the jobs of other agents without asking the person first */
|
|
37
|
+
takeJobs?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type BridgeUninstallFlags = SharedFlags;
|
|
40
|
+
/** `all` or one of the harnesses, as the command line names them. */
|
|
41
|
+
export declare const INSTALL_CHOICES: readonly ["claude", "codex", "all"];
|
|
42
|
+
/**
|
|
43
|
+
* cogitator bridge install [claude|codex|all]: gives the sessions a person opens the bridge.
|
|
44
|
+
* Every change is listed first and made only after a yes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function runBridgeInstall(target: string | undefined, flags: BridgeInstallFlags, context?: BridgeInstallContext): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* cogitator bridge uninstall [claude|codex|all]: takes out what `install` put in, and nothing
|
|
49
|
+
* else. Every change is listed first and made only after a yes.
|
|
50
|
+
*/
|
|
51
|
+
export declare function runBridgeUninstall(target: string | undefined, flags: BridgeUninstallFlags, context?: BridgeInstallContext): Promise<number>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=bridge-install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-install.d.ts","sourceRoot":"","sources":["../../src/commands/bridge-install.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKL,KAAK,YAAY,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AAGrC,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;CACzD;AAED,kCAAkC;AAClC,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,eAAe,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;CACvD;AAyBD,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAE/C,qEAAqE;AACrE,eAAO,MAAM,eAAe,qCAAuC,CAAC;AAmJpE;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,kBAAkB,EACzB,OAAO,GAAE,oBAAuC,GAC/C,OAAO,CAAC,MAAM,CAAC,CAoDjB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,oBAAoB,EAC3B,OAAO,GAAE,oBAAuC,GAC/C,OAAO,CAAC,MAAM,CAAC,CAsCjB"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* cogitator bridge install | uninstall - give the sessions a person opens in Claude Code and
|
|
3
|
+
* Codex the bridge, and take it away again
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { createInterface } from 'node:readline/promises';
|
|
8
|
+
import { BridgeClient, CommandMissingError, bridgePaths, findCheckoutRoot, } from '@cogitator-ai/bridge';
|
|
9
|
+
import { INSTALL_LABELS, INSTALL_TARGETS, bridgeSetups, } from '../utils/bridge-adapters.js';
|
|
10
|
+
import { CommandError, UsageError, printJson, reportFailure } from '../utils/cli.js';
|
|
11
|
+
/** Prompts on the terminal, undefined when stdin is not one */
|
|
12
|
+
function terminalIo() {
|
|
13
|
+
return {
|
|
14
|
+
print: (line) => console.log(line),
|
|
15
|
+
confirm: async (question) => {
|
|
16
|
+
if (!process.stdin.isTTY)
|
|
17
|
+
return undefined;
|
|
18
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
19
|
+
try {
|
|
20
|
+
const answer = await prompt.question(`${question} [y/N] `);
|
|
21
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
prompt.close();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const defaultContext = () => ({
|
|
30
|
+
io: terminalIo(),
|
|
31
|
+
env: process.env,
|
|
32
|
+
cwd: process.cwd(),
|
|
33
|
+
});
|
|
34
|
+
/** `all` or one of the harnesses, as the command line names them. */
|
|
35
|
+
export const INSTALL_CHOICES = [...INSTALL_TARGETS, 'all'];
|
|
36
|
+
function targetsOf(target) {
|
|
37
|
+
if (target === undefined || target === 'all')
|
|
38
|
+
return [...INSTALL_TARGETS];
|
|
39
|
+
const found = INSTALL_TARGETS.find((known) => known === target);
|
|
40
|
+
if (found)
|
|
41
|
+
return [found];
|
|
42
|
+
throw new UsageError(`"${target}" is not a harness the bridge sets up`, [
|
|
43
|
+
`Use one of: ${INSTALL_CHOICES.join(', ')}`,
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Asks each harness for its steps. A harness that is not installed is left out when every
|
|
48
|
+
* harness was asked for, and is a failure when it was named.
|
|
49
|
+
*/
|
|
50
|
+
async function planFor(targets, named, steps, setups) {
|
|
51
|
+
const plan = { planned: [], missing: [] };
|
|
52
|
+
for (const target of targets) {
|
|
53
|
+
const setup = setups[target];
|
|
54
|
+
if (!setup)
|
|
55
|
+
continue;
|
|
56
|
+
try {
|
|
57
|
+
plan.planned.push({ target, steps: await steps(setup) });
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (!(error instanceof CommandMissingError))
|
|
61
|
+
throw error;
|
|
62
|
+
if (named) {
|
|
63
|
+
throw new CommandError(`${INSTALL_LABELS[target]} is not installed: ${error.message}`);
|
|
64
|
+
}
|
|
65
|
+
plan.missing.push(target);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return plan;
|
|
69
|
+
}
|
|
70
|
+
function show(plan, io) {
|
|
71
|
+
let number = 0;
|
|
72
|
+
for (const { target, steps } of plan.planned) {
|
|
73
|
+
io.print(chalk.bold(INSTALL_LABELS[target]));
|
|
74
|
+
if (steps.length === 0)
|
|
75
|
+
io.print(chalk.dim(' nothing to change'));
|
|
76
|
+
for (const step of steps) {
|
|
77
|
+
number += 1;
|
|
78
|
+
io.print(` ${number}. ${step.title}`);
|
|
79
|
+
for (const line of step.lines)
|
|
80
|
+
io.print(chalk.dim(` ${line}`));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
for (const target of plan.missing) {
|
|
84
|
+
io.print(chalk.bold(INSTALL_LABELS[target]));
|
|
85
|
+
io.print(chalk.dim(' not installed on this machine, left out'));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function asJson(plan, applied) {
|
|
89
|
+
return {
|
|
90
|
+
applied,
|
|
91
|
+
changes: plan.planned.flatMap(({ target, steps }) => steps.map((step) => ({ harness: target, title: step.title, lines: step.lines }))),
|
|
92
|
+
missing: plan.missing,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Shows the plan, asks, and makes the changes one after another. Returns whether they were made.
|
|
97
|
+
*
|
|
98
|
+
* @throws CommandError when a step fails, naming it and how many were made before it
|
|
99
|
+
*/
|
|
100
|
+
async function carryOut(plan, flags, question, io) {
|
|
101
|
+
const steps = plan.planned.flatMap(({ steps: own }) => own);
|
|
102
|
+
if (!flags.json)
|
|
103
|
+
show(plan, io);
|
|
104
|
+
if (steps.length === 0 || flags.dryRun)
|
|
105
|
+
return false;
|
|
106
|
+
if (!flags.yes) {
|
|
107
|
+
if (flags.json) {
|
|
108
|
+
throw new UsageError('With --json nothing is asked', [
|
|
109
|
+
'Add --yes to make the changes, or --dry-run to list them',
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
const answer = await io.confirm(question.replace('%d', String(steps.length)));
|
|
113
|
+
if (answer === undefined) {
|
|
114
|
+
throw new CommandError('Nothing was changed: nobody is here to confirm', {
|
|
115
|
+
hints: ['Run it again with --yes'],
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (!answer) {
|
|
119
|
+
io.print('Nothing was changed');
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const [index, step] of steps.entries()) {
|
|
124
|
+
try {
|
|
125
|
+
await step.apply();
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw new CommandError(`"${step.title}" failed: ${error instanceof Error ? error.message : String(error)}`, {
|
|
129
|
+
hints: [
|
|
130
|
+
index === 0
|
|
131
|
+
? 'Nothing was changed before it'
|
|
132
|
+
: `The ${index} change${index === 1 ? '' : 's'} before it ${index === 1 ? 'was' : 'were'} made. Running the command again goes on from here`,
|
|
133
|
+
],
|
|
134
|
+
cause: error,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
function contextOf(flags, context) {
|
|
141
|
+
return {
|
|
142
|
+
project: findCheckoutRoot(resolve(context.cwd, flags.cwd ?? '.')),
|
|
143
|
+
scope: flags.user ? 'user' : 'project',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async function dispatcherRuns(flags, env) {
|
|
147
|
+
try {
|
|
148
|
+
const client = await BridgeClient.connect({
|
|
149
|
+
socketPath: bridgePaths({ ...(flags.home && { home: flags.home }), env }).socket,
|
|
150
|
+
timeoutMs: 3_000,
|
|
151
|
+
});
|
|
152
|
+
await client.close();
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* cogitator bridge install [claude|codex|all]: gives the sessions a person opens the bridge.
|
|
161
|
+
* Every change is listed first and made only after a yes.
|
|
162
|
+
*/
|
|
163
|
+
export async function runBridgeInstall(target, flags, context = defaultContext()) {
|
|
164
|
+
try {
|
|
165
|
+
const setups = context.setups ?? bridgeSetups(context.env, { ...(flags.home && { home: flags.home }) });
|
|
166
|
+
const where = contextOf(flags, context);
|
|
167
|
+
const plan = await planFor(targetsOf(target), target !== undefined && target !== 'all', (setup) => setup.install({
|
|
168
|
+
...where,
|
|
169
|
+
notes: flags.notes !== false,
|
|
170
|
+
takeJobs: flags.takeJobs === true,
|
|
171
|
+
allowTools: flags.allow !== false,
|
|
172
|
+
}), setups);
|
|
173
|
+
if (plan.planned.length === 0) {
|
|
174
|
+
throw new CommandError('Neither Claude Code nor Codex is installed on this machine');
|
|
175
|
+
}
|
|
176
|
+
if (!flags.json) {
|
|
177
|
+
context.io.print(where.scope === 'user'
|
|
178
|
+
? 'Setting up the agent bridge for every project of yours'
|
|
179
|
+
: `Setting up the agent bridge for the project ${where.project}`);
|
|
180
|
+
}
|
|
181
|
+
const applied = await carryOut(plan, flags, 'Make these %d changes?', context.io);
|
|
182
|
+
if (flags.json) {
|
|
183
|
+
printJson(asJson(plan, applied));
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
const changes = plan.planned.reduce((count, { steps }) => count + steps.length, 0);
|
|
187
|
+
if (changes === 0)
|
|
188
|
+
context.io.print(chalk.green('Everything is in place already'));
|
|
189
|
+
if (flags.dryRun || (changes > 0 && !applied))
|
|
190
|
+
return 0;
|
|
191
|
+
if (applied)
|
|
192
|
+
context.io.print(chalk.green(`Done: ${changes} change${changes === 1 ? '' : 's'}`));
|
|
193
|
+
if (!(await dispatcherRuns(flags, context.env))) {
|
|
194
|
+
context.io.print(chalk.dim(' No dispatcher runs yet. Start the one of this machine: cogitator bridge serve'));
|
|
195
|
+
}
|
|
196
|
+
if (applied) {
|
|
197
|
+
context.io.print(chalk.dim(' Sessions that are open now get the tools when they are started again'));
|
|
198
|
+
}
|
|
199
|
+
context.io.print(chalk.dim(' Check the setup: cogitator bridge doctor'));
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
return reportFailure(error, { json: flags.json ?? false });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* cogitator bridge uninstall [claude|codex|all]: takes out what `install` put in, and nothing
|
|
208
|
+
* else. Every change is listed first and made only after a yes.
|
|
209
|
+
*/
|
|
210
|
+
export async function runBridgeUninstall(target, flags, context = defaultContext()) {
|
|
211
|
+
try {
|
|
212
|
+
const setups = context.setups ?? bridgeSetups(context.env, { ...(flags.home && { home: flags.home }) });
|
|
213
|
+
const where = contextOf(flags, context);
|
|
214
|
+
const plan = await planFor(targetsOf(target), target !== undefined && target !== 'all', (setup) => setup.uninstall(where), setups);
|
|
215
|
+
if (!flags.json) {
|
|
216
|
+
context.io.print(where.scope === 'user'
|
|
217
|
+
? 'Taking the agent bridge out of every project of yours'
|
|
218
|
+
: `Taking the agent bridge out of the project ${where.project}`);
|
|
219
|
+
}
|
|
220
|
+
const applied = await carryOut(plan, flags, 'Make these %d changes?', context.io);
|
|
221
|
+
if (flags.json) {
|
|
222
|
+
printJson(asJson(plan, applied));
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
const changes = plan.planned.reduce((count, { steps }) => count + steps.length, 0);
|
|
226
|
+
if (changes === 0)
|
|
227
|
+
context.io.print(chalk.green('Nothing of the bridge is set up here'));
|
|
228
|
+
if (applied)
|
|
229
|
+
context.io.print(chalk.green(`Done: ${changes} change${changes === 1 ? '' : 's'}`));
|
|
230
|
+
if (where.scope === 'project' && plan.planned.some(({ target: name }) => name === 'codex')) {
|
|
231
|
+
context.io.print(chalk.dim(' Codex keeps its servers for every project: its server of tools goes with cogitator bridge uninstall codex --user'));
|
|
232
|
+
}
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
return reportFailure(error, { json: flags.json ?? false });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=bridge-install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-install.js","sourceRoot":"","sources":["../../src/commands/bridge-install.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,gBAAgB,GAIjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,GAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAkBrF,+DAA+D;AAC/D,SAAS,UAAU;IACjB,OAAO;QACL,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC1B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK;gBAAE,OAAO,SAAS,CAAC;YAC3C,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC;gBACH,MAAM,MAAM,GA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AAE,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,CAAC;YAC3F,OAAO,CAAC,EAAE,CAAC,KAAK,CACd,KAAK,CAAC,GAAG,CACP,oHAAoH,CACrH,CACF,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,aAAa,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* cogitator bridge delegate | send | inbox | wait | doctor - the bridge as a session and a
|
|
3
3
|
* person at a terminal use it
|
|
4
4
|
*/
|
|
5
|
-
import { type BridgeAdapter, type LetterKind } from '@cogitator-ai/bridge';
|
|
5
|
+
import { type BridgeAdapter, type LetterKind, type Verdict } from '@cogitator-ai/bridge';
|
|
6
6
|
/** What the session commands work with */
|
|
7
7
|
export interface BridgeSessionContext {
|
|
8
8
|
print(line: string): void;
|
|
@@ -29,15 +29,27 @@ export interface BridgeDelegateFlags extends HomeFlags {
|
|
|
29
29
|
/** cogitator bridge delegate <to> <text>: hands a job over and prints its number at once. */
|
|
30
30
|
export declare function runBridgeDelegate(to: string, words: readonly string[], flags: BridgeDelegateFlags, context?: BridgeSessionContext): Promise<number>;
|
|
31
31
|
export declare const SENDABLE_KINDS: readonly ["question", "answer", "report", "note", "permission"];
|
|
32
|
+
export declare const DECISIONS: readonly ["allow", "deny", "person"];
|
|
32
33
|
export interface BridgeSendFlags extends HomeFlags {
|
|
33
34
|
job: number;
|
|
34
35
|
kind: Exclude<LetterKind, 'task'>;
|
|
35
36
|
failed?: boolean;
|
|
36
37
|
replyTo?: string;
|
|
38
|
+
/** Of an answer: the decision of a permission request, or `person` to leave it to the user */
|
|
39
|
+
decision?: (typeof DECISIONS)[number];
|
|
37
40
|
json?: boolean;
|
|
38
41
|
}
|
|
39
42
|
/** cogitator bridge send --job N --kind K <text>: a letter on a job that exists. */
|
|
40
43
|
export declare function runBridgeSend(words: readonly string[], flags: BridgeSendFlags, context?: BridgeSessionContext): Promise<number>;
|
|
44
|
+
export interface BridgePersonFlags extends HomeFlags {
|
|
45
|
+
json?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** cogitator bridge asks: what waits for the word of the person. */
|
|
48
|
+
export declare function runBridgeAsks(flags: BridgePersonFlags, context?: BridgeSessionContext): Promise<number>;
|
|
49
|
+
/** cogitator bridge allow | deny <job or letter> [reason]: the person decides a permission request. */
|
|
50
|
+
export declare function runBridgeDecide(verdict: Verdict, target: string, words: readonly string[], flags: BridgePersonFlags, context?: BridgeSessionContext): Promise<number>;
|
|
51
|
+
/** cogitator bridge reply <job or letter> <text>: the person answers a question. */
|
|
52
|
+
export declare function runBridgeReply(target: string, words: readonly string[], flags: BridgePersonFlags, context?: BridgeSessionContext): Promise<number>;
|
|
41
53
|
export interface BridgeInboxFlags extends HomeFlags {
|
|
42
54
|
job?: number;
|
|
43
55
|
peek?: boolean;
|
|
@@ -59,6 +71,8 @@ export declare function runBridgeCancel(job: number, words: readonly string[], f
|
|
|
59
71
|
* as the session can run it, whatever its `PATH`.
|
|
60
72
|
*/
|
|
61
73
|
export declare function replyHint(bridgeCommand: string, home?: string): string;
|
|
74
|
+
/** How a session with the bridge's tools answers a letter it was woken with. */
|
|
75
|
+
export declare const TOOLS_REPLY_HINT: string;
|
|
62
76
|
export interface BridgeWaitFlags extends HomeFlags {
|
|
63
77
|
/** The harness whose hook runs the command: its stdin tells the session */
|
|
64
78
|
hook?: string;
|
|
@@ -66,6 +80,8 @@ export interface BridgeWaitFlags extends HomeFlags {
|
|
|
66
80
|
timeout?: number;
|
|
67
81
|
/** The name the bridge gave the session, for one it started */
|
|
68
82
|
agent?: string;
|
|
83
|
+
/** The session has the bridge's tools: it is told to reply with them, not with the command line */
|
|
84
|
+
tools?: boolean;
|
|
69
85
|
}
|
|
70
86
|
/** What `wait` exits with when it has mail: the code that makes a harness wake its session. */
|
|
71
87
|
export declare const WAKE_EXIT_CODE = 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-session.d.ts","sourceRoot":"","sources":["../../src/commands/bridge-session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAQL,KAAK,aAAa,EAIlB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"bridge-session.d.ts","sourceRoot":"","sources":["../../src/commands/bridge-session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAQL,KAAK,aAAa,EAIlB,KAAK,UAAU,EAEf,KAAK,OAAO,EACb,MAAM,sBAAsB,CAAC;AAI9B,0CAA0C;AAC1C,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kFAAkF;IAClF,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,8DAA8D;IAC9D,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACrC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAiBD,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAgGD,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,6FAA6F;AAC7F,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,SAAS,MAAM,E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