@polka-codes/cli 0.9.7 → 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.
- package/dist/index.js +69 -14
- package/package.json +1 -1
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.
|
|
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 (
|
|
76784
|
-
|
|
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
|
-
|
|
103872
|
-
|
|
103873
|
-
|
|
103874
|
-
|
|
103875
|
-
|
|
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
|
`);
|