@antondanv/brainyard 0.1.0 → 0.3.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/CHANGELOG.md +128 -0
- package/README.md +334 -105
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +23 -0
- package/dist/ask.js.map +1 -1
- package/dist/brains/adapter.d.ts +16 -2
- package/dist/brains/adapter.d.ts.map +1 -1
- package/dist/brains/adapter.js.map +1 -1
- package/dist/brains/index.d.ts.map +1 -1
- package/dist/brains/index.js +2 -1
- package/dist/brains/index.js.map +1 -1
- package/dist/brains/info.d.ts.map +1 -1
- package/dist/brains/info.js +22 -0
- package/dist/brains/info.js.map +1 -1
- package/dist/brains/opencode-bridge.d.ts +2 -0
- package/dist/brains/opencode-bridge.d.ts.map +1 -0
- package/dist/brains/opencode-bridge.js +332 -0
- package/dist/brains/opencode-bridge.js.map +1 -0
- package/dist/brains/opencode.d.ts +25 -0
- package/dist/brains/opencode.d.ts.map +1 -0
- package/dist/brains/opencode.js +491 -0
- package/dist/brains/opencode.js.map +1 -0
- package/dist/catalog.d.ts +8 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +100 -1
- package/dist/catalog.js.map +1 -1
- package/dist/codex-live.d.ts +12 -0
- package/dist/codex-live.d.ts.map +1 -0
- package/dist/codex-live.js +188 -0
- package/dist/codex-live.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +7 -5
- package/dist/flags.js.map +1 -1
- package/dist/humanize.d.ts.map +1 -1
- package/dist/humanize.js +19 -2
- package/dist/humanize.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/open.d.ts +109 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +338 -0
- package/dist/open.js.map +1 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +4 -2
- package/dist/options.js.map +1 -1
- package/dist/panes.d.ts +118 -0
- package/dist/panes.d.ts.map +1 -0
- package/dist/panes.js +480 -0
- package/dist/panes.js.map +1 -0
- package/dist/process.d.ts +36 -0
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +120 -2
- package/dist/process.js.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +13 -5
- package/dist/run.js.map +1 -1
- package/dist/sessions.d.ts +137 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/sessions.js +1023 -0
- package/dist/sessions.js.map +1 -0
- package/dist/status.d.ts +1 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +28 -7
- package/dist/status.js.map +1 -1
- package/dist/subscription-limits.d.ts +12 -0
- package/dist/subscription-limits.d.ts.map +1 -0
- package/dist/subscription-limits.js +281 -0
- package/dist/subscription-limits.js.map +1 -0
- package/dist/types.d.ts +25 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/usage-readers.d.ts +16 -0
- package/dist/usage-readers.d.ts.map +1 -0
- package/dist/usage-readers.js +194 -0
- package/dist/usage-readers.js.map +1 -0
- package/dist/usage.d.ts +71 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +403 -0
- package/dist/usage.js.map +1 -0
- package/package.json +7 -23
- package/README.ru.md +0 -334
- package/dist/cli/main.d.ts +0 -3
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -520
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/term.d.ts +0 -20
- package/dist/cli/term.d.ts.map +0 -1
- package/dist/cli/term.js +0 -87
- package/dist/cli/term.js.map +0 -1
- package/dist/ui/dashboard.html +0 -693
- package/dist/ui/page.d.ts +0 -9
- package/dist/ui/page.d.ts.map +0 -1
- package/dist/ui/page.js +0 -12
- package/dist/ui/page.js.map +0 -1
- package/dist/ui/server.d.ts +0 -20
- package/dist/ui/server.d.ts.map +0 -1
- package/dist/ui/server.js +0 -409
- package/dist/ui/server.js.map +0 -1
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode: `opencode run --format json`.
|
|
3
|
+
*
|
|
4
|
+
* The prompt goes to stdin (with no message argument, `run` reads it from
|
|
5
|
+
* there). `run` takes nothing more while the agent works, so a run that takes
|
|
6
|
+
* hints goes through OpenCode's server instead (`opencode-bridge.ts`), which
|
|
7
|
+
* prints the same stream. The stream is the session's parts as they finish — `step_start`,
|
|
8
|
+
* `text`, `reasoning`, `tool_use`, `step_finish` with tokens and cost — plus
|
|
9
|
+
* `error`. There is no final event: the process exits once the session is
|
|
10
|
+
* idle, and the reason the last step finished says how the turn ended.
|
|
11
|
+
*
|
|
12
|
+
* Permissions, MCP servers and the agent `ask()` answers with go in through
|
|
13
|
+
* the environment (`OPENCODE_PERMISSION`, `OPENCODE_CONFIG_CONTENT`): nothing
|
|
14
|
+
* is written into the project or the user's config.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
20
|
+
import { clip, describeTool, shortPath, tidyPaths } from '../humanize.js';
|
|
21
|
+
import { emptyUsage } from '../types.js';
|
|
22
|
+
import { num, obj, str, } from './adapter.js';
|
|
23
|
+
import { ANSWER_SYSTEM } from './claude.js';
|
|
24
|
+
/** The agent one-shot answers run as: its prompt replaces OpenCode's coding persona. */
|
|
25
|
+
export const ANSWER_AGENT = 'brainyard-answer';
|
|
26
|
+
const WEB_TOOLS = ['webfetch', 'websearch', 'codesearch'];
|
|
27
|
+
// A refused tool call: asked and rejected (`run` answers every question with
|
|
28
|
+
// no) or denied by a rule.
|
|
29
|
+
const DENIED = /rejected permission|rule which prevents you/i;
|
|
30
|
+
export const opencode = {
|
|
31
|
+
id: 'opencode',
|
|
32
|
+
// A message sent mid-turn joins the running turn, as with Claude Code.
|
|
33
|
+
messageIsTurn: false,
|
|
34
|
+
plan(launch) {
|
|
35
|
+
const warnings = [];
|
|
36
|
+
const args = ['run', '--format', 'json'];
|
|
37
|
+
// An empty title names the session after the prompt; without one OpenCode
|
|
38
|
+
// spends another model call on a generated title.
|
|
39
|
+
if (!launch.resume)
|
|
40
|
+
args.push('--title=');
|
|
41
|
+
if (launch.flags.has('--thinking'))
|
|
42
|
+
args.push('--thinking');
|
|
43
|
+
// A tool is switched off by taking it away (`deny`) — except where OpenCode
|
|
44
|
+
// Zen's free tier would refuse the request: it wants OpenCode's own tools
|
|
45
|
+
// ("can only be used from within OpenCode"). There the tool stays listed and
|
|
46
|
+
// every call of it is rejected (`ask`, which `run` answers with no). Not with
|
|
47
|
+
// `--auto`, which would approve it.
|
|
48
|
+
const model = launch.model ?? opencodeDefaultModel();
|
|
49
|
+
const zen = !model || model.startsWith('opencode/');
|
|
50
|
+
const off = zen && launch.access !== 'full' ? 'ask' : 'deny';
|
|
51
|
+
const permission = {};
|
|
52
|
+
if (launch.access === 'full') {
|
|
53
|
+
// `run` rejects whatever would need a question — a path outside the
|
|
54
|
+
// folder above all. `--auto` approves it; explicit denials still hold.
|
|
55
|
+
const old = launch.flags.has('--dangerously-skip-permissions') && !launch.flags.has('--auto');
|
|
56
|
+
args.push(old ? '--dangerously-skip-permissions' : '--auto');
|
|
57
|
+
}
|
|
58
|
+
else if (launch.access === 'workspace') {
|
|
59
|
+
permission.external_directory = 'deny';
|
|
60
|
+
if (launch.shell) {
|
|
61
|
+
// There is no sandbox: a command writes wherever it points (checked:
|
|
62
|
+
// `echo x > ~/file` went through). Workspace access keeps the shell
|
|
63
|
+
// only where a CLI can confine it.
|
|
64
|
+
permission.bash = off;
|
|
65
|
+
warnings.push('OpenCode cannot confine its shell to the folder, so workspace access turns the shell off; use full access to run commands');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
permission.edit = off;
|
|
70
|
+
permission.bash = off;
|
|
71
|
+
}
|
|
72
|
+
if (!launch.web)
|
|
73
|
+
for (const tool of WEB_TOOLS)
|
|
74
|
+
permission[tool] = off;
|
|
75
|
+
if (!launch.shell)
|
|
76
|
+
permission.bash = off;
|
|
77
|
+
const config = {
|
|
78
|
+
// Without it a refused tool ends the turn on the spot, without a word;
|
|
79
|
+
// with it the agent hears the refusal and answers.
|
|
80
|
+
experimental: { continue_loop_on_deny: true },
|
|
81
|
+
};
|
|
82
|
+
const servers = Object.entries(launch.mcpServers);
|
|
83
|
+
if (servers.length > 0) {
|
|
84
|
+
config.mcp = Object.fromEntries(servers.map(([name, server]) => [
|
|
85
|
+
name,
|
|
86
|
+
{
|
|
87
|
+
type: 'local',
|
|
88
|
+
command: [server.command, ...(server.args ?? [])],
|
|
89
|
+
...(server.env ? { environment: server.env } : {}),
|
|
90
|
+
},
|
|
91
|
+
]));
|
|
92
|
+
}
|
|
93
|
+
const env = {};
|
|
94
|
+
let prompt = launch.prompt;
|
|
95
|
+
if (launch.isolated) {
|
|
96
|
+
// An answer is not an agent run: its own instructions instead of the
|
|
97
|
+
// coding persona, and for `readonly` no tools at all. Tool definitions
|
|
98
|
+
// are most of the prompt: 8.7k tokens for "pong" with them, 0.2k without
|
|
99
|
+
// (6k on Zen, which wants them listed).
|
|
100
|
+
const agent = {
|
|
101
|
+
description: 'One-shot answers for Brainyard',
|
|
102
|
+
mode: 'primary',
|
|
103
|
+
prompt: launch.system?.trim() || ANSWER_SYSTEM,
|
|
104
|
+
};
|
|
105
|
+
if (launch.access === 'readonly') {
|
|
106
|
+
agent.permission = {
|
|
107
|
+
'*': off,
|
|
108
|
+
...(launch.web ? Object.fromEntries(WEB_TOOLS.map((tool) => [tool, 'allow'])) : {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
config.agent = { [ANSWER_AGENT]: agent };
|
|
112
|
+
args.push('--agent', ANSWER_AGENT);
|
|
113
|
+
// OpenCode reads Claude Code's CLAUDE.md and skills too; an answer has no use for them.
|
|
114
|
+
env.OPENCODE_DISABLE_CLAUDE_CODE = '1';
|
|
115
|
+
}
|
|
116
|
+
else if (launch.system?.trim()) {
|
|
117
|
+
prompt = `${launch.system.trim()}\n\n${launch.prompt}`;
|
|
118
|
+
}
|
|
119
|
+
// What the caller's environment already sets stays, under ours.
|
|
120
|
+
env.OPENCODE_CONFIG_CONTENT = JSON.stringify(merge(jsonObject(process.env.OPENCODE_CONFIG_CONTENT), config));
|
|
121
|
+
if (Object.keys(permission).length > 0) {
|
|
122
|
+
env.OPENCODE_PERMISSION = JSON.stringify({ ...jsonObject(process.env.OPENCODE_PERMISSION), ...permission });
|
|
123
|
+
}
|
|
124
|
+
// Hints need OpenCode's server: `run` exits before it answers a message
|
|
125
|
+
// sent mid-turn. Raw arguments belong to `run`, so they keep it.
|
|
126
|
+
if (launch.steerable && !launch.isolated && launch.extraArgs.length === 0) {
|
|
127
|
+
const settings = {
|
|
128
|
+
...(launch.model ? { model: launch.model } : {}),
|
|
129
|
+
...(launch.effort ? { variant: launch.effort } : {}),
|
|
130
|
+
...(launch.resume ? { resume: launch.resume } : {}),
|
|
131
|
+
auto: launch.access === 'full',
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
args: [],
|
|
135
|
+
prompt,
|
|
136
|
+
input: 'stream-json',
|
|
137
|
+
env: { ...env, BRAINYARD_OPENCODE_BRIDGE: JSON.stringify(settings) },
|
|
138
|
+
warnings,
|
|
139
|
+
through: [process.execPath, bridgePath()],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (launch.resume)
|
|
143
|
+
args.push('--session', launch.resume);
|
|
144
|
+
if (launch.model)
|
|
145
|
+
args.push('--model', launch.model);
|
|
146
|
+
if (launch.effort)
|
|
147
|
+
args.push('--variant', launch.effort);
|
|
148
|
+
args.push(...launch.extraArgs);
|
|
149
|
+
return { args, prompt, input: 'text', env, warnings };
|
|
150
|
+
},
|
|
151
|
+
message(text) {
|
|
152
|
+
// One line per message for the bridge; `run` reads the prompt as plain text.
|
|
153
|
+
return JSON.stringify({ type: 'user', text });
|
|
154
|
+
},
|
|
155
|
+
forget(sessionId) {
|
|
156
|
+
// `run` has no flag that keeps a session out of the store.
|
|
157
|
+
return ['session', 'delete', sessionId];
|
|
158
|
+
},
|
|
159
|
+
parser(cwd, model, mcpServers = []) {
|
|
160
|
+
return new OpencodeParser(cwd, model ?? opencodeDefaultModel(), mcpServers);
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* The environment that gives an interactive OpenCode (its TUI) standing
|
|
165
|
+
* instructions: the system prompt of the two agents a person works in — `build`,
|
|
166
|
+
* the default, and `plan` (Tab, or `--agent plan`) — through the same
|
|
167
|
+
* `OPENCODE_CONFIG_CONTENT` the one-shot answers use, so nothing is written to
|
|
168
|
+
* the project or the user's config. OpenCode has no flag or message field for
|
|
169
|
+
* it. The prompt replaces OpenCode's own base prompt for those agents; the
|
|
170
|
+
* tools, the environment block and AGENTS.md stay. `env` is what the CLI will
|
|
171
|
+
* inherit: a config it already sets stays, under ours.
|
|
172
|
+
*/
|
|
173
|
+
export function opencodeInstructionsEnv(system, env = process.env) {
|
|
174
|
+
const prompt = system.trim();
|
|
175
|
+
const config = merge(jsonObject(env.OPENCODE_CONFIG_CONTENT), {
|
|
176
|
+
agent: { build: { prompt }, plan: { prompt } },
|
|
177
|
+
});
|
|
178
|
+
return { OPENCODE_CONFIG_CONTENT: JSON.stringify(config) };
|
|
179
|
+
}
|
|
180
|
+
/** The bridge next to this module: compiled in the package, the TypeScript source when run from it. */
|
|
181
|
+
export function bridgePath() {
|
|
182
|
+
const compiled = fileURLToPath(new URL('./opencode-bridge.js', import.meta.url));
|
|
183
|
+
return existsSync(compiled) ? compiled : fileURLToPath(new URL('./opencode-bridge.ts', import.meta.url));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The model OpenCode runs when none is given: `model` from the inline config,
|
|
187
|
+
* else from the config files it loads (the later one wins).
|
|
188
|
+
*/
|
|
189
|
+
export function opencodeDefaultModel(env = process.env) {
|
|
190
|
+
const inline = jsonObject(env.OPENCODE_CONFIG_CONTENT).model;
|
|
191
|
+
if (typeof inline === 'string' && inline)
|
|
192
|
+
return inline;
|
|
193
|
+
const dir = join(env.XDG_CONFIG_HOME?.trim() || join(homedir(), '.config'), 'opencode');
|
|
194
|
+
const files = ['config.json', 'opencode.json', 'opencode.jsonc'].map((name) => join(dir, name));
|
|
195
|
+
if (env.OPENCODE_CONFIG?.trim())
|
|
196
|
+
files.push(env.OPENCODE_CONFIG.trim());
|
|
197
|
+
let model;
|
|
198
|
+
for (const file of files) {
|
|
199
|
+
let value;
|
|
200
|
+
try {
|
|
201
|
+
value = obj(parseJsonc(readFileSync(file, 'utf8'))).model;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (typeof value === 'string' && value)
|
|
207
|
+
model = value;
|
|
208
|
+
}
|
|
209
|
+
return model;
|
|
210
|
+
}
|
|
211
|
+
/** JSON with comments and trailing commas, the way OpenCode's config files are written. */
|
|
212
|
+
export function parseJsonc(text) {
|
|
213
|
+
return JSON.parse(withoutTrailingCommas(withoutComments(text)));
|
|
214
|
+
}
|
|
215
|
+
function withoutComments(text) {
|
|
216
|
+
let out = '';
|
|
217
|
+
for (let i = 0; i < text.length; i++) {
|
|
218
|
+
const char = text[i];
|
|
219
|
+
if (char === '"') {
|
|
220
|
+
const end = stringEnd(text, i);
|
|
221
|
+
out += text.slice(i, end);
|
|
222
|
+
i = end - 1;
|
|
223
|
+
}
|
|
224
|
+
else if (char === '/' && text[i + 1] === '/') {
|
|
225
|
+
while (i < text.length && text[i] !== '\n')
|
|
226
|
+
i++;
|
|
227
|
+
out += '\n';
|
|
228
|
+
}
|
|
229
|
+
else if (char === '/' && text[i + 1] === '*') {
|
|
230
|
+
const end = text.indexOf('*/', i + 2);
|
|
231
|
+
i = end < 0 ? text.length : end + 1;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
out += char;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
function withoutTrailingCommas(text) {
|
|
240
|
+
let out = '';
|
|
241
|
+
for (let i = 0; i < text.length; i++) {
|
|
242
|
+
const char = text[i];
|
|
243
|
+
if (char === '"') {
|
|
244
|
+
const end = stringEnd(text, i);
|
|
245
|
+
out += text.slice(i, end);
|
|
246
|
+
i = end - 1;
|
|
247
|
+
}
|
|
248
|
+
else if (char === ',' && /^\s*[}\]]/.test(text.slice(i + 1))) {
|
|
249
|
+
// A comma right before a closing bracket.
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
out += char;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
257
|
+
/** Index just past the string that starts with the quote at `start`. */
|
|
258
|
+
function stringEnd(text, start) {
|
|
259
|
+
for (let i = start + 1; i < text.length; i++) {
|
|
260
|
+
if (text[i] === '\\')
|
|
261
|
+
i++;
|
|
262
|
+
else if (text[i] === '"')
|
|
263
|
+
return i + 1;
|
|
264
|
+
}
|
|
265
|
+
return text.length;
|
|
266
|
+
}
|
|
267
|
+
function jsonObject(text) {
|
|
268
|
+
if (!text?.trim())
|
|
269
|
+
return {};
|
|
270
|
+
try {
|
|
271
|
+
return obj(JSON.parse(text));
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
return {};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function merge(base, extra) {
|
|
278
|
+
const out = { ...base };
|
|
279
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
280
|
+
const current = out[key];
|
|
281
|
+
out[key] =
|
|
282
|
+
value && typeof value === 'object' && !Array.isArray(value) && current && typeof current === 'object'
|
|
283
|
+
? merge(obj(current), obj(value))
|
|
284
|
+
: value;
|
|
285
|
+
}
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
class OpencodeParser {
|
|
289
|
+
#cwd;
|
|
290
|
+
#model;
|
|
291
|
+
/** `[name, prefix]`: OpenCode names an MCP tool `<server>_<tool>`. Longest first. */
|
|
292
|
+
#servers;
|
|
293
|
+
#sessionId;
|
|
294
|
+
#stepTexts = [];
|
|
295
|
+
#text = '';
|
|
296
|
+
#usage = emptyUsage();
|
|
297
|
+
#cost = 0;
|
|
298
|
+
#error;
|
|
299
|
+
#results = 0;
|
|
300
|
+
#denied = [];
|
|
301
|
+
constructor(cwd, model, servers) {
|
|
302
|
+
this.#cwd = cwd;
|
|
303
|
+
this.#model = model;
|
|
304
|
+
this.#servers = servers
|
|
305
|
+
.map((name) => [name, `${name.replace(/[^A-Za-z0-9_-]/g, '_')}_`])
|
|
306
|
+
.sort((a, b) => b[1].length - a[1].length);
|
|
307
|
+
}
|
|
308
|
+
get queuedTurns() {
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
push(event) {
|
|
312
|
+
const events = [];
|
|
313
|
+
const session = str(event.sessionID);
|
|
314
|
+
if (session && !this.#sessionId) {
|
|
315
|
+
this.#sessionId = session;
|
|
316
|
+
events.push({
|
|
317
|
+
kind: 'init',
|
|
318
|
+
// OpenCode does not name the model in its stream; this is the one asked for or configured.
|
|
319
|
+
summary: `OpenCode started${this.#model ? ` · ${this.#model}` : ''}`,
|
|
320
|
+
feed: true,
|
|
321
|
+
data: { model: this.#model, sessionId: session },
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const part = obj(event.part);
|
|
325
|
+
// Subagents work in sessions of their own: only the run's session speaks for it.
|
|
326
|
+
const own = !str(part.sessionID) || str(part.sessionID) === this.#sessionId;
|
|
327
|
+
switch (event.type) {
|
|
328
|
+
case 'step_start':
|
|
329
|
+
if (own)
|
|
330
|
+
this.#stepTexts = [];
|
|
331
|
+
break;
|
|
332
|
+
case 'text': {
|
|
333
|
+
const text = str(part.text);
|
|
334
|
+
if (!own || !text.trim())
|
|
335
|
+
break;
|
|
336
|
+
// Replies come per step ("let me check" before a tool call, the answer
|
|
337
|
+
// after it): the answer is the text of the last step that had any.
|
|
338
|
+
this.#stepTexts.push(text.trim());
|
|
339
|
+
this.#text = this.#stepTexts.join('\n\n');
|
|
340
|
+
events.push({ kind: 'message', summary: clip(tidyPaths(text, this.#cwd), 200), text, feed: true });
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
case 'reasoning': {
|
|
344
|
+
const text = str(part.text);
|
|
345
|
+
if (text.trim())
|
|
346
|
+
events.push({ kind: 'thinking', summary: clip(text, 200), text, feed: false });
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
case 'tool_use':
|
|
350
|
+
events.push(...this.#tool(part));
|
|
351
|
+
break;
|
|
352
|
+
case 'step_finish':
|
|
353
|
+
events.push(...this.#finish(part, own));
|
|
354
|
+
break;
|
|
355
|
+
case 'error':
|
|
356
|
+
events.push(this.#fail(obj(event.error)));
|
|
357
|
+
break;
|
|
358
|
+
default:
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
return events;
|
|
362
|
+
}
|
|
363
|
+
outcome() {
|
|
364
|
+
const out = {
|
|
365
|
+
text: this.#text,
|
|
366
|
+
usage: { ...this.#usage },
|
|
367
|
+
deniedTools: [...this.#denied],
|
|
368
|
+
limits: [],
|
|
369
|
+
results: this.#results,
|
|
370
|
+
};
|
|
371
|
+
if (this.#sessionId)
|
|
372
|
+
out.sessionId = this.#sessionId;
|
|
373
|
+
if (this.#model)
|
|
374
|
+
out.model = this.#model;
|
|
375
|
+
// OpenCode prices tokens from its model catalog. A provider without prices
|
|
376
|
+
// reports 0: an unknown price, not a free run.
|
|
377
|
+
if (this.#cost > 0)
|
|
378
|
+
out.costUsd = this.#cost;
|
|
379
|
+
if (this.#error)
|
|
380
|
+
out.error = this.#error;
|
|
381
|
+
return out;
|
|
382
|
+
}
|
|
383
|
+
/** A tool call arrives once, finished: the action, or what went wrong with it. */
|
|
384
|
+
#tool(part) {
|
|
385
|
+
const name = str(part.tool) || 'tool';
|
|
386
|
+
const state = obj(part.state);
|
|
387
|
+
const input = obj(state.input);
|
|
388
|
+
if (str(state.status) === 'error') {
|
|
389
|
+
const error = str(state.error) || 'failed';
|
|
390
|
+
if (DENIED.test(error)) {
|
|
391
|
+
if (!this.#denied.includes(name))
|
|
392
|
+
this.#denied.push(name);
|
|
393
|
+
return [
|
|
394
|
+
{
|
|
395
|
+
kind: 'denied',
|
|
396
|
+
summary: `the CLI refused ${name}`,
|
|
397
|
+
tool: name,
|
|
398
|
+
input,
|
|
399
|
+
feed: true,
|
|
400
|
+
data: { tool: name, reason: clip(error, 200) },
|
|
401
|
+
},
|
|
402
|
+
];
|
|
403
|
+
}
|
|
404
|
+
return [
|
|
405
|
+
{
|
|
406
|
+
kind: 'tool_result',
|
|
407
|
+
summary: `${name} failed: ${clip(tidyPaths(error, this.#cwd), 140)}`,
|
|
408
|
+
text: error,
|
|
409
|
+
tool: name,
|
|
410
|
+
input,
|
|
411
|
+
feed: true,
|
|
412
|
+
data: { isError: true },
|
|
413
|
+
},
|
|
414
|
+
];
|
|
415
|
+
}
|
|
416
|
+
const { kind, summary } = this.#describe(name, input);
|
|
417
|
+
const metadata = obj(state.metadata);
|
|
418
|
+
const output = str(metadata.output ?? state.output);
|
|
419
|
+
const exit = metadata.exit;
|
|
420
|
+
const failed = typeof exit === 'number' && exit !== 0;
|
|
421
|
+
return [
|
|
422
|
+
{ kind, summary, tool: name, input, feed: true },
|
|
423
|
+
{
|
|
424
|
+
kind: 'tool_result',
|
|
425
|
+
summary: failed
|
|
426
|
+
? `command failed (exit ${exit}): ${clip(tidyPaths(output, this.#cwd), 140)}`
|
|
427
|
+
: `${name} → ${clip(tidyPaths(output, this.#cwd), 140)}`,
|
|
428
|
+
text: output,
|
|
429
|
+
tool: name,
|
|
430
|
+
// A successful result is the file just read or "Wrote file
|
|
431
|
+
// successfully": the feed already said what happened.
|
|
432
|
+
feed: failed,
|
|
433
|
+
data: { isError: failed, ...(typeof exit === 'number' ? { exitCode: exit } : {}) },
|
|
434
|
+
},
|
|
435
|
+
];
|
|
436
|
+
}
|
|
437
|
+
#describe(name, input) {
|
|
438
|
+
for (const [server, prefix] of this.#servers) {
|
|
439
|
+
if (name.startsWith(prefix))
|
|
440
|
+
return { kind: 'tool_call', summary: `called ${server}: ${name.slice(prefix.length)}` };
|
|
441
|
+
}
|
|
442
|
+
if (name === 'apply_patch' || name === 'patch') {
|
|
443
|
+
const files = [...str(input.patchText).matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map((match) => shortPath(str(match[1]).trim(), this.#cwd));
|
|
444
|
+
return {
|
|
445
|
+
kind: 'file_write',
|
|
446
|
+
summary: files.length > 0 ? `edited ${clip(files.join(', '), 120)}` : 'applied a patch',
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
return describeTool(name, input, this.#cwd);
|
|
450
|
+
}
|
|
451
|
+
#finish(part, own) {
|
|
452
|
+
const tokens = obj(part.tokens);
|
|
453
|
+
const cache = obj(tokens.cache);
|
|
454
|
+
const reasoning = num(tokens.reasoning);
|
|
455
|
+
// Every step is a call of its own and reports only its own tokens. OpenCode
|
|
456
|
+
// counts reasoning apart from output; here it is a part of it.
|
|
457
|
+
this.#usage.inputTokens += num(tokens.input);
|
|
458
|
+
this.#usage.outputTokens += num(tokens.output) + reasoning;
|
|
459
|
+
this.#usage.reasoningTokens += reasoning;
|
|
460
|
+
this.#usage.cacheReadTokens += num(cache.read);
|
|
461
|
+
this.#usage.cacheWriteTokens += num(cache.write);
|
|
462
|
+
this.#cost += num(part.cost);
|
|
463
|
+
const reason = str(part.reason);
|
|
464
|
+
// `tool-calls` means another step follows; any other reason ends the turn.
|
|
465
|
+
if (!own || reason === 'tool-calls')
|
|
466
|
+
return [];
|
|
467
|
+
this.#results += 1;
|
|
468
|
+
if (reason === 'length') {
|
|
469
|
+
return [
|
|
470
|
+
{ kind: 'warning', summary: 'the answer stopped at the model’s output limit', feed: true, data: { reason } },
|
|
471
|
+
];
|
|
472
|
+
}
|
|
473
|
+
return [];
|
|
474
|
+
}
|
|
475
|
+
#fail(error) {
|
|
476
|
+
const data = obj(error.data);
|
|
477
|
+
const ref = str(data.ref);
|
|
478
|
+
// "Unexpected server error" says nothing by itself; OpenCode's log has the
|
|
479
|
+
// cause under this reference.
|
|
480
|
+
const message = `${str(data.message) || str(error.name) || 'error'}${ref ? ` (OpenCode log: ${ref})` : ''}`;
|
|
481
|
+
this.#error = message;
|
|
482
|
+
this.#results += 1;
|
|
483
|
+
return {
|
|
484
|
+
kind: 'error',
|
|
485
|
+
summary: clip(message, 200),
|
|
486
|
+
feed: true,
|
|
487
|
+
data: { name: str(error.name), ...(typeof data.statusCode === 'number' ? { status: data.statusCode } : {}) },
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
//# sourceMappingURL=opencode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode.js","sourceRoot":"","sources":["../../src/brains/opencode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAIL,GAAG,EAEH,GAAG,EAGH,GAAG,GACJ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,wFAAwF;AACxF,MAAM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,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACnB,OAAO;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC;YAC3B,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SAC7G,CAAC;IACJ,CAAC;CACF"}
|
package/dist/catalog.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface Catalog {
|
|
|
19
19
|
defaultEfforts: Effort[];
|
|
20
20
|
/** `cli`: asked from the CLI just now. `builtin`: the fallback list shipped with Brainyard. */
|
|
21
21
|
source: 'cli' | 'builtin';
|
|
22
|
+
/** The CLI runs no model outside this list (OpenCode), so a name missing from it is refused up front. */
|
|
23
|
+
complete?: boolean;
|
|
22
24
|
note?: string;
|
|
23
25
|
fetchedAt: string;
|
|
24
26
|
}
|
|
@@ -27,6 +29,8 @@ export declare const CLAUDE_EFFORTS: Effort[];
|
|
|
27
29
|
export declare function parseCodexModels(raw: string): ModelInfo[];
|
|
28
30
|
/** `agy models` → families with efforts, and models without. */
|
|
29
31
|
export declare function parseAgyModels(raw: string): ModelInfo[];
|
|
32
|
+
/** `opencode models [--verbose]` → models with the reasoning variants each offers. */
|
|
33
|
+
export declare function parseOpencodeModels(raw: string): ModelInfo[];
|
|
30
34
|
export interface CatalogOptions {
|
|
31
35
|
/** Ask the CLI again even if a fresh list is cached. */
|
|
32
36
|
refresh?: boolean;
|
|
@@ -39,6 +43,8 @@ export declare function models(brain: BrainId, options?: CatalogOptions): Promis
|
|
|
39
43
|
* runs it anyway), cached as if `models()` had asked.
|
|
40
44
|
*/
|
|
41
45
|
export declare function rememberAgyModels(command: Command, raw: string): Catalog | undefined;
|
|
46
|
+
/** The same for `opencode models --verbose` output. */
|
|
47
|
+
export declare function rememberOpencodeModels(command: Command, raw: string): Catalog | undefined;
|
|
42
48
|
/** Forget cached catalogs (tests, or after installing a CLI). */
|
|
43
49
|
export declare function clearCatalogCache(): void;
|
|
44
50
|
/** All efforts a CLI understands at all. */
|
|
@@ -57,7 +63,8 @@ export interface Pick {
|
|
|
57
63
|
* - A variant name (`gemini-3.8-flash-low`) becomes family + effort.
|
|
58
64
|
* - A model missing from the catalog is not refused: catalogs can be partial
|
|
59
65
|
* (hidden Codex models, full Claude names instead of aliases), and the CLI
|
|
60
|
-
* will refuse a wrong name itself — loudly, not by substitution.
|
|
66
|
+
* will refuse a wrong name itself — loudly, not by substitution. A complete
|
|
67
|
+
* catalog (OpenCode) is the exception.
|
|
61
68
|
*/
|
|
62
69
|
export declare function resolvePick(catalog: Catalog, wanted: {
|
|
63
70
|
model?: string;
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,KAAK,OAAO,EAA2B,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,cAAc,EAAE,OAAO,CAAC;IACxB,qEAAqE;IACrE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE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