@polka-codes/core 0.7.15 → 0.7.16

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.
@@ -11,9 +11,11 @@ declare abstract class AgentBase {
11
11
  start(prompt: string): Promise<ExitReason>;
12
12
  step(promp: string, messages?: MessageParam[]): Promise<AssistantMessageContent[]>;
13
13
  handleStepResponse(response: AssistantMessageContent[], messages?: MessageParam[]): Promise<{
14
- replay: string;
14
+ type: "reply";
15
+ message: string;
15
16
  } | {
16
- exit: ExitReason;
17
+ type: "exit";
18
+ reason: ExitReason;
17
19
  }>;
18
20
  continueTask(userMessage: string): Promise<ExitReason>;
19
21
  protected abstract onBeforeInvokeTool(name: string, args: Record<string, string>): Promise<ToolResponse | undefined>;
package/dist/index.js CHANGED
@@ -2257,11 +2257,11 @@ ${agents}`;
2257
2257
  }
2258
2258
  const response = await this.#request(nextRequest);
2259
2259
  const resp = await this.#handleResponse(response);
2260
- if ("exit" in resp) {
2261
- this.#callback({ kind: "EndTask" /* EndTask */, agent: this, exitReason: resp.exit });
2262
- return resp.exit;
2260
+ if (resp.type === "exit") {
2261
+ this.#callback({ kind: "EndTask" /* EndTask */, agent: this, exitReason: resp.reason });
2262
+ return resp.reason;
2263
2263
  }
2264
- nextRequest = resp.replay;
2264
+ nextRequest = resp.message;
2265
2265
  }
2266
2266
  }
2267
2267
  async continueTask(userMessage) {
@@ -2333,7 +2333,7 @@ ${agents}`;
2333
2333
  if (toolReponses.length > 0) {
2334
2334
  break outer;
2335
2335
  }
2336
- return { exit: toolResp };
2336
+ return { type: "exit", reason: toolResp };
2337
2337
  case "Invalid" /* Invalid */:
2338
2338
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
2339
2339
  toolReponses.push({ tool: content.name, response: toolResp.message });
@@ -2344,7 +2344,7 @@ ${agents}`;
2344
2344
  break outer;
2345
2345
  case "Interrupted" /* Interrupted */:
2346
2346
  await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
2347
- return { exit: toolResp };
2347
+ return { type: "exit", reason: toolResp };
2348
2348
  case "HandOver" /* HandOver */:
2349
2349
  if (toolReponses.length > 0) {
2350
2350
  break outer;
@@ -2358,7 +2358,7 @@ ${agents}`;
2358
2358
  context: toolResp.context,
2359
2359
  files: toolResp.files
2360
2360
  });
2361
- return { exit: toolResp };
2361
+ return { type: "exit", reason: toolResp };
2362
2362
  case "Delegate" /* Delegate */:
2363
2363
  if (toolReponses.length > 0) {
2364
2364
  continue;
@@ -2372,17 +2372,17 @@ ${agents}`;
2372
2372
  context: toolResp.context,
2373
2373
  files: toolResp.files
2374
2374
  });
2375
- return { exit: toolResp };
2375
+ return { type: "exit", reason: toolResp };
2376
2376
  }
2377
2377
  break;
2378
2378
  }
2379
2379
  }
2380
2380
  }
2381
2381
  if (toolReponses.length === 0) {
2382
- return { replay: responsePrompts.requireUseTool };
2382
+ return { type: "reply", message: responsePrompts.requireUseTool };
2383
2383
  }
2384
2384
  const finalResp = toolReponses.map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join("\n\n");
2385
- return { replay: finalResp };
2385
+ return { type: "reply", message: finalResp };
2386
2386
  }
2387
2387
  async #invokeTool(name, args) {
2388
2388
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",