@polka-codes/cli 0.10.25 → 0.10.26
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/agent/error-handling.d.ts +1 -1
- package/dist/bin.cjs +474 -364
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/config-validation.d.ts +22 -0
- package/dist/config-validation.d.ts.map +1 -0
- package/dist/config-validation.test.d.ts +2 -0
- package/dist/config-validation.test.d.ts.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/getModel.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +278 -122
- package/dist/options.d.ts.map +1 -1
- package/dist/runWorkflow.d.ts.map +1 -1
- package/dist/utils/command.d.ts +0 -35
- package/dist/utils/command.d.ts.map +1 -1
- package/dist/workflows/review.workflow.d.ts.map +1 -1
- package/dist/workflows/workflow.utils.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/bin.cjs
CHANGED
|
@@ -18849,7 +18849,7 @@ async function fetchWithTimeout(url2, timeoutMs) {
|
|
|
18849
18849
|
}
|
|
18850
18850
|
}
|
|
18851
18851
|
async function sleep(ms) {
|
|
18852
|
-
return new Promise((
|
|
18852
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
18853
18853
|
}
|
|
18854
18854
|
function shouldRetry(response, error48) {
|
|
18855
18855
|
if (error48) return true;
|
|
@@ -51493,8 +51493,8 @@ var require_retry = __commonJS({
|
|
|
51493
51493
|
}
|
|
51494
51494
|
const delay2 = getNextRetryDelay(config2);
|
|
51495
51495
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
51496
|
-
const backoff = config2.retryBackoff ? config2.retryBackoff(err, delay2) : new Promise((
|
|
51497
|
-
setTimeout(
|
|
51496
|
+
const backoff = config2.retryBackoff ? config2.retryBackoff(err, delay2) : new Promise((resolve11) => {
|
|
51497
|
+
setTimeout(resolve11, delay2);
|
|
51498
51498
|
});
|
|
51499
51499
|
if (config2.onRetryAttempt) {
|
|
51500
51500
|
await config2.onRetryAttempt(err);
|
|
@@ -52411,8 +52411,8 @@ var require_helpers = __commonJS({
|
|
|
52411
52411
|
function req(url2, opts = {}) {
|
|
52412
52412
|
const href = typeof url2 === "string" ? url2 : url2.href;
|
|
52413
52413
|
const req2 = (href.startsWith("https:") ? https2 : http3).request(url2, opts);
|
|
52414
|
-
const promise2 = new Promise((
|
|
52415
|
-
req2.once("response",
|
|
52414
|
+
const promise2 = new Promise((resolve11, reject) => {
|
|
52415
|
+
req2.once("response", resolve11).once("error", reject).end();
|
|
52416
52416
|
});
|
|
52417
52417
|
req2.then = promise2.then.bind(promise2);
|
|
52418
52418
|
return req2;
|
|
@@ -52591,7 +52591,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
52591
52591
|
var debug_1 = __importDefault(require_src());
|
|
52592
52592
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
52593
52593
|
function parseProxyResponse(socket) {
|
|
52594
|
-
return new Promise((
|
|
52594
|
+
return new Promise((resolve11, reject) => {
|
|
52595
52595
|
let buffersLength = 0;
|
|
52596
52596
|
const buffers = [];
|
|
52597
52597
|
function read() {
|
|
@@ -52657,7 +52657,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
52657
52657
|
}
|
|
52658
52658
|
debug("got proxy server response: %o %o", firstLine, headers);
|
|
52659
52659
|
cleanup();
|
|
52660
|
-
|
|
52660
|
+
resolve11({
|
|
52661
52661
|
connect: {
|
|
52662
52662
|
statusCode,
|
|
52663
52663
|
statusText,
|
|
@@ -52904,7 +52904,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
52904
52904
|
return new originalPromise(executor);
|
|
52905
52905
|
}
|
|
52906
52906
|
function promiseResolvedWith(value) {
|
|
52907
|
-
return newPromise((
|
|
52907
|
+
return newPromise((resolve11) => resolve11(value));
|
|
52908
52908
|
}
|
|
52909
52909
|
function promiseRejectedWith(reason) {
|
|
52910
52910
|
return originalPromiseReject(reason);
|
|
@@ -53074,8 +53074,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
53074
53074
|
return new TypeError("Cannot " + name25 + " a stream using a released reader");
|
|
53075
53075
|
}
|
|
53076
53076
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
53077
|
-
reader._closedPromise = newPromise((
|
|
53078
|
-
reader._closedPromise_resolve =
|
|
53077
|
+
reader._closedPromise = newPromise((resolve11, reject) => {
|
|
53078
|
+
reader._closedPromise_resolve = resolve11;
|
|
53079
53079
|
reader._closedPromise_reject = reject;
|
|
53080
53080
|
});
|
|
53081
53081
|
}
|
|
@@ -53249,8 +53249,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
53249
53249
|
}
|
|
53250
53250
|
let resolvePromise;
|
|
53251
53251
|
let rejectPromise;
|
|
53252
|
-
const promise2 = newPromise((
|
|
53253
|
-
resolvePromise =
|
|
53252
|
+
const promise2 = newPromise((resolve11, reject) => {
|
|
53253
|
+
resolvePromise = resolve11;
|
|
53254
53254
|
rejectPromise = reject;
|
|
53255
53255
|
});
|
|
53256
53256
|
const readRequest = {
|
|
@@ -53355,8 +53355,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
53355
53355
|
const reader = this._reader;
|
|
53356
53356
|
let resolvePromise;
|
|
53357
53357
|
let rejectPromise;
|
|
53358
|
-
const promise2 = newPromise((
|
|
53359
|
-
resolvePromise =
|
|
53358
|
+
const promise2 = newPromise((resolve11, reject) => {
|
|
53359
|
+
resolvePromise = resolve11;
|
|
53360
53360
|
rejectPromise = reject;
|
|
53361
53361
|
});
|
|
53362
53362
|
const readRequest = {
|
|
@@ -54375,8 +54375,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
54375
54375
|
}
|
|
54376
54376
|
let resolvePromise;
|
|
54377
54377
|
let rejectPromise;
|
|
54378
|
-
const promise2 = newPromise((
|
|
54379
|
-
resolvePromise =
|
|
54378
|
+
const promise2 = newPromise((resolve11, reject) => {
|
|
54379
|
+
resolvePromise = resolve11;
|
|
54380
54380
|
rejectPromise = reject;
|
|
54381
54381
|
});
|
|
54382
54382
|
const readIntoRequest = {
|
|
@@ -54688,10 +54688,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
54688
54688
|
wasAlreadyErroring = true;
|
|
54689
54689
|
reason = void 0;
|
|
54690
54690
|
}
|
|
54691
|
-
const promise2 = newPromise((
|
|
54691
|
+
const promise2 = newPromise((resolve11, reject) => {
|
|
54692
54692
|
stream._pendingAbortRequest = {
|
|
54693
54693
|
_promise: void 0,
|
|
54694
|
-
_resolve:
|
|
54694
|
+
_resolve: resolve11,
|
|
54695
54695
|
_reject: reject,
|
|
54696
54696
|
_reason: reason,
|
|
54697
54697
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -54708,9 +54708,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
54708
54708
|
if (state === "closed" || state === "errored") {
|
|
54709
54709
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
54710
54710
|
}
|
|
54711
|
-
const promise2 = newPromise((
|
|
54711
|
+
const promise2 = newPromise((resolve11, reject) => {
|
|
54712
54712
|
const closeRequest = {
|
|
54713
|
-
_resolve:
|
|
54713
|
+
_resolve: resolve11,
|
|
54714
54714
|
_reject: reject
|
|
54715
54715
|
};
|
|
54716
54716
|
stream._closeRequest = closeRequest;
|
|
@@ -54723,9 +54723,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
54723
54723
|
return promise2;
|
|
54724
54724
|
}
|
|
54725
54725
|
function WritableStreamAddWriteRequest(stream) {
|
|
54726
|
-
const promise2 = newPromise((
|
|
54726
|
+
const promise2 = newPromise((resolve11, reject) => {
|
|
54727
54727
|
const writeRequest = {
|
|
54728
|
-
_resolve:
|
|
54728
|
+
_resolve: resolve11,
|
|
54729
54729
|
_reject: reject
|
|
54730
54730
|
};
|
|
54731
54731
|
stream._writeRequests.push(writeRequest);
|
|
@@ -55341,8 +55341,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
55341
55341
|
return new TypeError("Cannot " + name25 + " a stream using a released writer");
|
|
55342
55342
|
}
|
|
55343
55343
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
55344
|
-
writer._closedPromise = newPromise((
|
|
55345
|
-
writer._closedPromise_resolve =
|
|
55344
|
+
writer._closedPromise = newPromise((resolve11, reject) => {
|
|
55345
|
+
writer._closedPromise_resolve = resolve11;
|
|
55346
55346
|
writer._closedPromise_reject = reject;
|
|
55347
55347
|
writer._closedPromiseState = "pending";
|
|
55348
55348
|
});
|
|
@@ -55378,8 +55378,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
55378
55378
|
writer._closedPromiseState = "resolved";
|
|
55379
55379
|
}
|
|
55380
55380
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
55381
|
-
writer._readyPromise = newPromise((
|
|
55382
|
-
writer._readyPromise_resolve =
|
|
55381
|
+
writer._readyPromise = newPromise((resolve11, reject) => {
|
|
55382
|
+
writer._readyPromise_resolve = resolve11;
|
|
55383
55383
|
writer._readyPromise_reject = reject;
|
|
55384
55384
|
});
|
|
55385
55385
|
writer._readyPromiseState = "pending";
|
|
@@ -55466,7 +55466,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
55466
55466
|
source._disturbed = true;
|
|
55467
55467
|
let shuttingDown = false;
|
|
55468
55468
|
let currentWrite = promiseResolvedWith(void 0);
|
|
55469
|
-
return newPromise((
|
|
55469
|
+
return newPromise((resolve11, reject) => {
|
|
55470
55470
|
let abortAlgorithm;
|
|
55471
55471
|
if (signal !== void 0) {
|
|
55472
55472
|
abortAlgorithm = () => {
|
|
@@ -55611,7 +55611,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
55611
55611
|
if (isError) {
|
|
55612
55612
|
reject(error48);
|
|
55613
55613
|
} else {
|
|
55614
|
-
|
|
55614
|
+
resolve11(void 0);
|
|
55615
55615
|
}
|
|
55616
55616
|
return null;
|
|
55617
55617
|
}
|
|
@@ -55892,8 +55892,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
55892
55892
|
let branch1;
|
|
55893
55893
|
let branch2;
|
|
55894
55894
|
let resolveCancelPromise;
|
|
55895
|
-
const cancelPromise = newPromise((
|
|
55896
|
-
resolveCancelPromise =
|
|
55895
|
+
const cancelPromise = newPromise((resolve11) => {
|
|
55896
|
+
resolveCancelPromise = resolve11;
|
|
55897
55897
|
});
|
|
55898
55898
|
function pullAlgorithm() {
|
|
55899
55899
|
if (reading) {
|
|
@@ -55984,8 +55984,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
55984
55984
|
let branch1;
|
|
55985
55985
|
let branch2;
|
|
55986
55986
|
let resolveCancelPromise;
|
|
55987
|
-
const cancelPromise = newPromise((
|
|
55988
|
-
resolveCancelPromise =
|
|
55987
|
+
const cancelPromise = newPromise((resolve11) => {
|
|
55988
|
+
resolveCancelPromise = resolve11;
|
|
55989
55989
|
});
|
|
55990
55990
|
function forwardReaderError(thisReader) {
|
|
55991
55991
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -56765,8 +56765,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56765
56765
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
56766
56766
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
56767
56767
|
let startPromise_resolve;
|
|
56768
|
-
const startPromise = newPromise((
|
|
56769
|
-
startPromise_resolve =
|
|
56768
|
+
const startPromise = newPromise((resolve11) => {
|
|
56769
|
+
startPromise_resolve = resolve11;
|
|
56770
56770
|
});
|
|
56771
56771
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
56772
56772
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -56859,8 +56859,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
56859
56859
|
if (stream._backpressureChangePromise !== void 0) {
|
|
56860
56860
|
stream._backpressureChangePromise_resolve();
|
|
56861
56861
|
}
|
|
56862
|
-
stream._backpressureChangePromise = newPromise((
|
|
56863
|
-
stream._backpressureChangePromise_resolve =
|
|
56862
|
+
stream._backpressureChangePromise = newPromise((resolve11) => {
|
|
56863
|
+
stream._backpressureChangePromise_resolve = resolve11;
|
|
56864
56864
|
});
|
|
56865
56865
|
stream._backpressure = backpressure;
|
|
56866
56866
|
}
|
|
@@ -57028,8 +57028,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57028
57028
|
return controller._finishPromise;
|
|
57029
57029
|
}
|
|
57030
57030
|
const readable = stream._readable;
|
|
57031
|
-
controller._finishPromise = newPromise((
|
|
57032
|
-
controller._finishPromise_resolve =
|
|
57031
|
+
controller._finishPromise = newPromise((resolve11, reject) => {
|
|
57032
|
+
controller._finishPromise_resolve = resolve11;
|
|
57033
57033
|
controller._finishPromise_reject = reject;
|
|
57034
57034
|
});
|
|
57035
57035
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -57055,8 +57055,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57055
57055
|
return controller._finishPromise;
|
|
57056
57056
|
}
|
|
57057
57057
|
const readable = stream._readable;
|
|
57058
|
-
controller._finishPromise = newPromise((
|
|
57059
|
-
controller._finishPromise_resolve =
|
|
57058
|
+
controller._finishPromise = newPromise((resolve11, reject) => {
|
|
57059
|
+
controller._finishPromise_resolve = resolve11;
|
|
57060
57060
|
controller._finishPromise_reject = reject;
|
|
57061
57061
|
});
|
|
57062
57062
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -57086,8 +57086,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
57086
57086
|
return controller._finishPromise;
|
|
57087
57087
|
}
|
|
57088
57088
|
const writable = stream._writable;
|
|
57089
|
-
controller._finishPromise = newPromise((
|
|
57090
|
-
controller._finishPromise_resolve =
|
|
57089
|
+
controller._finishPromise = newPromise((resolve11, reject) => {
|
|
57090
|
+
controller._finishPromise_resolve = resolve11;
|
|
57091
57091
|
controller._finishPromise_reject = reject;
|
|
57092
57092
|
});
|
|
57093
57093
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -59069,7 +59069,7 @@ __export(src_exports, {
|
|
|
59069
59069
|
isRedirect: () => isRedirect
|
|
59070
59070
|
});
|
|
59071
59071
|
async function fetch2(url2, options_) {
|
|
59072
|
-
return new Promise((
|
|
59072
|
+
return new Promise((resolve11, reject) => {
|
|
59073
59073
|
const request = new Request(url2, options_);
|
|
59074
59074
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
59075
59075
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -59078,7 +59078,7 @@ async function fetch2(url2, options_) {
|
|
|
59078
59078
|
if (parsedURL.protocol === "data:") {
|
|
59079
59079
|
const data = dist_default(request.url);
|
|
59080
59080
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
59081
|
-
|
|
59081
|
+
resolve11(response2);
|
|
59082
59082
|
return;
|
|
59083
59083
|
}
|
|
59084
59084
|
const send = (parsedURL.protocol === "https:" ? import_node_https.default : import_node_http2.default).request;
|
|
@@ -59200,7 +59200,7 @@ async function fetch2(url2, options_) {
|
|
|
59200
59200
|
if (responseReferrerPolicy) {
|
|
59201
59201
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
59202
59202
|
}
|
|
59203
|
-
|
|
59203
|
+
resolve11(fetch2(new Request(locationURL, requestOptions)));
|
|
59204
59204
|
finalize2();
|
|
59205
59205
|
return;
|
|
59206
59206
|
}
|
|
@@ -59233,7 +59233,7 @@ async function fetch2(url2, options_) {
|
|
|
59233
59233
|
const codings = headers.get("Content-Encoding");
|
|
59234
59234
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
59235
59235
|
response = new Response2(body, responseOptions);
|
|
59236
|
-
|
|
59236
|
+
resolve11(response);
|
|
59237
59237
|
return;
|
|
59238
59238
|
}
|
|
59239
59239
|
const zlibOptions = {
|
|
@@ -59247,7 +59247,7 @@ async function fetch2(url2, options_) {
|
|
|
59247
59247
|
}
|
|
59248
59248
|
});
|
|
59249
59249
|
response = new Response2(body, responseOptions);
|
|
59250
|
-
|
|
59250
|
+
resolve11(response);
|
|
59251
59251
|
return;
|
|
59252
59252
|
}
|
|
59253
59253
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -59271,12 +59271,12 @@ async function fetch2(url2, options_) {
|
|
|
59271
59271
|
});
|
|
59272
59272
|
}
|
|
59273
59273
|
response = new Response2(body, responseOptions);
|
|
59274
|
-
|
|
59274
|
+
resolve11(response);
|
|
59275
59275
|
});
|
|
59276
59276
|
raw.once("end", () => {
|
|
59277
59277
|
if (!response) {
|
|
59278
59278
|
response = new Response2(body, responseOptions);
|
|
59279
|
-
|
|
59279
|
+
resolve11(response);
|
|
59280
59280
|
}
|
|
59281
59281
|
});
|
|
59282
59282
|
return;
|
|
@@ -59288,11 +59288,11 @@ async function fetch2(url2, options_) {
|
|
|
59288
59288
|
}
|
|
59289
59289
|
});
|
|
59290
59290
|
response = new Response2(body, responseOptions);
|
|
59291
|
-
|
|
59291
|
+
resolve11(response);
|
|
59292
59292
|
return;
|
|
59293
59293
|
}
|
|
59294
59294
|
response = new Response2(body, responseOptions);
|
|
59295
|
-
|
|
59295
|
+
resolve11(response);
|
|
59296
59296
|
});
|
|
59297
59297
|
writeToStream(request_, request).catch(reject);
|
|
59298
59298
|
});
|
|
@@ -65625,7 +65625,7 @@ var require_jwtaccess = __commonJS({
|
|
|
65625
65625
|
}
|
|
65626
65626
|
}
|
|
65627
65627
|
fromStreamAsync(inputStream) {
|
|
65628
|
-
return new Promise((
|
|
65628
|
+
return new Promise((resolve11, reject) => {
|
|
65629
65629
|
if (!inputStream) {
|
|
65630
65630
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
65631
65631
|
}
|
|
@@ -65634,7 +65634,7 @@ var require_jwtaccess = __commonJS({
|
|
|
65634
65634
|
try {
|
|
65635
65635
|
const data = JSON.parse(s2);
|
|
65636
65636
|
this.fromJSON(data);
|
|
65637
|
-
|
|
65637
|
+
resolve11();
|
|
65638
65638
|
} catch (err) {
|
|
65639
65639
|
reject(err);
|
|
65640
65640
|
}
|
|
@@ -65873,7 +65873,7 @@ var require_jwtclient = __commonJS({
|
|
|
65873
65873
|
}
|
|
65874
65874
|
}
|
|
65875
65875
|
fromStreamAsync(inputStream) {
|
|
65876
|
-
return new Promise((
|
|
65876
|
+
return new Promise((resolve11, reject) => {
|
|
65877
65877
|
if (!inputStream) {
|
|
65878
65878
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
65879
65879
|
}
|
|
@@ -65882,7 +65882,7 @@ var require_jwtclient = __commonJS({
|
|
|
65882
65882
|
try {
|
|
65883
65883
|
const data = JSON.parse(s2);
|
|
65884
65884
|
this.fromJSON(data);
|
|
65885
|
-
|
|
65885
|
+
resolve11();
|
|
65886
65886
|
} catch (e2) {
|
|
65887
65887
|
reject(e2);
|
|
65888
65888
|
}
|
|
@@ -66015,7 +66015,7 @@ var require_refreshclient = __commonJS({
|
|
|
66015
66015
|
}
|
|
66016
66016
|
}
|
|
66017
66017
|
async fromStreamAsync(inputStream) {
|
|
66018
|
-
return new Promise((
|
|
66018
|
+
return new Promise((resolve11, reject) => {
|
|
66019
66019
|
if (!inputStream) {
|
|
66020
66020
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
66021
66021
|
}
|
|
@@ -66024,7 +66024,7 @@ var require_refreshclient = __commonJS({
|
|
|
66024
66024
|
try {
|
|
66025
66025
|
const data = JSON.parse(s2);
|
|
66026
66026
|
this.fromJSON(data);
|
|
66027
|
-
return
|
|
66027
|
+
return resolve11();
|
|
66028
66028
|
} catch (err) {
|
|
66029
66029
|
return reject(err);
|
|
66030
66030
|
}
|
|
@@ -67862,7 +67862,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
67862
67862
|
* @return A promise that resolves with the executable response.
|
|
67863
67863
|
*/
|
|
67864
67864
|
retrieveResponseFromExecutable(envMap) {
|
|
67865
|
-
return new Promise((
|
|
67865
|
+
return new Promise((resolve11, reject) => {
|
|
67866
67866
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
67867
67867
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
67868
67868
|
});
|
|
@@ -67884,7 +67884,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
67884
67884
|
try {
|
|
67885
67885
|
const responseJson = JSON.parse(output);
|
|
67886
67886
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
67887
|
-
return
|
|
67887
|
+
return resolve11(response);
|
|
67888
67888
|
} catch (error48) {
|
|
67889
67889
|
if (error48 instanceof executable_response_1.ExecutableResponseError) {
|
|
67890
67890
|
return reject(error48);
|
|
@@ -68790,7 +68790,7 @@ var require_googleauth = __commonJS({
|
|
|
68790
68790
|
}
|
|
68791
68791
|
}
|
|
68792
68792
|
fromStreamAsync(inputStream, options) {
|
|
68793
|
-
return new Promise((
|
|
68793
|
+
return new Promise((resolve11, reject) => {
|
|
68794
68794
|
if (!inputStream) {
|
|
68795
68795
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
68796
68796
|
}
|
|
@@ -68800,7 +68800,7 @@ var require_googleauth = __commonJS({
|
|
|
68800
68800
|
try {
|
|
68801
68801
|
const data = JSON.parse(chunks.join(""));
|
|
68802
68802
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
68803
|
-
return
|
|
68803
|
+
return resolve11(r2);
|
|
68804
68804
|
} catch (err) {
|
|
68805
68805
|
if (!this.keyFilename)
|
|
68806
68806
|
throw err;
|
|
@@ -68810,7 +68810,7 @@ var require_googleauth = __commonJS({
|
|
|
68810
68810
|
});
|
|
68811
68811
|
this.cachedCredential = client;
|
|
68812
68812
|
this.setGapicJWTValues(client);
|
|
68813
|
-
return
|
|
68813
|
+
return resolve11(client);
|
|
68814
68814
|
}
|
|
68815
68815
|
} catch (err) {
|
|
68816
68816
|
return reject(err);
|
|
@@ -68846,17 +68846,17 @@ var require_googleauth = __commonJS({
|
|
|
68846
68846
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
68847
68847
|
*/
|
|
68848
68848
|
async getDefaultServiceProjectId() {
|
|
68849
|
-
return new Promise((
|
|
68849
|
+
return new Promise((resolve11) => {
|
|
68850
68850
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
|
|
68851
68851
|
if (!err && stdout) {
|
|
68852
68852
|
try {
|
|
68853
68853
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
68854
|
-
|
|
68854
|
+
resolve11(projectId);
|
|
68855
68855
|
return;
|
|
68856
68856
|
} catch (e2) {
|
|
68857
68857
|
}
|
|
68858
68858
|
}
|
|
68859
|
-
|
|
68859
|
+
resolve11(null);
|
|
68860
68860
|
});
|
|
68861
68861
|
});
|
|
68862
68862
|
}
|
|
@@ -74022,13 +74022,13 @@ var init_promise_polyfill = __esm({
|
|
|
74022
74022
|
// Available starting from Node 22
|
|
74023
74023
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
74024
74024
|
static withResolver() {
|
|
74025
|
-
let
|
|
74025
|
+
let resolve11;
|
|
74026
74026
|
let reject;
|
|
74027
74027
|
const promise2 = new Promise((res, rej) => {
|
|
74028
|
-
|
|
74028
|
+
resolve11 = res;
|
|
74029
74029
|
reject = rej;
|
|
74030
74030
|
});
|
|
74031
|
-
return { promise: promise2, resolve:
|
|
74031
|
+
return { promise: promise2, resolve: resolve11, reject };
|
|
74032
74032
|
}
|
|
74033
74033
|
};
|
|
74034
74034
|
}
|
|
@@ -74065,7 +74065,7 @@ function createPrompt(view) {
|
|
|
74065
74065
|
output
|
|
74066
74066
|
});
|
|
74067
74067
|
const screen = new ScreenManager(rl);
|
|
74068
|
-
const { promise: promise2, resolve:
|
|
74068
|
+
const { promise: promise2, resolve: resolve11, reject } = PromisePolyfill.withResolver();
|
|
74069
74069
|
const cancel = () => reject(new CancelPromptError());
|
|
74070
74070
|
if (signal) {
|
|
74071
74071
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -74093,7 +74093,7 @@ function createPrompt(view) {
|
|
|
74093
74093
|
cycle(() => {
|
|
74094
74094
|
try {
|
|
74095
74095
|
const nextView = view(config2, (value) => {
|
|
74096
|
-
setImmediate(() =>
|
|
74096
|
+
setImmediate(() => resolve11(value));
|
|
74097
74097
|
});
|
|
74098
74098
|
if (nextView === void 0) {
|
|
74099
74099
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -84934,7 +84934,7 @@ async function searchFiles(path12, regex, filePattern, cwd, excludeFiles) {
|
|
|
84934
84934
|
}
|
|
84935
84935
|
}
|
|
84936
84936
|
args.push(regex, path12);
|
|
84937
|
-
return new Promise((
|
|
84937
|
+
return new Promise((resolve11, reject) => {
|
|
84938
84938
|
const results = [];
|
|
84939
84939
|
const rg = (0, import_node_child_process2.spawn)("rg", args, {
|
|
84940
84940
|
cwd,
|
|
@@ -84952,7 +84952,7 @@ async function searchFiles(path12, regex, filePattern, cwd, excludeFiles) {
|
|
|
84952
84952
|
reject(new Error(`Ripgrep process exited with code ${code2}`));
|
|
84953
84953
|
return;
|
|
84954
84954
|
}
|
|
84955
|
-
|
|
84955
|
+
resolve11(results);
|
|
84956
84956
|
});
|
|
84957
84957
|
});
|
|
84958
84958
|
}
|
|
@@ -85212,7 +85212,7 @@ ${content}`;
|
|
|
85212
85212
|
};
|
|
85213
85213
|
},
|
|
85214
85214
|
executeCommand: (command, _needApprove) => {
|
|
85215
|
-
return new Promise((
|
|
85215
|
+
return new Promise((resolve11, reject) => {
|
|
85216
85216
|
options.command?.onStarted(command);
|
|
85217
85217
|
const child = (0, import_node_child_process3.spawn)(command, [], {
|
|
85218
85218
|
shell: true,
|
|
@@ -85237,7 +85237,7 @@ ${content}`;
|
|
|
85237
85237
|
try {
|
|
85238
85238
|
const summary = await options.summarizeOutput(stdoutText, stderrText);
|
|
85239
85239
|
if (summary) {
|
|
85240
|
-
|
|
85240
|
+
resolve11({
|
|
85241
85241
|
summary,
|
|
85242
85242
|
stdout: stdoutText,
|
|
85243
85243
|
stderr: stderrText,
|
|
@@ -85249,7 +85249,7 @@ ${content}`;
|
|
|
85249
85249
|
console.error("Summarization failed:", _e);
|
|
85250
85250
|
}
|
|
85251
85251
|
}
|
|
85252
|
-
|
|
85252
|
+
resolve11({
|
|
85253
85253
|
stdout: stdoutText,
|
|
85254
85254
|
stderr: stderrText,
|
|
85255
85255
|
exitCode: code2 ?? 0
|
|
@@ -87616,7 +87616,7 @@ var init_sqlite_memory_store = __esm({
|
|
|
87616
87616
|
}
|
|
87617
87617
|
}
|
|
87618
87618
|
if (i2 < retries - 1) {
|
|
87619
|
-
await new Promise((
|
|
87619
|
+
await new Promise((resolve11) => setTimeout(resolve11, delay2));
|
|
87620
87620
|
} else {
|
|
87621
87621
|
throw new Error(`Cannot acquire lock after ${retries} retries (file: ${this.lockfilePath})`);
|
|
87622
87622
|
}
|
|
@@ -87654,7 +87654,7 @@ var init_sqlite_memory_store = __esm({
|
|
|
87654
87654
|
return () => this.release(owner);
|
|
87655
87655
|
}
|
|
87656
87656
|
while (this.locked) {
|
|
87657
|
-
await new Promise((
|
|
87657
|
+
await new Promise((resolve11) => this.queue.push(resolve11));
|
|
87658
87658
|
}
|
|
87659
87659
|
this.locked = true;
|
|
87660
87660
|
this.owner = owner;
|
|
@@ -89057,7 +89057,7 @@ ${event.systemPrompt}`);
|
|
|
89057
89057
|
|
|
89058
89058
|
// ../cli-shared/src/utils/readMultiline.ts
|
|
89059
89059
|
function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
89060
|
-
return new Promise((
|
|
89060
|
+
return new Promise((resolve11) => {
|
|
89061
89061
|
console.log(prompt);
|
|
89062
89062
|
const rl = import_node_readline.default.createInterface({
|
|
89063
89063
|
input: process.stdin,
|
|
@@ -89069,7 +89069,7 @@ function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
|
89069
89069
|
lines.push(line);
|
|
89070
89070
|
});
|
|
89071
89071
|
rl.on("close", () => {
|
|
89072
|
-
|
|
89072
|
+
resolve11(lines.join("\n"));
|
|
89073
89073
|
});
|
|
89074
89074
|
});
|
|
89075
89075
|
}
|
|
@@ -110577,6 +110577,145 @@ var init_env = __esm({
|
|
|
110577
110577
|
}
|
|
110578
110578
|
});
|
|
110579
110579
|
|
|
110580
|
+
// src/errors.ts
|
|
110581
|
+
function createProviderErrorFromStatus(provider, model, statusCode, cause) {
|
|
110582
|
+
switch (statusCode) {
|
|
110583
|
+
case 400:
|
|
110584
|
+
return new InvalidRequestError(provider, model, "Bad request", cause);
|
|
110585
|
+
case 401:
|
|
110586
|
+
return new AuthenticationError(provider, model, cause);
|
|
110587
|
+
case 403:
|
|
110588
|
+
case 404:
|
|
110589
|
+
return new ModelAccessError(provider, model, statusCode, cause);
|
|
110590
|
+
case 429:
|
|
110591
|
+
return new RateLimitError(provider, model, void 0, cause);
|
|
110592
|
+
default:
|
|
110593
|
+
if (statusCode >= 500) {
|
|
110594
|
+
return new ProviderUnavailableError(provider, model, statusCode, cause);
|
|
110595
|
+
}
|
|
110596
|
+
return new InvalidRequestError(provider, model, `HTTP ${statusCode}`, cause);
|
|
110597
|
+
}
|
|
110598
|
+
}
|
|
110599
|
+
var UserCancelledError, ConfigurationError, MissingDependencyError, ProviderError, ProviderUnavailableError, RateLimitError, ProviderTimeoutError, AuthenticationError, ModelAccessError, InvalidRequestError, QuotaExceededError, MaxRetriesExceededError;
|
|
110600
|
+
var init_errors6 = __esm({
|
|
110601
|
+
"src/errors.ts"() {
|
|
110602
|
+
"use strict";
|
|
110603
|
+
init_cjs_shims();
|
|
110604
|
+
init_src();
|
|
110605
|
+
UserCancelledError = createErrorClass("UserCancelledError", (args) => args[0] ?? "User cancelled");
|
|
110606
|
+
ConfigurationError = createErrorClass("ConfigurationError", (args) => args[0]);
|
|
110607
|
+
MissingDependencyError = createErrorClass("MissingDependencyError", (args) => args[1]);
|
|
110608
|
+
ProviderError = class extends Error {
|
|
110609
|
+
provider;
|
|
110610
|
+
model;
|
|
110611
|
+
retryable;
|
|
110612
|
+
cause;
|
|
110613
|
+
constructor(provider, model, message, retryable, cause) {
|
|
110614
|
+
super(message);
|
|
110615
|
+
this.name = this.constructor.name;
|
|
110616
|
+
this.provider = provider;
|
|
110617
|
+
this.model = model;
|
|
110618
|
+
this.retryable = retryable;
|
|
110619
|
+
this.cause = cause;
|
|
110620
|
+
}
|
|
110621
|
+
};
|
|
110622
|
+
ProviderUnavailableError = class extends ProviderError {
|
|
110623
|
+
constructor(provider, model, statusCode, cause) {
|
|
110624
|
+
super(
|
|
110625
|
+
provider,
|
|
110626
|
+
model,
|
|
110627
|
+
`${provider} API is temporarily unavailable (HTTP ${statusCode}). The service may be experiencing issues. Please try again in a few minutes.`,
|
|
110628
|
+
true,
|
|
110629
|
+
cause
|
|
110630
|
+
);
|
|
110631
|
+
}
|
|
110632
|
+
};
|
|
110633
|
+
RateLimitError = class extends ProviderError {
|
|
110634
|
+
retryAfter;
|
|
110635
|
+
constructor(provider, model, retryAfter, cause) {
|
|
110636
|
+
const message = retryAfter ? `${provider} rate limit exceeded. Please retry after ${retryAfter} seconds.` : `${provider} rate limit exceeded. Please wait a few minutes before retrying.`;
|
|
110637
|
+
super(provider, model, message, true, cause);
|
|
110638
|
+
this.retryAfter = retryAfter;
|
|
110639
|
+
}
|
|
110640
|
+
};
|
|
110641
|
+
ProviderTimeoutError = class extends ProviderError {
|
|
110642
|
+
timeoutSeconds;
|
|
110643
|
+
constructor(provider, model, timeoutSeconds, cause) {
|
|
110644
|
+
super(
|
|
110645
|
+
provider,
|
|
110646
|
+
model,
|
|
110647
|
+
`${provider} request timed out after ${timeoutSeconds} seconds. This could be due to network issues or the service being slow. Please check your connection and try again.`,
|
|
110648
|
+
true,
|
|
110649
|
+
cause
|
|
110650
|
+
);
|
|
110651
|
+
this.timeoutSeconds = timeoutSeconds;
|
|
110652
|
+
}
|
|
110653
|
+
};
|
|
110654
|
+
AuthenticationError = class extends ProviderError {
|
|
110655
|
+
constructor(provider, model, cause) {
|
|
110656
|
+
super(
|
|
110657
|
+
provider,
|
|
110658
|
+
model,
|
|
110659
|
+
`${provider} authentication failed for model '${model}'. Please check your API key is valid and has not expired. Run 'polka init' to reconfigure.`,
|
|
110660
|
+
false,
|
|
110661
|
+
cause
|
|
110662
|
+
);
|
|
110663
|
+
}
|
|
110664
|
+
};
|
|
110665
|
+
ModelAccessError = class extends ProviderError {
|
|
110666
|
+
constructor(provider, model, statusCode, cause) {
|
|
110667
|
+
super(
|
|
110668
|
+
provider,
|
|
110669
|
+
model,
|
|
110670
|
+
`${provider} model '${model}' is not available (HTTP ${statusCode}). This could mean the model doesn't exist, you don't have access, or it's not enabled in your account. Please check your model configuration.`,
|
|
110671
|
+
false,
|
|
110672
|
+
cause
|
|
110673
|
+
);
|
|
110674
|
+
}
|
|
110675
|
+
};
|
|
110676
|
+
InvalidRequestError = class extends ProviderError {
|
|
110677
|
+
constructor(provider, model, details, cause) {
|
|
110678
|
+
super(
|
|
110679
|
+
provider,
|
|
110680
|
+
model,
|
|
110681
|
+
`${provider} rejected the request: ${details}. Please check your request parameters and try again.`,
|
|
110682
|
+
false,
|
|
110683
|
+
cause
|
|
110684
|
+
);
|
|
110685
|
+
}
|
|
110686
|
+
};
|
|
110687
|
+
QuotaExceededError = class extends ProviderError {
|
|
110688
|
+
currentCost;
|
|
110689
|
+
maxCost;
|
|
110690
|
+
constructor(provider, model, currentCost, maxCost) {
|
|
110691
|
+
super(
|
|
110692
|
+
provider,
|
|
110693
|
+
model,
|
|
110694
|
+
`${provider} quota exceeded for model '${model}'. Current cost: $${currentCost.toFixed(2)}, Max budget: $${maxCost.toFixed(2)}. Adjust your budget with 'polka init' or reduce usage.`,
|
|
110695
|
+
false
|
|
110696
|
+
);
|
|
110697
|
+
this.currentCost = currentCost;
|
|
110698
|
+
this.maxCost = maxCost;
|
|
110699
|
+
}
|
|
110700
|
+
};
|
|
110701
|
+
MaxRetriesExceededError = class extends ProviderError {
|
|
110702
|
+
attempts;
|
|
110703
|
+
lastError;
|
|
110704
|
+
constructor(provider, model, attempts, lastError) {
|
|
110705
|
+
super(
|
|
110706
|
+
provider,
|
|
110707
|
+
model,
|
|
110708
|
+
`${provider} failed after ${attempts} retry attempts for model '${model}'. Last error: ${lastError.message}. Please check your network connection and verify the service is operational.`,
|
|
110709
|
+
false,
|
|
110710
|
+
lastError
|
|
110711
|
+
);
|
|
110712
|
+
this.attempts = attempts;
|
|
110713
|
+
this.lastError = lastError;
|
|
110714
|
+
}
|
|
110715
|
+
};
|
|
110716
|
+
}
|
|
110717
|
+
});
|
|
110718
|
+
|
|
110580
110719
|
// src/getModel.ts
|
|
110581
110720
|
function headersToObject(headers) {
|
|
110582
110721
|
if (!headers) {
|
|
@@ -110620,6 +110759,7 @@ var init_getModel = __esm({
|
|
|
110620
110759
|
init_dist23();
|
|
110621
110760
|
init_dist24();
|
|
110622
110761
|
init_env();
|
|
110762
|
+
init_errors6();
|
|
110623
110763
|
AiProvider = /* @__PURE__ */ ((AiProvider2) => {
|
|
110624
110764
|
AiProvider2["Anthropic"] = "anthropic";
|
|
110625
110765
|
AiProvider2["DeepSeek"] = "deepseek";
|
|
@@ -110805,7 +110945,7 @@ var init_getModel = __esm({
|
|
|
110805
110945
|
}
|
|
110806
110946
|
case "openai-compatible" /* OpenAICompatible */: {
|
|
110807
110947
|
if (!config2.baseUrl) {
|
|
110808
|
-
throw new
|
|
110948
|
+
throw new ConfigurationError("OpenAI-compatible providers require a baseUrl");
|
|
110809
110949
|
}
|
|
110810
110950
|
const openaiCompatible = createOpenAICompatible({
|
|
110811
110951
|
apiKey: config2.apiKey,
|
|
@@ -111165,6 +111305,7 @@ var init_workflow_utils = __esm({
|
|
|
111165
111305
|
init_src3();
|
|
111166
111306
|
init_zod();
|
|
111167
111307
|
init_ApiProviderConfig();
|
|
111308
|
+
init_errors6();
|
|
111168
111309
|
unquotePath = (path12) => {
|
|
111169
111310
|
if (path12.startsWith('"') && path12.endsWith('"')) {
|
|
111170
111311
|
try {
|
|
@@ -111187,7 +111328,7 @@ var init_workflow_utils = __esm({
|
|
|
111187
111328
|
checkGhInstalled = async (executeCommand2) => {
|
|
111188
111329
|
const result = await executeCommand2({ command: "gh", args: ["--version"] });
|
|
111189
111330
|
if (result.exitCode !== 0) {
|
|
111190
|
-
throw new
|
|
111331
|
+
throw new MissingDependencyError("gh", "GitHub CLI (gh) is not installed. Please install it from https://cli.github.com/");
|
|
111191
111332
|
}
|
|
111192
111333
|
};
|
|
111193
111334
|
getDefaultBranch = async (executeCommand2) => {
|
|
@@ -111391,143 +111532,6 @@ ${memoryContext}`
|
|
|
111391
111532
|
}
|
|
111392
111533
|
});
|
|
111393
111534
|
|
|
111394
|
-
// src/errors.ts
|
|
111395
|
-
function createProviderErrorFromStatus(provider, model, statusCode, cause) {
|
|
111396
|
-
switch (statusCode) {
|
|
111397
|
-
case 400:
|
|
111398
|
-
return new InvalidRequestError(provider, model, "Bad request", cause);
|
|
111399
|
-
case 401:
|
|
111400
|
-
return new AuthenticationError(provider, model, cause);
|
|
111401
|
-
case 403:
|
|
111402
|
-
case 404:
|
|
111403
|
-
return new ModelAccessError(provider, model, statusCode, cause);
|
|
111404
|
-
case 429:
|
|
111405
|
-
return new RateLimitError(provider, model, void 0, cause);
|
|
111406
|
-
default:
|
|
111407
|
-
if (statusCode >= 500) {
|
|
111408
|
-
return new ProviderUnavailableError(provider, model, statusCode, cause);
|
|
111409
|
-
}
|
|
111410
|
-
return new InvalidRequestError(provider, model, `HTTP ${statusCode}`, cause);
|
|
111411
|
-
}
|
|
111412
|
-
}
|
|
111413
|
-
var UserCancelledError, ProviderError, ProviderUnavailableError, RateLimitError, ProviderTimeoutError, AuthenticationError, ModelAccessError, InvalidRequestError, QuotaExceededError, MaxRetriesExceededError;
|
|
111414
|
-
var init_errors6 = __esm({
|
|
111415
|
-
"src/errors.ts"() {
|
|
111416
|
-
"use strict";
|
|
111417
|
-
init_cjs_shims();
|
|
111418
|
-
init_src();
|
|
111419
|
-
UserCancelledError = createErrorClass("UserCancelledError", (args) => args[0] ?? "User cancelled");
|
|
111420
|
-
ProviderError = class extends Error {
|
|
111421
|
-
provider;
|
|
111422
|
-
model;
|
|
111423
|
-
retryable;
|
|
111424
|
-
cause;
|
|
111425
|
-
constructor(provider, model, message, retryable, cause) {
|
|
111426
|
-
super(message);
|
|
111427
|
-
this.name = this.constructor.name;
|
|
111428
|
-
this.provider = provider;
|
|
111429
|
-
this.model = model;
|
|
111430
|
-
this.retryable = retryable;
|
|
111431
|
-
this.cause = cause;
|
|
111432
|
-
}
|
|
111433
|
-
};
|
|
111434
|
-
ProviderUnavailableError = class extends ProviderError {
|
|
111435
|
-
constructor(provider, model, statusCode, cause) {
|
|
111436
|
-
super(
|
|
111437
|
-
provider,
|
|
111438
|
-
model,
|
|
111439
|
-
`${provider} API is temporarily unavailable (HTTP ${statusCode}). The service may be experiencing issues. Please try again in a few minutes.`,
|
|
111440
|
-
true,
|
|
111441
|
-
cause
|
|
111442
|
-
);
|
|
111443
|
-
}
|
|
111444
|
-
};
|
|
111445
|
-
RateLimitError = class extends ProviderError {
|
|
111446
|
-
retryAfter;
|
|
111447
|
-
constructor(provider, model, retryAfter, cause) {
|
|
111448
|
-
const message = retryAfter ? `${provider} rate limit exceeded. Please retry after ${retryAfter} seconds.` : `${provider} rate limit exceeded. Please wait a few minutes before retrying.`;
|
|
111449
|
-
super(provider, model, message, true, cause);
|
|
111450
|
-
this.retryAfter = retryAfter;
|
|
111451
|
-
}
|
|
111452
|
-
};
|
|
111453
|
-
ProviderTimeoutError = class extends ProviderError {
|
|
111454
|
-
timeoutSeconds;
|
|
111455
|
-
constructor(provider, model, timeoutSeconds, cause) {
|
|
111456
|
-
super(
|
|
111457
|
-
provider,
|
|
111458
|
-
model,
|
|
111459
|
-
`${provider} request timed out after ${timeoutSeconds} seconds. This could be due to network issues or the service being slow. Please check your connection and try again.`,
|
|
111460
|
-
true,
|
|
111461
|
-
cause
|
|
111462
|
-
);
|
|
111463
|
-
this.timeoutSeconds = timeoutSeconds;
|
|
111464
|
-
}
|
|
111465
|
-
};
|
|
111466
|
-
AuthenticationError = class extends ProviderError {
|
|
111467
|
-
constructor(provider, model, cause) {
|
|
111468
|
-
super(
|
|
111469
|
-
provider,
|
|
111470
|
-
model,
|
|
111471
|
-
`${provider} authentication failed for model '${model}'. Please check your API key is valid and has not expired. Run 'polka init' to reconfigure.`,
|
|
111472
|
-
false,
|
|
111473
|
-
cause
|
|
111474
|
-
);
|
|
111475
|
-
}
|
|
111476
|
-
};
|
|
111477
|
-
ModelAccessError = class extends ProviderError {
|
|
111478
|
-
constructor(provider, model, statusCode, cause) {
|
|
111479
|
-
super(
|
|
111480
|
-
provider,
|
|
111481
|
-
model,
|
|
111482
|
-
`${provider} model '${model}' is not available (HTTP ${statusCode}). This could mean the model doesn't exist, you don't have access, or it's not enabled in your account. Please check your model configuration.`,
|
|
111483
|
-
false,
|
|
111484
|
-
cause
|
|
111485
|
-
);
|
|
111486
|
-
}
|
|
111487
|
-
};
|
|
111488
|
-
InvalidRequestError = class extends ProviderError {
|
|
111489
|
-
constructor(provider, model, details, cause) {
|
|
111490
|
-
super(
|
|
111491
|
-
provider,
|
|
111492
|
-
model,
|
|
111493
|
-
`${provider} rejected the request: ${details}. Please check your request parameters and try again.`,
|
|
111494
|
-
false,
|
|
111495
|
-
cause
|
|
111496
|
-
);
|
|
111497
|
-
}
|
|
111498
|
-
};
|
|
111499
|
-
QuotaExceededError = class extends ProviderError {
|
|
111500
|
-
currentCost;
|
|
111501
|
-
maxCost;
|
|
111502
|
-
constructor(provider, model, currentCost, maxCost) {
|
|
111503
|
-
super(
|
|
111504
|
-
provider,
|
|
111505
|
-
model,
|
|
111506
|
-
`${provider} quota exceeded for model '${model}'. Current cost: $${currentCost.toFixed(2)}, Max budget: $${maxCost.toFixed(2)}. Adjust your budget with 'polka init' or reduce usage.`,
|
|
111507
|
-
false
|
|
111508
|
-
);
|
|
111509
|
-
this.currentCost = currentCost;
|
|
111510
|
-
this.maxCost = maxCost;
|
|
111511
|
-
}
|
|
111512
|
-
};
|
|
111513
|
-
MaxRetriesExceededError = class extends ProviderError {
|
|
111514
|
-
attempts;
|
|
111515
|
-
lastError;
|
|
111516
|
-
constructor(provider, model, attempts, lastError) {
|
|
111517
|
-
super(
|
|
111518
|
-
provider,
|
|
111519
|
-
model,
|
|
111520
|
-
`${provider} failed after ${attempts} retry attempts for model '${model}'. Last error: ${lastError.message}. Please check your network connection and verify the service is operational.`,
|
|
111521
|
-
false,
|
|
111522
|
-
lastError
|
|
111523
|
-
);
|
|
111524
|
-
this.attempts = attempts;
|
|
111525
|
-
this.lastError = lastError;
|
|
111526
|
-
}
|
|
111527
|
-
};
|
|
111528
|
-
}
|
|
111529
|
-
});
|
|
111530
|
-
|
|
111531
111535
|
// src/workflows/plan.workflow.ts
|
|
111532
111536
|
var plan_workflow_exports = {};
|
|
111533
111537
|
__export(plan_workflow_exports, {
|
|
@@ -112764,6 +112768,7 @@ var init_review_workflow = __esm({
|
|
|
112764
112768
|
init_cjs_shims();
|
|
112765
112769
|
import_node_path11 = __toESM(require("path"), 1);
|
|
112766
112770
|
init_src();
|
|
112771
|
+
init_errors6();
|
|
112767
112772
|
init_tools3();
|
|
112768
112773
|
init_git_file_tools();
|
|
112769
112774
|
init_prompts2();
|
|
@@ -112807,7 +112812,7 @@ var init_review_workflow = __esm({
|
|
|
112807
112812
|
if (pr) {
|
|
112808
112813
|
const ghCheckResult = await tools.executeCommand({ command: "gh", args: ["--version"] });
|
|
112809
112814
|
if (ghCheckResult.exitCode !== 0) {
|
|
112810
|
-
throw new
|
|
112815
|
+
throw new MissingDependencyError("gh", "GitHub CLI (gh) is not installed. Please install it from https://cli.github.com/");
|
|
112811
112816
|
}
|
|
112812
112817
|
await step(`Checking out PR #${pr}...`, async () => {
|
|
112813
112818
|
const checkoutResult = await tools.executeCommand({
|
|
@@ -117312,7 +117317,7 @@ var init_protocol = __esm({
|
|
|
117312
117317
|
return;
|
|
117313
117318
|
}
|
|
117314
117319
|
const pollInterval = task3.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
117315
|
-
await new Promise((
|
|
117320
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
117316
117321
|
options?.signal?.throwIfAborted();
|
|
117317
117322
|
}
|
|
117318
117323
|
} catch (error48) {
|
|
@@ -117329,7 +117334,7 @@ var init_protocol = __esm({
|
|
|
117329
117334
|
*/
|
|
117330
117335
|
request(request, resultSchema, options) {
|
|
117331
117336
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task: task2, relatedTask } = options ?? {};
|
|
117332
|
-
return new Promise((
|
|
117337
|
+
return new Promise((resolve11, reject) => {
|
|
117333
117338
|
const earlyReject = (error48) => {
|
|
117334
117339
|
reject(error48);
|
|
117335
117340
|
};
|
|
@@ -117407,7 +117412,7 @@ var init_protocol = __esm({
|
|
|
117407
117412
|
if (!parseResult.success) {
|
|
117408
117413
|
reject(parseResult.error);
|
|
117409
117414
|
} else {
|
|
117410
|
-
|
|
117415
|
+
resolve11(parseResult.data);
|
|
117411
117416
|
}
|
|
117412
117417
|
} catch (error48) {
|
|
117413
117418
|
reject(error48);
|
|
@@ -117668,12 +117673,12 @@ var init_protocol = __esm({
|
|
|
117668
117673
|
}
|
|
117669
117674
|
} catch {
|
|
117670
117675
|
}
|
|
117671
|
-
return new Promise((
|
|
117676
|
+
return new Promise((resolve11, reject) => {
|
|
117672
117677
|
if (signal.aborted) {
|
|
117673
117678
|
reject(new McpError2(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
117674
117679
|
return;
|
|
117675
117680
|
}
|
|
117676
|
-
const timeoutId = setTimeout(
|
|
117681
|
+
const timeoutId = setTimeout(resolve11, interval);
|
|
117677
117682
|
signal.addEventListener("abort", () => {
|
|
117678
117683
|
clearTimeout(timeoutId);
|
|
117679
117684
|
reject(new McpError2(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -120721,7 +120726,7 @@ var require_compile = __commonJS({
|
|
|
120721
120726
|
const schOrFunc = root2.refs[ref];
|
|
120722
120727
|
if (schOrFunc)
|
|
120723
120728
|
return schOrFunc;
|
|
120724
|
-
let _sch =
|
|
120729
|
+
let _sch = resolve11.call(this, root2, ref);
|
|
120725
120730
|
if (_sch === void 0) {
|
|
120726
120731
|
const schema = (_a26 = root2.localRefs) === null || _a26 === void 0 ? void 0 : _a26[ref];
|
|
120727
120732
|
const { schemaId } = this.opts;
|
|
@@ -120748,7 +120753,7 @@ var require_compile = __commonJS({
|
|
|
120748
120753
|
function sameSchemaEnv(s1, s2) {
|
|
120749
120754
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
120750
120755
|
}
|
|
120751
|
-
function
|
|
120756
|
+
function resolve11(root2, ref) {
|
|
120752
120757
|
let sch;
|
|
120753
120758
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
120754
120759
|
ref = sch;
|
|
@@ -121326,7 +121331,7 @@ var require_fast_uri = __commonJS({
|
|
|
121326
121331
|
}
|
|
121327
121332
|
return uri;
|
|
121328
121333
|
}
|
|
121329
|
-
function
|
|
121334
|
+
function resolve11(baseURI, relativeURI, options) {
|
|
121330
121335
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
121331
121336
|
const resolved = resolveComponent(parse8(baseURI, schemelessOptions), parse8(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
121332
121337
|
schemelessOptions.skipEscape = true;
|
|
@@ -121553,7 +121558,7 @@ var require_fast_uri = __commonJS({
|
|
|
121553
121558
|
var fastUri = {
|
|
121554
121559
|
SCHEMES,
|
|
121555
121560
|
normalize: normalize6,
|
|
121556
|
-
resolve:
|
|
121561
|
+
resolve: resolve11,
|
|
121557
121562
|
resolveComponent,
|
|
121558
121563
|
equal,
|
|
121559
121564
|
serialize,
|
|
@@ -127318,7 +127323,7 @@ var require_compile2 = __commonJS({
|
|
|
127318
127323
|
const schOrFunc = root2.refs[ref];
|
|
127319
127324
|
if (schOrFunc)
|
|
127320
127325
|
return schOrFunc;
|
|
127321
|
-
let _sch =
|
|
127326
|
+
let _sch = resolve11.call(this, root2, ref);
|
|
127322
127327
|
if (_sch === void 0) {
|
|
127323
127328
|
const schema = (_a26 = root2.localRefs) === null || _a26 === void 0 ? void 0 : _a26[ref];
|
|
127324
127329
|
const { schemaId } = this.opts;
|
|
@@ -127345,7 +127350,7 @@ var require_compile2 = __commonJS({
|
|
|
127345
127350
|
function sameSchemaEnv(s1, s2) {
|
|
127346
127351
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
127347
127352
|
}
|
|
127348
|
-
function
|
|
127353
|
+
function resolve11(root2, ref) {
|
|
127349
127354
|
let sch;
|
|
127350
127355
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
127351
127356
|
ref = sch;
|
|
@@ -128181,7 +128186,7 @@ var require_uri_all = __commonJS({
|
|
|
128181
128186
|
target.fragment = relative4.fragment;
|
|
128182
128187
|
return target;
|
|
128183
128188
|
}
|
|
128184
|
-
function
|
|
128189
|
+
function resolve11(baseURI, relativeURI, options) {
|
|
128185
128190
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
128186
128191
|
return serialize(resolveComponents(parse8(baseURI, schemelessOptions), parse8(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
128187
128192
|
}
|
|
@@ -128446,7 +128451,7 @@ var require_uri_all = __commonJS({
|
|
|
128446
128451
|
exports3.removeDotSegments = removeDotSegments;
|
|
128447
128452
|
exports3.serialize = serialize;
|
|
128448
128453
|
exports3.resolveComponents = resolveComponents;
|
|
128449
|
-
exports3.resolve =
|
|
128454
|
+
exports3.resolve = resolve11;
|
|
128450
128455
|
exports3.normalize = normalize6;
|
|
128451
128456
|
exports3.equal = equal;
|
|
128452
128457
|
exports3.escapeComponent = escapeComponent;
|
|
@@ -132172,12 +132177,12 @@ var require_isexe = __commonJS({
|
|
|
132172
132177
|
if (typeof Promise !== "function") {
|
|
132173
132178
|
throw new TypeError("callback not provided");
|
|
132174
132179
|
}
|
|
132175
|
-
return new Promise(function(
|
|
132180
|
+
return new Promise(function(resolve11, reject) {
|
|
132176
132181
|
isexe(path12, options || {}, function(er, is) {
|
|
132177
132182
|
if (er) {
|
|
132178
132183
|
reject(er);
|
|
132179
132184
|
} else {
|
|
132180
|
-
|
|
132185
|
+
resolve11(is);
|
|
132181
132186
|
}
|
|
132182
132187
|
});
|
|
132183
132188
|
});
|
|
@@ -132245,27 +132250,27 @@ var require_which = __commonJS({
|
|
|
132245
132250
|
opt = {};
|
|
132246
132251
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
132247
132252
|
const found = [];
|
|
132248
|
-
const step = (i2) => new Promise((
|
|
132253
|
+
const step = (i2) => new Promise((resolve11, reject) => {
|
|
132249
132254
|
if (i2 === pathEnv.length)
|
|
132250
|
-
return opt.all && found.length ?
|
|
132255
|
+
return opt.all && found.length ? resolve11(found) : reject(getNotFoundError(cmd));
|
|
132251
132256
|
const ppRaw = pathEnv[i2];
|
|
132252
132257
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
132253
132258
|
const pCmd = path12.join(pathPart, cmd);
|
|
132254
132259
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
132255
|
-
|
|
132260
|
+
resolve11(subStep(p, i2, 0));
|
|
132256
132261
|
});
|
|
132257
|
-
const subStep = (p, i2, ii) => new Promise((
|
|
132262
|
+
const subStep = (p, i2, ii) => new Promise((resolve11, reject) => {
|
|
132258
132263
|
if (ii === pathExt.length)
|
|
132259
|
-
return
|
|
132264
|
+
return resolve11(step(i2 + 1));
|
|
132260
132265
|
const ext = pathExt[ii];
|
|
132261
132266
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
132262
132267
|
if (!er && is) {
|
|
132263
132268
|
if (opt.all)
|
|
132264
132269
|
found.push(p + ext);
|
|
132265
132270
|
else
|
|
132266
|
-
return
|
|
132271
|
+
return resolve11(p + ext);
|
|
132267
132272
|
}
|
|
132268
|
-
return
|
|
132273
|
+
return resolve11(subStep(p, i2, ii + 1));
|
|
132269
132274
|
});
|
|
132270
132275
|
});
|
|
132271
132276
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -132679,7 +132684,7 @@ var init_stdio2 = __esm({
|
|
|
132679
132684
|
if (this._process) {
|
|
132680
132685
|
throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
132681
132686
|
}
|
|
132682
|
-
return new Promise((
|
|
132687
|
+
return new Promise((resolve11, reject) => {
|
|
132683
132688
|
this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
|
|
132684
132689
|
// merge default env with server env because mcp server needs some env vars
|
|
132685
132690
|
env: {
|
|
@@ -132696,7 +132701,7 @@ var init_stdio2 = __esm({
|
|
|
132696
132701
|
this.onerror?.(error48);
|
|
132697
132702
|
});
|
|
132698
132703
|
this._process.on("spawn", () => {
|
|
132699
|
-
|
|
132704
|
+
resolve11();
|
|
132700
132705
|
});
|
|
132701
132706
|
this._process.on("close", (_code) => {
|
|
132702
132707
|
this._process = void 0;
|
|
@@ -132755,22 +132760,22 @@ var init_stdio2 = __esm({
|
|
|
132755
132760
|
if (this._process) {
|
|
132756
132761
|
const processToClose = this._process;
|
|
132757
132762
|
this._process = void 0;
|
|
132758
|
-
const closePromise = new Promise((
|
|
132763
|
+
const closePromise = new Promise((resolve11) => {
|
|
132759
132764
|
processToClose.once("close", () => {
|
|
132760
|
-
|
|
132765
|
+
resolve11();
|
|
132761
132766
|
});
|
|
132762
132767
|
});
|
|
132763
132768
|
try {
|
|
132764
132769
|
processToClose.stdin?.end();
|
|
132765
132770
|
} catch {
|
|
132766
132771
|
}
|
|
132767
|
-
await Promise.race([closePromise, new Promise((
|
|
132772
|
+
await Promise.race([closePromise, new Promise((resolve11) => setTimeout(resolve11, 2e3).unref())]);
|
|
132768
132773
|
if (processToClose.exitCode === null) {
|
|
132769
132774
|
try {
|
|
132770
132775
|
processToClose.kill("SIGTERM");
|
|
132771
132776
|
} catch {
|
|
132772
132777
|
}
|
|
132773
|
-
await Promise.race([closePromise, new Promise((
|
|
132778
|
+
await Promise.race([closePromise, new Promise((resolve11) => setTimeout(resolve11, 2e3).unref())]);
|
|
132774
132779
|
}
|
|
132775
132780
|
if (processToClose.exitCode === null) {
|
|
132776
132781
|
try {
|
|
@@ -132782,15 +132787,15 @@ var init_stdio2 = __esm({
|
|
|
132782
132787
|
this._readBuffer.clear();
|
|
132783
132788
|
}
|
|
132784
132789
|
send(message) {
|
|
132785
|
-
return new Promise((
|
|
132790
|
+
return new Promise((resolve11) => {
|
|
132786
132791
|
if (!this._process?.stdin) {
|
|
132787
132792
|
throw new Error("Not connected");
|
|
132788
132793
|
}
|
|
132789
132794
|
const json3 = serializeMessage(message);
|
|
132790
132795
|
if (this._process.stdin.write(json3)) {
|
|
132791
|
-
|
|
132796
|
+
resolve11();
|
|
132792
132797
|
} else {
|
|
132793
|
-
this._process.stdin.once("drain",
|
|
132798
|
+
this._process.stdin.once("drain", resolve11);
|
|
132794
132799
|
}
|
|
132795
132800
|
});
|
|
132796
132801
|
}
|
|
@@ -132995,7 +133000,7 @@ var {
|
|
|
132995
133000
|
} = import_index.default;
|
|
132996
133001
|
|
|
132997
133002
|
// package.json
|
|
132998
|
-
var version = "0.10.
|
|
133003
|
+
var version = "0.10.26";
|
|
132999
133004
|
|
|
133000
133005
|
// src/commands/agent.ts
|
|
133001
133006
|
init_cjs_shims();
|
|
@@ -135638,7 +135643,7 @@ function createContinuousImprovementLoop(context2, stateManager, _sessionId) {
|
|
|
135638
135643
|
context2.logger.info("[Continuous] Wait interrupted");
|
|
135639
135644
|
return;
|
|
135640
135645
|
}
|
|
135641
|
-
await new Promise((
|
|
135646
|
+
await new Promise((resolve11) => setTimeout(resolve11, 1e3));
|
|
135642
135647
|
}
|
|
135643
135648
|
}
|
|
135644
135649
|
return {
|
|
@@ -136000,10 +136005,10 @@ ${"\u2550".repeat(60)}`);
|
|
|
136000
136005
|
input: process.stdin,
|
|
136001
136006
|
output: process.stdout
|
|
136002
136007
|
});
|
|
136003
|
-
return new Promise((
|
|
136008
|
+
return new Promise((resolve11) => {
|
|
136004
136009
|
rl.question(query, (answer) => {
|
|
136005
136010
|
rl.close();
|
|
136006
|
-
|
|
136011
|
+
resolve11(answer.trim());
|
|
136007
136012
|
});
|
|
136008
136013
|
});
|
|
136009
136014
|
}
|
|
@@ -138022,6 +138027,7 @@ init_src3();
|
|
|
138022
138027
|
init_lodash();
|
|
138023
138028
|
init_ApiProviderConfig();
|
|
138024
138029
|
init_env();
|
|
138030
|
+
init_errors6();
|
|
138025
138031
|
init_getModel();
|
|
138026
138032
|
function addSharedOptions(command) {
|
|
138027
138033
|
return command.option("-c --config <paths>", "Path to config file(s)", (value, prev) => prev.concat(value), []).option("--api-provider <provider>", "API provider").option("--model <model>", "Model ID").option("--api-key <key>", "API key").option("--max-messages <iterations>", "Maximum number of messages to send.", Number.parseInt).option("--budget <budget>", "Budget for the AI service.", Number.parseFloat).option(
|
|
@@ -138044,7 +138050,7 @@ async function parseOptions(options, { cwdArg, commandName } = {}, home = import
|
|
|
138044
138050
|
const apiKey = options.apiKey || env2.POLKA_API_KEY;
|
|
138045
138051
|
if (apiKey) {
|
|
138046
138052
|
if (!defaultProvider) {
|
|
138047
|
-
throw new
|
|
138053
|
+
throw new ConfigurationError("Must specify a provider if providing an API key");
|
|
138048
138054
|
}
|
|
138049
138055
|
set_default(config2, ["providers", defaultProvider, "apiKey"], apiKey);
|
|
138050
138056
|
}
|
|
@@ -138242,7 +138248,7 @@ async function confirm(input2, context2) {
|
|
|
138242
138248
|
if (context2.yes) {
|
|
138243
138249
|
return true;
|
|
138244
138250
|
}
|
|
138245
|
-
await new Promise((
|
|
138251
|
+
await new Promise((resolve11) => setTimeout(resolve11, 50));
|
|
138246
138252
|
process.stderr.write("\x07");
|
|
138247
138253
|
return await dist_default6({ message: input2.message });
|
|
138248
138254
|
}
|
|
@@ -138250,7 +138256,7 @@ async function input(input2, context2) {
|
|
|
138250
138256
|
if (context2.yes) {
|
|
138251
138257
|
return input2.default ?? "";
|
|
138252
138258
|
}
|
|
138253
|
-
await new Promise((
|
|
138259
|
+
await new Promise((resolve11) => setTimeout(resolve11, 50));
|
|
138254
138260
|
process.stderr.write("\x07");
|
|
138255
138261
|
const result = await getUserInput(input2.message, {
|
|
138256
138262
|
default: input2.default
|
|
@@ -138264,12 +138270,12 @@ async function select(input2, context2) {
|
|
|
138264
138270
|
if (context2.yes) {
|
|
138265
138271
|
return input2.choices[0].value;
|
|
138266
138272
|
}
|
|
138267
|
-
await new Promise((
|
|
138273
|
+
await new Promise((resolve11) => setTimeout(resolve11, 50));
|
|
138268
138274
|
process.stderr.write("\x07");
|
|
138269
138275
|
return await dist_default9({ message: input2.message, choices: input2.choices });
|
|
138270
138276
|
}
|
|
138271
138277
|
async function executeCommand(input2) {
|
|
138272
|
-
return new Promise((
|
|
138278
|
+
return new Promise((resolve11, reject) => {
|
|
138273
138279
|
const child = input2.shell === true ? input2.args && input2.args.length > 0 ? (
|
|
138274
138280
|
// Use shell: true with command and args as separate parameters for safety
|
|
138275
138281
|
(0, import_node_child_process7.spawn)(input2.command, input2.args, { shell: true, stdio: "pipe" })
|
|
@@ -138291,7 +138297,7 @@ async function executeCommand(input2) {
|
|
|
138291
138297
|
let exitCode = null;
|
|
138292
138298
|
const checkAndResolve = () => {
|
|
138293
138299
|
if (stdoutEnded && stderrEnded && closeEventFired) {
|
|
138294
|
-
|
|
138300
|
+
resolve11({ exitCode: exitCode ?? -1, stdout, stderr });
|
|
138295
138301
|
}
|
|
138296
138302
|
};
|
|
138297
138303
|
if (child.stdout) {
|
|
@@ -138432,7 +138438,7 @@ async function generateText2(input2, context2) {
|
|
|
138432
138438
|
lastError = providerError;
|
|
138433
138439
|
const backoff = computeRateLimitBackoffSeconds(i2);
|
|
138434
138440
|
context2.workflowContext.logger.debug(`Waiting ${backoff}s before retry...`);
|
|
138435
|
-
await new Promise((
|
|
138441
|
+
await new Promise((resolve11) => setTimeout(resolve11, backoff * 1e3));
|
|
138436
138442
|
continue;
|
|
138437
138443
|
}
|
|
138438
138444
|
throw providerError;
|
|
@@ -138705,7 +138711,9 @@ async function runWorkflow(workflow, workflowInput, options) {
|
|
|
138705
138711
|
}
|
|
138706
138712
|
}
|
|
138707
138713
|
if (!commandConfig?.provider || !commandConfig.model) {
|
|
138708
|
-
const error48 = new
|
|
138714
|
+
const error48 = new ConfigurationError(
|
|
138715
|
+
`No provider configured for command: ${commandName}. Please run "polka init" to configure your AI provider.`
|
|
138716
|
+
);
|
|
138709
138717
|
logger.error(`Error: ${error48.message}`);
|
|
138710
138718
|
throw error48;
|
|
138711
138719
|
}
|
|
@@ -139323,16 +139331,13 @@ var COMMAND_CONSTANTS = {
|
|
|
139323
139331
|
|
|
139324
139332
|
// src/utils/command.ts
|
|
139325
139333
|
init_cjs_shims();
|
|
139326
|
-
function getGlobalOptions(command) {
|
|
139327
|
-
return (command.parent ?? command).opts();
|
|
139328
|
-
}
|
|
139329
139334
|
function getBaseWorkflowOptions(command) {
|
|
139330
|
-
const globalOpts =
|
|
139335
|
+
const globalOpts = (command.parent ?? command).opts();
|
|
139331
139336
|
const verbose = globalOpts.silent ? -1 : globalOpts.verbose ?? 0;
|
|
139332
139337
|
const logger = createLogger({ verbose });
|
|
139333
139338
|
return {
|
|
139334
|
-
interactive: !globalOpts.yes,
|
|
139335
139339
|
...globalOpts,
|
|
139340
|
+
interactive: !globalOpts.yes,
|
|
139336
139341
|
logger
|
|
139337
139342
|
};
|
|
139338
139343
|
}
|
|
@@ -139342,7 +139347,7 @@ var readStdin = async (timeoutMs = COMMAND_CONSTANTS.DEFAULT_STDIN_TIMEOUT_MS) =
|
|
|
139342
139347
|
if (process.stdin.isTTY) {
|
|
139343
139348
|
return "";
|
|
139344
139349
|
}
|
|
139345
|
-
return new Promise((
|
|
139350
|
+
return new Promise((resolve11, reject) => {
|
|
139346
139351
|
let input2 = "";
|
|
139347
139352
|
const cleanup = () => {
|
|
139348
139353
|
if (timeoutId) clearTimeout(timeoutId);
|
|
@@ -139350,14 +139355,14 @@ var readStdin = async (timeoutMs = COMMAND_CONSTANTS.DEFAULT_STDIN_TIMEOUT_MS) =
|
|
|
139350
139355
|
};
|
|
139351
139356
|
const timeoutId = setTimeout(() => {
|
|
139352
139357
|
cleanup();
|
|
139353
|
-
|
|
139358
|
+
resolve11(input2);
|
|
139354
139359
|
}, timeoutMs);
|
|
139355
139360
|
process.stdin.on("data", (chunk) => {
|
|
139356
139361
|
input2 += chunk.toString();
|
|
139357
139362
|
});
|
|
139358
139363
|
process.stdin.on("end", () => {
|
|
139359
139364
|
cleanup();
|
|
139360
|
-
|
|
139365
|
+
resolve11(input2);
|
|
139361
139366
|
});
|
|
139362
139367
|
process.stdin.on("error", (err) => {
|
|
139363
139368
|
cleanup();
|
|
@@ -139448,8 +139453,8 @@ var fixCommand = new Command("fix").description("Fix issues by running a command
|
|
|
139448
139453
|
|
|
139449
139454
|
// src/commands/init.ts
|
|
139450
139455
|
init_cjs_shims();
|
|
139451
|
-
var
|
|
139452
|
-
var
|
|
139456
|
+
var import_node_fs10 = require("fs");
|
|
139457
|
+
var import_node_path15 = require("path");
|
|
139453
139458
|
init_dist18();
|
|
139454
139459
|
init_src3();
|
|
139455
139460
|
init_lodash();
|
|
@@ -139472,6 +139477,103 @@ var BUILT_IN_COMMANDS = [
|
|
|
139472
139477
|
"skills"
|
|
139473
139478
|
];
|
|
139474
139479
|
|
|
139480
|
+
// src/config-validation.ts
|
|
139481
|
+
init_cjs_shims();
|
|
139482
|
+
var import_node_fs9 = require("fs");
|
|
139483
|
+
var import_node_os6 = require("os");
|
|
139484
|
+
var import_node_path13 = require("path");
|
|
139485
|
+
init_src3();
|
|
139486
|
+
init_zod();
|
|
139487
|
+
function addConfigSource(sources, path12, required2) {
|
|
139488
|
+
const existingSource = sources.find((source) => source.path === path12);
|
|
139489
|
+
if (existingSource) {
|
|
139490
|
+
existingSource.required = existingSource.required || required2;
|
|
139491
|
+
return;
|
|
139492
|
+
}
|
|
139493
|
+
sources.push({ path: path12, required: required2 });
|
|
139494
|
+
}
|
|
139495
|
+
function formatIssuePath(path12) {
|
|
139496
|
+
if (path12.length === 0) {
|
|
139497
|
+
return void 0;
|
|
139498
|
+
}
|
|
139499
|
+
return path12.map(String).join(".");
|
|
139500
|
+
}
|
|
139501
|
+
function normalizeValidationError(source, error48) {
|
|
139502
|
+
if (error48 instanceof ZodError) {
|
|
139503
|
+
return error48.issues.map((issue2) => ({
|
|
139504
|
+
source,
|
|
139505
|
+
path: formatIssuePath(issue2.path),
|
|
139506
|
+
message: issue2.message,
|
|
139507
|
+
code: "invalid_schema"
|
|
139508
|
+
}));
|
|
139509
|
+
}
|
|
139510
|
+
if (error48 && typeof error48 === "object" && "code" in error48 && error48.code === "ENOENT") {
|
|
139511
|
+
return [
|
|
139512
|
+
{
|
|
139513
|
+
source,
|
|
139514
|
+
message: `Config file not found: ${source}`,
|
|
139515
|
+
code: "file_not_found"
|
|
139516
|
+
}
|
|
139517
|
+
];
|
|
139518
|
+
}
|
|
139519
|
+
return [
|
|
139520
|
+
{
|
|
139521
|
+
source,
|
|
139522
|
+
message: error48 instanceof Error ? error48.message : String(error48),
|
|
139523
|
+
code: "invalid_yaml"
|
|
139524
|
+
}
|
|
139525
|
+
];
|
|
139526
|
+
}
|
|
139527
|
+
function getConfigSources(paths, cwd, home, includeGlobal) {
|
|
139528
|
+
const sources = [];
|
|
139529
|
+
if (includeGlobal) {
|
|
139530
|
+
const globalConfigPath = getGlobalConfigPath(home);
|
|
139531
|
+
if ((0, import_node_fs9.existsSync)(globalConfigPath)) {
|
|
139532
|
+
addConfigSource(sources, globalConfigPath, false);
|
|
139533
|
+
}
|
|
139534
|
+
}
|
|
139535
|
+
if (paths) {
|
|
139536
|
+
const explicitPaths = Array.isArray(paths) ? paths : [paths];
|
|
139537
|
+
for (const path12 of explicitPaths) {
|
|
139538
|
+
addConfigSource(sources, (0, import_node_path13.resolve)(cwd, path12), true);
|
|
139539
|
+
}
|
|
139540
|
+
return sources;
|
|
139541
|
+
}
|
|
139542
|
+
const defaultLocalConfigPath = (0, import_node_path13.join)(cwd, localConfigFileName);
|
|
139543
|
+
if ((0, import_node_fs9.existsSync)(defaultLocalConfigPath)) {
|
|
139544
|
+
addConfigSource(sources, defaultLocalConfigPath, false);
|
|
139545
|
+
}
|
|
139546
|
+
return sources;
|
|
139547
|
+
}
|
|
139548
|
+
async function validateConfig2(paths, options = {}) {
|
|
139549
|
+
const cwd = options.cwd ?? process.cwd();
|
|
139550
|
+
const home = options.home ?? (0, import_node_os6.homedir)();
|
|
139551
|
+
const includeGlobal = options.includeGlobal ?? true;
|
|
139552
|
+
const configSources = getConfigSources(paths, cwd, home, includeGlobal);
|
|
139553
|
+
if (configSources.length === 0) {
|
|
139554
|
+
return { valid: true, config: {} };
|
|
139555
|
+
}
|
|
139556
|
+
const configs = [];
|
|
139557
|
+
const errors = [];
|
|
139558
|
+
for (const source of configSources) {
|
|
139559
|
+
if (!source.required && !(0, import_node_fs9.existsSync)(source.path)) {
|
|
139560
|
+
continue;
|
|
139561
|
+
}
|
|
139562
|
+
try {
|
|
139563
|
+
configs.push(readConfig(source.path));
|
|
139564
|
+
} catch (error48) {
|
|
139565
|
+
errors.push(...normalizeValidationError(source.path, error48));
|
|
139566
|
+
}
|
|
139567
|
+
}
|
|
139568
|
+
if (errors.length > 0) {
|
|
139569
|
+
return { valid: false, errors };
|
|
139570
|
+
}
|
|
139571
|
+
return {
|
|
139572
|
+
valid: true,
|
|
139573
|
+
config: mergeConfigs(configs)
|
|
139574
|
+
};
|
|
139575
|
+
}
|
|
139576
|
+
|
|
139475
139577
|
// src/configPrompt.ts
|
|
139476
139578
|
init_cjs_shims();
|
|
139477
139579
|
init_dist18();
|
|
@@ -139512,7 +139614,7 @@ async function configPrompt(existingConfig) {
|
|
|
139512
139614
|
|
|
139513
139615
|
// src/workflows/init-interactive.workflow.ts
|
|
139514
139616
|
init_cjs_shims();
|
|
139515
|
-
var
|
|
139617
|
+
var import_node_path14 = require("path");
|
|
139516
139618
|
init_src3();
|
|
139517
139619
|
init_src();
|
|
139518
139620
|
var import_yaml5 = __toESM(require_dist(), 1);
|
|
@@ -139683,7 +139785,7 @@ Please:
|
|
|
139683
139785
|
}
|
|
139684
139786
|
const scriptDir = ".polka-scripts";
|
|
139685
139787
|
const scriptFileName = `${scriptName}.ts`;
|
|
139686
|
-
const scriptFilePath = (0,
|
|
139788
|
+
const scriptFilePath = (0, import_node_path14.join)(scriptDir, scriptFileName);
|
|
139687
139789
|
await step("save-script", async () => {
|
|
139688
139790
|
await tools.writeToFile({ path: scriptFilePath, content: script });
|
|
139689
139791
|
logger.info(`
|
|
@@ -139720,8 +139822,8 @@ async function createSkill(name25, logger, interactive) {
|
|
|
139720
139822
|
`Skill name '${name25}' conflicts with a built-in command. Please choose a different name (e.g., '${name25}-skill' or 'my-${name25}')`
|
|
139721
139823
|
);
|
|
139722
139824
|
}
|
|
139723
|
-
const skillDir = (0,
|
|
139724
|
-
if ((0,
|
|
139825
|
+
const skillDir = (0, import_node_path15.join)(".claude", "skills", name25);
|
|
139826
|
+
if ((0, import_node_fs10.existsSync)(skillDir)) {
|
|
139725
139827
|
if (interactive) {
|
|
139726
139828
|
const proceed = await dist_default6({
|
|
139727
139829
|
message: `Skill '${name25}' already exists. Overwrite?`,
|
|
@@ -139735,10 +139837,10 @@ async function createSkill(name25, logger, interactive) {
|
|
|
139735
139837
|
throw new Error(`Skill already exists: ${skillDir}`);
|
|
139736
139838
|
}
|
|
139737
139839
|
}
|
|
139738
|
-
(0,
|
|
139840
|
+
(0, import_node_fs10.mkdirSync)(skillDir, { recursive: true });
|
|
139739
139841
|
logger.info(`Created skill directory: ${skillDir}`);
|
|
139740
139842
|
const template = generateSkillTemplate(name25);
|
|
139741
|
-
(0,
|
|
139843
|
+
(0, import_node_fs10.writeFileSync)((0, import_node_path15.join)(skillDir, "SKILL.md"), template);
|
|
139742
139844
|
logger.info(`Created SKILL.md`);
|
|
139743
139845
|
logger.info("");
|
|
139744
139846
|
logger.info(`Skill '${name25}' created successfully!`);
|
|
@@ -139809,8 +139911,8 @@ Add additional files like:
|
|
|
139809
139911
|
async function createScript(name25, logger, interactive, isGlobal = false) {
|
|
139810
139912
|
const scriptDir = ".polka-scripts";
|
|
139811
139913
|
const scriptPathConfig = `${scriptDir}/${name25}.ts`;
|
|
139812
|
-
const scriptPathActual = (0,
|
|
139813
|
-
if ((0,
|
|
139914
|
+
const scriptPathActual = (0, import_node_path15.join)(scriptDir, `${name25}.ts`);
|
|
139915
|
+
if ((0, import_node_fs10.existsSync)(scriptPathActual)) {
|
|
139814
139916
|
if (interactive) {
|
|
139815
139917
|
const proceed = await dist_default6({
|
|
139816
139918
|
message: `Script '${scriptPathActual}' already exists. Overwrite?`,
|
|
@@ -139824,8 +139926,8 @@ async function createScript(name25, logger, interactive, isGlobal = false) {
|
|
|
139824
139926
|
throw new Error(`Script already exists: ${scriptPathActual}`);
|
|
139825
139927
|
}
|
|
139826
139928
|
}
|
|
139827
|
-
if (!(0,
|
|
139828
|
-
(0,
|
|
139929
|
+
if (!(0, import_node_fs10.existsSync)(scriptDir)) {
|
|
139930
|
+
(0, import_node_fs10.mkdirSync)(scriptDir, { recursive: true });
|
|
139829
139931
|
logger.info(`Created directory: ${scriptDir}`);
|
|
139830
139932
|
}
|
|
139831
139933
|
const template = `// Generated by polka.codes
|
|
@@ -139848,65 +139950,67 @@ if (import.meta.main) {
|
|
|
139848
139950
|
main(process.argv.slice(2))
|
|
139849
139951
|
}
|
|
139850
139952
|
`;
|
|
139851
|
-
(0,
|
|
139953
|
+
(0, import_node_fs10.writeFileSync)(scriptPathActual, template);
|
|
139852
139954
|
logger.info(`Created script: ${scriptPathActual}`);
|
|
139853
139955
|
const configPath = isGlobal ? getGlobalConfigPath() : localConfigFileName;
|
|
139854
|
-
if ((0,
|
|
139855
|
-
|
|
139856
|
-
|
|
139857
|
-
|
|
139858
|
-
|
|
139859
|
-
|
|
139860
|
-
|
|
139861
|
-
|
|
139862
|
-
|
|
139863
|
-
};
|
|
139864
|
-
|
|
139865
|
-
|
|
139866
|
-
|
|
139867
|
-
|
|
139956
|
+
if ((0, import_node_fs10.existsSync)(configPath)) {
|
|
139957
|
+
const validation = await validateConfig2(configPath, { includeGlobal: false });
|
|
139958
|
+
if (!validation.valid) {
|
|
139959
|
+
logger.warn("Could not update config file due to validation errors:");
|
|
139960
|
+
for (const error48 of validation.errors) {
|
|
139961
|
+
logger.warn(` ${error48.message}`);
|
|
139962
|
+
}
|
|
139963
|
+
logger.info("Add the script manually to your config:");
|
|
139964
|
+
logger.info(` scripts:`);
|
|
139965
|
+
logger.info(` ${name25}:`);
|
|
139966
|
+
logger.info(` script: ${scriptPathConfig}`);
|
|
139967
|
+
logger.info(` description: Custom script: ${name25}`);
|
|
139968
|
+
return;
|
|
139969
|
+
}
|
|
139970
|
+
const config2 = validation.config;
|
|
139971
|
+
if (!config2.scripts) {
|
|
139972
|
+
config2.scripts = {};
|
|
139973
|
+
}
|
|
139974
|
+
config2.scripts[name25] = {
|
|
139975
|
+
script: scriptPathConfig,
|
|
139976
|
+
description: `Custom script: ${name25}`
|
|
139977
|
+
};
|
|
139978
|
+
const configContent = (0, import_node_fs10.readFileSync)(configPath, "utf-8");
|
|
139979
|
+
let newContent = configContent;
|
|
139980
|
+
if (!configContent.includes("scripts:")) {
|
|
139981
|
+
newContent = `${configContent.trimEnd()}
|
|
139868
139982
|
|
|
139869
139983
|
scripts:
|
|
139870
139984
|
${name25}:
|
|
139871
139985
|
script: ${scriptPathConfig}
|
|
139872
139986
|
description: Custom script: ${name25}
|
|
139873
139987
|
`;
|
|
139874
|
-
|
|
139875
|
-
|
|
139876
|
-
|
|
139877
|
-
|
|
139878
|
-
|
|
139879
|
-
}
|
|
139880
|
-
doc.setIn(["scripts", name25], {
|
|
139881
|
-
script: scriptPathConfig,
|
|
139882
|
-
description: `Custom script: ${name25}`
|
|
139883
|
-
});
|
|
139884
|
-
newContent = doc.toString();
|
|
139885
|
-
} catch (parseError) {
|
|
139886
|
-
logger.warn("Could not parse config file safely. Please add the script manually:");
|
|
139887
|
-
logger.info(` scripts:`);
|
|
139888
|
-
logger.info(` ${name25}:`);
|
|
139889
|
-
logger.info(` script: ${scriptPathConfig}`);
|
|
139890
|
-
logger.info(` description: Custom script: ${name25}`);
|
|
139891
|
-
if (parseError instanceof Error) {
|
|
139892
|
-
logger.debug(`Error: ${parseError.message}`);
|
|
139893
|
-
}
|
|
139894
|
-
return;
|
|
139988
|
+
} else {
|
|
139989
|
+
try {
|
|
139990
|
+
const doc = (0, import_yaml6.parseDocument)(configContent);
|
|
139991
|
+
if (!doc.has("scripts")) {
|
|
139992
|
+
doc.set("scripts", {});
|
|
139895
139993
|
}
|
|
139896
|
-
|
|
139897
|
-
|
|
139898
|
-
|
|
139899
|
-
|
|
139900
|
-
|
|
139901
|
-
|
|
139902
|
-
|
|
139903
|
-
|
|
139904
|
-
|
|
139905
|
-
|
|
139906
|
-
|
|
139907
|
-
|
|
139994
|
+
doc.setIn(["scripts", name25], {
|
|
139995
|
+
script: scriptPathConfig,
|
|
139996
|
+
description: `Custom script: ${name25}`
|
|
139997
|
+
});
|
|
139998
|
+
newContent = doc.toString();
|
|
139999
|
+
} catch (parseError) {
|
|
140000
|
+
logger.warn("Could not parse config file safely. Please add the script manually:");
|
|
140001
|
+
logger.info(` scripts:`);
|
|
140002
|
+
logger.info(` ${name25}:`);
|
|
140003
|
+
logger.info(` script: ${scriptPathConfig}`);
|
|
140004
|
+
logger.info(` description: Custom script: ${name25}`);
|
|
140005
|
+
if (parseError instanceof Error) {
|
|
140006
|
+
logger.debug(`Error: ${parseError.message}`);
|
|
140007
|
+
}
|
|
140008
|
+
return;
|
|
139908
140009
|
}
|
|
139909
140010
|
}
|
|
140011
|
+
(0, import_node_fs10.writeFileSync)(configPath, newContent);
|
|
140012
|
+
logger.info(`Added script to config: ${configPath}`);
|
|
140013
|
+
logger.info(`Run with: polka run ${name25}`);
|
|
139910
140014
|
} else {
|
|
139911
140015
|
logger.info(`Tip: Add this script to your .polkacodes.yml:`);
|
|
139912
140016
|
logger.info(` scripts:`);
|
|
@@ -139975,8 +140079,8 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
139975
140079
|
process.exit(1);
|
|
139976
140080
|
}
|
|
139977
140081
|
const scriptDir = ".polka-scripts";
|
|
139978
|
-
const scriptPath = (0,
|
|
139979
|
-
if ((0,
|
|
140082
|
+
const scriptPath = (0, import_node_path15.join)(scriptDir, `${name25}.ts`);
|
|
140083
|
+
if ((0, import_node_fs10.existsSync)(scriptPath)) {
|
|
139980
140084
|
if (interactive) {
|
|
139981
140085
|
const proceed = await dist_default6({
|
|
139982
140086
|
message: `Script '${scriptPath}' already exists. Overwrite?`,
|
|
@@ -140034,7 +140138,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
140034
140138
|
const globalConfigPath = getGlobalConfigPath();
|
|
140035
140139
|
let isGlobal = options.global ?? false;
|
|
140036
140140
|
let configPath = isGlobal ? globalConfigPath : localConfigFileName;
|
|
140037
|
-
const exists = (0,
|
|
140141
|
+
const exists = (0, import_node_fs10.existsSync)(configPath);
|
|
140038
140142
|
if (exists) {
|
|
140039
140143
|
if (interactive) {
|
|
140040
140144
|
const proceed = await dist_default6({
|
|
@@ -140063,11 +140167,16 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
140063
140167
|
}
|
|
140064
140168
|
logger.info(`Config file path: ${configPath}`);
|
|
140065
140169
|
let existingConfig = {};
|
|
140066
|
-
|
|
140067
|
-
|
|
140068
|
-
|
|
140069
|
-
|
|
140070
|
-
|
|
140170
|
+
if ((0, import_node_fs10.existsSync)(configPath)) {
|
|
140171
|
+
const validation = await validateConfig2(configPath, { includeGlobal: false });
|
|
140172
|
+
if (!validation.valid) {
|
|
140173
|
+
logger.error(`Config validation failed for ${configPath}:`);
|
|
140174
|
+
for (const error48 of validation.errors) {
|
|
140175
|
+
logger.error(` ${error48.code}: ${error48.message}`);
|
|
140176
|
+
}
|
|
140177
|
+
throw new Error(`Invalid config file: ${configPath}`);
|
|
140178
|
+
}
|
|
140179
|
+
existingConfig = validation.config;
|
|
140071
140180
|
}
|
|
140072
140181
|
const providerConfig = await configPrompt({});
|
|
140073
140182
|
const { provider, model, apiKey } = providerConfig;
|
|
@@ -140087,23 +140196,24 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
140087
140196
|
case "local":
|
|
140088
140197
|
break;
|
|
140089
140198
|
case "global": {
|
|
140090
|
-
const
|
|
140199
|
+
const globalValidation = await validateConfig2(globalConfigPath, { includeGlobal: false });
|
|
140200
|
+
const globalConfig2 = globalValidation.valid ? globalValidation.config : {};
|
|
140091
140201
|
set_default(globalConfig2, ["providers", provider, "apiKey"], apiKey);
|
|
140092
|
-
(0,
|
|
140202
|
+
(0, import_node_fs10.writeFileSync)(globalConfigPath, (0, import_yaml6.stringify)(globalConfig2));
|
|
140093
140203
|
logger.info(`API key saved to global config file: ${globalConfigPath}`);
|
|
140094
140204
|
providerConfig.apiKey = void 0;
|
|
140095
140205
|
break;
|
|
140096
140206
|
}
|
|
140097
140207
|
case "env": {
|
|
140098
140208
|
let envFileContent = "";
|
|
140099
|
-
const envExists = (0,
|
|
140209
|
+
const envExists = (0, import_node_fs10.existsSync)(".env");
|
|
140100
140210
|
if (envExists) {
|
|
140101
|
-
envFileContent = (0,
|
|
140211
|
+
envFileContent = (0, import_node_fs10.readFileSync)(".env", "utf-8");
|
|
140102
140212
|
if (!envFileContent.endsWith("\n")) envFileContent += "\n";
|
|
140103
140213
|
}
|
|
140104
140214
|
envFileContent += `${provider.toUpperCase()}_API_KEY=${apiKey}
|
|
140105
140215
|
`;
|
|
140106
|
-
(0,
|
|
140216
|
+
(0, import_node_fs10.writeFileSync)(".env", envFileContent);
|
|
140107
140217
|
logger.info("API key saved to .env file");
|
|
140108
140218
|
providerConfig.apiKey = void 0;
|
|
140109
140219
|
break;
|
|
@@ -140121,7 +140231,7 @@ var initCommand = new Command("init").description("Initialize polkacodes configu
|
|
|
140121
140231
|
if (providerConfig.apiKey) {
|
|
140122
140232
|
set_default(finalConfig, ["providers", provider, "apiKey"], providerConfig.apiKey);
|
|
140123
140233
|
}
|
|
140124
|
-
(0,
|
|
140234
|
+
(0, import_node_fs10.writeFileSync)(configPath, (0, import_yaml6.stringify)(finalConfig));
|
|
140125
140235
|
logger.info(`Configuration saved to ${configPath}`);
|
|
140126
140236
|
let shouldAnalyze = false;
|
|
140127
140237
|
if (!isGlobal && interactive) {
|
|
@@ -141080,7 +141190,7 @@ var McpServer = class {
|
|
|
141080
141190
|
let task2 = createTaskResult.task;
|
|
141081
141191
|
const pollInterval = task2.pollInterval ?? 5e3;
|
|
141082
141192
|
while (task2.status !== "completed" && task2.status !== "failed" && task2.status !== "cancelled") {
|
|
141083
|
-
await new Promise((
|
|
141193
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
141084
141194
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
141085
141195
|
if (!updatedTask) {
|
|
141086
141196
|
throw new McpError2(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -141701,12 +141811,12 @@ var StdioServerTransport = class {
|
|
|
141701
141811
|
this.onclose?.();
|
|
141702
141812
|
}
|
|
141703
141813
|
send(message) {
|
|
141704
|
-
return new Promise((
|
|
141814
|
+
return new Promise((resolve11) => {
|
|
141705
141815
|
const json3 = serializeMessage(message);
|
|
141706
141816
|
if (this._stdout.write(json3)) {
|
|
141707
|
-
|
|
141817
|
+
resolve11();
|
|
141708
141818
|
} else {
|
|
141709
|
-
this._stdout.once("drain",
|
|
141819
|
+
this._stdout.once("drain", resolve11);
|
|
141710
141820
|
}
|
|
141711
141821
|
});
|
|
141712
141822
|
}
|
|
@@ -142599,7 +142709,7 @@ var mcpServerCommand = new Command("mcp-server").description("Start polka-codes
|
|
|
142599
142709
|
// src/commands/memory.ts
|
|
142600
142710
|
init_cjs_shims();
|
|
142601
142711
|
var import_promises8 = require("fs/promises");
|
|
142602
|
-
var
|
|
142712
|
+
var import_node_path16 = require("path");
|
|
142603
142713
|
init_src3();
|
|
142604
142714
|
init_src();
|
|
142605
142715
|
async function getMemoryStore2() {
|
|
@@ -142752,8 +142862,8 @@ async function memoryExport(options) {
|
|
|
142752
142862
|
console.error("Failed to export: query did not return entries");
|
|
142753
142863
|
return;
|
|
142754
142864
|
}
|
|
142755
|
-
const outputPath = options.output ? (0,
|
|
142756
|
-
await (0, import_promises8.mkdir)((0,
|
|
142865
|
+
const outputPath = options.output ? (0, import_node_path16.resolve)(process.cwd(), options.output) : (0, import_node_path16.resolve)(process.cwd(), `memory-export-${Date.now()}.json`);
|
|
142866
|
+
await (0, import_promises8.mkdir)((0, import_node_path16.dirname)(outputPath), { recursive: true });
|
|
142757
142867
|
await (0, import_promises8.writeFile)(outputPath, JSON.stringify(entries, null, 2));
|
|
142758
142868
|
console.log(`Exported ${entries.length} entries to ${outputPath}`);
|
|
142759
142869
|
} finally {
|
|
@@ -142763,7 +142873,7 @@ async function memoryExport(options) {
|
|
|
142763
142873
|
async function memoryImport(inputFile, options) {
|
|
142764
142874
|
const store = await getMemoryStore2();
|
|
142765
142875
|
try {
|
|
142766
|
-
const inputPath = (0,
|
|
142876
|
+
const inputPath = (0, import_node_path16.resolve)(process.cwd(), inputFile);
|
|
142767
142877
|
const data = await (0, import_promises8.readFile)(inputPath, "utf-8");
|
|
142768
142878
|
let entries;
|
|
142769
142879
|
try {
|
|
@@ -142914,8 +143024,8 @@ init_src();
|
|
|
142914
143024
|
|
|
142915
143025
|
// src/script/runner.ts
|
|
142916
143026
|
init_cjs_shims();
|
|
142917
|
-
var
|
|
142918
|
-
var
|
|
143027
|
+
var import_node_fs11 = require("fs");
|
|
143028
|
+
var import_node_path17 = require("path");
|
|
142919
143029
|
var import_node_url3 = require("url");
|
|
142920
143030
|
init_src();
|
|
142921
143031
|
var ScriptValidationError = createErrorClass(
|
|
@@ -142928,13 +143038,13 @@ var ScriptTimeoutError = createErrorClass(
|
|
|
142928
143038
|
);
|
|
142929
143039
|
var ScriptExecutionError = createErrorClass("ScriptExecutionError", (args) => `Script execution failed: ${args[0]}`);
|
|
142930
143040
|
function validateScriptPath(scriptPath, projectRoot = process.cwd()) {
|
|
142931
|
-
const normalizedRoot = (0,
|
|
142932
|
-
const normalizedScript = (0,
|
|
142933
|
-
const relativePath = (0,
|
|
143041
|
+
const normalizedRoot = (0, import_node_path17.resolve)(projectRoot);
|
|
143042
|
+
const normalizedScript = (0, import_node_path17.resolve)(projectRoot, scriptPath);
|
|
143043
|
+
const relativePath = (0, import_node_path17.relative)(normalizedRoot, normalizedScript);
|
|
142934
143044
|
if (relativePath.startsWith("..")) {
|
|
142935
143045
|
throw new ScriptValidationError(`Script path '${scriptPath}' is outside project directory`);
|
|
142936
143046
|
}
|
|
142937
|
-
if (!(0,
|
|
143047
|
+
if (!(0, import_node_fs11.existsSync)(normalizedScript)) {
|
|
142938
143048
|
throw new ScriptValidationError(`Script file not found: ${scriptPath}`);
|
|
142939
143049
|
}
|
|
142940
143050
|
const validExtensions = [".ts", ".js", ".mjs", ".cjs"];
|
|
@@ -142980,7 +143090,7 @@ var ScriptRunner = class {
|
|
|
142980
143090
|
try {
|
|
142981
143091
|
const returnValue = await this.withTimeout(timeout, async () => {
|
|
142982
143092
|
const projectRoot = context2.projectRoot || process.cwd();
|
|
142983
|
-
const absolutePath = (0,
|
|
143093
|
+
const absolutePath = (0, import_node_path17.resolve)(projectRoot, scriptPath);
|
|
142984
143094
|
const cacheBustUrl = `${(0, import_node_url3.pathToFileURL)(absolutePath).href}?t=${Date.now()}`;
|
|
142985
143095
|
const scriptModule = await import(cacheBustUrl);
|
|
142986
143096
|
if (typeof scriptModule.main !== "function") {
|
|
@@ -143255,14 +143365,14 @@ async function tryExecuteCommand(commandName, logger) {
|
|
|
143255
143365
|
|
|
143256
143366
|
// src/commands/plan.ts
|
|
143257
143367
|
init_cjs_shims();
|
|
143258
|
-
var
|
|
143368
|
+
var import_node_fs12 = require("fs");
|
|
143259
143369
|
var planCommand = new Command("plan").description("Create or update a plan for a task.").argument("[task]", "The task to plan.").option("-p, --plan-file <path>", "The path to the plan file.").action(async (task2, options, command) => {
|
|
143260
143370
|
const workflowOpts = getBaseWorkflowOptions(command);
|
|
143261
143371
|
let taskInput = task2;
|
|
143262
143372
|
let fileContent;
|
|
143263
143373
|
if (options.planFile) {
|
|
143264
143374
|
try {
|
|
143265
|
-
fileContent = (0,
|
|
143375
|
+
fileContent = (0, import_node_fs12.readFileSync)(options.planFile, "utf-8").trim();
|
|
143266
143376
|
} catch {
|
|
143267
143377
|
}
|
|
143268
143378
|
}
|
|
@@ -143296,7 +143406,7 @@ var prCommand = new Command("pr").description("Create a GitHub pull request").ar
|
|
|
143296
143406
|
|
|
143297
143407
|
// src/commands/review.ts
|
|
143298
143408
|
init_cjs_shims();
|
|
143299
|
-
var
|
|
143409
|
+
var import_node_fs13 = require("fs");
|
|
143300
143410
|
init_dist18();
|
|
143301
143411
|
init_workflow_utils();
|
|
143302
143412
|
var reviewCommand = new Command("review").description("Review a GitHub pull request or local changes").argument("[files...]", "Specific files to review (use --context for review instructions)").option("--pr <pr>", "The pull request number to review", (value) => {
|
|
@@ -143334,7 +143444,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
143334
143444
|
});
|
|
143335
143445
|
let context2 = contextOption;
|
|
143336
143446
|
let filesToReview = files;
|
|
143337
|
-
if (files.length === 1 && !(0,
|
|
143447
|
+
if (files.length === 1 && !(0, import_node_fs13.existsSync)(files[0]) && files[0].includes(" ") && !context2) {
|
|
143338
143448
|
logger.warn(
|
|
143339
143449
|
"Warning: The argument looks like context but was passed as a file. Treating it as context. Please use --context for review instructions in the future."
|
|
143340
143450
|
);
|
|
@@ -143365,7 +143475,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
143365
143475
|
if (yes) {
|
|
143366
143476
|
shouldRunTask = true;
|
|
143367
143477
|
} else if (process.stdin.isTTY && !json3) {
|
|
143368
|
-
await new Promise((
|
|
143478
|
+
await new Promise((resolve11) => setTimeout(resolve11, 50));
|
|
143369
143479
|
try {
|
|
143370
143480
|
const answer = await dist_default9({
|
|
143371
143481
|
message: "Do you wish polka-codes to address the review results?",
|