@cogitator-ai/bridge 0.2.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 +242 -8
- package/dist/adapter.d.ts +130 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +2 -0
- package/dist/adapter.js.map +1 -0
- package/dist/adapters/claude.d.ts +145 -0
- package/dist/adapters/claude.d.ts.map +1 -0
- package/dist/adapters/claude.js +537 -0
- package/dist/adapters/claude.js.map +1 -0
- package/dist/adapters/codex.d.ts +71 -0
- package/dist/adapters/codex.d.ts.map +1 -0
- package/dist/adapters/codex.js +379 -0
- package/dist/adapters/codex.js.map +1 -0
- package/dist/adapters/exec.d.ts +70 -0
- package/dist/adapters/exec.d.ts.map +1 -0
- package/dist/adapters/exec.js +161 -0
- package/dist/adapters/exec.js.map +1 -0
- package/dist/adapters/hosted.d.ts +168 -0
- package/dist/adapters/hosted.d.ts.map +1 -0
- package/dist/adapters/hosted.js +361 -0
- package/dist/adapters/hosted.js.map +1 -0
- 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/client.d.ts +9 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -3
- package/dist/client.js.map +1 -1
- package/dist/dispatcher.d.ts +69 -17
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher.js +243 -17
- package/dist/dispatcher.js.map +1 -1
- package/dist/host.d.ts +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/inputs.d.ts +40 -1
- package/dist/inputs.d.ts.map +1 -1
- package/dist/inputs.js +25 -2
- package/dist/inputs.js.map +1 -1
- package/dist/paths.d.ts +6 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +19 -0
- package/dist/paths.js.map +1 -1
- package/dist/protocol.d.ts +5 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +5 -0
- package/dist/protocol.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.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/conformance.d.ts +65 -0
- package/dist/testing/conformance.d.ts.map +1 -0
- package/dist/testing/conformance.js +217 -0
- package/dist/testing/conformance.js.map +1 -0
- package/dist/testing/fake-harnesses.d.ts +121 -0
- package/dist/testing/fake-harnesses.d.ts.map +1 -0
- package/dist/testing/fake-harnesses.js +303 -0
- package/dist/testing/fake-harnesses.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- 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/dist/types.d.ts +3 -39
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/waiter.d.ts +36 -0
- package/dist/waiter.d.ts.map +1 -0
- package/dist/waiter.js +92 -0
- package/dist/waiter.js.map +1 -0
- package/fakes/claude.mjs +715 -0
- package/fakes/codex.mjs +571 -0
- package/fakes/lib.mjs +585 -0
- package/fakes/mcp.mjs +151 -0
- package/fakes/sandbox.mjs +84 -0
- package/package.json +19 -1
|
@@ -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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AAI,EAAE,CAAC,CAAC;;gBACpC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { claudeSetup, withBridgeSettings, withoutBridgeSettings } from './claude.js';
|
|
2
|
+
export type { BridgeSettings, 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":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { BridgeAdapter, IdentifyContext } from '../adapter.js';
|
|
2
|
+
/** What a case of the adapter contract works in. */
|
|
3
|
+
export interface AdapterConformanceContext {
|
|
4
|
+
/** The folder of the bridge the case hosts: an adapter whose sessions call back needs it */
|
|
5
|
+
home: string;
|
|
6
|
+
}
|
|
7
|
+
/** An adapter under test, with the harness it reaches (a real one or a stand-in). */
|
|
8
|
+
export interface AdapterConformanceTarget {
|
|
9
|
+
/** A fresh adapter. Every case gets its own */
|
|
10
|
+
create(context: AdapterConformanceContext): Promise<BridgeAdapter> | BridgeAdapter;
|
|
11
|
+
/** Called with each adapter `create` made once its case is done, to stop what it started */
|
|
12
|
+
release?(adapter: BridgeAdapter): Promise<void>;
|
|
13
|
+
/** An empty folder a case may keep the bridge's files in, a new one for every call */
|
|
14
|
+
home(): string;
|
|
15
|
+
/** A folder the harness may start sessions in */
|
|
16
|
+
cwd: string;
|
|
17
|
+
/**
|
|
18
|
+
* What the adapter is expected to have besides delivery. `declares-itself` fails when the
|
|
19
|
+
* adapter has more or less, so a method that goes missing is noticed instead of its cases
|
|
20
|
+
* being skipped
|
|
21
|
+
*/
|
|
22
|
+
supports: readonly AdapterFeature[];
|
|
23
|
+
/**
|
|
24
|
+
* Resolves once the session got a text that includes `needle`: how a case sees what reached
|
|
25
|
+
* the harness. Rejects when it does not come in reasonable time
|
|
26
|
+
*/
|
|
27
|
+
received(sessionId: string, needle: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* What `identify` is given for a process of the session. Needed when the adapter is said to
|
|
30
|
+
* support `identify`
|
|
31
|
+
*/
|
|
32
|
+
processOf?(sessionId: string): IdentifyContext;
|
|
33
|
+
/**
|
|
34
|
+
* For an adapter that starts no sessions: opens a session of the harness outside the bridge
|
|
35
|
+
* and returns its id, so the delivery of a letter to it can be checked
|
|
36
|
+
*/
|
|
37
|
+
openSession?(): Promise<string>;
|
|
38
|
+
/** Cases to leave out, with the reason */
|
|
39
|
+
skip?: Partial<Record<AdapterScenario, string>>;
|
|
40
|
+
}
|
|
41
|
+
export type AdapterFeature = 'createSession' | 'liveSessions' | 'identify' | 'health';
|
|
42
|
+
export type AdapterScenario = 'declares-itself' | 'starts-a-session' | 'delivers-a-letter' | 'lists-its-sessions' | 'identifies-its-sessions' | 'reports-health';
|
|
43
|
+
/** One case of the adapter contract. */
|
|
44
|
+
export interface AdapterConformanceCase {
|
|
45
|
+
name: AdapterScenario;
|
|
46
|
+
/** Why the case does not apply, when it does not */
|
|
47
|
+
skip?: string;
|
|
48
|
+
/** Runs the case, throws an `AssertionError` when the adapter breaks the contract */
|
|
49
|
+
run(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The contract every adapter keeps, as cases a test runs one by one against the adapter and its
|
|
53
|
+
* harness: it says what it is, starts a session that gets the job's first letter, hands later
|
|
54
|
+
* letters to it, and tells the truth about the sessions it lists, the processes it recognizes
|
|
55
|
+
* and the health it reports. Cases for what an adapter does not claim are skipped.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* for (const conformance of adapterConformanceCases(target)) {
|
|
60
|
+
* it.skipIf(conformance.skip)(conformance.name, () => conformance.run());
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function adapterConformanceCases(target: AdapterConformanceTarget): AdapterConformanceCase[];
|
|
65
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../src/testing/conformance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMpE,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACxC,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qFAAqF;AACrF,MAAM,WAAW,wBAAwB;IACvC,+CAA+C;IAC/C,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC;IACnF,4FAA4F;IAC5F,OAAO,CAAC,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,sFAAsF;IACtF,IAAI,IAAI,MAAM,CAAC;IACf,iDAAiD;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D;;;OAGG;IACH,SAAS,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IAC/C;;;OAGG;IACH,WAAW,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,0CAA0C;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,CAAC;AAItF,MAAM,MAAM,eAAe,GACvB,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,yBAAyB,GACzB,gBAAgB,CAAC;AAErB,wCAAwC;AACxC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,eAAe,CAAC;IACtB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AA6GD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,wBAAwB,GAC/B,sBAAsB,EAAE,CAkI1B"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { isBridgeError } from '../errors.js';
|
|
4
|
+
import { hostBridge } from '../host.js';
|
|
5
|
+
import { aliasOfHarness } from '../registry.js';
|
|
6
|
+
import { HarnessNameSchema } from '../types.js';
|
|
7
|
+
const FEATURES = ['createSession', 'liveSessions', 'identify', 'health'];
|
|
8
|
+
const POLL_MS = 20;
|
|
9
|
+
const SETTLE_MS = 15_000;
|
|
10
|
+
async function until(read, what) {
|
|
11
|
+
const deadline = Date.now() + SETTLE_MS;
|
|
12
|
+
for (;;) {
|
|
13
|
+
const value = await read();
|
|
14
|
+
if (value !== undefined)
|
|
15
|
+
return value;
|
|
16
|
+
if (Date.now() > deadline)
|
|
17
|
+
assert.fail(`Timed out waiting for ${what}`);
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_MS));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function staged(target, work) {
|
|
22
|
+
const home = target.home();
|
|
23
|
+
const adapter = await target.create({ home });
|
|
24
|
+
const errors = [];
|
|
25
|
+
let host;
|
|
26
|
+
try {
|
|
27
|
+
host = await hostBridge({
|
|
28
|
+
home,
|
|
29
|
+
adapters: [adapter],
|
|
30
|
+
tickMs: 50,
|
|
31
|
+
onError: (error) => errors.push(error),
|
|
32
|
+
});
|
|
33
|
+
const bridge = host.dispatcher;
|
|
34
|
+
const orchestrator = await bridge.register({
|
|
35
|
+
harness: 'conformance',
|
|
36
|
+
sessionId: randomUUID(),
|
|
37
|
+
cwd: target.cwd,
|
|
38
|
+
project: target.cwd,
|
|
39
|
+
});
|
|
40
|
+
await work({
|
|
41
|
+
adapter,
|
|
42
|
+
host,
|
|
43
|
+
orchestrator,
|
|
44
|
+
start: async () => {
|
|
45
|
+
let to = `${aliasOfHarness(adapter.harness)}:new`;
|
|
46
|
+
if (!adapter.createSession) {
|
|
47
|
+
assert.ok(target.openSession, 'an adapter that starts no session needs openSession');
|
|
48
|
+
const opened = await bridge.register({
|
|
49
|
+
harness: adapter.harness,
|
|
50
|
+
sessionId: await target.openSession(),
|
|
51
|
+
cwd: target.cwd,
|
|
52
|
+
project: target.cwd,
|
|
53
|
+
});
|
|
54
|
+
to = opened.name;
|
|
55
|
+
}
|
|
56
|
+
const { job, letter } = await bridge.createJob(orchestrator.name, {
|
|
57
|
+
to,
|
|
58
|
+
body: 'Conformance: say you got this',
|
|
59
|
+
});
|
|
60
|
+
const agent = await until(async () => {
|
|
61
|
+
const current = await bridge.job(job.number);
|
|
62
|
+
assert.notEqual(current.state, 'failed', `the job failed: ${current.reason ?? ''}`);
|
|
63
|
+
const [worker] = await bridge.agents({ harness: adapter.harness, statuses: ['active'] });
|
|
64
|
+
return worker?.sessionId ? worker : undefined;
|
|
65
|
+
}, `the ${adapter.harness} session to start`);
|
|
66
|
+
return { agent, job: job.number, firstLetter: letter.id };
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
assert.deepEqual(errors.map((error) => error.message), [], 'the bridge reported errors');
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
await host?.close();
|
|
73
|
+
await target.release?.(adapter);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A letter for a session that already has its job: one more thing on that job, or the first
|
|
78
|
+
* letter of another job when the session's answer has closed the first one meanwhile, as the
|
|
79
|
+
* answer of a session the bridge speaks for does.
|
|
80
|
+
*/
|
|
81
|
+
async function later(host, orchestrator, agent, job) {
|
|
82
|
+
const body = 'Conformance: one more thing';
|
|
83
|
+
try {
|
|
84
|
+
return (await host.dispatcher.send(orchestrator.name, { job, kind: 'note', body })).letter;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
if (!isBridgeError(error) || error.code !== 'job_finished')
|
|
88
|
+
throw error;
|
|
89
|
+
return (await host.dispatcher.createJob(orchestrator.name, { to: agent.name, body })).letter;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The contract every adapter keeps, as cases a test runs one by one against the adapter and its
|
|
94
|
+
* harness: it says what it is, starts a session that gets the job's first letter, hands later
|
|
95
|
+
* letters to it, and tells the truth about the sessions it lists, the processes it recognizes
|
|
96
|
+
* and the health it reports. Cases for what an adapter does not claim are skipped.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* for (const conformance of adapterConformanceCases(target)) {
|
|
101
|
+
* it.skipIf(conformance.skip)(conformance.name, () => conformance.run());
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export function adapterConformanceCases(target) {
|
|
106
|
+
const probe = () => target.create({ home: target.home() });
|
|
107
|
+
const cases = [
|
|
108
|
+
{
|
|
109
|
+
name: 'declares-itself',
|
|
110
|
+
async run() {
|
|
111
|
+
const adapter = await probe();
|
|
112
|
+
try {
|
|
113
|
+
assert.equal(HarnessNameSchema.safeParse(adapter.harness).data, adapter.harness, 'the harness name is lower case letters, digits, ".", "_" and "-"');
|
|
114
|
+
assert.ok(adapter.delivery.trim(), 'the adapter names how letters travel');
|
|
115
|
+
assert.equal(adapter.createSession !== undefined, adapter.capabilities.createSession, 'createSession is there exactly when capabilities.createSession says so');
|
|
116
|
+
if (adapter.deliver) {
|
|
117
|
+
assert.ok(adapter.capabilities.push, 'an adapter that delivers says it pushes');
|
|
118
|
+
}
|
|
119
|
+
assert.deepEqual(FEATURES.filter((feature) => adapter[feature] !== undefined), FEATURES.filter((feature) => target.supports.includes(feature)), 'the adapter has what the target says it supports, no more and no less');
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
await target.release?.(adapter);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'starts-a-session',
|
|
128
|
+
needs: 'createSession',
|
|
129
|
+
run: () => staged(target, async ({ host, start }) => {
|
|
130
|
+
const { agent, job, firstLetter } = await start();
|
|
131
|
+
await target.received(agent.sessionId, firstLetter);
|
|
132
|
+
await target.received(agent.sessionId, 'not typed by the user');
|
|
133
|
+
await until(async () => {
|
|
134
|
+
const [first] = await host.dispatcher.letters({ job });
|
|
135
|
+
return first?.state === 'queued' ? undefined : first;
|
|
136
|
+
}, 'the first letter to count as handed over');
|
|
137
|
+
assert.notEqual((await host.dispatcher.job(job)).state, 'submitted', 'the job is taken');
|
|
138
|
+
}),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'delivers-a-letter',
|
|
142
|
+
run: () => staged(target, async ({ host, orchestrator, start }) => {
|
|
143
|
+
const { agent, job, firstLetter } = await start();
|
|
144
|
+
await target.received(agent.sessionId, firstLetter);
|
|
145
|
+
const letter = await later(host, orchestrator, agent, job);
|
|
146
|
+
await target.received(agent.sessionId, letter.id);
|
|
147
|
+
await until(async () => {
|
|
148
|
+
const sent = await host.dispatcher.letters({ job: letter.job });
|
|
149
|
+
const current = sent.find((entry) => entry.id === letter.id);
|
|
150
|
+
return current?.state === 'queued' ? undefined : current;
|
|
151
|
+
}, 'the later letter to count as handed over');
|
|
152
|
+
}),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'lists-its-sessions',
|
|
156
|
+
needs: 'liveSessions',
|
|
157
|
+
run: () => staged(target, async ({ adapter, start }) => {
|
|
158
|
+
const { agent } = await start();
|
|
159
|
+
await until(async () => {
|
|
160
|
+
const sessions = (await adapter.liveSessions?.()) ?? [];
|
|
161
|
+
return sessions.find((session) => session.sessionId === agent.sessionId);
|
|
162
|
+
}, 'the started session to be listed');
|
|
163
|
+
}),
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'identifies-its-sessions',
|
|
167
|
+
needs: 'identify',
|
|
168
|
+
async run() {
|
|
169
|
+
const adapter = await probe();
|
|
170
|
+
try {
|
|
171
|
+
assert.equal(adapter.identify?.({ env: {}, cwd: target.cwd }), undefined, 'a process of no session is nobody');
|
|
172
|
+
assert.ok(target.processOf, 'a target whose adapter identifies sessions gives processOf');
|
|
173
|
+
const sessionId = randomUUID();
|
|
174
|
+
const caller = adapter.identify?.(target.processOf(sessionId));
|
|
175
|
+
assert.equal(caller?.harness, adapter.harness);
|
|
176
|
+
assert.equal(caller?.sessionId, sessionId);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
await target.release?.(adapter);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: 'reports-health',
|
|
185
|
+
needs: 'health',
|
|
186
|
+
async run() {
|
|
187
|
+
const adapter = await probe();
|
|
188
|
+
try {
|
|
189
|
+
const checks = (await adapter.health?.({ cwd: target.cwd })) ?? [];
|
|
190
|
+
assert.ok(checks.length > 0, 'health says something');
|
|
191
|
+
assert.equal(new Set(checks.map((check) => check.id)).size, checks.length, 'ids repeat');
|
|
192
|
+
for (const check of checks) {
|
|
193
|
+
assert.ok(['ok', 'warn', 'fail'].includes(check.status), `status of ${check.id}`);
|
|
194
|
+
assert.ok(check.title.trim(), `title of ${check.id}`);
|
|
195
|
+
if (check.status !== 'ok') {
|
|
196
|
+
assert.ok(check.fix?.trim(), `${check.id} is ${check.status} and says what to do`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
await target.release?.(adapter);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
];
|
|
206
|
+
return cases.map(({ name, needs, run }) => {
|
|
207
|
+
const skip = target.skip?.[name] ??
|
|
208
|
+
(needs && !target.supports.includes(needs) ? `the adapter has no ${needs}` : undefined) ??
|
|
209
|
+
(name === 'delivers-a-letter' &&
|
|
210
|
+
!target.supports.includes('createSession') &&
|
|
211
|
+
!target.openSession
|
|
212
|
+
? 'the adapter starts no session and the target opens none'
|
|
213
|
+
: undefined);
|
|
214
|
+
return { name, run, ...(skip !== undefined && { skip }) };
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../src/testing/conformance.ts"],"names":[],"mappings":"AA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E,GAAG,EAAE,EAAE,EAAE;QACxC,MAAM,IAAI,GACR,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;YACnB,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACvF,CAAC,IAAI,KAAK,mBAAmB;gBAC7B,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC;gBAC1C,CAAC,MAAM,CAAC,WAAW;gBACjB,CAAC,CAAC,yDAAyD;gBAC3D,CAAC,CAAC,SAAS,CAAC,CAAC;QACjB,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export interface FakeCommandRun {
|
|
2
|
+
command: string;
|
|
3
|
+
code: number | null;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
}
|
|
7
|
+
/** A call of a tool of an MCP server the session has. */
|
|
8
|
+
export interface FakeToolRun {
|
|
9
|
+
/** `<server>.<tool>` */
|
|
10
|
+
tool: string;
|
|
11
|
+
/** The arguments as the scripted model wrote them */
|
|
12
|
+
args: Record<string, unknown>;
|
|
13
|
+
/** The arguments as they reached the server, when a hook of the harness changed them */
|
|
14
|
+
sent?: Record<string, unknown>;
|
|
15
|
+
/** What the tool answered, or why the harness did not call it */
|
|
16
|
+
text: string;
|
|
17
|
+
isError: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface FakeTurn {
|
|
20
|
+
turn: number;
|
|
21
|
+
at: string;
|
|
22
|
+
input: string;
|
|
23
|
+
ran: FakeCommandRun[];
|
|
24
|
+
/** The tool calls of the turn, in order */
|
|
25
|
+
tools: FakeToolRun[];
|
|
26
|
+
answer: string;
|
|
27
|
+
wokenBy: 'prompt' | 'user' | 'hook' | 'queue' | 'exec';
|
|
28
|
+
}
|
|
29
|
+
export interface FakeClaudeSession {
|
|
30
|
+
id?: string;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
cwd: string;
|
|
34
|
+
kind: 'background' | 'interactive';
|
|
35
|
+
status?: 'busy' | 'idle';
|
|
36
|
+
state?: string;
|
|
37
|
+
pid?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface FakeRunResult {
|
|
40
|
+
code: number | null;
|
|
41
|
+
stdout: string;
|
|
42
|
+
stderr: string;
|
|
43
|
+
}
|
|
44
|
+
export interface FakeRunOptions {
|
|
45
|
+
cwd?: string;
|
|
46
|
+
/** Added to what `env()` gives */
|
|
47
|
+
env?: NodeJS.ProcessEnv;
|
|
48
|
+
/** Written to stdin, which is then closed */
|
|
49
|
+
input?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface FakeHarnesses {
|
|
52
|
+
/** The folder holding the `claude` and `codex` executables */
|
|
53
|
+
readonly bin: string;
|
|
54
|
+
/** Where the fakes keep their state */
|
|
55
|
+
readonly home: string;
|
|
56
|
+
/**
|
|
57
|
+
* `base` (default `process.env`) with the fakes first on PATH and their state folder set.
|
|
58
|
+
* Session id variables of a surrounding real harness (`CLAUDE_CODE_SESSION_ID`,
|
|
59
|
+
* `CODEX_THREAD_ID`) are removed. The bridge's folder (`COGITATOR_BRIDGE_HOME`) and Claude
|
|
60
|
+
* Code's (`CLAUDE_CONFIG_DIR`) are those the options name, or `base` when it differs there
|
|
61
|
+
* from the environment of the tests themselves, and never those of the machine: otherwise
|
|
62
|
+
* they are folders inside the fakes' own, so nothing under test reaches a real dispatcher or
|
|
63
|
+
* reads real settings by accident
|
|
64
|
+
*/
|
|
65
|
+
env(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
66
|
+
/** Marks a folder as one Claude Code trusts */
|
|
67
|
+
trustFolder(folder: string): void;
|
|
68
|
+
/** Runs a fake command to its end */
|
|
69
|
+
run(harness: 'claude' | 'codex', args: string[], options?: FakeRunOptions): Promise<FakeRunResult>;
|
|
70
|
+
/** A Claude Code session sitting idle like an open window */
|
|
71
|
+
openClaudeWindow(options: {
|
|
72
|
+
cwd: string;
|
|
73
|
+
settings?: unknown;
|
|
74
|
+
/** MCP servers of the session, as `--mcp-config` takes them: `{ mcpServers: { ... } }` */
|
|
75
|
+
mcpConfig?: unknown;
|
|
76
|
+
name?: string;
|
|
77
|
+
env?: NodeJS.ProcessEnv;
|
|
78
|
+
}): Promise<string>;
|
|
79
|
+
/** A person types into a Claude Code session */
|
|
80
|
+
say(sessionId: string, text: string): Promise<void>;
|
|
81
|
+
claudeSessions(options?: {
|
|
82
|
+
all?: boolean;
|
|
83
|
+
}): Promise<FakeClaudeSession[]>;
|
|
84
|
+
/**
|
|
85
|
+
* A Codex thread sitting idle, owned by the stand-in of the desktop app unless `owner` is
|
|
86
|
+
* `none`. With `sandbox` its commands are kept from sockets and from writing outside `cwd`
|
|
87
|
+
*/
|
|
88
|
+
openCodexThread(options: {
|
|
89
|
+
cwd: string;
|
|
90
|
+
owner?: 'app' | 'none';
|
|
91
|
+
sandbox?: 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
92
|
+
}): Promise<string>;
|
|
93
|
+
startCodexApp(): Promise<void>;
|
|
94
|
+
stopCodexApp(): Promise<void>;
|
|
95
|
+
startCodexDaemon(): Promise<void>;
|
|
96
|
+
stopCodexDaemon(): Promise<void>;
|
|
97
|
+
/** The turns a session or thread ran, oldest first */
|
|
98
|
+
transcript(harness: 'claude' | 'codex', id: string): FakeTurn[];
|
|
99
|
+
/** Resolves with the first turn of the session `matches` accepts, rejects after `timeoutMs` (default 30000) naming what it waited for and the turns seen */
|
|
100
|
+
waitForTurn(harness: 'claude' | 'codex', id: string, matches: (turn: FakeTurn) => boolean, options?: {
|
|
101
|
+
timeoutMs?: number;
|
|
102
|
+
what?: string;
|
|
103
|
+
}): Promise<FakeTurn>;
|
|
104
|
+
/** Stops every process the fakes started and removes the folders this call created */
|
|
105
|
+
cleanup(): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
export interface FakeHarnessOptions {
|
|
108
|
+
/** An existing empty folder to work in, a new temp folder by default */
|
|
109
|
+
dir?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Extra environment for every fake process, such as FAKE_CLAUDE_MISSING, or
|
|
112
|
+
* COGITATOR_BRIDGE_HOME for the bridge their sessions call
|
|
113
|
+
*/
|
|
114
|
+
env?: NodeJS.ProcessEnv;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Installs executable stand-ins of `claude` and `codex` for tests of code that drives the real
|
|
118
|
+
* command lines. Each call gets its own executables and its own state, `cleanup()` ends it.
|
|
119
|
+
*/
|
|
120
|
+
export declare function installFakeHarnesses(options?: FakeHarnessOptions): FakeHarnesses;
|
|
121
|
+
//# sourceMappingURL=fake-harnesses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-harnesses.d.ts","sourceRoot":"","sources":["../../src/testing/fake-harnesses.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW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