@polka-codes/core 0.8.26 → 0.8.27
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 +21 -1
- package/dist/index.js +60 -52
- package/package.json +1 -1
|
@@ -54,6 +54,8 @@ declare type AgentBaseConfig = {
|
|
|
54
54
|
}>;
|
|
55
55
|
callback?: TaskEventCallback;
|
|
56
56
|
policies: AgentPolicy[];
|
|
57
|
+
retryCount?: number;
|
|
58
|
+
requestTimeoutSeconds?: number;
|
|
57
59
|
};
|
|
58
60
|
export { AgentBaseConfig }
|
|
59
61
|
export { AgentBaseConfig as AgentBaseConfig_alias_1 }
|
|
@@ -482,6 +484,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
482
484
|
defaultParameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
483
485
|
maxMessageCount: z.ZodOptional<z.ZodNumber>;
|
|
484
486
|
budget: z.ZodOptional<z.ZodNumber>;
|
|
487
|
+
retryCount: z.ZodOptional<z.ZodNumber>;
|
|
488
|
+
requestTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
485
489
|
scripts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
486
490
|
command: z.ZodString;
|
|
487
491
|
description: z.ZodString;
|
|
@@ -507,6 +511,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
507
511
|
maxFileCount?: number | undefined;
|
|
508
512
|
excludes?: string[] | undefined;
|
|
509
513
|
}>>;
|
|
514
|
+
retryCount: z.ZodOptional<z.ZodNumber>;
|
|
515
|
+
requestTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
510
516
|
}>, "strip", z.ZodTypeAny, {
|
|
511
517
|
provider?: string | undefined;
|
|
512
518
|
model?: string | undefined;
|
|
@@ -515,6 +521,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
515
521
|
maxFileCount?: number | undefined;
|
|
516
522
|
excludes?: string[] | undefined;
|
|
517
523
|
} | undefined;
|
|
524
|
+
retryCount?: number | undefined;
|
|
525
|
+
requestTimeoutSeconds?: number | undefined;
|
|
518
526
|
}, {
|
|
519
527
|
provider?: string | undefined;
|
|
520
528
|
model?: string | undefined;
|
|
@@ -523,6 +531,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
523
531
|
maxFileCount?: number | undefined;
|
|
524
532
|
excludes?: string[] | undefined;
|
|
525
533
|
} | undefined;
|
|
534
|
+
retryCount?: number | undefined;
|
|
535
|
+
requestTimeoutSeconds?: number | undefined;
|
|
526
536
|
}>>>;
|
|
527
537
|
commands: z.ZodOptional<z.ZodObject<{
|
|
528
538
|
default: z.ZodOptional<z.ZodObject<{
|
|
@@ -607,6 +617,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
607
617
|
excludeFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
608
618
|
policies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
609
619
|
}, "strict", z.ZodTypeAny, {
|
|
620
|
+
retryCount?: number | undefined;
|
|
621
|
+
requestTimeoutSeconds?: number | undefined;
|
|
610
622
|
agent?: string | undefined;
|
|
611
623
|
prices?: Record<string, Record<string, {
|
|
612
624
|
inputPrice?: number | undefined;
|
|
@@ -636,6 +648,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
636
648
|
maxFileCount?: number | undefined;
|
|
637
649
|
excludes?: string[] | undefined;
|
|
638
650
|
} | undefined;
|
|
651
|
+
retryCount?: number | undefined;
|
|
652
|
+
requestTimeoutSeconds?: number | undefined;
|
|
639
653
|
}> | undefined;
|
|
640
654
|
commands?: z.objectOutputType<{
|
|
641
655
|
default: z.ZodOptional<z.ZodObject<{
|
|
@@ -668,6 +682,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
668
682
|
excludeFiles?: string[] | undefined;
|
|
669
683
|
policies?: string[] | undefined;
|
|
670
684
|
}, {
|
|
685
|
+
retryCount?: number | undefined;
|
|
686
|
+
requestTimeoutSeconds?: number | undefined;
|
|
671
687
|
agent?: string | undefined;
|
|
672
688
|
prices?: Record<string, Record<string, {
|
|
673
689
|
inputPrice?: number | undefined;
|
|
@@ -697,6 +713,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
697
713
|
maxFileCount?: number | undefined;
|
|
698
714
|
excludes?: string[] | undefined;
|
|
699
715
|
} | undefined;
|
|
716
|
+
retryCount?: number | undefined;
|
|
717
|
+
requestTimeoutSeconds?: number | undefined;
|
|
700
718
|
}> | undefined;
|
|
701
719
|
commands?: z.objectInputType<{
|
|
702
720
|
default: z.ZodOptional<z.ZodObject<{
|
|
@@ -1910,7 +1928,7 @@ export declare const default_alias_2: {
|
|
|
1910
1928
|
export declare const default_alias_3: {
|
|
1911
1929
|
readonly name: "generateProjectConfig";
|
|
1912
1930
|
readonly description: "Analyzes project files to generate polkacodes config sections";
|
|
1913
|
-
readonly prompt: "
|
|
1931
|
+
readonly prompt: "\nRole: Analyzer agent\nGoal: Produce a valid polkacodes YAML configuration for the project.\n\nWorkflow\n1. Scan project files with tool_read_file and identify:\n - Package/build tool (npm, bun, pnpm, etc.)\n - Test framework and patterns (snapshot tests, coverage, etc.)\n - Formatter / linter and their rules\n - Folder structure and naming conventions\n - CI / development workflows\n\n2. Build a YAML config with three root keys:\n\n```yaml\nscripts: # derive from package.json and CI\n format: # code formatter\n command: \"<formatter cmd>\"\n description: \"Format code\"\n check: # linter / type checker\n command: \"<linter cmd>\"\n description: \"Static checks\"\n test: # test runner\n command: \"<test cmd>\"\n description: \"Run tests\"\n # add any other meaningful project scripts\n\nrules: # bullet list of key conventions/tools\n\nexcludeFiles: # only files likely to hold secrets\n - \".env\"\n - \".env.*\"\n - \".npmrc\"\n # do NOT list build artifacts, lockfiles, or paths already in .gitignore\n```\n\n3. Return the YAML exactly once, wrapped like:\n\n<tool_attempt_completion>\n<tool_parameter_result>\n# YAML (2-space indents, double-quoted commands)\n</tool_parameter_result>\n</tool_attempt_completion>\n";
|
|
1914
1932
|
readonly formatInput: () => string;
|
|
1915
1933
|
readonly parseOutput: (output: string) => string;
|
|
1916
1934
|
readonly agent: "analyzer";
|
|
@@ -2655,6 +2673,8 @@ declare type SharedAgentOptions = {
|
|
|
2655
2673
|
agents?: Readonly<AgentInfo[]>;
|
|
2656
2674
|
callback?: TaskEventCallback;
|
|
2657
2675
|
policies: AgentPolicy[];
|
|
2676
|
+
retryCount?: number;
|
|
2677
|
+
requestTimeoutSeconds?: number;
|
|
2658
2678
|
};
|
|
2659
2679
|
export { SharedAgentOptions }
|
|
2660
2680
|
export { SharedAgentOptions as SharedAgentOptions_alias_1 }
|
package/dist/index.js
CHANGED
|
@@ -2988,12 +2988,27 @@ ${instance.prompt}`;
|
|
|
2988
2988
|
}
|
|
2989
2989
|
}
|
|
2990
2990
|
let currentAssistantMessage = "";
|
|
2991
|
-
const retryCount = 5;
|
|
2991
|
+
const retryCount = this.config.retryCount ?? 5;
|
|
2992
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
|
|
2992
2993
|
for (let i = 0; i < retryCount; i++) {
|
|
2993
2994
|
currentAssistantMessage = "";
|
|
2995
|
+
let timeout;
|
|
2996
|
+
const resetTimeout = () => {
|
|
2997
|
+
if (timeout) {
|
|
2998
|
+
clearTimeout(timeout);
|
|
2999
|
+
}
|
|
3000
|
+
if (requestTimeoutSeconds > 0) {
|
|
3001
|
+
timeout = setTimeout(() => {
|
|
3002
|
+
console.debug(`No data received for ${requestTimeoutSeconds} seconds. Aborting request.`);
|
|
3003
|
+
this.ai.abort();
|
|
3004
|
+
}, requestTimeoutSeconds * 1e3);
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
2994
3007
|
const stream = this.ai.send(this.config.systemPrompt, this.#messages);
|
|
2995
3008
|
try {
|
|
3009
|
+
resetTimeout();
|
|
2996
3010
|
for await (const chunk of stream) {
|
|
3011
|
+
resetTimeout();
|
|
2997
3012
|
switch (chunk.type) {
|
|
2998
3013
|
case "usage":
|
|
2999
3014
|
await this.#callback({ kind: "Usage" /* Usage */, agent: this });
|
|
@@ -3012,6 +3027,10 @@ ${instance.prompt}`;
|
|
|
3012
3027
|
break;
|
|
3013
3028
|
}
|
|
3014
3029
|
console.error("Error in stream:", error);
|
|
3030
|
+
} finally {
|
|
3031
|
+
if (timeout) {
|
|
3032
|
+
clearTimeout(timeout);
|
|
3033
|
+
}
|
|
3015
3034
|
}
|
|
3016
3035
|
if (currentAssistantMessage) {
|
|
3017
3036
|
break;
|
|
@@ -3797,7 +3816,9 @@ var agentSchema = providerModelSchema.extend({
|
|
|
3797
3816
|
initialContext: z.object({
|
|
3798
3817
|
maxFileCount: z.number().int().positive().optional(),
|
|
3799
3818
|
excludes: z.array(z.string()).optional()
|
|
3800
|
-
}).optional()
|
|
3819
|
+
}).optional(),
|
|
3820
|
+
retryCount: z.number().int().min(0).optional(),
|
|
3821
|
+
requestTimeoutSeconds: z.number().int().positive().optional()
|
|
3801
3822
|
});
|
|
3802
3823
|
var configSchema = z.object({
|
|
3803
3824
|
agent: z.string().optional(),
|
|
@@ -3828,6 +3849,8 @@ var configSchema = z.object({
|
|
|
3828
3849
|
defaultParameters: z.record(z.string(), z.any()).optional(),
|
|
3829
3850
|
maxMessageCount: z.number().int().positive().optional(),
|
|
3830
3851
|
budget: z.number().positive().optional(),
|
|
3852
|
+
retryCount: z.number().int().min(0).optional(),
|
|
3853
|
+
requestTimeoutSeconds: z.number().int().positive().optional(),
|
|
3831
3854
|
scripts: z.record(
|
|
3832
3855
|
z.string(),
|
|
3833
3856
|
z.string().or(
|
|
@@ -4323,64 +4346,49 @@ ${output}`);
|
|
|
4323
4346
|
};
|
|
4324
4347
|
|
|
4325
4348
|
// src/AiTool/generateProjectConfig.ts
|
|
4326
|
-
var prompt5 = `
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
- Build tools and package manager (e.g., bun, npm)
|
|
4330
|
-
- Testing frameworks and patterns
|
|
4331
|
-
- Code style tools and rules
|
|
4332
|
-
- Project structure and conventions
|
|
4333
|
-
- Common development workflows
|
|
4334
|
-
|
|
4335
|
-
2. Generate a YAML configuration that captures:
|
|
4336
|
-
- scripts section based on package.json scripts and CI workflows. If applicable, generate following scripts:
|
|
4337
|
-
- format: Format the code using a code formatter tool
|
|
4338
|
-
- check: Check the code for errors using a linter tool
|
|
4339
|
-
- test: Run tests using a test runner tool
|
|
4340
|
-
- include other relevant scripts based on project conventions, tools, and patterns
|
|
4341
|
-
- rules section based on project conventions, tools, and patterns
|
|
4342
|
-
- excludeFiles section for sensitive files
|
|
4343
|
-
|
|
4344
|
-
3. Use tool_attempt_completion to return the final configuration in this format:
|
|
4349
|
+
var prompt5 = `
|
|
4350
|
+
Role: Analyzer agent
|
|
4351
|
+
Goal: Produce a valid polkacodes YAML configuration for the project.
|
|
4345
4352
|
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
command: "biome check ."
|
|
4354
|
-
description: "Check code style with Biome"
|
|
4353
|
+
Workflow
|
|
4354
|
+
1. Scan project files with tool_read_file and identify:
|
|
4355
|
+
- Package/build tool (npm, bun, pnpm, etc.)
|
|
4356
|
+
- Test framework and patterns (snapshot tests, coverage, etc.)
|
|
4357
|
+
- Formatter / linter and their rules
|
|
4358
|
+
- Folder structure and naming conventions
|
|
4359
|
+
- CI / development workflows
|
|
4355
4360
|
|
|
4356
|
-
|
|
4357
|
-
- "Use \`bun\` as package manager"
|
|
4358
|
-
- "Write tests using bun:test with snapshots"
|
|
4359
|
-
- "Follow Biome code style"
|
|
4361
|
+
2. Build a YAML config with three root keys:
|
|
4360
4362
|
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
+
\`\`\`yaml
|
|
4364
|
+
scripts: # derive from package.json and CI
|
|
4365
|
+
format: # code formatter
|
|
4366
|
+
command: "<formatter cmd>"
|
|
4367
|
+
description: "Format code"
|
|
4368
|
+
check: # linter / type checker
|
|
4369
|
+
command: "<linter cmd>"
|
|
4370
|
+
description: "Static checks"
|
|
4371
|
+
test: # test runner
|
|
4372
|
+
command: "<test cmd>"
|
|
4373
|
+
description: "Run tests"
|
|
4374
|
+
# add any other meaningful project scripts
|
|
4375
|
+
|
|
4376
|
+
rules: # bullet list of key conventions/tools
|
|
4377
|
+
|
|
4378
|
+
excludeFiles: # only files likely to hold secrets
|
|
4363
4379
|
- ".env"
|
|
4364
4380
|
- ".env.*"
|
|
4365
4381
|
- ".npmrc"
|
|
4382
|
+
# do NOT list build artifacts, lockfiles, or paths already in .gitignore
|
|
4383
|
+
\`\`\`
|
|
4384
|
+
|
|
4385
|
+
3. Return the YAML exactly once, wrapped like:
|
|
4386
|
+
|
|
4387
|
+
<tool_attempt_completion>
|
|
4388
|
+
<tool_parameter_result>
|
|
4389
|
+
# YAML (2-space indents, double-quoted commands)
|
|
4366
4390
|
</tool_parameter_result>
|
|
4367
4391
|
</tool_attempt_completion>
|
|
4368
|
-
|
|
4369
|
-
Focus on:
|
|
4370
|
-
- Package manager and dependency management
|
|
4371
|
-
- Testing frameworks and patterns
|
|
4372
|
-
- Code style and linting rules
|
|
4373
|
-
- File organization and naming conventions
|
|
4374
|
-
- Build and development workflows
|
|
4375
|
-
- Sensitive files that should not be committed:
|
|
4376
|
-
- Environment files (.env*)
|
|
4377
|
-
- Configuration files with potential secrets
|
|
4378
|
-
- Generated files to exclude:
|
|
4379
|
-
- Lock files from package managers
|
|
4380
|
-
- Build artifacts and outputs
|
|
4381
|
-
- Generated file that are not ignored by .gitignore
|
|
4382
|
-
|
|
4383
|
-
The configuration should accurately reflect the project's structure, tools, and conventions.
|
|
4384
4392
|
`;
|
|
4385
4393
|
var generateProjectConfig_default = {
|
|
4386
4394
|
name: "generateProjectConfig",
|