@polka-codes/cli-shared 0.7.19 → 0.7.20
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 +13 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31205,6 +31205,7 @@ ${agents}`;
|
|
|
31205
31205
|
}
|
|
31206
31206
|
async#handleResponse(response) {
|
|
31207
31207
|
const toolReponses = [];
|
|
31208
|
+
let hasPause = false;
|
|
31208
31209
|
outer:
|
|
31209
31210
|
for (const content of response) {
|
|
31210
31211
|
switch (content.type) {
|
|
@@ -31216,7 +31217,7 @@ ${agents}`;
|
|
|
31216
31217
|
switch (toolResp.type) {
|
|
31217
31218
|
case "Reply" /* Reply */:
|
|
31218
31219
|
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
31219
|
-
toolReponses.push({ tool: content.name, response: toolResp.message });
|
|
31220
|
+
toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
31220
31221
|
break;
|
|
31221
31222
|
case "Exit" /* Exit */:
|
|
31222
31223
|
if (toolReponses.length > 0) {
|
|
@@ -31225,11 +31226,11 @@ ${agents}`;
|
|
|
31225
31226
|
return { type: "exit", reason: toolResp };
|
|
31226
31227
|
case "Invalid" /* Invalid */:
|
|
31227
31228
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
31228
|
-
toolReponses.push({ tool: content.name, response: toolResp.message });
|
|
31229
|
+
toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
31229
31230
|
break outer;
|
|
31230
31231
|
case "Error" /* Error */:
|
|
31231
31232
|
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
31232
|
-
toolReponses.push({ tool: content.name, response: toolResp.message });
|
|
31233
|
+
toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
31233
31234
|
break outer;
|
|
31234
31235
|
case "Interrupted" /* Interrupted */:
|
|
31235
31236
|
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
@@ -31274,15 +31275,23 @@ ${agents}`;
|
|
|
31274
31275
|
});
|
|
31275
31276
|
return { type: "exit", reason: delegateResp };
|
|
31276
31277
|
}
|
|
31278
|
+
case "Pause" /* Pause */: {
|
|
31279
|
+
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
31280
|
+
toolReponses.push({ type: "pause", tool: content.name, object: toolResp.object });
|
|
31281
|
+
hasPause = true;
|
|
31282
|
+
}
|
|
31277
31283
|
}
|
|
31278
31284
|
break;
|
|
31279
31285
|
}
|
|
31280
31286
|
}
|
|
31281
31287
|
}
|
|
31288
|
+
if (hasPause) {
|
|
31289
|
+
return { type: "exit", reason: { type: "Pause", responses: toolReponses } };
|
|
31290
|
+
}
|
|
31282
31291
|
if (toolReponses.length === 0) {
|
|
31283
31292
|
return { type: "reply", message: responsePrompts.requireUseTool };
|
|
31284
31293
|
}
|
|
31285
|
-
const finalResp = toolReponses.map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
|
|
31294
|
+
const finalResp = toolReponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
|
|
31286
31295
|
|
|
31287
31296
|
`);
|
|
31288
31297
|
return { type: "reply", message: finalResp };
|