@polka-codes/core 0.7.11 → 0.7.13
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 +15 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -2
- package/package.json +1 -1
|
@@ -7,8 +7,16 @@ declare abstract class AgentBase {
|
|
|
7
7
|
protected readonly config: Readonly<AgentBaseConfig>;
|
|
8
8
|
protected readonly handlers: Record<string, FullToolInfo>;
|
|
9
9
|
protected readonly messages: MessageParam[];
|
|
10
|
-
constructor(name: string, ai: AiServiceBase, config: AgentBaseConfig);
|
|
10
|
+
constructor(name: string, ai: AiServiceBase, config: AgentBaseConfig, messages?: MessageParam[]);
|
|
11
11
|
start(prompt: string): Promise<ExitReason>;
|
|
12
|
+
step(promp: string): Promise<AssistantMessageContent[] | {
|
|
13
|
+
type: string;
|
|
14
|
+
}>;
|
|
15
|
+
handleStepResponse(response: AssistantMessageContent[]): Promise<{
|
|
16
|
+
replay: string;
|
|
17
|
+
} | {
|
|
18
|
+
exit: ExitReason;
|
|
19
|
+
}>;
|
|
12
20
|
continueTask(userMessage: string): Promise<ExitReason>;
|
|
13
21
|
protected abstract onBeforeInvokeTool(name: string, args: Record<string, string>): Promise<ToolResponse | undefined>;
|
|
14
22
|
get model(): {
|
|
@@ -1422,6 +1430,7 @@ export { getAvailableTools as getAvailableTools_alias_1 }
|
|
|
1422
1430
|
declare const getBoolean: <T extends string>(args: Partial<Record<T, string>>, name: T, defaultValue?: boolean) => boolean;
|
|
1423
1431
|
export { getBoolean }
|
|
1424
1432
|
export { getBoolean as getBoolean_alias_1 }
|
|
1433
|
+
export { getBoolean as getBoolean_alias_2 }
|
|
1425
1434
|
|
|
1426
1435
|
declare type GetInput<T> = T extends AiToolDefinition<infer Input, any> ? Input : never;
|
|
1427
1436
|
export { GetInput }
|
|
@@ -1431,6 +1440,7 @@ export { GetInput as GetInput_alias_2 }
|
|
|
1431
1440
|
declare const getInt: <T extends string>(args: Partial<Record<T, string>>, name: T, defaultValue?: number) => number;
|
|
1432
1441
|
export { getInt }
|
|
1433
1442
|
export { getInt as getInt_alias_1 }
|
|
1443
|
+
export { getInt as getInt_alias_2 }
|
|
1434
1444
|
|
|
1435
1445
|
declare type GetOutput<T> = T extends AiToolDefinition<any, infer Output> ? Output : never;
|
|
1436
1446
|
export { GetOutput }
|
|
@@ -1440,10 +1450,12 @@ export { GetOutput as GetOutput_alias_2 }
|
|
|
1440
1450
|
declare const getString: <T extends string>(args: Partial<Partial<Record<T, string>>>, name: T, defaultValue?: string) => string;
|
|
1441
1451
|
export { getString }
|
|
1442
1452
|
export { getString as getString_alias_1 }
|
|
1453
|
+
export { getString as getString_alias_2 }
|
|
1443
1454
|
|
|
1444
1455
|
declare const getStringArray: <T extends string>(args: Partial<Record<T, string>>, name: T, defaultValue?: string[]) => string[];
|
|
1445
1456
|
export { getStringArray }
|
|
1446
1457
|
export { getStringArray as getStringArray_alias_1 }
|
|
1458
|
+
export { getStringArray as getStringArray_alias_2 }
|
|
1447
1459
|
|
|
1448
1460
|
export declare const handler: ToolHandler<typeof toolInfo, InteractionProvider>;
|
|
1449
1461
|
|
|
@@ -1753,6 +1765,7 @@ export { PermissionLevel }
|
|
|
1753
1765
|
export { PermissionLevel as PermissionLevel_alias_1 }
|
|
1754
1766
|
|
|
1755
1767
|
declare const replaceInFile_2: (fileContent: string, diff: string) => Promise<string>;
|
|
1768
|
+
export { replaceInFile_2 as replaceInFileHelper }
|
|
1756
1769
|
export { replaceInFile_2 as replaceInFile_alias_3 }
|
|
1757
1770
|
export { replaceInFile_2 as replaceInFile_alias_4 }
|
|
1758
1771
|
|
|
@@ -2387,6 +2400,7 @@ export { ToolResponseError as ToolResponseError_alias_1 }
|
|
|
2387
2400
|
declare type ToolResponseExit = {
|
|
2388
2401
|
type: ToolResponseType.Exit;
|
|
2389
2402
|
message: string;
|
|
2403
|
+
object?: any;
|
|
2390
2404
|
};
|
|
2391
2405
|
export { ToolResponseExit }
|
|
2392
2406
|
export { ToolResponseExit as ToolResponseExit_alias_1 }
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { replaceInFileHelper } from './_tsup-dts-rollup.js';
|
|
1
2
|
export { AiServiceProvider } from './_tsup-dts-rollup.js';
|
|
2
3
|
export { defaultModels } from './_tsup-dts-rollup.js';
|
|
3
4
|
export { createService } from './_tsup-dts-rollup.js';
|
|
@@ -104,3 +105,7 @@ export { ToolResponseDelegate } from './_tsup-dts-rollup.js';
|
|
|
104
105
|
export { ToolResponse } from './_tsup-dts-rollup.js';
|
|
105
106
|
export { ToolHandler } from './_tsup-dts-rollup.js';
|
|
106
107
|
export { getAvailableTools_alias_1 as getAvailableTools } from './_tsup-dts-rollup.js';
|
|
108
|
+
export { getString } from './_tsup-dts-rollup.js';
|
|
109
|
+
export { getStringArray } from './_tsup-dts-rollup.js';
|
|
110
|
+
export { getBoolean } from './_tsup-dts-rollup.js';
|
|
111
|
+
export { getInt } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -2185,9 +2185,10 @@ var AgentBase = class {
|
|
|
2185
2185
|
ai;
|
|
2186
2186
|
config;
|
|
2187
2187
|
handlers;
|
|
2188
|
-
messages
|
|
2189
|
-
constructor(name, ai, config) {
|
|
2188
|
+
messages;
|
|
2189
|
+
constructor(name, ai, config, messages = []) {
|
|
2190
2190
|
this.ai = ai;
|
|
2191
|
+
this.messages = messages;
|
|
2191
2192
|
if (config.agents && config.agents.length > 0) {
|
|
2192
2193
|
const agents = agentsPrompt(config.agents, name);
|
|
2193
2194
|
config.systemPrompt += `
|
|
@@ -2207,6 +2208,19 @@ ${agents}`;
|
|
|
2207
2208
|
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
2208
2209
|
return await this.#processLoop(prompt5);
|
|
2209
2210
|
}
|
|
2211
|
+
async step(promp) {
|
|
2212
|
+
if (this.messages.length === 0) {
|
|
2213
|
+
this.#callback({ kind: "StartTask" /* StartTask */, agent: this, systemPrompt: this.config.systemPrompt });
|
|
2214
|
+
}
|
|
2215
|
+
if (this.ai.usageMeter.isLimitExceeded().result) {
|
|
2216
|
+
this.#callback({ kind: "UsageExceeded" /* UsageExceeded */, agent: this });
|
|
2217
|
+
return { type: "UsageExceeded" };
|
|
2218
|
+
}
|
|
2219
|
+
return await this.#request(promp);
|
|
2220
|
+
}
|
|
2221
|
+
async handleStepResponse(response) {
|
|
2222
|
+
return this.#handleResponse(response);
|
|
2223
|
+
}
|
|
2210
2224
|
async #processLoop(userMessage) {
|
|
2211
2225
|
let nextRequest = userMessage;
|
|
2212
2226
|
while (true) {
|
|
@@ -3407,6 +3421,10 @@ export {
|
|
|
3407
3421
|
generateGithubPullRequestDetails,
|
|
3408
3422
|
generateProjectConfig,
|
|
3409
3423
|
getAvailableTools,
|
|
3424
|
+
getBoolean,
|
|
3425
|
+
getInt,
|
|
3426
|
+
getString,
|
|
3427
|
+
getStringArray,
|
|
3410
3428
|
handOver_default as handOver,
|
|
3411
3429
|
listCodeDefinitionNames_default as listCodeDefinitionNames,
|
|
3412
3430
|
listFiles_default as listFiles,
|
|
@@ -3418,6 +3436,7 @@ export {
|
|
|
3418
3436
|
removeFile_default as removeFile,
|
|
3419
3437
|
renameFile_default as renameFile,
|
|
3420
3438
|
replaceInFile_default as replaceInFile,
|
|
3439
|
+
replaceInFile as replaceInFileHelper,
|
|
3421
3440
|
responsePrompts,
|
|
3422
3441
|
searchFiles_default as searchFiles,
|
|
3423
3442
|
systemInformation,
|