@cogitator-ai/bridge 0.3.0 → 0.4.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 +95 -9
- package/dist/adapter.d.ts +7 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapters/claude.d.ts +55 -0
- package/dist/adapters/claude.d.ts.map +1 -1
- package/dist/adapters/claude.js +195 -17
- package/dist/adapters/claude.js.map +1 -1
- package/dist/adapters/codex.d.ts +16 -3
- package/dist/adapters/codex.d.ts.map +1 -1
- package/dist/adapters/codex.js +58 -9
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/exec.d.ts +16 -3
- package/dist/adapters/exec.d.ts.map +1 -1
- package/dist/adapters/exec.js +22 -10
- package/dist/adapters/exec.js.map +1 -1
- package/dist/adapters/tools-server.d.ts +21 -0
- package/dist/adapters/tools-server.d.ts.map +1 -0
- package/dist/adapters/tools-server.js +19 -0
- package/dist/adapters/tools-server.js.map +1 -0
- package/dist/dispatcher.d.ts +2 -0
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher.js +3 -0
- package/dist/dispatcher.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/setup/claude.d.ts +53 -0
- package/dist/setup/claude.d.ts.map +1 -0
- package/dist/setup/claude.js +261 -0
- package/dist/setup/claude.js.map +1 -0
- package/dist/setup/codex.d.ts +22 -0
- package/dist/setup/codex.d.ts.map +1 -0
- package/dist/setup/codex.js +95 -0
- package/dist/setup/codex.js.map +1 -0
- package/dist/setup/files.d.ts +22 -0
- package/dist/setup/files.d.ts.map +1 -0
- package/dist/setup/files.js +86 -0
- package/dist/setup/files.js.map +1 -0
- package/dist/setup/index.d.ts +6 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +3 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/setup.d.ts +52 -0
- package/dist/setup/setup.d.ts.map +1 -0
- package/dist/setup/setup.js +2 -0
- package/dist/setup/setup.js.map +1 -0
- package/dist/testing/fake-harnesses.d.ts +22 -2
- package/dist/testing/fake-harnesses.d.ts.map +1 -1
- package/dist/testing/fake-harnesses.js +16 -4
- package/dist/testing/fake-harnesses.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/tools/caller.d.ts +39 -0
- package/dist/tools/caller.d.ts.map +1 -0
- package/dist/tools/caller.js +92 -0
- package/dist/tools/caller.js.map +1 -0
- package/dist/tools/guidance.d.ts +33 -0
- package/dist/tools/guidance.d.ts.map +1 -0
- package/dist/tools/guidance.js +92 -0
- package/dist/tools/guidance.js.map +1 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +24 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/tools.d.ts +38 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +354 -0
- package/dist/tools/tools.js.map +1 -0
- package/fakes/claude.mjs +288 -23
- package/fakes/codex.mjs +199 -19
- package/fakes/lib.mjs +94 -16
- package/fakes/mcp.mjs +151 -0
- package/fakes/sandbox.mjs +84 -0
- package/package.json +13 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { CLAUDE_TOOLS_PERMISSION, DEFAULT_HOOK_TIMEOUT_S, claudeToolsHook, claudeWaitHook, } from '../adapters/claude.js';
|
|
4
|
+
import { failureOf, outsideSessionEnv, runCommand, shellQuote } from '../adapters/exec.js';
|
|
5
|
+
import { BRIDGE_TOOLS_SERVER } from '../adapters/tools-server.js';
|
|
6
|
+
import { canonicalPath } from '../paths.js';
|
|
7
|
+
import { bridgeNotes } from '../tools/guidance.js';
|
|
8
|
+
import { notesStep, readSettings, readText, removeNotesStep, writeSettings } from './files.js';
|
|
9
|
+
const WAITS = /\bbridge\s+wait\b/;
|
|
10
|
+
const NAMES_CALLER = /\bbridge\s+caller\b/;
|
|
11
|
+
function isObject(value) {
|
|
12
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function commandsOf(groups, pattern) {
|
|
15
|
+
if (!Array.isArray(groups))
|
|
16
|
+
return [];
|
|
17
|
+
return groups.flatMap((group) => {
|
|
18
|
+
const hooks = isObject(group) && Array.isArray(group.hooks) ? group.hooks : [];
|
|
19
|
+
return hooks.flatMap((hook) => isObject(hook) && typeof hook.command === 'string' && pattern.test(hook.command)
|
|
20
|
+
? [hook.command]
|
|
21
|
+
: []);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** The groups of an event without the hooks of the bridge, and without a group they emptied. */
|
|
25
|
+
function withoutHooks(groups, pattern) {
|
|
26
|
+
if (!Array.isArray(groups))
|
|
27
|
+
return [];
|
|
28
|
+
return groups.flatMap((group) => {
|
|
29
|
+
if (!isObject(group) || !Array.isArray(group.hooks))
|
|
30
|
+
return [group];
|
|
31
|
+
const kept = group.hooks.filter((hook) => !(isObject(hook) && typeof hook.command === 'string' && pattern.test(hook.command)));
|
|
32
|
+
if (kept.length === group.hooks.length)
|
|
33
|
+
return [group];
|
|
34
|
+
return kept.length === 0 ? [] : [{ ...group, hooks: kept }];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** `settings` with `key` set, or without it when the value holds nothing. */
|
|
38
|
+
function setOrDrop(settings, key, value) {
|
|
39
|
+
const empty = value === undefined ||
|
|
40
|
+
(Array.isArray(value) && value.length === 0) ||
|
|
41
|
+
(isObject(value) && Object.keys(value).length === 0);
|
|
42
|
+
if (!empty)
|
|
43
|
+
return { ...settings, [key]: value };
|
|
44
|
+
const { [key]: _dropped, ...rest } = settings;
|
|
45
|
+
return rest;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Settings of Claude Code without anything of the bridge: its two hooks and the rule that lets
|
|
49
|
+
* its tools run. What else the settings hold stays as it is.
|
|
50
|
+
*/
|
|
51
|
+
export function withoutBridgeSettings(settings) {
|
|
52
|
+
let next = settings;
|
|
53
|
+
if (isObject(settings.hooks)) {
|
|
54
|
+
let hooks = settings.hooks;
|
|
55
|
+
hooks = setOrDrop(hooks, 'Stop', withoutHooks(hooks.Stop, WAITS));
|
|
56
|
+
hooks = setOrDrop(hooks, 'PreToolUse', withoutHooks(hooks.PreToolUse, NAMES_CALLER));
|
|
57
|
+
next = setOrDrop(next, 'hooks', hooks);
|
|
58
|
+
}
|
|
59
|
+
if (isObject(settings.permissions) && Array.isArray(settings.permissions.allow)) {
|
|
60
|
+
const allow = settings.permissions.allow.filter((rule) => rule !== CLAUDE_TOOLS_PERMISSION);
|
|
61
|
+
next = setOrDrop(next, 'permissions', setOrDrop(settings.permissions, 'allow', allow));
|
|
62
|
+
}
|
|
63
|
+
return next;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Settings of Claude Code with the bridge in them: the hooks it had of the bridge are replaced,
|
|
67
|
+
* its other hooks and rules stay. A rule that lets the tools run is added when asked for, and
|
|
68
|
+
* one that is there is never taken away.
|
|
69
|
+
*/
|
|
70
|
+
export function withBridgeSettings(settings, bridge) {
|
|
71
|
+
const had = isObject(settings.permissions) &&
|
|
72
|
+
Array.isArray(settings.permissions.allow) &&
|
|
73
|
+
settings.permissions.allow.includes(CLAUDE_TOOLS_PERMISSION);
|
|
74
|
+
const base = withoutBridgeSettings(settings);
|
|
75
|
+
const hooks = isObject(base.hooks) ? base.hooks : {};
|
|
76
|
+
const stop = Array.isArray(hooks.Stop) ? hooks.Stop : [];
|
|
77
|
+
const before = Array.isArray(hooks.PreToolUse) ? hooks.PreToolUse : [];
|
|
78
|
+
const next = {
|
|
79
|
+
...base,
|
|
80
|
+
hooks: {
|
|
81
|
+
...hooks,
|
|
82
|
+
Stop: [...stop, ...bridge.wait.hooks.Stop],
|
|
83
|
+
PreToolUse: [...before, ...bridge.tools.hooks.PreToolUse],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
if (!bridge.allow && !had)
|
|
87
|
+
return next;
|
|
88
|
+
const permissions = isObject(base.permissions) ? base.permissions : {};
|
|
89
|
+
const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
|
|
90
|
+
return { ...next, permissions: { ...permissions, allow: [...allow, CLAUDE_TOOLS_PERMISSION] } };
|
|
91
|
+
}
|
|
92
|
+
/** What settings hold of the bridge, a line each, for a person to read. */
|
|
93
|
+
function bridgeLines(settings, sign) {
|
|
94
|
+
const hooks = isObject(settings.hooks) ? settings.hooks : {};
|
|
95
|
+
const allowed = isObject(settings.permissions) &&
|
|
96
|
+
Array.isArray(settings.permissions.allow) &&
|
|
97
|
+
settings.permissions.allow.includes(CLAUDE_TOOLS_PERMISSION);
|
|
98
|
+
return [
|
|
99
|
+
...commandsOf(hooks.Stop, WAITS).map((command) => `${sign} hooks.Stop: ${command}`),
|
|
100
|
+
...commandsOf(hooks.PreToolUse, NAMES_CALLER).map((command) => `${sign} hooks.PreToolUse: ${command}`),
|
|
101
|
+
...(allowed ? [`${sign} permissions.allow: ${CLAUDE_TOOLS_PERMISSION}`] : []),
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
105
|
+
/**
|
|
106
|
+
* How Claude Code is given the bridge for the sessions a person opens: the server of tools
|
|
107
|
+
* (`claude mcp add`), a hook that wakes a session for its mail and one that tells the tools
|
|
108
|
+
* which session calls, the rule that lets the tools run, and the notes in `CLAUDE.md`. For one
|
|
109
|
+
* project it all goes where only this person has it: the local scope of Claude Code and the
|
|
110
|
+
* project's `.claude/settings.local.json`. Only the notes go into a file the project may share.
|
|
111
|
+
*/
|
|
112
|
+
export function claudeSetup(options) {
|
|
113
|
+
const command = options.command ?? 'claude';
|
|
114
|
+
const base = options.env ?? process.env;
|
|
115
|
+
const env = outsideSessionEnv(base);
|
|
116
|
+
const configDir = base.CLAUDE_CONFIG_DIR?.trim();
|
|
117
|
+
const configPath = options.configPath ?? join(configDir || homedir(), '.claude.json');
|
|
118
|
+
const userDir = configDir || join(homedir(), '.claude');
|
|
119
|
+
const userSettingsPath = options.userSettingsPath ?? join(userDir, 'settings.json');
|
|
120
|
+
const userNotesPath = options.userNotesPath ?? join(userDir, 'CLAUDE.md');
|
|
121
|
+
const server = options.toolsServer;
|
|
122
|
+
const hook = {
|
|
123
|
+
...(options.bridgeCommand !== undefined && { bridgeCommand: options.bridgeCommand }),
|
|
124
|
+
...(options.bridgeHome !== undefined && { bridgeHome: options.bridgeHome }),
|
|
125
|
+
};
|
|
126
|
+
const places = (context) => {
|
|
127
|
+
const project = resolve(context.project);
|
|
128
|
+
return context.scope === 'user'
|
|
129
|
+
? { scope: 'user', settings: userSettingsPath, notes: userNotesPath, project }
|
|
130
|
+
: {
|
|
131
|
+
scope: 'local',
|
|
132
|
+
settings: join(project, '.claude', 'settings.local.json'),
|
|
133
|
+
notes: join(project, 'CLAUDE.md'),
|
|
134
|
+
project,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/** The server of tools as Claude Code has it in a scope, when it has one there. */
|
|
138
|
+
function registered(scope, project) {
|
|
139
|
+
const text = readText(configPath);
|
|
140
|
+
let config;
|
|
141
|
+
try {
|
|
142
|
+
config = text === undefined ? {} : JSON.parse(text);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new Error(`${configPath} is not valid JSON: cannot tell what Claude Code has set up`);
|
|
146
|
+
}
|
|
147
|
+
if (!isObject(config))
|
|
148
|
+
return undefined;
|
|
149
|
+
if (scope === 'user') {
|
|
150
|
+
return isObject(config.mcpServers) ? config.mcpServers[BRIDGE_TOOLS_SERVER] : undefined;
|
|
151
|
+
}
|
|
152
|
+
const projects = isObject(config.projects) ? config.projects : {};
|
|
153
|
+
for (const folder of new Set([canonicalPath(project), project])) {
|
|
154
|
+
const entry = projects[folder];
|
|
155
|
+
const servers = isObject(entry) && isObject(entry.mcpServers) ? entry.mcpServers : {};
|
|
156
|
+
if (servers[BRIDGE_TOOLS_SERVER] !== undefined)
|
|
157
|
+
return servers[BRIDGE_TOOLS_SERVER];
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
async function run(args, cwd) {
|
|
162
|
+
const result = await runCommand(command, args, { cwd, env });
|
|
163
|
+
if (result.code !== 0) {
|
|
164
|
+
throw new Error(`${command} ${args.slice(0, 2).join(' ')} failed: ${failureOf(result)}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const removal = (scope) => [
|
|
168
|
+
'mcp',
|
|
169
|
+
'remove',
|
|
170
|
+
BRIDGE_TOOLS_SERVER,
|
|
171
|
+
'--scope',
|
|
172
|
+
scope,
|
|
173
|
+
];
|
|
174
|
+
const shown = (args) => [command, ...args].map((word) => shellQuote(word)).join(' ');
|
|
175
|
+
async function install(context) {
|
|
176
|
+
const version = await runCommand(command, ['--version'], { env });
|
|
177
|
+
if (version.code !== 0)
|
|
178
|
+
throw new Error(`${command} --version failed: ${failureOf(version)}`);
|
|
179
|
+
const place = places(context);
|
|
180
|
+
const steps = [];
|
|
181
|
+
const has = registered(place.scope, place.project);
|
|
182
|
+
const wanted = { command: server.command, args: [...server.args] };
|
|
183
|
+
const current = isObject(has) ? { command: has.command, args: has.args ?? [] } : undefined;
|
|
184
|
+
if (!same(current, wanted)) {
|
|
185
|
+
const addition = [
|
|
186
|
+
'mcp',
|
|
187
|
+
'add',
|
|
188
|
+
'--scope',
|
|
189
|
+
place.scope,
|
|
190
|
+
BRIDGE_TOOLS_SERVER,
|
|
191
|
+
'--',
|
|
192
|
+
server.command,
|
|
193
|
+
...server.args,
|
|
194
|
+
];
|
|
195
|
+
const replaces = has !== undefined;
|
|
196
|
+
steps.push({
|
|
197
|
+
title: place.scope === 'user'
|
|
198
|
+
? `${replaces ? 'Replace' : 'Register'} the bridge's server of tools with Claude Code, for every project of yours`
|
|
199
|
+
: `${replaces ? 'Replace' : 'Register'} the bridge's server of tools with Claude Code, for you in this project`,
|
|
200
|
+
lines: [...(replaces ? [shown(removal(place.scope))] : []), shown(addition)],
|
|
201
|
+
apply: async () => {
|
|
202
|
+
if (replaces)
|
|
203
|
+
await run(removal(place.scope), place.project);
|
|
204
|
+
await run(addition, place.project);
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
const before = readSettings(place.settings);
|
|
209
|
+
const after = withBridgeSettings(before, {
|
|
210
|
+
wait: claudeWaitHook({
|
|
211
|
+
...hook,
|
|
212
|
+
tools: true,
|
|
213
|
+
timeoutS: options.hookTimeoutS ?? DEFAULT_HOOK_TIMEOUT_S,
|
|
214
|
+
}),
|
|
215
|
+
tools: claudeToolsHook(hook),
|
|
216
|
+
allow: context.allowTools,
|
|
217
|
+
});
|
|
218
|
+
if (!same(before, after)) {
|
|
219
|
+
const kept = new Set(bridgeLines(before, '+'));
|
|
220
|
+
steps.push({
|
|
221
|
+
title: `Edit ${place.settings}: the hooks that wake a session for its mail and name it to the tools`,
|
|
222
|
+
lines: bridgeLines(after, '+').filter((line) => !kept.has(line)),
|
|
223
|
+
apply: async () => writeSettings(place.settings, after),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (context.notes) {
|
|
227
|
+
const notes = notesStep(place.notes, bridgeNotes({ takeJobs: context.takeJobs }));
|
|
228
|
+
if (notes)
|
|
229
|
+
steps.push(notes);
|
|
230
|
+
}
|
|
231
|
+
return steps;
|
|
232
|
+
}
|
|
233
|
+
async function uninstall(context) {
|
|
234
|
+
const place = places(context);
|
|
235
|
+
const steps = [];
|
|
236
|
+
if (registered(place.scope, place.project) !== undefined) {
|
|
237
|
+
steps.push({
|
|
238
|
+
title: "Remove the bridge's server of tools from Claude Code",
|
|
239
|
+
lines: [shown(removal(place.scope))],
|
|
240
|
+
apply: () => run(removal(place.scope), place.project),
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
const before = readSettings(place.settings);
|
|
244
|
+
const after = withoutBridgeSettings(before);
|
|
245
|
+
if (!same(before, after)) {
|
|
246
|
+
steps.push({
|
|
247
|
+
title: Object.keys(after).length === 0
|
|
248
|
+
? `Remove ${place.settings}, which holds only the hooks of the bridge`
|
|
249
|
+
: `Edit ${place.settings}: take the hooks of the bridge out`,
|
|
250
|
+
lines: bridgeLines(before, '-'),
|
|
251
|
+
apply: async () => writeSettings(place.settings, after),
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const notes = removeNotesStep(place.notes);
|
|
255
|
+
if (notes)
|
|
256
|
+
steps.push(notes);
|
|
257
|
+
return steps;
|
|
258
|
+
}
|
|
259
|
+
return { install, uninstall };
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/setup/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAA2B,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA0B/F,MAAM,KAAK,GAAG,mBAAmB,CAAC;AAClC,MAAM,YAAY,GAAG,qBAAqB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
+
export interface CodexSetupOptions {
|
|
4
|
+
/** How a thread starts the bridge's server of tools */
|
|
5
|
+
toolsServer: ToolsServerCommand;
|
|
6
|
+
/** The Codex executable, `codex` on `PATH` by default */
|
|
7
|
+
command?: string;
|
|
8
|
+
/** The environment of the commands, `process.env` by default */
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
/** Where Codex reads a person's instructions for every project, `AGENTS.md` in its home */
|
|
11
|
+
userNotesPath?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* How Codex is given the bridge for the threads a person opens: the server of tools
|
|
15
|
+
* (`codex mcp add`) and the notes in `AGENTS.md`. Codex needs no hook: the bridge hands a thread
|
|
16
|
+
* its mail through the thread's own queue, and Codex names the thread in every tool call.
|
|
17
|
+
*
|
|
18
|
+
* Codex keeps its servers in one place for every project, so the server is registered for all
|
|
19
|
+
* of them whichever scope is asked for, and only an uninstall for every project removes it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function codexSetup(options: CodexSetupOptions): AdapterSetup;
|
|
22
|
+
//# sourceMappingURL=codex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/setup/codex.ts"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAG3F,OAAO,KAAK,EAAE,YAAY,EAA2C,MAAM,YAAY,CAAC;AAExF,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,WAAW,EAAE,kBAAkB,CAAC;IAChC,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,YAAY,CA8EnE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { failureOf, outsideSessionEnv, runCommand, shellQuote } from '../adapters/exec.js';
|
|
5
|
+
import { BRIDGE_TOOLS_SERVER } from '../adapters/tools-server.js';
|
|
6
|
+
import { bridgeNotes } from '../tools/guidance.js';
|
|
7
|
+
import { notesStep, removeNotesStep } from './files.js';
|
|
8
|
+
const ServerSchema = z.object({
|
|
9
|
+
transport: z.object({
|
|
10
|
+
command: z.string().optional(),
|
|
11
|
+
args: z.array(z.string()).nullish(),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* How Codex is given the bridge for the threads a person opens: the server of tools
|
|
16
|
+
* (`codex mcp add`) and the notes in `AGENTS.md`. Codex needs no hook: the bridge hands a thread
|
|
17
|
+
* its mail through the thread's own queue, and Codex names the thread in every tool call.
|
|
18
|
+
*
|
|
19
|
+
* Codex keeps its servers in one place for every project, so the server is registered for all
|
|
20
|
+
* of them whichever scope is asked for, and only an uninstall for every project removes it.
|
|
21
|
+
*/
|
|
22
|
+
export function codexSetup(options) {
|
|
23
|
+
const command = options.command ?? 'codex';
|
|
24
|
+
const base = options.env ?? process.env;
|
|
25
|
+
const env = outsideSessionEnv(base);
|
|
26
|
+
const userNotesPath = options.userNotesPath ??
|
|
27
|
+
join(base.CODEX_HOME?.trim() || join(homedir(), '.codex'), 'AGENTS.md');
|
|
28
|
+
const server = options.toolsServer;
|
|
29
|
+
const notesPath = (context) => context.scope === 'user' ? userNotesPath : join(resolve(context.project), 'AGENTS.md');
|
|
30
|
+
const shown = (args) => [command, ...args].map((word) => shellQuote(word)).join(' ');
|
|
31
|
+
async function run(args) {
|
|
32
|
+
const result = await runCommand(command, args, { env });
|
|
33
|
+
if (result.code !== 0) {
|
|
34
|
+
throw new Error(`${command} ${args.slice(0, 2).join(' ')} failed: ${failureOf(result)}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** The command Codex starts the server of tools with, when it has the server. */
|
|
38
|
+
async function registered() {
|
|
39
|
+
const result = await runCommand(command, ['mcp', 'get', BRIDGE_TOOLS_SERVER, '--json'], {
|
|
40
|
+
env,
|
|
41
|
+
});
|
|
42
|
+
if (result.code !== 0)
|
|
43
|
+
return undefined;
|
|
44
|
+
let shownServer;
|
|
45
|
+
try {
|
|
46
|
+
shownServer = JSON.parse(result.stdout);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return { args: [] };
|
|
50
|
+
}
|
|
51
|
+
const parsed = ServerSchema.safeParse(shownServer);
|
|
52
|
+
if (!parsed.success)
|
|
53
|
+
return { args: [] };
|
|
54
|
+
const { command: started, args } = parsed.data.transport;
|
|
55
|
+
return { ...(started !== undefined && { command: started }), args: args ?? [] };
|
|
56
|
+
}
|
|
57
|
+
async function install(context) {
|
|
58
|
+
const version = await runCommand(command, ['--version'], { env });
|
|
59
|
+
if (version.code !== 0)
|
|
60
|
+
throw new Error(`${command} --version failed: ${failureOf(version)}`);
|
|
61
|
+
const steps = [];
|
|
62
|
+
const has = await registered();
|
|
63
|
+
if (has?.command !== server.command || has.args.join('\0') !== server.args.join('\0')) {
|
|
64
|
+
const addition = ['mcp', 'add', BRIDGE_TOOLS_SERVER, '--', server.command, ...server.args];
|
|
65
|
+
steps.push({
|
|
66
|
+
title: `${has ? 'Replace' : 'Register'} the bridge's server of tools with Codex, which keeps its servers for every project`,
|
|
67
|
+
lines: [shown(addition)],
|
|
68
|
+
apply: () => run(addition),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (context.notes) {
|
|
72
|
+
const notes = notesStep(notesPath(context), bridgeNotes({ takeJobs: context.takeJobs }));
|
|
73
|
+
if (notes)
|
|
74
|
+
steps.push(notes);
|
|
75
|
+
}
|
|
76
|
+
return steps;
|
|
77
|
+
}
|
|
78
|
+
async function uninstall(context) {
|
|
79
|
+
const steps = [];
|
|
80
|
+
if (context.scope === 'user' && (await registered())) {
|
|
81
|
+
const removal = ['mcp', 'remove', BRIDGE_TOOLS_SERVER];
|
|
82
|
+
steps.push({
|
|
83
|
+
title: "Remove the bridge's server of tools from Codex",
|
|
84
|
+
lines: [shown(removal)],
|
|
85
|
+
apply: () => run(removal),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const notes = removeNotesStep(notesPath(context));
|
|
89
|
+
if (notes)
|
|
90
|
+
steps.push(notes);
|
|
91
|
+
return steps;
|
|
92
|
+
}
|
|
93
|
+
return { install, uninstall };
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/setup/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAA2B,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAcxD,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC9B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;KACpC,CAAC;CACH,CAAC,CAAC;AAEH;;;;;;;GAOG;A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ACvB,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC;aAC1B,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SetupStep } from './setup.js';
|
|
2
|
+
/** The text of a file, or undefined when it is not there. */
|
|
3
|
+
export declare function readText(path: string): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* A settings file as an object: empty when the file is not there or holds nothing.
|
|
6
|
+
*
|
|
7
|
+
* @throws Error when the file is not a JSON object: it is never overwritten then
|
|
8
|
+
*/
|
|
9
|
+
export declare function readSettings(path: string): Record<string, unknown>;
|
|
10
|
+
/** Writes a settings file, or removes it when nothing is left in it. */
|
|
11
|
+
export declare function writeSettings(path: string, settings: Record<string, unknown>): void;
|
|
12
|
+
/**
|
|
13
|
+
* The step that puts the notes of the bridge into an instructions file, or brings the notes it
|
|
14
|
+
* has up to date. Undefined when the file has exactly these notes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function notesStep(path: string, notes: string): SetupStep | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The step that takes the notes of the bridge out of an instructions file. A file that held
|
|
19
|
+
* nothing else is removed. Undefined when the file has no notes.
|
|
20
|
+
*/
|
|
21
|
+
export declare function removeNotesStep(path: string): SetupStep | undefined;
|
|
22
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/setup/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,6DAA6D;AAC7D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOzD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAalE;AAOD,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAGnF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAU5E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAenE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { hasBridgeNotes, withBridgeNotes, withoutBridgeNotes } from '../tools/guidance.js';
|
|
4
|
+
/** The text of a file, or undefined when it is not there. */
|
|
5
|
+
export function readText(path) {
|
|
6
|
+
try {
|
|
7
|
+
return readFileSync(path, 'utf8');
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error.code === 'ENOENT')
|
|
11
|
+
return undefined;
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A settings file as an object: empty when the file is not there or holds nothing.
|
|
17
|
+
*
|
|
18
|
+
* @throws Error when the file is not a JSON object: it is never overwritten then
|
|
19
|
+
*/
|
|
20
|
+
export function readSettings(path) {
|
|
21
|
+
const text = readText(path);
|
|
22
|
+
if (text === undefined || text.trim() === '')
|
|
23
|
+
return {};
|
|
24
|
+
let value;
|
|
25
|
+
try {
|
|
26
|
+
value = JSON.parse(text);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
throw new Error(`${path} is not valid JSON. Fix it first: nothing was changed`);
|
|
30
|
+
}
|
|
31
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
32
|
+
throw new Error(`${path} does not hold a JSON object. Fix it first: nothing was changed`);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function writeText(path, text) {
|
|
37
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
38
|
+
writeFileSync(path, text);
|
|
39
|
+
}
|
|
40
|
+
/** Writes a settings file, or removes it when nothing is left in it. */
|
|
41
|
+
export function writeSettings(path, settings) {
|
|
42
|
+
if (Object.keys(settings).length === 0)
|
|
43
|
+
rmSync(path, { force: true });
|
|
44
|
+
else
|
|
45
|
+
writeText(path, `${JSON.stringify(settings, null, 2)}\n`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The step that puts the notes of the bridge into an instructions file, or brings the notes it
|
|
49
|
+
* has up to date. Undefined when the file has exactly these notes.
|
|
50
|
+
*/
|
|
51
|
+
export function notesStep(path, notes) {
|
|
52
|
+
const before = readText(path);
|
|
53
|
+
const after = withBridgeNotes(before ?? '', notes);
|
|
54
|
+
if (before === after)
|
|
55
|
+
return undefined;
|
|
56
|
+
const had = before !== undefined && hasBridgeNotes(before);
|
|
57
|
+
return {
|
|
58
|
+
title: `${had ? 'Update' : 'Add'} the notes of the bridge in ${path}${before === undefined ? ' (a new file)' : ''}`,
|
|
59
|
+
lines: notes.split('\n').map((line) => `+ ${line}`),
|
|
60
|
+
apply: async () => writeText(path, after),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The step that takes the notes of the bridge out of an instructions file. A file that held
|
|
65
|
+
* nothing else is removed. Undefined when the file has no notes.
|
|
66
|
+
*/
|
|
67
|
+
export function removeNotesStep(path) {
|
|
68
|
+
const before = readText(path);
|
|
69
|
+
const after = before === undefined ? undefined : withoutBridgeNotes(before);
|
|
70
|
+
if (after === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
const empty = after.trim() === '';
|
|
73
|
+
return {
|
|
74
|
+
title: empty
|
|
75
|
+
? `Remove ${path}, which holds only the notes of the bridge`
|
|
76
|
+
: `Remove the notes of the bridge from ${path}`,
|
|
77
|
+
lines: [],
|
|
78
|
+
apply: async () => {
|
|
79
|
+
if (empty)
|
|
80
|
+
rmSync(path, { force: true });
|
|
81
|
+
else
|
|
82
|
+
writeText(path, after);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/setup/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG3F,6DAA6D;AAC7D,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QACzE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IACxD,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC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geSettings, ClaudeSetupOptions } from './claude.js';
|
|
3
|
+
export { codexSetup } from './codex.js';
|
|
4
|
+
export type { CodexSetupOptions } from './codex.js';
|
|
5
|
+
export type { AdapterSetup, InstallContext, SetupContext, SetupStep } from './setup.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAErF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** What `install` and `uninstall` are asked to set up or undo. */
|
|
2
|
+
export interface SetupContext {
|
|
3
|
+
/**
|
|
4
|
+
* The checkout the sessions work in, an absolute path. A linked git worktree is set up on its
|
|
5
|
+
* own: a harness reads the settings of the folder a session is opened in, not of the main
|
|
6
|
+
* checkout
|
|
7
|
+
*/
|
|
8
|
+
project: string;
|
|
9
|
+
/**
|
|
10
|
+
* `project`: for this person in this project only. `user`: for this person in every project.
|
|
11
|
+
* A path of this machine never goes into a file the project shares: what names one is kept
|
|
12
|
+
* where only this person has it
|
|
13
|
+
*/
|
|
14
|
+
scope: 'project' | 'user';
|
|
15
|
+
}
|
|
16
|
+
export interface InstallContext extends SetupContext {
|
|
17
|
+
/** Whether the notes of the bridge go into the instructions file the sessions read */
|
|
18
|
+
notes: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the notes let a session a person opened carry out a job of another agent without
|
|
21
|
+
* asking the person first
|
|
22
|
+
*/
|
|
23
|
+
takeJobs: boolean;
|
|
24
|
+
/** Whether sessions may call the bridge's tools without a permission prompt, where the harness has one */
|
|
25
|
+
allowTools: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One change to the setup of a harness, as a person is shown it before anything is written.
|
|
29
|
+
* A step exists only when it changes something: a harness that is set up already has none.
|
|
30
|
+
*/
|
|
31
|
+
export interface SetupStep {
|
|
32
|
+
/** What changes, in a few words */
|
|
33
|
+
title: string;
|
|
34
|
+
/** The change itself, a line each: the command that runs, or what a file gains or loses */
|
|
35
|
+
lines: string[];
|
|
36
|
+
/** Makes the change. Rejects with what went wrong */
|
|
37
|
+
apply(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** How one harness is given the bridge for the sessions a person opens, and how that is undone. */
|
|
40
|
+
export interface AdapterSetup {
|
|
41
|
+
/**
|
|
42
|
+
* The steps that give the sessions of a project the bridge: its tools, the hooks the harness
|
|
43
|
+
* needs to wake a session and to tell the tools who calls, and the notes. Empty when
|
|
44
|
+
* everything is in place.
|
|
45
|
+
*
|
|
46
|
+
* @throws Error when the harness is not installed, or what it keeps cannot be read
|
|
47
|
+
*/
|
|
48
|
+
install(context: InstallContext): Promise<SetupStep[]>;
|
|
49
|
+
/** The steps that take all of it away again. Empty when nothing of the bridge is there */
|
|
50
|
+
uninstall(context: SetupContext): Promise<SetupStep[]>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/setup/setup.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,sFAAsF;IACtF,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,0GAA0G;IAC1G,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,qDAAqD;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,mGAAmG;AACnG,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACvD,0FAA0F;IAC1F,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/setup/setup.ts"],"names":[],"mappings":""}
|