genaicode 2.33.0 → 2.35.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 +1 -0
- package/dist/agents/artifacts.d.ts +1 -1
- package/dist/agents/artifacts.js +4 -65
- package/dist/agents/artifacts.js.map +1 -1
- package/dist/agents/cli-agent.d.ts +3 -0
- package/dist/agents/cli-agent.js +1 -0
- package/dist/agents/cli-agent.js.map +1 -1
- package/dist/agents/drivers/anthropic-managed.d.ts +145 -0
- package/dist/agents/drivers/anthropic-managed.js +799 -0
- package/dist/agents/drivers/anthropic-managed.js.map +1 -0
- package/dist/agents/drivers/antigravity.js +2 -0
- package/dist/agents/drivers/antigravity.js.map +1 -1
- package/dist/agents/drivers/claude.js +2 -0
- package/dist/agents/drivers/claude.js.map +1 -1
- package/dist/agents/drivers/codex-live.js +2 -0
- package/dist/agents/drivers/codex-live.js.map +1 -1
- package/dist/agents/drivers/codex.js +2 -0
- package/dist/agents/drivers/codex.js.map +1 -1
- package/dist/agents/drivers/copilot.js +2 -0
- package/dist/agents/drivers/copilot.js.map +1 -1
- package/dist/agents/drivers/cursor-cloud.d.ts +78 -0
- package/dist/agents/drivers/cursor-cloud.js +523 -0
- package/dist/agents/drivers/cursor-cloud.js.map +1 -0
- package/dist/agents/drivers/cursor.js +2 -0
- package/dist/agents/drivers/cursor.js.map +1 -1
- package/dist/agents/drivers/gemini-managed.d.ts +78 -0
- package/dist/agents/drivers/gemini-managed.js +528 -0
- package/dist/agents/drivers/gemini-managed.js.map +1 -0
- package/dist/agents/drivers/gemini.js +2 -0
- package/dist/agents/drivers/gemini.js.map +1 -1
- package/dist/agents/drivers/managed-http.d.ts +28 -0
- package/dist/agents/drivers/managed-http.js +142 -0
- package/dist/agents/drivers/managed-http.js.map +1 -0
- package/dist/agents/drivers/muse-live.js +2 -0
- package/dist/agents/drivers/muse-live.js.map +1 -1
- package/dist/agents/drivers/muse.js +2 -0
- package/dist/agents/drivers/muse.js.map +1 -1
- package/dist/agents/drivers/openai-managed.d.ts +79 -0
- package/dist/agents/drivers/openai-managed.js +404 -0
- package/dist/agents/drivers/openai-managed.js.map +1 -0
- package/dist/agents/drivers/opencode.js +2 -0
- package/dist/agents/drivers/opencode.js.map +1 -1
- package/dist/agents/drivers/vibe.js +2 -0
- package/dist/agents/drivers/vibe.js.map +1 -1
- package/dist/agents/failover.d.ts +19 -1
- package/dist/agents/failover.js +63 -2
- package/dist/agents/failover.js.map +1 -1
- package/dist/agents/hosted.d.ts +5 -1
- package/dist/agents/hosted.js +47 -132
- package/dist/agents/hosted.js.map +1 -1
- package/dist/agents/live-agent.d.ts +3 -0
- package/dist/agents/live-agent.js +1 -0
- package/dist/agents/live-agent.js.map +1 -1
- package/dist/agents/managed.d.ts +157 -0
- package/dist/agents/managed.js +562 -0
- package/dist/agents/managed.js.map +1 -0
- package/dist/agents/mcp-server.d.ts +19 -0
- package/dist/agents/mcp-server.js +74 -0
- package/dist/agents/mcp-server.js.map +1 -0
- package/dist/agents/pack-git.d.ts +23 -0
- package/dist/agents/pack-git.js +112 -0
- package/dist/agents/pack-git.js.map +1 -0
- package/dist/agents/pack.d.ts +68 -0
- package/dist/agents/pack.js +611 -0
- package/dist/agents/pack.js.map +1 -0
- package/dist/agents/runtime.d.ts +5 -1
- package/dist/agents/runtime.js +9 -0
- package/dist/agents/runtime.js.map +1 -1
- package/dist/agents/session.d.ts +10 -0
- package/dist/agents/session.js +26 -0
- package/dist/agents/session.js.map +1 -1
- package/dist/agents/sessions/claude.d.ts +14 -0
- package/dist/agents/sessions/claude.js +233 -0
- package/dist/agents/sessions/claude.js.map +1 -0
- package/dist/agents/sessions/codex-api.d.ts +32 -0
- package/dist/agents/sessions/codex-api.js +233 -0
- package/dist/agents/sessions/codex-api.js.map +1 -0
- package/dist/agents/sessions/codex.d.ts +28 -0
- package/dist/agents/sessions/codex.js +430 -0
- package/dist/agents/sessions/codex.js.map +1 -0
- package/dist/agents/sessions/doctor.d.ts +67 -0
- package/dist/agents/sessions/doctor.js +182 -0
- package/dist/agents/sessions/doctor.js.map +1 -0
- package/dist/agents/sessions/files.d.ts +44 -0
- package/dist/agents/sessions/files.js +150 -0
- package/dist/agents/sessions/files.js.map +1 -0
- package/dist/agents/sessions/group.d.ts +24 -0
- package/dist/agents/sessions/group.js +27 -0
- package/dist/agents/sessions/group.js.map +1 -0
- package/dist/agents/sessions/hooks.d.ts +32 -0
- package/dist/agents/sessions/hooks.js +155 -0
- package/dist/agents/sessions/hooks.js.map +1 -0
- package/dist/agents/sessions/index.d.ts +42 -0
- package/dist/agents/sessions/index.js +97 -0
- package/dist/agents/sessions/index.js.map +1 -0
- package/dist/agents/sessions/live.d.ts +67 -0
- package/dist/agents/sessions/live.js +308 -0
- package/dist/agents/sessions/live.js.map +1 -0
- package/dist/agents/sessions/sqlite.d.ts +12 -0
- package/dist/agents/sessions/sqlite.js +61 -0
- package/dist/agents/sessions/sqlite.js.map +1 -0
- package/dist/agents/sessions/stores.d.ts +38 -0
- package/dist/agents/sessions/stores.js +616 -0
- package/dist/agents/sessions/stores.js.map +1 -0
- package/dist/agents/sessions/transcript.d.ts +20 -0
- package/dist/agents/sessions/transcript.js +134 -0
- package/dist/agents/sessions/transcript.js.map +1 -0
- package/dist/agents/sessions/types.d.ts +95 -0
- package/dist/agents/sessions/types.js +2 -0
- package/dist/agents/sessions/types.js.map +1 -0
- package/dist/agents/types.d.ts +31 -0
- package/dist/agents.d.ts +17 -1
- package/dist/agents.js +9 -1
- package/dist/agents.js.map +1 -1
- package/dist/backend/backend.d.ts +131 -0
- package/dist/backend/backend.js +773 -0
- package/dist/backend/backend.js.map +1 -0
- package/dist/backend/limiter.d.ts +34 -0
- package/dist/backend/limiter.js +76 -0
- package/dist/backend/limiter.js.map +1 -0
- package/dist/backend/node.d.ts +10 -0
- package/dist/backend/node.js +124 -0
- package/dist/backend/node.js.map +1 -0
- package/dist/backend/protocol.d.ts +98 -0
- package/dist/backend/protocol.js +2 -0
- package/dist/backend/protocol.js.map +1 -0
- package/dist/backend/seal.d.ts +7 -0
- package/dist/backend/seal.js +60 -0
- package/dist/backend/seal.js.map +1 -0
- package/dist/backend.d.ts +27 -0
- package/dist/backend.js +25 -0
- package/dist/backend.js.map +1 -0
- package/dist/browser/invoke.d.ts +17 -0
- package/dist/browser/invoke.js +69 -0
- package/dist/browser/invoke.js.map +1 -0
- package/dist/browser/nano.d.ts +10 -0
- package/dist/browser/nano.js +10 -56
- package/dist/browser/nano.js.map +1 -1
- package/dist/browser/page-agent.d.ts +7 -0
- package/dist/browser/page-agent.js +26 -5
- package/dist/browser/page-agent.js.map +1 -1
- package/dist/browser/remote.d.ts +44 -0
- package/dist/browser/remote.js +372 -0
- package/dist/browser/remote.js.map +1 -0
- package/dist/browser.d.ts +9 -2
- package/dist/browser.js +8 -2
- package/dist/browser.js.map +1 -1
- package/dist/cli/args.d.ts +26 -0
- package/dist/cli/args.js +66 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/hook.d.ts +7 -0
- package/dist/cli/hook.js +21 -0
- package/dist/cli/hook.js.map +1 -0
- package/dist/cli/main.d.ts +3 -1
- package/dist/cli/main.js +237 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli.js +31 -21
- package/dist/cli.js.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/google-converter.js +21 -8
- package/dist/providers/google-converter.js.map +1 -1
- package/dist/providers/google.js +7 -10
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/openai-converter.js +3 -2
- package/dist/providers/openai-converter.js.map +1 -1
- package/dist/providers/openai-responses-converter.d.ts +35 -0
- package/dist/providers/openai-responses-converter.js +188 -0
- package/dist/providers/openai-responses-converter.js.map +1 -0
- package/dist/providers/openai.d.ts +6 -1
- package/dist/providers/openai.js +16 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/providers.js.map +1 -1
- package/dist/react/page-agent-chat.js +6 -2
- package/dist/react/page-agent-chat.js.map +1 -1
- package/dist/ui/index.js +109 -82
- package/dist/ui/sessions.d.ts +19 -0
- package/dist/ui/sessions.js +59 -0
- package/dist/ui/sessions.js.map +1 -0
- package/dist/ui/web-client.js +15 -14
- package/docs/CHANGELOG.md +51 -388
- package/docs/agents.md +417 -2
- package/docs/backend.md +125 -0
- package/docs/browser.md +6 -1
- package/docs/changelog-2.26-and-older.md +441 -0
- package/docs/cli.md +39 -0
- package/docs/llm.md +6 -1
- package/docs/pivot.md +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import { handleMcpMessage } from './mcp-tools.js';
|
|
4
|
+
/**
|
|
5
|
+
* Serve `tools` over MCP (streamable HTTP, JSON responses) on a random loopback port, behind a
|
|
6
|
+
* random bearer token.
|
|
7
|
+
*/
|
|
8
|
+
export async function startLocalMcpServer(options) {
|
|
9
|
+
const { name, tools } = options;
|
|
10
|
+
const expected = Buffer.from(`Bearer ${randomBytes(32).toString('hex')}`);
|
|
11
|
+
const maxBody = options.maxBody ?? 1024 * 1024;
|
|
12
|
+
let port = 0;
|
|
13
|
+
const server = createServer((request, response) => {
|
|
14
|
+
const reply = (status, body) => {
|
|
15
|
+
if (response.headersSent || response.destroyed)
|
|
16
|
+
return;
|
|
17
|
+
if (body === undefined)
|
|
18
|
+
response.writeHead(status).end();
|
|
19
|
+
else
|
|
20
|
+
response.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify(body));
|
|
21
|
+
};
|
|
22
|
+
// A rebinding domain sends its own name as Host; a browser always sends Origin on POST.
|
|
23
|
+
if (![`127.0.0.1:${port}`, `localhost:${port}`].includes(request.headers.host ?? ''))
|
|
24
|
+
return reply(403);
|
|
25
|
+
if (request.headers.origin !== undefined)
|
|
26
|
+
return reply(403);
|
|
27
|
+
const given = Buffer.from(request.headers.authorization ?? '');
|
|
28
|
+
if (given.length !== expected.length || !timingSafeEqual(given, expected))
|
|
29
|
+
return reply(401);
|
|
30
|
+
if (request.method !== 'POST' || request.url?.split('?')[0] !== '/mcp')
|
|
31
|
+
return reply(405);
|
|
32
|
+
const chunks = [];
|
|
33
|
+
let size = 0;
|
|
34
|
+
request.on('data', (chunk) => {
|
|
35
|
+
size += chunk.length;
|
|
36
|
+
if (size > maxBody) {
|
|
37
|
+
reply(413);
|
|
38
|
+
request.destroy();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
chunks.push(chunk);
|
|
42
|
+
});
|
|
43
|
+
request.once('error', () => reply(400));
|
|
44
|
+
request.once('end', () => {
|
|
45
|
+
let message;
|
|
46
|
+
try {
|
|
47
|
+
message = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return reply(400, { jsonrpc: '2.0', id: null, error: { code: -32700, message: 'parse error' } });
|
|
51
|
+
}
|
|
52
|
+
handleMcpMessage(message, tools, { name: `genaicode-${name}`, version: '1' }).then((answer) => (answer === null ? reply(202) : reply(200, answer)), () => reply(500));
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
// A tool may hold its answer for minutes (waiting on other agents).
|
|
56
|
+
server.requestTimeout = 0;
|
|
57
|
+
await new Promise((resolve, reject) => {
|
|
58
|
+
server.once('error', reject);
|
|
59
|
+
server.listen(0, '127.0.0.1', () => {
|
|
60
|
+
server.off('error', reject);
|
|
61
|
+
resolve();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
port = server.address().port;
|
|
65
|
+
server.unref();
|
|
66
|
+
return {
|
|
67
|
+
mcpServer: { name, url: `http://127.0.0.1:${port}/mcp`, headers: { Authorization: expected.toString() } },
|
|
68
|
+
close: () => new Promise((resolve) => {
|
|
69
|
+
server.close(() => resolve());
|
|
70
|
+
server.closeAllConnections();
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/agents/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAEpF,OAAO,EAAE,gBAAgB,EAAgB,MAAM,gBAAgB,CAAC;AAiBhE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAA8B;IACtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,GAAG,IAAI,CAAC;IAC/C,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,OAAwB,EAAE,QAAwB,EAAE,EAAE;QACjF,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,IAAc,EAAE,EAAE;YAC/C,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,SAAS;gBAAE,OAAO;YACvD,IAAI,IAAI,KAAK,SAAS;gBAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;;gBACpD,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACpG,CAAC,CAAC;QACF,wFAA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AAI,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,OAAO;QACL,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,oBAAoB,IAAI,MAAM,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE;QACzG,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACtB,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9B,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC/B,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** The top of the git worktree `cwd` is in, or null outside a repository. */
|
|
2
|
+
export declare function repoRoot(cwd: string): Promise<string | null>;
|
|
3
|
+
/**
|
|
4
|
+
* A new detached worktree at `dir` holding `repo` as it is now, uncommitted and untracked files
|
|
5
|
+
* included. Returns the commit it starts from (reachable only from the worktree).
|
|
6
|
+
*/
|
|
7
|
+
export declare function addWorktree(repo: string, dir: string): Promise<string>;
|
|
8
|
+
export declare function removeWorktree(repo: string, dir: string): Promise<void>;
|
|
9
|
+
/** Files the worktree changed since `start`, as `git diff --name-status` lines. */
|
|
10
|
+
export declare function worktreeChanges(dir: string, start: string): Promise<string[]>;
|
|
11
|
+
/** The worktree's changes since `start` as a patch `git apply` takes. */
|
|
12
|
+
export declare function worktreeDiff(dir: string, start: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Apply `patch` to the files in `repo`. Plain apply is all or nothing; `threeWay` merges what it
|
|
15
|
+
* can and leaves conflict markers in the rest (git stages the files it merged).
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyPatch(repo: string, patch: string, threeWay?: boolean): Promise<{
|
|
18
|
+
ok: true;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
error: string;
|
|
22
|
+
conflicts: boolean;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
const MAX_OUTPUT = 64 * 1024 * 1024;
|
|
6
|
+
function git(cwd, args, options = {}) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const child = spawn('git', args, { cwd, env: options.env ?? process.env, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
9
|
+
const out = [];
|
|
10
|
+
const err = [];
|
|
11
|
+
let size = 0;
|
|
12
|
+
child.stdout.on('data', (chunk) => {
|
|
13
|
+
size += chunk.length;
|
|
14
|
+
if (size > MAX_OUTPUT)
|
|
15
|
+
child.kill();
|
|
16
|
+
else
|
|
17
|
+
out.push(chunk);
|
|
18
|
+
});
|
|
19
|
+
child.stderr.on('data', (chunk) => err.push(chunk));
|
|
20
|
+
child.once('error', (error) => resolve({ code: 1, stdout: '', stderr: error.message }));
|
|
21
|
+
child.once('close', (code) => resolve({
|
|
22
|
+
code: size > MAX_OUTPUT ? 1 : (code ?? 1),
|
|
23
|
+
stdout: Buffer.concat(out).toString('utf8'),
|
|
24
|
+
stderr: size > MAX_OUTPUT ? 'git output too large' : Buffer.concat(err).toString('utf8'),
|
|
25
|
+
}));
|
|
26
|
+
child.stdin.on('error', () => { });
|
|
27
|
+
child.stdin.end(options.input ?? '');
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function must(cwd, args, options) {
|
|
31
|
+
const result = await git(cwd, args, options);
|
|
32
|
+
if (result.code !== 0)
|
|
33
|
+
throw new Error(result.stderr.trim() || `git ${args[0]} failed`);
|
|
34
|
+
return result.stdout;
|
|
35
|
+
}
|
|
36
|
+
/** The top of the git worktree `cwd` is in, or null outside a repository. */
|
|
37
|
+
export async function repoRoot(cwd) {
|
|
38
|
+
const result = await git(cwd, ['rev-parse', '--show-toplevel']);
|
|
39
|
+
return result.code === 0 ? result.stdout.trim() : null;
|
|
40
|
+
}
|
|
41
|
+
/** Everything in `dir` (tracked, changed and untracked, minus ignored) as a git tree. Stages nothing. */
|
|
42
|
+
async function snapshotTree(dir) {
|
|
43
|
+
const scratch = mkdtempSync(path.join(tmpdir(), 'genaicode-pack-index-'));
|
|
44
|
+
const env = { ...process.env, GIT_INDEX_FILE: path.join(scratch, 'index') };
|
|
45
|
+
try {
|
|
46
|
+
const head = await git(dir, ['rev-parse', '--verify', '-q', 'HEAD']);
|
|
47
|
+
if (head.code === 0)
|
|
48
|
+
await must(dir, ['read-tree', head.stdout.trim()], { env });
|
|
49
|
+
await must(dir, ['add', '-A'], { env });
|
|
50
|
+
return (await must(dir, ['write-tree'], { env })).trim();
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const IDENTITY = {
|
|
57
|
+
GIT_AUTHOR_NAME: 'genaicode pack',
|
|
58
|
+
GIT_AUTHOR_EMAIL: 'pack@genaicode.invalid',
|
|
59
|
+
GIT_COMMITTER_NAME: 'genaicode pack',
|
|
60
|
+
GIT_COMMITTER_EMAIL: 'pack@genaicode.invalid',
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A new detached worktree at `dir` holding `repo` as it is now, uncommitted and untracked files
|
|
64
|
+
* included. Returns the commit it starts from (reachable only from the worktree).
|
|
65
|
+
*/
|
|
66
|
+
export async function addWorktree(repo, dir) {
|
|
67
|
+
const tree = await snapshotTree(repo);
|
|
68
|
+
const head = await git(repo, ['rev-parse', '--verify', '-q', 'HEAD']);
|
|
69
|
+
const parent = head.code === 0 ? ['-p', head.stdout.trim()] : [];
|
|
70
|
+
const commit = (await must(repo, ['commit-tree', tree, ...parent, '-m', 'genaicode pack: start of a delegated task'], {
|
|
71
|
+
env: { ...process.env, ...IDENTITY },
|
|
72
|
+
})).trim();
|
|
73
|
+
const parentDir = path.dirname(dir);
|
|
74
|
+
mkdirSync(parentDir, { recursive: true });
|
|
75
|
+
// Keep the worktrees out of the repository they sit in.
|
|
76
|
+
const ignore = path.join(parentDir, '.gitignore');
|
|
77
|
+
if (!existsSync(ignore))
|
|
78
|
+
writeFileSync(ignore, '*\n');
|
|
79
|
+
await must(repo, ['worktree', 'add', '--detach', dir, commit]);
|
|
80
|
+
return commit;
|
|
81
|
+
}
|
|
82
|
+
export async function removeWorktree(repo, dir) {
|
|
83
|
+
await git(repo, ['worktree', 'remove', '--force', dir]);
|
|
84
|
+
rmSync(dir, { recursive: true, force: true });
|
|
85
|
+
await git(repo, ['worktree', 'prune']);
|
|
86
|
+
}
|
|
87
|
+
/** Files the worktree changed since `start`, as `git diff --name-status` lines. */
|
|
88
|
+
export async function worktreeChanges(dir, start) {
|
|
89
|
+
const tree = await snapshotTree(dir);
|
|
90
|
+
return (await must(dir, ['diff', '--name-status', '--no-renames', start, tree])).split('\n').filter(Boolean);
|
|
91
|
+
}
|
|
92
|
+
/** The worktree's changes since `start` as a patch `git apply` takes. */
|
|
93
|
+
export async function worktreeDiff(dir, start) {
|
|
94
|
+
const tree = await snapshotTree(dir);
|
|
95
|
+
return must(dir, ['diff', '--binary', '--no-renames', start, tree]);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Apply `patch` to the files in `repo`. Plain apply is all or nothing; `threeWay` merges what it
|
|
99
|
+
* can and leaves conflict markers in the rest (git stages the files it merged).
|
|
100
|
+
*/
|
|
101
|
+
export async function applyPatch(repo, patch, threeWay = false) {
|
|
102
|
+
const base = ['apply', '--whitespace=nowarn'];
|
|
103
|
+
if (!threeWay) {
|
|
104
|
+
const result = await git(repo, [...base, '-'], { input: patch });
|
|
105
|
+
return result.code === 0 ? { ok: true } : { ok: false, error: result.stderr.trim(), conflicts: false };
|
|
106
|
+
}
|
|
107
|
+
const result = await git(repo, [...base, '--3way', '-'], { input: patch });
|
|
108
|
+
if (result.code === 0)
|
|
109
|
+
return { ok: true };
|
|
110
|
+
return { ok: false, error: result.stderr.trim(), conflicts: /with conflicts/.test(result.stderr) };
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=pack-git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-git.js","sourceRoot":"","sources":["../../src/agents/pack-git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpC,SAAS,GAAG,CACV,GAAW,EACX,IAAc,EACd,UAAuD,EAAE;IAEzD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAC5G,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YACxC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC;YACrB,IAAI,IAAI,GAAG,UAAU;gBAAE,KAAK,CAAC,IAAI,EAAE,CAAC;;gBAC/B,GAAG,CAAC,IAAI,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CAAC,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,KAAa,EACb,QAAQ,GAAG,KAAK;IAEhB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACjE,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACzG,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IAC3C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AgentFailure, AgentResult, CodingAgent, RateLimit } from './types.js';
|
|
2
|
+
export interface PackOptions {
|
|
3
|
+
/** The agent that takes the prompt and hands work out. Needs `capabilities.mcp`. */
|
|
4
|
+
lead: CodingAgent;
|
|
5
|
+
/** Agents the lead may delegate to. The lead may be one of them. */
|
|
6
|
+
members: readonly CodingAgent[];
|
|
7
|
+
/** Name of the combined agent. Default `pack`. */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Most delegated tasks running at once. Default 4. */
|
|
10
|
+
maxParallel?: number;
|
|
11
|
+
/** Replaces the briefing put in front of the lead's first prompt. */
|
|
12
|
+
brief?(members: readonly PackMember[]): string;
|
|
13
|
+
/** Where worktrees go, relative to the repository root. Default `.genaicode/worktrees`. */
|
|
14
|
+
worktreeDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Called with a new worktree before its agent starts, e.g. to link `node_modules`: a worktree
|
|
17
|
+
* holds the repository's files without anything git ignores.
|
|
18
|
+
*/
|
|
19
|
+
prepareWorktree?(dir: string, repo: string): void | Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** What the lead learns about a member from the `agents` tool. */
|
|
22
|
+
export interface PackMember {
|
|
23
|
+
name: string;
|
|
24
|
+
installed: boolean;
|
|
25
|
+
/** Delegated tasks it is running now. */
|
|
26
|
+
running: number;
|
|
27
|
+
steer: boolean;
|
|
28
|
+
/** The latest plan limits it reported, by window. */
|
|
29
|
+
limits?: RateLimit[];
|
|
30
|
+
/** How its last delegated task failed, when the agent itself was at fault. */
|
|
31
|
+
lastFailure?: AgentFailure;
|
|
32
|
+
}
|
|
33
|
+
export type PackTaskStatus = 'running' | AgentResult['status'];
|
|
34
|
+
/** A delegated task, as the `wait` tool and `tasks()` report it. */
|
|
35
|
+
export interface PackTask {
|
|
36
|
+
id: string;
|
|
37
|
+
agent: string;
|
|
38
|
+
prompt: string;
|
|
39
|
+
mode: 'worktree' | 'shared';
|
|
40
|
+
status: PackTaskStatus;
|
|
41
|
+
/** Where the agent works: its worktree, or the lead's directory. */
|
|
42
|
+
cwd: string;
|
|
43
|
+
/** The agent's final message, or the last thing it did while running. */
|
|
44
|
+
text?: string;
|
|
45
|
+
error?: string;
|
|
46
|
+
failure?: AgentFailure;
|
|
47
|
+
/** `git diff --name-status` lines of a worktree task, once it ended. */
|
|
48
|
+
changes?: string[];
|
|
49
|
+
/** What became of a worktree task's changes. */
|
|
50
|
+
state?: 'unmerged' | 'merged' | 'discarded';
|
|
51
|
+
}
|
|
52
|
+
export interface Pack extends CodingAgent {
|
|
53
|
+
/** Every task delegated so far, over all runs. */
|
|
54
|
+
tasks(): PackTask[];
|
|
55
|
+
/** Stop running tasks and remove the worktrees still on disk (unmerged changes are lost). */
|
|
56
|
+
close(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One `CodingAgent` over the agents on a machine: `lead` gets the prompt plus MCP tools to
|
|
60
|
+
* delegate parts of it to `members` (in parallel, each in its own git worktree), follow them, and
|
|
61
|
+
* merge what they did. Routing is the lead's judgement; genaicode adds the tools, not a loop.
|
|
62
|
+
*
|
|
63
|
+
* Events are the lead's, plus `subtask-start`, `subtask` and `subtask-update` for delegated work.
|
|
64
|
+
* `usage` events and the result's usage add up the lead and every delegated task, and
|
|
65
|
+
* `task.budget` caps that sum. Delegated tasks inherit `env`, `permissions` and `onApproval`
|
|
66
|
+
* (request ids are prefixed with the task id). `resume`, `steer()` and the session id are the lead's.
|
|
67
|
+
*/
|
|
68
|
+
export declare function pack(options: PackOptions): Pack;
|