@bunny-agent/daemon 0.9.31 → 0.9.32
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/dist/bundle.mjs +110 -6
- package/dist/index.js +110 -6
- package/dist/nextjs.js +110 -6
- package/dist/routes/coding.d.ts +5 -0
- package/dist/routes/coding.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/bundle.mjs
CHANGED
|
@@ -290115,8 +290115,103 @@ function buildSecretAwareTools(cwd, secrets) {
|
|
|
290115
290115
|
return tools;
|
|
290116
290116
|
}
|
|
290117
290117
|
|
|
290118
|
+
// ../../packages/runner-pi/dist/tool-refs.js
|
|
290119
|
+
var LOG_PREFIX2 = "[bunny-agent:pi-tool-ref]";
|
|
290120
|
+
function buildToolDefinitionsFromRefs(tools) {
|
|
290121
|
+
return tools.map((spec) => buildOne(spec));
|
|
290122
|
+
}
|
|
290123
|
+
function buildOne(spec) {
|
|
290124
|
+
const parameters = Type.Unsafe(spec.inputSchema);
|
|
290125
|
+
return {
|
|
290126
|
+
name: spec.name,
|
|
290127
|
+
label: spec.name,
|
|
290128
|
+
description: spec.description,
|
|
290129
|
+
parameters,
|
|
290130
|
+
async execute(_toolCallId, params, signal) {
|
|
290131
|
+
let response;
|
|
290132
|
+
try {
|
|
290133
|
+
response = await executeToolRef(spec, params, signal);
|
|
290134
|
+
} catch (error) {
|
|
290135
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
290136
|
+
return transportErrorResult(spec.name, message);
|
|
290137
|
+
}
|
|
290138
|
+
if (response.status < 200 || response.status >= 300) {
|
|
290139
|
+
return statusErrorResult(spec.name, response.status, response.body);
|
|
290140
|
+
}
|
|
290141
|
+
return okResult(response.body);
|
|
290142
|
+
}
|
|
290143
|
+
};
|
|
290144
|
+
}
|
|
290145
|
+
async function executeToolRef(spec, params, signal) {
|
|
290146
|
+
switch (spec.runtime.type) {
|
|
290147
|
+
case "http":
|
|
290148
|
+
return sendDirectHttpRequest(spec.runtime, params, signal);
|
|
290149
|
+
case "module":
|
|
290150
|
+
return executeModuleTool(spec.runtime, params, signal);
|
|
290151
|
+
}
|
|
290152
|
+
}
|
|
290153
|
+
async function sendDirectHttpRequest(runtime, params, signal) {
|
|
290154
|
+
const response = await fetch(runtime.url, {
|
|
290155
|
+
method: "POST",
|
|
290156
|
+
signal,
|
|
290157
|
+
headers: {
|
|
290158
|
+
"Content-Type": "application/json",
|
|
290159
|
+
...runtime.headers ?? {}
|
|
290160
|
+
},
|
|
290161
|
+
body: JSON.stringify(params)
|
|
290162
|
+
});
|
|
290163
|
+
const body = await response.text();
|
|
290164
|
+
return { status: response.status, body };
|
|
290165
|
+
}
|
|
290166
|
+
async function executeModuleTool(runtime, params, signal) {
|
|
290167
|
+
const mod = await import(runtime.module);
|
|
290168
|
+
const exportName = runtime.exportName ?? "execute";
|
|
290169
|
+
const fn = mod[exportName];
|
|
290170
|
+
if (typeof fn !== "function") {
|
|
290171
|
+
return {
|
|
290172
|
+
status: 500,
|
|
290173
|
+
body: `module tool export "${exportName}" is not a function`
|
|
290174
|
+
};
|
|
290175
|
+
}
|
|
290176
|
+
const result = await fn(params, { signal });
|
|
290177
|
+
return { status: 200, body: serializeResult(result) };
|
|
290178
|
+
}
|
|
290179
|
+
function okResult(text) {
|
|
290180
|
+
return {
|
|
290181
|
+
content: [{ type: "text", text }],
|
|
290182
|
+
details: void 0
|
|
290183
|
+
};
|
|
290184
|
+
}
|
|
290185
|
+
function statusErrorResult(toolName, status2, body) {
|
|
290186
|
+
return {
|
|
290187
|
+
content: [
|
|
290188
|
+
{
|
|
290189
|
+
type: "text",
|
|
290190
|
+
text: `${LOG_PREFIX2} tool "${toolName}" failed (status ${status2}): ${body}`
|
|
290191
|
+
}
|
|
290192
|
+
],
|
|
290193
|
+
details: void 0
|
|
290194
|
+
};
|
|
290195
|
+
}
|
|
290196
|
+
function transportErrorResult(toolName, message) {
|
|
290197
|
+
return {
|
|
290198
|
+
content: [
|
|
290199
|
+
{
|
|
290200
|
+
type: "text",
|
|
290201
|
+
text: `${LOG_PREFIX2} tool "${toolName}" transport error: ${message}`
|
|
290202
|
+
}
|
|
290203
|
+
],
|
|
290204
|
+
details: void 0
|
|
290205
|
+
};
|
|
290206
|
+
}
|
|
290207
|
+
function serializeResult(result) {
|
|
290208
|
+
if (typeof result === "string")
|
|
290209
|
+
return result;
|
|
290210
|
+
return JSON.stringify(result);
|
|
290211
|
+
}
|
|
290212
|
+
|
|
290118
290213
|
// ../../packages/runner-pi/dist/pi-runner.js
|
|
290119
|
-
var
|
|
290214
|
+
var LOG_PREFIX3 = "[bunny-agent:pi]";
|
|
290120
290215
|
function parseModelSpec(model) {
|
|
290121
290216
|
const trimmed = model.trim();
|
|
290122
290217
|
const separator = trimmed.indexOf(":");
|
|
@@ -290241,11 +290336,11 @@ function createPiRunner(options2 = {}) {
|
|
|
290241
290336
|
return SessionManager.open(resume);
|
|
290242
290337
|
}
|
|
290243
290338
|
const sessionPath2 = resolveSessionPathById(cwd, resume);
|
|
290244
|
-
console.error(`${
|
|
290339
|
+
console.error(`${LOG_PREFIX3} resume: id=${resume} path=${sessionPath2 ?? "(not found)"}`);
|
|
290245
290340
|
if (sessionPath2) {
|
|
290246
290341
|
if (isSessionFileTooLarge(sessionPath2)) {
|
|
290247
290342
|
const context = extractSessionContext(sessionPath2);
|
|
290248
|
-
console.error(`${
|
|
290343
|
+
console.error(`${LOG_PREFIX3} session file too large, starting fresh${context ? " (with context)" : ""}`);
|
|
290249
290344
|
const newMgr = SessionManager.create(cwd);
|
|
290250
290345
|
if (context) {
|
|
290251
290346
|
const firstId = newMgr.getEntries()[0]?.id ?? "";
|
|
@@ -290265,7 +290360,7 @@ function createPiRunner(options2 = {}) {
|
|
|
290265
290360
|
appendSystemPrompt: options2.systemPrompt
|
|
290266
290361
|
}) : void 0;
|
|
290267
290362
|
if (options2.skillPaths && options2.skillPaths.length > 0) {
|
|
290268
|
-
console.error(`${
|
|
290363
|
+
console.error(`${LOG_PREFIX3} runner: cwd=${cwd} skillPaths=${JSON.stringify(options2.skillPaths)}`);
|
|
290269
290364
|
}
|
|
290270
290365
|
if (resourceLoader) {
|
|
290271
290366
|
await resourceLoader.reload();
|
|
@@ -290275,6 +290370,12 @@ function createPiRunner(options2 = {}) {
|
|
|
290275
290370
|
const apiKey = await modelRegistry2.authStorage.getApiKey(provider) ?? "";
|
|
290276
290371
|
customTools.push(buildImageGenerateTool(cwd, imageModelName, model.baseUrl, apiKey), buildImageEditTool(cwd, imageModelName, model.baseUrl, apiKey));
|
|
290277
290372
|
}
|
|
290373
|
+
if (options2.customTools && options2.customTools.length > 0) {
|
|
290374
|
+
customTools.push(...options2.customTools);
|
|
290375
|
+
}
|
|
290376
|
+
if (options2.toolRefs && options2.toolRefs.length > 0) {
|
|
290377
|
+
customTools.push(...buildToolDefinitionsFromRefs(options2.toolRefs));
|
|
290378
|
+
}
|
|
290278
290379
|
const { session } = await createAgentSession({
|
|
290279
290380
|
cwd,
|
|
290280
290381
|
model,
|
|
@@ -290472,13 +290573,15 @@ function dispatchRunner(runner, base, cwd, options2) {
|
|
|
290472
290573
|
env: base.env,
|
|
290473
290574
|
abortController: base.abortController
|
|
290474
290575
|
}).run(options2.userInput);
|
|
290475
|
-
case "pi":
|
|
290576
|
+
case "pi": {
|
|
290476
290577
|
return createPiRunner({
|
|
290477
290578
|
...base,
|
|
290478
290579
|
cwd,
|
|
290479
290580
|
sessionId: base.resume,
|
|
290480
|
-
skillPaths: options2.skillPaths ?? discoverSkillPaths(cwd)
|
|
290581
|
+
skillPaths: options2.skillPaths ?? discoverSkillPaths(cwd),
|
|
290582
|
+
toolRefs: options2.toolRefs
|
|
290481
290583
|
}).run(options2.userInput);
|
|
290584
|
+
}
|
|
290482
290585
|
case "opencode":
|
|
290483
290586
|
return createOpenCodeRunner({
|
|
290484
290587
|
model: options2.model,
|
|
@@ -290549,6 +290652,7 @@ async function bunnyAgentRun(req, res, env2) {
|
|
|
290549
290652
|
yolo: req.yolo,
|
|
290550
290653
|
env: env2,
|
|
290551
290654
|
abortController,
|
|
290655
|
+
toolRefs: req.toolRefs,
|
|
290552
290656
|
// API: caller owns resume/session; do not read/write cwd/.bunny-agent or auto-load CLAUDE.md.
|
|
290553
290657
|
autoInject: false
|
|
290554
290658
|
});
|
package/dist/index.js
CHANGED
|
@@ -290111,8 +290111,103 @@ function buildSecretAwareTools(cwd, secrets) {
|
|
|
290111
290111
|
return tools;
|
|
290112
290112
|
}
|
|
290113
290113
|
|
|
290114
|
+
// ../../packages/runner-pi/dist/tool-refs.js
|
|
290115
|
+
var LOG_PREFIX2 = "[bunny-agent:pi-tool-ref]";
|
|
290116
|
+
function buildToolDefinitionsFromRefs(tools) {
|
|
290117
|
+
return tools.map((spec) => buildOne(spec));
|
|
290118
|
+
}
|
|
290119
|
+
function buildOne(spec) {
|
|
290120
|
+
const parameters = Type.Unsafe(spec.inputSchema);
|
|
290121
|
+
return {
|
|
290122
|
+
name: spec.name,
|
|
290123
|
+
label: spec.name,
|
|
290124
|
+
description: spec.description,
|
|
290125
|
+
parameters,
|
|
290126
|
+
async execute(_toolCallId, params, signal) {
|
|
290127
|
+
let response;
|
|
290128
|
+
try {
|
|
290129
|
+
response = await executeToolRef(spec, params, signal);
|
|
290130
|
+
} catch (error) {
|
|
290131
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
290132
|
+
return transportErrorResult(spec.name, message);
|
|
290133
|
+
}
|
|
290134
|
+
if (response.status < 200 || response.status >= 300) {
|
|
290135
|
+
return statusErrorResult(spec.name, response.status, response.body);
|
|
290136
|
+
}
|
|
290137
|
+
return okResult(response.body);
|
|
290138
|
+
}
|
|
290139
|
+
};
|
|
290140
|
+
}
|
|
290141
|
+
async function executeToolRef(spec, params, signal) {
|
|
290142
|
+
switch (spec.runtime.type) {
|
|
290143
|
+
case "http":
|
|
290144
|
+
return sendDirectHttpRequest(spec.runtime, params, signal);
|
|
290145
|
+
case "module":
|
|
290146
|
+
return executeModuleTool(spec.runtime, params, signal);
|
|
290147
|
+
}
|
|
290148
|
+
}
|
|
290149
|
+
async function sendDirectHttpRequest(runtime, params, signal) {
|
|
290150
|
+
const response = await fetch(runtime.url, {
|
|
290151
|
+
method: "POST",
|
|
290152
|
+
signal,
|
|
290153
|
+
headers: {
|
|
290154
|
+
"Content-Type": "application/json",
|
|
290155
|
+
...runtime.headers ?? {}
|
|
290156
|
+
},
|
|
290157
|
+
body: JSON.stringify(params)
|
|
290158
|
+
});
|
|
290159
|
+
const body = await response.text();
|
|
290160
|
+
return { status: response.status, body };
|
|
290161
|
+
}
|
|
290162
|
+
async function executeModuleTool(runtime, params, signal) {
|
|
290163
|
+
const mod = await import(runtime.module);
|
|
290164
|
+
const exportName = runtime.exportName ?? "execute";
|
|
290165
|
+
const fn = mod[exportName];
|
|
290166
|
+
if (typeof fn !== "function") {
|
|
290167
|
+
return {
|
|
290168
|
+
status: 500,
|
|
290169
|
+
body: `module tool export "${exportName}" is not a function`
|
|
290170
|
+
};
|
|
290171
|
+
}
|
|
290172
|
+
const result = await fn(params, { signal });
|
|
290173
|
+
return { status: 200, body: serializeResult(result) };
|
|
290174
|
+
}
|
|
290175
|
+
function okResult(text) {
|
|
290176
|
+
return {
|
|
290177
|
+
content: [{ type: "text", text }],
|
|
290178
|
+
details: void 0
|
|
290179
|
+
};
|
|
290180
|
+
}
|
|
290181
|
+
function statusErrorResult(toolName, status2, body) {
|
|
290182
|
+
return {
|
|
290183
|
+
content: [
|
|
290184
|
+
{
|
|
290185
|
+
type: "text",
|
|
290186
|
+
text: `${LOG_PREFIX2} tool "${toolName}" failed (status ${status2}): ${body}`
|
|
290187
|
+
}
|
|
290188
|
+
],
|
|
290189
|
+
details: void 0
|
|
290190
|
+
};
|
|
290191
|
+
}
|
|
290192
|
+
function transportErrorResult(toolName, message) {
|
|
290193
|
+
return {
|
|
290194
|
+
content: [
|
|
290195
|
+
{
|
|
290196
|
+
type: "text",
|
|
290197
|
+
text: `${LOG_PREFIX2} tool "${toolName}" transport error: ${message}`
|
|
290198
|
+
}
|
|
290199
|
+
],
|
|
290200
|
+
details: void 0
|
|
290201
|
+
};
|
|
290202
|
+
}
|
|
290203
|
+
function serializeResult(result) {
|
|
290204
|
+
if (typeof result === "string")
|
|
290205
|
+
return result;
|
|
290206
|
+
return JSON.stringify(result);
|
|
290207
|
+
}
|
|
290208
|
+
|
|
290114
290209
|
// ../../packages/runner-pi/dist/pi-runner.js
|
|
290115
|
-
var
|
|
290210
|
+
var LOG_PREFIX3 = "[bunny-agent:pi]";
|
|
290116
290211
|
function parseModelSpec(model) {
|
|
290117
290212
|
const trimmed = model.trim();
|
|
290118
290213
|
const separator = trimmed.indexOf(":");
|
|
@@ -290237,11 +290332,11 @@ function createPiRunner(options2 = {}) {
|
|
|
290237
290332
|
return SessionManager.open(resume);
|
|
290238
290333
|
}
|
|
290239
290334
|
const sessionPath2 = resolveSessionPathById(cwd, resume);
|
|
290240
|
-
console.error(`${
|
|
290335
|
+
console.error(`${LOG_PREFIX3} resume: id=${resume} path=${sessionPath2 ?? "(not found)"}`);
|
|
290241
290336
|
if (sessionPath2) {
|
|
290242
290337
|
if (isSessionFileTooLarge(sessionPath2)) {
|
|
290243
290338
|
const context = extractSessionContext(sessionPath2);
|
|
290244
|
-
console.error(`${
|
|
290339
|
+
console.error(`${LOG_PREFIX3} session file too large, starting fresh${context ? " (with context)" : ""}`);
|
|
290245
290340
|
const newMgr = SessionManager.create(cwd);
|
|
290246
290341
|
if (context) {
|
|
290247
290342
|
const firstId = newMgr.getEntries()[0]?.id ?? "";
|
|
@@ -290261,7 +290356,7 @@ function createPiRunner(options2 = {}) {
|
|
|
290261
290356
|
appendSystemPrompt: options2.systemPrompt
|
|
290262
290357
|
}) : void 0;
|
|
290263
290358
|
if (options2.skillPaths && options2.skillPaths.length > 0) {
|
|
290264
|
-
console.error(`${
|
|
290359
|
+
console.error(`${LOG_PREFIX3} runner: cwd=${cwd} skillPaths=${JSON.stringify(options2.skillPaths)}`);
|
|
290265
290360
|
}
|
|
290266
290361
|
if (resourceLoader) {
|
|
290267
290362
|
await resourceLoader.reload();
|
|
@@ -290271,6 +290366,12 @@ function createPiRunner(options2 = {}) {
|
|
|
290271
290366
|
const apiKey = await modelRegistry2.authStorage.getApiKey(provider) ?? "";
|
|
290272
290367
|
customTools.push(buildImageGenerateTool(cwd, imageModelName, model.baseUrl, apiKey), buildImageEditTool(cwd, imageModelName, model.baseUrl, apiKey));
|
|
290273
290368
|
}
|
|
290369
|
+
if (options2.customTools && options2.customTools.length > 0) {
|
|
290370
|
+
customTools.push(...options2.customTools);
|
|
290371
|
+
}
|
|
290372
|
+
if (options2.toolRefs && options2.toolRefs.length > 0) {
|
|
290373
|
+
customTools.push(...buildToolDefinitionsFromRefs(options2.toolRefs));
|
|
290374
|
+
}
|
|
290274
290375
|
const { session } = await createAgentSession({
|
|
290275
290376
|
cwd,
|
|
290276
290377
|
model,
|
|
@@ -290468,13 +290569,15 @@ function dispatchRunner(runner, base, cwd, options2) {
|
|
|
290468
290569
|
env: base.env,
|
|
290469
290570
|
abortController: base.abortController
|
|
290470
290571
|
}).run(options2.userInput);
|
|
290471
|
-
case "pi":
|
|
290572
|
+
case "pi": {
|
|
290472
290573
|
return createPiRunner({
|
|
290473
290574
|
...base,
|
|
290474
290575
|
cwd,
|
|
290475
290576
|
sessionId: base.resume,
|
|
290476
|
-
skillPaths: options2.skillPaths ?? discoverSkillPaths(cwd)
|
|
290577
|
+
skillPaths: options2.skillPaths ?? discoverSkillPaths(cwd),
|
|
290578
|
+
toolRefs: options2.toolRefs
|
|
290477
290579
|
}).run(options2.userInput);
|
|
290580
|
+
}
|
|
290478
290581
|
case "opencode":
|
|
290479
290582
|
return createOpenCodeRunner({
|
|
290480
290583
|
model: options2.model,
|
|
@@ -290545,6 +290648,7 @@ async function bunnyAgentRun(req, res, env2) {
|
|
|
290545
290648
|
yolo: req.yolo,
|
|
290546
290649
|
env: env2,
|
|
290547
290650
|
abortController,
|
|
290651
|
+
toolRefs: req.toolRefs,
|
|
290548
290652
|
// API: caller owns resume/session; do not read/write cwd/.bunny-agent or auto-load CLAUDE.md.
|
|
290549
290653
|
autoInject: false
|
|
290550
290654
|
});
|
package/dist/nextjs.js
CHANGED
|
@@ -290107,8 +290107,103 @@ function buildSecretAwareTools(cwd, secrets) {
|
|
|
290107
290107
|
return tools;
|
|
290108
290108
|
}
|
|
290109
290109
|
|
|
290110
|
+
// ../../packages/runner-pi/dist/tool-refs.js
|
|
290111
|
+
var LOG_PREFIX2 = "[bunny-agent:pi-tool-ref]";
|
|
290112
|
+
function buildToolDefinitionsFromRefs(tools) {
|
|
290113
|
+
return tools.map((spec) => buildOne(spec));
|
|
290114
|
+
}
|
|
290115
|
+
function buildOne(spec) {
|
|
290116
|
+
const parameters = Type.Unsafe(spec.inputSchema);
|
|
290117
|
+
return {
|
|
290118
|
+
name: spec.name,
|
|
290119
|
+
label: spec.name,
|
|
290120
|
+
description: spec.description,
|
|
290121
|
+
parameters,
|
|
290122
|
+
async execute(_toolCallId, params, signal) {
|
|
290123
|
+
let response;
|
|
290124
|
+
try {
|
|
290125
|
+
response = await executeToolRef(spec, params, signal);
|
|
290126
|
+
} catch (error) {
|
|
290127
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
290128
|
+
return transportErrorResult(spec.name, message);
|
|
290129
|
+
}
|
|
290130
|
+
if (response.status < 200 || response.status >= 300) {
|
|
290131
|
+
return statusErrorResult(spec.name, response.status, response.body);
|
|
290132
|
+
}
|
|
290133
|
+
return okResult(response.body);
|
|
290134
|
+
}
|
|
290135
|
+
};
|
|
290136
|
+
}
|
|
290137
|
+
async function executeToolRef(spec, params, signal) {
|
|
290138
|
+
switch (spec.runtime.type) {
|
|
290139
|
+
case "http":
|
|
290140
|
+
return sendDirectHttpRequest(spec.runtime, params, signal);
|
|
290141
|
+
case "module":
|
|
290142
|
+
return executeModuleTool(spec.runtime, params, signal);
|
|
290143
|
+
}
|
|
290144
|
+
}
|
|
290145
|
+
async function sendDirectHttpRequest(runtime, params, signal) {
|
|
290146
|
+
const response = await fetch(runtime.url, {
|
|
290147
|
+
method: "POST",
|
|
290148
|
+
signal,
|
|
290149
|
+
headers: {
|
|
290150
|
+
"Content-Type": "application/json",
|
|
290151
|
+
...runtime.headers ?? {}
|
|
290152
|
+
},
|
|
290153
|
+
body: JSON.stringify(params)
|
|
290154
|
+
});
|
|
290155
|
+
const body = await response.text();
|
|
290156
|
+
return { status: response.status, body };
|
|
290157
|
+
}
|
|
290158
|
+
async function executeModuleTool(runtime, params, signal) {
|
|
290159
|
+
const mod = await import(runtime.module);
|
|
290160
|
+
const exportName = runtime.exportName ?? "execute";
|
|
290161
|
+
const fn = mod[exportName];
|
|
290162
|
+
if (typeof fn !== "function") {
|
|
290163
|
+
return {
|
|
290164
|
+
status: 500,
|
|
290165
|
+
body: `module tool export "${exportName}" is not a function`
|
|
290166
|
+
};
|
|
290167
|
+
}
|
|
290168
|
+
const result = await fn(params, { signal });
|
|
290169
|
+
return { status: 200, body: serializeResult(result) };
|
|
290170
|
+
}
|
|
290171
|
+
function okResult(text) {
|
|
290172
|
+
return {
|
|
290173
|
+
content: [{ type: "text", text }],
|
|
290174
|
+
details: void 0
|
|
290175
|
+
};
|
|
290176
|
+
}
|
|
290177
|
+
function statusErrorResult(toolName, status2, body) {
|
|
290178
|
+
return {
|
|
290179
|
+
content: [
|
|
290180
|
+
{
|
|
290181
|
+
type: "text",
|
|
290182
|
+
text: `${LOG_PREFIX2} tool "${toolName}" failed (status ${status2}): ${body}`
|
|
290183
|
+
}
|
|
290184
|
+
],
|
|
290185
|
+
details: void 0
|
|
290186
|
+
};
|
|
290187
|
+
}
|
|
290188
|
+
function transportErrorResult(toolName, message) {
|
|
290189
|
+
return {
|
|
290190
|
+
content: [
|
|
290191
|
+
{
|
|
290192
|
+
type: "text",
|
|
290193
|
+
text: `${LOG_PREFIX2} tool "${toolName}" transport error: ${message}`
|
|
290194
|
+
}
|
|
290195
|
+
],
|
|
290196
|
+
details: void 0
|
|
290197
|
+
};
|
|
290198
|
+
}
|
|
290199
|
+
function serializeResult(result) {
|
|
290200
|
+
if (typeof result === "string")
|
|
290201
|
+
return result;
|
|
290202
|
+
return JSON.stringify(result);
|
|
290203
|
+
}
|
|
290204
|
+
|
|
290110
290205
|
// ../../packages/runner-pi/dist/pi-runner.js
|
|
290111
|
-
var
|
|
290206
|
+
var LOG_PREFIX3 = "[bunny-agent:pi]";
|
|
290112
290207
|
function parseModelSpec(model) {
|
|
290113
290208
|
const trimmed = model.trim();
|
|
290114
290209
|
const separator = trimmed.indexOf(":");
|
|
@@ -290233,11 +290328,11 @@ function createPiRunner(options2 = {}) {
|
|
|
290233
290328
|
return SessionManager.open(resume);
|
|
290234
290329
|
}
|
|
290235
290330
|
const sessionPath2 = resolveSessionPathById(cwd, resume);
|
|
290236
|
-
console.error(`${
|
|
290331
|
+
console.error(`${LOG_PREFIX3} resume: id=${resume} path=${sessionPath2 ?? "(not found)"}`);
|
|
290237
290332
|
if (sessionPath2) {
|
|
290238
290333
|
if (isSessionFileTooLarge(sessionPath2)) {
|
|
290239
290334
|
const context = extractSessionContext(sessionPath2);
|
|
290240
|
-
console.error(`${
|
|
290335
|
+
console.error(`${LOG_PREFIX3} session file too large, starting fresh${context ? " (with context)" : ""}`);
|
|
290241
290336
|
const newMgr = SessionManager.create(cwd);
|
|
290242
290337
|
if (context) {
|
|
290243
290338
|
const firstId = newMgr.getEntries()[0]?.id ?? "";
|
|
@@ -290257,7 +290352,7 @@ function createPiRunner(options2 = {}) {
|
|
|
290257
290352
|
appendSystemPrompt: options2.systemPrompt
|
|
290258
290353
|
}) : void 0;
|
|
290259
290354
|
if (options2.skillPaths && options2.skillPaths.length > 0) {
|
|
290260
|
-
console.error(`${
|
|
290355
|
+
console.error(`${LOG_PREFIX3} runner: cwd=${cwd} skillPaths=${JSON.stringify(options2.skillPaths)}`);
|
|
290261
290356
|
}
|
|
290262
290357
|
if (resourceLoader) {
|
|
290263
290358
|
await resourceLoader.reload();
|
|
@@ -290267,6 +290362,12 @@ function createPiRunner(options2 = {}) {
|
|
|
290267
290362
|
const apiKey = await modelRegistry2.authStorage.getApiKey(provider) ?? "";
|
|
290268
290363
|
customTools.push(buildImageGenerateTool(cwd, imageModelName, model.baseUrl, apiKey), buildImageEditTool(cwd, imageModelName, model.baseUrl, apiKey));
|
|
290269
290364
|
}
|
|
290365
|
+
if (options2.customTools && options2.customTools.length > 0) {
|
|
290366
|
+
customTools.push(...options2.customTools);
|
|
290367
|
+
}
|
|
290368
|
+
if (options2.toolRefs && options2.toolRefs.length > 0) {
|
|
290369
|
+
customTools.push(...buildToolDefinitionsFromRefs(options2.toolRefs));
|
|
290370
|
+
}
|
|
290270
290371
|
const { session } = await createAgentSession({
|
|
290271
290372
|
cwd,
|
|
290272
290373
|
model,
|
|
@@ -290464,13 +290565,15 @@ function dispatchRunner(runner, base, cwd, options2) {
|
|
|
290464
290565
|
env: base.env,
|
|
290465
290566
|
abortController: base.abortController
|
|
290466
290567
|
}).run(options2.userInput);
|
|
290467
|
-
case "pi":
|
|
290568
|
+
case "pi": {
|
|
290468
290569
|
return createPiRunner({
|
|
290469
290570
|
...base,
|
|
290470
290571
|
cwd,
|
|
290471
290572
|
sessionId: base.resume,
|
|
290472
|
-
skillPaths: options2.skillPaths ?? discoverSkillPaths(cwd)
|
|
290573
|
+
skillPaths: options2.skillPaths ?? discoverSkillPaths(cwd),
|
|
290574
|
+
toolRefs: options2.toolRefs
|
|
290473
290575
|
}).run(options2.userInput);
|
|
290576
|
+
}
|
|
290474
290577
|
case "opencode":
|
|
290475
290578
|
return createOpenCodeRunner({
|
|
290476
290579
|
model: options2.model,
|
|
@@ -290539,6 +290642,7 @@ function codingRunStream(req, env2) {
|
|
|
290539
290642
|
yolo: req.yolo,
|
|
290540
290643
|
env: env2,
|
|
290541
290644
|
abortController,
|
|
290645
|
+
toolRefs: req.toolRefs,
|
|
290542
290646
|
autoInject: false
|
|
290543
290647
|
});
|
|
290544
290648
|
for await (const chunk of stream2) {
|
package/dist/routes/coding.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type * as http from "node:http";
|
|
2
|
+
import { type RunnerCoreOptions } from "@bunny-agent/runner-harness";
|
|
3
|
+
type RunToolRefs = RunnerCoreOptions["toolRefs"];
|
|
2
4
|
export interface RunRequest {
|
|
3
5
|
runner?: string;
|
|
4
6
|
model?: string;
|
|
@@ -13,6 +15,8 @@ export interface RunRequest {
|
|
|
13
15
|
yolo?: boolean;
|
|
14
16
|
/** Inline runner env (string map); same keys override. */
|
|
15
17
|
env?: Record<string, string>;
|
|
18
|
+
/** Tool refs the runner should expose to the LLM. */
|
|
19
|
+
toolRefs?: RunToolRefs;
|
|
16
20
|
}
|
|
17
21
|
export declare const HEARTBEAT_COMMENT = ": heartbeat\n\n";
|
|
18
22
|
/** Get current heartbeat interval. */
|
|
@@ -28,4 +32,5 @@ export declare function bunnyAgentRun(req: RunRequest, res: http.ServerResponse,
|
|
|
28
32
|
* Returns a streaming Response with NDJSON body.
|
|
29
33
|
*/
|
|
30
34
|
export declare function codingRunStream(req: RunRequest, env: Record<string, string>): Response;
|
|
35
|
+
export {};
|
|
31
36
|
//# sourceMappingURL=coding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coding.d.ts","sourceRoot":"","sources":["../../src/routes/coding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"coding.d.ts","sourceRoot":"","sources":["../../src/routes/coding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAErC,KAAK,WAAW,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;AAEjD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB;AAKD,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,sCAAsC;AACtC,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,IAAI,CAAC,CAqDf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,QAAQ,CA8DV"}
|