genaicode 2.29.0 → 2.31.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 +2 -1
- package/dist/agents/artifacts.d.ts +70 -0
- package/dist/agents/artifacts.js +310 -0
- package/dist/agents/artifacts.js.map +1 -0
- package/dist/agents/cli-agent.js +2 -2
- package/dist/agents/cli-agent.js.map +1 -1
- package/dist/agents/drivers/mcp-isolation.js +5 -2
- package/dist/agents/drivers/mcp-isolation.js.map +1 -1
- package/dist/agents/failover.d.ts +17 -0
- package/dist/agents/failover.js +153 -0
- package/dist/agents/failover.js.map +1 -0
- package/dist/agents/handoff.d.ts +12 -0
- package/dist/agents/handoff.js +133 -0
- package/dist/agents/handoff.js.map +1 -0
- package/dist/agents/live-agent.js +2 -2
- package/dist/agents/live-agent.js.map +1 -1
- package/dist/agents/mcp-tools.d.ts +25 -0
- package/dist/agents/mcp-tools.js +64 -0
- package/dist/agents/mcp-tools.js.map +1 -0
- package/dist/agents/prepare.d.ts +12 -1
- package/dist/agents/prepare.js +15 -2
- package/dist/agents/prepare.js.map +1 -1
- package/dist/agents/runtime.d.ts +4 -2
- package/dist/agents/runtime.js +35 -10
- package/dist/agents/runtime.js.map +1 -1
- package/dist/agents/session.d.ts +68 -4
- package/dist/agents/session.js +196 -43
- package/dist/agents/session.js.map +1 -1
- package/dist/agents/types.d.ts +42 -0
- package/dist/agents/usage.d.ts +5 -0
- package/dist/agents/usage.js +26 -0
- package/dist/agents/usage.js.map +1 -0
- package/dist/agents.d.ts +4 -1
- package/dist/agents.js +2 -0
- package/dist/agents.js.map +1 -1
- package/dist/app-agent/app-agent.d.ts +21 -0
- package/dist/app-agent/app-agent.js +52 -0
- package/dist/app-agent/app-agent.js.map +1 -1
- package/dist/app-agent/http.d.ts +1 -0
- package/dist/app-agent/http.js +15 -0
- package/dist/app-agent/http.js.map +1 -1
- package/dist/app-agent/mcp.d.ts +2 -25
- package/dist/app-agent/mcp.js +1 -63
- package/dist/app-agent/mcp.js.map +1 -1
- package/dist/app-agent/state.d.ts +2 -0
- package/dist/app-agent/state.js.map +1 -1
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.js +15 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/main.d.ts +5 -1
- package/dist/cli/main.js +27 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/render.js +4 -0
- package/dist/cli/render.js.map +1 -1
- package/dist/react/agent-chat.css +59 -0
- package/dist/react/agent-chat.d.ts +9 -1
- package/dist/react/agent-chat.js +33 -5
- package/dist/react/agent-chat.js.map +1 -1
- package/dist/react/app-agent-chat.d.ts +6 -1
- package/dist/react/app-agent-chat.js +3 -2
- package/dist/react/app-agent-chat.js.map +1 -1
- package/dist/react/format.d.ts +1 -0
- package/dist/react/format.js +7 -0
- package/dist/react/format.js.map +1 -1
- package/dist/ui/index.js +99 -79
- package/dist/ui/web-client.js +71 -12
- package/dist/ui.d.ts +2 -0
- package/dist/ui.js.map +1 -1
- package/docs/agents.md +97 -2
- package/docs/app-agent.md +9 -0
- package/docs/cli.md +14 -2
- package/docs/react.md +13 -12
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<b>One API and one CLI for the coding agents you already have.</b><br>
|
|
11
|
-
Claude Code · Codex · Copilot CLI · Cursor · Gemini CLI · opencode · Muse · Mistral Vibe · Antigravity
|
|
11
|
+
Claude Code · Codex · Copilot CLI · Cursor · Gemini CLI · opencode · Muse · Mistral Vibe · Antigravity<br>
|
|
12
|
+
<a href="https://grzegorz.tanczyk.pl/genaicode/"><b>Homepage</b></a> · <a href="https://www.npmjs.com/package/genaicode">npm</a> · <a href="docs/CHANGELOG.md">Changelog</a>
|
|
12
13
|
</p>
|
|
13
14
|
|
|
14
15
|
<p align="center">
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type McpTool } from './mcp-tools.js';
|
|
2
|
+
import type { Artifact, McpServer } from './types.js';
|
|
3
|
+
/** The MCP tool agents call to publish an artifact. */
|
|
4
|
+
export declare const PUBLISH_ARTIFACT_TOOL = "publish_artifact";
|
|
5
|
+
export interface ArtifactStoreOptions {
|
|
6
|
+
/** Files are published from inside this directory only. A function is read on every publish. */
|
|
7
|
+
cwd: string | (() => string);
|
|
8
|
+
/** Largest artifact, in bytes. Default 5 MB. */
|
|
9
|
+
maxBytes?: number;
|
|
10
|
+
/** Most artifacts kept; the oldest is dropped beyond that. Default 30. */
|
|
11
|
+
maxArtifacts?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PublishArtifact {
|
|
14
|
+
title: string;
|
|
15
|
+
/** A file inside `cwd`. Its content is copied now; later edits need another publish. */
|
|
16
|
+
path?: string;
|
|
17
|
+
/** The content itself, instead of `path`. */
|
|
18
|
+
content?: string;
|
|
19
|
+
/** What `content` is. Default `text`. Ignored with `path`, where the extension decides. */
|
|
20
|
+
format?: 'html' | 'markdown' | 'text' | 'svg';
|
|
21
|
+
/** Publish under the same name again to replace the content. Default: `path`, else the title. */
|
|
22
|
+
name?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Artifacts an agent published, with a copy of their content, held in memory. */
|
|
25
|
+
export interface ArtifactStore {
|
|
26
|
+
/** Throws `ArtifactError` when the request is refused (outside cwd, secret file, too large...). */
|
|
27
|
+
publish(input: PublishArtifact): Promise<Artifact>;
|
|
28
|
+
list(): Artifact[];
|
|
29
|
+
/** The artifact and the content of its latest version. */
|
|
30
|
+
read(id: string): {
|
|
31
|
+
artifact: Artifact;
|
|
32
|
+
body: Buffer;
|
|
33
|
+
} | undefined;
|
|
34
|
+
/** Forget every artifact; their addresses stop working. */
|
|
35
|
+
clear(): void;
|
|
36
|
+
/** Called after every publish. Returns the unsubscribe function. */
|
|
37
|
+
subscribe(listener: (artifact: Artifact) => void): () => void;
|
|
38
|
+
/** The `publish_artifact` tool, to mount on an MCP server the agent is given. */
|
|
39
|
+
tool(): McpTool;
|
|
40
|
+
}
|
|
41
|
+
/** A publish request the store refused. The message is safe to show the agent. */
|
|
42
|
+
export declare class ArtifactError extends Error {
|
|
43
|
+
name: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function createArtifactStore(options: ArtifactStoreOptions): ArtifactStore;
|
|
46
|
+
/**
|
|
47
|
+
* The HTTP response for an artifact's content, for the host that serves it (`genaicode ui`
|
|
48
|
+
* does, at `/artifacts/<id>`). Serve it with these headers unchanged: they are what keeps
|
|
49
|
+
* agent-written HTML away from the page that shows it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function artifactResponse(artifact: Artifact, body: Buffer): {
|
|
52
|
+
headers: Record<string, string>;
|
|
53
|
+
body: Buffer;
|
|
54
|
+
};
|
|
55
|
+
export interface ArtifactChannelOptions extends ArtifactStoreOptions {
|
|
56
|
+
/** MCP server name the agent sees. Default `artifacts`. */
|
|
57
|
+
name?: string;
|
|
58
|
+
}
|
|
59
|
+
/** An artifact store and the MCP server that lets an agent publish to it. */
|
|
60
|
+
export interface ArtifactChannel {
|
|
61
|
+
store: ArtifactStore;
|
|
62
|
+
/** Give this to the agent (`createAgentSession({ artifacts })` does, for agents that take MCP servers). */
|
|
63
|
+
mcpServer: McpServer;
|
|
64
|
+
close(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Serve `publish_artifact` over MCP (streamable HTTP, JSON responses) on a random loopback
|
|
68
|
+
* port, behind a random bearer token. For hosts with no MCP server of their own.
|
|
69
|
+
*/
|
|
70
|
+
export declare function startArtifactChannel(options: ArtifactChannelOptions): Promise<ArtifactChannel>;
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
import { basename, extname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { handleMcpMessage } from './mcp-tools.js';
|
|
6
|
+
/** The MCP tool agents call to publish an artifact. */
|
|
7
|
+
export const PUBLISH_ARTIFACT_TOOL = 'publish_artifact';
|
|
8
|
+
/** A publish request the store refused. The message is safe to show the agent. */
|
|
9
|
+
export class ArtifactError extends Error {
|
|
10
|
+
name = 'ArtifactError';
|
|
11
|
+
}
|
|
12
|
+
const TEXT = 'text/plain; charset=utf-8';
|
|
13
|
+
// Extension → what the browser is told. Anything else downloads as a file.
|
|
14
|
+
const TYPES = {
|
|
15
|
+
'.html': { kind: 'html', mimeType: 'text/html; charset=utf-8' },
|
|
16
|
+
'.htm': { kind: 'html', mimeType: 'text/html; charset=utf-8' },
|
|
17
|
+
'.png': { kind: 'image', mimeType: 'image/png' },
|
|
18
|
+
'.jpg': { kind: 'image', mimeType: 'image/jpeg' },
|
|
19
|
+
'.jpeg': { kind: 'image', mimeType: 'image/jpeg' },
|
|
20
|
+
'.gif': { kind: 'image', mimeType: 'image/gif' },
|
|
21
|
+
'.webp': { kind: 'image', mimeType: 'image/webp' },
|
|
22
|
+
'.avif': { kind: 'image', mimeType: 'image/avif' },
|
|
23
|
+
'.svg': { kind: 'image', mimeType: 'image/svg+xml' },
|
|
24
|
+
'.md': { kind: 'text', mimeType: 'text/markdown; charset=utf-8' },
|
|
25
|
+
...Object.fromEntries(['.txt', '.log', '.json', '.csv', '.tsv', '.xml', '.yaml', '.yml', '.toml', '.diff', '.patch'].map((ext) => [
|
|
26
|
+
ext,
|
|
27
|
+
{ kind: 'text', mimeType: TEXT },
|
|
28
|
+
])),
|
|
29
|
+
};
|
|
30
|
+
const FORMATS = {
|
|
31
|
+
html: '.html',
|
|
32
|
+
markdown: '.md',
|
|
33
|
+
text: '.txt',
|
|
34
|
+
svg: '.svg',
|
|
35
|
+
};
|
|
36
|
+
// Folders and files that hold credentials. An agent with a shell can read them anyway; this
|
|
37
|
+
// keeps a confused or prompt-injected agent from putting them on screen through this tool.
|
|
38
|
+
const SECRET_DIRS = new Set(['.git', '.genaicode', '.ssh', '.aws', '.gnupg', '.kube', '.docker']);
|
|
39
|
+
const SECRET_FILE = /^(\.env(\..*)?|\.npmrc|\.netrc|\.pypirc|id_(rsa|dsa|ecdsa|ed25519).*|.*\.(pem|key|p12|pfx|keystore))$/i;
|
|
40
|
+
export function createArtifactStore(options) {
|
|
41
|
+
const maxBytes = options.maxBytes ?? 5 * 1024 * 1024;
|
|
42
|
+
const maxArtifacts = Math.max(1, options.maxArtifacts ?? 30);
|
|
43
|
+
// Insertion order is age: a republished artifact moves to the end.
|
|
44
|
+
const byName = new Map();
|
|
45
|
+
const listeners = new Set();
|
|
46
|
+
const fromFile = async (path) => {
|
|
47
|
+
let root;
|
|
48
|
+
let real;
|
|
49
|
+
try {
|
|
50
|
+
root = await fs.realpath(typeof options.cwd === 'function' ? options.cwd() : options.cwd);
|
|
51
|
+
// Through symlinks: a link inside the workspace must not reach a file outside it.
|
|
52
|
+
real = await fs.realpath(resolve(root, path));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw new ArtifactError(`No such file: ${path}`);
|
|
56
|
+
}
|
|
57
|
+
const inside = relative(root, real);
|
|
58
|
+
if (!inside || inside === '..' || inside.startsWith(`..${sep}`) || isAbsolute(inside)) {
|
|
59
|
+
throw new ArtifactError('Only files inside the working directory can be published.');
|
|
60
|
+
}
|
|
61
|
+
const parts = inside.split(sep);
|
|
62
|
+
if (parts.slice(0, -1).some((part) => SECRET_DIRS.has(part)) || SECRET_FILE.test(parts.at(-1))) {
|
|
63
|
+
throw new ArtifactError(`${inside} looks like a credential or internal file and cannot be published.`);
|
|
64
|
+
}
|
|
65
|
+
const file = await fs.open(real, 'r').catch(() => {
|
|
66
|
+
throw new ArtifactError(`Cannot read ${path}.`);
|
|
67
|
+
});
|
|
68
|
+
try {
|
|
69
|
+
const stat = await file.stat();
|
|
70
|
+
if (!stat.isFile())
|
|
71
|
+
throw new ArtifactError(`${path} is not a file.`);
|
|
72
|
+
if (stat.size > maxBytes)
|
|
73
|
+
throw new ArtifactError(tooLarge(stat.size, maxBytes));
|
|
74
|
+
const body = await file.readFile();
|
|
75
|
+
// The file may have grown since `stat`.
|
|
76
|
+
if (body.length > maxBytes)
|
|
77
|
+
throw new ArtifactError(tooLarge(body.length, maxBytes));
|
|
78
|
+
return { body, relative: parts.join('/') };
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
await file.close();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const store = {
|
|
85
|
+
async publish(input) {
|
|
86
|
+
const title = clean(input.title, 200);
|
|
87
|
+
if (!title)
|
|
88
|
+
throw new ArtifactError('title is required.');
|
|
89
|
+
const hasPath = typeof input.path === 'string' && input.path !== '';
|
|
90
|
+
const hasContent = typeof input.content === 'string';
|
|
91
|
+
if (hasPath === hasContent)
|
|
92
|
+
throw new ArtifactError('Give either path or content.');
|
|
93
|
+
let body;
|
|
94
|
+
let extension;
|
|
95
|
+
let path;
|
|
96
|
+
if (hasPath) {
|
|
97
|
+
const file = await fromFile(input.path);
|
|
98
|
+
body = file.body;
|
|
99
|
+
path = file.relative;
|
|
100
|
+
extension = extname(path).toLowerCase();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
body = Buffer.from(input.content, 'utf8');
|
|
104
|
+
if (body.length > maxBytes)
|
|
105
|
+
throw new ArtifactError(tooLarge(body.length, maxBytes));
|
|
106
|
+
const format = input.format ?? 'text';
|
|
107
|
+
if (!Object.hasOwn(FORMATS, format))
|
|
108
|
+
throw new ArtifactError('format must be html, markdown, text or svg.');
|
|
109
|
+
extension = FORMATS[format];
|
|
110
|
+
}
|
|
111
|
+
const type = TYPES[extension] ?? { kind: 'file', mimeType: 'application/octet-stream' };
|
|
112
|
+
const name = clean(input.name, 200) || path || title;
|
|
113
|
+
const before = byName.get(name);
|
|
114
|
+
const artifact = {
|
|
115
|
+
id: before?.artifact.id ?? randomBytes(16).toString('hex'),
|
|
116
|
+
name,
|
|
117
|
+
title,
|
|
118
|
+
kind: type.kind,
|
|
119
|
+
mimeType: type.mimeType,
|
|
120
|
+
bytes: body.length,
|
|
121
|
+
version: (before?.artifact.version ?? 0) + 1,
|
|
122
|
+
...(path ? { path } : {}),
|
|
123
|
+
};
|
|
124
|
+
byName.delete(name);
|
|
125
|
+
byName.set(name, { artifact, body });
|
|
126
|
+
while (byName.size > maxArtifacts)
|
|
127
|
+
byName.delete(byName.keys().next().value);
|
|
128
|
+
for (const listener of [...listeners]) {
|
|
129
|
+
try {
|
|
130
|
+
listener(artifact);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// A failing subscriber must not fail the publish.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return artifact;
|
|
137
|
+
},
|
|
138
|
+
list: () => [...byName.values()].map((entry) => entry.artifact),
|
|
139
|
+
read(id) {
|
|
140
|
+
for (const entry of byName.values())
|
|
141
|
+
if (entry.artifact.id === id)
|
|
142
|
+
return entry;
|
|
143
|
+
return undefined;
|
|
144
|
+
},
|
|
145
|
+
clear: () => byName.clear(),
|
|
146
|
+
subscribe(listener) {
|
|
147
|
+
listeners.add(listener);
|
|
148
|
+
return () => listeners.delete(listener);
|
|
149
|
+
},
|
|
150
|
+
tool: () => ({
|
|
151
|
+
name: PUBLISH_ARTIFACT_TOOL,
|
|
152
|
+
description: 'Show the user something to look at in the chat: a report, a chart, a diagram, a mockup, an image or a ' +
|
|
153
|
+
'document. Give `path` (a file in the working directory) or `content` with `format`. The user sees a card ' +
|
|
154
|
+
'and opens it in a preview. HTML runs in a sandbox with no network: make it one self-contained file with ' +
|
|
155
|
+
'inline CSS and JS and data: images; nothing loads from a CDN. The content is copied when you call this, ' +
|
|
156
|
+
'so call it again with the same `name` after you change it. Not for source files the user edits: just edit those.',
|
|
157
|
+
inputSchema: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {
|
|
160
|
+
title: { type: 'string', description: 'Short title shown on the card.' },
|
|
161
|
+
path: { type: 'string', description: 'File to publish, relative to the working directory.' },
|
|
162
|
+
content: { type: 'string', description: 'The content itself, instead of path.' },
|
|
163
|
+
format: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
enum: Object.keys(FORMATS),
|
|
166
|
+
description: 'What content is. Default text. With path the file extension decides.',
|
|
167
|
+
},
|
|
168
|
+
name: { type: 'string', description: 'Stable name; publish the same name again to replace it.' },
|
|
169
|
+
},
|
|
170
|
+
required: ['title'],
|
|
171
|
+
},
|
|
172
|
+
async call(args) {
|
|
173
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key] : undefined);
|
|
174
|
+
const artifact = await store.publish({
|
|
175
|
+
title: text('title') ?? '',
|
|
176
|
+
path: text('path'),
|
|
177
|
+
content: text('content'),
|
|
178
|
+
format: text('format'),
|
|
179
|
+
name: text('name'),
|
|
180
|
+
});
|
|
181
|
+
const again = artifact.version > 1 ? `, version ${artifact.version}` : '';
|
|
182
|
+
return `Published "${artifact.title}" (${artifact.kind}${again}). The user can open it from the chat.`;
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
};
|
|
186
|
+
return store;
|
|
187
|
+
}
|
|
188
|
+
function clean(value, max) {
|
|
189
|
+
// Control characters would break headers and terminal rows.
|
|
190
|
+
return typeof value === 'string'
|
|
191
|
+
? value
|
|
192
|
+
.replace(/\p{Cc}+/gu, ' ')
|
|
193
|
+
.trim()
|
|
194
|
+
.slice(0, max)
|
|
195
|
+
: '';
|
|
196
|
+
}
|
|
197
|
+
function tooLarge(bytes, max) {
|
|
198
|
+
return `Too large: ${bytes} bytes, the limit is ${max}.`;
|
|
199
|
+
}
|
|
200
|
+
// What an HTML artifact may do: run its own inline code and nothing else. No network (so it
|
|
201
|
+
// cannot send what it shows anywhere), no forms, and `sandbox` gives it an origin of its own
|
|
202
|
+
// even when the URL is opened directly, so it never reads the host page's cookies or storage.
|
|
203
|
+
const HTML_CSP = [
|
|
204
|
+
"default-src 'none'",
|
|
205
|
+
"script-src 'unsafe-inline'",
|
|
206
|
+
"style-src 'unsafe-inline'",
|
|
207
|
+
'img-src data: blob:',
|
|
208
|
+
'media-src data: blob:',
|
|
209
|
+
'font-src data:',
|
|
210
|
+
"form-action 'none'",
|
|
211
|
+
"base-uri 'none'",
|
|
212
|
+
"webrtc 'block'",
|
|
213
|
+
'sandbox allow-scripts',
|
|
214
|
+
].join('; ');
|
|
215
|
+
// Everything else is inert: an SVG opened directly must not run its scripts.
|
|
216
|
+
const INERT_CSP = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
|
|
217
|
+
/**
|
|
218
|
+
* The HTTP response for an artifact's content, for the host that serves it (`genaicode ui`
|
|
219
|
+
* does, at `/artifacts/<id>`). Serve it with these headers unchanged: they are what keeps
|
|
220
|
+
* agent-written HTML away from the page that shows it.
|
|
221
|
+
*/
|
|
222
|
+
export function artifactResponse(artifact, body) {
|
|
223
|
+
const fallback = FORMATS[artifact.kind === 'html' ? 'html' : 'text'];
|
|
224
|
+
const filename = basename(artifact.path ?? '') || `${artifact.title.replace(/[^\w.-]+/g, '-') || 'artifact'}${fallback}`;
|
|
225
|
+
return {
|
|
226
|
+
body,
|
|
227
|
+
headers: {
|
|
228
|
+
'content-type': artifact.mimeType,
|
|
229
|
+
'content-length': String(body.length),
|
|
230
|
+
'content-security-policy': artifact.kind === 'html' ? HTML_CSP : INERT_CSP,
|
|
231
|
+
'content-disposition': `${artifact.kind === 'file' ? 'attachment' : 'inline'}; filename="${filename.replace(/[^\w.-]/g, '_')}"`,
|
|
232
|
+
'x-content-type-options': 'nosniff',
|
|
233
|
+
'referrer-policy': 'no-referrer',
|
|
234
|
+
'cache-control': 'no-store',
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Serve `publish_artifact` over MCP (streamable HTTP, JSON responses) on a random loopback
|
|
240
|
+
* port, behind a random bearer token. For hosts with no MCP server of their own.
|
|
241
|
+
*/
|
|
242
|
+
export async function startArtifactChannel(options) {
|
|
243
|
+
const name = options.name ?? 'artifacts';
|
|
244
|
+
const store = createArtifactStore(options);
|
|
245
|
+
const tools = [store.tool()];
|
|
246
|
+
const expected = Buffer.from(`Bearer ${randomBytes(32).toString('hex')}`);
|
|
247
|
+
// JSON escaping can double the content; the store enforces the real limit.
|
|
248
|
+
const maxBody = (options.maxBytes ?? 5 * 1024 * 1024) * 2 + 64 * 1024;
|
|
249
|
+
let port = 0;
|
|
250
|
+
const server = createServer((request, response) => {
|
|
251
|
+
const reply = (status, body) => {
|
|
252
|
+
if (response.headersSent || response.destroyed)
|
|
253
|
+
return;
|
|
254
|
+
if (body === undefined)
|
|
255
|
+
response.writeHead(status).end();
|
|
256
|
+
else
|
|
257
|
+
response.writeHead(status, { 'content-type': 'application/json' }).end(JSON.stringify(body));
|
|
258
|
+
};
|
|
259
|
+
// A rebinding domain sends its own name as Host; a browser always sends Origin on POST.
|
|
260
|
+
if (![`127.0.0.1:${port}`, `localhost:${port}`].includes(request.headers.host ?? ''))
|
|
261
|
+
return reply(403);
|
|
262
|
+
if (request.headers.origin !== undefined)
|
|
263
|
+
return reply(403);
|
|
264
|
+
const given = Buffer.from(request.headers.authorization ?? '');
|
|
265
|
+
if (given.length !== expected.length || !timingSafeEqual(given, expected))
|
|
266
|
+
return reply(401);
|
|
267
|
+
if (request.method !== 'POST' || request.url?.split('?')[0] !== '/mcp')
|
|
268
|
+
return reply(405);
|
|
269
|
+
const chunks = [];
|
|
270
|
+
let size = 0;
|
|
271
|
+
request.on('data', (chunk) => {
|
|
272
|
+
size += chunk.length;
|
|
273
|
+
if (size > maxBody) {
|
|
274
|
+
reply(413);
|
|
275
|
+
request.destroy();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
chunks.push(chunk);
|
|
279
|
+
});
|
|
280
|
+
request.once('error', () => reply(400));
|
|
281
|
+
request.once('end', () => {
|
|
282
|
+
let message;
|
|
283
|
+
try {
|
|
284
|
+
message = JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
return reply(400, { jsonrpc: '2.0', id: null, error: { code: -32700, message: 'parse error' } });
|
|
288
|
+
}
|
|
289
|
+
handleMcpMessage(message, tools, { name: `genaicode-${name}`, version: '1' }).then((answer) => (answer === null ? reply(202) : reply(200, answer)), () => reply(500));
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
await new Promise((resolve, reject) => {
|
|
293
|
+
server.once('error', reject);
|
|
294
|
+
server.listen(0, '127.0.0.1', () => {
|
|
295
|
+
server.off('error', reject);
|
|
296
|
+
resolve();
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
port = server.address().port;
|
|
300
|
+
server.unref();
|
|
301
|
+
return {
|
|
302
|
+
store,
|
|
303
|
+
mcpServer: { name, url: `http://127.0.0.1:${port}/mcp`, headers: { Authorization: expected.toString() } },
|
|
304
|
+
close: () => new Promise((resolve) => {
|
|
305
|
+
server.close(() => resolve());
|
|
306
|
+
server.closeAllConnections();
|
|
307
|
+
}),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../src/agents/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AAEpF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAgB,MAAM,gBAAgB,CAAC;AAGhE,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAsCxD,kFAAkF;AAClF,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,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;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,GAAI,MAAM,CAAC,OAAO,EAAkB,CAAC,IAAI,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,CAAC;IAEf,OAAO;QACL,KAAK;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"}
|
package/dist/agents/cli-agent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { planSpawnAsync } from './prepare.js';
|
|
1
|
+
import { planError, planSpawnAsync } from './prepare.js';
|
|
2
2
|
import { startProcess } from './process.js';
|
|
3
3
|
import { invalidCwd, linkAbort, RunRecorder } from './runtime.js';
|
|
4
4
|
/**
|
|
@@ -81,7 +81,7 @@ function runCliAgent(definition, task) {
|
|
|
81
81
|
if (!plan.ok) {
|
|
82
82
|
lifetime.abort();
|
|
83
83
|
input?.fail();
|
|
84
|
-
return recorder.finish({ exitCode: null, signal: null, reason: 'spawn-error', error:
|
|
84
|
+
return recorder.finish({ exitCode: null, signal: null, reason: 'spawn-error', error: planError(plan) }, undefined);
|
|
85
85
|
}
|
|
86
86
|
// Stopped while `prepare` was still running.
|
|
87
87
|
if (stopped || task.signal?.aborted) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-agent.js","sourceRoot":"","sources":["../../src/agents/cli-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAyD,MAAM,cAAc,CA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,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACxF,MAAM,EAAE,CAAC;YACT,IAAI,MAAM,KAAK,MAAM,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK;gBAAE,OAAO;YAC/D,KAAK,GAAG,IAAI,CAAC;YACb,KAAK,EAAE,QAAQ,EAAE,CAAC;QACpB,CAAC;QACD,IAAI;QACJ,KAAK,CAAC,IAAY;YAChB,IAAI,KAAK;gBAAE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,0BAA0B,CAAC,CAAC,CAAC;YAC1F,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9B,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;YAChG,KAAK,EAAE,CAAC;YACR,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -8,8 +8,11 @@ export function configuredMcpServers(command, task, servers) {
|
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
// `task.env` replaces the environment, as it does for the run itself: what the caller left out stays out.
|
|
10
10
|
execFile(command, ['mcp', 'list', '--json'], { cwd: task.cwd, env: task.env ?? process.env, timeout: 30_000, maxBuffer: 8 * 1024 * 1024 }, (error, stdout) => {
|
|
11
|
-
if (error)
|
|
12
|
-
|
|
11
|
+
if (error) {
|
|
12
|
+
// The errno stays: a CLI that is not installed is `unavailable`, not a failed task.
|
|
13
|
+
const failed = new Error(`could not list ${command}'s MCP servers: ${error.message}`);
|
|
14
|
+
return reject(Object.assign(failed, typeof error.code === 'string' ? { code: error.code } : {}));
|
|
15
|
+
}
|
|
13
16
|
try {
|
|
14
17
|
const own = new Set((task.mcpServers ?? []).map((server) => server.name));
|
|
15
18
|
const nameOf = (server) => (typeof server === 'string' ? server : server.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-isolation.js","sourceRoot":"","sources":["../../../src/agents/drivers/mcp-isolation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,IAAe,EACf,OAAkC;IAElC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,0GAA0G;QAC1G,QAAQ,CACN,OAAO,EACP,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EACzB,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,EAC5F,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChB,IAAI,KAAK;
|
|
1
|
+
{"version":3,"file":"mcp-isolation.js","sourceRoot":"","sources":["../../../src/agents/drivers/mcp-isolation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,IAAe,EACf,OAAkC;IAElC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,0GAA0G;QAC1G,QAAQ,CACN,OAAO,EACP,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EACzB,EAAE,GAAG,EAAE,IAAI,CAAC,G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AAE,CAAC,CAAC,CAAC;YACrG,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AgentFailure, AgentResult, CodingAgent } from './types.js';
|
|
2
|
+
/** Whether `result` failed in a way a different agent could get past. */
|
|
3
|
+
export declare function shouldFailOver(result: AgentResult): boolean;
|
|
4
|
+
/** A line for people: `claude → codex (quota, resets 16:00)`. */
|
|
5
|
+
export declare function describeFailover(from: string, to: string, failure: AgentFailure): string;
|
|
6
|
+
/**
|
|
7
|
+
* One `CodingAgent` over several: runs `agents[0]`, and when a run fails with a quota, sign-in,
|
|
8
|
+
* missing CLI or crash (`shouldFailOver`), runs the same task on the next agent. Each agent is
|
|
9
|
+
* tried at most once per run. An agent that failed this way goes last in later runs (until it
|
|
10
|
+
* completes one), so a repair loop does not hit the same limit again. Other failures, a stop and a spent budget end
|
|
11
|
+
* the run as they are.
|
|
12
|
+
*
|
|
13
|
+
* Each agent gets `model` only if it is the first one and `resume` only if the session is its own
|
|
14
|
+
* (another vendor's ids mean nothing to it), `effort` only where it takes it, and `budget` minus what earlier agents used.
|
|
15
|
+
* The result adds up every agent's usage and cost. A `failover` event marks each switch. Capabilities are the first agent's.
|
|
16
|
+
*/
|
|
17
|
+
export declare function withFallback(agents: readonly CodingAgent[]): CodingAgent;
|