@polka-codes/runner 0.7.24 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +68 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25790,7 +25790,7 @@ var {
25790
25790
  Help
25791
25791
  } = import__.default;
25792
25792
  // package.json
25793
- var version = "0.7.24";
25793
+ var version = "0.8.0";
25794
25794
 
25795
25795
  // src/runner.ts
25796
25796
  import { execSync } from "node:child_process";
@@ -54535,6 +54535,11 @@ var wsOutgoingMessageSchema = z3.discriminatedUnion("type", [
54535
54535
  response: z3.string()
54536
54536
  }))
54537
54537
  }),
54538
+ z3.object({
54539
+ type: z3.literal("pending_tools_response_completed"),
54540
+ step: z3.number(),
54541
+ index: z3.number()
54542
+ }),
54538
54543
  z3.object({
54539
54544
  type: z3.literal("file"),
54540
54545
  path: z3.string(),
@@ -54742,29 +54747,71 @@ class Runner {
54742
54747
  console.log(`Received tool requests for step ${message.step}:`, message.requests.map((r2) => r2.tool));
54743
54748
  const responses = [];
54744
54749
  for (const request of message.requests) {
54745
- let respMsg;
54746
- try {
54747
- console.log(`Executing tool: ${request.tool} with params:`, request.params);
54748
- const tool2 = this.availableTools[request.tool];
54749
- if (tool2) {
54750
- const resp = await tool2.handler(this.provider, request.params);
54751
- if (resp.type === "Reply" /* Reply */) {
54752
- respMsg = responsePrompts.toolResults(request.tool, resp.message);
54753
- } else {
54754
- respMsg = responsePrompts.errorInvokeTool(request.tool, `Unexpected tool response: ${JSON.stringify(resp)}`);
54750
+ const fn = async () => {
54751
+ try {
54752
+ console.log(`Executing tool: ${request.tool} with params:`, request.params);
54753
+ if (request.params.overridenAgent === "coder" && this.provider.executeCommand) {
54754
+ const { format, check, test } = request.params;
54755
+ if (format) {
54756
+ try {
54757
+ await this.provider.executeCommand(format, false);
54758
+ } catch (error) {
54759
+ console.warn(`Failed to format code using command: ${format}`, error);
54760
+ }
54761
+ }
54762
+ if (check) {
54763
+ try {
54764
+ const { exitCode, stdout, stderr } = await this.provider.executeCommand(check, false);
54765
+ if (exitCode !== 0) {
54766
+ return responsePrompts.commandResult(check, exitCode, stdout, stderr);
54767
+ }
54768
+ } catch (error) {
54769
+ console.warn(`Failed to check code using command: ${check}`, error);
54770
+ }
54771
+ }
54772
+ if (test) {
54773
+ try {
54774
+ const { exitCode, stdout, stderr } = await this.provider.executeCommand(test, false);
54775
+ if (exitCode !== 0) {
54776
+ return responsePrompts.commandResult(test, exitCode, stdout, stderr);
54777
+ }
54778
+ } catch (error) {
54779
+ console.warn(`Failed to test code using command: ${test}`, error);
54780
+ }
54781
+ }
54782
+ return {
54783
+ type: "exit"
54784
+ };
54755
54785
  }
54756
- } else {
54757
- respMsg = responsePrompts.errorInvokeTool(request.tool, "Tool not available");
54786
+ const tool2 = this.availableTools[request.tool];
54787
+ if (tool2) {
54788
+ const resp = await tool2.handler(this.provider, request.params);
54789
+ if (resp.type === "Reply" /* Reply */) {
54790
+ return responsePrompts.toolResults(request.tool, resp.message);
54791
+ }
54792
+ return responsePrompts.errorInvokeTool(request.tool, `Unexpected tool response: ${JSON.stringify(resp)}`);
54793
+ }
54794
+ return responsePrompts.errorInvokeTool(request.tool, "Tool not available");
54795
+ } catch (toolError) {
54796
+ console.error(`Error executing tool ${request.tool}:`, toolError);
54797
+ return responsePrompts.errorInvokeTool(request.tool, toolError);
54758
54798
  }
54759
- } catch (toolError) {
54760
- console.error(`Error executing tool ${request.tool}:`, toolError);
54761
- respMsg = responsePrompts.errorInvokeTool(request.tool, toolError);
54799
+ };
54800
+ const respMsg = await fn();
54801
+ if (typeof respMsg === "string") {
54802
+ responses.push({
54803
+ index: request.index,
54804
+ tool: request.tool,
54805
+ response: respMsg
54806
+ });
54807
+ } else if (respMsg.type === "exit") {
54808
+ this.wsManager.sendMessage({
54809
+ type: "pending_tools_response_completed",
54810
+ step: message.step,
54811
+ index: request.index
54812
+ });
54813
+ return;
54762
54814
  }
54763
- responses.push({
54764
- index: request.index,
54765
- tool: request.tool,
54766
- response: respMsg
54767
- });
54768
54815
  }
54769
54816
  this.wsManager.sendMessage({
54770
54817
  type: "pending_tools_response",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.7.24",
3
+ "version": "0.8.0",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",