@polka-codes/core 0.9.8 → 0.9.10

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.
@@ -1737,7 +1737,7 @@ export { ToolUse }
1737
1737
  export { ToolUse as ToolUse_alias_1 }
1738
1738
  export { ToolUse as ToolUse_alias_2 }
1739
1739
 
1740
- declare const toolUsePrompt: (tools: FullToolInfoV2[], toolNamePrefix: string) => string;
1740
+ declare const toolUsePrompt: (useNativeTool: boolean, tools: FullToolInfoV2[], toolNamePrefix: string) => string;
1741
1741
  export { toolUsePrompt }
1742
1742
  export { toolUsePrompt as toolUsePrompt_alias_1 }
1743
1743
  export { toolUsePrompt as toolUsePrompt_alias_2 }
package/dist/index.js CHANGED
@@ -1488,7 +1488,17 @@ var toolInfoExamplesPrompt = (tool, example, toolNamePrefix, parameterPrefix) =>
1488
1488
  ${Object.entries(example.input).map(([name, value]) => renderParameterValue(name, value, parameterPrefix)).join("\n")}
1489
1489
  </${toolNamePrefix}${tool.name}>
1490
1490
  `;
1491
- var toolUsePrompt = (tools, toolNamePrefix) => {
1491
+ var toolUsePrompt = (useNativeTool, tools, toolNamePrefix) => {
1492
+ if (useNativeTool) {
1493
+ return `
1494
+ ====
1495
+
1496
+ TOOL USE
1497
+
1498
+ - You MUST use a tool.
1499
+ - Batch tool use when feasible; avoid redundant calls.
1500
+ `;
1501
+ }
1492
1502
  if (tools.length === 0) {
1493
1503
  return "";
1494
1504
  }
@@ -1856,7 +1866,8 @@ ${instance.prompt}`;
1856
1866
  if (requestTimeoutSeconds > 0 && requestAbortController) {
1857
1867
  timeout = setTimeout(() => {
1858
1868
  console.debug(
1859
- `Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`
1869
+ `
1870
+ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current request attempt ${i + 1}/${retryCount}.`
1860
1871
  );
1861
1872
  requestAbortController?.abort();
1862
1873
  }, requestTimeoutSeconds * 1e3);
@@ -1918,7 +1929,15 @@ ${instance.prompt}`;
1918
1929
  }
1919
1930
  }
1920
1931
  if (this.config.toolFormat === "native") {
1921
- if (respMessages.some((m) => m.role === "tool")) {
1932
+ if (respMessages.some((m) => {
1933
+ if (m.role === "tool") {
1934
+ return true;
1935
+ }
1936
+ if (typeof m.content === "string") {
1937
+ return true;
1938
+ }
1939
+ return m.content.some((part) => part.type === "tool-call" || part.type === "tool-result" || part.type === "text");
1940
+ })) {
1922
1941
  break;
1923
1942
  }
1924
1943
  } else {
@@ -1930,7 +1949,8 @@ ${instance.prompt}`;
1930
1949
  break;
1931
1950
  }
1932
1951
  if (i < retryCount - 1) {
1933
- console.debug(`Retrying request ${i + 2} of ${retryCount}`);
1952
+ console.debug(`
1953
+ Retrying request ${i + 2} of ${retryCount}`);
1934
1954
  }
1935
1955
  }
1936
1956
  if (respMessages.length === 0) {
@@ -2167,7 +2187,7 @@ You are the **Analyzer** agent, responsible for:
2167
2187
  5. **Documentation Assessment**: Review documentation quality and completeness.
2168
2188
  6. **Non-Modification**: Never modify code or files - focus solely on analysis.
2169
2189
 
2170
- ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
2190
+ ${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
2171
2191
  ${capabilities(toolNamePrefix)}
2172
2192
  ${systemInformation(info)}
2173
2193
  ${customInstructions(instructions)}
@@ -2264,7 +2284,7 @@ You are the **Architect** agent, responsible for:
2264
2284
  - If multiple steps are required, break them into numbered tasks to delegate to the **Coder** agent.
2265
2285
  - Provide all necessary context, implementation plan, file references, and clarifications for successful execution.
2266
2286
 
2267
- ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
2287
+ ${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
2268
2288
  ${capabilities(toolNamePrefix)}
2269
2289
  ${systemInformation(info)}
2270
2290
  ${customInstructions(instructions)}
@@ -2391,7 +2411,7 @@ RETRY GUIDELINES
2391
2411
  - Report any partial improvements`;
2392
2412
  var fullSystemPrompt3 = (info, tools, toolNamePrefix, instructions, scripts, _interactive, useNativeTool) => `
2393
2413
  ${basePrompt}
2394
- ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
2414
+ ${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
2395
2415
  ${codeFixingStrategies}
2396
2416
  ${retryGuidelines}
2397
2417
  ${capabilities(toolNamePrefix)}
@@ -2598,7 +2618,7 @@ You solve the user's task by working in small, verifiable steps.
2598
2618
  `;
2599
2619
  var fullSystemPrompt4 = (info, tools, toolNamePrefix, instructions, scripts, useNativeTool) => `
2600
2620
  ${basePrompt2}
2601
- ${useNativeTool ? "" : toolUsePrompt(tools, toolNamePrefix)}
2621
+ ${toolUsePrompt(useNativeTool, tools, toolNamePrefix)}
2602
2622
  ${editingFilesPrompt(toolNamePrefix)}
2603
2623
  ${capabilities(toolNamePrefix)}
2604
2624
  ${rules(toolNamePrefix)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/core",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",