@polka-codes/runner 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/index.js +64 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32748,7 +32748,7 @@ var {
|
|
|
32748
32748
|
Help
|
|
32749
32749
|
} = import__.default;
|
|
32750
32750
|
// package.json
|
|
32751
|
-
var version = "0.8.
|
|
32751
|
+
var version = "0.8.27";
|
|
32752
32752
|
|
|
32753
32753
|
// src/runner.ts
|
|
32754
32754
|
import { execSync } from "node:child_process";
|
|
@@ -44079,12 +44079,27 @@ ${instance.prompt}`;
|
|
|
44079
44079
|
}
|
|
44080
44080
|
}
|
|
44081
44081
|
let currentAssistantMessage = "";
|
|
44082
|
-
const retryCount = 5;
|
|
44082
|
+
const retryCount = this.config.retryCount ?? 5;
|
|
44083
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
|
|
44083
44084
|
for (let i2 = 0;i2 < retryCount; i2++) {
|
|
44084
44085
|
currentAssistantMessage = "";
|
|
44086
|
+
let timeout;
|
|
44087
|
+
const resetTimeout = () => {
|
|
44088
|
+
if (timeout) {
|
|
44089
|
+
clearTimeout(timeout);
|
|
44090
|
+
}
|
|
44091
|
+
if (requestTimeoutSeconds > 0) {
|
|
44092
|
+
timeout = setTimeout(() => {
|
|
44093
|
+
console.debug(`No data received for ${requestTimeoutSeconds} seconds. Aborting request.`);
|
|
44094
|
+
this.ai.abort();
|
|
44095
|
+
}, requestTimeoutSeconds * 1000);
|
|
44096
|
+
}
|
|
44097
|
+
};
|
|
44085
44098
|
const stream = this.ai.send(this.config.systemPrompt, this.#messages);
|
|
44086
44099
|
try {
|
|
44100
|
+
resetTimeout();
|
|
44087
44101
|
for await (const chunk of stream) {
|
|
44102
|
+
resetTimeout();
|
|
44088
44103
|
switch (chunk.type) {
|
|
44089
44104
|
case "usage":
|
|
44090
44105
|
await this.#callback({ kind: "Usage" /* Usage */, agent: this });
|
|
@@ -44103,6 +44118,10 @@ ${instance.prompt}`;
|
|
|
44103
44118
|
break;
|
|
44104
44119
|
}
|
|
44105
44120
|
console.error("Error in stream:", error);
|
|
44121
|
+
} finally {
|
|
44122
|
+
if (timeout) {
|
|
44123
|
+
clearTimeout(timeout);
|
|
44124
|
+
}
|
|
44106
44125
|
}
|
|
44107
44126
|
if (currentAssistantMessage) {
|
|
44108
44127
|
break;
|
|
@@ -48498,7 +48517,9 @@ var agentSchema = providerModelSchema.extend({
|
|
|
48498
48517
|
initialContext: z2.object({
|
|
48499
48518
|
maxFileCount: z2.number().int().positive().optional(),
|
|
48500
48519
|
excludes: z2.array(z2.string()).optional()
|
|
48501
|
-
}).optional()
|
|
48520
|
+
}).optional(),
|
|
48521
|
+
retryCount: z2.number().int().min(0).optional(),
|
|
48522
|
+
requestTimeoutSeconds: z2.number().int().positive().optional()
|
|
48502
48523
|
});
|
|
48503
48524
|
var configSchema = z2.object({
|
|
48504
48525
|
agent: z2.string().optional(),
|
|
@@ -48518,6 +48539,8 @@ var configSchema = z2.object({
|
|
|
48518
48539
|
defaultParameters: z2.record(z2.string(), z2.any()).optional(),
|
|
48519
48540
|
maxMessageCount: z2.number().int().positive().optional(),
|
|
48520
48541
|
budget: z2.number().positive().optional(),
|
|
48542
|
+
retryCount: z2.number().int().min(0).optional(),
|
|
48543
|
+
requestTimeoutSeconds: z2.number().int().positive().optional(),
|
|
48521
48544
|
scripts: z2.record(z2.string(), z2.string().or(z2.object({
|
|
48522
48545
|
command: z2.string(),
|
|
48523
48546
|
description: z2.string()
|
|
@@ -48800,64 +48823,49 @@ ${output}`);
|
|
|
48800
48823
|
};
|
|
48801
48824
|
|
|
48802
48825
|
// ../core/src/AiTool/generateProjectConfig.ts
|
|
48803
|
-
var prompt4 = `
|
|
48804
|
-
|
|
48805
|
-
|
|
48806
|
-
|
|
48807
|
-
|
|
48808
|
-
|
|
48809
|
-
-
|
|
48810
|
-
-
|
|
48811
|
-
|
|
48812
|
-
|
|
48813
|
-
-
|
|
48814
|
-
|
|
48815
|
-
|
|
48816
|
-
|
|
48817
|
-
|
|
48818
|
-
|
|
48819
|
-
|
|
48820
|
-
|
|
48821
|
-
|
|
48822
|
-
|
|
48823
|
-
<
|
|
48824
|
-
|
|
48825
|
-
|
|
48826
|
-
|
|
48827
|
-
|
|
48828
|
-
|
|
48829
|
-
|
|
48830
|
-
|
|
48831
|
-
|
|
48832
|
-
|
|
48833
|
-
rules:
|
|
48834
|
-
- "Use \`bun\` as package manager"
|
|
48835
|
-
- "Write tests using bun:test with snapshots"
|
|
48836
|
-
- "Follow Biome code style"
|
|
48837
|
-
|
|
48838
|
-
excludeFiles:
|
|
48839
|
-
# Sensitive files
|
|
48826
|
+
var prompt4 = `
|
|
48827
|
+
Role: Analyzer agent
|
|
48828
|
+
Goal: Produce a valid polkacodes YAML configuration for the project.
|
|
48829
|
+
|
|
48830
|
+
Workflow
|
|
48831
|
+
1. Scan project files with tool_read_file and identify:
|
|
48832
|
+
- Package/build tool (npm, bun, pnpm, etc.)
|
|
48833
|
+
- Test framework and patterns (snapshot tests, coverage, etc.)
|
|
48834
|
+
- Formatter / linter and their rules
|
|
48835
|
+
- Folder structure and naming conventions
|
|
48836
|
+
- CI / development workflows
|
|
48837
|
+
|
|
48838
|
+
2. Build a YAML config with three root keys:
|
|
48839
|
+
|
|
48840
|
+
\`\`\`yaml
|
|
48841
|
+
scripts: # derive from package.json and CI
|
|
48842
|
+
format: # code formatter
|
|
48843
|
+
command: "<formatter cmd>"
|
|
48844
|
+
description: "Format code"
|
|
48845
|
+
check: # linter / type checker
|
|
48846
|
+
command: "<linter cmd>"
|
|
48847
|
+
description: "Static checks"
|
|
48848
|
+
test: # test runner
|
|
48849
|
+
command: "<test cmd>"
|
|
48850
|
+
description: "Run tests"
|
|
48851
|
+
# add any other meaningful project scripts
|
|
48852
|
+
|
|
48853
|
+
rules: # bullet list of key conventions/tools
|
|
48854
|
+
|
|
48855
|
+
excludeFiles: # only files likely to hold secrets
|
|
48840
48856
|
- ".env"
|
|
48841
48857
|
- ".env.*"
|
|
48842
48858
|
- ".npmrc"
|
|
48859
|
+
# do NOT list build artifacts, lockfiles, or paths already in .gitignore
|
|
48860
|
+
\`\`\`
|
|
48861
|
+
|
|
48862
|
+
3. Return the YAML exactly once, wrapped like:
|
|
48863
|
+
|
|
48864
|
+
<tool_attempt_completion>
|
|
48865
|
+
<tool_parameter_result>
|
|
48866
|
+
# YAML (2-space indents, double-quoted commands)
|
|
48843
48867
|
</tool_parameter_result>
|
|
48844
48868
|
</tool_attempt_completion>
|
|
48845
|
-
|
|
48846
|
-
Focus on:
|
|
48847
|
-
- Package manager and dependency management
|
|
48848
|
-
- Testing frameworks and patterns
|
|
48849
|
-
- Code style and linting rules
|
|
48850
|
-
- File organization and naming conventions
|
|
48851
|
-
- Build and development workflows
|
|
48852
|
-
- Sensitive files that should not be committed:
|
|
48853
|
-
- Environment files (.env*)
|
|
48854
|
-
- Configuration files with potential secrets
|
|
48855
|
-
- Generated files to exclude:
|
|
48856
|
-
- Lock files from package managers
|
|
48857
|
-
- Build artifacts and outputs
|
|
48858
|
-
- Generated file that are not ignored by .gitignore
|
|
48859
|
-
|
|
48860
|
-
The configuration should accurately reflect the project's structure, tools, and conventions.
|
|
48861
48869
|
`;
|
|
48862
48870
|
var generateProjectConfig_default = {
|
|
48863
48871
|
name: "generateProjectConfig",
|