@cogitator-ai/bridge 0.3.0 → 0.5.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 +154 -19
- package/dist/adapter.d.ts +9 -1
- 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/hosted.d.ts +36 -4
- package/dist/adapters/hosted.d.ts.map +1 -1
- package/dist/adapters/hosted.js +188 -9
- package/dist/adapters/hosted.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/client.d.ts +16 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +24 -1
- package/dist/client.js.map +1 -1
- package/dist/dispatcher.d.ts +115 -3
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher.js +496 -23
- 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/guards.d.ts +3 -2
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +4 -3
- package/dist/guards.js.map +1 -1
- package/dist/host.d.ts +9 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +2 -0
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +19 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/dist/inputs.d.ts +76 -1
- package/dist/inputs.d.ts.map +1 -1
- package/dist/inputs.js +31 -1
- package/dist/inputs.js.map +1 -1
- package/dist/job-record.d.ts +1 -0
- package/dist/job-record.d.ts.map +1 -1
- package/dist/job-record.js +1 -0
- package/dist/job-record.js.map +1 -1
- package/dist/letters.d.ts.map +1 -1
- package/dist/letters.js +23 -1
- package/dist/letters.js.map +1 -1
- package/dist/person-channel.d.ts +45 -0
- package/dist/person-channel.d.ts.map +1 -0
- package/dist/person-channel.js +154 -0
- package/dist/person-channel.js.map +1 -0
- package/dist/person-inbox.d.ts +30 -0
- package/dist/person-inbox.d.ts.map +1 -0
- package/dist/person-inbox.js +60 -0
- package/dist/person-inbox.js.map +1 -0
- package/dist/person.d.ts +52 -0
- package/dist/person.d.ts.map +1 -0
- package/dist/person.js +30 -0
- package/dist/person.js.map +1 -0
- package/dist/protocol.d.ts +6 -1
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +5 -1
- package/dist/protocol.js.map +1 -1
- package/dist/rights/index.d.ts +36 -0
- package/dist/rights/index.d.ts.map +1 -0
- package/dist/rights/index.js +186 -0
- package/dist/rights/index.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +9 -0
- 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/store/sqlite.d.ts +6 -1
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +74 -18
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/store.d.ts +6 -2
- package/dist/store/store.d.ts.map +1 -1
- 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 +93 -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 +377 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/types.d.ts +81 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -1
- 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 +18 -1
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { tool } from '@cogitator-ai/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { BridgeClient } from '../client.js';
|
|
4
|
+
import { BridgeError, isBridgeError } from '../errors.js';
|
|
5
|
+
import { oneLine } from '../letters.js';
|
|
6
|
+
import { NEW_SESSION, aliasOfHarness } from '../registry.js';
|
|
7
|
+
import { mailText } from '../waiter.js';
|
|
8
|
+
import { callerOfToolCall } from './caller.js';
|
|
9
|
+
/** A tool that changes something in the bridge: it adds, never destroys, and stays on this machine. */
|
|
10
|
+
const WRITES = {
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
destructiveHint: false,
|
|
13
|
+
idempotentHint: false,
|
|
14
|
+
openWorldHint: false,
|
|
15
|
+
};
|
|
16
|
+
const READS = { readOnlyHint: true, openWorldHint: false };
|
|
17
|
+
const OPEN_STATES = ['submitted', 'working', 'input-required'];
|
|
18
|
+
/** How many letters of a job `job` shows, the newest. */
|
|
19
|
+
const TRAIL_LETTERS = 10;
|
|
20
|
+
/** How much of one letter `job` shows. The whole letter is in the inbox of who got it. */
|
|
21
|
+
const TRAIL_BODY = 4_000;
|
|
22
|
+
const JobNumber = z.number().int().positive().describe('The number of the job');
|
|
23
|
+
/** An ISO time to the minute, as an agent reads it: `2026-11-16 13:49 UTC`. */
|
|
24
|
+
function clock(at) {
|
|
25
|
+
return `${at.slice(0, 16).replace('T', ' ')} UTC`;
|
|
26
|
+
}
|
|
27
|
+
function jobLine(job) {
|
|
28
|
+
return `#${job.number} ${job.state} ${job.from} -> ${job.to} "${oneLine(job.title)}"`;
|
|
29
|
+
}
|
|
30
|
+
function letterBlock(letter) {
|
|
31
|
+
const body = letter.body.length > TRAIL_BODY
|
|
32
|
+
? `${letter.body.slice(0, TRAIL_BODY)}\n[cut here, ${letter.body.length} characters in all]`
|
|
33
|
+
: letter.body;
|
|
34
|
+
const outcome = letter.outcome ? ` (${letter.outcome})` : '';
|
|
35
|
+
return `${clock(letter.createdAt)} ${letter.kind}${outcome} from ${letter.from} to ${letter.to}, letter ${letter.id}:\n${body}`;
|
|
36
|
+
}
|
|
37
|
+
function agentLine(agent, self, waiting) {
|
|
38
|
+
const notes = [
|
|
39
|
+
agent.name === self ? 'this session' : undefined,
|
|
40
|
+
agent.sessionName ? `"${oneLine(agent.sessionName)}"` : undefined,
|
|
41
|
+
agent.status === 'starting' ? 'starting' : undefined,
|
|
42
|
+
waiting ? 'wakes for mail' : undefined,
|
|
43
|
+
].filter((note) => note !== undefined);
|
|
44
|
+
return `${agent.name} ${agent.harness}${notes.length > 0 ? `, ${notes.join(', ')}` : ''}`;
|
|
45
|
+
}
|
|
46
|
+
const NO_DISPATCHER = 'No bridge dispatcher runs on this machine, so nothing was sent. Tell the user to start it: cogitator bridge serve';
|
|
47
|
+
const NO_SESSION = 'The bridge cannot tell which session is calling: the call names none, and neither does the environment of the tools. ' +
|
|
48
|
+
'They work inside a session of Claude Code or Codex. Tell the user to check the setup: cogitator bridge doctor';
|
|
49
|
+
/**
|
|
50
|
+
* The bridge as tools of an agent: hand a job over, ask and answer on the way, report, and see
|
|
51
|
+
* what goes on. They are what `cogitator bridge mcp` serves to Claude Code and Codex. No tool
|
|
52
|
+
* waits for another agent: each returns at once, and the reply comes later as a letter.
|
|
53
|
+
*
|
|
54
|
+
* Every call says which session makes it (`callerOfToolCall`) and reaches the dispatcher on a
|
|
55
|
+
* connection of its own, so the tools go on working across a restart of the dispatcher and
|
|
56
|
+
* across a change of the session they serve.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { MCPServer } from '@cogitator-ai/mcp';
|
|
61
|
+
* import { bridgePaths } from '@cogitator-ai/bridge';
|
|
62
|
+
* import { BRIDGE_INSTRUCTIONS, bridgeTools } from '@cogitator-ai/bridge/tools';
|
|
63
|
+
*
|
|
64
|
+
* const server = new MCPServer({
|
|
65
|
+
* name: 'cogitator-bridge',
|
|
66
|
+
* version: '1.0.0',
|
|
67
|
+
* transport: 'stdio',
|
|
68
|
+
* instructions: BRIDGE_INSTRUCTIONS,
|
|
69
|
+
* });
|
|
70
|
+
* server.registerTools(bridgeTools({ socketPath: bridgePaths().socket }));
|
|
71
|
+
* await server.start();
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function bridgeTools(options) {
|
|
75
|
+
const env = options.env ?? process.env;
|
|
76
|
+
function originOf(args, context) {
|
|
77
|
+
const request = typeof context === 'object' && context !== null && 'request' in context
|
|
78
|
+
? context.request
|
|
79
|
+
: undefined;
|
|
80
|
+
const { meta, client } = (typeof request === 'object' && request !== null ? request : {});
|
|
81
|
+
const name = typeof client === 'object' && client !== null && 'name' in client
|
|
82
|
+
? client.name
|
|
83
|
+
: undefined;
|
|
84
|
+
return {
|
|
85
|
+
args,
|
|
86
|
+
...(typeof meta === 'object' && meta !== null && { meta: meta }),
|
|
87
|
+
...(typeof name === 'string' && { client: name }),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Runs `work` as the session that made the call, on a connection that lasts for the call. */
|
|
91
|
+
async function asCaller(args, context, work) {
|
|
92
|
+
let caller;
|
|
93
|
+
let bridge;
|
|
94
|
+
try {
|
|
95
|
+
caller = callerOfToolCall(originOf(args, context), env, options.cwd ?? process.cwd());
|
|
96
|
+
if (!caller)
|
|
97
|
+
throw new Error(NO_SESSION);
|
|
98
|
+
bridge = await BridgeClient.connect({
|
|
99
|
+
socketPath: options.socketPath,
|
|
100
|
+
caller,
|
|
101
|
+
...(options.timeoutMs !== undefined && { timeoutMs: options.timeoutMs }),
|
|
102
|
+
});
|
|
103
|
+
if (!bridge.agent) {
|
|
104
|
+
throw new BridgeError('not_registered', 'The bridge did not say which agent this session is');
|
|
105
|
+
}
|
|
106
|
+
return await work(bridge, bridge.agent);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (isBridgeError(error) && error.code === 'not_running' && !bridge) {
|
|
110
|
+
throw new Error(NO_DISPATCHER, { cause: error });
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
await bridge?.close().catch(() => undefined);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const delegate = tool({
|
|
119
|
+
name: 'delegate',
|
|
120
|
+
title: 'Hand a job to another agent',
|
|
121
|
+
description: 'Hand a job to another coding agent on this machine and get its number at once. The agent works in its own session: its questions and its report come back later as letters that wake this session, so end your turn after the call instead of waiting.',
|
|
122
|
+
parameters: z.looseObject({
|
|
123
|
+
to: z
|
|
124
|
+
.string()
|
|
125
|
+
.min(1)
|
|
126
|
+
.describe(`Who gets the job: "codex" or "claude" for the session of that agent in this project (one is started when none is open), "codex:${NEW_SESSION}" for a fresh one, or an agent name from the agents tool such as "codex-2@app"`),
|
|
127
|
+
task: z
|
|
128
|
+
.string()
|
|
129
|
+
.min(1)
|
|
130
|
+
.describe('The job: what to do, and what done looks like. The other agent sees nothing of this conversation, so name the files, the constraints and the decisions already made'),
|
|
131
|
+
title: z.string().optional().describe('A short name of the job, its first line by default'),
|
|
132
|
+
cwd: z
|
|
133
|
+
.string()
|
|
134
|
+
.optional()
|
|
135
|
+
.describe("The folder the job is done in, inside this project. This session's by default"),
|
|
136
|
+
parent: z
|
|
137
|
+
.number()
|
|
138
|
+
.int()
|
|
139
|
+
.positive()
|
|
140
|
+
.optional()
|
|
141
|
+
.describe('The job this one is part of, when this session carries out several. Found by itself otherwise'),
|
|
142
|
+
}),
|
|
143
|
+
annotations: WRITES,
|
|
144
|
+
sideEffects: ['process'],
|
|
145
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
146
|
+
const { job, duplicate } = await bridge.createJob({
|
|
147
|
+
to: args.to,
|
|
148
|
+
body: args.task,
|
|
149
|
+
...(args.title !== undefined && { title: args.title }),
|
|
150
|
+
...(args.cwd !== undefined && { cwd: args.cwd }),
|
|
151
|
+
...(args.parent !== undefined && { parent: args.parent }),
|
|
152
|
+
});
|
|
153
|
+
return (`Job #${job.number} is with ${job.to} (${job.state})${duplicate ? ', handed over before: nothing was sent twice' : ''}. ` +
|
|
154
|
+
'Its questions and its report arrive as letters. Say in one line what you handed over, then end your turn: do not wait or poll.');
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
const ask = tool({
|
|
158
|
+
name: 'ask',
|
|
159
|
+
title: 'Ask about a job',
|
|
160
|
+
description: 'Ask the other agent of a job a question: whoever handed you the job, or the agent you handed one to. The answer comes back as a letter that wakes this session, so end your turn after asking.',
|
|
161
|
+
parameters: z.looseObject({
|
|
162
|
+
job: JobNumber,
|
|
163
|
+
question: z
|
|
164
|
+
.string()
|
|
165
|
+
.min(1)
|
|
166
|
+
.describe('The question, with what the other agent needs to answer it'),
|
|
167
|
+
}),
|
|
168
|
+
annotations: WRITES,
|
|
169
|
+
sideEffects: ['external'],
|
|
170
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
171
|
+
const sent = await bridge.send({ job: args.job, kind: 'question', body: args.question });
|
|
172
|
+
return `Asked ${sent.letter.to}. Job #${sent.job.number} is ${sent.job.state}. End your turn: the answer wakes this session.`;
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
const answer = tool({
|
|
176
|
+
name: 'answer',
|
|
177
|
+
title: 'Answer a question',
|
|
178
|
+
description: 'Answer a question another agent asked about a job, or decide its permission request. The answer goes to that agent, who does not see this conversation. A permission request takes a decision.',
|
|
179
|
+
parameters: z.looseObject({
|
|
180
|
+
job: JobNumber,
|
|
181
|
+
answer: z
|
|
182
|
+
.string()
|
|
183
|
+
.min(1)
|
|
184
|
+
.optional()
|
|
185
|
+
.describe('The answer to a question, or the reason of a decision'),
|
|
186
|
+
decision: z
|
|
187
|
+
.enum(['allow', 'deny', 'person'])
|
|
188
|
+
.optional()
|
|
189
|
+
.describe('For a permission request: allow or deny the call. person leaves a request or a question to the user, when it is not for you to say'),
|
|
190
|
+
letter: z
|
|
191
|
+
.string()
|
|
192
|
+
.optional()
|
|
193
|
+
.describe('The id of the letter this answers, from its first line. The open question of the job by default'),
|
|
194
|
+
}),
|
|
195
|
+
annotations: WRITES,
|
|
196
|
+
sideEffects: ['external'],
|
|
197
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
198
|
+
if (args.decision === 'person') {
|
|
199
|
+
const passed = await bridge.escalate(args.letter !== undefined ? { letter: args.letter } : { job: args.job });
|
|
200
|
+
return `Left to the user: their answer goes to ${passed.from}. Tell the user in one line that ${passed.from} waits for their word on job #${passed.job}, which they give with "cogitator bridge asks".`;
|
|
201
|
+
}
|
|
202
|
+
const body = args.answer ??
|
|
203
|
+
(args.decision === 'allow'
|
|
204
|
+
? 'Allowed'
|
|
205
|
+
: args.decision === 'deny'
|
|
206
|
+
? 'Refused'
|
|
207
|
+
: undefined);
|
|
208
|
+
if (body === undefined) {
|
|
209
|
+
throw new BridgeError('invalid_input', 'Say the answer, or the decision');
|
|
210
|
+
}
|
|
211
|
+
const sent = await bridge.send({
|
|
212
|
+
job: args.job,
|
|
213
|
+
kind: 'answer',
|
|
214
|
+
body,
|
|
215
|
+
...(args.decision !== undefined && { verdict: args.decision }),
|
|
216
|
+
...(args.letter !== undefined && { inReplyTo: args.letter }),
|
|
217
|
+
});
|
|
218
|
+
const said = args.decision === 'allow' ? 'Allowed' : args.decision === 'deny' ? 'Refused' : 'Answered';
|
|
219
|
+
return `${said} ${sent.letter.to}. Job #${sent.job.number} is ${sent.job.state}.`;
|
|
220
|
+
}),
|
|
221
|
+
});
|
|
222
|
+
const report = tool({
|
|
223
|
+
name: 'report',
|
|
224
|
+
title: 'Report on a job',
|
|
225
|
+
description: 'Report the result of a job that was handed to this session, which ends the job. Whoever handed it over reads only this report, so say what was done, where, and what is left.',
|
|
226
|
+
parameters: z.looseObject({
|
|
227
|
+
job: JobNumber,
|
|
228
|
+
result: z
|
|
229
|
+
.string()
|
|
230
|
+
.min(1)
|
|
231
|
+
.describe('What was done: the outcome, the files touched, how it was checked, what is left open'),
|
|
232
|
+
failed: z
|
|
233
|
+
.boolean()
|
|
234
|
+
.optional()
|
|
235
|
+
.describe('True when the job could not be done. The result then says why'),
|
|
236
|
+
}),
|
|
237
|
+
annotations: WRITES,
|
|
238
|
+
sideEffects: ['external'],
|
|
239
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
240
|
+
const sent = await bridge.send({
|
|
241
|
+
job: args.job,
|
|
242
|
+
kind: 'report',
|
|
243
|
+
body: args.result,
|
|
244
|
+
...(args.failed && { outcome: 'failed' }),
|
|
245
|
+
});
|
|
246
|
+
return `Reported to ${sent.letter.to}. Job #${sent.job.number} is ${sent.job.state}.`;
|
|
247
|
+
}),
|
|
248
|
+
});
|
|
249
|
+
const note = tool({
|
|
250
|
+
name: 'note',
|
|
251
|
+
title: 'Send a note on a job',
|
|
252
|
+
description: 'Tell the other agent of a job something it should know and need not answer: progress, a finding, a change of plan. The job goes on.',
|
|
253
|
+
parameters: z.looseObject({
|
|
254
|
+
job: JobNumber,
|
|
255
|
+
text: z.string().min(1).describe('What the other agent should know'),
|
|
256
|
+
}),
|
|
257
|
+
annotations: WRITES,
|
|
258
|
+
sideEffects: ['external'],
|
|
259
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
260
|
+
const sent = await bridge.send({ job: args.job, kind: 'note', body: args.text });
|
|
261
|
+
return `Sent the note to ${sent.letter.to}. Job #${sent.job.number} is ${sent.job.state}.`;
|
|
262
|
+
}),
|
|
263
|
+
});
|
|
264
|
+
const inbox = tool({
|
|
265
|
+
name: 'inbox',
|
|
266
|
+
title: 'Read the letters that wait',
|
|
267
|
+
description: 'Read the letters that wait for this session, each under the line that says which job it is about and who wrote it. Letters usually arrive by themselves: use this when nothing woke the session, or for a letter too long to be handed over whole.',
|
|
268
|
+
parameters: z.looseObject({
|
|
269
|
+
job: z.number().int().positive().optional().describe('Only the letters of one job'),
|
|
270
|
+
peek: z.boolean().optional().describe('Look without taking: the letters stay as they are'),
|
|
271
|
+
unhandled: z
|
|
272
|
+
.boolean()
|
|
273
|
+
.optional()
|
|
274
|
+
.describe('Also the letters read before and not answered since'),
|
|
275
|
+
}),
|
|
276
|
+
annotations: WRITES,
|
|
277
|
+
sideEffects: [],
|
|
278
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
279
|
+
const letters = await bridge.inbox({
|
|
280
|
+
...(args.job !== undefined && { job: args.job }),
|
|
281
|
+
...(args.peek && { peek: true }),
|
|
282
|
+
...(args.unhandled && { unhandled: true }),
|
|
283
|
+
});
|
|
284
|
+
return letters.length === 0 ? 'No letters wait for this session.' : mailText(letters);
|
|
285
|
+
}),
|
|
286
|
+
});
|
|
287
|
+
const job = tool({
|
|
288
|
+
name: 'job',
|
|
289
|
+
title: 'Look at a job',
|
|
290
|
+
description: 'See one job: its state, who handed it to whom, and for a job of this session its latest letters. Reads only, takes nothing from the inbox.',
|
|
291
|
+
parameters: z.looseObject({ job: JobNumber }),
|
|
292
|
+
annotations: READS,
|
|
293
|
+
sideEffects: [],
|
|
294
|
+
execute: async (args, context) => asCaller(args, context, async (bridge, self) => {
|
|
295
|
+
const found = await bridge.job(args.job);
|
|
296
|
+
const lines = [
|
|
297
|
+
jobLine(found),
|
|
298
|
+
`Handed over ${clock(found.createdAt)}, last change ${clock(found.updatedAt)}, folder ${found.cwd}`,
|
|
299
|
+
];
|
|
300
|
+
if (found.reason)
|
|
301
|
+
lines.push(`Reason: ${found.reason}`);
|
|
302
|
+
if (found.parent !== undefined)
|
|
303
|
+
lines.push(`Part of job #${found.parent}`);
|
|
304
|
+
if (found.from !== self.name && found.to !== self.name) {
|
|
305
|
+
lines.push('Its letters are between its two agents: this session is neither.');
|
|
306
|
+
return lines.join('\n');
|
|
307
|
+
}
|
|
308
|
+
const trail = await bridge.letters({
|
|
309
|
+
job: found.number,
|
|
310
|
+
newestFirst: true,
|
|
311
|
+
limit: TRAIL_LETTERS,
|
|
312
|
+
});
|
|
313
|
+
if (trail.length > 0) {
|
|
314
|
+
lines.push('', ...trail.reverse().map((letter) => letterBlock(letter)));
|
|
315
|
+
}
|
|
316
|
+
return lines.join('\n');
|
|
317
|
+
}),
|
|
318
|
+
});
|
|
319
|
+
const jobs = tool({
|
|
320
|
+
name: 'jobs',
|
|
321
|
+
title: 'List the jobs of this session',
|
|
322
|
+
description: 'List the jobs this session handed over or carries out: those in progress, or all of them.',
|
|
323
|
+
parameters: z.looseObject({
|
|
324
|
+
all: z.boolean().optional().describe('Also the jobs that are over, the newest first'),
|
|
325
|
+
}),
|
|
326
|
+
annotations: READS,
|
|
327
|
+
sideEffects: [],
|
|
328
|
+
execute: async (args, context) => asCaller(args, context, async (bridge, self) => {
|
|
329
|
+
const found = await bridge.jobs({
|
|
330
|
+
party: self.name,
|
|
331
|
+
...(!args.all && { states: OPEN_STATES }),
|
|
332
|
+
limit: 50,
|
|
333
|
+
});
|
|
334
|
+
if (found.length === 0) {
|
|
335
|
+
return args.all ? 'This session has no jobs.' : 'This session has no jobs in progress.';
|
|
336
|
+
}
|
|
337
|
+
return found.map((entry) => jobLine(entry)).join('\n');
|
|
338
|
+
}),
|
|
339
|
+
});
|
|
340
|
+
const cancel = tool({
|
|
341
|
+
name: 'cancel',
|
|
342
|
+
title: 'Take a job back',
|
|
343
|
+
description: 'Take back a job this session handed over. The agent that worked on it is told to stop, and what it did so far stays where it is.',
|
|
344
|
+
parameters: z.looseObject({
|
|
345
|
+
job: JobNumber,
|
|
346
|
+
reason: z.string().optional().describe('Why, for the agent that worked on it'),
|
|
347
|
+
}),
|
|
348
|
+
annotations: WRITES,
|
|
349
|
+
sideEffects: ['process'],
|
|
350
|
+
execute: async (args, context) => asCaller(args, context, async (bridge) => {
|
|
351
|
+
const canceled = await bridge.cancel(args.job, args.reason?.trim() || undefined);
|
|
352
|
+
return `Job #${canceled.number} is ${canceled.state}, ${canceled.to} is told.`;
|
|
353
|
+
}),
|
|
354
|
+
});
|
|
355
|
+
const agents = tool({
|
|
356
|
+
name: 'agents',
|
|
357
|
+
title: 'See who can take a job',
|
|
358
|
+
description: 'List the sessions of coding agents the bridge knows in this project, and the agents it can start a session of. Their names are what delegate takes.',
|
|
359
|
+
parameters: z.looseObject({}),
|
|
360
|
+
annotations: READS,
|
|
361
|
+
sideEffects: [],
|
|
362
|
+
execute: async (args, context) => asCaller(args, context, async (bridge, self) => {
|
|
363
|
+
const [known, status] = await Promise.all([
|
|
364
|
+
bridge.agents({ project: self.project, statuses: ['active', 'starting'] }),
|
|
365
|
+
bridge.status(),
|
|
366
|
+
]);
|
|
367
|
+
const lines = known.map((agent) => agentLine(agent, self.name, status.waiting.includes(agent.name)));
|
|
368
|
+
const startable = status.startable.map((harness) => aliasOfHarness(harness));
|
|
369
|
+
lines.push('', startable.length > 0
|
|
370
|
+
? `The bridge starts a session for a job handed to: ${startable.join(', ')} (when none is open in this project, or with ":${NEW_SESSION}" after the word)`
|
|
371
|
+
: 'The bridge cannot start sessions here: a job goes to a session that is listed above');
|
|
372
|
+
return lines.join('\n');
|
|
373
|
+
}),
|
|
374
|
+
});
|
|
375
|
+
return [delegate, ask, answer, report, note, inbox, job, jobs, cancel, agents];
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAuB,MAAM,aAAa,CAAC;AAapE,uGAAuG;AACvG,MAAM,MAAM,GAAoB;IAC9B,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;IACrB,aAA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AE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CACjE,CAAC;YACF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YAC7E,KAAK,CAAC,IAAI,CACR,EAAE,EACF,SAAS,CAAC,MAAM,GAAG,CAAC;gBAClB,CAAC,CAAC,oDAAoD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,kDAAkD,WAAW,mBAAmB;gBAC1J,CAAC,CAAC,qFAAqF,CAC1F,CAAC;YACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC;KACL,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAW,CAAC;AAC3F,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { z } from 'zod';
|
|
|
3
3
|
export declare const BRIDGE_JOB_KEY = "cogitator:bridge";
|
|
4
4
|
/** The sender of letters the bridge writes itself: reminders, and news of a job that ended. */
|
|
5
5
|
export declare const BRIDGE_SENDER = "bridge";
|
|
6
|
+
/**
|
|
7
|
+
* The person at the machine, as the sender of an answer they gave. No agent carries this name:
|
|
8
|
+
* a session cannot sign a letter with it
|
|
9
|
+
*/
|
|
10
|
+
export declare const PERSON = "person";
|
|
6
11
|
/** Harnesses the bridge knows by name. Any other string names a harness an adapter brings. */
|
|
7
12
|
export declare const HARNESSES: {
|
|
8
13
|
readonly claudeCode: "claude-code";
|
|
@@ -59,6 +64,12 @@ export interface AgentRecord {
|
|
|
59
64
|
registeredAt: string;
|
|
60
65
|
/** ISO 8601 time of the last call it made as an agent: a job, a letter, its inbox */
|
|
61
66
|
lastSeenAt: string;
|
|
67
|
+
/**
|
|
68
|
+
* The permission mode the session said it runs in the last time it told: `default`,
|
|
69
|
+
* `acceptEdits`, `plan` and so on, in the words of its harness. Absent for a harness that does
|
|
70
|
+
* not tell
|
|
71
|
+
*/
|
|
72
|
+
permissionMode?: string;
|
|
62
73
|
}
|
|
63
74
|
/** Who calls the bridge, as read from the caller's environment. */
|
|
64
75
|
export interface CallerIdentity {
|
|
@@ -72,6 +83,8 @@ export interface CallerIdentity {
|
|
|
72
83
|
sessionName?: string;
|
|
73
84
|
/** The name the bridge gave a session it started, handed to that session in its environment */
|
|
74
85
|
agentName?: string;
|
|
86
|
+
/** The permission mode the session runs in right now, when its harness tells */
|
|
87
|
+
permissionMode?: string;
|
|
75
88
|
}
|
|
76
89
|
/**
|
|
77
90
|
* The name of a harness: letters, digits, `.`, `_` and `-`, compared without regard to case and
|
|
@@ -85,6 +98,7 @@ export declare const CallerIdentitySchema: z.ZodObject<{
|
|
|
85
98
|
project: z.ZodOptional<z.ZodString>;
|
|
86
99
|
sessionName: z.ZodOptional<z.ZodString>;
|
|
87
100
|
agentName: z.ZodOptional<z.ZodString>;
|
|
101
|
+
permissionMode: z.ZodOptional<z.ZodString>;
|
|
88
102
|
}, z.core.$strict>;
|
|
89
103
|
/**
|
|
90
104
|
* The lifecycle of a job, the states of the A2A task under it: `submitted` (handed over, not
|
|
@@ -151,6 +165,11 @@ export interface BridgeJobRecord {
|
|
|
151
165
|
createdAt: string;
|
|
152
166
|
/** ISO 8601 time the job fails at when it is still running */
|
|
153
167
|
deadlineAt: string;
|
|
168
|
+
/**
|
|
169
|
+
* ISO 8601 time since which the job waits for the person, or a job handed over from inside
|
|
170
|
+
* it does. While it is set the deadline does not fail the job
|
|
171
|
+
*/
|
|
172
|
+
personWaitSince?: string;
|
|
154
173
|
/** Why the job failed or was canceled */
|
|
155
174
|
reason?: string;
|
|
156
175
|
verification?: JobVerification;
|
|
@@ -162,6 +181,52 @@ export interface BridgeJob extends BridgeJobRecord {
|
|
|
162
181
|
/** ISO 8601 time of its last change of state */
|
|
163
182
|
updatedAt: string;
|
|
164
183
|
}
|
|
184
|
+
/** What a call needs leave for, in the terms permission rules are written in. */
|
|
185
|
+
export type PermissionAccess = 'command' | 'read' | 'edit' | 'fetch' | 'other';
|
|
186
|
+
export declare const PERMISSION_ACCESSES: readonly PermissionAccess[];
|
|
187
|
+
/**
|
|
188
|
+
* A call an agent asks leave for, in a form the rules of any harness can judge. What a reader
|
|
189
|
+
* sees is the body of the letter that carries it
|
|
190
|
+
*/
|
|
191
|
+
export interface PermissionAsk {
|
|
192
|
+
/** The tool as the agent's harness names it: `Bash`, `Edit`, `mcp__github__create_issue` */
|
|
193
|
+
tool: string;
|
|
194
|
+
access: PermissionAccess;
|
|
195
|
+
/** Of a `command`: the command line */
|
|
196
|
+
command?: string;
|
|
197
|
+
/** Of a `command`: the folder it runs in */
|
|
198
|
+
cwd?: string;
|
|
199
|
+
/** Of a `command`: the environment variables it sets for itself */
|
|
200
|
+
env?: Record<string, string>;
|
|
201
|
+
/** Of a `read` or an `edit`: the files, absolute */
|
|
202
|
+
paths?: string[];
|
|
203
|
+
/** Of a `fetch`: the address */
|
|
204
|
+
url?: string;
|
|
205
|
+
}
|
|
206
|
+
export declare const PermissionAskSchema: z.ZodObject<{
|
|
207
|
+
tool: z.ZodString;
|
|
208
|
+
access: z.ZodEnum<{
|
|
209
|
+
command: "command";
|
|
210
|
+
read: "read";
|
|
211
|
+
edit: "edit";
|
|
212
|
+
fetch: "fetch";
|
|
213
|
+
other: "other";
|
|
214
|
+
}>;
|
|
215
|
+
command: z.ZodOptional<z.ZodString>;
|
|
216
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
217
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
218
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
219
|
+
url: z.ZodOptional<z.ZodString>;
|
|
220
|
+
}, z.core.$strict>;
|
|
221
|
+
/** The answer to a permission request. */
|
|
222
|
+
export type Verdict = 'allow' | 'deny';
|
|
223
|
+
export declare const VERDICTS: readonly Verdict[];
|
|
224
|
+
/**
|
|
225
|
+
* What the rules of the agent that handed a job over say of a call the one carrying it out asks
|
|
226
|
+
* leave for: `allow`, it may do this itself, so the answer is its own to give, `deny`, its rules
|
|
227
|
+
* forbid it, `ask`, it would have to ask the person, so only the person can allow it
|
|
228
|
+
*/
|
|
229
|
+
export type Rights = 'allow' | 'ask' | 'deny';
|
|
165
230
|
/**
|
|
166
231
|
* `task`: the job itself, `question` and `permission`: need an `answer`, `report`: the result
|
|
167
232
|
* that ends the job, `note`: something to know that needs no answer
|
|
@@ -191,6 +256,14 @@ export interface Letter {
|
|
|
191
256
|
inReplyTo?: string;
|
|
192
257
|
/** Of a `report`: how it ends the job */
|
|
193
258
|
outcome?: ReportOutcome;
|
|
259
|
+
/** Of a `permission`: the call leave is asked for, when the request names one */
|
|
260
|
+
ask?: PermissionAsk;
|
|
261
|
+
/** Of an `answer` to a `permission` that names its call: whether it may go ahead */
|
|
262
|
+
verdict?: Verdict;
|
|
263
|
+
/** The answer is the person's to give, not the recipient's */
|
|
264
|
+
needsPerson?: boolean;
|
|
265
|
+
/** ISO 8601 time the letter began to wait for the person */
|
|
266
|
+
personAskedAt?: string;
|
|
194
267
|
state: DeliveryState;
|
|
195
268
|
/** ISO 8601 */
|
|
196
269
|
createdAt: string;
|
|
@@ -212,7 +285,7 @@ export interface Letter {
|
|
|
212
285
|
export interface RenderedLetter extends Letter {
|
|
213
286
|
text: string;
|
|
214
287
|
}
|
|
215
|
-
export type JournalEntryType = 'agent.registered' | 'agent.gone' | 'job.created' | 'job.state' | 'job.verified' | 'letter.queued' | 'letter.delivered' | 'letter.read' | 'letter.handled' | 'letter.rejected' | 'letter.undelivered' | 'letter.reminded';
|
|
288
|
+
export type JournalEntryType = 'agent.registered' | 'agent.gone' | 'job.created' | 'job.state' | 'job.verified' | 'letter.queued' | 'letter.delivered' | 'letter.read' | 'letter.handled' | 'letter.rejected' | 'letter.undelivered' | 'letter.reminded' | 'letter.escalated';
|
|
216
289
|
/** One line of the bridge's append-only journal. */
|
|
217
290
|
export interface JournalEntry {
|
|
218
291
|
seq: number;
|
|
@@ -257,6 +330,12 @@ export interface BridgeLimits {
|
|
|
257
330
|
maxStartingSessions: number;
|
|
258
331
|
/** How often adapters that can list their sessions are asked which of them still run */
|
|
259
332
|
presenceCheckMs: number;
|
|
333
|
+
/**
|
|
334
|
+
* How long a letter waits for the person before they are reminded, and after that before the
|
|
335
|
+
* job fails, in ms. A person is slower than an agent, so it is longer than the job's own
|
|
336
|
+
* `replyTimeoutMs`
|
|
337
|
+
*/
|
|
338
|
+
personReplyTimeoutMs: number;
|
|
260
339
|
}
|
|
261
340
|
export declare const BridgeLimitsSchema: z.ZodObject<{
|
|
262
341
|
maxDepth: z.ZodNumber;
|
|
@@ -281,6 +360,7 @@ export declare const BridgeLimitsSchema: z.ZodObject<{
|
|
|
281
360
|
jobsPerHour: z.ZodNumber;
|
|
282
361
|
maxStartingSessions: z.ZodNumber;
|
|
283
362
|
presenceCheckMs: z.ZodNumber;
|
|
363
|
+
personReplyTimeoutMs: z.ZodNumber;
|
|
284
364
|
}, z.core.$strict>;
|
|
285
365
|
export declare const DEFAULT_LIMITS: BridgeLimits;
|
|
286
366
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAC1E,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,+FAA+F;AAC/F,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC,8FAA8F;AAC9F,eAAO,MAAM,SAAS;;;;;CAKZ,CAAC;AAEX,+DAA+D;AAC/D,MAAM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C;IAClB,iCAAiC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,yFAAyF;IACzF,gBAAgB,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sGAAsG;IACtG,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wFAAwF;IACxF,eAAe,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;kBAwB7B,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,YAgB5B,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -4,6 +4,11 @@ import { z } from 'zod';
|
|
|
4
4
|
export const BRIDGE_JOB_KEY = 'cogitator:bridge';
|
|
5
5
|
/** The sender of letters the bridge writes itself: reminders, and news of a job that ended. */
|
|
6
6
|
export const BRIDGE_SENDER = 'bridge';
|
|
7
|
+
/**
|
|
8
|
+
* The person at the machine, as the sender of an answer they gave. No agent carries this name:
|
|
9
|
+
* a session cannot sign a letter with it
|
|
10
|
+
*/
|
|
11
|
+
export const PERSON = 'person';
|
|
7
12
|
/** Harnesses the bridge knows by name. Any other string names a harness an adapter brings. */
|
|
8
13
|
export const HARNESSES = {
|
|
9
14
|
claudeCode: 'claude-code',
|
|
@@ -56,6 +61,7 @@ export const CallerIdentitySchema = z.strictObject({
|
|
|
56
61
|
project: AbsolutePathSchema.optional(),
|
|
57
62
|
sessionName: OneLineSchema.optional(),
|
|
58
63
|
agentName: OneLineSchema.optional(),
|
|
64
|
+
permissionMode: OneLineSchema.optional(),
|
|
59
65
|
});
|
|
60
66
|
export const JOB_STATES = [
|
|
61
67
|
'submitted',
|
|
@@ -84,6 +90,23 @@ export const JobBudgetSchema = z.object({
|
|
|
84
90
|
.positive()
|
|
85
91
|
.max(7 * 86_400_000),
|
|
86
92
|
});
|
|
93
|
+
export const PERMISSION_ACCESSES = [
|
|
94
|
+
'command',
|
|
95
|
+
'read',
|
|
96
|
+
'edit',
|
|
97
|
+
'fetch',
|
|
98
|
+
'other',
|
|
99
|
+
];
|
|
100
|
+
export const PermissionAskSchema = z.strictObject({
|
|
101
|
+
tool: OneLineSchema,
|
|
102
|
+
access: z.enum(['command', 'read', 'edit', 'fetch', 'other']),
|
|
103
|
+
command: z.string().min(1).max(100_000).optional(),
|
|
104
|
+
cwd: AbsolutePathSchema.optional(),
|
|
105
|
+
env: z.record(z.string().min(1).max(256), z.string().max(100_000)).optional(),
|
|
106
|
+
paths: z.array(AbsolutePathSchema).max(1000).optional(),
|
|
107
|
+
url: z.string().min(1).max(8192).optional(),
|
|
108
|
+
});
|
|
109
|
+
export const VERDICTS = ['allow', 'deny'];
|
|
87
110
|
export const LETTER_KINDS = [
|
|
88
111
|
'task',
|
|
89
112
|
'question',
|
|
@@ -112,6 +135,11 @@ export const BridgeLimitsSchema = z.strictObject({
|
|
|
112
135
|
jobsPerHour: z.number().int().positive().max(100_000),
|
|
113
136
|
maxStartingSessions: z.number().int().positive().max(100),
|
|
114
137
|
presenceCheckMs: z.number().int().positive().max(86_400_000),
|
|
138
|
+
personReplyTimeoutMs: z
|
|
139
|
+
.number()
|
|
140
|
+
.int()
|
|
141
|
+
.positive()
|
|
142
|
+
.max(7 * 86_400_000),
|
|
115
143
|
});
|
|
116
144
|
export const DEFAULT_LIMITS = {
|
|
117
145
|
maxDepth: 3,
|
|
@@ -128,5 +156,6 @@ export const DEFAULT_LIMITS = {
|
|
|
128
156
|
jobsPerHour: 60,
|
|
129
157
|
maxStartingSessions: 2,
|
|
130
158
|
presenceCheckMs: 60_000,
|
|
159
|
+
personReplyTimeoutMs: 4 * 3_600_000,
|
|
131
160
|
};
|
|
132
161
|
//# sourceMappingURL=types.js.map
|