@bunny-agent/runner-cli 0.9.60 → 0.9.61
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 +68 -78
- package/package.json +9 -9
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,43 @@ 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
|
+
};
|
|
24506
|
+
function resolveDynamicModelProfile(modelName, effort) {
|
|
24507
|
+
const profile = DYNAMIC_MODEL_PROFILES[modelName.toLowerCase()];
|
|
24508
|
+
return {
|
|
24509
|
+
contextWindow: profile?.contextWindow ?? DEFAULT_DYNAMIC_MODEL_PROFILE.contextWindow,
|
|
24510
|
+
maxTokens: profile?.maxTokens ?? DEFAULT_DYNAMIC_MODEL_PROFILE.maxTokens,
|
|
24511
|
+
reasoning: profile?.reasoning ?? Boolean(effort && effort !== "off"),
|
|
24512
|
+
thinkingLevelMap: {
|
|
24513
|
+
...profile?.thinkingLevelMap ?? DEFAULT_DYNAMIC_MODEL_PROFILE.thinkingLevelMap
|
|
24514
|
+
}
|
|
24515
|
+
};
|
|
24516
|
+
}
|
|
24517
|
+
function resolveInitialThinkingLevel(effort, previousModel, currentModel) {
|
|
24518
|
+
if (effort)
|
|
24519
|
+
return effort;
|
|
24520
|
+
if (previousModel && (previousModel.provider !== currentModel.provider || previousModel.modelId !== currentModel.id)) {
|
|
24521
|
+
return "medium";
|
|
24522
|
+
}
|
|
24523
|
+
return void 0;
|
|
24524
|
+
}
|
|
24471
24525
|
async function disposePiSession(session) {
|
|
24472
24526
|
try {
|
|
24473
24527
|
if (session.hasExtensionHandlers("session_shutdown")) {
|
|
@@ -24493,72 +24547,6 @@ function normalizeAllowedTools(allowedTools) {
|
|
|
24493
24547
|
...new Set(allowedTools.map((toolName) => toolName === LEGACY_ASK_USER_QUESTION_TOOL_NAME ? ASK_USER_QUESTION_TOOL_NAME : toolName))
|
|
24494
24548
|
];
|
|
24495
24549
|
}
|
|
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
24550
|
function parseModelSpec(model) {
|
|
24563
24551
|
const trimmed = model.trim();
|
|
24564
24552
|
const separator = trimmed.indexOf(":");
|
|
@@ -24657,6 +24645,7 @@ function createPiRunner(options = {}) {
|
|
|
24657
24645
|
if (!baseUrl) {
|
|
24658
24646
|
throw new Error(`Pi runner: model "${modelSpec}" not found in built-in catalog. Set ${baseUrlEnvKey} (or OPENAI_BASE_URL) to auto-register it.`);
|
|
24659
24647
|
}
|
|
24648
|
+
const profile = resolveDynamicModelProfile(modelName, options.effort);
|
|
24660
24649
|
modelRuntime.registerProvider(provider, {
|
|
24661
24650
|
baseUrl,
|
|
24662
24651
|
apiKey: inlineApiKey ?? apiKeyEnvKey,
|
|
@@ -24665,12 +24654,12 @@ function createPiRunner(options = {}) {
|
|
|
24665
24654
|
{
|
|
24666
24655
|
id: modelName,
|
|
24667
24656
|
name: modelName,
|
|
24668
|
-
reasoning:
|
|
24669
|
-
thinkingLevelMap:
|
|
24657
|
+
reasoning: profile.reasoning,
|
|
24658
|
+
thinkingLevelMap: profile.thinkingLevelMap,
|
|
24670
24659
|
input: ["text", "image"],
|
|
24671
24660
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
24672
|
-
contextWindow:
|
|
24673
|
-
maxTokens:
|
|
24661
|
+
contextWindow: profile.contextWindow,
|
|
24662
|
+
maxTokens: profile.maxTokens
|
|
24674
24663
|
}
|
|
24675
24664
|
]
|
|
24676
24665
|
});
|
|
@@ -24712,7 +24701,6 @@ function createPiRunner(options = {}) {
|
|
|
24712
24701
|
}
|
|
24713
24702
|
return SessionManager2.create(cwd);
|
|
24714
24703
|
})();
|
|
24715
|
-
stripLLMThoughtSignaturesFromSessionManager(sessionManager, model);
|
|
24716
24704
|
const resourceLoader = options.skillPaths || options.systemPrompt || mcpExtension ? new BunnyAgentResourceLoader({
|
|
24717
24705
|
cwd,
|
|
24718
24706
|
skillPaths: options.skillPaths,
|
|
@@ -24762,13 +24750,15 @@ function createPiRunner(options = {}) {
|
|
|
24762
24750
|
}
|
|
24763
24751
|
const gatedTools = gateToolsForApproval(regularTools, bypassApproval, approvalGate);
|
|
24764
24752
|
const askUserQuestionEnabled = allowedTools === void 0 || allowedTools.includes(ASK_USER_QUESTION_TOOL_NAME);
|
|
24753
|
+
const previousModel = sessionManager.buildSessionContext?.().model;
|
|
24754
|
+
const thinkingLevel = resolveInitialThinkingLevel(options.effort, previousModel, model);
|
|
24765
24755
|
const { session } = await createAgentSession({
|
|
24766
24756
|
cwd,
|
|
24767
24757
|
model,
|
|
24768
24758
|
sessionManager,
|
|
24769
24759
|
modelRuntime,
|
|
24770
24760
|
resourceLoader,
|
|
24771
|
-
thinkingLevel
|
|
24761
|
+
thinkingLevel,
|
|
24772
24762
|
tools: allowedTools,
|
|
24773
24763
|
customTools: [
|
|
24774
24764
|
...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",
|
|
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/
|
|
69
|
-
"@bunny-agent/runner-
|
|
63
|
+
"@bunny-agent/runner-claude": "0.6.2",
|
|
64
|
+
"@bunny-agent/runner-codex": "0.6.2",
|
|
65
|
+
"@bunny-agent/runner-gemini": "0.6.2",
|
|
66
|
+
"@bunny-agent/runner-copilot": "0.1.0",
|
|
70
67
|
"@bunny-agent/runner-harness": "0.1.1-beta.0",
|
|
71
|
-
"@bunny-agent/
|
|
68
|
+
"@bunny-agent/manager": "0.9.61",
|
|
69
|
+
"@bunny-agent/runner-pi": "0.6.4-beta.0",
|
|
70
|
+
"@bunny-agent/server-acp": "0.1.0",
|
|
71
|
+
"@bunny-agent/runner-opencode": "0.6.2"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsc && pnpm bundle",
|