@polka-codes/cli-shared 0.9.39 → 0.9.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +563 -644
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4974,7 +4974,7 @@ var require_lodash = __commonJS((exports, module) => {
4974
4974
  }
4975
4975
  return func(collection, getIteratee(predicate, 3));
4976
4976
  }
4977
- function filter2(collection, predicate) {
4977
+ function filter3(collection, predicate) {
4978
4978
  var func = isArray(collection) ? arrayFilter : baseFilter;
4979
4979
  return func(collection, getIteratee(predicate, 3));
4980
4980
  }
@@ -6390,7 +6390,7 @@ __p += '`;
6390
6390
  lodash.dropRightWhile = dropRightWhile;
6391
6391
  lodash.dropWhile = dropWhile;
6392
6392
  lodash.fill = fill;
6393
- lodash.filter = filter2;
6393
+ lodash.filter = filter3;
6394
6394
  lodash.flatMap = flatMap;
6395
6395
  lodash.flatMapDeep = flatMapDeep;
6396
6396
  lodash.flatMapDepth = flatMapDepth;
@@ -15266,124 +15266,6 @@ var require_lib = __commonJS((exports, module) => {
15266
15266
  module.exports = MuteStream;
15267
15267
  });
15268
15268
 
15269
- // ../../node_modules/ansi-escapes/index.js
15270
- var require_ansi_escapes = __commonJS((exports, module) => {
15271
- var ansiEscapes = exports;
15272
- exports.default = ansiEscapes;
15273
- var ESC = "\x1B[";
15274
- var OSC = "\x1B]";
15275
- var BEL = "\x07";
15276
- var SEP = ";";
15277
- var isTerminalApp = process.env.TERM_PROGRAM === "Apple_Terminal";
15278
- ansiEscapes.cursorTo = (x, y) => {
15279
- if (typeof x !== "number") {
15280
- throw new TypeError("The `x` argument is required");
15281
- }
15282
- if (typeof y !== "number") {
15283
- return ESC + (x + 1) + "G";
15284
- }
15285
- return ESC + (y + 1) + ";" + (x + 1) + "H";
15286
- };
15287
- ansiEscapes.cursorMove = (x, y) => {
15288
- if (typeof x !== "number") {
15289
- throw new TypeError("The `x` argument is required");
15290
- }
15291
- let ret = "";
15292
- if (x < 0) {
15293
- ret += ESC + -x + "D";
15294
- } else if (x > 0) {
15295
- ret += ESC + x + "C";
15296
- }
15297
- if (y < 0) {
15298
- ret += ESC + -y + "A";
15299
- } else if (y > 0) {
15300
- ret += ESC + y + "B";
15301
- }
15302
- return ret;
15303
- };
15304
- ansiEscapes.cursorUp = (count = 1) => ESC + count + "A";
15305
- ansiEscapes.cursorDown = (count = 1) => ESC + count + "B";
15306
- ansiEscapes.cursorForward = (count = 1) => ESC + count + "C";
15307
- ansiEscapes.cursorBackward = (count = 1) => ESC + count + "D";
15308
- ansiEscapes.cursorLeft = ESC + "G";
15309
- ansiEscapes.cursorSavePosition = isTerminalApp ? "\x1B7" : ESC + "s";
15310
- ansiEscapes.cursorRestorePosition = isTerminalApp ? "\x1B8" : ESC + "u";
15311
- ansiEscapes.cursorGetPosition = ESC + "6n";
15312
- ansiEscapes.cursorNextLine = ESC + "E";
15313
- ansiEscapes.cursorPrevLine = ESC + "F";
15314
- ansiEscapes.cursorHide = ESC + "?25l";
15315
- ansiEscapes.cursorShow = ESC + "?25h";
15316
- ansiEscapes.eraseLines = (count) => {
15317
- let clear = "";
15318
- for (let i = 0;i < count; i++) {
15319
- clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : "");
15320
- }
15321
- if (count) {
15322
- clear += ansiEscapes.cursorLeft;
15323
- }
15324
- return clear;
15325
- };
15326
- ansiEscapes.eraseEndLine = ESC + "K";
15327
- ansiEscapes.eraseStartLine = ESC + "1K";
15328
- ansiEscapes.eraseLine = ESC + "2K";
15329
- ansiEscapes.eraseDown = ESC + "J";
15330
- ansiEscapes.eraseUp = ESC + "1J";
15331
- ansiEscapes.eraseScreen = ESC + "2J";
15332
- ansiEscapes.scrollUp = ESC + "S";
15333
- ansiEscapes.scrollDown = ESC + "T";
15334
- ansiEscapes.clearScreen = "\x1Bc";
15335
- ansiEscapes.clearTerminal = process.platform === "win32" ? `${ansiEscapes.eraseScreen}${ESC}0f` : `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
15336
- ansiEscapes.beep = BEL;
15337
- ansiEscapes.link = (text2, url2) => {
15338
- return [
15339
- OSC,
15340
- "8",
15341
- SEP,
15342
- SEP,
15343
- url2,
15344
- BEL,
15345
- text2,
15346
- OSC,
15347
- "8",
15348
- SEP,
15349
- SEP,
15350
- BEL
15351
- ].join("");
15352
- };
15353
- ansiEscapes.image = (buffer, options = {}) => {
15354
- let ret = `${OSC}1337;File=inline=1`;
15355
- if (options.width) {
15356
- ret += `;width=${options.width}`;
15357
- }
15358
- if (options.height) {
15359
- ret += `;height=${options.height}`;
15360
- }
15361
- if (options.preserveAspectRatio === false) {
15362
- ret += ";preserveAspectRatio=0";
15363
- }
15364
- return ret + ":" + buffer.toString("base64") + BEL;
15365
- };
15366
- ansiEscapes.iTerm = {
15367
- setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
15368
- annotation: (message, options = {}) => {
15369
- let ret = `${OSC}1337;`;
15370
- const hasX = typeof options.x !== "undefined";
15371
- const hasY = typeof options.y !== "undefined";
15372
- if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== "undefined")) {
15373
- throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");
15374
- }
15375
- message = message.replace(/\|/g, "");
15376
- ret += options.isHidden ? "AddHiddenAnnotation=" : "AddAnnotation=";
15377
- if (options.length > 0) {
15378
- ret += (hasX ? [message, options.length, options.x, options.y] : [options.length, message]).join("|");
15379
- } else {
15380
- ret += message;
15381
- }
15382
- return ret + BEL;
15383
- }
15384
- };
15385
- });
15386
-
15387
15269
  // ../../node_modules/ignore/index.js
15388
15270
  var require_ignore = __commonJS((exports, module) => {
15389
15271
  function makeArray(subject) {
@@ -37030,16 +36912,18 @@ var toolInfo = {
37030
36912
  {
37031
36913
  description: "Single clarifying question (no options)",
37032
36914
  input: {
37033
- questions: { prompt: "What is the target deployment environment?" }
36915
+ questions: [{ prompt: "What is the target deployment environment?" }]
37034
36916
  }
37035
36917
  },
37036
36918
  {
37037
36919
  description: "Single question with multiple-choice options",
37038
36920
  input: {
37039
- questions: {
37040
- prompt: "Which frontend framework are you using?",
37041
- options: ["React", "Angular", "Vue", "Svelte"]
37042
- }
36921
+ questions: [
36922
+ {
36923
+ prompt: "Which frontend framework are you using?",
36924
+ options: ["React", "Angular", "Vue", "Svelte"]
36925
+ }
36926
+ ]
37043
36927
  }
37044
36928
  },
37045
36929
  {
@@ -37057,10 +36941,12 @@ var toolInfo = {
37057
36941
  {
37058
36942
  description: "Binary (yes/no) confirmation",
37059
36943
  input: {
37060
- questions: {
37061
- prompt: "Is it acceptable to refactor existing tests to improve performance?",
37062
- options: ["Yes", "No"]
37063
- }
36944
+ questions: [
36945
+ {
36946
+ prompt: "Is it acceptable to refactor existing tests to improve performance?",
36947
+ options: ["Yes", "No"]
36948
+ }
36949
+ ]
37064
36950
  }
37065
36951
  }
37066
36952
  ]
@@ -42482,13 +42368,7 @@ var optionalType = ZodOptional2.create;
42482
42368
  var nullableType = ZodNullable2.create;
42483
42369
  var preprocessType = ZodEffects.createWithPreprocess;
42484
42370
  var pipelineType = ZodPipeline.create;
42485
- // ../../node_modules/@ai-sdk/provider-utils/dist/index.mjs
42486
- function combineHeaders(...headers) {
42487
- return headers.reduce((combinedHeaders, currentHeaders) => ({
42488
- ...combinedHeaders,
42489
- ...currentHeaders != null ? currentHeaders : {}
42490
- }), {});
42491
- }
42371
+ // ../../node_modules/ai/node_modules/@ai-sdk/provider-utils/dist/index.mjs
42492
42372
  async function delay(delayInMs, options) {
42493
42373
  if (delayInMs == null) {
42494
42374
  return Promise.resolve();
@@ -42517,9 +42397,6 @@ async function delay(delayInMs, options) {
42517
42397
  function createAbortError() {
42518
42398
  return new DOMException("Delay was aborted", "AbortError");
42519
42399
  }
42520
- function extractResponseHeaders(response) {
42521
- return Object.fromEntries([...response.headers]);
42522
- }
42523
42400
  var createIdGenerator = ({
42524
42401
  prefix,
42525
42402
  size = 16,
@@ -42561,96 +42438,6 @@ function getErrorMessage2(error43) {
42561
42438
  function isAbortError(error43) {
42562
42439
  return (error43 instanceof Error || error43 instanceof DOMException) && (error43.name === "AbortError" || error43.name === "ResponseAborted" || error43.name === "TimeoutError");
42563
42440
  }
42564
- var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
42565
- function handleFetchError({
42566
- error: error43,
42567
- url: url2,
42568
- requestBodyValues
42569
- }) {
42570
- if (isAbortError(error43)) {
42571
- return error43;
42572
- }
42573
- if (error43 instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error43.message.toLowerCase())) {
42574
- const cause = error43.cause;
42575
- if (cause != null) {
42576
- return new APICallError({
42577
- message: `Cannot connect to API: ${cause.message}`,
42578
- cause,
42579
- url: url2,
42580
- requestBodyValues,
42581
- isRetryable: true
42582
- });
42583
- }
42584
- }
42585
- return error43;
42586
- }
42587
- function removeUndefinedEntries(record2) {
42588
- return Object.fromEntries(Object.entries(record2).filter(([_key, value]) => value != null));
42589
- }
42590
- var getOriginalFetch = () => globalThis.fetch;
42591
- var getFromApi = async ({
42592
- url: url2,
42593
- headers = {},
42594
- successfulResponseHandler,
42595
- failedResponseHandler,
42596
- abortSignal,
42597
- fetch: fetch2 = getOriginalFetch()
42598
- }) => {
42599
- try {
42600
- const response = await fetch2(url2, {
42601
- method: "GET",
42602
- headers: removeUndefinedEntries(headers),
42603
- signal: abortSignal
42604
- });
42605
- const responseHeaders = extractResponseHeaders(response);
42606
- if (!response.ok) {
42607
- let errorInformation;
42608
- try {
42609
- errorInformation = await failedResponseHandler({
42610
- response,
42611
- url: url2,
42612
- requestBodyValues: {}
42613
- });
42614
- } catch (error43) {
42615
- if (isAbortError(error43) || APICallError.isInstance(error43)) {
42616
- throw error43;
42617
- }
42618
- throw new APICallError({
42619
- message: "Failed to process error response",
42620
- cause: error43,
42621
- statusCode: response.status,
42622
- url: url2,
42623
- responseHeaders,
42624
- requestBodyValues: {}
42625
- });
42626
- }
42627
- throw errorInformation.value;
42628
- }
42629
- try {
42630
- return await successfulResponseHandler({
42631
- response,
42632
- url: url2,
42633
- requestBodyValues: {}
42634
- });
42635
- } catch (error43) {
42636
- if (error43 instanceof Error) {
42637
- if (isAbortError(error43) || APICallError.isInstance(error43)) {
42638
- throw error43;
42639
- }
42640
- }
42641
- throw new APICallError({
42642
- message: "Failed to process successful response",
42643
- cause: error43,
42644
- statusCode: response.status,
42645
- url: url2,
42646
- responseHeaders,
42647
- requestBodyValues: {}
42648
- });
42649
- }
42650
- } catch (error43) {
42651
- throw handleFetchError({ error: error43, url: url2, requestBodyValues: {} });
42652
- }
42653
- };
42654
42441
  function isUrlSupported({
42655
42442
  mediaType,
42656
42443
  url: url2,
@@ -42663,22 +42450,6 @@ function isUrlSupported({
42663
42450
  return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
42664
42451
  }).filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix)).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url2));
42665
42452
  }
42666
- function loadOptionalSetting({
42667
- settingValue,
42668
- environmentVariableName
42669
- }) {
42670
- if (typeof settingValue === "string") {
42671
- return settingValue;
42672
- }
42673
- if (settingValue != null || typeof process === "undefined") {
42674
- return;
42675
- }
42676
- settingValue = process.env[environmentVariableName];
42677
- if (settingValue == null || typeof settingValue !== "string") {
42678
- return;
42679
- }
42680
- return settingValue;
42681
- }
42682
42453
  var suspectProtoRx = /"__proto__"\s*:/;
42683
42454
  var suspectConstructorRx = /"constructor"\s*:/;
42684
42455
  function _parse2(text) {
@@ -42780,23 +42551,6 @@ async function safeValidateTypes({
42780
42551
  };
42781
42552
  }
42782
42553
  }
42783
- async function parseJSON({
42784
- text,
42785
- schema
42786
- }) {
42787
- try {
42788
- const value = secureJsonParse(text);
42789
- if (schema == null) {
42790
- return value;
42791
- }
42792
- return validateTypes({ value, schema });
42793
- } catch (error43) {
42794
- if (JSONParseError.isInstance(error43) || TypeValidationError.isInstance(error43)) {
42795
- throw error43;
42796
- }
42797
- throw new JSONParseError({ text, cause: error43 });
42798
- }
42799
- }
42800
42554
  async function safeParseJSON({
42801
42555
  text,
42802
42556
  schema
@@ -42815,205 +42569,6 @@ async function safeParseJSON({
42815
42569
  };
42816
42570
  }
42817
42571
  }
42818
- function parseJsonEventStream({
42819
- stream,
42820
- schema
42821
- }) {
42822
- return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream).pipeThrough(new TransformStream({
42823
- async transform({ data }, controller) {
42824
- if (data === "[DONE]") {
42825
- return;
42826
- }
42827
- controller.enqueue(await safeParseJSON({ text: data, schema }));
42828
- }
42829
- }));
42830
- }
42831
- var getOriginalFetch2 = () => globalThis.fetch;
42832
- var postJsonToApi = async ({
42833
- url: url2,
42834
- headers,
42835
- body,
42836
- failedResponseHandler,
42837
- successfulResponseHandler,
42838
- abortSignal,
42839
- fetch: fetch2
42840
- }) => postToApi({
42841
- url: url2,
42842
- headers: {
42843
- "Content-Type": "application/json",
42844
- ...headers
42845
- },
42846
- body: {
42847
- content: JSON.stringify(body),
42848
- values: body
42849
- },
42850
- failedResponseHandler,
42851
- successfulResponseHandler,
42852
- abortSignal,
42853
- fetch: fetch2
42854
- });
42855
- var postToApi = async ({
42856
- url: url2,
42857
- headers = {},
42858
- body,
42859
- successfulResponseHandler,
42860
- failedResponseHandler,
42861
- abortSignal,
42862
- fetch: fetch2 = getOriginalFetch2()
42863
- }) => {
42864
- try {
42865
- const response = await fetch2(url2, {
42866
- method: "POST",
42867
- headers: removeUndefinedEntries(headers),
42868
- body: body.content,
42869
- signal: abortSignal
42870
- });
42871
- const responseHeaders = extractResponseHeaders(response);
42872
- if (!response.ok) {
42873
- let errorInformation;
42874
- try {
42875
- errorInformation = await failedResponseHandler({
42876
- response,
42877
- url: url2,
42878
- requestBodyValues: body.values
42879
- });
42880
- } catch (error43) {
42881
- if (isAbortError(error43) || APICallError.isInstance(error43)) {
42882
- throw error43;
42883
- }
42884
- throw new APICallError({
42885
- message: "Failed to process error response",
42886
- cause: error43,
42887
- statusCode: response.status,
42888
- url: url2,
42889
- responseHeaders,
42890
- requestBodyValues: body.values
42891
- });
42892
- }
42893
- throw errorInformation.value;
42894
- }
42895
- try {
42896
- return await successfulResponseHandler({
42897
- response,
42898
- url: url2,
42899
- requestBodyValues: body.values
42900
- });
42901
- } catch (error43) {
42902
- if (error43 instanceof Error) {
42903
- if (isAbortError(error43) || APICallError.isInstance(error43)) {
42904
- throw error43;
42905
- }
42906
- }
42907
- throw new APICallError({
42908
- message: "Failed to process successful response",
42909
- cause: error43,
42910
- statusCode: response.status,
42911
- url: url2,
42912
- responseHeaders,
42913
- requestBodyValues: body.values
42914
- });
42915
- }
42916
- } catch (error43) {
42917
- throw handleFetchError({ error: error43, url: url2, requestBodyValues: body.values });
42918
- }
42919
- };
42920
- async function resolve(value) {
42921
- if (typeof value === "function") {
42922
- value = value();
42923
- }
42924
- return Promise.resolve(value);
42925
- }
42926
- var createJsonErrorResponseHandler = ({
42927
- errorSchema,
42928
- errorToMessage,
42929
- isRetryable
42930
- }) => async ({ response, url: url2, requestBodyValues }) => {
42931
- const responseBody = await response.text();
42932
- const responseHeaders = extractResponseHeaders(response);
42933
- if (responseBody.trim() === "") {
42934
- return {
42935
- responseHeaders,
42936
- value: new APICallError({
42937
- message: response.statusText,
42938
- url: url2,
42939
- requestBodyValues,
42940
- statusCode: response.status,
42941
- responseHeaders,
42942
- responseBody,
42943
- isRetryable: isRetryable == null ? undefined : isRetryable(response)
42944
- })
42945
- };
42946
- }
42947
- try {
42948
- const parsedError = await parseJSON({
42949
- text: responseBody,
42950
- schema: errorSchema
42951
- });
42952
- return {
42953
- responseHeaders,
42954
- value: new APICallError({
42955
- message: errorToMessage(parsedError),
42956
- url: url2,
42957
- requestBodyValues,
42958
- statusCode: response.status,
42959
- responseHeaders,
42960
- responseBody,
42961
- data: parsedError,
42962
- isRetryable: isRetryable == null ? undefined : isRetryable(response, parsedError)
42963
- })
42964
- };
42965
- } catch (parseError) {
42966
- return {
42967
- responseHeaders,
42968
- value: new APICallError({
42969
- message: response.statusText,
42970
- url: url2,
42971
- requestBodyValues,
42972
- statusCode: response.status,
42973
- responseHeaders,
42974
- responseBody,
42975
- isRetryable: isRetryable == null ? undefined : isRetryable(response)
42976
- })
42977
- };
42978
- }
42979
- };
42980
- var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
42981
- const responseHeaders = extractResponseHeaders(response);
42982
- if (response.body == null) {
42983
- throw new EmptyResponseBodyError({});
42984
- }
42985
- return {
42986
- responseHeaders,
42987
- value: parseJsonEventStream({
42988
- stream: response.body,
42989
- schema: chunkSchema
42990
- })
42991
- };
42992
- };
42993
- var createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
42994
- const responseBody = await response.text();
42995
- const parsedResult = await safeParseJSON({
42996
- text: responseBody,
42997
- schema: responseSchema
42998
- });
42999
- const responseHeaders = extractResponseHeaders(response);
43000
- if (!parsedResult.success) {
43001
- throw new APICallError({
43002
- message: "Invalid JSON response",
43003
- cause: parsedResult.error,
43004
- statusCode: response.status,
43005
- responseHeaders,
43006
- responseBody,
43007
- url: url2,
43008
- requestBodyValues
43009
- });
43010
- }
43011
- return {
43012
- responseHeaders,
43013
- value: parsedResult.value,
43014
- rawValue: parsedResult.rawValue
43015
- };
43016
- };
43017
42572
  var getRelativePath = (pathA, pathB) => {
43018
42573
  let i = 0;
43019
42574
  for (;i < pathA.length && i < pathB.length; i++) {
@@ -44079,9 +43634,6 @@ function convertUint8ArrayToBase64(array2) {
44079
43634
  }
44080
43635
  return btoa2(latin1string);
44081
43636
  }
44082
- function withoutTrailingSlash(url2) {
44083
- return url2 == null ? undefined : url2.replace(/\/$/, "");
44084
- }
44085
43637
  function isAsyncIterable(obj) {
44086
43638
  return obj != null && typeof obj[Symbol.asyncIterator] === "function";
44087
43639
  }
@@ -44102,6 +43654,492 @@ async function* executeTool({
44102
43654
  yield { type: "final", output: await result };
44103
43655
  }
44104
43656
  }
43657
+ // ../../node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils/dist/index.mjs
43658
+ function combineHeaders(...headers) {
43659
+ return headers.reduce((combinedHeaders, currentHeaders) => ({
43660
+ ...combinedHeaders,
43661
+ ...currentHeaders != null ? currentHeaders : {}
43662
+ }), {});
43663
+ }
43664
+ function extractResponseHeaders(response) {
43665
+ return Object.fromEntries([...response.headers]);
43666
+ }
43667
+ var createIdGenerator2 = ({
43668
+ prefix,
43669
+ size = 16,
43670
+ alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
43671
+ separator = "-"
43672
+ } = {}) => {
43673
+ const generator = () => {
43674
+ const alphabetLength = alphabet.length;
43675
+ const chars = new Array(size);
43676
+ for (let i = 0;i < size; i++) {
43677
+ chars[i] = alphabet[Math.random() * alphabetLength | 0];
43678
+ }
43679
+ return chars.join("");
43680
+ };
43681
+ if (prefix == null) {
43682
+ return generator;
43683
+ }
43684
+ if (alphabet.includes(separator)) {
43685
+ throw new InvalidArgumentError({
43686
+ argument: "separator",
43687
+ message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
43688
+ });
43689
+ }
43690
+ return () => `${prefix}${separator}${generator()}`;
43691
+ };
43692
+ var generateId2 = createIdGenerator2();
43693
+ function isAbortError2(error43) {
43694
+ return (error43 instanceof Error || error43 instanceof DOMException) && (error43.name === "AbortError" || error43.name === "ResponseAborted" || error43.name === "TimeoutError");
43695
+ }
43696
+ var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
43697
+ function handleFetchError({
43698
+ error: error43,
43699
+ url: url2,
43700
+ requestBodyValues
43701
+ }) {
43702
+ if (isAbortError2(error43)) {
43703
+ return error43;
43704
+ }
43705
+ if (error43 instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error43.message.toLowerCase())) {
43706
+ const cause = error43.cause;
43707
+ if (cause != null) {
43708
+ return new APICallError({
43709
+ message: `Cannot connect to API: ${cause.message}`,
43710
+ cause,
43711
+ url: url2,
43712
+ requestBodyValues,
43713
+ isRetryable: true
43714
+ });
43715
+ }
43716
+ }
43717
+ return error43;
43718
+ }
43719
+ function removeUndefinedEntries(record2) {
43720
+ return Object.fromEntries(Object.entries(record2).filter(([_key, value]) => value != null));
43721
+ }
43722
+ var getOriginalFetch = () => globalThis.fetch;
43723
+ var getFromApi = async ({
43724
+ url: url2,
43725
+ headers = {},
43726
+ successfulResponseHandler,
43727
+ failedResponseHandler,
43728
+ abortSignal,
43729
+ fetch: fetch2 = getOriginalFetch()
43730
+ }) => {
43731
+ try {
43732
+ const response = await fetch2(url2, {
43733
+ method: "GET",
43734
+ headers: removeUndefinedEntries(headers),
43735
+ signal: abortSignal
43736
+ });
43737
+ const responseHeaders = extractResponseHeaders(response);
43738
+ if (!response.ok) {
43739
+ let errorInformation;
43740
+ try {
43741
+ errorInformation = await failedResponseHandler({
43742
+ response,
43743
+ url: url2,
43744
+ requestBodyValues: {}
43745
+ });
43746
+ } catch (error43) {
43747
+ if (isAbortError2(error43) || APICallError.isInstance(error43)) {
43748
+ throw error43;
43749
+ }
43750
+ throw new APICallError({
43751
+ message: "Failed to process error response",
43752
+ cause: error43,
43753
+ statusCode: response.status,
43754
+ url: url2,
43755
+ responseHeaders,
43756
+ requestBodyValues: {}
43757
+ });
43758
+ }
43759
+ throw errorInformation.value;
43760
+ }
43761
+ try {
43762
+ return await successfulResponseHandler({
43763
+ response,
43764
+ url: url2,
43765
+ requestBodyValues: {}
43766
+ });
43767
+ } catch (error43) {
43768
+ if (error43 instanceof Error) {
43769
+ if (isAbortError2(error43) || APICallError.isInstance(error43)) {
43770
+ throw error43;
43771
+ }
43772
+ }
43773
+ throw new APICallError({
43774
+ message: "Failed to process successful response",
43775
+ cause: error43,
43776
+ statusCode: response.status,
43777
+ url: url2,
43778
+ responseHeaders,
43779
+ requestBodyValues: {}
43780
+ });
43781
+ }
43782
+ } catch (error43) {
43783
+ throw handleFetchError({ error: error43, url: url2, requestBodyValues: {} });
43784
+ }
43785
+ };
43786
+ function loadOptionalSetting({
43787
+ settingValue,
43788
+ environmentVariableName
43789
+ }) {
43790
+ if (typeof settingValue === "string") {
43791
+ return settingValue;
43792
+ }
43793
+ if (settingValue != null || typeof process === "undefined") {
43794
+ return;
43795
+ }
43796
+ settingValue = process.env[environmentVariableName];
43797
+ if (settingValue == null || typeof settingValue !== "string") {
43798
+ return;
43799
+ }
43800
+ return settingValue;
43801
+ }
43802
+ var suspectProtoRx2 = /"__proto__"\s*:/;
43803
+ var suspectConstructorRx2 = /"constructor"\s*:/;
43804
+ function _parse3(text) {
43805
+ const obj = JSON.parse(text);
43806
+ if (obj === null || typeof obj !== "object") {
43807
+ return obj;
43808
+ }
43809
+ if (suspectProtoRx2.test(text) === false && suspectConstructorRx2.test(text) === false) {
43810
+ return obj;
43811
+ }
43812
+ return filter2(obj);
43813
+ }
43814
+ function filter2(obj) {
43815
+ let next = [obj];
43816
+ while (next.length) {
43817
+ const nodes = next;
43818
+ next = [];
43819
+ for (const node of nodes) {
43820
+ if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
43821
+ throw new SyntaxError("Object contains forbidden prototype property");
43822
+ }
43823
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
43824
+ throw new SyntaxError("Object contains forbidden prototype property");
43825
+ }
43826
+ for (const key in node) {
43827
+ const value = node[key];
43828
+ if (value && typeof value === "object") {
43829
+ next.push(value);
43830
+ }
43831
+ }
43832
+ }
43833
+ }
43834
+ return obj;
43835
+ }
43836
+ function secureJsonParse2(text) {
43837
+ const { stackTraceLimit } = Error;
43838
+ Error.stackTraceLimit = 0;
43839
+ try {
43840
+ return _parse3(text);
43841
+ } finally {
43842
+ Error.stackTraceLimit = stackTraceLimit;
43843
+ }
43844
+ }
43845
+ var validatorSymbol2 = Symbol.for("vercel.ai.validator");
43846
+ function validator2(validate) {
43847
+ return { [validatorSymbol2]: true, validate };
43848
+ }
43849
+ function isValidator2(value) {
43850
+ return typeof value === "object" && value !== null && validatorSymbol2 in value && value[validatorSymbol2] === true && "validate" in value;
43851
+ }
43852
+ function asValidator2(value) {
43853
+ return isValidator2(value) ? value : standardSchemaValidator2(value);
43854
+ }
43855
+ function standardSchemaValidator2(standardSchema) {
43856
+ return validator2(async (value) => {
43857
+ const result = await standardSchema["~standard"].validate(value);
43858
+ return result.issues == null ? { success: true, value: result.value } : {
43859
+ success: false,
43860
+ error: new TypeValidationError({
43861
+ value,
43862
+ cause: result.issues
43863
+ })
43864
+ };
43865
+ });
43866
+ }
43867
+ async function validateTypes2({
43868
+ value,
43869
+ schema
43870
+ }) {
43871
+ const result = await safeValidateTypes2({ value, schema });
43872
+ if (!result.success) {
43873
+ throw TypeValidationError.wrap({ value, cause: result.error });
43874
+ }
43875
+ return result.value;
43876
+ }
43877
+ async function safeValidateTypes2({
43878
+ value,
43879
+ schema
43880
+ }) {
43881
+ const validator22 = asValidator2(schema);
43882
+ try {
43883
+ if (validator22.validate == null) {
43884
+ return { success: true, value, rawValue: value };
43885
+ }
43886
+ const result = await validator22.validate(value);
43887
+ if (result.success) {
43888
+ return { success: true, value: result.value, rawValue: value };
43889
+ }
43890
+ return {
43891
+ success: false,
43892
+ error: TypeValidationError.wrap({ value, cause: result.error }),
43893
+ rawValue: value
43894
+ };
43895
+ } catch (error43) {
43896
+ return {
43897
+ success: false,
43898
+ error: TypeValidationError.wrap({ value, cause: error43 }),
43899
+ rawValue: value
43900
+ };
43901
+ }
43902
+ }
43903
+ async function parseJSON({
43904
+ text,
43905
+ schema
43906
+ }) {
43907
+ try {
43908
+ const value = secureJsonParse2(text);
43909
+ if (schema == null) {
43910
+ return value;
43911
+ }
43912
+ return validateTypes2({ value, schema });
43913
+ } catch (error43) {
43914
+ if (JSONParseError.isInstance(error43) || TypeValidationError.isInstance(error43)) {
43915
+ throw error43;
43916
+ }
43917
+ throw new JSONParseError({ text, cause: error43 });
43918
+ }
43919
+ }
43920
+ async function safeParseJSON2({
43921
+ text,
43922
+ schema
43923
+ }) {
43924
+ try {
43925
+ const value = secureJsonParse2(text);
43926
+ if (schema == null) {
43927
+ return { success: true, value, rawValue: value };
43928
+ }
43929
+ return await safeValidateTypes2({ value, schema });
43930
+ } catch (error43) {
43931
+ return {
43932
+ success: false,
43933
+ error: JSONParseError.isInstance(error43) ? error43 : new JSONParseError({ text, cause: error43 }),
43934
+ rawValue: undefined
43935
+ };
43936
+ }
43937
+ }
43938
+ function parseJsonEventStream({
43939
+ stream,
43940
+ schema
43941
+ }) {
43942
+ return stream.pipeThrough(new TextDecoderStream).pipeThrough(new EventSourceParserStream).pipeThrough(new TransformStream({
43943
+ async transform({ data }, controller) {
43944
+ if (data === "[DONE]") {
43945
+ return;
43946
+ }
43947
+ controller.enqueue(await safeParseJSON2({ text: data, schema }));
43948
+ }
43949
+ }));
43950
+ }
43951
+ var getOriginalFetch2 = () => globalThis.fetch;
43952
+ var postJsonToApi = async ({
43953
+ url: url2,
43954
+ headers,
43955
+ body,
43956
+ failedResponseHandler,
43957
+ successfulResponseHandler,
43958
+ abortSignal,
43959
+ fetch: fetch2
43960
+ }) => postToApi({
43961
+ url: url2,
43962
+ headers: {
43963
+ "Content-Type": "application/json",
43964
+ ...headers
43965
+ },
43966
+ body: {
43967
+ content: JSON.stringify(body),
43968
+ values: body
43969
+ },
43970
+ failedResponseHandler,
43971
+ successfulResponseHandler,
43972
+ abortSignal,
43973
+ fetch: fetch2
43974
+ });
43975
+ var postToApi = async ({
43976
+ url: url2,
43977
+ headers = {},
43978
+ body,
43979
+ successfulResponseHandler,
43980
+ failedResponseHandler,
43981
+ abortSignal,
43982
+ fetch: fetch2 = getOriginalFetch2()
43983
+ }) => {
43984
+ try {
43985
+ const response = await fetch2(url2, {
43986
+ method: "POST",
43987
+ headers: removeUndefinedEntries(headers),
43988
+ body: body.content,
43989
+ signal: abortSignal
43990
+ });
43991
+ const responseHeaders = extractResponseHeaders(response);
43992
+ if (!response.ok) {
43993
+ let errorInformation;
43994
+ try {
43995
+ errorInformation = await failedResponseHandler({
43996
+ response,
43997
+ url: url2,
43998
+ requestBodyValues: body.values
43999
+ });
44000
+ } catch (error43) {
44001
+ if (isAbortError2(error43) || APICallError.isInstance(error43)) {
44002
+ throw error43;
44003
+ }
44004
+ throw new APICallError({
44005
+ message: "Failed to process error response",
44006
+ cause: error43,
44007
+ statusCode: response.status,
44008
+ url: url2,
44009
+ responseHeaders,
44010
+ requestBodyValues: body.values
44011
+ });
44012
+ }
44013
+ throw errorInformation.value;
44014
+ }
44015
+ try {
44016
+ return await successfulResponseHandler({
44017
+ response,
44018
+ url: url2,
44019
+ requestBodyValues: body.values
44020
+ });
44021
+ } catch (error43) {
44022
+ if (error43 instanceof Error) {
44023
+ if (isAbortError2(error43) || APICallError.isInstance(error43)) {
44024
+ throw error43;
44025
+ }
44026
+ }
44027
+ throw new APICallError({
44028
+ message: "Failed to process successful response",
44029
+ cause: error43,
44030
+ statusCode: response.status,
44031
+ url: url2,
44032
+ responseHeaders,
44033
+ requestBodyValues: body.values
44034
+ });
44035
+ }
44036
+ } catch (error43) {
44037
+ throw handleFetchError({ error: error43, url: url2, requestBodyValues: body.values });
44038
+ }
44039
+ };
44040
+ async function resolve(value) {
44041
+ if (typeof value === "function") {
44042
+ value = value();
44043
+ }
44044
+ return Promise.resolve(value);
44045
+ }
44046
+ var createJsonErrorResponseHandler = ({
44047
+ errorSchema,
44048
+ errorToMessage,
44049
+ isRetryable
44050
+ }) => async ({ response, url: url2, requestBodyValues }) => {
44051
+ const responseBody = await response.text();
44052
+ const responseHeaders = extractResponseHeaders(response);
44053
+ if (responseBody.trim() === "") {
44054
+ return {
44055
+ responseHeaders,
44056
+ value: new APICallError({
44057
+ message: response.statusText,
44058
+ url: url2,
44059
+ requestBodyValues,
44060
+ statusCode: response.status,
44061
+ responseHeaders,
44062
+ responseBody,
44063
+ isRetryable: isRetryable == null ? undefined : isRetryable(response)
44064
+ })
44065
+ };
44066
+ }
44067
+ try {
44068
+ const parsedError = await parseJSON({
44069
+ text: responseBody,
44070
+ schema: errorSchema
44071
+ });
44072
+ return {
44073
+ responseHeaders,
44074
+ value: new APICallError({
44075
+ message: errorToMessage(parsedError),
44076
+ url: url2,
44077
+ requestBodyValues,
44078
+ statusCode: response.status,
44079
+ responseHeaders,
44080
+ responseBody,
44081
+ data: parsedError,
44082
+ isRetryable: isRetryable == null ? undefined : isRetryable(response, parsedError)
44083
+ })
44084
+ };
44085
+ } catch (parseError) {
44086
+ return {
44087
+ responseHeaders,
44088
+ value: new APICallError({
44089
+ message: response.statusText,
44090
+ url: url2,
44091
+ requestBodyValues,
44092
+ statusCode: response.status,
44093
+ responseHeaders,
44094
+ responseBody,
44095
+ isRetryable: isRetryable == null ? undefined : isRetryable(response)
44096
+ })
44097
+ };
44098
+ }
44099
+ };
44100
+ var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
44101
+ const responseHeaders = extractResponseHeaders(response);
44102
+ if (response.body == null) {
44103
+ throw new EmptyResponseBodyError({});
44104
+ }
44105
+ return {
44106
+ responseHeaders,
44107
+ value: parseJsonEventStream({
44108
+ stream: response.body,
44109
+ schema: chunkSchema
44110
+ })
44111
+ };
44112
+ };
44113
+ var createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
44114
+ const responseBody = await response.text();
44115
+ const parsedResult = await safeParseJSON2({
44116
+ text: responseBody,
44117
+ schema: responseSchema
44118
+ });
44119
+ const responseHeaders = extractResponseHeaders(response);
44120
+ if (!parsedResult.success) {
44121
+ throw new APICallError({
44122
+ message: "Invalid JSON response",
44123
+ cause: parsedResult.error,
44124
+ statusCode: response.status,
44125
+ responseHeaders,
44126
+ responseBody,
44127
+ url: url2,
44128
+ requestBodyValues
44129
+ });
44130
+ }
44131
+ return {
44132
+ responseHeaders,
44133
+ value: parsedResult.value,
44134
+ rawValue: parsedResult.rawValue
44135
+ };
44136
+ };
44137
+ var ignoreOverride2 = Symbol("Let zodToJsonSchema decide on which parser to use");
44138
+ var ALPHA_NUMERIC2 = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
44139
+ var schemaSymbol2 = Symbol.for("vercel.ai.schema");
44140
+ function withoutTrailingSlash(url2) {
44141
+ return url2 == null ? undefined : url2.replace(/\/$/, "");
44142
+ }
44105
44143
 
44106
44144
  // ../../node_modules/@ai-sdk/gateway/dist/index.mjs
44107
44145
  var marker15 = "vercel.ai.gateway.error";
@@ -51173,64 +51211,6 @@ var createNewProject_default = {
51173
51211
  agent: "architect"
51174
51212
  };
51175
51213
 
51176
- // ../core/src/AiTool/generateProjectConfig.ts
51177
- var prompt2 = `
51178
- Role: Analyzer agent
51179
- Goal: Produce a valid polkacodes YAML configuration for the project.
51180
-
51181
- Workflow
51182
- 1. Scan project files with tool_read_file and identify:
51183
- - Package/build tool (npm, bun, pnpm, etc.)
51184
- - Test framework and patterns (snapshot tests, coverage, etc.)
51185
- - Formatter / linter and their rules
51186
- - Folder structure and naming conventions
51187
- - CI / development workflows
51188
-
51189
- 2. Build a YAML config with three root keys:
51190
-
51191
- \`\`\`yaml
51192
- scripts: # derive from package.json and CI
51193
- format: # code formatter
51194
- command: "<formatter cmd>"
51195
- description: "Format code"
51196
- check: # linter / type checker
51197
- command: "<linter cmd>"
51198
- description: "Static checks"
51199
- test: # test runner
51200
- command: "<test cmd>"
51201
- description: "Run tests"
51202
- # add any other meaningful project scripts
51203
-
51204
- rules: # bullet list of key conventions/tools
51205
-
51206
- excludeFiles: # only files likely to hold secrets
51207
- - ".env"
51208
- - ".env.*"
51209
- - ".npmrc"
51210
- # do NOT list build artifacts, lockfiles, or paths already in .gitignore
51211
- \`\`\`
51212
-
51213
- 3. Return the YAML exactly once, wrapped like:
51214
-
51215
- <tool_attempt_completion>
51216
- <tool_parameter_result>
51217
- # YAML (2-space indents, double-quoted commands)
51218
- </tool_parameter_result>
51219
- </tool_attempt_completion>
51220
- `;
51221
- var generateProjectConfig_default = {
51222
- name: "generateProjectConfig",
51223
- description: "Analyzes project files to generate polkacodes config sections",
51224
- prompt: prompt2,
51225
- formatInput: () => {
51226
- return "";
51227
- },
51228
- parseOutput: (output) => {
51229
- return output;
51230
- },
51231
- agent: "analyzer"
51232
- };
51233
-
51234
51214
  // ../core/src/AiTool/index.ts
51235
51215
  var executeMultiAgentTool = async (definition, agent, params) => {
51236
51216
  const exitReason = await agent.startTask({
@@ -51248,79 +51228,9 @@ var makeMultiAgentTool = (definition) => {
51248
51228
  return executeMultiAgentTool(definition, agent, params);
51249
51229
  };
51250
51230
  };
51251
- var generateProjectConfig = makeMultiAgentTool(generateProjectConfig_default);
51252
51231
  var createNewProject = makeMultiAgentTool(createNewProject_default);
51253
- // ../core/src/workflow/utils.ts
51254
- var import_lodash2 = __toESM(require_lodash(), 1);
51255
- // ../core/src/workflow/builder.ts
51256
- class StepsBuilder {
51257
- #steps = [];
51258
- build() {
51259
- if (this.#steps.length === 0) {
51260
- throw new Error("A workflow must have at least one step.");
51261
- }
51262
- const rootStep = this.#steps.length > 1 ? {
51263
- id: "root",
51264
- type: "sequential",
51265
- steps: this.#steps
51266
- } : this.#steps[0];
51267
- return rootStep;
51268
- }
51269
- step(step) {
51270
- this.#steps.push(step);
51271
- return this;
51272
- }
51273
- parallel(id, step) {
51274
- return this.step({
51275
- id,
51276
- type: "parallel",
51277
- step
51278
- });
51279
- }
51280
- loop(id, config2) {
51281
- return this.step({
51282
- ...config2,
51283
- id,
51284
- type: "loop"
51285
- });
51286
- }
51287
- custom(idOrSpec, run) {
51288
- if (typeof idOrSpec === "string") {
51289
- if (!run) {
51290
- throw new Error('Custom step "run" function must be provided.');
51291
- }
51292
- return this.step({
51293
- id: idOrSpec,
51294
- type: "custom",
51295
- run
51296
- });
51297
- }
51298
- return this.step(idOrSpec);
51299
- }
51300
- workflow(id, config2) {
51301
- return this.step({
51302
- ...config2,
51303
- id,
51304
- type: "workflow"
51305
- });
51306
- }
51307
- agent(id, spec2) {
51308
- return this.step({
51309
- ...spec2,
51310
- id,
51311
- type: "agent"
51312
- });
51313
- }
51314
- branch(id, config2) {
51315
- return this.step({
51316
- ...config2,
51317
- id,
51318
- type: "branch"
51319
- });
51320
- }
51321
- }
51322
51232
  // src/config.ts
51323
- var import_lodash3 = __toESM(require_lodash(), 1);
51233
+ var import_lodash2 = __toESM(require_lodash(), 1);
51324
51234
 
51325
51235
  // node_modules/yaml/dist/index.js
51326
51236
  var composer = require_composer();
@@ -53965,9 +53875,9 @@ class ZodUnion3 extends ZodType3 {
53965
53875
  return this._def.options;
53966
53876
  }
53967
53877
  }
53968
- ZodUnion3.create = (types2, params) => {
53878
+ ZodUnion3.create = (types, params) => {
53969
53879
  return new ZodUnion3({
53970
- options: types2,
53880
+ options: types,
53971
53881
  typeName: ZodFirstPartyTypeKind3.ZodUnion,
53972
53882
  ...processCreateParams2(params)
53973
53883
  });
@@ -55231,7 +55141,7 @@ function mergeConfigs(configs) {
55231
55141
  return {};
55232
55142
  }
55233
55143
  const mergedConfig = configs.reduce((acc, config3) => {
55234
- const merged = import_lodash3.merge({}, acc, config3);
55144
+ const merged = import_lodash2.merge({}, acc, config3);
55235
55145
  let accRules = acc.rules ?? [];
55236
55146
  if (typeof accRules === "string") {
55237
55147
  accRules = [accRules];
@@ -56168,15 +56078,29 @@ var {
56168
56078
  } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
56169
56079
 
56170
56080
  // ../../node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
56171
- var import_ansi_escapes = __toESM(require_ansi_escapes(), 1);
56172
56081
  import { stripVTControlCharacters } from "node:util";
56082
+
56083
+ // ../../node_modules/@inquirer/ansi/dist/esm/index.js
56084
+ var ESC = "\x1B[";
56085
+ var cursorLeft = ESC + "G";
56086
+ var cursorHide = ESC + "?25l";
56087
+ var cursorShow = ESC + "?25h";
56088
+ var cursorUp = (rows = 1) => rows > 0 ? `${ESC}${rows}A` : "";
56089
+ var cursorDown = (rows = 1) => rows > 0 ? `${ESC}${rows}B` : "";
56090
+ var cursorTo = (x, y) => {
56091
+ if (typeof y === "number" && !Number.isNaN(y)) {
56092
+ return `${ESC}${y + 1};${x + 1}H`;
56093
+ }
56094
+ return `${ESC}${x + 1}G`;
56095
+ };
56096
+ var eraseLine = ESC + "2K";
56097
+ var eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft : "";
56098
+
56099
+ // ../../node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
56173
56100
  var height = (content) => content.split(`
56174
56101
  `).length;
56175
56102
  var lastLine = (content) => content.split(`
56176
56103
  `).pop() ?? "";
56177
- function cursorDown(n) {
56178
- return n > 0 ? import_ansi_escapes.default.cursorDown(n) : "";
56179
- }
56180
56104
 
56181
56105
  class ScreenManager {
56182
56106
  height = 0;
@@ -56195,11 +56119,11 @@ class ScreenManager {
56195
56119
  render(content, bottomContent = "") {
56196
56120
  const promptLine = lastLine(content);
56197
56121
  const rawPromptLine = stripVTControlCharacters(promptLine);
56198
- let prompt3 = rawPromptLine;
56122
+ let prompt2 = rawPromptLine;
56199
56123
  if (this.rl.line.length > 0) {
56200
- prompt3 = prompt3.slice(0, -this.rl.line.length);
56124
+ prompt2 = prompt2.slice(0, -this.rl.line.length);
56201
56125
  }
56202
- this.rl.setPrompt(prompt3);
56126
+ this.rl.setPrompt(prompt2);
56203
56127
  this.cursorPos = this.rl.getCursorPos();
56204
56128
  const width = readlineWidth();
56205
56129
  content = breakLines(content, width);
@@ -56213,25 +56137,25 @@ class ScreenManager {
56213
56137
  const promptLineUpDiff = Math.floor(rawPromptLine.length / width) - this.cursorPos.rows;
56214
56138
  const bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
56215
56139
  if (bottomContentHeight > 0)
56216
- output += import_ansi_escapes.default.cursorUp(bottomContentHeight);
56217
- output += import_ansi_escapes.default.cursorTo(this.cursorPos.cols);
56218
- this.write(cursorDown(this.extraLinesUnderPrompt) + import_ansi_escapes.default.eraseLines(this.height) + output);
56140
+ output += cursorUp(bottomContentHeight);
56141
+ output += cursorTo(this.cursorPos.cols);
56142
+ this.write(cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output);
56219
56143
  this.extraLinesUnderPrompt = bottomContentHeight;
56220
56144
  this.height = height(output);
56221
56145
  }
56222
56146
  checkCursorPos() {
56223
56147
  const cursorPos = this.rl.getCursorPos();
56224
56148
  if (cursorPos.cols !== this.cursorPos.cols) {
56225
- this.write(import_ansi_escapes.default.cursorTo(cursorPos.cols));
56149
+ this.write(cursorTo(cursorPos.cols));
56226
56150
  this.cursorPos = cursorPos;
56227
56151
  }
56228
56152
  }
56229
56153
  done({ clearContent }) {
56230
56154
  this.rl.setPrompt("");
56231
56155
  let output = cursorDown(this.extraLinesUnderPrompt);
56232
- output += clearContent ? import_ansi_escapes.default.eraseLines(this.height) : `
56156
+ output += clearContent ? eraseLines(this.height) : `
56233
56157
  `;
56234
- output += import_ansi_escapes.default.cursorShow;
56158
+ output += cursorShow;
56235
56159
  this.write(output);
56236
56160
  this.rl.close();
56237
56161
  }
@@ -56269,7 +56193,7 @@ function getCallSites() {
56269
56193
  }
56270
56194
  function createPrompt(view) {
56271
56195
  const callSites = getCallSites();
56272
- const prompt3 = (config3, context = {}) => {
56196
+ const prompt2 = (config3, context = {}) => {
56273
56197
  const { input = process.stdin, signal } = context;
56274
56198
  const cleanups = new Set;
56275
56199
  const output = new import_mute_stream.default;
@@ -56334,7 +56258,7 @@ function createPrompt(view) {
56334
56258
  }).then(() => promise2), { cancel });
56335
56259
  });
56336
56260
  };
56337
- return prompt3;
56261
+ return prompt2;
56338
56262
  }
56339
56263
  // ../../node_modules/@inquirer/core/dist/esm/lib/Separator.js
56340
56264
  var import_yoctocolors_cjs2 = __toESM(require_yoctocolors_cjs(), 1);
@@ -56423,7 +56347,6 @@ var esm_default2 = createPrompt((config3, done) => {
56423
56347
  });
56424
56348
  // ../../node_modules/@inquirer/select/dist/esm/index.js
56425
56349
  var import_yoctocolors_cjs3 = __toESM(require_yoctocolors_cjs(), 1);
56426
- var import_ansi_escapes2 = __toESM(require_ansi_escapes(), 1);
56427
56350
  var selectTheme = {
56428
56351
  icon: { cursor: esm_default.pointer },
56429
56352
  style: {
@@ -56574,7 +56497,7 @@ ${theme.style.help(`(${config3.instructions?.pager ?? "Use arrow keys to reveal
56574
56497
  const choiceDescription = selectedChoice.description ? `
56575
56498
  ${theme.style.description(selectedChoice.description)}` : ``;
56576
56499
  return `${[prefix, message, helpTipTop].filter(Boolean).join(" ")}
56577
- ${page}${helpTipBottom}${choiceDescription}${import_ansi_escapes2.default.cursorHide}`;
56500
+ ${page}${helpTipBottom}${choiceDescription}${cursorHide}`;
56578
56501
  });
56579
56502
  // src/provider.ts
56580
56503
  var import_ignore2 = __toESM(require_ignore(), 1);
@@ -56616,7 +56539,7 @@ function lookup(path) {
56616
56539
  }
56617
56540
  return $types[extension2] || false;
56618
56541
  }
56619
- function populateMaps(extensions, types2) {
56542
+ function populateMaps(extensions, types) {
56620
56543
  Object.keys(db).forEach(function forEachMimeType(type) {
56621
56544
  var mime = db[type];
56622
56545
  var exts = mime.extensions;
@@ -56626,10 +56549,10 @@ function populateMaps(extensions, types2) {
56626
56549
  extensions[type] = exts;
56627
56550
  for (var i = 0;i < exts.length; i++) {
56628
56551
  var extension2 = exts[i];
56629
- types2[extension2] = _preferredType(extension2, types2[extension2], type);
56630
- const legacyType = _preferredTypeLegacy(extension2, types2[extension2], type);
56631
- if (legacyType !== types2[extension2]) {
56632
- $_extensionConflicts.push([extension2, legacyType, types2[extension2]]);
56552
+ types[extension2] = _preferredType(extension2, types[extension2], type);
56553
+ const legacyType = _preferredTypeLegacy(extension2, types[extension2], type);
56554
+ if (legacyType !== types[extension2]) {
56555
+ $_extensionConflicts.push([extension2, legacyType, types[extension2]]);
56633
56556
  }
56634
56557
  }
56635
56558
  });
@@ -56874,10 +56797,10 @@ var getProvider = (options = {}) => {
56874
56797
  mediaType
56875
56798
  };
56876
56799
  },
56877
- executeCommand: (command2, _needApprove) => {
56800
+ executeCommand: (command, _needApprove) => {
56878
56801
  return new Promise((resolve4, reject) => {
56879
- options.command?.onStarted(command2);
56880
- const child = spawn2(command2, [], {
56802
+ options.command?.onStarted(command);
56803
+ const child = spawn2(command, [], {
56881
56804
  shell: true,
56882
56805
  stdio: "pipe"
56883
56806
  });
@@ -57340,17 +57263,17 @@ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
57340
57263
  for (const [styleName, style] of Object.entries(ansi_styles_default)) {
57341
57264
  styles2[styleName] = {
57342
57265
  get() {
57343
- const builder2 = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
57344
- Object.defineProperty(this, styleName, { value: builder2 });
57345
- return builder2;
57266
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
57267
+ Object.defineProperty(this, styleName, { value: builder });
57268
+ return builder;
57346
57269
  }
57347
57270
  };
57348
57271
  }
57349
57272
  styles2.visible = {
57350
57273
  get() {
57351
- const builder2 = createBuilder(this, this[STYLER], true);
57352
- Object.defineProperty(this, "visible", { value: builder2 });
57353
- return builder2;
57274
+ const builder = createBuilder(this, this[STYLER], true);
57275
+ Object.defineProperty(this, "visible", { value: builder });
57276
+ return builder;
57354
57277
  }
57355
57278
  };
57356
57279
  var getModelAnsi = (model, level, type, ...arguments_) => {
@@ -57421,12 +57344,12 @@ var createStyler = (open, close, parent) => {
57421
57344
  };
57422
57345
  };
57423
57346
  var createBuilder = (self2, _styler, _isEmpty) => {
57424
- const builder2 = (...arguments_) => applyStyle(builder2, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
57425
- Object.setPrototypeOf(builder2, proto);
57426
- builder2[GENERATOR] = self2;
57427
- builder2[STYLER] = _styler;
57428
- builder2[IS_EMPTY] = _isEmpty;
57429
- return builder2;
57347
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
57348
+ Object.setPrototypeOf(builder, proto);
57349
+ builder[GENERATOR] = self2;
57350
+ builder[STYLER] = _styler;
57351
+ builder[IS_EMPTY] = _isEmpty;
57352
+ return builder;
57430
57353
  };
57431
57354
  var applyStyle = (self2, string4) => {
57432
57355
  if (self2.level <= 0 || !string4) {
@@ -57531,25 +57454,21 @@ ${event.systemPrompt}`);
57531
57454
  break;
57532
57455
  case "Usage" /* Usage */:
57533
57456
  break;
57534
- case "Text" /* Text */:
57535
- if (customConsole !== console) {
57536
- break;
57537
- }
57457
+ case "Text" /* Text */: {
57538
57458
  if (hadReasoning) {
57539
- process.stdout.write(`
57459
+ customConsole.write(`
57540
57460
 
57541
57461
  `);
57542
57462
  hadReasoning = false;
57543
57463
  }
57544
- process.stdout.write(event.newText);
57464
+ customConsole.write(event.newText);
57545
57465
  break;
57546
- case "Reasoning" /* Reasoning */:
57547
- if (customConsole !== console) {
57548
- break;
57549
- }
57550
- process.stdout.write(source_default.dim(event.newText));
57466
+ }
57467
+ case "Reasoning" /* Reasoning */: {
57468
+ customConsole.write(source_default.dim(event.newText));
57551
57469
  hadReasoning = true;
57552
57470
  break;
57471
+ }
57553
57472
  case "ToolUse" /* ToolUse */: {
57554
57473
  customConsole.log(source_default.yellow(`
57555
57474