@polka-codes/core 0.7.22 → 0.7.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 +5 -4
- package/dist/index.js +7 -14
- package/package.json +1 -1
|
@@ -7,12 +7,12 @@ declare abstract class AgentBase {
|
|
|
7
7
|
protected readonly ai: AiServiceBase;
|
|
8
8
|
protected readonly config: Readonly<AgentBaseConfig>;
|
|
9
9
|
protected readonly handlers: Record<string, FullToolInfo>;
|
|
10
|
-
constructor(name: string, ai: AiServiceBase, config: AgentBaseConfig
|
|
10
|
+
constructor(name: string, ai: AiServiceBase, config: AgentBaseConfig);
|
|
11
11
|
get messages(): Readonly<MessageParam[]>;
|
|
12
|
-
setMessages(messages: MessageParam[]): void;
|
|
12
|
+
setMessages(messages: Readonly<MessageParam[]>): void;
|
|
13
13
|
start(prompt: string): Promise<ExitReason>;
|
|
14
|
-
step(
|
|
15
|
-
handleStepResponse(response: AssistantMessageContent[]
|
|
14
|
+
step(prompt: string): Promise<AssistantMessageContent[]>;
|
|
15
|
+
handleStepResponse(response: AssistantMessageContent[]): Promise<{
|
|
16
16
|
type: "reply";
|
|
17
17
|
message: string;
|
|
18
18
|
} | {
|
|
@@ -2142,6 +2142,7 @@ export { TaskEventCallback as TaskEventCallback_alias_2 }
|
|
|
2142
2142
|
*/
|
|
2143
2143
|
declare interface TaskEventEndRequest extends TaskEventBase {
|
|
2144
2144
|
kind: TaskEventKind.EndRequest;
|
|
2145
|
+
message: string;
|
|
2145
2146
|
}
|
|
2146
2147
|
export { TaskEventEndRequest }
|
|
2147
2148
|
export { TaskEventEndRequest as TaskEventEndRequest_alias_1 }
|
package/dist/index.js
CHANGED
|
@@ -2211,11 +2211,10 @@ var AgentBase = class {
|
|
|
2211
2211
|
ai;
|
|
2212
2212
|
config;
|
|
2213
2213
|
handlers;
|
|
2214
|
-
#messages;
|
|
2214
|
+
#messages = [];
|
|
2215
2215
|
#originalTask;
|
|
2216
|
-
constructor(name, ai, config
|
|
2216
|
+
constructor(name, ai, config) {
|
|
2217
2217
|
this.ai = ai;
|
|
2218
|
-
this.#messages = messages;
|
|
2219
2218
|
if (config.agents && config.agents.length > 0) {
|
|
2220
2219
|
const agents = agentsPrompt(config.agents, name);
|
|
2221
2220
|
config.systemPrompt += `
|
|
@@ -2232,7 +2231,7 @@ ${agents}`;
|
|
|
2232
2231
|
return this.#messages;
|
|
2233
2232
|
}
|
|
2234
2233
|
setMessages(messages) {
|
|
2235
|
-
this.#messages = messages;
|
|
2234
|
+
this.#messages = [...messages];
|
|
2236
2235
|
}
|
|
2237
2236
|
async #callback(event) {
|
|
2238
2237
|
await this.config.callback?.(event);
|
|
@@ -2242,19 +2241,13 @@ ${agents}`;
|
|
|
2242
2241
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
2243
2242
|
return await this.#processLoop(prompt5);
|
|
2244
2243
|
}
|
|
2245
|
-
async step(
|
|
2246
|
-
if (messages) {
|
|
2247
|
-
this.#messages = messages;
|
|
2248
|
-
}
|
|
2244
|
+
async step(prompt5) {
|
|
2249
2245
|
if (this.#messages.length === 0) {
|
|
2250
2246
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
2251
2247
|
}
|
|
2252
|
-
return await this.#request(
|
|
2248
|
+
return await this.#request(prompt5);
|
|
2253
2249
|
}
|
|
2254
|
-
async handleStepResponse(response
|
|
2255
|
-
if (messages) {
|
|
2256
|
-
this.#messages = messages;
|
|
2257
|
-
}
|
|
2250
|
+
async handleStepResponse(response) {
|
|
2258
2251
|
return this.#handleResponse(response);
|
|
2259
2252
|
}
|
|
2260
2253
|
async #processLoop(userMessage) {
|
|
@@ -2321,7 +2314,7 @@ ${agents}`;
|
|
|
2321
2314
|
content: currentAssistantMessage
|
|
2322
2315
|
});
|
|
2323
2316
|
const ret = parseAssistantMessage(currentAssistantMessage, this.config.tools, this.config.toolNamePrefix);
|
|
2324
|
-
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this });
|
|
2317
|
+
await this.#callback({ kind: "EndRequest" /* EndRequest */, agent: this, message: currentAssistantMessage });
|
|
2325
2318
|
return ret;
|
|
2326
2319
|
}
|
|
2327
2320
|
async #handleResponse(response) {
|