@bunny-agent/runner-cli 0.9.60 → 0.9.61-beta.2
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.
|
@@ -16,6 +16,22 @@ import { buildImage } from "../build-image.js";
|
|
|
16
16
|
const mockedExecSync = vi.mocked(execSync);
|
|
17
17
|
const TEST_DIR = join(process.cwd(), ".test-build-image");
|
|
18
18
|
const BUILD_CONTEXT = join(TEST_DIR, ".docker-staging");
|
|
19
|
+
const REPOSITORY_ROOT = join(process.cwd(), "../..");
|
|
20
|
+
const CHROMIUM_STORAGE_ARGUMENTS = [
|
|
21
|
+
"--user-data-dir=/tmp/bunny-agent-chromium",
|
|
22
|
+
"--disk-cache-dir=/tmp/bunny-agent-chromium-cache",
|
|
23
|
+
"--disk-cache-size=104857600 --media-cache-size=104857600",
|
|
24
|
+
];
|
|
25
|
+
function expectValidChromiumArgumentContinuations(content) {
|
|
26
|
+
const expectedSuffix = "\\".repeat(3) + "n\\";
|
|
27
|
+
for (const argument of CHROMIUM_STORAGE_ARGUMENTS) {
|
|
28
|
+
const line = content
|
|
29
|
+
.split("\n")
|
|
30
|
+
.find((candidate) => candidate.includes(argument));
|
|
31
|
+
expect(line, "missing Chromium argument: " + argument).toBeDefined();
|
|
32
|
+
expect(line?.endsWith(expectedSuffix), argument).toBe(true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
19
35
|
beforeEach(() => {
|
|
20
36
|
mkdirSync(TEST_DIR, { recursive: true });
|
|
21
37
|
mockedExecSync.mockClear();
|
|
@@ -61,8 +77,27 @@ describe("buildImage", () => {
|
|
|
61
77
|
const content = readFileSync(dockerfilePath, "utf8");
|
|
62
78
|
expect(content).toContain("FROM node:24-slim");
|
|
63
79
|
expect(content).toContain("@bunny-agent/runner-cli");
|
|
80
|
+
expect(content).toContain("--user-data-dir=/tmp/bunny-agent-chromium");
|
|
81
|
+
expect(content).toContain("--disk-cache-dir=/tmp/bunny-agent-chromium-cache");
|
|
82
|
+
expect(content).toContain("--disk-cache-size=104857600");
|
|
83
|
+
expect(content).toContain("--media-cache-size=104857600");
|
|
84
|
+
expect(content).toContain("proxy_read_timeout 3600s;");
|
|
85
|
+
expect(content).toContain("proxy_send_timeout 3600s;");
|
|
86
|
+
expect(content).toContain("proxy_socket_keepalive on;");
|
|
87
|
+
expectValidChromiumArgumentContinuations(content);
|
|
64
88
|
expect(content).toContain('CMD ["sleep", "infinity"]');
|
|
65
89
|
});
|
|
90
|
+
it("keeps Chromium argument continuations valid in every Dockerfile", () => {
|
|
91
|
+
const dockerfiles = [
|
|
92
|
+
"Dockerfile",
|
|
93
|
+
"Dockerfile.local",
|
|
94
|
+
"Dockerfile.template",
|
|
95
|
+
];
|
|
96
|
+
for (const dockerfile of dockerfiles) {
|
|
97
|
+
const content = readFileSync(join(REPOSITORY_ROOT, "docker/bunny-agent-claude", dockerfile), "utf8");
|
|
98
|
+
expectValidChromiumArgumentContinuations(content);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
66
101
|
it("uses --image override when provided", async () => {
|
|
67
102
|
await buildImage({
|
|
68
103
|
name: "bunny-agent",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-image.test.js","sourceRoot":"","sources":["../../src/__tests__/build-image.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,qDAAqD;AACrD,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC;IACnC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE;QAC9B,gDAAgD;QAChD,IA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,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/bundle.mjs
CHANGED
|
@@ -20867,6 +20867,15 @@ function extractAskUserQuestionOutput(toolName, result) {
|
|
|
20867
20867
|
function sseData4(obj) {
|
|
20868
20868
|
return "data: " + JSON.stringify(obj) + "\n\n";
|
|
20869
20869
|
}
|
|
20870
|
+
function getProviderStopReasonFromAgentEndMessages(messages) {
|
|
20871
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
20872
|
+
const message = messages[index];
|
|
20873
|
+
if (message.role === "assistant" && message.stopReason) {
|
|
20874
|
+
return message.stopReason;
|
|
20875
|
+
}
|
|
20876
|
+
}
|
|
20877
|
+
return void 0;
|
|
20878
|
+
}
|
|
20870
20879
|
var PiAISDKStreamConverter = class {
|
|
20871
20880
|
constructor(options) {
|
|
20872
20881
|
this.options = options;
|
|
@@ -20956,8 +20965,10 @@ var PiAISDKStreamConverter = class {
|
|
|
20956
20965
|
const errorMsg = this.options.getErrorFromAgentEndMessages(event.messages);
|
|
20957
20966
|
if (errorMsg)
|
|
20958
20967
|
chunks.push(...this.finishError(errorMsg));
|
|
20959
|
-
else
|
|
20960
|
-
|
|
20968
|
+
else {
|
|
20969
|
+
const providerStopReason = getProviderStopReasonFromAgentEndMessages(event.messages);
|
|
20970
|
+
chunks.push(...this.finishSuccess(this.options.getUsageFromAgentEndMessages(event.messages), providerStopReason === "length" ? "length" : "stop", providerStopReason));
|
|
20971
|
+
}
|
|
20961
20972
|
}
|
|
20962
20973
|
return chunks;
|
|
20963
20974
|
}
|
|
@@ -21002,9 +21013,10 @@ var PiAISDKStreamConverter = class {
|
|
|
21002
21013
|
this.activeTextPartId = null;
|
|
21003
21014
|
return [sseData4({ type: "text-end", id })];
|
|
21004
21015
|
}
|
|
21005
|
-
finishSuccess(usage) {
|
|
21016
|
+
finishSuccess(usage, finishReason2 = "stop", providerStopReason) {
|
|
21006
21017
|
const chunks = [...this.endTextStreamIfOpen()];
|
|
21007
21018
|
const raw = {};
|
|
21019
|
+
const messageMetadata = {};
|
|
21008
21020
|
let chatUsage;
|
|
21009
21021
|
if (usage) {
|
|
21010
21022
|
const { id } = this.options.model;
|
|
@@ -21019,10 +21031,16 @@ var PiAISDKStreamConverter = class {
|
|
|
21019
21031
|
}
|
|
21020
21032
|
const finishPayload = {
|
|
21021
21033
|
type: "finish",
|
|
21022
|
-
finishReason:
|
|
21034
|
+
finishReason: finishReason2
|
|
21023
21035
|
};
|
|
21024
21036
|
if (usage) {
|
|
21025
|
-
|
|
21037
|
+
messageMetadata.usage = { ...chatUsage, raw };
|
|
21038
|
+
}
|
|
21039
|
+
if (providerStopReason) {
|
|
21040
|
+
messageMetadata.providerStopReason = providerStopReason;
|
|
21041
|
+
}
|
|
21042
|
+
if (Object.keys(messageMetadata).length > 0) {
|
|
21043
|
+
finishPayload.messageMetadata = messageMetadata;
|
|
21026
21044
|
}
|
|
21027
21045
|
chunks.push(sseData4(finishPayload), "data: [DONE]\n\n");
|
|
21028
21046
|
this.hasFinished = true;
|
|
@@ -24467,7 +24485,54 @@ function serializeResult2(result) {
|
|
|
24467
24485
|
|
|
24468
24486
|
// ../../packages/runner-pi/dist/pi-runner.js
|
|
24469
24487
|
var LOG_PREFIX2 = "[bunny-agent:pi]";
|
|
24470
|
-
var
|
|
24488
|
+
var DEFAULT_DYNAMIC_MODEL_PROFILE = {
|
|
24489
|
+
contextWindow: 128e3,
|
|
24490
|
+
maxTokens: 8192,
|
|
24491
|
+
thinkingLevelMap: { off: null, xhigh: "xhigh" }
|
|
24492
|
+
};
|
|
24493
|
+
var DYNAMIC_MODEL_PROFILES = {
|
|
24494
|
+
"gemini-3.7-flash": {
|
|
24495
|
+
contextWindow: 1048576,
|
|
24496
|
+
maxTokens: 65536,
|
|
24497
|
+
reasoning: true,
|
|
24498
|
+
thinkingLevelMap: {
|
|
24499
|
+
off: null,
|
|
24500
|
+
minimal: null,
|
|
24501
|
+
xhigh: null,
|
|
24502
|
+
max: null
|
|
24503
|
+
}
|
|
24504
|
+
},
|
|
24505
|
+
"gemini-3.8-flash": {
|
|
24506
|
+
contextWindow: 1048576,
|
|
24507
|
+
maxTokens: 65536,
|
|
24508
|
+
reasoning: true,
|
|
24509
|
+
thinkingLevelMap: {
|
|
24510
|
+
off: null,
|
|
24511
|
+
minimal: null,
|
|
24512
|
+
xhigh: null,
|
|
24513
|
+
max: null
|
|
24514
|
+
}
|
|
24515
|
+
}
|
|
24516
|
+
};
|
|
24517
|
+
function resolveDynamicModelProfile(modelName, effort) {
|
|
24518
|
+
const profile = DYNAMIC_MODEL_PROFILES[modelName.toLowerCase()];
|
|
24519
|
+
return {
|
|
24520
|
+
contextWindow: profile?.contextWindow ?? DEFAULT_DYNAMIC_MODEL_PROFILE.contextWindow,
|
|
24521
|
+
maxTokens: profile?.maxTokens ?? DEFAULT_DYNAMIC_MODEL_PROFILE.maxTokens,
|
|
24522
|
+
reasoning: profile?.reasoning ?? Boolean(effort && effort !== "off"),
|
|
24523
|
+
thinkingLevelMap: {
|
|
24524
|
+
...profile?.thinkingLevelMap ?? DEFAULT_DYNAMIC_MODEL_PROFILE.thinkingLevelMap
|
|
24525
|
+
}
|
|
24526
|
+
};
|
|
24527
|
+
}
|
|
24528
|
+
function resolveInitialThinkingLevel(effort, previousModel, currentModel) {
|
|
24529
|
+
if (effort)
|
|
24530
|
+
return effort;
|
|
24531
|
+
if (previousModel && (previousModel.provider !== currentModel.provider || previousModel.modelId !== currentModel.id)) {
|
|
24532
|
+
return "medium";
|
|
24533
|
+
}
|
|
24534
|
+
return void 0;
|
|
24535
|
+
}
|
|
24471
24536
|
async function disposePiSession(session) {
|
|
24472
24537
|
try {
|
|
24473
24538
|
if (session.hasExtensionHandlers("session_shutdown")) {
|
|
@@ -24493,72 +24558,6 @@ function normalizeAllowedTools(allowedTools) {
|
|
|
24493
24558
|
...new Set(allowedTools.map((toolName) => toolName === LEGACY_ASK_USER_QUESTION_TOOL_NAME ? ASK_USER_QUESTION_TOOL_NAME : toolName))
|
|
24494
24559
|
];
|
|
24495
24560
|
}
|
|
24496
|
-
function shouldStripLLMThoughtSignaturesForModel(model) {
|
|
24497
|
-
const id = (model.id ?? "").toLowerCase();
|
|
24498
|
-
return !id.includes("gemini");
|
|
24499
|
-
}
|
|
24500
|
-
function stripLLMThoughtSignatureFromId(id) {
|
|
24501
|
-
const separatorIndex = id.indexOf(LLM_THOUGHT_SIGNATURE_SEPARATOR);
|
|
24502
|
-
if (separatorIndex === -1)
|
|
24503
|
-
return id;
|
|
24504
|
-
return id.slice(0, separatorIndex);
|
|
24505
|
-
}
|
|
24506
|
-
function stripLLMThoughtSignaturesFromSessionManager(sessionManager, model) {
|
|
24507
|
-
if (!shouldStripLLMThoughtSignaturesForModel(model))
|
|
24508
|
-
return;
|
|
24509
|
-
const manager = sessionManager;
|
|
24510
|
-
const entries = manager.getEntries?.();
|
|
24511
|
-
if (Array.isArray(entries)) {
|
|
24512
|
-
for (const entry of entries) {
|
|
24513
|
-
if (entry == null || typeof entry !== "object")
|
|
24514
|
-
continue;
|
|
24515
|
-
const message = entry.message;
|
|
24516
|
-
if (entry.type === "message") {
|
|
24517
|
-
stripLLMThoughtSignaturesFromMessage(message);
|
|
24518
|
-
}
|
|
24519
|
-
}
|
|
24520
|
-
return;
|
|
24521
|
-
}
|
|
24522
|
-
const context = sessionManager.buildSessionContext?.();
|
|
24523
|
-
const messages = context?.messages;
|
|
24524
|
-
if (!Array.isArray(messages))
|
|
24525
|
-
return;
|
|
24526
|
-
for (const message of messages) {
|
|
24527
|
-
stripLLMThoughtSignaturesFromMessage(message);
|
|
24528
|
-
}
|
|
24529
|
-
}
|
|
24530
|
-
function stripLLMThoughtSignaturesFromMessage(message) {
|
|
24531
|
-
if (message == null || typeof message !== "object")
|
|
24532
|
-
return;
|
|
24533
|
-
const msg = message;
|
|
24534
|
-
if (typeof msg.toolCallId === "string") {
|
|
24535
|
-
msg.toolCallId = stripLLMThoughtSignatureFromId(msg.toolCallId);
|
|
24536
|
-
}
|
|
24537
|
-
if (typeof msg.tool_call_id === "string") {
|
|
24538
|
-
msg.tool_call_id = stripLLMThoughtSignatureFromId(msg.tool_call_id);
|
|
24539
|
-
}
|
|
24540
|
-
if (!Array.isArray(msg.content))
|
|
24541
|
-
return;
|
|
24542
|
-
for (const block of msg.content) {
|
|
24543
|
-
if (block == null || typeof block !== "object")
|
|
24544
|
-
continue;
|
|
24545
|
-
const contentBlock = block;
|
|
24546
|
-
if (contentBlock.type !== "toolCall")
|
|
24547
|
-
continue;
|
|
24548
|
-
if (typeof contentBlock.id === "string") {
|
|
24549
|
-
contentBlock.id = stripLLMThoughtSignatureFromId(contentBlock.id);
|
|
24550
|
-
}
|
|
24551
|
-
if (typeof contentBlock.toolCallId === "string") {
|
|
24552
|
-
contentBlock.toolCallId = stripLLMThoughtSignatureFromId(contentBlock.toolCallId);
|
|
24553
|
-
}
|
|
24554
|
-
if (typeof contentBlock.tool_call_id === "string") {
|
|
24555
|
-
contentBlock.tool_call_id = stripLLMThoughtSignatureFromId(contentBlock.tool_call_id);
|
|
24556
|
-
}
|
|
24557
|
-
if (typeof contentBlock.call_id === "string") {
|
|
24558
|
-
contentBlock.call_id = stripLLMThoughtSignatureFromId(contentBlock.call_id);
|
|
24559
|
-
}
|
|
24560
|
-
}
|
|
24561
|
-
}
|
|
24562
24561
|
function parseModelSpec(model) {
|
|
24563
24562
|
const trimmed = model.trim();
|
|
24564
24563
|
const separator = trimmed.indexOf(":");
|
|
@@ -24657,6 +24656,7 @@ function createPiRunner(options = {}) {
|
|
|
24657
24656
|
if (!baseUrl) {
|
|
24658
24657
|
throw new Error(`Pi runner: model "${modelSpec}" not found in built-in catalog. Set ${baseUrlEnvKey} (or OPENAI_BASE_URL) to auto-register it.`);
|
|
24659
24658
|
}
|
|
24659
|
+
const profile = resolveDynamicModelProfile(modelName, options.effort);
|
|
24660
24660
|
modelRuntime.registerProvider(provider, {
|
|
24661
24661
|
baseUrl,
|
|
24662
24662
|
apiKey: inlineApiKey ?? apiKeyEnvKey,
|
|
@@ -24665,12 +24665,12 @@ function createPiRunner(options = {}) {
|
|
|
24665
24665
|
{
|
|
24666
24666
|
id: modelName,
|
|
24667
24667
|
name: modelName,
|
|
24668
|
-
reasoning:
|
|
24669
|
-
thinkingLevelMap:
|
|
24668
|
+
reasoning: profile.reasoning,
|
|
24669
|
+
thinkingLevelMap: profile.thinkingLevelMap,
|
|
24670
24670
|
input: ["text", "image"],
|
|
24671
24671
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
24672
|
-
contextWindow:
|
|
24673
|
-
maxTokens:
|
|
24672
|
+
contextWindow: profile.contextWindow,
|
|
24673
|
+
maxTokens: profile.maxTokens
|
|
24674
24674
|
}
|
|
24675
24675
|
]
|
|
24676
24676
|
});
|
|
@@ -24712,7 +24712,6 @@ function createPiRunner(options = {}) {
|
|
|
24712
24712
|
}
|
|
24713
24713
|
return SessionManager2.create(cwd);
|
|
24714
24714
|
})();
|
|
24715
|
-
stripLLMThoughtSignaturesFromSessionManager(sessionManager, model);
|
|
24716
24715
|
const resourceLoader = options.skillPaths || options.systemPrompt || mcpExtension ? new BunnyAgentResourceLoader({
|
|
24717
24716
|
cwd,
|
|
24718
24717
|
skillPaths: options.skillPaths,
|
|
@@ -24762,13 +24761,15 @@ function createPiRunner(options = {}) {
|
|
|
24762
24761
|
}
|
|
24763
24762
|
const gatedTools = gateToolsForApproval(regularTools, bypassApproval, approvalGate);
|
|
24764
24763
|
const askUserQuestionEnabled = allowedTools === void 0 || allowedTools.includes(ASK_USER_QUESTION_TOOL_NAME);
|
|
24764
|
+
const previousModel = sessionManager.buildSessionContext?.().model;
|
|
24765
|
+
const thinkingLevel = resolveInitialThinkingLevel(options.effort, previousModel, model);
|
|
24765
24766
|
const { session } = await createAgentSession({
|
|
24766
24767
|
cwd,
|
|
24767
24768
|
model,
|
|
24768
24769
|
sessionManager,
|
|
24769
24770
|
modelRuntime,
|
|
24770
24771
|
resourceLoader,
|
|
24771
|
-
thinkingLevel
|
|
24772
|
+
thinkingLevel,
|
|
24772
24773
|
tools: allowedTools,
|
|
24773
24774
|
customTools: [
|
|
24774
24775
|
...gatedTools,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunny-agent/runner-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.61-beta.2",
|
|
4
4
|
"description": "BunnyAgent Runner CLI - Like gemini-cli or claude-code, runs in your local terminal with AI SDK UI streaming",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -59,16 +59,16 @@
|
|
|
59
59
|
"esbuild": "^0.27.2",
|
|
60
60
|
"typescript": "^5.3.0",
|
|
61
61
|
"vitest": "^1.6.1",
|
|
62
|
-
"@bunny-agent/manager": "0.9.60",
|
|
63
|
-
"@bunny-agent/runner-copilot": "0.1.0",
|
|
64
|
-
"@bunny-agent/runner-gemini": "0.6.2",
|
|
65
|
-
"@bunny-agent/runner-codex": "0.6.2",
|
|
66
|
-
"@bunny-agent/runner-opencode": "0.6.2",
|
|
67
62
|
"@bunny-agent/apply-patch": "0.1.0",
|
|
68
|
-
"@bunny-agent/
|
|
63
|
+
"@bunny-agent/manager": "0.9.61-beta.2",
|
|
64
|
+
"@bunny-agent/runner-claude": "0.6.2",
|
|
65
|
+
"@bunny-agent/runner-codex": "0.6.2",
|
|
66
|
+
"@bunny-agent/runner-gemini": "0.6.2",
|
|
67
|
+
"@bunny-agent/runner-copilot": "0.1.0",
|
|
69
68
|
"@bunny-agent/runner-pi": "0.6.4-beta.0",
|
|
70
|
-
"@bunny-agent/
|
|
71
|
-
"@bunny-agent/runner-
|
|
69
|
+
"@bunny-agent/server-acp": "0.1.0",
|
|
70
|
+
"@bunny-agent/runner-opencode": "0.6.2",
|
|
71
|
+
"@bunny-agent/runner-harness": "0.1.1-beta.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsc && pnpm bundle",
|