@polka-codes/cli 0.9.6 → 0.9.8

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.
Files changed (2) hide show
  1. package/dist/index.js +71 -22
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -39731,7 +39731,7 @@ var {
39731
39731
  Help
39732
39732
  } = import__.default;
39733
39733
  // package.json
39734
- var version = "0.9.6";
39734
+ var version = "0.9.8";
39735
39735
 
39736
39736
  // ../../node_modules/@inquirer/core/dist/esm/lib/key.js
39737
39737
  var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
@@ -76780,8 +76780,14 @@ ${instance.prompt}`;
76780
76780
  clearTimeout(timeout);
76781
76781
  }
76782
76782
  }
76783
- if (respMessages.length > 0) {
76784
- break;
76783
+ if (this.config.toolFormat === "native") {
76784
+ if (respMessages.some((m) => m.role === "tool")) {
76785
+ break;
76786
+ }
76787
+ } else {
76788
+ if (respMessages.length > 0) {
76789
+ break;
76790
+ }
76785
76791
  }
76786
76792
  if (this.#aborted) {
76787
76793
  break;
@@ -77059,7 +77065,8 @@ class AnalyzerAgent extends AgentBase {
77059
77065
  policies: options.policies,
77060
77066
  toolFormat: options.toolFormat,
77061
77067
  parameters: options.parameters ?? {},
77062
- usageMeter: options.usageMeter ?? new UsageMeter
77068
+ usageMeter: options.usageMeter ?? new UsageMeter,
77069
+ requestTimeoutSeconds: options.requestTimeoutSeconds
77063
77070
  });
77064
77071
  }
77065
77072
  onBeforeInvokeTool() {
@@ -77148,7 +77155,8 @@ class ArchitectAgent extends AgentBase {
77148
77155
  policies: options.policies,
77149
77156
  toolFormat: options.toolFormat,
77150
77157
  parameters: options.parameters ?? {},
77151
- usageMeter: options.usageMeter ?? new UsageMeter
77158
+ usageMeter: options.usageMeter ?? new UsageMeter,
77159
+ requestTimeoutSeconds: options.requestTimeoutSeconds
77152
77160
  });
77153
77161
  }
77154
77162
  onBeforeInvokeTool() {
@@ -77270,7 +77278,8 @@ class CodeFixerAgent extends AgentBase {
77270
77278
  policies: options.policies,
77271
77279
  toolFormat: options.toolFormat,
77272
77280
  parameters: options.parameters ?? {},
77273
- usageMeter: options.usageMeter ?? new UsageMeter
77281
+ usageMeter: options.usageMeter ?? new UsageMeter,
77282
+ requestTimeoutSeconds: options.requestTimeoutSeconds
77274
77283
  });
77275
77284
  this.#maxRetries = options.maxRetries ?? 5;
77276
77285
  }
@@ -77468,7 +77477,8 @@ class CoderAgent extends AgentBase {
77468
77477
  policies: options.policies,
77469
77478
  toolFormat: options.toolFormat,
77470
77479
  parameters: options.parameters ?? {},
77471
- usageMeter: options.usageMeter ?? new UsageMeter
77480
+ usageMeter: options.usageMeter ?? new UsageMeter,
77481
+ requestTimeoutSeconds: options.requestTimeoutSeconds
77472
77482
  });
77473
77483
  }
77474
77484
  async#runScript(scriptName, shouldReplyWithError) {
@@ -103819,6 +103829,33 @@ function getEnv(override) {
103819
103829
  }
103820
103830
 
103821
103831
  // src/getModel.ts
103832
+ function headersToObject(headers) {
103833
+ if (!headers) {
103834
+ return;
103835
+ }
103836
+ if (headers instanceof Headers) {
103837
+ return Object.fromEntries(headers.entries());
103838
+ }
103839
+ if (Array.isArray(headers)) {
103840
+ return Object.fromEntries(headers);
103841
+ }
103842
+ return headers;
103843
+ }
103844
+ function redactHeaders(headers) {
103845
+ if (!headers) {
103846
+ return;
103847
+ }
103848
+ const redactedHeaders = {};
103849
+ const sensitiveKeywords = ["authorization", "cookie", "key", "token"];
103850
+ for (const [key2, value] of Object.entries(headers)) {
103851
+ if (sensitiveKeywords.some((keyword) => key2.toLowerCase().includes(keyword))) {
103852
+ redactedHeaders[key2] = "REDACTED";
103853
+ } else {
103854
+ redactedHeaders[key2] = value;
103855
+ }
103856
+ }
103857
+ return redactedHeaders;
103858
+ }
103822
103859
  var AiProvider;
103823
103860
  ((AiProvider2) => {
103824
103861
  AiProvider2["Anthropic"] = "anthropic";
@@ -103843,7 +103880,7 @@ var getModel = (config5, debugLogging = false) => {
103843
103880
  type: "request",
103844
103881
  timestamp: new Date().toISOString(),
103845
103882
  url: url4,
103846
- headers: options?.headers,
103883
+ headers: redactHeaders(headersToObject(options?.headers)),
103847
103884
  body: requestBody
103848
103885
  }, null, 2)}
103849
103886
  `);
@@ -103868,12 +103905,30 @@ var getModel = (config5, debugLogging = false) => {
103868
103905
  console.log("<- Stream chunk:", text2.replace(/\n/g, "\\n"));
103869
103906
  }
103870
103907
  if (TRACING_FILE) {
103871
- appendFileSync(TRACING_FILE, `${JSON.stringify({
103872
- type: "response-chunk",
103873
- timestamp: new Date().toISOString(),
103874
- chunk: text2
103875
- }, null, 2)}
103908
+ for (const line of text2.split(`
103909
+ `)) {
103910
+ if (line.startsWith("data:")) {
103911
+ const content = line.slice("data:".length).trim();
103912
+ if (content) {
103913
+ try {
103914
+ const json4 = JSON.parse(content);
103915
+ appendFileSync(TRACING_FILE, `${JSON.stringify({
103916
+ type: "response-chunk",
103917
+ timestamp: new Date().toISOString(),
103918
+ chunk: json4
103919
+ }, null, 2)}
103876
103920
  `);
103921
+ } catch (_e) {
103922
+ appendFileSync(TRACING_FILE, `${JSON.stringify({
103923
+ type: "response-chunk",
103924
+ timestamp: new Date().toISOString(),
103925
+ chunk: content
103926
+ }, null, 2)}
103927
+ `);
103928
+ }
103929
+ }
103930
+ }
103931
+ }
103877
103932
  }
103878
103933
  }
103879
103934
  }
@@ -103894,7 +103949,7 @@ var getModel = (config5, debugLogging = false) => {
103894
103949
  type: "response",
103895
103950
  timestamp: new Date().toISOString(),
103896
103951
  status: res.status,
103897
- headers: Object.fromEntries(res.headers.entries()),
103952
+ headers: redactHeaders(Object.fromEntries(res.headers.entries())),
103898
103953
  body: responseBody
103899
103954
  }, null, 2)}
103900
103955
  `);
@@ -110749,15 +110804,9 @@ async function reviewPR(prIdentifier, spinner, sharedAiOptions, isJsonOutput) {
110749
110804
  try {
110750
110805
  spinner.text = `Checking out PR #${prNumber}...`;
110751
110806
  execSync3(`gh pr checkout ${prNumber}`, { stdio: "pipe" });
110752
- } catch (_error) {
110807
+ } catch (error120) {
110753
110808
  spinner.fail(`Error checking out PR #${prNumber}. Make sure the PR number is correct and you have access to the repository.`);
110754
- process.exit(1);
110755
- }
110756
- const gitRoot = execSync3("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
110757
- const remoteUrl = execSync3("git remote get-url origin", { cwd: gitRoot, encoding: "utf-8" }).trim();
110758
- const remoteMatch = remoteUrl.match(/github\.com[/:](?<owner>[^/]+)\/(?<repo>[^/]+)\.git$/);
110759
- if (!remoteMatch?.groups) {
110760
- spinner.fail("Could not determine GitHub repository owner and repo from remote URL.");
110809
+ console.error(error120);
110761
110810
  process.exit(1);
110762
110811
  }
110763
110812
  spinner.text = "Fetching pull request details...";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/cli",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",
@@ -23,10 +23,10 @@
23
23
  "@ai-sdk/openai": "2.0.0-beta.11",
24
24
  "@ai-sdk/provider": "2.0.0-beta.1",
25
25
  "@ai-sdk/provider-utils": "3.0.0-beta.5",
26
- "@inquirer/prompts": "^7.2.3",
26
+ "@inquirer/prompts": "^7.8.0",
27
27
  "@openrouter/ai-sdk-provider": "^1.0.0-beta.6",
28
- "@polka-codes/cli-shared": "0.9.4",
29
- "@polka-codes/core": "0.9.4",
28
+ "@polka-codes/cli-shared": "0.9.6",
29
+ "@polka-codes/core": "0.9.6",
30
30
  "ai": "5.0.0-beta.24",
31
31
  "commander": "^13.0.0",
32
32
  "dotenv": "^16.4.7",