@polka-codes/core 0.7.16 → 0.7.18
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 +292 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +102 -14
- package/package.json +3 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Anthropic } from '@anthropic-ai/sdk';
|
|
2
2
|
import type OpenAI from 'openai';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
declare abstract class AgentBase {
|
|
5
6
|
#private;
|
|
@@ -392,6 +393,293 @@ export { CommandProvider }
|
|
|
392
393
|
export { CommandProvider as CommandProvider_alias_1 }
|
|
393
394
|
export { CommandProvider as CommandProvider_alias_2 }
|
|
394
395
|
|
|
396
|
+
declare type Config = z.infer<typeof configSchema>;
|
|
397
|
+
export { Config }
|
|
398
|
+
export { Config as Config_alias_1 }
|
|
399
|
+
|
|
400
|
+
declare const configSchema: z.ZodObject<{
|
|
401
|
+
agent: z.ZodOptional<z.ZodString>;
|
|
402
|
+
prices: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
403
|
+
inputPrice: z.ZodOptional<z.ZodNumber>;
|
|
404
|
+
outputPrice: z.ZodOptional<z.ZodNumber>;
|
|
405
|
+
cacheWritesPrice: z.ZodOptional<z.ZodNumber>;
|
|
406
|
+
cacheReadsPrice: z.ZodOptional<z.ZodNumber>;
|
|
407
|
+
}, "strip", z.ZodTypeAny, {
|
|
408
|
+
inputPrice?: number | undefined;
|
|
409
|
+
outputPrice?: number | undefined;
|
|
410
|
+
cacheWritesPrice?: number | undefined;
|
|
411
|
+
cacheReadsPrice?: number | undefined;
|
|
412
|
+
}, {
|
|
413
|
+
inputPrice?: number | undefined;
|
|
414
|
+
outputPrice?: number | undefined;
|
|
415
|
+
cacheWritesPrice?: number | undefined;
|
|
416
|
+
cacheReadsPrice?: number | undefined;
|
|
417
|
+
}>>>>;
|
|
418
|
+
providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
419
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
420
|
+
defaultModel: z.ZodOptional<z.ZodString>;
|
|
421
|
+
defaultParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
422
|
+
}, "strip", z.ZodTypeAny, {
|
|
423
|
+
apiKey?: string | undefined;
|
|
424
|
+
defaultModel?: string | undefined;
|
|
425
|
+
defaultParameters?: Record<string, any> | undefined;
|
|
426
|
+
}, {
|
|
427
|
+
apiKey?: string | undefined;
|
|
428
|
+
defaultModel?: string | undefined;
|
|
429
|
+
defaultParameters?: Record<string, any> | undefined;
|
|
430
|
+
}>>>;
|
|
431
|
+
defaultProvider: z.ZodOptional<z.ZodString>;
|
|
432
|
+
defaultModel: z.ZodOptional<z.ZodString>;
|
|
433
|
+
defaultParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
434
|
+
maxMessageCount: z.ZodOptional<z.ZodNumber>;
|
|
435
|
+
budget: z.ZodOptional<z.ZodNumber>;
|
|
436
|
+
scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
437
|
+
command: z.ZodString;
|
|
438
|
+
description: z.ZodString;
|
|
439
|
+
}, "strip", z.ZodTypeAny, {
|
|
440
|
+
command: string;
|
|
441
|
+
description: string;
|
|
442
|
+
}, {
|
|
443
|
+
command: string;
|
|
444
|
+
description: string;
|
|
445
|
+
}>]>>>;
|
|
446
|
+
agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<z.objectUtil.extendShape<{
|
|
447
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
448
|
+
model: z.ZodOptional<z.ZodString>;
|
|
449
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
450
|
+
}, {
|
|
451
|
+
initialContext: z.ZodOptional<z.ZodObject<{
|
|
452
|
+
maxFileCount: z.ZodOptional<z.ZodNumber>;
|
|
453
|
+
excludes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
454
|
+
}, "strip", z.ZodTypeAny, {
|
|
455
|
+
maxFileCount?: number | undefined;
|
|
456
|
+
excludes?: string[] | undefined;
|
|
457
|
+
}, {
|
|
458
|
+
maxFileCount?: number | undefined;
|
|
459
|
+
excludes?: string[] | undefined;
|
|
460
|
+
}>>;
|
|
461
|
+
}>, "strip", z.ZodTypeAny, {
|
|
462
|
+
provider?: string | undefined;
|
|
463
|
+
model?: string | undefined;
|
|
464
|
+
parameters?: Record<string, any> | undefined;
|
|
465
|
+
initialContext?: {
|
|
466
|
+
maxFileCount?: number | undefined;
|
|
467
|
+
excludes?: string[] | undefined;
|
|
468
|
+
} | undefined;
|
|
469
|
+
}, {
|
|
470
|
+
provider?: string | undefined;
|
|
471
|
+
model?: string | undefined;
|
|
472
|
+
parameters?: Record<string, any> | undefined;
|
|
473
|
+
initialContext?: {
|
|
474
|
+
maxFileCount?: number | undefined;
|
|
475
|
+
excludes?: string[] | undefined;
|
|
476
|
+
} | undefined;
|
|
477
|
+
}>>>;
|
|
478
|
+
commands: z.ZodOptional<z.ZodObject<{
|
|
479
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
480
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
481
|
+
model: z.ZodOptional<z.ZodString>;
|
|
482
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
483
|
+
}, "strip", z.ZodTypeAny, {
|
|
484
|
+
provider?: string | undefined;
|
|
485
|
+
model?: string | undefined;
|
|
486
|
+
parameters?: Record<string, any> | undefined;
|
|
487
|
+
}, {
|
|
488
|
+
provider?: string | undefined;
|
|
489
|
+
model?: string | undefined;
|
|
490
|
+
parameters?: Record<string, any> | undefined;
|
|
491
|
+
}>>;
|
|
492
|
+
}, "strip", z.ZodObject<{
|
|
493
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
494
|
+
model: z.ZodOptional<z.ZodString>;
|
|
495
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
496
|
+
}, "strip", z.ZodTypeAny, {
|
|
497
|
+
provider?: string | undefined;
|
|
498
|
+
model?: string | undefined;
|
|
499
|
+
parameters?: Record<string, any> | undefined;
|
|
500
|
+
}, {
|
|
501
|
+
provider?: string | undefined;
|
|
502
|
+
model?: string | undefined;
|
|
503
|
+
parameters?: Record<string, any> | undefined;
|
|
504
|
+
}>, z.objectOutputType<{
|
|
505
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
506
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
507
|
+
model: z.ZodOptional<z.ZodString>;
|
|
508
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
509
|
+
}, "strip", z.ZodTypeAny, {
|
|
510
|
+
provider?: string | undefined;
|
|
511
|
+
model?: string | undefined;
|
|
512
|
+
parameters?: Record<string, any> | undefined;
|
|
513
|
+
}, {
|
|
514
|
+
provider?: string | undefined;
|
|
515
|
+
model?: string | undefined;
|
|
516
|
+
parameters?: Record<string, any> | undefined;
|
|
517
|
+
}>>;
|
|
518
|
+
}, z.ZodObject<{
|
|
519
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
520
|
+
model: z.ZodOptional<z.ZodString>;
|
|
521
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
522
|
+
}, "strip", z.ZodTypeAny, {
|
|
523
|
+
provider?: string | undefined;
|
|
524
|
+
model?: string | undefined;
|
|
525
|
+
parameters?: Record<string, any> | undefined;
|
|
526
|
+
}, {
|
|
527
|
+
provider?: string | undefined;
|
|
528
|
+
model?: string | undefined;
|
|
529
|
+
parameters?: Record<string, any> | undefined;
|
|
530
|
+
}>, "strip">, z.objectInputType<{
|
|
531
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
532
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
533
|
+
model: z.ZodOptional<z.ZodString>;
|
|
534
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
535
|
+
}, "strip", z.ZodTypeAny, {
|
|
536
|
+
provider?: string | undefined;
|
|
537
|
+
model?: string | undefined;
|
|
538
|
+
parameters?: Record<string, any> | undefined;
|
|
539
|
+
}, {
|
|
540
|
+
provider?: string | undefined;
|
|
541
|
+
model?: string | undefined;
|
|
542
|
+
parameters?: Record<string, any> | undefined;
|
|
543
|
+
}>>;
|
|
544
|
+
}, z.ZodObject<{
|
|
545
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
546
|
+
model: z.ZodOptional<z.ZodString>;
|
|
547
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
548
|
+
}, "strip", z.ZodTypeAny, {
|
|
549
|
+
provider?: string | undefined;
|
|
550
|
+
model?: string | undefined;
|
|
551
|
+
parameters?: Record<string, any> | undefined;
|
|
552
|
+
}, {
|
|
553
|
+
provider?: string | undefined;
|
|
554
|
+
model?: string | undefined;
|
|
555
|
+
parameters?: Record<string, any> | undefined;
|
|
556
|
+
}>, "strip">>>;
|
|
557
|
+
rules: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodArray<z.ZodString, "many">>, z.ZodString]>>;
|
|
558
|
+
excludeFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
559
|
+
}, "strict", z.ZodTypeAny, {
|
|
560
|
+
agent?: string | undefined;
|
|
561
|
+
prices?: Record<string, Record<string, {
|
|
562
|
+
inputPrice?: number | undefined;
|
|
563
|
+
outputPrice?: number | undefined;
|
|
564
|
+
cacheWritesPrice?: number | undefined;
|
|
565
|
+
cacheReadsPrice?: number | undefined;
|
|
566
|
+
}>> | undefined;
|
|
567
|
+
defaultModel?: string | undefined;
|
|
568
|
+
defaultParameters?: Record<string, any> | undefined;
|
|
569
|
+
providers?: Record<string, {
|
|
570
|
+
apiKey?: string | undefined;
|
|
571
|
+
defaultModel?: string | undefined;
|
|
572
|
+
defaultParameters?: Record<string, any> | undefined;
|
|
573
|
+
}> | undefined;
|
|
574
|
+
defaultProvider?: string | undefined;
|
|
575
|
+
maxMessageCount?: number | undefined;
|
|
576
|
+
budget?: number | undefined;
|
|
577
|
+
scripts?: Record<string, string | {
|
|
578
|
+
command: string;
|
|
579
|
+
description: string;
|
|
580
|
+
}> | undefined;
|
|
581
|
+
agents?: Record<string, {
|
|
582
|
+
provider?: string | undefined;
|
|
583
|
+
model?: string | undefined;
|
|
584
|
+
parameters?: Record<string, any> | undefined;
|
|
585
|
+
initialContext?: {
|
|
586
|
+
maxFileCount?: number | undefined;
|
|
587
|
+
excludes?: string[] | undefined;
|
|
588
|
+
} | undefined;
|
|
589
|
+
}> | undefined;
|
|
590
|
+
commands?: z.objectOutputType<{
|
|
591
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
592
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
593
|
+
model: z.ZodOptional<z.ZodString>;
|
|
594
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
595
|
+
}, "strip", z.ZodTypeAny, {
|
|
596
|
+
provider?: string | undefined;
|
|
597
|
+
model?: string | undefined;
|
|
598
|
+
parameters?: Record<string, any> | undefined;
|
|
599
|
+
}, {
|
|
600
|
+
provider?: string | undefined;
|
|
601
|
+
model?: string | undefined;
|
|
602
|
+
parameters?: Record<string, any> | undefined;
|
|
603
|
+
}>>;
|
|
604
|
+
}, z.ZodObject<{
|
|
605
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
606
|
+
model: z.ZodOptional<z.ZodString>;
|
|
607
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
608
|
+
}, "strip", z.ZodTypeAny, {
|
|
609
|
+
provider?: string | undefined;
|
|
610
|
+
model?: string | undefined;
|
|
611
|
+
parameters?: Record<string, any> | undefined;
|
|
612
|
+
}, {
|
|
613
|
+
provider?: string | undefined;
|
|
614
|
+
model?: string | undefined;
|
|
615
|
+
parameters?: Record<string, any> | undefined;
|
|
616
|
+
}>, "strip"> | undefined;
|
|
617
|
+
rules?: string | string[] | undefined;
|
|
618
|
+
excludeFiles?: string[] | undefined;
|
|
619
|
+
}, {
|
|
620
|
+
agent?: string | undefined;
|
|
621
|
+
prices?: Record<string, Record<string, {
|
|
622
|
+
inputPrice?: number | undefined;
|
|
623
|
+
outputPrice?: number | undefined;
|
|
624
|
+
cacheWritesPrice?: number | undefined;
|
|
625
|
+
cacheReadsPrice?: number | undefined;
|
|
626
|
+
}>> | undefined;
|
|
627
|
+
defaultModel?: string | undefined;
|
|
628
|
+
defaultParameters?: Record<string, any> | undefined;
|
|
629
|
+
providers?: Record<string, {
|
|
630
|
+
apiKey?: string | undefined;
|
|
631
|
+
defaultModel?: string | undefined;
|
|
632
|
+
defaultParameters?: Record<string, any> | undefined;
|
|
633
|
+
}> | undefined;
|
|
634
|
+
defaultProvider?: string | undefined;
|
|
635
|
+
maxMessageCount?: number | undefined;
|
|
636
|
+
budget?: number | undefined;
|
|
637
|
+
scripts?: Record<string, string | {
|
|
638
|
+
command: string;
|
|
639
|
+
description: string;
|
|
640
|
+
}> | undefined;
|
|
641
|
+
agents?: Record<string, {
|
|
642
|
+
provider?: string | undefined;
|
|
643
|
+
model?: string | undefined;
|
|
644
|
+
parameters?: Record<string, any> | undefined;
|
|
645
|
+
initialContext?: {
|
|
646
|
+
maxFileCount?: number | undefined;
|
|
647
|
+
excludes?: string[] | undefined;
|
|
648
|
+
} | undefined;
|
|
649
|
+
}> | undefined;
|
|
650
|
+
commands?: z.objectInputType<{
|
|
651
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
652
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
653
|
+
model: z.ZodOptional<z.ZodString>;
|
|
654
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
655
|
+
}, "strip", z.ZodTypeAny, {
|
|
656
|
+
provider?: string | undefined;
|
|
657
|
+
model?: string | undefined;
|
|
658
|
+
parameters?: Record<string, any> | undefined;
|
|
659
|
+
}, {
|
|
660
|
+
provider?: string | undefined;
|
|
661
|
+
model?: string | undefined;
|
|
662
|
+
parameters?: Record<string, any> | undefined;
|
|
663
|
+
}>>;
|
|
664
|
+
}, z.ZodObject<{
|
|
665
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
666
|
+
model: z.ZodOptional<z.ZodString>;
|
|
667
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
668
|
+
}, "strip", z.ZodTypeAny, {
|
|
669
|
+
provider?: string | undefined;
|
|
670
|
+
model?: string | undefined;
|
|
671
|
+
parameters?: Record<string, any> | undefined;
|
|
672
|
+
}, {
|
|
673
|
+
provider?: string | undefined;
|
|
674
|
+
model?: string | undefined;
|
|
675
|
+
parameters?: Record<string, any> | undefined;
|
|
676
|
+
}>, "strip"> | undefined;
|
|
677
|
+
rules?: string | string[] | undefined;
|
|
678
|
+
excludeFiles?: string[] | undefined;
|
|
679
|
+
}>;
|
|
680
|
+
export { configSchema }
|
|
681
|
+
export { configSchema as configSchema_alias_1 }
|
|
682
|
+
|
|
395
683
|
export declare function convertToAnthropicMessage(completion: OpenAI.Chat.Completions.ChatCompletion): Anthropic.Messages.Message;
|
|
396
684
|
|
|
397
685
|
export declare function convertToOpenAiMessages(anthropicMessages: Anthropic.Messages.MessageParam[]): OpenAI.Chat.ChatCompletionMessageParam[];
|
|
@@ -1684,7 +1972,7 @@ export { MultiAgent as MultiAgent_alias_2 }
|
|
|
1684
1972
|
|
|
1685
1973
|
declare type MultiAgentConfig = {
|
|
1686
1974
|
createAgent: (name: string) => Promise<AgentBase>;
|
|
1687
|
-
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>;
|
|
1688
1976
|
};
|
|
1689
1977
|
export { MultiAgentConfig }
|
|
1690
1978
|
export { MultiAgentConfig as MultiAgentConfig_alias_1 }
|
|
@@ -1944,6 +2232,7 @@ declare interface TaskEventToolHandOverDelegate extends TaskEventBase {
|
|
|
1944
2232
|
task: string;
|
|
1945
2233
|
context?: string;
|
|
1946
2234
|
files?: string[];
|
|
2235
|
+
originalTask?: string;
|
|
1947
2236
|
}
|
|
1948
2237
|
export { TaskEventToolHandOverDelegate }
|
|
1949
2238
|
export { TaskEventToolHandOverDelegate as TaskEventToolHandOverDelegate_alias_1 }
|
|
@@ -2401,6 +2690,7 @@ declare type ToolResponseDelegate = {
|
|
|
2401
2690
|
task: string;
|
|
2402
2691
|
context?: string;
|
|
2403
2692
|
files?: string[];
|
|
2693
|
+
originalTask?: string;
|
|
2404
2694
|
};
|
|
2405
2695
|
export { ToolResponseDelegate }
|
|
2406
2696
|
export { ToolResponseDelegate as ToolResponseDelegate_alias_1 }
|
|
@@ -2427,6 +2717,7 @@ declare type ToolResponseHandOver = {
|
|
|
2427
2717
|
task: string;
|
|
2428
2718
|
context?: string;
|
|
2429
2719
|
files?: string[];
|
|
2720
|
+
originalTask?: string;
|
|
2430
2721
|
};
|
|
2431
2722
|
export { ToolResponseHandOver }
|
|
2432
2723
|
export { ToolResponseHandOver as ToolResponseHandOver_alias_1 }
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,8 @@ export { ToolResponseDelegate } from './_tsup-dts-rollup.js';
|
|
|
109
109
|
export { ToolResponse } from './_tsup-dts-rollup.js';
|
|
110
110
|
export { ToolHandler } from './_tsup-dts-rollup.js';
|
|
111
111
|
export { getAvailableTools_alias_1 as getAvailableTools } from './_tsup-dts-rollup.js';
|
|
112
|
+
export { configSchema_alias_1 as configSchema } from './_tsup-dts-rollup.js';
|
|
113
|
+
export { Config_alias_1 as Config } from './_tsup-dts-rollup.js';
|
|
112
114
|
export { getString } from './_tsup-dts-rollup.js';
|
|
113
115
|
export { getStringArray } from './_tsup-dts-rollup.js';
|
|
114
116
|
export { getBoolean } from './_tsup-dts-rollup.js';
|
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 */:
|
|
@@ -3407,6 +3435,65 @@ var generateGitCommitMessage = makeTool(generateGitCommitMessage_default);
|
|
|
3407
3435
|
var generateGithubPullRequestDetails = makeTool(generateGithubPullRequestDetails_default);
|
|
3408
3436
|
var generateProjectConfig = makeAgentTool(generateProjectConfig_default);
|
|
3409
3437
|
var createNewProject = makeAgentTool(createNewProject_default);
|
|
3438
|
+
|
|
3439
|
+
// src/config.ts
|
|
3440
|
+
import { z } from "zod";
|
|
3441
|
+
var providerModelSchema = z.object({
|
|
3442
|
+
provider: z.string().optional(),
|
|
3443
|
+
model: z.string().optional(),
|
|
3444
|
+
parameters: z.record(z.string(), z.any()).optional()
|
|
3445
|
+
});
|
|
3446
|
+
var agentSchema = providerModelSchema.extend({
|
|
3447
|
+
initialContext: z.object({
|
|
3448
|
+
maxFileCount: z.number().int().positive().optional(),
|
|
3449
|
+
excludes: z.array(z.string()).optional()
|
|
3450
|
+
}).optional()
|
|
3451
|
+
});
|
|
3452
|
+
var configSchema = z.object({
|
|
3453
|
+
agent: z.string().optional(),
|
|
3454
|
+
prices: z.record(
|
|
3455
|
+
z.string(),
|
|
3456
|
+
// provider
|
|
3457
|
+
z.record(
|
|
3458
|
+
z.string(),
|
|
3459
|
+
// model
|
|
3460
|
+
z.object({
|
|
3461
|
+
inputPrice: z.number().optional(),
|
|
3462
|
+
outputPrice: z.number().optional(),
|
|
3463
|
+
cacheWritesPrice: z.number().optional(),
|
|
3464
|
+
cacheReadsPrice: z.number().optional()
|
|
3465
|
+
})
|
|
3466
|
+
)
|
|
3467
|
+
).optional(),
|
|
3468
|
+
providers: z.record(
|
|
3469
|
+
z.string(),
|
|
3470
|
+
z.object({
|
|
3471
|
+
apiKey: z.string().optional(),
|
|
3472
|
+
defaultModel: z.string().optional(),
|
|
3473
|
+
defaultParameters: z.record(z.string(), z.any()).optional()
|
|
3474
|
+
})
|
|
3475
|
+
).optional(),
|
|
3476
|
+
defaultProvider: z.string().optional(),
|
|
3477
|
+
defaultModel: z.string().optional(),
|
|
3478
|
+
defaultParameters: z.record(z.string(), z.any()).optional(),
|
|
3479
|
+
maxMessageCount: z.number().int().positive().optional(),
|
|
3480
|
+
budget: z.number().positive().optional(),
|
|
3481
|
+
scripts: z.record(
|
|
3482
|
+
z.string(),
|
|
3483
|
+
z.string().or(
|
|
3484
|
+
z.object({
|
|
3485
|
+
command: z.string(),
|
|
3486
|
+
description: z.string()
|
|
3487
|
+
})
|
|
3488
|
+
)
|
|
3489
|
+
).optional(),
|
|
3490
|
+
agents: z.record(z.string(), agentSchema).optional(),
|
|
3491
|
+
commands: z.object({
|
|
3492
|
+
default: providerModelSchema.optional()
|
|
3493
|
+
}).catchall(providerModelSchema).optional(),
|
|
3494
|
+
rules: z.array(z.string()).optional().or(z.string()).optional(),
|
|
3495
|
+
excludeFiles: z.array(z.string()).optional()
|
|
3496
|
+
}).strict();
|
|
3410
3497
|
export {
|
|
3411
3498
|
AgentBase,
|
|
3412
3499
|
AiServiceBase,
|
|
@@ -3433,6 +3520,7 @@ export {
|
|
|
3433
3520
|
capabilities,
|
|
3434
3521
|
codeFixerAgentInfo,
|
|
3435
3522
|
coderAgentInfo,
|
|
3523
|
+
configSchema,
|
|
3436
3524
|
createNewProject,
|
|
3437
3525
|
createService,
|
|
3438
3526
|
customInstructions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.18",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@anthropic-ai/sdk": "0.39.0",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
|
-
"openai": "^4.80.0"
|
|
20
|
+
"openai": "^4.80.0",
|
|
21
|
+
"zod": "^3.24.2"
|
|
21
22
|
}
|
|
22
23
|
}
|