@polka-codes/runner 0.8.25 → 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 +70 -58
- 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";
|
|
@@ -42920,14 +42920,18 @@ var handler8 = async (provider, args) => {
|
|
|
42920
42920
|
if (result.status === "no_diff_applied") {
|
|
42921
42921
|
return {
|
|
42922
42922
|
type: "Error" /* Error */,
|
|
42923
|
-
message: `<replace_in_file_result path="${path}" status="failed" message="Unable to apply changes"
|
|
42923
|
+
message: `<replace_in_file_result path="${path}" status="failed" message="Unable to apply changes">
|
|
42924
|
+
<file_content path="${path}">${fileContent}</file_content>
|
|
42925
|
+
</replace_in_file_result>`
|
|
42924
42926
|
};
|
|
42925
42927
|
}
|
|
42926
42928
|
await provider.writeFile(path, result.content);
|
|
42927
42929
|
if (result.status === "some_diff_applied") {
|
|
42928
42930
|
return {
|
|
42929
42931
|
type: "Reply" /* Reply */,
|
|
42930
|
-
message: `<replace_in_file_result path="${path}" status="some_diff_applied" applied_count="${result.appliedCount}" total_count="${result.totalCount}"
|
|
42932
|
+
message: `<replace_in_file_result path="${path}" status="some_diff_applied" applied_count="${result.appliedCount}" total_count="${result.totalCount}">
|
|
42933
|
+
<file_content path="${path}">${result.content}</file_content>
|
|
42934
|
+
</replace_in_file_result>`
|
|
42931
42935
|
};
|
|
42932
42936
|
}
|
|
42933
42937
|
return {
|
|
@@ -44075,12 +44079,27 @@ ${instance.prompt}`;
|
|
|
44075
44079
|
}
|
|
44076
44080
|
}
|
|
44077
44081
|
let currentAssistantMessage = "";
|
|
44078
|
-
const retryCount = 5;
|
|
44082
|
+
const retryCount = this.config.retryCount ?? 5;
|
|
44083
|
+
const requestTimeoutSeconds = this.config.requestTimeoutSeconds ?? 10;
|
|
44079
44084
|
for (let i2 = 0;i2 < retryCount; i2++) {
|
|
44080
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
|
+
};
|
|
44081
44098
|
const stream = this.ai.send(this.config.systemPrompt, this.#messages);
|
|
44082
44099
|
try {
|
|
44100
|
+
resetTimeout();
|
|
44083
44101
|
for await (const chunk of stream) {
|
|
44102
|
+
resetTimeout();
|
|
44084
44103
|
switch (chunk.type) {
|
|
44085
44104
|
case "usage":
|
|
44086
44105
|
await this.#callback({ kind: "Usage" /* Usage */, agent: this });
|
|
@@ -44099,6 +44118,10 @@ ${instance.prompt}`;
|
|
|
44099
44118
|
break;
|
|
44100
44119
|
}
|
|
44101
44120
|
console.error("Error in stream:", error);
|
|
44121
|
+
} finally {
|
|
44122
|
+
if (timeout) {
|
|
44123
|
+
clearTimeout(timeout);
|
|
44124
|
+
}
|
|
44102
44125
|
}
|
|
44103
44126
|
if (currentAssistantMessage) {
|
|
44104
44127
|
break;
|
|
@@ -48494,7 +48517,9 @@ var agentSchema = providerModelSchema.extend({
|
|
|
48494
48517
|
initialContext: z2.object({
|
|
48495
48518
|
maxFileCount: z2.number().int().positive().optional(),
|
|
48496
48519
|
excludes: z2.array(z2.string()).optional()
|
|
48497
|
-
}).optional()
|
|
48520
|
+
}).optional(),
|
|
48521
|
+
retryCount: z2.number().int().min(0).optional(),
|
|
48522
|
+
requestTimeoutSeconds: z2.number().int().positive().optional()
|
|
48498
48523
|
});
|
|
48499
48524
|
var configSchema = z2.object({
|
|
48500
48525
|
agent: z2.string().optional(),
|
|
@@ -48514,6 +48539,8 @@ var configSchema = z2.object({
|
|
|
48514
48539
|
defaultParameters: z2.record(z2.string(), z2.any()).optional(),
|
|
48515
48540
|
maxMessageCount: z2.number().int().positive().optional(),
|
|
48516
48541
|
budget: z2.number().positive().optional(),
|
|
48542
|
+
retryCount: z2.number().int().min(0).optional(),
|
|
48543
|
+
requestTimeoutSeconds: z2.number().int().positive().optional(),
|
|
48517
48544
|
scripts: z2.record(z2.string(), z2.string().or(z2.object({
|
|
48518
48545
|
command: z2.string(),
|
|
48519
48546
|
description: z2.string()
|
|
@@ -48796,64 +48823,49 @@ ${output}`);
|
|
|
48796
48823
|
};
|
|
48797
48824
|
|
|
48798
48825
|
// ../core/src/AiTool/generateProjectConfig.ts
|
|
48799
|
-
var prompt4 = `
|
|
48800
|
-
|
|
48801
|
-
|
|
48802
|
-
|
|
48803
|
-
|
|
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
|
-
rules:
|
|
48830
|
-
- "Use \`bun\` as package manager"
|
|
48831
|
-
- "Write tests using bun:test with snapshots"
|
|
48832
|
-
- "Follow Biome code style"
|
|
48833
|
-
|
|
48834
|
-
excludeFiles:
|
|
48835
|
-
# 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
|
|
48836
48856
|
- ".env"
|
|
48837
48857
|
- ".env.*"
|
|
48838
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)
|
|
48839
48867
|
</tool_parameter_result>
|
|
48840
48868
|
</tool_attempt_completion>
|
|
48841
|
-
|
|
48842
|
-
Focus on:
|
|
48843
|
-
- Package manager and dependency management
|
|
48844
|
-
- Testing frameworks and patterns
|
|
48845
|
-
- Code style and linting rules
|
|
48846
|
-
- File organization and naming conventions
|
|
48847
|
-
- Build and development workflows
|
|
48848
|
-
- Sensitive files that should not be committed:
|
|
48849
|
-
- Environment files (.env*)
|
|
48850
|
-
- Configuration files with potential secrets
|
|
48851
|
-
- Generated files to exclude:
|
|
48852
|
-
- Lock files from package managers
|
|
48853
|
-
- Build artifacts and outputs
|
|
48854
|
-
- Generated file that are not ignored by .gitignore
|
|
48855
|
-
|
|
48856
|
-
The configuration should accurately reflect the project's structure, tools, and conventions.
|
|
48857
48869
|
`;
|
|
48858
48870
|
var generateProjectConfig_default = {
|
|
48859
48871
|
name: "generateProjectConfig",
|