@cogitator-ai/bridge 0.6.1 → 0.8.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 +102 -19
- package/dist/adapters/claude.d.ts +13 -0
- package/dist/adapters/claude.d.ts.map +1 -1
- package/dist/adapters/claude.js +11 -1
- package/dist/adapters/claude.js.map +1 -1
- package/dist/board.d.ts +76 -0
- package/dist/board.d.ts.map +1 -0
- package/dist/board.js +19 -0
- package/dist/board.js.map +1 -0
- package/dist/checks.d.ts +31 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +202 -0
- package/dist/checks.js.map +1 -0
- package/dist/client.d.ts +17 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -0
- package/dist/client.js.map +1 -1
- package/dist/dispatcher.d.ts +187 -2
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher.js +930 -18
- package/dist/dispatcher.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/handover.d.ts +72 -0
- package/dist/handover.d.ts.map +1 -0
- package/dist/handover.js +225 -0
- package/dist/handover.js.map +1 -0
- package/dist/host.d.ts +7 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +1 -0
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/inputs.d.ts +166 -0
- package/dist/inputs.d.ts.map +1 -1
- package/dist/inputs.js +65 -0
- package/dist/inputs.js.map +1 -1
- package/dist/job-record.d.ts +42 -1
- package/dist/job-record.d.ts.map +1 -1
- package/dist/job-record.js +39 -1
- package/dist/job-record.js.map +1 -1
- package/dist/letters.d.ts +3 -1
- package/dist/letters.d.ts.map +1 -1
- package/dist/letters.js +38 -5
- package/dist/letters.js.map +1 -1
- package/dist/memory/index.d.ts +35 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +192 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/paths.d.ts +7 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +9 -0
- package/dist/paths.js.map +1 -1
- package/dist/protocol.d.ts +6 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +6 -0
- package/dist/protocol.js.map +1 -1
- package/dist/registry.d.ts +7 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +8 -5
- package/dist/registry.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/guidance.d.ts.map +1 -1
- package/dist/tools/guidance.js +4 -0
- package/dist/tools/guidance.js.map +1 -1
- package/dist/tools/tools.d.ts.map +1 -1
- package/dist/tools/tools.js +292 -2
- package/dist/tools/tools.js.map +1 -1
- package/dist/types.d.ts +105 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +27 -2
- package/dist/types.js.map +1 -1
- package/dist/worktree.d.ts +131 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +278 -0
- package/dist/worktree.js.map +1 -0
- package/fakes/claude.mjs +53 -3
- package/fakes/lib.mjs +24 -9
- package/package.json +11 -1
package/fakes/lib.mjs
CHANGED
|
@@ -549,26 +549,37 @@ async function runWithLeave(command, cwd, env, askLeave) {
|
|
|
549
549
|
* An `edit:` directive: a file the session's own edit tool changes, by adding a line to it,
|
|
550
550
|
* which the session needs leave for the way its harness decides. It is in the turn as a command
|
|
551
551
|
* `edit <path>`, refused or done. A harness that imitates no edit tool of its own fails it.
|
|
552
|
+
* A harness may move the session before it edits, as Claude Code moves a background session
|
|
553
|
+
* into a worktree of its own: the leave then says where the session is now (`cwd`) and which
|
|
554
|
+
* file the edit means there (`file`).
|
|
552
555
|
* @param {string} path as the model wrote it, relative to the folder of the session or absolute
|
|
553
556
|
* @param {LeaveAsker | undefined} askLeave
|
|
554
|
-
* @returns {Promise<CommandRun>}
|
|
557
|
+
* @returns {Promise<CommandRun & { movedTo?: string }>}
|
|
555
558
|
*/
|
|
556
559
|
async function editWithLeave(path, cwd, askLeave) {
|
|
557
|
-
const file = resolve(cwd, path);
|
|
558
560
|
const command = `edit ${path}`;
|
|
559
561
|
if (!askLeave) {
|
|
560
562
|
return { command, code: 1, stdout: '', stderr: 'this stand-in has no edit tool of its own' };
|
|
561
563
|
}
|
|
562
|
-
const leave = await askLeave({ tool: 'Edit', input: { file_path:
|
|
564
|
+
const leave = await askLeave({ tool: 'Edit', input: { file_path: resolve(cwd, path) } });
|
|
565
|
+
const moved = leave.cwd !== undefined && { movedTo: leave.cwd };
|
|
563
566
|
if (!leave.allowed) {
|
|
564
|
-
return {
|
|
567
|
+
return {
|
|
568
|
+
command,
|
|
569
|
+
code: null,
|
|
570
|
+
stdout: '',
|
|
571
|
+
stderr: leave.message ?? 'denied',
|
|
572
|
+
denied: true,
|
|
573
|
+
...moved,
|
|
574
|
+
};
|
|
565
575
|
}
|
|
576
|
+
const file = leave.file ?? resolve(cwd, path);
|
|
566
577
|
try {
|
|
567
578
|
mkdirSync(dirname(file), { recursive: true });
|
|
568
579
|
appendFileSync(file, 'edited\n');
|
|
569
|
-
return { command, code: 0, stdout: '', stderr: '' };
|
|
580
|
+
return { command, code: 0, stdout: '', stderr: '', ...moved };
|
|
570
581
|
} catch (error) {
|
|
571
|
-
return { command, code: 1, stdout: '', stderr: error.message };
|
|
582
|
+
return { command, code: 1, stdout: '', stderr: error.message, ...moved };
|
|
572
583
|
}
|
|
573
584
|
}
|
|
574
585
|
|
|
@@ -586,16 +597,20 @@ async function editWithLeave(path, cwd, askLeave) {
|
|
|
586
597
|
* @param {LeaveAsker} [turn.askLeave] how the session gets leave for a call of its own tools
|
|
587
598
|
* @returns {Promise<TurnOutcome>}
|
|
588
599
|
*/
|
|
589
|
-
export async function performTurn({ input, cwd, env, callTool, askLeave }) {
|
|
600
|
+
export async function performTurn({ input, cwd: startedIn, env, callTool, askLeave }) {
|
|
590
601
|
const at = new Date().toISOString();
|
|
591
602
|
const ran = [];
|
|
592
603
|
const tools = [];
|
|
593
604
|
let answer = 'ok';
|
|
605
|
+
let cwd = startedIn;
|
|
594
606
|
for (const { kind, value } of directives(input)) {
|
|
595
607
|
if (kind === 'run') ran.push(await runCommand(value, cwd, env));
|
|
596
608
|
else if (kind === 'bash') ran.push(await runWithLeave(value, cwd, env, askLeave));
|
|
597
|
-
else if (kind === 'edit')
|
|
598
|
-
|
|
609
|
+
else if (kind === 'edit') {
|
|
610
|
+
const { movedTo, ...run } = await editWithLeave(value, cwd, askLeave);
|
|
611
|
+
if (movedTo !== undefined) cwd = movedTo;
|
|
612
|
+
ran.push(run);
|
|
613
|
+
} else if (kind === 'tool') tools.push(await runTool(value, callTool));
|
|
599
614
|
else if (kind === 'sleep') await sleep(Number(value));
|
|
600
615
|
else answer = value;
|
|
601
616
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogitator-ai/bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Agent bridge for Cogitator: Claude Code, Codex and other agents hand each other jobs, ask questions and report back, each in its own window (experimental)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cogitator",
|
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
"types": "./dist/testing/index.d.ts",
|
|
38
38
|
"import": "./dist/testing/index.js",
|
|
39
39
|
"default": "./dist/testing/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./memory": {
|
|
42
|
+
"types": "./dist/memory/index.d.ts",
|
|
43
|
+
"import": "./dist/memory/index.js",
|
|
44
|
+
"default": "./dist/memory/index.js"
|
|
40
45
|
}
|
|
41
46
|
},
|
|
42
47
|
"sideEffects": false,
|
|
@@ -54,6 +59,7 @@
|
|
|
54
59
|
"devDependencies": {
|
|
55
60
|
"@cogitator-ai/core": "0.79.0",
|
|
56
61
|
"@cogitator-ai/mcp": "19.12.0",
|
|
62
|
+
"@cogitator-ai/memory": "0.29.7",
|
|
57
63
|
"@types/better-sqlite3": "^9.6.0",
|
|
58
64
|
"@types/node": "^22.20.4",
|
|
59
65
|
"better-sqlite3": "^13.0.3",
|
|
@@ -62,6 +68,7 @@
|
|
|
62
68
|
},
|
|
63
69
|
"peerDependencies": {
|
|
64
70
|
"@cogitator-ai/core": ">=0.79.0",
|
|
71
|
+
"@cogitator-ai/memory": ">=0.29.7",
|
|
65
72
|
"better-sqlite3": "^11.0.0 || ^12.0.0 || ^13.0.0"
|
|
66
73
|
},
|
|
67
74
|
"peerDependenciesMeta": {
|
|
@@ -70,6 +77,9 @@
|
|
|
70
77
|
},
|
|
71
78
|
"better-sqlite3": {
|
|
72
79
|
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@cogitator-ai/memory": {
|
|
82
|
+
"optional": true
|
|
73
83
|
}
|
|
74
84
|
},
|
|
75
85
|
"engines": {
|