@polka-codes/runner 0.9.35 → 0.9.37
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/index.js +45 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30494,7 +30494,7 @@ var {
|
|
|
30494
30494
|
Help
|
|
30495
30495
|
} = import__.default;
|
|
30496
30496
|
// package.json
|
|
30497
|
-
var version = "0.9.
|
|
30497
|
+
var version = "0.9.37";
|
|
30498
30498
|
|
|
30499
30499
|
// src/runner.ts
|
|
30500
30500
|
import { execSync } from "node:child_process";
|
|
@@ -42659,14 +42659,23 @@ var handler4 = async (provider, args) => {
|
|
|
42659
42659
|
try {
|
|
42660
42660
|
console.log("Executing command:", command, "Requires approval:", requiresApproval);
|
|
42661
42661
|
const result = await provider.executeCommand(command, requiresApproval);
|
|
42662
|
-
|
|
42662
|
+
let message = `<command>${command}</command>
|
|
42663
42663
|
<command_exit_code>${result.exitCode}</command_exit_code>
|
|
42664
|
-
|
|
42664
|
+
`;
|
|
42665
|
+
if (result.summary) {
|
|
42666
|
+
message += `<command_output_summary>
|
|
42667
|
+
${result.summary}
|
|
42668
|
+
</command_output_summary>
|
|
42669
|
+
`;
|
|
42670
|
+
} else {
|
|
42671
|
+
message += `<command_stdout>
|
|
42665
42672
|
${result.stdout}
|
|
42666
42673
|
</command_stdout>
|
|
42667
42674
|
<command_stderr>
|
|
42668
42675
|
${result.stderr}
|
|
42669
|
-
</command_stderr
|
|
42676
|
+
</command_stderr>
|
|
42677
|
+
`;
|
|
42678
|
+
}
|
|
42670
42679
|
if (result.exitCode === 0) {
|
|
42671
42680
|
return {
|
|
42672
42681
|
type: "Reply" /* Reply */,
|
|
@@ -43709,6 +43718,14 @@ class UsageMeter {
|
|
|
43709
43718
|
get usage() {
|
|
43710
43719
|
return { ...this.#totals };
|
|
43711
43720
|
}
|
|
43721
|
+
merge(other) {
|
|
43722
|
+
const otherUsage = other.usage;
|
|
43723
|
+
this.#totals.input += otherUsage.input;
|
|
43724
|
+
this.#totals.output += otherUsage.output;
|
|
43725
|
+
this.#totals.cachedRead += otherUsage.cachedRead;
|
|
43726
|
+
this.#totals.cost += otherUsage.cost;
|
|
43727
|
+
this.#totals.messageCount += otherUsage.messageCount;
|
|
43728
|
+
}
|
|
43712
43729
|
printUsage(customConsole = console) {
|
|
43713
43730
|
const u = this.usage;
|
|
43714
43731
|
customConsole.log(`Usage - messages: ${u.messageCount}, input: ${u.input}, cached: ${u.cachedRead}, ` + `output: ${u.output}, cost: $${u.cost.toFixed(4)}`);
|
|
@@ -55541,6 +55558,7 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
55541
55558
|
};
|
|
55542
55559
|
try {
|
|
55543
55560
|
resetTimeout();
|
|
55561
|
+
const usageMeterOnFinishHandler = this.config.usageMeter.onFinishHandler(this.ai);
|
|
55544
55562
|
const streamTextOptions = {
|
|
55545
55563
|
model: this.ai,
|
|
55546
55564
|
temperature: 0,
|
|
@@ -55559,7 +55577,10 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
55559
55577
|
break;
|
|
55560
55578
|
}
|
|
55561
55579
|
},
|
|
55562
|
-
onFinish:
|
|
55580
|
+
onFinish: (evt) => {
|
|
55581
|
+
usageMeterOnFinishHandler(evt);
|
|
55582
|
+
this.#callback({ kind: "Usage" /* Usage */, agent: this, usage: evt.totalUsage });
|
|
55583
|
+
},
|
|
55563
55584
|
onError: async (error43) => {
|
|
55564
55585
|
console.error("Error in stream:", error43);
|
|
55565
55586
|
},
|
|
@@ -56441,6 +56462,7 @@ var configSchema = exports_external.object({
|
|
|
56441
56462
|
budget: exports_external.number().positive().optional(),
|
|
56442
56463
|
retryCount: exports_external.number().int().min(0).optional(),
|
|
56443
56464
|
requestTimeoutSeconds: exports_external.number().int().positive().optional(),
|
|
56465
|
+
summaryThreshold: exports_external.number().int().positive().optional(),
|
|
56444
56466
|
scripts: exports_external.record(exports_external.string(), exports_external.string().or(exports_external.object({
|
|
56445
56467
|
command: exports_external.string(),
|
|
56446
56468
|
description: exports_external.string()
|
|
@@ -62234,8 +62256,25 @@ var getProvider = (options = {}) => {
|
|
|
62234
62256
|
options.command?.onStderr(dataStr);
|
|
62235
62257
|
stderrText += dataStr;
|
|
62236
62258
|
});
|
|
62237
|
-
child.on("close", (code) => {
|
|
62259
|
+
child.on("close", async (code) => {
|
|
62238
62260
|
options.command?.onExit(code ?? 0);
|
|
62261
|
+
const totalLength = stdoutText.length + stderrText.length;
|
|
62262
|
+
if (totalLength > (options.summaryThreshold ?? 5000) && options.summarizeOutput) {
|
|
62263
|
+
try {
|
|
62264
|
+
const summary = await options.summarizeOutput(stdoutText, stderrText);
|
|
62265
|
+
if (summary) {
|
|
62266
|
+
resolve4({
|
|
62267
|
+
summary,
|
|
62268
|
+
stdout: stdoutText,
|
|
62269
|
+
stderr: stderrText,
|
|
62270
|
+
exitCode: code ?? 0
|
|
62271
|
+
});
|
|
62272
|
+
return;
|
|
62273
|
+
}
|
|
62274
|
+
} catch (_e) {
|
|
62275
|
+
console.error("Summarization failed:", _e);
|
|
62276
|
+
}
|
|
62277
|
+
}
|
|
62239
62278
|
resolve4({
|
|
62240
62279
|
stdout: stdoutText,
|
|
62241
62280
|
stderr: stderrText,
|