@polka-codes/core 0.9.23 → 0.9.24
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/_tsup-dts-rollup.d.ts +28 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.js +59 -37
- package/package.json +1 -1
|
@@ -1331,7 +1331,7 @@ export { systemInformation as systemInformation_alias_2 }
|
|
|
1331
1331
|
/**
|
|
1332
1332
|
* Union type of all possible task events
|
|
1333
1333
|
*/
|
|
1334
|
-
declare type TaskEvent = TaskEventStartTask | TaskEventStartRequest | TaskEventEndRequest | TaskEventUsage | TaskEventText |
|
|
1334
|
+
declare type TaskEvent = TaskEventStartTask | TaskEventStartRequest | TaskEventEndRequest | TaskEventUsage | TaskEventText | TaskEventToolUse | TaskEventToolResult | TaskEventToolError | TaskEventToolPause | TaskEventToolHandOverDelegate | TaskEventUsageExceeded | TaskEventEndTask;
|
|
1335
1335
|
export { TaskEvent }
|
|
1336
1336
|
export { TaskEvent as TaskEvent_alias_1 }
|
|
1337
1337
|
export { TaskEvent as TaskEvent_alias_2 }
|
|
@@ -1432,17 +1432,14 @@ export { TaskEventText }
|
|
|
1432
1432
|
export { TaskEventText as TaskEventText_alias_1 }
|
|
1433
1433
|
export { TaskEventText as TaskEventText_alias_2 }
|
|
1434
1434
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
*/
|
|
1438
|
-
declare interface TaskEventTool extends TaskEventBase {
|
|
1439
|
-
kind: TaskEventKind.ToolUse | TaskEventKind.ToolReply | TaskEventKind.ToolInvalid | TaskEventKind.ToolError | TaskEventKind.ToolInterrupted;
|
|
1435
|
+
declare interface TaskEventToolError extends TaskEventBase {
|
|
1436
|
+
kind: TaskEventKind.ToolError;
|
|
1440
1437
|
tool: string;
|
|
1441
|
-
|
|
1438
|
+
error: ToolResponseError | ToolResponseResult;
|
|
1442
1439
|
}
|
|
1443
|
-
export {
|
|
1444
|
-
export {
|
|
1445
|
-
export {
|
|
1440
|
+
export { TaskEventToolError }
|
|
1441
|
+
export { TaskEventToolError as TaskEventToolError_alias_1 }
|
|
1442
|
+
export { TaskEventToolError as TaskEventToolError_alias_2 }
|
|
1446
1443
|
|
|
1447
1444
|
/**
|
|
1448
1445
|
* Event for tool handover
|
|
@@ -1468,6 +1465,27 @@ export { TaskEventToolPause }
|
|
|
1468
1465
|
export { TaskEventToolPause as TaskEventToolPause_alias_1 }
|
|
1469
1466
|
export { TaskEventToolPause as TaskEventToolPause_alias_2 }
|
|
1470
1467
|
|
|
1468
|
+
declare interface TaskEventToolResult extends TaskEventBase {
|
|
1469
|
+
kind: TaskEventKind.ToolReply | TaskEventKind.ToolInvalid | TaskEventKind.ToolInterrupted;
|
|
1470
|
+
tool: string;
|
|
1471
|
+
content: ToolResponseResult;
|
|
1472
|
+
}
|
|
1473
|
+
export { TaskEventToolResult }
|
|
1474
|
+
export { TaskEventToolResult as TaskEventToolResult_alias_1 }
|
|
1475
|
+
export { TaskEventToolResult as TaskEventToolResult_alias_2 }
|
|
1476
|
+
|
|
1477
|
+
/**
|
|
1478
|
+
* Event for tool-related updates
|
|
1479
|
+
*/
|
|
1480
|
+
declare interface TaskEventToolUse extends TaskEventBase {
|
|
1481
|
+
kind: TaskEventKind.ToolUse;
|
|
1482
|
+
tool: string;
|
|
1483
|
+
params: Record<string, any>;
|
|
1484
|
+
}
|
|
1485
|
+
export { TaskEventToolUse }
|
|
1486
|
+
export { TaskEventToolUse as TaskEventToolUse_alias_1 }
|
|
1487
|
+
export { TaskEventToolUse as TaskEventToolUse_alias_2 }
|
|
1488
|
+
|
|
1471
1489
|
/**
|
|
1472
1490
|
* Event for API usage updates
|
|
1473
1491
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export { TaskEventStartRequest } from './_tsup-dts-rollup.js';
|
|
|
9
9
|
export { TaskEventEndRequest } from './_tsup-dts-rollup.js';
|
|
10
10
|
export { TaskEventUsage } from './_tsup-dts-rollup.js';
|
|
11
11
|
export { TaskEventText } from './_tsup-dts-rollup.js';
|
|
12
|
-
export {
|
|
12
|
+
export { TaskEventToolUse } from './_tsup-dts-rollup.js';
|
|
13
|
+
export { TaskEventToolResult } from './_tsup-dts-rollup.js';
|
|
14
|
+
export { TaskEventToolError } from './_tsup-dts-rollup.js';
|
|
13
15
|
export { TaskEventToolPause } from './_tsup-dts-rollup.js';
|
|
14
16
|
export { TaskEventToolHandOverDelegate } from './_tsup-dts-rollup.js';
|
|
15
17
|
export { TaskEventUsageExceeded } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -2236,12 +2236,13 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
2236
2236
|
return resp;
|
|
2237
2237
|
};
|
|
2238
2238
|
let hasPause = false;
|
|
2239
|
+
const toolUseContents = response.filter((c) => c.type === "tool_use");
|
|
2239
2240
|
outer: for (const content of response) {
|
|
2240
2241
|
switch (content.type) {
|
|
2241
2242
|
case "text":
|
|
2242
2243
|
break;
|
|
2243
2244
|
case "tool_use": {
|
|
2244
|
-
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name,
|
|
2245
|
+
await this.#callback({ kind: "ToolUse" /* ToolUse */, agent: this, tool: content.name, params: content.params });
|
|
2245
2246
|
const toolResp = await this.#invokeTool(content.name, content.params);
|
|
2246
2247
|
switch (toolResp.type) {
|
|
2247
2248
|
case "Reply" /* Reply */: {
|
|
@@ -2250,52 +2251,73 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
2250
2251
|
break;
|
|
2251
2252
|
}
|
|
2252
2253
|
case "Exit" /* Exit */:
|
|
2254
|
+
case "HandOver" /* HandOver */:
|
|
2255
|
+
case "Delegate" /* Delegate */: {
|
|
2256
|
+
if (this.config.toolFormat === "native" && toolUseContents.length > 1) {
|
|
2257
|
+
const message = {
|
|
2258
|
+
type: "Error" /* Error */,
|
|
2259
|
+
message: {
|
|
2260
|
+
type: "error-text",
|
|
2261
|
+
value: `Error: The tool '${content.name}' must be called alone, but it was called with other tools.`
|
|
2262
|
+
},
|
|
2263
|
+
canRetry: false
|
|
2264
|
+
};
|
|
2265
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: message });
|
|
2266
|
+
toolResponses.push({
|
|
2267
|
+
type: "response",
|
|
2268
|
+
tool: content.name,
|
|
2269
|
+
response: processResponse(message.message),
|
|
2270
|
+
id: content.id
|
|
2271
|
+
});
|
|
2272
|
+
break;
|
|
2273
|
+
}
|
|
2253
2274
|
if (toolResponses.length > 0) {
|
|
2254
2275
|
break outer;
|
|
2255
2276
|
}
|
|
2256
|
-
|
|
2277
|
+
if (toolResp.type === "Exit" /* Exit */) {
|
|
2278
|
+
return { type: "exit", reason: toolResp };
|
|
2279
|
+
}
|
|
2280
|
+
if (toolResp.type === "HandOver" /* HandOver */) {
|
|
2281
|
+
await this.#callback({
|
|
2282
|
+
kind: "ToolHandOver" /* ToolHandOver */,
|
|
2283
|
+
agent: this,
|
|
2284
|
+
tool: content.name,
|
|
2285
|
+
agentName: toolResp.agentName,
|
|
2286
|
+
task: toolResp.task,
|
|
2287
|
+
context: toolResp.context,
|
|
2288
|
+
files: toolResp.files
|
|
2289
|
+
});
|
|
2290
|
+
return { type: "exit", reason: toolResp };
|
|
2291
|
+
}
|
|
2292
|
+
if (toolResp.type === "Delegate" /* Delegate */) {
|
|
2293
|
+
await this.#callback({
|
|
2294
|
+
kind: "ToolDelegate" /* ToolDelegate */,
|
|
2295
|
+
agent: this,
|
|
2296
|
+
tool: content.name,
|
|
2297
|
+
agentName: toolResp.agentName,
|
|
2298
|
+
task: toolResp.task,
|
|
2299
|
+
context: toolResp.context,
|
|
2300
|
+
files: toolResp.files
|
|
2301
|
+
});
|
|
2302
|
+
return { type: "exit", reason: toolResp };
|
|
2303
|
+
}
|
|
2304
|
+
break;
|
|
2305
|
+
}
|
|
2257
2306
|
case "Invalid" /* Invalid */: {
|
|
2258
2307
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name, content: toolResp.message });
|
|
2259
2308
|
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
2260
|
-
|
|
2261
|
-
}
|
|
2262
|
-
case "Error" /* Error */: {
|
|
2263
|
-
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, content: toolResp.message });
|
|
2264
|
-
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
2265
|
-
break outer;
|
|
2266
|
-
}
|
|
2267
|
-
case "Interrupted" /* Interrupted */:
|
|
2268
|
-
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name, content: toolResp.message });
|
|
2269
|
-
return { type: "exit", reason: toolResp };
|
|
2270
|
-
case "HandOver" /* HandOver */: {
|
|
2271
|
-
if (toolResponses.length > 0) {
|
|
2309
|
+
if (this.config.toolFormat !== "native") {
|
|
2272
2310
|
break outer;
|
|
2273
2311
|
}
|
|
2274
|
-
|
|
2275
|
-
kind: "ToolHandOver" /* ToolHandOver */,
|
|
2276
|
-
agent: this,
|
|
2277
|
-
tool: content.name,
|
|
2278
|
-
agentName: toolResp.agentName,
|
|
2279
|
-
task: toolResp.task,
|
|
2280
|
-
context: toolResp.context,
|
|
2281
|
-
files: toolResp.files
|
|
2282
|
-
});
|
|
2283
|
-
return { type: "exit", reason: toolResp };
|
|
2312
|
+
break;
|
|
2284
2313
|
}
|
|
2285
|
-
case "
|
|
2286
|
-
|
|
2314
|
+
case "Error" /* Error */: {
|
|
2315
|
+
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name, error: toolResp.message });
|
|
2316
|
+
toolResponses.push({ type: "response", tool: content.name, response: processResponse(toolResp.message), id: content.id });
|
|
2317
|
+
if (this.config.toolFormat !== "native") {
|
|
2287
2318
|
break outer;
|
|
2288
2319
|
}
|
|
2289
|
-
|
|
2290
|
-
kind: "ToolDelegate" /* ToolDelegate */,
|
|
2291
|
-
agent: this,
|
|
2292
|
-
tool: content.name,
|
|
2293
|
-
agentName: toolResp.agentName,
|
|
2294
|
-
task: toolResp.task,
|
|
2295
|
-
context: toolResp.context,
|
|
2296
|
-
files: toolResp.files
|
|
2297
|
-
});
|
|
2298
|
-
return { type: "exit", reason: toolResp };
|
|
2320
|
+
break;
|
|
2299
2321
|
}
|
|
2300
2322
|
case "Pause" /* Pause */: {
|
|
2301
2323
|
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
@@ -3743,7 +3765,7 @@ var handler15 = async (provider, args) => {
|
|
|
3743
3765
|
commandParts.push(commitRange);
|
|
3744
3766
|
}
|
|
3745
3767
|
if (file) {
|
|
3746
|
-
commandParts.push("--", file);
|
|
3768
|
+
commandParts.push("--", `'${file}'`);
|
|
3747
3769
|
}
|
|
3748
3770
|
const command = commandParts.join(" ");
|
|
3749
3771
|
try {
|