@polka-codes/core 0.7.17 → 0.7.19
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 +4 -1
- package/dist/index.js +42 -14
- package/package.json +1 -1
|
@@ -1972,7 +1972,7 @@ export { MultiAgent as MultiAgent_alias_2 }
|
|
|
1972
1972
|
|
|
1973
1973
|
declare type MultiAgentConfig = {
|
|
1974
1974
|
createAgent: (name: string) => Promise<AgentBase>;
|
|
1975
|
-
getPrompt?: (name: string, task: string, context?: string, files?: string[]) => Promise<string>;
|
|
1975
|
+
getPrompt?: (name: string, task: string, context?: string, files?: string[], originalTask?: string) => Promise<string>;
|
|
1976
1976
|
};
|
|
1977
1977
|
export { MultiAgentConfig }
|
|
1978
1978
|
export { MultiAgentConfig as MultiAgentConfig_alias_1 }
|
|
@@ -2232,6 +2232,7 @@ declare interface TaskEventToolHandOverDelegate extends TaskEventBase {
|
|
|
2232
2232
|
task: string;
|
|
2233
2233
|
context?: string;
|
|
2234
2234
|
files?: string[];
|
|
2235
|
+
originalTask?: string;
|
|
2235
2236
|
}
|
|
2236
2237
|
export { TaskEventToolHandOverDelegate }
|
|
2237
2238
|
export { TaskEventToolHandOverDelegate as TaskEventToolHandOverDelegate_alias_1 }
|
|
@@ -2689,6 +2690,7 @@ declare type ToolResponseDelegate = {
|
|
|
2689
2690
|
task: string;
|
|
2690
2691
|
context?: string;
|
|
2691
2692
|
files?: string[];
|
|
2693
|
+
originalTask?: string;
|
|
2692
2694
|
};
|
|
2693
2695
|
export { ToolResponseDelegate }
|
|
2694
2696
|
export { ToolResponseDelegate as ToolResponseDelegate_alias_1 }
|
|
@@ -2715,6 +2717,7 @@ declare type ToolResponseHandOver = {
|
|
|
2715
2717
|
task: string;
|
|
2716
2718
|
context?: string;
|
|
2717
2719
|
files?: string[];
|
|
2720
|
+
originalTask?: string;
|
|
2718
2721
|
};
|
|
2719
2722
|
export { ToolResponseHandOver }
|
|
2720
2723
|
export { ToolResponseHandOver as ToolResponseHandOver_alias_1 }
|
package/dist/index.js
CHANGED
|
@@ -1219,6 +1219,7 @@ var handler3 = async (_provider, args) => {
|
|
|
1219
1219
|
task,
|
|
1220
1220
|
context,
|
|
1221
1221
|
files
|
|
1222
|
+
// originalTask will be set by AgentBase
|
|
1222
1223
|
};
|
|
1223
1224
|
};
|
|
1224
1225
|
var isAvailable3 = (_provider) => {
|
|
@@ -1814,6 +1815,7 @@ var handler11 = async (_provider, args) => {
|
|
|
1814
1815
|
task,
|
|
1815
1816
|
context,
|
|
1816
1817
|
files
|
|
1818
|
+
// originalTask will be set by AgentBase
|
|
1817
1819
|
};
|
|
1818
1820
|
};
|
|
1819
1821
|
var isAvailable11 = (_provider) => {
|
|
@@ -2208,6 +2210,7 @@ var AgentBase = class {
|
|
|
2208
2210
|
config;
|
|
2209
2211
|
handlers;
|
|
2210
2212
|
#messages;
|
|
2213
|
+
#originalTask;
|
|
2211
2214
|
constructor(name, ai, config, messages = []) {
|
|
2212
2215
|
this.ai = ai;
|
|
2213
2216
|
this.#messages = messages;
|
|
@@ -2230,6 +2233,7 @@ ${agents}`;
|
|
|
2230
2233
|
await this.config.callback?.(event);
|
|
2231
2234
|
}
|
|
2232
2235
|
async start(prompt5) {
|
|
2236
|
+
this.#originalTask = prompt5;
|
|
2233
2237
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
2234
2238
|
return await this.#processLoop(prompt5);
|
|
2235
2239
|
}
|
|
@@ -2345,34 +2349,46 @@ ${agents}`;
|
|
|
2345
2349
|
case "Interrupted" /* Interrupted */:
|
|
2346
2350
|
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
2347
2351
|
return { type: "exit", reason: toolResp };
|
|
2348
|
-
case "HandOver" /* HandOver */:
|
|
2352
|
+
case "HandOver" /* HandOver */: {
|
|
2349
2353
|
if (toolReponses.length > 0) {
|
|
2350
2354
|
break outer;
|
|
2351
2355
|
}
|
|
2356
|
+
const handOverResp = {
|
|
2357
|
+
...toolResp,
|
|
2358
|
+
originalTask: this.#originalTask
|
|
2359
|
+
};
|
|
2352
2360
|
await this.#callback({
|
|
2353
2361
|
kind: "ToolHandOver" /* ToolHandOver */,
|
|
2354
2362
|
agent: this,
|
|
2355
2363
|
tool: content.name,
|
|
2356
|
-
agentName:
|
|
2357
|
-
task:
|
|
2358
|
-
context:
|
|
2359
|
-
files:
|
|
2364
|
+
agentName: handOverResp.agentName,
|
|
2365
|
+
task: handOverResp.task,
|
|
2366
|
+
context: handOverResp.context,
|
|
2367
|
+
files: handOverResp.files,
|
|
2368
|
+
originalTask: handOverResp.originalTask
|
|
2360
2369
|
});
|
|
2361
|
-
return { type: "exit", reason:
|
|
2362
|
-
|
|
2370
|
+
return { type: "exit", reason: handOverResp };
|
|
2371
|
+
}
|
|
2372
|
+
case "Delegate" /* Delegate */: {
|
|
2363
2373
|
if (toolReponses.length > 0) {
|
|
2364
2374
|
continue;
|
|
2365
2375
|
}
|
|
2376
|
+
const delegateResp = {
|
|
2377
|
+
...toolResp,
|
|
2378
|
+
originalTask: this.#originalTask
|
|
2379
|
+
};
|
|
2366
2380
|
await this.#callback({
|
|
2367
2381
|
kind: "ToolDelegate" /* ToolDelegate */,
|
|
2368
2382
|
agent: this,
|
|
2369
2383
|
tool: content.name,
|
|
2370
|
-
agentName:
|
|
2371
|
-
task:
|
|
2372
|
-
context:
|
|
2373
|
-
files:
|
|
2384
|
+
agentName: delegateResp.agentName,
|
|
2385
|
+
task: delegateResp.task,
|
|
2386
|
+
context: delegateResp.context,
|
|
2387
|
+
files: delegateResp.files,
|
|
2388
|
+
originalTask: delegateResp.originalTask
|
|
2374
2389
|
});
|
|
2375
|
-
return { type: "exit", reason:
|
|
2390
|
+
return { type: "exit", reason: delegateResp };
|
|
2391
|
+
}
|
|
2376
2392
|
}
|
|
2377
2393
|
break;
|
|
2378
2394
|
}
|
|
@@ -2974,11 +2990,23 @@ var MultiAgent = class {
|
|
|
2974
2990
|
switch (exitReason.type) {
|
|
2975
2991
|
case "HandOver" /* HandOver */: {
|
|
2976
2992
|
this.#agents.pop();
|
|
2977
|
-
const prompt5 = await this.#config.getPrompt?.(
|
|
2993
|
+
const prompt5 = await this.#config.getPrompt?.(
|
|
2994
|
+
exitReason.agentName,
|
|
2995
|
+
exitReason.task,
|
|
2996
|
+
exitReason.context,
|
|
2997
|
+
exitReason.files,
|
|
2998
|
+
exitReason.originalTask
|
|
2999
|
+
) ?? exitReason.task;
|
|
2978
3000
|
return await this.#startTask(exitReason.agentName, prompt5);
|
|
2979
3001
|
}
|
|
2980
3002
|
case "Delegate" /* Delegate */: {
|
|
2981
|
-
const prompt5 = await this.#config.getPrompt?.(
|
|
3003
|
+
const prompt5 = await this.#config.getPrompt?.(
|
|
3004
|
+
exitReason.agentName,
|
|
3005
|
+
exitReason.task,
|
|
3006
|
+
exitReason.context,
|
|
3007
|
+
exitReason.files,
|
|
3008
|
+
exitReason.originalTask
|
|
3009
|
+
) ?? exitReason.task;
|
|
2982
3010
|
const delegateResult = await this.#startTask(exitReason.agentName, prompt5);
|
|
2983
3011
|
switch (delegateResult.type) {
|
|
2984
3012
|
case "HandOver" /* HandOver */:
|