@getpochi/cli 0.5.28 → 0.5.30
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/cli.js +631 -299
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -29505,8 +29505,8 @@ var init_fiberRuntime = __esm(() => {
|
|
|
29505
29505
|
const clockService = get10(this.getFiberRef(currentServices), clockTag);
|
|
29506
29506
|
const date6 = new Date(clockService.unsafeCurrentTimeMillis());
|
|
29507
29507
|
withRedactableContext(contextMap, () => {
|
|
29508
|
-
for (const
|
|
29509
|
-
|
|
29508
|
+
for (const logger14 of loggers) {
|
|
29509
|
+
logger14.log({
|
|
29510
29510
|
fiberId: this.id(),
|
|
29511
29511
|
logLevel,
|
|
29512
29512
|
message,
|
|
@@ -34865,7 +34865,7 @@ var init_FiberRef = __esm(() => {
|
|
|
34865
34865
|
});
|
|
34866
34866
|
|
|
34867
34867
|
// ../../node_modules/effect/dist/esm/internal/layer/circular.js
|
|
34868
|
-
var minimumLogLevel = (level) => scopedDiscard(fiberRefLocallyScoped(currentMinimumLogLevel, level)), withMinimumLogLevel, addLogger = (
|
|
34868
|
+
var minimumLogLevel = (level) => scopedDiscard(fiberRefLocallyScoped(currentMinimumLogLevel, level)), withMinimumLogLevel, addLogger = (logger14) => scopedDiscard(fiberRefLocallyScopedWith(currentLoggers, add2(logger14))), addLoggerEffect = (effect) => unwrapEffect(map17(effect, addLogger)), addLoggerScoped = (effect) => unwrapScoped(map17(effect, addLogger)), removeLogger = (logger14) => scopedDiscard(fiberRefLocallyScopedWith(currentLoggers, remove6(logger14))), replaceLogger, replaceLoggerEffect, replaceLoggerScoped, setConfigProvider = (configProvider) => scopedDiscard(withConfigProviderScoped(configProvider)), parentSpan = (span2) => succeedContext(make11(spanTag, span2)), span2 = (name17, options) => {
|
|
34869
34869
|
options = addSpanStackTrace(options);
|
|
34870
34870
|
return scoped2(spanTag, options?.onEnd ? tap2(makeSpanScoped(name17, options), (span3) => addFinalizer((exit4) => options.onEnd(span3, exit4))) : makeSpanScoped(name17, options));
|
|
34871
34871
|
}, setTracer = (tracer3) => scopedDiscard(withTracerScoped(tracer3));
|
|
@@ -63956,7 +63956,7 @@ var init_httpApp = __esm(() => {
|
|
|
63956
63956
|
});
|
|
63957
63957
|
|
|
63958
63958
|
// ../../node_modules/@effect/platform/dist/esm/internal/httpMiddleware.js
|
|
63959
|
-
var make86 = (middleware) => middleware, loggerDisabled, withLoggerDisabled = (self2) => zipRight7(set10(loggerDisabled, true), self2), currentTracerDisabledWhen2, withTracerDisabledWhen2, withTracerDisabledWhenEffect, withTracerDisabledForUrls, SpanNameGenerator2, withSpanNameGenerator2,
|
|
63959
|
+
var make86 = (middleware) => middleware, loggerDisabled, withLoggerDisabled = (self2) => zipRight7(set10(loggerDisabled, true), self2), currentTracerDisabledWhen2, withTracerDisabledWhen2, withTracerDisabledWhenEffect, withTracerDisabledForUrls, SpanNameGenerator2, withSpanNameGenerator2, logger14, tracer3, xForwardedHeaders, searchParamsParser = (httpApp) => withFiberRuntime2((fiber) => {
|
|
63960
63960
|
const context10 = fiber.currentContext;
|
|
63961
63961
|
const request2 = unsafeGet5(context10, HttpServerRequest);
|
|
63962
63962
|
const params = searchParamsFromURL2(new URL(request2.originalUrl));
|
|
@@ -64071,7 +64071,7 @@ var init_httpMiddleware = __esm(() => {
|
|
|
64071
64071
|
defaultValue: () => (request2) => `http.server ${request2.method}`
|
|
64072
64072
|
});
|
|
64073
64073
|
withSpanNameGenerator2 = /* @__PURE__ */ dual(2, (self2, f2) => provide3(self2, succeed12(SpanNameGenerator2, f2)));
|
|
64074
|
-
|
|
64074
|
+
logger14 = /* @__PURE__ */ make86((httpApp) => {
|
|
64075
64075
|
let counter6 = 0;
|
|
64076
64076
|
return withFiberRuntime2((fiber) => {
|
|
64077
64077
|
const request2 = unsafeGet5(fiber.currentContext, HttpServerRequest);
|
|
@@ -65084,16 +65084,16 @@ __export(exports_HttpMiddleware, {
|
|
|
65084
65084
|
searchParamsParser: () => searchParamsParser2,
|
|
65085
65085
|
make: () => make89,
|
|
65086
65086
|
loggerDisabled: () => loggerDisabled2,
|
|
65087
|
-
logger: () =>
|
|
65087
|
+
logger: () => logger15,
|
|
65088
65088
|
currentTracerDisabledWhen: () => currentTracerDisabledWhen3,
|
|
65089
65089
|
cors: () => cors2,
|
|
65090
65090
|
SpanNameGenerator: () => SpanNameGenerator3
|
|
65091
65091
|
});
|
|
65092
|
-
var make89,
|
|
65092
|
+
var make89, logger15, loggerDisabled2, withLoggerDisabled2, currentTracerDisabledWhen3, withTracerDisabledWhen3, withTracerDisabledWhenEffect2, withTracerDisabledForUrls2, xForwardedHeaders2, searchParamsParser2, cors2, SpanNameGenerator3, withSpanNameGenerator3;
|
|
65093
65093
|
var init_HttpMiddleware = __esm(() => {
|
|
65094
65094
|
init_httpMiddleware();
|
|
65095
65095
|
make89 = make86;
|
|
65096
|
-
|
|
65096
|
+
logger15 = logger14;
|
|
65097
65097
|
loggerDisabled2 = loggerDisabled;
|
|
65098
65098
|
withLoggerDisabled2 = withLoggerDisabled;
|
|
65099
65099
|
currentTracerDisabledWhen3 = currentTracerDisabledWhen2;
|
|
@@ -83693,9 +83693,9 @@ import * as Http from "node:http";
|
|
|
83693
83693
|
import * as Https from "node:https";
|
|
83694
83694
|
import { Readable as Readable2 } from "node:stream";
|
|
83695
83695
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
83696
|
-
var HttpAgentTypeId, HttpAgent, makeAgent = (options4) => map26(all9([acquireRelease2(sync6(() => new Http.Agent(options4)), (agent) => sync6(() => agent.destroy())), acquireRelease2(sync6(() => new Https.Agent(options4)), (agent) => sync6(() => agent.destroy()))]), ([
|
|
83696
|
+
var HttpAgentTypeId, HttpAgent, makeAgent = (options4) => map26(all9([acquireRelease2(sync6(() => new Http.Agent(options4)), (agent) => sync6(() => agent.destroy())), acquireRelease2(sync6(() => new Https.Agent(options4)), (agent) => sync6(() => agent.destroy()))]), ([http3, https]) => ({
|
|
83697
83697
|
[HttpAgentTypeId]: HttpAgentTypeId,
|
|
83698
|
-
http:
|
|
83698
|
+
http: http3,
|
|
83699
83699
|
https
|
|
83700
83700
|
})), makeAgentLayer = (options4) => scoped4(HttpAgent, makeAgent(options4)), agentLayer, fromAgent = (agent) => make74((request4, url3, signal2) => {
|
|
83701
83701
|
const nodeRequest = url3.protocol === "https:" ? Https.request(url3, {
|
|
@@ -90132,11 +90132,11 @@ var require_client_h2 = __commonJS((exports, module) => {
|
|
|
90132
90132
|
var { channels } = require_diagnostics();
|
|
90133
90133
|
var kOpenStreams = Symbol("open streams");
|
|
90134
90134
|
var extractBody;
|
|
90135
|
-
var
|
|
90135
|
+
var http22;
|
|
90136
90136
|
try {
|
|
90137
|
-
|
|
90137
|
+
http22 = __require("node:http2");
|
|
90138
90138
|
} catch {
|
|
90139
|
-
|
|
90139
|
+
http22 = { constants: {} };
|
|
90140
90140
|
}
|
|
90141
90141
|
var {
|
|
90142
90142
|
constants: {
|
|
@@ -90148,7 +90148,7 @@ var require_client_h2 = __commonJS((exports, module) => {
|
|
|
90148
90148
|
HTTP2_HEADER_EXPECT,
|
|
90149
90149
|
HTTP2_HEADER_STATUS
|
|
90150
90150
|
}
|
|
90151
|
-
} =
|
|
90151
|
+
} = http22;
|
|
90152
90152
|
function parseH2Headers(headers) {
|
|
90153
90153
|
const result2 = [];
|
|
90154
90154
|
for (const [name17, value9] of Object.entries(headers)) {
|
|
@@ -90164,7 +90164,7 @@ var require_client_h2 = __commonJS((exports, module) => {
|
|
|
90164
90164
|
}
|
|
90165
90165
|
async function connectH2(client, socket) {
|
|
90166
90166
|
client[kSocket] = socket;
|
|
90167
|
-
const session =
|
|
90167
|
+
const session = http22.connect(client[kUrl], {
|
|
90168
90168
|
createConnection: () => socket,
|
|
90169
90169
|
peerMaxConcurrentStreams: client[kMaxConcurrentStreams],
|
|
90170
90170
|
settings: {
|
|
@@ -90629,7 +90629,7 @@ var require_client_h2 = __commonJS((exports, module) => {
|
|
|
90629
90629
|
var require_client = __commonJS((exports, module) => {
|
|
90630
90630
|
var assert5 = __require("node:assert");
|
|
90631
90631
|
var net = __require("node:net");
|
|
90632
|
-
var
|
|
90632
|
+
var http3 = __require("node:http");
|
|
90633
90633
|
var util4 = require_util();
|
|
90634
90634
|
var { ClientStats } = require_stats();
|
|
90635
90635
|
var { channels } = require_diagnostics();
|
|
@@ -90684,7 +90684,7 @@ var require_client = __commonJS((exports, module) => {
|
|
|
90684
90684
|
var connectH1 = require_client_h1();
|
|
90685
90685
|
var connectH2 = require_client_h2();
|
|
90686
90686
|
var kClosedResolve = Symbol("kClosedResolve");
|
|
90687
|
-
var getDefaultNodeMaxHeaderSize =
|
|
90687
|
+
var getDefaultNodeMaxHeaderSize = http3 && http3.maxHeaderSize && Number.isInteger(http3.maxHeaderSize) && http3.maxHeaderSize > 0 ? () => http3.maxHeaderSize : () => {
|
|
90688
90688
|
throw new InvalidArgumentError5("http module not available or http.maxHeaderSize invalid");
|
|
90689
90689
|
};
|
|
90690
90690
|
var noop4 = () => {};
|
|
@@ -105256,7 +105256,7 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
105256
105256
|
var require_websocket2 = __commonJS((exports, module) => {
|
|
105257
105257
|
var EventEmitter = __require("events");
|
|
105258
105258
|
var https = __require("https");
|
|
105259
|
-
var
|
|
105259
|
+
var http3 = __require("http");
|
|
105260
105260
|
var net = __require("net");
|
|
105261
105261
|
var tls = __require("tls");
|
|
105262
105262
|
var { randomBytes: randomBytes3, createHash: createHash3 } = __require("crypto");
|
|
@@ -105669,7 +105669,7 @@ var require_websocket2 = __commonJS((exports, module) => {
|
|
|
105669
105669
|
}
|
|
105670
105670
|
const defaultPort = isSecure ? 443 : 80;
|
|
105671
105671
|
const key2 = randomBytes3(16).toString("base64");
|
|
105672
|
-
const request4 = isSecure ? https.request :
|
|
105672
|
+
const request4 = isSecure ? https.request : http3.request;
|
|
105673
105673
|
const protocolSet = new Set;
|
|
105674
105674
|
let perMessageDeflate;
|
|
105675
105675
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -106162,7 +106162,7 @@ var require_subprotocol = __commonJS((exports, module) => {
|
|
|
106162
106162
|
// ../../node_modules/@effect/platform-node/node_modules/ws/lib/websocket-server.js
|
|
106163
106163
|
var require_websocket_server = __commonJS((exports, module) => {
|
|
106164
106164
|
var EventEmitter = __require("events");
|
|
106165
|
-
var
|
|
106165
|
+
var http3 = __require("http");
|
|
106166
106166
|
var { Duplex: Duplex2 } = __require("stream");
|
|
106167
106167
|
var { createHash: createHash3 } = __require("crypto");
|
|
106168
106168
|
var extension2 = require_extension();
|
|
@@ -106200,8 +106200,8 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
106200
106200
|
throw new TypeError('One and only one of the "port", "server", or "noServer" options ' + "must be specified");
|
|
106201
106201
|
}
|
|
106202
106202
|
if (options4.port != null) {
|
|
106203
|
-
this._server =
|
|
106204
|
-
const body =
|
|
106203
|
+
this._server = http3.createServer((req, res) => {
|
|
106204
|
+
const body = http3.STATUS_CODES[426];
|
|
106205
106205
|
res.writeHead(426, {
|
|
106206
106206
|
"Content-Length": body.length,
|
|
106207
106207
|
"Content-Type": "text/plain"
|
|
@@ -106435,7 +106435,7 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
106435
106435
|
this.destroy();
|
|
106436
106436
|
}
|
|
106437
106437
|
function abortHandshake(socket, code2, message, headers) {
|
|
106438
|
-
message = message ||
|
|
106438
|
+
message = message || http3.STATUS_CODES[code2];
|
|
106439
106439
|
headers = {
|
|
106440
106440
|
Connection: "close",
|
|
106441
106441
|
"Content-Type": "text/html",
|
|
@@ -106443,7 +106443,7 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
106443
106443
|
...headers
|
|
106444
106444
|
};
|
|
106445
106445
|
socket.once("finish", socket.destroy);
|
|
106446
|
-
socket.end(`HTTP/1.1 ${code2} ${
|
|
106446
|
+
socket.end(`HTTP/1.1 ${code2} ${http3.STATUS_CODES[code2]}\r
|
|
106447
106447
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join(`\r
|
|
106448
106448
|
`) + `\r
|
|
106449
106449
|
\r
|
|
@@ -107854,7 +107854,7 @@ __export(exports_NodeClusterRunnerHttp, {
|
|
|
107854
107854
|
layerHttpServer: () => layerHttpServer,
|
|
107855
107855
|
layer: () => layer37
|
|
107856
107856
|
});
|
|
107857
|
-
import { createServer as
|
|
107857
|
+
import { createServer as createServer4 } from "node:http";
|
|
107858
107858
|
var layer37 = (options4) => {
|
|
107859
107859
|
const layer38 = options4.clientOnly ? options4.transport === "http" ? provide3(layerHttpClientOnly, layerUndici) : provide3(layerWebsocketClientOnly, layerWebSocketConstructor) : options4.transport === "http" ? provide3(layerHttp, [layerHttpServer, layerUndici]) : provide3(layerWebsocket, [layerHttpServer, layerWebSocketConstructor]);
|
|
107860
107860
|
return layer38.pipe(provideMerge2(options4?.storage === "sql" ? layer17 : layerNoop3), provide3(options4?.storage === "sql" ? options4.clientOnly ? empty34 : layer18 : layerNoop4), provide3(layerFromEnv(options4?.shardingConfig)), provide3(options4?.serialization === "ndjson" ? layerNdjson : layerMsgPack));
|
|
@@ -107879,7 +107879,7 @@ var init_NodeClusterRunnerHttp = __esm(() => {
|
|
|
107879
107879
|
if (isNone2(listenAddress)) {
|
|
107880
107880
|
return yield* dieMessage2("NodeClusterHttpRunner.layerHttpServer: ShardingConfig.podAddress is None");
|
|
107881
107881
|
}
|
|
107882
|
-
return layer36(
|
|
107882
|
+
return layer36(createServer4, listenAddress.value);
|
|
107883
107883
|
}).pipe(unwrapEffect2);
|
|
107884
107884
|
});
|
|
107885
107885
|
|
|
@@ -109559,7 +109559,7 @@ var require_extension2 = __commonJS((exports, module) => {
|
|
|
109559
109559
|
var require_websocket3 = __commonJS((exports, module) => {
|
|
109560
109560
|
var EventEmitter = __require("events");
|
|
109561
109561
|
var https = __require("https");
|
|
109562
|
-
var
|
|
109562
|
+
var http3 = __require("http");
|
|
109563
109563
|
var net = __require("net");
|
|
109564
109564
|
var tls = __require("tls");
|
|
109565
109565
|
var { randomBytes: randomBytes4, createHash: createHash3 } = __require("crypto");
|
|
@@ -109972,7 +109972,7 @@ var require_websocket3 = __commonJS((exports, module) => {
|
|
|
109972
109972
|
}
|
|
109973
109973
|
const defaultPort = isSecure ? 443 : 80;
|
|
109974
109974
|
const key2 = randomBytes4(16).toString("base64");
|
|
109975
|
-
const request4 = isSecure ? https.request :
|
|
109975
|
+
const request4 = isSecure ? https.request : http3.request;
|
|
109976
109976
|
const protocolSet = new Set;
|
|
109977
109977
|
let perMessageDeflate;
|
|
109978
109978
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -110465,7 +110465,7 @@ var require_subprotocol2 = __commonJS((exports, module) => {
|
|
|
110465
110465
|
// ../../node_modules/@effect/platform-node-shared/node_modules/ws/lib/websocket-server.js
|
|
110466
110466
|
var require_websocket_server2 = __commonJS((exports, module) => {
|
|
110467
110467
|
var EventEmitter = __require("events");
|
|
110468
|
-
var
|
|
110468
|
+
var http3 = __require("http");
|
|
110469
110469
|
var { Duplex: Duplex2 } = __require("stream");
|
|
110470
110470
|
var { createHash: createHash3 } = __require("crypto");
|
|
110471
110471
|
var extension2 = require_extension2();
|
|
@@ -110503,8 +110503,8 @@ var require_websocket_server2 = __commonJS((exports, module) => {
|
|
|
110503
110503
|
throw new TypeError('One and only one of the "port", "server", or "noServer" options ' + "must be specified");
|
|
110504
110504
|
}
|
|
110505
110505
|
if (options4.port != null) {
|
|
110506
|
-
this._server =
|
|
110507
|
-
const body =
|
|
110506
|
+
this._server = http3.createServer((req, res) => {
|
|
110507
|
+
const body = http3.STATUS_CODES[426];
|
|
110508
110508
|
res.writeHead(426, {
|
|
110509
110509
|
"Content-Length": body.length,
|
|
110510
110510
|
"Content-Type": "text/plain"
|
|
@@ -110738,7 +110738,7 @@ var require_websocket_server2 = __commonJS((exports, module) => {
|
|
|
110738
110738
|
this.destroy();
|
|
110739
110739
|
}
|
|
110740
110740
|
function abortHandshake(socket, code2, message, headers) {
|
|
110741
|
-
message = message ||
|
|
110741
|
+
message = message || http3.STATUS_CODES[code2];
|
|
110742
110742
|
headers = {
|
|
110743
110743
|
Connection: "close",
|
|
110744
110744
|
"Content-Type": "text/html",
|
|
@@ -110746,7 +110746,7 @@ var require_websocket_server2 = __commonJS((exports, module) => {
|
|
|
110746
110746
|
...headers
|
|
110747
110747
|
};
|
|
110748
110748
|
socket.once("finish", socket.destroy);
|
|
110749
|
-
socket.end(`HTTP/1.1 ${code2} ${
|
|
110749
|
+
socket.end(`HTTP/1.1 ${code2} ${http3.STATUS_CODES[code2]}\r
|
|
110750
110750
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join(`\r
|
|
110751
110751
|
`) + `\r
|
|
110752
110752
|
\r
|
|
@@ -110978,7 +110978,7 @@ __export(exports_NodeClusterShardManagerHttp, {
|
|
|
110978
110978
|
layerHttpServer: () => layerHttpServer2,
|
|
110979
110979
|
layer: () => layer41
|
|
110980
110980
|
});
|
|
110981
|
-
import { createServer as
|
|
110981
|
+
import { createServer as createServer6 } from "node:http";
|
|
110982
110982
|
var layerHttpServer2, layer41 = (options4) => {
|
|
110983
110983
|
const layer42 = options4.transport === "http" ? layerHttp2.pipe(provide3([layerRunnerHealthHttp, layerHttpServer2]), provide3(layerUndici)) : layerWebsocket2.pipe(provide3([layerRunnerHealthWebsocket, layerHttpServer2]), provide3(layerWebSocketConstructor));
|
|
110984
110984
|
return layer42.pipe(provide3(options4?.storage === "sql" ? layer18 : layerNoop4), provide3([layerFromEnv(options4.shardingConfig), layerConfigFromEnv(options4?.config), options4?.serialization === "ndjson" ? layerNdjson : layerMsgPack]));
|
|
@@ -110997,7 +110997,7 @@ var init_NodeClusterShardManagerHttp = __esm(() => {
|
|
|
110997
110997
|
init_NodeSocket2();
|
|
110998
110998
|
layerHttpServer2 = /* @__PURE__ */ gen4(function* () {
|
|
110999
110999
|
const config5 = yield* ShardingConfig;
|
|
111000
|
-
return layer36(
|
|
111000
|
+
return layer36(createServer6, config5.shardManagerAddress);
|
|
111001
111001
|
}).pipe(unwrapEffect2);
|
|
111002
111002
|
});
|
|
111003
111003
|
|
|
@@ -111549,7 +111549,7 @@ var init_ChildProcessWorker = __esm(() => {
|
|
|
111549
111549
|
});
|
|
111550
111550
|
|
|
111551
111551
|
// ../../node_modules/@livestore/utils/dist/node/mod.js
|
|
111552
|
-
import * as
|
|
111552
|
+
import * as http3 from "node:http";
|
|
111553
111553
|
var getFreePort, OtelLiveDummy;
|
|
111554
111554
|
var init_mod11 = __esm(() => {
|
|
111555
111555
|
init_esm5();
|
|
@@ -111560,7 +111560,7 @@ var init_mod11 = __esm(() => {
|
|
|
111560
111560
|
init_ChildProcessRunner();
|
|
111561
111561
|
init_ChildProcessWorker();
|
|
111562
111562
|
getFreePort = exports_Effect.async((cb, signal2) => {
|
|
111563
|
-
const server =
|
|
111563
|
+
const server = http3.createServer();
|
|
111564
111564
|
signal2.addEventListener("abort", () => {
|
|
111565
111565
|
server.close();
|
|
111566
111566
|
});
|
|
@@ -180051,24 +180051,24 @@ function createLogger(level = "info", options4 = {}) {
|
|
|
180051
180051
|
}
|
|
180052
180052
|
}
|
|
180053
180053
|
const warnedMessages = /* @__PURE__ */ new Set;
|
|
180054
|
-
const
|
|
180054
|
+
const logger16 = {
|
|
180055
180055
|
hasWarned: false,
|
|
180056
180056
|
info(msg, opts) {
|
|
180057
180057
|
output2("info", msg, opts);
|
|
180058
180058
|
},
|
|
180059
180059
|
warn(msg, opts) {
|
|
180060
|
-
|
|
180060
|
+
logger16.hasWarned = true;
|
|
180061
180061
|
output2("warn", msg, opts);
|
|
180062
180062
|
},
|
|
180063
180063
|
warnOnce(msg, opts) {
|
|
180064
180064
|
if (warnedMessages.has(msg))
|
|
180065
180065
|
return;
|
|
180066
|
-
|
|
180066
|
+
logger16.hasWarned = true;
|
|
180067
180067
|
output2("warn", msg, opts);
|
|
180068
180068
|
warnedMessages.add(msg);
|
|
180069
180069
|
},
|
|
180070
180070
|
error(msg, opts) {
|
|
180071
|
-
|
|
180071
|
+
logger16.hasWarned = true;
|
|
180072
180072
|
output2("error", msg, opts);
|
|
180073
180073
|
},
|
|
180074
180074
|
clearScreen(type3) {
|
|
@@ -180079,7 +180079,7 @@ function createLogger(level = "info", options4 = {}) {
|
|
|
180079
180079
|
return loggedErrors.has(error42);
|
|
180080
180080
|
}
|
|
180081
180081
|
};
|
|
180082
|
-
return
|
|
180082
|
+
return logger16;
|
|
180083
180083
|
}
|
|
180084
180084
|
function printServerUrls(urls, optionsHost, info2) {
|
|
180085
180085
|
const colorUrl = (url3) => import_picocolors.default.cyan(url3.replace(/:(\d+)\//, (_7, port2) => `:${import_picocolors.default.bold(port2)}/`));
|
|
@@ -187696,8 +187696,8 @@ var SOURCEMAPPING_URL = "sourceMa", isWindows, windowsSlashRE, postfixRE, AsyncF
|
|
|
187696
187696
|
customListenersMap = /* @__PURE__ */ new Map;
|
|
187697
187697
|
ctxToListenersMap = /* @__PURE__ */ new Map;
|
|
187698
187698
|
currentFirstInvalidatedBy;
|
|
187699
|
-
constructor(
|
|
187700
|
-
this.logger =
|
|
187699
|
+
constructor(logger16, transport, importUpdatedModule) {
|
|
187700
|
+
this.logger = logger16, this.transport = transport, this.importUpdatedModule = importUpdatedModule;
|
|
187701
187701
|
}
|
|
187702
187702
|
async notifyListeners(event, data) {
|
|
187703
187703
|
let cbs = this.customListenersMap.get(event);
|
|
@@ -200225,11 +200225,11 @@ Did you specify these with the most recent transformation maps first?`);
|
|
|
200225
200225
|
}
|
|
200226
200226
|
if (flattenedConfigs.some(({ config: { options: { ignore: ignore7, only } } }) => shouldIgnore(context15, ignore7, only, dirname7)))
|
|
200227
200227
|
return null;
|
|
200228
|
-
const chain = emptyChain(),
|
|
200228
|
+
const chain = emptyChain(), logger16 = createLogger2(input2, context15, baseLogger);
|
|
200229
200229
|
for (const { config: config5, index: index3, envName } of flattenedConfigs) {
|
|
200230
200230
|
if (!(yield* mergeExtendsChain(chain, config5.options, dirname7, context15, files, baseLogger)))
|
|
200231
200231
|
return null;
|
|
200232
|
-
|
|
200232
|
+
logger16(config5, index3, envName), yield* mergeChainOpts(chain, config5);
|
|
200233
200233
|
}
|
|
200234
200234
|
return chain;
|
|
200235
200235
|
};
|
|
@@ -250636,13 +250636,13 @@ function getNamesFromAssets(consumedFiles) {
|
|
|
250636
250636
|
names.sort((a11, b10) => a11.length - b10.length || (a11 > b10 ? 1 : a11 === b10 ? 0 : -1));
|
|
250637
250637
|
return { names, originalFileNames };
|
|
250638
250638
|
}
|
|
250639
|
-
function getLogHandler(level, code2,
|
|
250639
|
+
function getLogHandler(level, code2, logger16, pluginName, logLevel2) {
|
|
250640
250640
|
if (logLevelPriority[level] < logLevelPriority[logLevel2]) {
|
|
250641
250641
|
return doNothing;
|
|
250642
250642
|
}
|
|
250643
250643
|
return (log7, pos) => {
|
|
250644
250644
|
if (pos != null) {
|
|
250645
|
-
|
|
250645
|
+
logger16(LOGLEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
250646
250646
|
}
|
|
250647
250647
|
log7 = normalizeLog(log7);
|
|
250648
250648
|
if (log7.code && !log7.pluginCode) {
|
|
@@ -250650,7 +250650,7 @@ function getLogHandler(level, code2, logger14, pluginName, logLevel2) {
|
|
|
250650
250650
|
}
|
|
250651
250651
|
log7.code = code2;
|
|
250652
250652
|
log7.plugin = pluginName;
|
|
250653
|
-
|
|
250653
|
+
logger16(level, log7);
|
|
250654
250654
|
};
|
|
250655
250655
|
}
|
|
250656
250656
|
function getPluginContext(plugin, pluginCache, graph, options4, fileEmitter, existingPluginNames) {
|
|
@@ -251299,7 +251299,7 @@ async function initWasm() {}
|
|
|
251299
251299
|
function getLogger2(plugins, onLog, watchMode, logLevel2) {
|
|
251300
251300
|
plugins = getSortedValidatedPlugins("onLog", plugins);
|
|
251301
251301
|
const minimalPriority = logLevelPriority[logLevel2];
|
|
251302
|
-
const
|
|
251302
|
+
const logger16 = (level, log7, skipped = EMPTY_SET) => {
|
|
251303
251303
|
augmentLogMessage(log7);
|
|
251304
251304
|
const logPriority = logLevelPriority[level];
|
|
251305
251305
|
if (logPriority < minimalPriority) {
|
|
@@ -251313,7 +251313,7 @@ function getLogger2(plugins, onLog, watchMode, logLevel2) {
|
|
|
251313
251313
|
if (logLevelPriority[level2] < minimalPriority) {
|
|
251314
251314
|
return doNothing;
|
|
251315
251315
|
}
|
|
251316
|
-
return (log8) =>
|
|
251316
|
+
return (log8) => logger16(level2, normalizeLog(log8), new Set(skipped).add(plugin));
|
|
251317
251317
|
};
|
|
251318
251318
|
const handler2 = "handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
251319
251319
|
if (handler2.call({
|
|
@@ -251328,7 +251328,7 @@ function getLogger2(plugins, onLog, watchMode, logLevel2) {
|
|
|
251328
251328
|
}
|
|
251329
251329
|
onLog(level, log7);
|
|
251330
251330
|
};
|
|
251331
|
-
return
|
|
251331
|
+
return logger16;
|
|
251332
251332
|
}
|
|
251333
251333
|
async function normalizeInputOptions(config5, watchMode) {
|
|
251334
251334
|
const unsetOptions = new Set;
|
|
@@ -251533,16 +251533,16 @@ async function getInputOptions(initialInputOptions, watchMode) {
|
|
|
251533
251533
|
async function getProcessedInputOptions(inputOptions, watchMode) {
|
|
251534
251534
|
const plugins = getSortedValidatedPlugins("options", await normalizePluginOption(inputOptions.plugins));
|
|
251535
251535
|
const logLevel2 = inputOptions.logLevel || LOGLEVEL_INFO;
|
|
251536
|
-
const
|
|
251536
|
+
const logger16 = getLogger2(plugins, getOnLog(inputOptions, logLevel2), watchMode, logLevel2);
|
|
251537
251537
|
for (const plugin of plugins) {
|
|
251538
251538
|
const { name: name17, options: options4 } = plugin;
|
|
251539
251539
|
const handler2 = "handler" in options4 ? options4.handler : options4;
|
|
251540
251540
|
const processedOptions = await handler2.call({
|
|
251541
|
-
debug: getLogHandler(LOGLEVEL_DEBUG, "PLUGIN_LOG",
|
|
251541
|
+
debug: getLogHandler(LOGLEVEL_DEBUG, "PLUGIN_LOG", logger16, name17, logLevel2),
|
|
251542
251542
|
error: (error_) => error42(logPluginError(normalizeLog(error_), name17, { hook: "onLog" })),
|
|
251543
|
-
info: getLogHandler(LOGLEVEL_INFO, "PLUGIN_LOG",
|
|
251543
|
+
info: getLogHandler(LOGLEVEL_INFO, "PLUGIN_LOG", logger16, name17, logLevel2),
|
|
251544
251544
|
meta: { rollupVersion: version4, watchMode },
|
|
251545
|
-
warn: getLogHandler(LOGLEVEL_WARN, "PLUGIN_WARNING",
|
|
251545
|
+
warn: getLogHandler(LOGLEVEL_WARN, "PLUGIN_WARNING", logger16, name17, logLevel2)
|
|
251546
251546
|
}, inputOptions);
|
|
251547
251547
|
if (processedOptions) {
|
|
251548
251548
|
inputOptions = processedOptions;
|
|
@@ -274709,7 +274709,7 @@ import assert5 from "node:assert";
|
|
|
274709
274709
|
import process$13 from "node:process";
|
|
274710
274710
|
import v82 from "node:v8";
|
|
274711
274711
|
import { EventEmitter } from "node:events";
|
|
274712
|
-
import { STATUS_CODES, createServer as
|
|
274712
|
+
import { STATUS_CODES, createServer as createServer11, get as get34 } from "node:http";
|
|
274713
274713
|
import { createServer as createServer$1, get as get$1 } from "node:https";
|
|
274714
274714
|
import * as qs2 from "node:querystring";
|
|
274715
274715
|
function wrapId(id5) {
|
|
@@ -279727,7 +279727,7 @@ async function computeSourceRoute(map$1, file5) {
|
|
|
279727
279727
|
} catch {}
|
|
279728
279728
|
return sourceRoot;
|
|
279729
279729
|
}
|
|
279730
|
-
async function injectSourcesContent(map$1, file5,
|
|
279730
|
+
async function injectSourcesContent(map$1, file5, logger16) {
|
|
279731
279731
|
let sourceRootPromise;
|
|
279732
279732
|
const missingSources = [];
|
|
279733
279733
|
const sourcesContent = map$1.sourcesContent || [];
|
|
@@ -279750,7 +279750,7 @@ async function injectSourcesContent(map$1, file5, logger14) {
|
|
|
279750
279750
|
await Promise.all(sourcesContentPromises);
|
|
279751
279751
|
map$1.sourcesContent = sourcesContent;
|
|
279752
279752
|
if (missingSources.length) {
|
|
279753
|
-
|
|
279753
|
+
logger16.warnOnce(`Sourcemap for "${file5}" points to missing source files`);
|
|
279754
279754
|
debug$16?.(`Missing sources:
|
|
279755
279755
|
` + missingSources.join(`
|
|
279756
279756
|
`));
|
|
@@ -279774,7 +279774,7 @@ function getCodeWithSourcemap(type3, code2, map$1) {
|
|
|
279774
279774
|
/*# sourceMappingURL=${genSourceMapUrl(map$1)} */`;
|
|
279775
279775
|
return code2;
|
|
279776
279776
|
}
|
|
279777
|
-
function applySourcemapIgnoreList(map$1, sourcemapPath, sourcemapIgnoreList,
|
|
279777
|
+
function applySourcemapIgnoreList(map$1, sourcemapPath, sourcemapIgnoreList, logger16) {
|
|
279778
279778
|
let { x_google_ignoreList } = map$1;
|
|
279779
279779
|
if (x_google_ignoreList === undefined)
|
|
279780
279780
|
x_google_ignoreList = [];
|
|
@@ -279783,8 +279783,8 @@ function applySourcemapIgnoreList(map$1, sourcemapPath, sourcemapIgnoreList, log
|
|
|
279783
279783
|
if (!sourcePath)
|
|
279784
279784
|
continue;
|
|
279785
279785
|
const ignoreList = sourcemapIgnoreList(path16.isAbsolute(sourcePath) ? sourcePath : path16.resolve(path16.dirname(sourcemapPath), sourcePath), sourcemapPath);
|
|
279786
|
-
if (
|
|
279787
|
-
|
|
279786
|
+
if (logger16 && typeof ignoreList !== "boolean")
|
|
279787
|
+
logger16.warn("sourcemapIgnoreList function must return a boolean.");
|
|
279788
279788
|
if (ignoreList && !x_google_ignoreList.includes(sourcesIndex))
|
|
279789
279789
|
x_google_ignoreList.push(sourcesIndex);
|
|
279790
279790
|
}
|
|
@@ -280458,7 +280458,7 @@ function err$1(e$1, pos) {
|
|
|
280458
280458
|
error$1.pos = pos;
|
|
280459
280459
|
return error$1;
|
|
280460
280460
|
}
|
|
280461
|
-
function parseGlobOptions(rawOpts, optsStartIndex,
|
|
280461
|
+
function parseGlobOptions(rawOpts, optsStartIndex, logger16) {
|
|
280462
280462
|
let opts = {};
|
|
280463
280463
|
try {
|
|
280464
280464
|
opts = evalValue(rawOpts);
|
|
@@ -280493,9 +280493,9 @@ function parseGlobOptions(rawOpts, optsStartIndex, logger14) {
|
|
|
280493
280493
|
}
|
|
280494
280494
|
opts.query = stringifyQuery(opts.query);
|
|
280495
280495
|
}
|
|
280496
|
-
if (opts.as &&
|
|
280496
|
+
if (opts.as && logger16) {
|
|
280497
280497
|
const importSuggestion = forceDefaultAs.includes(opts.as) ? `, import: 'default'` : "";
|
|
280498
|
-
|
|
280498
|
+
logger16.warn(import_picocolors$28.default.yellow(`The glob option "as" has been deprecated in favour of "query". Please update \`as: '${opts.as}'\` to \`query: '?${opts.as}'${importSuggestion}\`.`));
|
|
280499
280499
|
}
|
|
280500
280500
|
if (opts.as && forceDefaultAs.includes(opts.as)) {
|
|
280501
280501
|
if (opts.import && opts.import !== "default" && opts.import !== "*")
|
|
@@ -280510,7 +280510,7 @@ function parseGlobOptions(rawOpts, optsStartIndex, logger14) {
|
|
|
280510
280510
|
opts.query = `?${opts.query}`;
|
|
280511
280511
|
return opts;
|
|
280512
280512
|
}
|
|
280513
|
-
async function parseImportGlob(code2, importer, root3, resolveId2,
|
|
280513
|
+
async function parseImportGlob(code2, importer, root3, resolveId2, logger16) {
|
|
280514
280514
|
let cleanCode;
|
|
280515
280515
|
try {
|
|
280516
280516
|
cleanCode = stripLiteral(code2);
|
|
@@ -280563,7 +280563,7 @@ async function parseImportGlob(code2, importer, root3, resolveId2, logger14) {
|
|
|
280563
280563
|
if (arg2) {
|
|
280564
280564
|
if (arg2.type !== "ObjectExpression")
|
|
280565
280565
|
throw err$2(`Expected the second argument to be an object literal, but got "${arg2.type}"`);
|
|
280566
|
-
options$1 = parseGlobOptions(code2.slice(start4 + arg2.start, start4 + arg2.end), start4 + arg2.start,
|
|
280566
|
+
options$1 = parseGlobOptions(code2.slice(start4 + arg2.start, start4 + arg2.end), start4 + arg2.start, logger16);
|
|
280567
280567
|
}
|
|
280568
280568
|
const globsResolved = await Promise.all(globs.map((glob$1) => toAbsoluteGlob(glob$1, root3, importer, resolveId2, options$1.base)));
|
|
280569
280569
|
const isRelative$1 = globs.every((i$1) => ".!".includes(i$1[0]));
|
|
@@ -280606,12 +280606,12 @@ function findCorrespondingCloseParenthesisPosition(cleanCode, openPos) {
|
|
|
280606
280606
|
}
|
|
280607
280607
|
return -1;
|
|
280608
280608
|
}
|
|
280609
|
-
async function transformGlobImport(code2, id5, root3, resolveId2, restoreQueryExtension = false,
|
|
280609
|
+
async function transformGlobImport(code2, id5, root3, resolveId2, restoreQueryExtension = false, logger16) {
|
|
280610
280610
|
id5 = slash2(id5);
|
|
280611
280611
|
root3 = slash2(root3);
|
|
280612
280612
|
const isVirtual = isVirtualModule(id5);
|
|
280613
280613
|
const dir2 = isVirtual ? undefined : dirname$2(id5);
|
|
280614
|
-
const matches$2 = await parseImportGlob(code2, isVirtual ? undefined : id5, root3, resolveId2,
|
|
280614
|
+
const matches$2 = await parseImportGlob(code2, isVirtual ? undefined : id5, root3, resolveId2, logger16);
|
|
280615
280615
|
const matchedFiles = /* @__PURE__ */ new Set;
|
|
280616
280616
|
if (!matches$2.length)
|
|
280617
280617
|
return null;
|
|
@@ -281622,13 +281622,13 @@ async function prepareEsbuildOptimizerRun(environment2, depsInfo, processingCach
|
|
|
281622
281622
|
};
|
|
281623
281623
|
}
|
|
281624
281624
|
async function addManuallyIncludedOptimizeDeps(environment2, deps) {
|
|
281625
|
-
const { logger:
|
|
281625
|
+
const { logger: logger16 } = environment2;
|
|
281626
281626
|
const { optimizeDeps: optimizeDeps$1 } = environment2.config;
|
|
281627
281627
|
const optimizeDepsInclude = optimizeDeps$1.include ?? [];
|
|
281628
281628
|
if (optimizeDepsInclude.length) {
|
|
281629
281629
|
const unableToOptimize = (id5, msg) => {
|
|
281630
281630
|
if (optimizeDepsInclude.includes(id5))
|
|
281631
|
-
|
|
281631
|
+
logger16.warn(`${msg}: ${import_picocolors$26.default.cyan(id5)}, present in ${environment2.name} 'optimizeDeps.include'`);
|
|
281632
281632
|
};
|
|
281633
281633
|
const includes2 = [...optimizeDepsInclude];
|
|
281634
281634
|
for (let i$1 = 0;i$1 < includes2.length; i$1++) {
|
|
@@ -282796,7 +282796,7 @@ async function readFileIfExists(value$1) {
|
|
|
282796
282796
|
return value$1;
|
|
282797
282797
|
}
|
|
282798
282798
|
async function httpServerStart(httpServer, serverOptions) {
|
|
282799
|
-
let { port: port2, strictPort, host, logger:
|
|
282799
|
+
let { port: port2, strictPort, host, logger: logger16 } = serverOptions;
|
|
282800
282800
|
return new Promise((resolve$4, reject3) => {
|
|
282801
282801
|
const onError$1 = (e$1) => {
|
|
282802
282802
|
if (e$1.code === "EADDRINUSE")
|
|
@@ -282804,7 +282804,7 @@ async function httpServerStart(httpServer, serverOptions) {
|
|
|
282804
282804
|
httpServer.removeListener("error", onError$1);
|
|
282805
282805
|
reject3(/* @__PURE__ */ new Error(`Port ${port2} is already in use`));
|
|
282806
282806
|
} else {
|
|
282807
|
-
|
|
282807
|
+
logger16.info(`Port ${port2} is in use, trying another one...`);
|
|
282808
282808
|
httpServer.listen(++port2, host);
|
|
282809
282809
|
}
|
|
282810
282810
|
else {
|
|
@@ -282819,12 +282819,12 @@ async function httpServerStart(httpServer, serverOptions) {
|
|
|
282819
282819
|
});
|
|
282820
282820
|
});
|
|
282821
282821
|
}
|
|
282822
|
-
function setClientErrorHandler(server,
|
|
282822
|
+
function setClientErrorHandler(server, logger16) {
|
|
282823
282823
|
server.on("clientError", (err$2, socket) => {
|
|
282824
282824
|
let msg = "400 Bad Request";
|
|
282825
282825
|
if (err$2.code === "HPE_HEADER_OVERFLOW") {
|
|
282826
282826
|
msg = "431 Request Header Fields Too Large";
|
|
282827
|
-
|
|
282827
|
+
logger16.warn(import_picocolors$21.default.yellow("Server responded with status code 431. See https://vite.dev/guide/troubleshooting.html#_431-request-header-fields-too-large."));
|
|
282828
282828
|
}
|
|
282829
282829
|
if (err$2.code === "ECONNRESET" || !socket.writable)
|
|
282830
282830
|
return;
|
|
@@ -283505,16 +283505,16 @@ function detectPlatformBinary({ [platform4]: platformBinary }, { wsl }) {
|
|
|
283505
283505
|
throw new Error(`${platform4} is not supported`);
|
|
283506
283506
|
return detectArchBinary(platformBinary);
|
|
283507
283507
|
}
|
|
283508
|
-
function openBrowser(url$3, opt,
|
|
283508
|
+
function openBrowser(url$3, opt, logger16) {
|
|
283509
283509
|
const browser2 = typeof opt === "string" ? opt : process.env.BROWSER || "";
|
|
283510
283510
|
if (browser2.toLowerCase().endsWith(".js"))
|
|
283511
|
-
executeNodeScript(browser2, url$3,
|
|
283511
|
+
executeNodeScript(browser2, url$3, logger16);
|
|
283512
283512
|
else if (browser2.toLowerCase() !== "none") {
|
|
283513
283513
|
const browserArgs = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(" ") : [];
|
|
283514
|
-
startBrowserProcess(browser2, browserArgs, url$3,
|
|
283514
|
+
startBrowserProcess(browser2, browserArgs, url$3, logger16);
|
|
283515
283515
|
}
|
|
283516
283516
|
}
|
|
283517
|
-
function executeNodeScript(scriptPath, url$3,
|
|
283517
|
+
function executeNodeScript(scriptPath, url$3, logger16) {
|
|
283518
283518
|
const extraArgs = process.argv.slice(2);
|
|
283519
283519
|
const child = (0, import_cross_spawn.default)(process.execPath, [
|
|
283520
283520
|
scriptPath,
|
|
@@ -283523,13 +283523,13 @@ function executeNodeScript(scriptPath, url$3, logger14) {
|
|
|
283523
283523
|
], { stdio: "inherit" });
|
|
283524
283524
|
child.on("close", (code2) => {
|
|
283525
283525
|
if (code2 !== 0)
|
|
283526
|
-
|
|
283526
|
+
logger16.error(import_picocolors$19.default.red(`
|
|
283527
283527
|
The script specified as BROWSER environment variable failed.
|
|
283528
283528
|
|
|
283529
283529
|
${import_picocolors$19.default.cyan(scriptPath)} exited with code ${code2}.`), { error: null });
|
|
283530
283530
|
});
|
|
283531
283531
|
}
|
|
283532
|
-
async function startBrowserProcess(browser2, browserArgs, url$3,
|
|
283532
|
+
async function startBrowserProcess(browser2, browserArgs, url$3, logger16) {
|
|
283533
283533
|
const preferredOSXBrowser = browser2 === "google chrome" ? "Google Chrome" : browser2;
|
|
283534
283534
|
const shouldTryOpenChromeWithJXA = process.platform === "darwin" && (!preferredOSXBrowser || supportedChromiumBrowsers.includes(preferredOSXBrowser));
|
|
283535
283535
|
if (shouldTryOpenChromeWithJXA)
|
|
@@ -283553,7 +283553,7 @@ async function startBrowserProcess(browser2, browserArgs, url$3, logger14) {
|
|
|
283553
283553
|
subprocess.on("error", reject3);
|
|
283554
283554
|
}).catch(reject3);
|
|
283555
283555
|
}).catch((err$2) => {
|
|
283556
|
-
|
|
283556
|
+
logger16.error(err$2.stack || err$2.message);
|
|
283557
283557
|
});
|
|
283558
283558
|
return true;
|
|
283559
283559
|
} catch {
|
|
@@ -283614,12 +283614,12 @@ function getResolvedOutDirs(root3, outDir, outputOptions) {
|
|
|
283614
283614
|
return new Set([resolvedOutDir]);
|
|
283615
283615
|
return new Set(arraify(outputOptions).map(({ dir: dir2 }) => dir2 ? path16.resolve(root3, dir2) : resolvedOutDir));
|
|
283616
283616
|
}
|
|
283617
|
-
function resolveEmptyOutDir(emptyOutDir, root3, outDirs,
|
|
283617
|
+
function resolveEmptyOutDir(emptyOutDir, root3, outDirs, logger16) {
|
|
283618
283618
|
if (emptyOutDir != null)
|
|
283619
283619
|
return emptyOutDir;
|
|
283620
283620
|
for (const outDir of outDirs)
|
|
283621
283621
|
if (!normalizePath5(outDir).startsWith(withTrailingSlash(root3))) {
|
|
283622
|
-
|
|
283622
|
+
logger16?.warn(import_picocolors$17.default.yellow(`
|
|
283623
283623
|
${import_picocolors$17.default.bold(`(!)`)} outDir ${import_picocolors$17.default.white(import_picocolors$17.default.dim(outDir))} is not inside project root and will not be emptied.
|
|
283624
283624
|
Use --emptyOutDir to override.
|
|
283625
283625
|
`));
|
|
@@ -283811,7 +283811,7 @@ function createWebSocketServer(server, config$2, httpsOptions) {
|
|
|
283811
283811
|
if (httpsOptions)
|
|
283812
283812
|
wsHttpServer = createServer$1(httpsOptions, route2);
|
|
283813
283813
|
else
|
|
283814
|
-
wsHttpServer =
|
|
283814
|
+
wsHttpServer = createServer11(route2);
|
|
283815
283815
|
wsHttpServer.on("upgrade", (req$4, socket, head13) => {
|
|
283816
283816
|
const protocol = req$4.headers["sec-websocket-protocol"];
|
|
283817
283817
|
if (protocol === "vite-ping" && server && !server.listening) {
|
|
@@ -284584,7 +284584,7 @@ async function getCachedTransformResult(environment2, url$3, module$1, timestamp
|
|
|
284584
284584
|
}
|
|
284585
284585
|
}
|
|
284586
284586
|
async function loadAndTransform(environment2, id5, url$3, options$1, timestamp, mod2, resolved) {
|
|
284587
|
-
const { config: config$2, pluginContainer, logger:
|
|
284587
|
+
const { config: config$2, pluginContainer, logger: logger16 } = environment2;
|
|
284588
284588
|
const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url$3, config$2.root) : "";
|
|
284589
284589
|
const moduleGraph = environment2.moduleGraph;
|
|
284590
284590
|
if (options$1.allowId && !options$1.allowId(id5)) {
|
|
@@ -284618,7 +284618,7 @@ async function loadAndTransform(environment2, id5, url$3, options$1, timestamp,
|
|
|
284618
284618
|
map$1 = extracted.map;
|
|
284619
284619
|
}
|
|
284620
284620
|
} catch (e$1) {
|
|
284621
|
-
|
|
284621
|
+
logger16.warn(`Failed to load source map for ${file5}.
|
|
284622
284622
|
${e$1}`, { timestamp: true });
|
|
284623
284623
|
}
|
|
284624
284624
|
} else {
|
|
@@ -284663,9 +284663,9 @@ ${e$1}`, { timestamp: true });
|
|
|
284663
284663
|
normalizedMap = null;
|
|
284664
284664
|
if (normalizedMap && "version" in normalizedMap && mod2.file) {
|
|
284665
284665
|
if (normalizedMap.mappings)
|
|
284666
|
-
await injectSourcesContent(normalizedMap, mod2.file,
|
|
284666
|
+
await injectSourcesContent(normalizedMap, mod2.file, logger16);
|
|
284667
284667
|
const sourcemapPath = `${mod2.file}.map`;
|
|
284668
|
-
applySourcemapIgnoreList(normalizedMap, sourcemapPath, config$2.server.sourcemapIgnoreList,
|
|
284668
|
+
applySourcemapIgnoreList(normalizedMap, sourcemapPath, config$2.server.sourcemapIgnoreList, logger16);
|
|
284669
284669
|
if (path16.isAbsolute(mod2.file)) {
|
|
284670
284670
|
let modDirname;
|
|
284671
284671
|
for (let sourcesIndex = 0;sourcesIndex < normalizedMap.sources.length; ++sourcesIndex) {
|
|
@@ -285521,11 +285521,11 @@ function resolveHtmlTransforms(plugins$1) {
|
|
|
285521
285521
|
function headTagInsertCheck(tags3, ctx) {
|
|
285522
285522
|
if (!tags3.length)
|
|
285523
285523
|
return;
|
|
285524
|
-
const { logger:
|
|
285524
|
+
const { logger: logger16 } = ctx.server?.config || {};
|
|
285525
285525
|
const disallowedTags = tags3.filter((tagDescriptor) => !elementsAllowedInHead.has(tagDescriptor.tag));
|
|
285526
285526
|
if (disallowedTags.length) {
|
|
285527
285527
|
const dedupedTags = unique(disallowedTags.map((tagDescriptor) => `<${tagDescriptor.tag}>`));
|
|
285528
|
-
|
|
285528
|
+
logger16?.warn(import_picocolors$13.default.yellow(import_picocolors$13.default.bold(`[${dedupedTags.join(",")}] can not be used inside the <head> Element, please check the 'injectTo' value`)));
|
|
285529
285529
|
}
|
|
285530
285530
|
}
|
|
285531
285531
|
async function applyHtmlTransforms(html4, hooks, pluginContext, ctx) {
|
|
@@ -286531,7 +286531,7 @@ function createServerCloseFn(server) {
|
|
|
286531
286531
|
function resolvedAllowDir(root3, dir2) {
|
|
286532
286532
|
return normalizePath5(path16.resolve(root3, dir2));
|
|
286533
286533
|
}
|
|
286534
|
-
function resolveServerOptions(root3, raw4,
|
|
286534
|
+
function resolveServerOptions(root3, raw4, logger16) {
|
|
286535
286535
|
const _server = mergeWithDefaults({
|
|
286536
286536
|
...serverConfigDefaults,
|
|
286537
286537
|
host: undefined,
|
|
@@ -286553,7 +286553,7 @@ function resolveServerOptions(root3, raw4, logger14) {
|
|
|
286553
286553
|
const yarnCacheDir = execSync2(`yarn config get ${enableGlobalCache ? "globalFolder" : "cacheFolder"}`, { cwd: cwd2 }).toString().trim();
|
|
286554
286554
|
allowDirs.push(yarnCacheDir);
|
|
286555
286555
|
} catch (e$1) {
|
|
286556
|
-
|
|
286556
|
+
logger16.warn(`Get yarn cache dir error: ${e$1.message}`, { timestamp: true });
|
|
286557
286557
|
}
|
|
286558
286558
|
}
|
|
286559
286559
|
allowDirs = allowDirs.map((i$1) => resolvedAllowDir(root3, i$1));
|
|
@@ -286563,7 +286563,7 @@ function resolveServerOptions(root3, raw4, logger14) {
|
|
|
286563
286563
|
server.fs.allow = allowDirs;
|
|
286564
286564
|
if (server.origin?.endsWith("/")) {
|
|
286565
286565
|
server.origin = server.origin.slice(0, -1);
|
|
286566
|
-
|
|
286566
|
+
logger16.warn(import_picocolors$11.default.yellow(`${import_picocolors$11.default.bold("(!)")} server.origin should not end with "/". Using "${server.origin}" instead.`));
|
|
286567
286567
|
}
|
|
286568
286568
|
if (process.env.__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS && Array.isArray(server.allowedHosts)) {
|
|
286569
286569
|
const additionalHost = process.env.__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS;
|
|
@@ -286598,12 +286598,12 @@ async function restartServer(server) {
|
|
|
286598
286598
|
server.middlewares = middlewares;
|
|
286599
286599
|
newServer._setInternalServer(server);
|
|
286600
286600
|
}
|
|
286601
|
-
const { logger:
|
|
286601
|
+
const { logger: logger16, server: { port: port2, middlewareMode } } = server.config;
|
|
286602
286602
|
if (!middlewareMode)
|
|
286603
286603
|
await server.listen(port2, true);
|
|
286604
286604
|
else
|
|
286605
286605
|
await Promise.all(Object.values(server.environments).map((e$1) => e$1.listen(server)));
|
|
286606
|
-
|
|
286606
|
+
logger16.info("server restarted.", { timestamp: true });
|
|
286607
286607
|
if (shortcutsOptions) {
|
|
286608
286608
|
shortcutsOptions.print = false;
|
|
286609
286609
|
bindCLIShortcuts(server, shortcutsOptions);
|
|
@@ -286617,9 +286617,9 @@ async function restartServerWithUrls(server) {
|
|
|
286617
286617
|
const { port: prevPort, host: prevHost } = server.config.server;
|
|
286618
286618
|
const prevUrls = server.resolvedUrls;
|
|
286619
286619
|
await server.restart();
|
|
286620
|
-
const { logger:
|
|
286620
|
+
const { logger: logger16, server: { port: port2, host } } = server.config;
|
|
286621
286621
|
if ((port2 ?? DEFAULT_DEV_PORT) !== (prevPort ?? DEFAULT_DEV_PORT) || host !== prevHost || diffDnsOrderChange(prevUrls, server.resolvedUrls)) {
|
|
286622
|
-
|
|
286622
|
+
logger16.info("");
|
|
286623
286623
|
server.printUrls();
|
|
286624
286624
|
}
|
|
286625
286625
|
}
|
|
@@ -289554,7 +289554,7 @@ async function transformSugarSS(environment2, id5, code2) {
|
|
|
289554
289554
|
const result2 = await runPostCSS(id5, code2, [], { parser: loadSss(config$2.root) }, undefined, environment2.logger, devSourcemap);
|
|
289555
289555
|
return result2;
|
|
289556
289556
|
}
|
|
289557
|
-
async function runPostCSS(id5, code2, plugins$1, options$1, deps,
|
|
289557
|
+
async function runPostCSS(id5, code2, plugins$1, options$1, deps, logger16, enableSourcemap) {
|
|
289558
289558
|
let postcssResult;
|
|
289559
289559
|
try {
|
|
289560
289560
|
const source = removeDirectQuery(id5);
|
|
@@ -289593,7 +289593,7 @@ ${generateCodeFrame(code2, {
|
|
|
289593
289593
|
line: warning2.endLine,
|
|
289594
289594
|
column: warning2.endColumn - 1
|
|
289595
289595
|
} : undefined)}`;
|
|
289596
|
-
|
|
289596
|
+
logger16.warn(import_picocolors$6.default.yellow(msg));
|
|
289597
289597
|
}
|
|
289598
289598
|
} catch (e$1) {
|
|
289599
289599
|
e$1.message = `[postcss] ${e$1.message}`;
|
|
@@ -290699,12 +290699,12 @@ function areSeparateFolders(a11, b10) {
|
|
|
290699
290699
|
const nb = normalizePath5(b10);
|
|
290700
290700
|
return na2 !== nb && !na2.startsWith(withTrailingSlash(nb)) && !nb.startsWith(withTrailingSlash(na2));
|
|
290701
290701
|
}
|
|
290702
|
-
function resolveBuildEnvironmentOptions(raw4,
|
|
290702
|
+
function resolveBuildEnvironmentOptions(raw4, logger16, consumer) {
|
|
290703
290703
|
const deprecatedPolyfillModulePreload = raw4.polyfillModulePreload;
|
|
290704
290704
|
const { polyfillModulePreload, ...rest } = raw4;
|
|
290705
290705
|
raw4 = rest;
|
|
290706
290706
|
if (deprecatedPolyfillModulePreload !== undefined)
|
|
290707
|
-
|
|
290707
|
+
logger16.warn("polyfillModulePreload is deprecated. Use modulePreload.polyfill instead.");
|
|
290708
290708
|
if (deprecatedPolyfillModulePreload === false && raw4.modulePreload === undefined)
|
|
290709
290709
|
raw4.modulePreload = { polyfill: false };
|
|
290710
290710
|
const merged = mergeWithDefaults({
|
|
@@ -290766,7 +290766,7 @@ function resolveConfigToBuild(inlineConfig = {}, patchConfig, patchPlugins) {
|
|
|
290766
290766
|
function resolveRollupOptions(environment2) {
|
|
290767
290767
|
const { root: root3, packageCache, build: options$1 } = environment2.config;
|
|
290768
290768
|
const libOptions = options$1.lib;
|
|
290769
|
-
const { logger:
|
|
290769
|
+
const { logger: logger16 } = environment2;
|
|
290770
290770
|
const ssr = environment2.config.consumer === "server";
|
|
290771
290771
|
const resolve$4 = (p13) => path16.resolve(root3, p13);
|
|
290772
290772
|
const input2 = libOptions ? options$1.rollupOptions.input || (typeof libOptions.entry === "string" ? resolve$4(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve$4) : Object.fromEntries(Object.entries(libOptions.entry).map(([alias$2, file5]) => [alias$2, resolve$4(file5)]))) : typeof options$1.ssr === "string" ? resolve$4(options$1.ssr) : options$1.rollupOptions.input || resolve$4("index.html");
|
|
@@ -290794,11 +290794,11 @@ function resolveRollupOptions(environment2) {
|
|
|
290794
290794
|
const isSsrTargetWebworkerEnvironment = environment2.name === "ssr" && environment2.getTopLevelConfig().ssr?.target === "webworker";
|
|
290795
290795
|
const buildOutputOptions = (output2 = {}) => {
|
|
290796
290796
|
if (output2.output)
|
|
290797
|
-
|
|
290797
|
+
logger16.warn(`You've set "rollupOptions.output.output" in your config. This is deprecated and will override all Vite.js default output options. Please use "rollupOptions.output" instead.`);
|
|
290798
290798
|
if (output2.file)
|
|
290799
290799
|
throw new Error('Vite does not support "rollupOptions.output.file". Please use "rollupOptions.output.dir" and "rollupOptions.output.entryFileNames" instead.');
|
|
290800
290800
|
if (output2.sourcemap)
|
|
290801
|
-
|
|
290801
|
+
logger16.warnOnce(import_picocolors$4.default.yellow('Vite does not support "rollupOptions.output.sourcemap". Please use "build.sourcemap" instead.'));
|
|
290802
290802
|
const format$3 = output2.format || "es";
|
|
290803
290803
|
const jsExt = ssr && !isSsrTargetWebworkerEnvironment || libOptions ? resolveOutputJsExtension(format$3, findNearestPackageData(root3, packageCache)?.data.type) : "js";
|
|
290804
290804
|
return {
|
|
@@ -290816,7 +290816,7 @@ function resolveRollupOptions(environment2) {
|
|
|
290816
290816
|
...output2
|
|
290817
290817
|
};
|
|
290818
290818
|
};
|
|
290819
|
-
const outputs = resolveBuildOutputs(options$1.rollupOptions.output, libOptions,
|
|
290819
|
+
const outputs = resolveBuildOutputs(options$1.rollupOptions.output, libOptions, logger16);
|
|
290820
290820
|
if (Array.isArray(outputs))
|
|
290821
290821
|
rollupOptions.output = outputs.map(buildOutputOptions);
|
|
290822
290822
|
else
|
|
@@ -290824,19 +290824,19 @@ function resolveRollupOptions(environment2) {
|
|
|
290824
290824
|
return rollupOptions;
|
|
290825
290825
|
}
|
|
290826
290826
|
async function buildEnvironment(environment2) {
|
|
290827
|
-
const { logger:
|
|
290827
|
+
const { logger: logger16, config: config$2 } = environment2;
|
|
290828
290828
|
const { root: root3, build: options$1 } = config$2;
|
|
290829
290829
|
const ssr = config$2.consumer === "server";
|
|
290830
|
-
|
|
290830
|
+
logger16.info(import_picocolors$4.default.cyan(`vite v${VERSION} ${import_picocolors$4.default.green(`building ${ssr ? `SSR bundle ` : ``}for ${environment2.config.mode}...`)}`));
|
|
290831
290831
|
let bundle;
|
|
290832
290832
|
let startTime;
|
|
290833
290833
|
try {
|
|
290834
290834
|
const rollupOptions = resolveRollupOptions(environment2);
|
|
290835
290835
|
if (options$1.watch) {
|
|
290836
|
-
|
|
290836
|
+
logger16.info(import_picocolors$4.default.cyan(`
|
|
290837
290837
|
watching for file changes...`));
|
|
290838
290838
|
const resolvedOutDirs = getResolvedOutDirs(root3, options$1.outDir, options$1.rollupOptions.output);
|
|
290839
|
-
const emptyOutDir = resolveEmptyOutDir(options$1.emptyOutDir, root3, resolvedOutDirs,
|
|
290839
|
+
const emptyOutDir = resolveEmptyOutDir(options$1.emptyOutDir, root3, resolvedOutDirs, logger16);
|
|
290840
290840
|
const resolvedChokidarOptions = resolveChokidarOptions({
|
|
290841
290841
|
...(rollupOptions.watch || {}).chokidar,
|
|
290842
290842
|
...options$1.watch.chokidar
|
|
@@ -290852,16 +290852,16 @@ watching for file changes...`));
|
|
|
290852
290852
|
});
|
|
290853
290853
|
watcher.on("event", (event) => {
|
|
290854
290854
|
if (event.code === "BUNDLE_START")
|
|
290855
|
-
|
|
290855
|
+
logger16.info(import_picocolors$4.default.cyan(`
|
|
290856
290856
|
build started...`));
|
|
290857
290857
|
else if (event.code === "BUNDLE_END") {
|
|
290858
290858
|
event.result.close();
|
|
290859
|
-
|
|
290859
|
+
logger16.info(import_picocolors$4.default.cyan(`built in ${event.duration}ms.`));
|
|
290860
290860
|
} else if (event.code === "ERROR") {
|
|
290861
290861
|
const e$1 = event.error;
|
|
290862
290862
|
enhanceRollupError(e$1);
|
|
290863
290863
|
clearLine();
|
|
290864
|
-
|
|
290864
|
+
logger16.error(e$1.message, { error: e$1 });
|
|
290865
290865
|
}
|
|
290866
290866
|
});
|
|
290867
290867
|
return watcher;
|
|
@@ -290872,13 +290872,13 @@ build started...`));
|
|
|
290872
290872
|
const res = [];
|
|
290873
290873
|
for (const output2 of arraify(rollupOptions.output))
|
|
290874
290874
|
res.push(await bundle[options$1.write ? "write" : "generate"](output2));
|
|
290875
|
-
|
|
290875
|
+
logger16.info(`${import_picocolors$4.default.green(`✓ built in ${displayTime(Date.now() - startTime)}`)}`);
|
|
290876
290876
|
return Array.isArray(rollupOptions.output) ? res : res[0];
|
|
290877
290877
|
} catch (e$1) {
|
|
290878
290878
|
enhanceRollupError(e$1);
|
|
290879
290879
|
clearLine();
|
|
290880
290880
|
if (startTime) {
|
|
290881
|
-
|
|
290881
|
+
logger16.error(`${import_picocolors$4.default.red("✗")} Build failed in ${displayTime(Date.now() - startTime)}`);
|
|
290882
290882
|
startTime = undefined;
|
|
290883
290883
|
}
|
|
290884
290884
|
throw e$1;
|
|
@@ -290938,7 +290938,7 @@ function resolveLibFilename(libOptions, format$3, entryName, root3, extension$1,
|
|
|
290938
290938
|
return `${name17}.${extension$1}`;
|
|
290939
290939
|
return `${name17}.${format$3}.${extension$1}`;
|
|
290940
290940
|
}
|
|
290941
|
-
function resolveBuildOutputs(outputs, libOptions,
|
|
290941
|
+
function resolveBuildOutputs(outputs, libOptions, logger16) {
|
|
290942
290942
|
if (libOptions) {
|
|
290943
290943
|
const libHasMultipleEntries = typeof libOptions.entry !== "string" && Object.values(libOptions.entry).length > 1;
|
|
290944
290944
|
const libFormats = libOptions.formats || (libHasMultipleEntries ? ["es", "cjs"] : ["es", "umd"]);
|
|
@@ -290955,7 +290955,7 @@ function resolveBuildOutputs(outputs, libOptions, logger14) {
|
|
|
290955
290955
|
}));
|
|
290956
290956
|
}
|
|
290957
290957
|
if (libOptions.formats)
|
|
290958
|
-
|
|
290958
|
+
logger16.warn(import_picocolors$4.default.yellow('"build.lib.formats" will be ignored because "build.rollupOptions.output" is already an array format.'));
|
|
290959
290959
|
outputs.forEach((output2) => {
|
|
290960
290960
|
if ((output2.format === "umd" || output2.format === "iife") && !output2.name)
|
|
290961
290961
|
throw new Error('Entries in "build.rollupOptions.output" must specify "name" when the format is "umd" or "iife".');
|
|
@@ -291373,7 +291373,7 @@ ${MODULE_RUNNER_SOURCEMAPPING_SOURCE}
|
|
|
291373
291373
|
return result2;
|
|
291374
291374
|
}
|
|
291375
291375
|
function createDepsOptimizer(environment2) {
|
|
291376
|
-
const { logger:
|
|
291376
|
+
const { logger: logger16 } = environment2;
|
|
291377
291377
|
const sessionTimestamp = Date.now().toString();
|
|
291378
291378
|
let debounceProcessingHandle;
|
|
291379
291379
|
let closed = false;
|
|
@@ -291396,14 +291396,14 @@ function createDepsOptimizer(environment2) {
|
|
|
291396
291396
|
let newDepsToLogHandle;
|
|
291397
291397
|
const logNewlyDiscoveredDeps = () => {
|
|
291398
291398
|
if (newDepsToLog.length) {
|
|
291399
|
-
|
|
291399
|
+
logger16.info(import_picocolors$3.default.green(`✨ new dependencies optimized: ${depsLogString(newDepsToLog)}`), { timestamp: true });
|
|
291400
291400
|
newDepsToLog = [];
|
|
291401
291401
|
}
|
|
291402
291402
|
};
|
|
291403
291403
|
let discoveredDepsWhileScanning = [];
|
|
291404
291404
|
const logDiscoveredDepsWhileScanning = () => {
|
|
291405
291405
|
if (discoveredDepsWhileScanning.length) {
|
|
291406
|
-
|
|
291406
|
+
logger16.info(import_picocolors$3.default.green(`✨ discovered while scanning: ${depsLogString(discoveredDepsWhileScanning)}`), { timestamp: true });
|
|
291407
291407
|
discoveredDepsWhileScanning = [];
|
|
291408
291408
|
}
|
|
291409
291409
|
};
|
|
@@ -291483,7 +291483,7 @@ function createDepsOptimizer(environment2) {
|
|
|
291483
291483
|
runOptimizer(result2);
|
|
291484
291484
|
});
|
|
291485
291485
|
} catch (e$1) {
|
|
291486
|
-
|
|
291486
|
+
logger16.error(e$1.stack || e$1.message);
|
|
291487
291487
|
} finally {
|
|
291488
291488
|
resolve$4();
|
|
291489
291489
|
depsOptimizer.scanProcessing = undefined;
|
|
@@ -291580,7 +291580,7 @@ function createDepsOptimizer(environment2) {
|
|
|
291580
291580
|
logNewlyDiscoveredDeps();
|
|
291581
291581
|
if (warnAboutMissedDependencies) {
|
|
291582
291582
|
logDiscoveredDepsWhileScanning();
|
|
291583
|
-
|
|
291583
|
+
logger16.info(import_picocolors$3.default.magenta(`❗ add these dependencies to optimizeDeps.include to speed up cold start`), { timestamp: true });
|
|
291584
291584
|
warnAboutMissedDependencies = false;
|
|
291585
291585
|
}
|
|
291586
291586
|
}, 2 * debounceMs);
|
|
@@ -291598,17 +291598,17 @@ function createDepsOptimizer(environment2) {
|
|
|
291598
291598
|
logNewlyDiscoveredDeps();
|
|
291599
291599
|
if (warnAboutMissedDependencies) {
|
|
291600
291600
|
logDiscoveredDepsWhileScanning();
|
|
291601
|
-
|
|
291601
|
+
logger16.info(import_picocolors$3.default.magenta(`❗ add these dependencies to optimizeDeps.include to avoid a full page reload during cold start`), { timestamp: true });
|
|
291602
291602
|
warnAboutMissedDependencies = false;
|
|
291603
291603
|
}
|
|
291604
291604
|
}
|
|
291605
|
-
|
|
291605
|
+
logger16.info(import_picocolors$3.default.green(`✨ optimized dependencies changed. reloading`), { timestamp: true });
|
|
291606
291606
|
if (needsInteropMismatch.length > 0)
|
|
291607
|
-
|
|
291607
|
+
logger16.warn(`Mixed ESM and CJS detected in ${import_picocolors$3.default.yellow(needsInteropMismatch.join(", "))}, add ${needsInteropMismatch.length === 1 ? "it" : "them"} to optimizeDeps.needsInterop to speed up cold start`, { timestamp: true });
|
|
291608
291608
|
fullReload();
|
|
291609
291609
|
}
|
|
291610
291610
|
} catch (e$1) {
|
|
291611
|
-
|
|
291611
|
+
logger16.error(import_picocolors$3.default.red(`error while updating dependencies:
|
|
291612
291612
|
${e$1.stack}`), {
|
|
291613
291613
|
timestamp: true,
|
|
291614
291614
|
error: e$1
|
|
@@ -291968,7 +291968,7 @@ function resolveDevEnvironmentOptions(dev, environmentName, consumer, preTransfo
|
|
|
291968
291968
|
sourcemapIgnoreList: resolved.sourcemapIgnoreList === false ? () => false : resolved.sourcemapIgnoreList
|
|
291969
291969
|
};
|
|
291970
291970
|
}
|
|
291971
|
-
function resolveEnvironmentOptions(options$1, alias$2, preserveSymlinks, forceOptimizeDeps,
|
|
291971
|
+
function resolveEnvironmentOptions(options$1, alias$2, preserveSymlinks, forceOptimizeDeps, logger16, environmentName, isSsrTargetWebworkerSet, preTransformRequests) {
|
|
291972
291972
|
const isClientEnvironment = environmentName === "client";
|
|
291973
291973
|
const consumer = options$1.consumer ?? (isClientEnvironment ? "client" : "server");
|
|
291974
291974
|
const isSsrTargetWebworkerEnvironment = isSsrTargetWebworkerSet && environmentName === "ssr";
|
|
@@ -291977,10 +291977,10 @@ function resolveEnvironmentOptions(options$1, alias$2, preserveSymlinks, forceOp
|
|
|
291977
291977
|
if (typeof processEnvDefine === "object") {
|
|
291978
291978
|
const pathKey$1 = Object.entries(processEnvDefine).find(([key2, value$1]) => key2.toLowerCase() === "path" && !!value$1)?.[0];
|
|
291979
291979
|
if (pathKey$1)
|
|
291980
|
-
|
|
291980
|
+
logger16.warnOnce(import_picocolors2.default.yellow(`The \`define\` option contains an object with ${JSON.stringify(pathKey$1)} for "process.env" key. It looks like you may have passed the entire \`process.env\` object to \`define\`, which can unintentionally expose all environment variables. This poses a security risk and is discouraged.`));
|
|
291981
291981
|
}
|
|
291982
291982
|
}
|
|
291983
|
-
const resolve$4 = resolveEnvironmentResolveOptions(options$1.resolve, alias$2, preserveSymlinks,
|
|
291983
|
+
const resolve$4 = resolveEnvironmentResolveOptions(options$1.resolve, alias$2, preserveSymlinks, logger16, consumer, isSsrTargetWebworkerEnvironment);
|
|
291984
291984
|
return {
|
|
291985
291985
|
define: options$1.define,
|
|
291986
291986
|
resolve: resolve$4,
|
|
@@ -291988,7 +291988,7 @@ function resolveEnvironmentOptions(options$1, alias$2, preserveSymlinks, forceOp
|
|
|
291988
291988
|
consumer,
|
|
291989
291989
|
optimizeDeps: resolveDepOptimizationOptions(options$1.optimizeDeps, resolve$4.preserveSymlinks, forceOptimizeDeps, consumer),
|
|
291990
291990
|
dev: resolveDevEnvironmentOptions(options$1.dev, environmentName, consumer, preTransformRequests),
|
|
291991
|
-
build: resolveBuildEnvironmentOptions(options$1.build ?? {},
|
|
291991
|
+
build: resolveBuildEnvironmentOptions(options$1.build ?? {}, logger16, consumer),
|
|
291992
291992
|
plugins: undefined
|
|
291993
291993
|
};
|
|
291994
291994
|
}
|
|
@@ -292004,7 +292004,7 @@ function getDefaultEnvironmentOptions(config$2) {
|
|
|
292004
292004
|
build: config$2.build
|
|
292005
292005
|
};
|
|
292006
292006
|
}
|
|
292007
|
-
function checkBadCharactersInPath(name17, path$13,
|
|
292007
|
+
function checkBadCharactersInPath(name17, path$13, logger16) {
|
|
292008
292008
|
const badChars = [];
|
|
292009
292009
|
if (path$13.includes("#"))
|
|
292010
292010
|
badChars.push("#");
|
|
@@ -292015,10 +292015,10 @@ function checkBadCharactersInPath(name17, path$13, logger14) {
|
|
|
292015
292015
|
if (badChars.length > 0) {
|
|
292016
292016
|
const charString = badChars.map((c10) => `"${c10}"`).join(" and ");
|
|
292017
292017
|
const inflectedChars = badChars.length > 1 ? "characters" : "character";
|
|
292018
|
-
|
|
292018
|
+
logger16.warn(import_picocolors2.default.yellow(`${name17} contains the ${charString} ${inflectedChars} (${import_picocolors2.default.cyan(path$13)}), which may not work when running Vite. Consider renaming the directory / file to remove the characters.`));
|
|
292019
292019
|
}
|
|
292020
292020
|
}
|
|
292021
|
-
function resolveEnvironmentResolveOptions(resolve$4, alias$2, preserveSymlinks,
|
|
292021
|
+
function resolveEnvironmentResolveOptions(resolve$4, alias$2, preserveSymlinks, logger16, consumer, isSsrTargetWebworkerEnvironment) {
|
|
292022
292022
|
const resolvedResolve = mergeWithDefaults({
|
|
292023
292023
|
...configDefaults.resolve,
|
|
292024
292024
|
mainFields: consumer === undefined || consumer === "client" || isSsrTargetWebworkerEnvironment ? DEFAULT_CLIENT_MAIN_FIELDS : DEFAULT_SERVER_MAIN_FIELDS,
|
|
@@ -292028,15 +292028,15 @@ function resolveEnvironmentResolveOptions(resolve$4, alias$2, preserveSymlinks,
|
|
|
292028
292028
|
resolvedResolve.preserveSymlinks = preserveSymlinks;
|
|
292029
292029
|
resolvedResolve.alias = alias$2;
|
|
292030
292030
|
if (resolve$4?.browserField === false && resolvedResolve.mainFields.includes("browser"))
|
|
292031
|
-
|
|
292031
|
+
logger16.warn(import_picocolors2.default.yellow("`resolve.browserField` is set to false, but the option is removed in favour of the 'browser' string in `resolve.mainFields`. You may want to update `resolve.mainFields` to remove the 'browser' string and preserve the previous browser behaviour."));
|
|
292032
292032
|
return resolvedResolve;
|
|
292033
292033
|
}
|
|
292034
|
-
function resolveResolveOptions(resolve$4,
|
|
292034
|
+
function resolveResolveOptions(resolve$4, logger16) {
|
|
292035
292035
|
const alias$2 = normalizeAlias(mergeAlias(clientAlias, resolve$4?.alias || configDefaults.resolve.alias));
|
|
292036
292036
|
const preserveSymlinks = resolve$4?.preserveSymlinks ?? configDefaults.resolve.preserveSymlinks;
|
|
292037
292037
|
if (alias$2.some((a11) => a11.find === "/"))
|
|
292038
|
-
|
|
292039
|
-
return resolveEnvironmentResolveOptions(resolve$4, alias$2, preserveSymlinks,
|
|
292038
|
+
logger16.warn(import_picocolors2.default.yellow("`resolve.alias` contains an alias that maps `/`. This is not recommended as it can cause unexpected behavior when resolving paths."));
|
|
292039
|
+
return resolveEnvironmentResolveOptions(resolve$4, alias$2, preserveSymlinks, logger16, undefined);
|
|
292040
292040
|
}
|
|
292041
292041
|
function resolveDepOptimizationOptions(optimizeDeps$1, preserveSymlinks, forceOptimizeDeps, consumer) {
|
|
292042
292042
|
return mergeWithDefaults({
|
|
@@ -292108,12 +292108,12 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
|
292108
292108
|
client: {},
|
|
292109
292109
|
...config$2.environments
|
|
292110
292110
|
};
|
|
292111
|
-
const
|
|
292111
|
+
const logger16 = createLogger(config$2.logLevel, {
|
|
292112
292112
|
allowClearScreen: config$2.clearScreen,
|
|
292113
292113
|
customLogger: config$2.customLogger
|
|
292114
292114
|
});
|
|
292115
292115
|
const resolvedRoot = normalizePath5(config$2.root ? path16.resolve(config$2.root) : process.cwd());
|
|
292116
|
-
checkBadCharactersInPath("The project root", resolvedRoot,
|
|
292116
|
+
checkBadCharactersInPath("The project root", resolvedRoot, logger16);
|
|
292117
292117
|
const configEnvironmentsClient = config$2.environments.client;
|
|
292118
292118
|
configEnvironmentsClient.dev ??= {};
|
|
292119
292119
|
const deprecatedSsrOptimizeDepsConfig = config$2.ssr?.optimizeDeps ?? {};
|
|
@@ -292163,17 +292163,17 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
|
292163
292163
|
};
|
|
292164
292164
|
for (const name17 of Object.keys(config$2.environments))
|
|
292165
292165
|
config$2.environments[name17] = mergeConfig(name17 === "client" ? defaultClientEnvironmentOptions : defaultNonClientEnvironmentOptions, config$2.environments[name17]);
|
|
292166
|
-
await runConfigEnvironmentHook(config$2.environments, userPlugins,
|
|
292166
|
+
await runConfigEnvironmentHook(config$2.environments, userPlugins, logger16, configEnv, config$2.ssr?.target === "webworker");
|
|
292167
292167
|
config$2.resolve ??= {};
|
|
292168
292168
|
config$2.resolve.conditions = config$2.environments.client.resolve?.conditions;
|
|
292169
292169
|
config$2.resolve.mainFields = config$2.environments.client.resolve?.mainFields;
|
|
292170
|
-
const resolvedDefaultResolve = resolveResolveOptions(config$2.resolve,
|
|
292170
|
+
const resolvedDefaultResolve = resolveResolveOptions(config$2.resolve, logger16);
|
|
292171
292171
|
const resolvedEnvironments = {};
|
|
292172
292172
|
for (const environmentName of Object.keys(config$2.environments))
|
|
292173
|
-
resolvedEnvironments[environmentName] = resolveEnvironmentOptions(config$2.environments[environmentName], resolvedDefaultResolve.alias, resolvedDefaultResolve.preserveSymlinks, inlineConfig.forceOptimizeDeps,
|
|
292173
|
+
resolvedEnvironments[environmentName] = resolveEnvironmentOptions(config$2.environments[environmentName], resolvedDefaultResolve.alias, resolvedDefaultResolve.preserveSymlinks, inlineConfig.forceOptimizeDeps, logger16, environmentName, config$2.ssr?.target === "webworker", config$2.server?.preTransformRequests);
|
|
292174
292174
|
const backwardCompatibleOptimizeDeps = resolvedEnvironments.client.optimizeDeps;
|
|
292175
292175
|
const resolvedDevEnvironmentOptions = resolveDevEnvironmentOptions(config$2.dev, undefined, undefined);
|
|
292176
|
-
const resolvedBuildOptions = resolveBuildEnvironmentOptions(config$2.build ?? {},
|
|
292176
|
+
const resolvedBuildOptions = resolveBuildEnvironmentOptions(config$2.build ?? {}, logger16, undefined);
|
|
292177
292177
|
const patchedConfigSsr = {
|
|
292178
292178
|
...config$2.ssr,
|
|
292179
292179
|
external: resolvedEnvironments.ssr?.resolve.external,
|
|
@@ -292195,27 +292195,27 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
|
292195
292195
|
if (userNodeEnv === "development")
|
|
292196
292196
|
process.env.NODE_ENV = "development";
|
|
292197
292197
|
else
|
|
292198
|
-
|
|
292198
|
+
logger16.warn(`NODE_ENV=${userNodeEnv} is not supported in the .env file. Only NODE_ENV=development is supported to create a development build of your project. If you need to set process.env.NODE_ENV, you can set it in the Vite config instead.`);
|
|
292199
292199
|
const isProduction = false;
|
|
292200
292200
|
const relativeBaseShortcut = config$2.base === "" || config$2.base === "./";
|
|
292201
|
-
const resolvedBase = relativeBaseShortcut ? !isBuild || config$2.build?.ssr ? "/" : "./" : resolveBaseUrl(config$2.base, isBuild,
|
|
292201
|
+
const resolvedBase = relativeBaseShortcut ? !isBuild || config$2.build?.ssr ? "/" : "./" : resolveBaseUrl(config$2.base, isBuild, logger16);
|
|
292202
292202
|
const pkgDir = findNearestPackageData(resolvedRoot, packageCache)?.dir;
|
|
292203
292203
|
const cacheDir = normalizePath5(config$2.cacheDir ? path16.resolve(resolvedRoot, config$2.cacheDir) : pkgDir ? path16.join(pkgDir, `node_modules/.vite`) : path16.join(resolvedRoot, `.vite`));
|
|
292204
292204
|
const assetsFilter = config$2.assetsInclude && (!Array.isArray(config$2.assetsInclude) || config$2.assetsInclude.length) ? createFilter3(config$2.assetsInclude) : () => false;
|
|
292205
292205
|
const { publicDir } = config$2;
|
|
292206
292206
|
const resolvedPublicDir = publicDir !== false && publicDir !== "" ? normalizePath5(path16.resolve(resolvedRoot, typeof publicDir === "string" ? publicDir : configDefaults.publicDir)) : "";
|
|
292207
|
-
const server = resolveServerOptions(resolvedRoot, config$2.server,
|
|
292207
|
+
const server = resolveServerOptions(resolvedRoot, config$2.server, logger16);
|
|
292208
292208
|
const builder = resolveBuilderOptions(config$2.builder);
|
|
292209
292209
|
const BASE_URL = resolvedBase;
|
|
292210
292210
|
const resolvedConfigContext = new BasicMinimalPluginContext({
|
|
292211
292211
|
...basePluginContextMeta,
|
|
292212
292212
|
watchMode: command === "serve" && !isPreview || command === "build" && !!resolvedBuildOptions.watch
|
|
292213
|
-
},
|
|
292213
|
+
}, logger16);
|
|
292214
292214
|
let resolved;
|
|
292215
292215
|
let createUserWorkerPlugins = config$2.worker?.plugins;
|
|
292216
292216
|
if (Array.isArray(createUserWorkerPlugins)) {
|
|
292217
292217
|
createUserWorkerPlugins = () => config$2.worker?.plugins;
|
|
292218
|
-
|
|
292218
|
+
logger16.warn(import_picocolors2.default.yellow(`worker.plugins is now a function that returns an array of plugins. Please update your Vite config accordingly.
|
|
292219
292219
|
`));
|
|
292220
292220
|
}
|
|
292221
292221
|
const createWorkerPlugins = async function(bundleChain) {
|
|
@@ -292295,7 +292295,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
|
292295
292295
|
assetsInclude(file5) {
|
|
292296
292296
|
return DEFAULT_ASSETS_RE.test(file5) || assetsFilter(file5);
|
|
292297
292297
|
},
|
|
292298
|
-
logger:
|
|
292298
|
+
logger: logger16,
|
|
292299
292299
|
packageCache,
|
|
292300
292300
|
worker: resolvedWorkerOptions,
|
|
292301
292301
|
appType: config$2.appType ?? "spa",
|
|
@@ -292386,14 +292386,14 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
|
292386
292386
|
`));
|
|
292387
292387
|
return resolved;
|
|
292388
292388
|
}
|
|
292389
|
-
function resolveBaseUrl(base2 = configDefaults.base, isBuild,
|
|
292389
|
+
function resolveBaseUrl(base2 = configDefaults.base, isBuild, logger16) {
|
|
292390
292390
|
if (base2[0] === ".") {
|
|
292391
|
-
|
|
292391
|
+
logger16.warn(import_picocolors2.default.yellow(import_picocolors2.default.bold(`(!) invalid "base" option: "${base2}". The value can only be an absolute URL, "./", or an empty string.`)));
|
|
292392
292392
|
return "/";
|
|
292393
292393
|
}
|
|
292394
292394
|
const isExternal$1 = isExternalUrl(base2);
|
|
292395
292395
|
if (!isExternal$1 && base2[0] !== "/")
|
|
292396
|
-
|
|
292396
|
+
logger16.warn(import_picocolors2.default.yellow(import_picocolors2.default.bold(`(!) "base" option should start with a slash.`)));
|
|
292397
292397
|
if (!isBuild || !isExternal$1) {
|
|
292398
292398
|
base2 = new URL(base2, "http://vite.dev").pathname;
|
|
292399
292399
|
if (base2[0] !== "/")
|
|
@@ -292460,9 +292460,9 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
292460
292460
|
dependencies
|
|
292461
292461
|
};
|
|
292462
292462
|
} catch (e$1) {
|
|
292463
|
-
const
|
|
292464
|
-
checkBadCharactersInPath("The config path", resolvedPath,
|
|
292465
|
-
|
|
292463
|
+
const logger16 = createLogger(logLevel2, { customLogger });
|
|
292464
|
+
checkBadCharactersInPath("The config path", resolvedPath, logger16);
|
|
292465
|
+
logger16.error(import_picocolors2.default.red(`failed to load config from ${resolvedPath}`), { error: e$1 });
|
|
292466
292466
|
throw e$1;
|
|
292467
292467
|
}
|
|
292468
292468
|
}
|
|
@@ -292639,8 +292639,8 @@ async function runConfigHook(config$2, plugins$1, configEnv) {
|
|
|
292639
292639
|
}
|
|
292640
292640
|
return conf;
|
|
292641
292641
|
}
|
|
292642
|
-
async function runConfigEnvironmentHook(environments, plugins$1,
|
|
292643
|
-
const context15 = new BasicMinimalPluginContext(basePluginContextMeta,
|
|
292642
|
+
async function runConfigEnvironmentHook(environments, plugins$1, logger16, configEnv, isSsrTargetWebworkerSet) {
|
|
292643
|
+
const context15 = new BasicMinimalPluginContext(basePluginContextMeta, logger16);
|
|
292644
292644
|
const environmentNames = Object.keys(environments);
|
|
292645
292645
|
for (const p13 of getSortedPluginsByHook("configEnvironment", plugins$1)) {
|
|
292646
292646
|
const hook = p13.configEnvironment;
|
|
@@ -309094,7 +309094,7 @@ Error: ${e$1.message}`);
|
|
|
309094
309094
|
};
|
|
309095
309095
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
309096
309096
|
exports.ProxyServer = undefined;
|
|
309097
|
-
const
|
|
309097
|
+
const http4 = __importStar(__require2("node:http"));
|
|
309098
309098
|
const https = __importStar(__require2("node:https"));
|
|
309099
309099
|
const web_incoming_1 = require_web_incoming();
|
|
309100
309100
|
const ws_incoming_1$1 = require_ws_incoming();
|
|
@@ -309163,7 +309163,7 @@ Error: ${e$1.message}`);
|
|
|
309163
309163
|
const requestListener = (req$4, res) => {
|
|
309164
309164
|
this.web(req$4, res);
|
|
309165
309165
|
};
|
|
309166
|
-
this._server = this.options.ssl ? https.createServer(this.options.ssl, requestListener) :
|
|
309166
|
+
this._server = this.options.ssl ? https.createServer(this.options.ssl, requestListener) : http4.createServer(requestListener);
|
|
309167
309167
|
if (this.options.ws)
|
|
309168
309168
|
this._server.on("upgrade", (req$4, socket, head13) => {
|
|
309169
309169
|
this.ws(req$4, socket, head13);
|
|
@@ -310320,7 +310320,7 @@ var exports_devtools_server = {};
|
|
|
310320
310320
|
__export(exports_devtools_server, {
|
|
310321
310321
|
startDevtoolsServer: () => startDevtoolsServer
|
|
310322
310322
|
});
|
|
310323
|
-
import
|
|
310323
|
+
import http4 from "node:http";
|
|
310324
310324
|
import path18 from "node:path";
|
|
310325
310325
|
var startDevtoolsServer = ({ schemaPath, clientSessionInfo, port: port2, host }) => exports_Effect2.gen(function* () {
|
|
310326
310326
|
const viteMiddleware = yield* makeViteMiddleware({
|
|
@@ -310377,7 +310377,7 @@ var startDevtoolsServer = ({ schemaPath, clientSessionInfo, port: port2, host })
|
|
|
310377
310377
|
return exports_HttpServer.serve(handler2, exports_HttpMiddleware.logger);
|
|
310378
310378
|
}).pipe(exports_Effect2.withSpan("@livestore/adapter-node:startDevtoolsServer", {
|
|
310379
310379
|
attributes: { clientSessionInfo, port: port2, host, schemaPath }
|
|
310380
|
-
}), exports_HttpMiddleware.withLoggerDisabled, exports_Layer.unwrapScoped, exports_Layer.provide(exports_esm3.NodeHttpServer.layer(() =>
|
|
310380
|
+
}), exports_HttpMiddleware.withLoggerDisabled, exports_Layer.unwrapScoped, exports_Layer.provide(exports_esm3.NodeHttpServer.layer(() => http4.createServer(), { port: port2, host })), exports_Layer.launch, exports_Effect2.orDie);
|
|
310381
310381
|
var init_devtools_server = __esm(() => {
|
|
310382
310382
|
init_mod();
|
|
310383
310383
|
init_effect();
|
|
@@ -345243,10 +345243,10 @@ class VendorBase {
|
|
|
345243
345243
|
vendorId;
|
|
345244
345244
|
constructor(vendorId) {
|
|
345245
345245
|
this.vendorId = vendorId;
|
|
345246
|
-
this.getCredentials = this.getCredentials.bind(this);
|
|
345247
|
-
this.getUserInfo = this.getUserInfo.bind(this);
|
|
345246
|
+
this.getCredentials = runExclusive.buildMethod(this.getCredentials).bind(this);
|
|
345247
|
+
this.getUserInfo = runExclusive.buildMethod(this.getUserInfo).bind(this);
|
|
345248
345248
|
}
|
|
345249
|
-
getCredentials =
|
|
345249
|
+
getCredentials = async () => {
|
|
345250
345250
|
const { credentials } = this.getVendorConfig();
|
|
345251
345251
|
const newCredentials = await this.renewCredentials(credentials);
|
|
345252
345252
|
if (credentials !== newCredentials) {
|
|
@@ -345255,8 +345255,8 @@ class VendorBase {
|
|
|
345255
345255
|
});
|
|
345256
345256
|
}
|
|
345257
345257
|
return newCredentials;
|
|
345258
|
-
}
|
|
345259
|
-
getUserInfo =
|
|
345258
|
+
};
|
|
345259
|
+
getUserInfo = async () => {
|
|
345260
345260
|
const { user } = this.getVendorConfig();
|
|
345261
345261
|
if (user)
|
|
345262
345262
|
return user;
|
|
@@ -345267,7 +345267,7 @@ class VendorBase {
|
|
|
345267
345267
|
credentials
|
|
345268
345268
|
});
|
|
345269
345269
|
return newUser;
|
|
345270
|
-
}
|
|
345270
|
+
};
|
|
345271
345271
|
logout() {
|
|
345272
345272
|
return updateVendorConfig(this.vendorId, null);
|
|
345273
345273
|
}
|
|
@@ -347491,17 +347491,222 @@ class GeminiCli extends VendorBase {
|
|
|
347491
347491
|
// ../vendor-gemini-cli/src/node.ts
|
|
347492
347492
|
registerVendor(new GeminiCli);
|
|
347493
347493
|
|
|
347494
|
-
// ../vendor-claude-code/src/
|
|
347495
|
-
import * as
|
|
347496
|
-
import { stdin as input, stdout as output } from "node:process";
|
|
347497
|
-
import * as readline from "node:readline/promises";
|
|
347494
|
+
// ../vendor-claude-code/src/proxy.ts
|
|
347495
|
+
import * as http2 from "node:http";
|
|
347498
347496
|
|
|
347499
347497
|
// ../vendor-claude-code/src/types.ts
|
|
347500
347498
|
var VendorId4 = "claude-code";
|
|
347501
347499
|
var ClientId = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
347502
347500
|
|
|
347501
|
+
// ../vendor-claude-code/src/proxy.ts
|
|
347502
|
+
var logger4 = getLogger(`${VendorId4}-proxy`);
|
|
347503
|
+
var proxyInstance = null;
|
|
347504
|
+
async function startProxyServer(config3) {
|
|
347505
|
+
if (proxyInstance) {
|
|
347506
|
+
logger4.info("Proxy server already running on port", proxyInstance.port);
|
|
347507
|
+
return proxyInstance;
|
|
347508
|
+
}
|
|
347509
|
+
const port = config3.port || 54321;
|
|
347510
|
+
const host = config3.host || "127.0.0.1";
|
|
347511
|
+
return new Promise((resolve2, reject) => {
|
|
347512
|
+
const server = http2.createServer(async (req, res) => {
|
|
347513
|
+
try {
|
|
347514
|
+
await handleProxyRequest(req, res, config3);
|
|
347515
|
+
} catch (error40) {
|
|
347516
|
+
logger4.error("Proxy request failed:", error40);
|
|
347517
|
+
res.statusCode = 500;
|
|
347518
|
+
res.end(JSON.stringify({ error: "Proxy request failed" }));
|
|
347519
|
+
}
|
|
347520
|
+
});
|
|
347521
|
+
server.on("error", (error40) => {
|
|
347522
|
+
if (error40.code === "EADDRINUSE") {
|
|
347523
|
+
logger4.info(`Port ${port} is busy, trying ${port + 1}`);
|
|
347524
|
+
server.close();
|
|
347525
|
+
config3.port = port + 1;
|
|
347526
|
+
startProxyServer(config3).then(resolve2).catch(reject);
|
|
347527
|
+
} else {
|
|
347528
|
+
reject(error40);
|
|
347529
|
+
}
|
|
347530
|
+
});
|
|
347531
|
+
server.listen(port, host, () => {
|
|
347532
|
+
const address = server.address();
|
|
347533
|
+
const actualPort = typeof address === "object" && address ? address.port : port;
|
|
347534
|
+
const url2 = `http://${host}:${actualPort}`;
|
|
347535
|
+
logger4.info(`Claude Code proxy server started at ${url2}`);
|
|
347536
|
+
proxyInstance = {
|
|
347537
|
+
server,
|
|
347538
|
+
port: actualPort,
|
|
347539
|
+
url: url2
|
|
347540
|
+
};
|
|
347541
|
+
resolve2(proxyInstance);
|
|
347542
|
+
});
|
|
347543
|
+
});
|
|
347544
|
+
}
|
|
347545
|
+
function stopProxyServer() {
|
|
347546
|
+
if (proxyInstance) {
|
|
347547
|
+
proxyInstance.server.close();
|
|
347548
|
+
logger4.info("Claude Code proxy server stopped");
|
|
347549
|
+
proxyInstance = null;
|
|
347550
|
+
}
|
|
347551
|
+
}
|
|
347552
|
+
function getProxyUrl() {
|
|
347553
|
+
return proxyInstance?.url || null;
|
|
347554
|
+
}
|
|
347555
|
+
async function handleProxyRequest(req, res, config3) {
|
|
347556
|
+
setCorsHeaders(res);
|
|
347557
|
+
if (req.method === "OPTIONS") {
|
|
347558
|
+
res.statusCode = 204;
|
|
347559
|
+
res.end();
|
|
347560
|
+
return;
|
|
347561
|
+
}
|
|
347562
|
+
const credentials = await config3.getCredentials();
|
|
347563
|
+
if (!credentials) {
|
|
347564
|
+
res.statusCode = 401;
|
|
347565
|
+
res.end(JSON.stringify({ error: "No authentication credentials" }));
|
|
347566
|
+
return;
|
|
347567
|
+
}
|
|
347568
|
+
const targetUrl = new URL(req.url || "/", "https://api.anthropic.com");
|
|
347569
|
+
const headers = {};
|
|
347570
|
+
const excludeHeaders = new Set([
|
|
347571
|
+
"x-api-key",
|
|
347572
|
+
"origin",
|
|
347573
|
+
"referer",
|
|
347574
|
+
"sec-fetch-site",
|
|
347575
|
+
"sec-fetch-mode",
|
|
347576
|
+
"sec-fetch-dest",
|
|
347577
|
+
"sec-ch-ua",
|
|
347578
|
+
"sec-ch-ua-mobile",
|
|
347579
|
+
"sec-ch-ua-platform",
|
|
347580
|
+
"anthropic-dangerous-direct-browser-access"
|
|
347581
|
+
]);
|
|
347582
|
+
for (const [key, value2] of Object.entries(req.headers)) {
|
|
347583
|
+
if (!excludeHeaders.has(key.toLowerCase()) && typeof value2 === "string") {
|
|
347584
|
+
headers[key] = value2;
|
|
347585
|
+
}
|
|
347586
|
+
}
|
|
347587
|
+
headers.host = "api.anthropic.com";
|
|
347588
|
+
headers.authorization = `Bearer ${credentials.accessToken}`;
|
|
347589
|
+
headers["anthropic-beta"] = "oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14";
|
|
347590
|
+
headers["anthropic-version"] = "2023-06-01";
|
|
347591
|
+
const body = await collectRequestBody(req);
|
|
347592
|
+
logger4.debug(`Proxying ${req.method} request to ${targetUrl.toString()}`);
|
|
347593
|
+
try {
|
|
347594
|
+
const response = await fetch(targetUrl.toString(), {
|
|
347595
|
+
method: req.method,
|
|
347596
|
+
headers,
|
|
347597
|
+
body: body || undefined
|
|
347598
|
+
});
|
|
347599
|
+
res.statusCode = response.status;
|
|
347600
|
+
const responseHeaders = {};
|
|
347601
|
+
response.headers.forEach((value2, key) => {
|
|
347602
|
+
if (!["content-encoding", "content-length", "transfer-encoding"].includes(key.toLowerCase())) {
|
|
347603
|
+
responseHeaders[key] = value2;
|
|
347604
|
+
}
|
|
347605
|
+
});
|
|
347606
|
+
setCorsHeaders(res, responseHeaders);
|
|
347607
|
+
if (response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
347608
|
+
res.setHeader("content-type", "text/event-stream");
|
|
347609
|
+
res.setHeader("cache-control", "no-cache");
|
|
347610
|
+
res.setHeader("connection", "keep-alive");
|
|
347611
|
+
const reader = response.body?.getReader();
|
|
347612
|
+
if (reader) {
|
|
347613
|
+
const decoder2 = new TextDecoder;
|
|
347614
|
+
try {
|
|
347615
|
+
while (true) {
|
|
347616
|
+
const { done, value: value2 } = await reader.read();
|
|
347617
|
+
if (done)
|
|
347618
|
+
break;
|
|
347619
|
+
const chunk = decoder2.decode(value2, { stream: true });
|
|
347620
|
+
res.write(chunk);
|
|
347621
|
+
}
|
|
347622
|
+
} finally {
|
|
347623
|
+
reader.releaseLock();
|
|
347624
|
+
}
|
|
347625
|
+
}
|
|
347626
|
+
res.end();
|
|
347627
|
+
} else {
|
|
347628
|
+
const responseBody = await response.text();
|
|
347629
|
+
res.end(responseBody);
|
|
347630
|
+
}
|
|
347631
|
+
} catch (error40) {
|
|
347632
|
+
logger4.error("Failed to proxy request:", error40);
|
|
347633
|
+
res.statusCode = 502;
|
|
347634
|
+
res.end(JSON.stringify({ error: "Failed to proxy request" }));
|
|
347635
|
+
}
|
|
347636
|
+
}
|
|
347637
|
+
function setCorsHeaders(res, additionalHeaders) {
|
|
347638
|
+
const headers = {
|
|
347639
|
+
"Access-Control-Allow-Origin": "*",
|
|
347640
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS, PATCH",
|
|
347641
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization, anthropic-version, anthropic-beta, x-api-key",
|
|
347642
|
+
"Access-Control-Max-Age": "86400",
|
|
347643
|
+
...additionalHeaders
|
|
347644
|
+
};
|
|
347645
|
+
for (const [key, value2] of Object.entries(headers)) {
|
|
347646
|
+
res.setHeader(key, value2);
|
|
347647
|
+
}
|
|
347648
|
+
}
|
|
347649
|
+
async function collectRequestBody(req) {
|
|
347650
|
+
return new Promise((resolve2) => {
|
|
347651
|
+
const chunks = [];
|
|
347652
|
+
req.on("data", (chunk) => {
|
|
347653
|
+
chunks.push(chunk);
|
|
347654
|
+
});
|
|
347655
|
+
req.on("end", () => {
|
|
347656
|
+
if (chunks.length === 0) {
|
|
347657
|
+
resolve2(null);
|
|
347658
|
+
} else {
|
|
347659
|
+
resolve2(Buffer.concat(chunks).toString());
|
|
347660
|
+
}
|
|
347661
|
+
});
|
|
347662
|
+
req.on("error", () => {
|
|
347663
|
+
resolve2(null);
|
|
347664
|
+
});
|
|
347665
|
+
});
|
|
347666
|
+
}
|
|
347667
|
+
var proxyStarted = false;
|
|
347668
|
+
async function initializeProxy() {
|
|
347669
|
+
if (proxyStarted) {
|
|
347670
|
+
const existingUrl = getProxyUrl();
|
|
347671
|
+
if (existingUrl) {
|
|
347672
|
+
logger4.info("Proxy already running at", existingUrl);
|
|
347673
|
+
return existingUrl;
|
|
347674
|
+
}
|
|
347675
|
+
}
|
|
347676
|
+
try {
|
|
347677
|
+
const proxy = await startProxyServer({
|
|
347678
|
+
port: 54321,
|
|
347679
|
+
getCredentials: async () => {
|
|
347680
|
+
const vendor2 = getVendor("claude-code");
|
|
347681
|
+
const creds = await vendor2.getCredentials();
|
|
347682
|
+
return creds;
|
|
347683
|
+
}
|
|
347684
|
+
});
|
|
347685
|
+
proxyStarted = true;
|
|
347686
|
+
process.env.CLAUDE_CODE_PROXY_URL = proxy.url;
|
|
347687
|
+
logger4.info(`Claude Code proxy auto-started at ${proxy.url}`);
|
|
347688
|
+
const cleanup = () => {
|
|
347689
|
+
if (proxyStarted) {
|
|
347690
|
+
stopProxyServer();
|
|
347691
|
+
proxyStarted = false;
|
|
347692
|
+
logger4.info("Claude Code proxy stopped");
|
|
347693
|
+
}
|
|
347694
|
+
};
|
|
347695
|
+
process.on("exit", cleanup);
|
|
347696
|
+
process.on("SIGINT", cleanup);
|
|
347697
|
+
process.on("SIGTERM", cleanup);
|
|
347698
|
+
return proxy.url;
|
|
347699
|
+
} catch (error40) {
|
|
347700
|
+
logger4.error("Failed to auto-start Claude Code proxy:", error40);
|
|
347701
|
+
throw error40;
|
|
347702
|
+
}
|
|
347703
|
+
}
|
|
347704
|
+
|
|
347503
347705
|
// ../vendor-claude-code/src/auth.ts
|
|
347504
|
-
|
|
347706
|
+
import * as crypto3 from "node:crypto";
|
|
347707
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
347708
|
+
import * as readline from "node:readline/promises";
|
|
347709
|
+
var logger5 = getLogger(VendorId4);
|
|
347505
347710
|
async function startOAuthFlow2() {
|
|
347506
347711
|
const pkce = generatePKCEParams2();
|
|
347507
347712
|
const redirectUri = "https://console.anthropic.com/oauth/code/callback";
|
|
@@ -347554,10 +347759,10 @@ async function exchangeCodeForTokens2(code, verifier, redirectUri) {
|
|
|
347554
347759
|
code_verifier: verifier
|
|
347555
347760
|
})
|
|
347556
347761
|
});
|
|
347557
|
-
|
|
347762
|
+
logger5.debug("Token exchange response status:", response.ok);
|
|
347558
347763
|
if (!response.ok) {
|
|
347559
347764
|
const errorText = await response.text();
|
|
347560
|
-
|
|
347765
|
+
logger5.error("Token exchange failed:", errorText);
|
|
347561
347766
|
throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
|
|
347562
347767
|
}
|
|
347563
347768
|
const tokenData = await response.json();
|
|
@@ -347583,7 +347788,7 @@ async function renewCredentials2(credentials) {
|
|
|
347583
347788
|
client_id: ClientId
|
|
347584
347789
|
})
|
|
347585
347790
|
});
|
|
347586
|
-
|
|
347791
|
+
logger5.debug("Token refresh response status:", response.ok);
|
|
347587
347792
|
if (!response.ok) {
|
|
347588
347793
|
throw new Error(`Token refresh failed: ${response.status} ${response.statusText}`);
|
|
347589
347794
|
}
|
|
@@ -347594,7 +347799,7 @@ async function renewCredentials2(credentials) {
|
|
|
347594
347799
|
expiresAt: Date.now() + tokenData.expires_in * 1000
|
|
347595
347800
|
};
|
|
347596
347801
|
} catch (error40) {
|
|
347597
|
-
|
|
347802
|
+
logger5.error("Failed to refresh Claude Code token:", error40);
|
|
347598
347803
|
return;
|
|
347599
347804
|
}
|
|
347600
347805
|
}
|
|
@@ -347612,9 +347817,33 @@ function generatePKCEParams2() {
|
|
|
347612
347817
|
|
|
347613
347818
|
// ../vendor-claude-code/src/vendor.ts
|
|
347614
347819
|
class ClaudeCode extends VendorBase {
|
|
347820
|
+
proxyStarted = false;
|
|
347615
347821
|
constructor() {
|
|
347616
347822
|
super(VendorId4);
|
|
347617
347823
|
}
|
|
347824
|
+
async initializeProxy(getCredentials, port) {
|
|
347825
|
+
if (this.proxyStarted) {
|
|
347826
|
+
const url2 = getProxyUrl();
|
|
347827
|
+
if (url2) {
|
|
347828
|
+
return url2;
|
|
347829
|
+
}
|
|
347830
|
+
}
|
|
347831
|
+
const proxy = await startProxyServer({
|
|
347832
|
+
port,
|
|
347833
|
+
getCredentials
|
|
347834
|
+
});
|
|
347835
|
+
this.proxyStarted = true;
|
|
347836
|
+
return proxy.url;
|
|
347837
|
+
}
|
|
347838
|
+
stopProxy() {
|
|
347839
|
+
if (this.proxyStarted) {
|
|
347840
|
+
stopProxyServer();
|
|
347841
|
+
this.proxyStarted = false;
|
|
347842
|
+
}
|
|
347843
|
+
}
|
|
347844
|
+
getProxyUrl() {
|
|
347845
|
+
return getProxyUrl();
|
|
347846
|
+
}
|
|
347618
347847
|
authenticate() {
|
|
347619
347848
|
return startOAuthFlow2();
|
|
347620
347849
|
}
|
|
@@ -347639,7 +347868,27 @@ class ClaudeCode extends VendorBase {
|
|
|
347639
347868
|
}
|
|
347640
347869
|
|
|
347641
347870
|
// ../vendor-claude-code/src/node.ts
|
|
347871
|
+
var logger6 = getLogger(`${VendorId4}-node`);
|
|
347872
|
+
var isVSCodeEnvironment2 = () => {
|
|
347873
|
+
if (typeof process !== "undefined") {
|
|
347874
|
+
if (process.env.VSCODE_PID) {
|
|
347875
|
+
return true;
|
|
347876
|
+
}
|
|
347877
|
+
if (process.env.VSCODE_SERVER_PORT) {
|
|
347878
|
+
return true;
|
|
347879
|
+
}
|
|
347880
|
+
if (process.env.VSCODE_CWD) {
|
|
347881
|
+
return true;
|
|
347882
|
+
}
|
|
347883
|
+
}
|
|
347884
|
+
return false;
|
|
347885
|
+
};
|
|
347642
347886
|
registerVendor(new ClaudeCode);
|
|
347887
|
+
if (isVSCodeEnvironment2()) {
|
|
347888
|
+
initializeProxy().catch((error40) => {
|
|
347889
|
+
logger6.error("Proxy initialization error:", error40);
|
|
347890
|
+
});
|
|
347891
|
+
}
|
|
347643
347892
|
|
|
347644
347893
|
// ../common/src/vendor/edge.ts
|
|
347645
347894
|
var { register: register2, get: get2 } = createRegistry();
|
|
@@ -351654,13 +351903,22 @@ function createAnthropic(options = {}) {
|
|
|
351654
351903
|
var anthropic = createAnthropic();
|
|
351655
351904
|
|
|
351656
351905
|
// ../vendor-claude-code/src/model.ts
|
|
351657
|
-
|
|
351658
|
-
|
|
351659
|
-
|
|
351660
|
-
|
|
351661
|
-
|
|
351906
|
+
var ClaudeCodeSystemPrompt = "You are Claude Code, Anthropic's official CLI for Claude.";
|
|
351907
|
+
var AnthropicHeaders = {
|
|
351908
|
+
beta: "oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14",
|
|
351909
|
+
version: "2023-06-01"
|
|
351910
|
+
};
|
|
351911
|
+
function addAnthropicHeaders(headers, credentials) {
|
|
351912
|
+
if (credentials) {
|
|
351913
|
+
headers.set("authorization", `Bearer ${credentials.accessToken}`);
|
|
351914
|
+
}
|
|
351915
|
+
headers.set("anthropic-beta", AnthropicHeaders.beta);
|
|
351916
|
+
headers.set("anthropic-version", AnthropicHeaders.version);
|
|
351917
|
+
headers.delete("x-api-key");
|
|
351918
|
+
}
|
|
351919
|
+
function createClaudeCodeModelBase(modelId, baseURL, customFetch) {
|
|
351662
351920
|
const anthropic2 = createAnthropic({
|
|
351663
|
-
baseURL
|
|
351921
|
+
baseURL,
|
|
351664
351922
|
apiKey: "oauth-token",
|
|
351665
351923
|
fetch: customFetch
|
|
351666
351924
|
});
|
|
@@ -351673,7 +351931,7 @@ function createClaudeCodeModel({
|
|
|
351673
351931
|
params.prompt = [
|
|
351674
351932
|
{
|
|
351675
351933
|
role: "system",
|
|
351676
|
-
content:
|
|
351934
|
+
content: ClaudeCodeSystemPrompt
|
|
351677
351935
|
},
|
|
351678
351936
|
...params.prompt
|
|
351679
351937
|
];
|
|
@@ -351689,20 +351947,55 @@ function createPatchedFetch2(getCredentials) {
|
|
|
351689
351947
|
return async (input2, init) => {
|
|
351690
351948
|
const credentials = await getCredentials();
|
|
351691
351949
|
const headers = new Headers(init?.headers);
|
|
351692
|
-
headers
|
|
351693
|
-
|
|
351694
|
-
|
|
351695
|
-
|
|
351696
|
-
|
|
351697
|
-
|
|
351698
|
-
|
|
351699
|
-
|
|
351700
|
-
|
|
351950
|
+
addAnthropicHeaders(headers, credentials);
|
|
351951
|
+
return fetch(input2, { ...init, headers });
|
|
351952
|
+
};
|
|
351953
|
+
}
|
|
351954
|
+
function createProxyFetch(getCredentials, proxyUrl) {
|
|
351955
|
+
return async (input2, init) => {
|
|
351956
|
+
const url2 = convertToProxyUrl(input2, proxyUrl);
|
|
351957
|
+
const credentials = await getCredentials();
|
|
351958
|
+
const headers = new Headers(init?.headers);
|
|
351959
|
+
addAnthropicHeaders(headers, credentials);
|
|
351960
|
+
headers.delete("origin");
|
|
351961
|
+
headers.delete("referer");
|
|
351962
|
+
return fetch(url2, { ...init, headers });
|
|
351701
351963
|
};
|
|
351702
351964
|
}
|
|
351965
|
+
function convertToProxyUrl(input2, proxyUrl) {
|
|
351966
|
+
if (typeof input2 === "string") {
|
|
351967
|
+
if (input2.startsWith("https://api.anthropic.com")) {
|
|
351968
|
+
return input2.replace("https://api.anthropic.com", proxyUrl);
|
|
351969
|
+
}
|
|
351970
|
+
if (input2.startsWith("/")) {
|
|
351971
|
+
return `${proxyUrl}${input2}`;
|
|
351972
|
+
}
|
|
351973
|
+
return input2;
|
|
351974
|
+
}
|
|
351975
|
+
if (input2 instanceof URL) {
|
|
351976
|
+
return input2.toString().replace("https://api.anthropic.com", proxyUrl);
|
|
351977
|
+
}
|
|
351978
|
+
return input2.url.replace("https://api.anthropic.com", proxyUrl);
|
|
351979
|
+
}
|
|
351980
|
+
function createClaudeCodeModel({
|
|
351981
|
+
modelId,
|
|
351982
|
+
getCredentials
|
|
351983
|
+
}) {
|
|
351984
|
+
const customFetch = createPatchedFetch2(getCredentials);
|
|
351985
|
+
return createClaudeCodeModelBase(modelId, "https://api.anthropic.com/v1", customFetch);
|
|
351986
|
+
}
|
|
351987
|
+
function createEdgeClaudeCodeModel({
|
|
351988
|
+
modelId,
|
|
351989
|
+
getCredentials
|
|
351990
|
+
}) {
|
|
351991
|
+
const PROXY_URL = process.env.CLAUDE_CODE_PROXY_URL || "http://localhost:54321";
|
|
351992
|
+
const customFetch = createProxyFetch(getCredentials, PROXY_URL);
|
|
351993
|
+
return createClaudeCodeModelBase(modelId, `${PROXY_URL}/v1`, customFetch);
|
|
351994
|
+
}
|
|
351703
351995
|
|
|
351704
351996
|
// ../vendor-claude-code/src/edge.ts
|
|
351705
|
-
|
|
351997
|
+
var modelCreator = "window" in globalThis ? createEdgeClaudeCodeModel : createClaudeCodeModel;
|
|
351998
|
+
registerModel(VendorId4, modelCreator);
|
|
351706
351999
|
|
|
351707
352000
|
// ../../node_modules/@commander-js/extra-typings/esm.mjs
|
|
351708
352001
|
var import__4 = __toESM(require_extra_typings(), 1);
|
|
@@ -351727,8 +352020,8 @@ var getVendors2 = getAll2;
|
|
|
351727
352020
|
// ../common/src/vendor/edge.ts
|
|
351728
352021
|
var { register: register4, get: get4 } = createRegistry();
|
|
351729
352022
|
function createModel(vendorId, opts) {
|
|
351730
|
-
const
|
|
351731
|
-
return
|
|
352023
|
+
const modelCreator2 = get4(vendorId);
|
|
352024
|
+
return modelCreator2(opts);
|
|
351732
352025
|
}
|
|
351733
352026
|
|
|
351734
352027
|
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
@@ -352232,7 +352525,7 @@ var {
|
|
|
352232
352525
|
// package.json
|
|
352233
352526
|
var package_default = {
|
|
352234
352527
|
name: "@getpochi/cli",
|
|
352235
|
-
version: "0.5.
|
|
352528
|
+
version: "0.5.30",
|
|
352236
352529
|
type: "module",
|
|
352237
352530
|
bin: {
|
|
352238
352531
|
pochi: "src/cli.ts"
|
|
@@ -353711,9 +354004,9 @@ var MaxTerminalOutputSize = 30000;
|
|
|
353711
354004
|
|
|
353712
354005
|
// ../common/src/tool-utils/ripgrep.ts
|
|
353713
354006
|
var execAsync = promisify(exec2);
|
|
353714
|
-
var
|
|
354007
|
+
var logger7 = getLogger("RipgrepUtils");
|
|
353715
354008
|
async function searchFilesWithRipgrep(path3, regex, rgPath, workspacePath, filePattern, abortSignal) {
|
|
353716
|
-
|
|
354009
|
+
logger7.debug("searchFiles", path3, regex, filePattern);
|
|
353717
354010
|
const matches = [];
|
|
353718
354011
|
let command = `"${rgPath.replace(/"/g, "\\\"")}" --json --case-sensitive --binary --sortr modified `;
|
|
353719
354012
|
if (filePattern) {
|
|
@@ -353721,14 +354014,14 @@ async function searchFilesWithRipgrep(path3, regex, rgPath, workspacePath, fileP
|
|
|
353721
354014
|
}
|
|
353722
354015
|
const absPath = resolve3(workspacePath, path3.replace(/'/g, "'\\''"));
|
|
353723
354016
|
command += `'${regex.replace(/'/g, "'\\''")}' '${absPath}'`;
|
|
353724
|
-
|
|
354017
|
+
logger7.debug("command", command);
|
|
353725
354018
|
try {
|
|
353726
354019
|
const { stdout, stderr } = await execAsync(command, {
|
|
353727
354020
|
maxBuffer: 1024 * 1024 * 10,
|
|
353728
354021
|
signal: abortSignal
|
|
353729
354022
|
});
|
|
353730
354023
|
if (stderr) {
|
|
353731
|
-
|
|
354024
|
+
logger7.warn("rg command stderr: ", stderr.slice(0, 1000));
|
|
353732
354025
|
}
|
|
353733
354026
|
const outputLines = stdout.trim().split(`
|
|
353734
354027
|
`);
|
|
@@ -353744,25 +354037,25 @@ async function searchFilesWithRipgrep(path3, regex, rgPath, workspacePath, fileP
|
|
|
353744
354037
|
});
|
|
353745
354038
|
}
|
|
353746
354039
|
} catch (parseError) {
|
|
353747
|
-
|
|
354040
|
+
logger7.error(`Failed to parse rg JSON output line: ${line}`, parseError);
|
|
353748
354041
|
}
|
|
353749
354042
|
}
|
|
353750
354043
|
} catch (error40) {
|
|
353751
354044
|
if (!error40) {
|
|
353752
|
-
|
|
354045
|
+
logger7.error("rg command error: ", error40);
|
|
353753
354046
|
throw error40;
|
|
353754
354047
|
}
|
|
353755
354048
|
if (error40.code && error40.code > 1) {
|
|
353756
354049
|
throw new Error(`rg command failed with code ${error40.code}: ${error40.stderr || error40.message}`);
|
|
353757
354050
|
}
|
|
353758
354051
|
if (!error40.code && error40.stderr) {
|
|
353759
|
-
|
|
354052
|
+
logger7.warn(`rg command stderr (exit code 0): ${error40.stderr}`);
|
|
353760
354053
|
} else if (error40.code === 1 && !error40.stdout && !error40.stderr) {} else if (error40.code === 1 && error40.stdout) {
|
|
353761
354054
|
if (error40.stderr) {
|
|
353762
|
-
|
|
354055
|
+
logger7.warn(`rg command stderr (exit code 1): ${error40.stderr}`);
|
|
353763
354056
|
}
|
|
353764
354057
|
} else {
|
|
353765
|
-
|
|
354058
|
+
logger7.error("Error executing rg command: ", error40);
|
|
353766
354059
|
throw error40;
|
|
353767
354060
|
}
|
|
353768
354061
|
}
|
|
@@ -353775,7 +354068,7 @@ async function searchFilesWithRipgrep(path3, regex, rgPath, workspacePath, fileP
|
|
|
353775
354068
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
353776
354069
|
import * as fs3 from "node:fs/promises";
|
|
353777
354070
|
import * as path3 from "node:path";
|
|
353778
|
-
var
|
|
354071
|
+
var logger8 = getLogger("ignoreWalk");
|
|
353779
354072
|
var MaxScanItems = 1e4;
|
|
353780
354073
|
async function attemptLoadIgnoreFromPath(directoryPath) {
|
|
353781
354074
|
try {
|
|
@@ -353821,9 +354114,9 @@ async function ignoreWalk({
|
|
|
353821
354114
|
const scannedFileResults = [];
|
|
353822
354115
|
const processedDirs = new Set;
|
|
353823
354116
|
const queue = [{ uri: dir, ignore: import_ignore.default().add(".git") }];
|
|
353824
|
-
|
|
354117
|
+
logger8.trace(`Starting traversal from ${dir} with limit ${MaxScanItems}, recursive: ${recursive}`);
|
|
353825
354118
|
if (abortSignal?.aborted) {
|
|
353826
|
-
|
|
354119
|
+
logger8.debug("Traversal aborted before starting.");
|
|
353827
354120
|
return [];
|
|
353828
354121
|
}
|
|
353829
354122
|
let fileScannedCount = 0;
|
|
@@ -353842,23 +354135,23 @@ async function ignoreWalk({
|
|
|
353842
354135
|
const entries = await fs3.readdir(currentFsPath, { withFileTypes: true });
|
|
353843
354136
|
for (const entry of entries) {
|
|
353844
354137
|
if (abortSignal?.aborted) {
|
|
353845
|
-
|
|
354138
|
+
logger8.debug("Traversal aborted during directory processing.");
|
|
353846
354139
|
break;
|
|
353847
354140
|
}
|
|
353848
354141
|
const maxItemsReached = await processDirectoryEntry(entry, currentFsPath, dir, directoryIg, recursive, processedDirs, queue, scannedFileResults);
|
|
353849
354142
|
fileScannedCount++;
|
|
353850
354143
|
if (maxItemsReached || fileScannedCount >= MaxScanItems) {
|
|
353851
|
-
|
|
354144
|
+
logger8.debug(`MaxScanItems (${MaxScanItems}) reached or exceeded. Halting traversal.`);
|
|
353852
354145
|
queue.length = 0;
|
|
353853
354146
|
break;
|
|
353854
354147
|
}
|
|
353855
354148
|
}
|
|
353856
354149
|
} catch (error40) {
|
|
353857
354150
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
353858
|
-
|
|
354151
|
+
logger8.warn(`Error reading directory ${currentFsPath}: ${message}`);
|
|
353859
354152
|
}
|
|
353860
354153
|
}
|
|
353861
|
-
|
|
354154
|
+
logger8.trace(`Completed traversal. Found ${scannedFileResults.length} items. Processed approximately ${fileScannedCount} entries.`);
|
|
353862
354155
|
return scannedFileResults;
|
|
353863
354156
|
}
|
|
353864
354157
|
// ../common/src/tool-utils/fs.ts
|
|
@@ -353962,10 +354255,10 @@ async function isFileExists(filePath) {
|
|
|
353962
354255
|
}
|
|
353963
354256
|
// ../common/src/tool-utils/list-files.ts
|
|
353964
354257
|
import path5 from "node:path";
|
|
353965
|
-
var
|
|
354258
|
+
var logger9 = getLogger("listFiles");
|
|
353966
354259
|
async function listFiles2(options) {
|
|
353967
354260
|
const { cwd, path: dirPath, recursive, abortSignal } = options;
|
|
353968
|
-
|
|
354261
|
+
logger9.debug("handling listFile with dirPath", dirPath, "and recursive", recursive);
|
|
353969
354262
|
const dir = resolvePath(dirPath, cwd);
|
|
353970
354263
|
if (!path5.isAbsolute(dirPath)) {
|
|
353971
354264
|
validateRelativePath(dirPath);
|
|
@@ -353982,7 +354275,7 @@ async function listFiles2(options) {
|
|
|
353982
354275
|
return { files, isTruncated };
|
|
353983
354276
|
} catch (error40) {
|
|
353984
354277
|
const errorMessage = error40 instanceof Error ? error40.message : String(error40);
|
|
353985
|
-
|
|
354278
|
+
logger9.error("Error listing files:", errorMessage);
|
|
353986
354279
|
throw new Error(`Failed to list files: ${errorMessage}`);
|
|
353987
354280
|
}
|
|
353988
354281
|
}
|
|
@@ -353993,7 +354286,7 @@ async function listWorkspaceFiles(options) {
|
|
|
353993
354286
|
abortSignal,
|
|
353994
354287
|
maxItems = MaxListFileItems
|
|
353995
354288
|
} = options;
|
|
353996
|
-
|
|
354289
|
+
logger9.debug("Listing workspace files from", cwd, "with maxItems", maxItems);
|
|
353997
354290
|
try {
|
|
353998
354291
|
const results = await ignoreWalk({
|
|
353999
354292
|
dir: cwd,
|
|
@@ -354006,16 +354299,16 @@ async function listWorkspaceFiles(options) {
|
|
|
354006
354299
|
});
|
|
354007
354300
|
return { files, isTruncated };
|
|
354008
354301
|
} catch (error40) {
|
|
354009
|
-
|
|
354302
|
+
logger9.warn("Failed to list workspace files:", error40);
|
|
354010
354303
|
return { files: [], isTruncated: false };
|
|
354011
354304
|
}
|
|
354012
354305
|
}
|
|
354013
354306
|
// ../common/src/tool-utils/glob-files.ts
|
|
354014
354307
|
import * as path6 from "node:path";
|
|
354015
|
-
var
|
|
354308
|
+
var logger10 = getLogger("globFiles");
|
|
354016
354309
|
async function globFiles2(options) {
|
|
354017
354310
|
const { cwd, path: searchPath, globPattern, abortSignal } = options;
|
|
354018
|
-
|
|
354311
|
+
logger10.debug("handling globFiles with searchPath:", searchPath, "and pattern", globPattern);
|
|
354019
354312
|
const dir = resolvePath(searchPath, cwd);
|
|
354020
354313
|
if (!path6.isAbsolute(searchPath)) {
|
|
354021
354314
|
validateRelativePath(searchPath);
|
|
@@ -354041,8 +354334,8 @@ async function globFiles2(options) {
|
|
|
354041
354334
|
const errorMessage = error40 instanceof Error ? error40.message : String(error40);
|
|
354042
354335
|
throw new Error(`Failed to glob files: ${errorMessage}`);
|
|
354043
354336
|
}
|
|
354044
|
-
|
|
354045
|
-
|
|
354337
|
+
logger10.debug(`Found ${files.length} files matching pattern ${globPattern}`);
|
|
354338
|
+
logger10.trace("Files found in globFiles:", files);
|
|
354046
354339
|
return { files, isTruncated };
|
|
354047
354340
|
}
|
|
354048
354341
|
// ../common/src/tool-utils/system-info.ts
|
|
@@ -354138,7 +354431,7 @@ function parseGitOriginUrl(originUrl) {
|
|
|
354138
354431
|
}
|
|
354139
354432
|
|
|
354140
354433
|
// ../common/src/tool-utils/git-status.ts
|
|
354141
|
-
var
|
|
354434
|
+
var logger11 = getLogger("GitStatus");
|
|
354142
354435
|
|
|
354143
354436
|
class GitStatusReader {
|
|
354144
354437
|
execPromise = promisify2(exec3);
|
|
@@ -354245,16 +354538,16 @@ class GitStatusReader {
|
|
|
354245
354538
|
}
|
|
354246
354539
|
async readGitStatus() {
|
|
354247
354540
|
if (!this.cwd) {
|
|
354248
|
-
|
|
354541
|
+
logger11.warn("No Git repository path specified");
|
|
354249
354542
|
return;
|
|
354250
354543
|
}
|
|
354251
354544
|
try {
|
|
354252
|
-
|
|
354545
|
+
logger11.trace("Reading Git status for repository", {
|
|
354253
354546
|
path: this.cwd
|
|
354254
354547
|
});
|
|
354255
354548
|
return await this.readGitStatusImpl();
|
|
354256
354549
|
} catch (error40) {
|
|
354257
|
-
|
|
354550
|
+
logger11.error("Error reading Git status", error40);
|
|
354258
354551
|
return;
|
|
354259
354552
|
}
|
|
354260
354553
|
}
|
|
@@ -363893,7 +364186,7 @@ async function parseAgentFile(content3) {
|
|
|
363893
364186
|
}
|
|
363894
364187
|
}
|
|
363895
364188
|
// src/lib/load-agents.ts
|
|
363896
|
-
var
|
|
364189
|
+
var logger12 = getLogger("CustomAgentManager");
|
|
363897
364190
|
async function readAgentsFromDir(dir) {
|
|
363898
364191
|
const agents = [];
|
|
363899
364192
|
try {
|
|
@@ -363911,12 +364204,12 @@ async function readAgentsFromDir(dir) {
|
|
|
363911
364204
|
agents.push({ ...agent, filePath });
|
|
363912
364205
|
}
|
|
363913
364206
|
} catch (error40) {
|
|
363914
|
-
|
|
364207
|
+
logger12.debug(`Could not read agent file ${filePath}:`, error40);
|
|
363915
364208
|
}
|
|
363916
364209
|
}
|
|
363917
364210
|
}
|
|
363918
364211
|
} catch (error40) {
|
|
363919
|
-
|
|
364212
|
+
logger12.debug(`Could not read agents from directory ${dir}:`, error40);
|
|
363920
364213
|
}
|
|
363921
364214
|
return agents;
|
|
363922
364215
|
}
|
|
@@ -363929,16 +364222,16 @@ async function loadAgents(workingDirectory) {
|
|
|
363929
364222
|
}
|
|
363930
364223
|
const systemAgentsDir = path8.join(os6.homedir(), ".pochi", "agents");
|
|
363931
364224
|
allAgents.push(...await readAgentsFromDir(systemAgentsDir));
|
|
363932
|
-
|
|
364225
|
+
logger12.debug(`Loaded ${allAgents.length} custom agents`);
|
|
363933
364226
|
return allAgents;
|
|
363934
364227
|
} catch (error40) {
|
|
363935
|
-
|
|
364228
|
+
logger12.error("Failed to load custom agents", error40);
|
|
363936
364229
|
return [];
|
|
363937
364230
|
}
|
|
363938
364231
|
}
|
|
363939
364232
|
|
|
363940
364233
|
// src/lib/store-utils.ts
|
|
363941
|
-
var
|
|
364234
|
+
var logger13 = getLogger("Shutdown");
|
|
363942
364235
|
async function shutdownStoreAndExit(store) {
|
|
363943
364236
|
try {
|
|
363944
364237
|
await Promise.race([
|
|
@@ -363949,7 +364242,7 @@ async function shutdownStoreAndExit(store) {
|
|
|
363949
364242
|
]);
|
|
363950
364243
|
process.exit(0);
|
|
363951
364244
|
} catch (error40) {
|
|
363952
|
-
|
|
364245
|
+
logger13.warn("Store shutdown failed", error40);
|
|
363953
364246
|
process.exit(1);
|
|
363954
364247
|
}
|
|
363955
364248
|
}
|
|
@@ -364043,7 +364336,6 @@ var binary_to_base58_default = binary_to_base58;
|
|
|
364043
364336
|
var StoreId = v4_default.object({
|
|
364044
364337
|
sub: v4_default.string(),
|
|
364045
364338
|
machineId: v4_default.string(),
|
|
364046
|
-
cwd: v4_default.string(),
|
|
364047
364339
|
date: v4_default.string().describe("Local date in MM/DD/YYYY format")
|
|
364048
364340
|
});
|
|
364049
364341
|
function encodeStoreId(storeId) {
|
|
@@ -364060,7 +364352,6 @@ __export(exports_livestore, {
|
|
|
364060
364352
|
});
|
|
364061
364353
|
|
|
364062
364354
|
// ../../node_modules/@livestore/livestore/dist/mod.js
|
|
364063
|
-
init_dist2();
|
|
364064
364355
|
init_mod8();
|
|
364065
364356
|
init_effect();
|
|
364066
364357
|
|
|
@@ -365815,6 +366106,8 @@ var tables = {
|
|
|
365815
366106
|
columns: {
|
|
365816
366107
|
id: exports_mod4.SQLite.text({ primaryKey: true }),
|
|
365817
366108
|
shareId: exports_mod4.SQLite.text({ nullable: true }),
|
|
366109
|
+
cwd: exports_mod4.SQLite.text({ nullable: true }),
|
|
366110
|
+
isPublicShared: exports_mod4.SQLite.boolean({ default: false }),
|
|
365818
366111
|
title: exports_mod4.SQLite.text({ nullable: true }),
|
|
365819
366112
|
parentId: exports_mod4.SQLite.text({ nullable: true }),
|
|
365820
366113
|
status: exports_mod4.SQLite.text({
|
|
@@ -365843,6 +366136,10 @@ var tables = {
|
|
|
365843
366136
|
name: "idx-shareId",
|
|
365844
366137
|
columns: ["shareId"],
|
|
365845
366138
|
isUnique: true
|
|
366139
|
+
},
|
|
366140
|
+
{
|
|
366141
|
+
name: "idx-cwd",
|
|
366142
|
+
columns: ["cwd"]
|
|
365846
366143
|
}
|
|
365847
366144
|
]
|
|
365848
366145
|
}),
|
|
@@ -365867,6 +366164,7 @@ var events = {
|
|
|
365867
366164
|
schema: exports_Schema2.Struct({
|
|
365868
366165
|
id: exports_Schema2.String,
|
|
365869
366166
|
parentId: exports_Schema2.optional(exports_Schema2.String),
|
|
366167
|
+
cwd: exports_Schema2.optional(exports_Schema2.String),
|
|
365870
366168
|
createdAt: exports_Schema2.Date,
|
|
365871
366169
|
initMessage: exports_Schema2.optional(exports_Schema2.Struct({
|
|
365872
366170
|
id: exports_Schema2.String,
|
|
@@ -365919,15 +366217,24 @@ var events = {
|
|
|
365919
366217
|
title: exports_Schema2.String,
|
|
365920
366218
|
updatedAt: exports_Schema2.Date
|
|
365921
366219
|
})
|
|
366220
|
+
}),
|
|
366221
|
+
updateIsPublicShared: exports_events.synced({
|
|
366222
|
+
name: "v1.UpdateIsPublicShared",
|
|
366223
|
+
schema: exports_Schema2.Struct({
|
|
366224
|
+
id: exports_Schema2.String,
|
|
366225
|
+
isPublicShared: exports_Schema2.Boolean,
|
|
366226
|
+
updatedAt: exports_Schema2.Date
|
|
366227
|
+
})
|
|
365922
366228
|
})
|
|
365923
366229
|
};
|
|
365924
366230
|
var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
365925
|
-
"v1.TaskInited": ({ id: id4, parentId, createdAt, initMessage }) => [
|
|
366231
|
+
"v1.TaskInited": ({ id: id4, parentId, createdAt, cwd, initMessage }) => [
|
|
365926
366232
|
tables.tasks.insert({
|
|
365927
366233
|
id: id4,
|
|
365928
366234
|
status: initMessage ? "pending-model" : "pending-input",
|
|
365929
366235
|
parentId,
|
|
365930
366236
|
createdAt,
|
|
366237
|
+
cwd,
|
|
365931
366238
|
updatedAt: createdAt
|
|
365932
366239
|
}),
|
|
365933
366240
|
...initMessage ? [
|
|
@@ -365984,15 +366291,17 @@ var materializers2 = exports_mod4.SQLite.materializers(events, {
|
|
|
365984
366291
|
] : []
|
|
365985
366292
|
],
|
|
365986
366293
|
"v1.UpdateShareId": ({ id: id4, shareId, updatedAt }) => tables.tasks.update({ shareId, updatedAt }).where({ id: id4, shareId: null }),
|
|
365987
|
-
"v1.UpdateTitle": ({ id: id4, title, updatedAt }) => tables.tasks.update({ title, updatedAt }).where({ id: id4 })
|
|
366294
|
+
"v1.UpdateTitle": ({ id: id4, title, updatedAt }) => tables.tasks.update({ title, updatedAt }).where({ id: id4 }),
|
|
366295
|
+
"v1.UpdateIsPublicShared": ({ id: id4, isPublicShared, updatedAt }) => tables.tasks.update({ isPublicShared, updatedAt }).where({ id: id4 })
|
|
365988
366296
|
});
|
|
365989
366297
|
var state = exports_mod4.SQLite.makeState({ tables, materializers: materializers2 });
|
|
365990
366298
|
var schema6 = makeSchema({ events, state });
|
|
365991
366299
|
// ../livekit/src/livestore/queries.ts
|
|
365992
366300
|
var exports_queries = {};
|
|
365993
366301
|
__export(exports_queries, {
|
|
365994
|
-
|
|
366302
|
+
makeTasksQuery: () => makeTasksQuery,
|
|
365995
366303
|
makeTaskQuery: () => makeTaskQuery,
|
|
366304
|
+
makeSubTaskQuery: () => makeSubTaskQuery,
|
|
365996
366305
|
makeMessagesQuery: () => makeMessagesQuery
|
|
365997
366306
|
});
|
|
365998
366307
|
var makeTaskQuery = (taskId) => queryDb(() => tables.tasks.where("id", "=", taskId).first({ behaviour: "undefined" }), {
|
|
@@ -366003,11 +366312,16 @@ var makeMessagesQuery = (taskId) => queryDb(() => tables.messages.where("taskId"
|
|
|
366003
366312
|
label: "messages",
|
|
366004
366313
|
deps: [taskId]
|
|
366005
366314
|
});
|
|
366006
|
-
var
|
|
366007
|
-
|
|
366008
|
-
|
|
366315
|
+
var makeTasksQuery = (cwd) => queryDb(() => {
|
|
366316
|
+
const q = tables.tasks.where("parentId", "=", null).orderBy("updatedAt", "desc");
|
|
366317
|
+
return cwd ? q.where("cwd", "=", cwd) : q;
|
|
366009
366318
|
}, {
|
|
366010
|
-
label: "tasks"
|
|
366319
|
+
label: "tasks",
|
|
366320
|
+
deps: [cwd]
|
|
366321
|
+
});
|
|
366322
|
+
var makeSubTaskQuery = (taskId) => queryDb(() => tables.tasks.where("parentId", "=", taskId), {
|
|
366323
|
+
label: "subTasks",
|
|
366324
|
+
deps: [taskId]
|
|
366011
366325
|
});
|
|
366012
366326
|
// ../../node_modules/@livestore/adapter-node/dist/client-session/adapter.js
|
|
366013
366327
|
init_dist2();
|
|
@@ -373783,9 +374097,9 @@ var makeWsSync = (options4) => ({ storeId, payload }) => exports_Effect2.gen(fun
|
|
|
373783
374097
|
|
|
373784
374098
|
// src/livekit/store.ts
|
|
373785
374099
|
var import_node_machine_id = __toESM(require_dist3(), 1);
|
|
373786
|
-
async function createStore3(
|
|
374100
|
+
async function createStore3() {
|
|
373787
374101
|
const { jwt: jwt2 = null } = await getPochiCredentials2() || {};
|
|
373788
|
-
const storeId = await getStoreId(jwt2
|
|
374102
|
+
const storeId = await getStoreId(jwt2);
|
|
373789
374103
|
const adapter4 = makeAdapter({
|
|
373790
374104
|
storage: {
|
|
373791
374105
|
type: "fs",
|
|
@@ -373815,10 +374129,10 @@ async function getPochiCredentials2() {
|
|
|
373815
374129
|
const credentials = await pochi.getCredentials().catch(() => null);
|
|
373816
374130
|
return credentials;
|
|
373817
374131
|
}
|
|
373818
|
-
async function getStoreId(jwt2
|
|
374132
|
+
async function getStoreId(jwt2) {
|
|
373819
374133
|
const sub = (jwt2 ? decodeJwt(jwt2).sub : undefined) ?? "anonymous";
|
|
373820
374134
|
const date8 = new Date().toLocaleDateString("en-US");
|
|
373821
|
-
return encodeStoreId({ sub, machineId: await import_node_machine_id.machineId(),
|
|
374135
|
+
return encodeStoreId({ sub, machineId: await import_node_machine_id.machineId(), date: date8 });
|
|
373822
374136
|
}
|
|
373823
374137
|
|
|
373824
374138
|
// src/mcp/list.ts
|
|
@@ -387413,9 +387727,9 @@ init_effect();
|
|
|
387413
387727
|
import os10 from "node:os";
|
|
387414
387728
|
import path21 from "node:path";
|
|
387415
387729
|
var import_node_machine_id2 = __toESM(require_dist3(), 1);
|
|
387416
|
-
async function createStore4(
|
|
387730
|
+
async function createStore4() {
|
|
387417
387731
|
const { jwt: jwt2 = null } = await getPochiCredentials3() || {};
|
|
387418
|
-
const storeId = await getStoreId2(jwt2
|
|
387732
|
+
const storeId = await getStoreId2(jwt2);
|
|
387419
387733
|
const adapter4 = makeAdapter({
|
|
387420
387734
|
storage: {
|
|
387421
387735
|
type: "fs",
|
|
@@ -387445,10 +387759,10 @@ async function getPochiCredentials3() {
|
|
|
387445
387759
|
const credentials = await pochi.getCredentials().catch(() => null);
|
|
387446
387760
|
return credentials;
|
|
387447
387761
|
}
|
|
387448
|
-
async function getStoreId2(jwt2
|
|
387762
|
+
async function getStoreId2(jwt2) {
|
|
387449
387763
|
const sub = (jwt2 ? decodeJwt(jwt2).sub : undefined) ?? "anonymous";
|
|
387450
387764
|
const date8 = new Date().toLocaleDateString("en-US");
|
|
387451
|
-
return encodeStoreId({ sub, machineId: await import_node_machine_id2.machineId(),
|
|
387765
|
+
return encodeStoreId({ sub, machineId: await import_node_machine_id2.machineId(), date: date8 });
|
|
387452
387766
|
}
|
|
387453
387767
|
// src/livekit/chat.node.ts
|
|
387454
387768
|
class NodeChatState {
|
|
@@ -387512,7 +387826,7 @@ class Chat extends AbstractChat {
|
|
|
387512
387826
|
}
|
|
387513
387827
|
}
|
|
387514
387828
|
// src/lib/store-utils.ts
|
|
387515
|
-
var
|
|
387829
|
+
var logger16 = getLogger("Shutdown");
|
|
387516
387830
|
async function shutdownStoreAndExit2(store) {
|
|
387517
387831
|
try {
|
|
387518
387832
|
await Promise.race([
|
|
@@ -387523,7 +387837,7 @@ async function shutdownStoreAndExit2(store) {
|
|
|
387523
387837
|
]);
|
|
387524
387838
|
process.exit(0);
|
|
387525
387839
|
} catch (error44) {
|
|
387526
|
-
|
|
387840
|
+
logger16.warn("Store shutdown failed", error44);
|
|
387527
387841
|
process.exit(1);
|
|
387528
387842
|
}
|
|
387529
387843
|
}
|
|
@@ -387535,9 +387849,9 @@ function registerTaskListCommand(taskCommand) {
|
|
|
387535
387849
|
if (Number.isNaN(limit) || limit <= 0) {
|
|
387536
387850
|
return taskCommand.error("Limit must be a positive number");
|
|
387537
387851
|
}
|
|
387538
|
-
const store = await createStore4(
|
|
387852
|
+
const store = await createStore4();
|
|
387539
387853
|
try {
|
|
387540
|
-
const allTasks = store.query(exports_livestore.queries.
|
|
387854
|
+
const allTasks = store.query(exports_livestore.queries.makeTasksQuery(process.cwd()));
|
|
387541
387855
|
const sortedTasks = [...allTasks].sort((a11, b10) => b10.updatedAt.getTime() - a11.updatedAt.getTime());
|
|
387542
387856
|
const tasks = sortedTasks.slice(0, limit);
|
|
387543
387857
|
if (tasks.length === 0) {
|
|
@@ -387653,7 +387967,7 @@ function clipTitle(title, maxLength2) {
|
|
|
387653
387967
|
// src/task/share.ts
|
|
387654
387968
|
function registerTaskShareCommand(taskCommand) {
|
|
387655
387969
|
taskCommand.command("get-share-url").description("Get the shareable URL for a specific task by its ID.").argument("<task-id>", "The ID of the task to get the share URL for.").action(async (taskId) => {
|
|
387656
|
-
const store = await createStore4(
|
|
387970
|
+
const store = await createStore4();
|
|
387657
387971
|
const { shareId } = store.query(exports_livestore.queries.makeTaskQuery(taskId)) || {};
|
|
387658
387972
|
if (shareId) {
|
|
387659
387973
|
const shareUrl = `https://app.getpochi.com/share/${shareId}`;
|
|
@@ -387674,7 +387988,7 @@ function registerTaskCommand(program5) {
|
|
|
387674
387988
|
return taskCommand;
|
|
387675
387989
|
}
|
|
387676
387990
|
async function waitForSync() {
|
|
387677
|
-
const store = await createStore4(
|
|
387991
|
+
const store = await createStore4();
|
|
387678
387992
|
await exports_Effect2.gen(function* (_8) {
|
|
387679
387993
|
while (true) {
|
|
387680
387994
|
const nextChange = store.syncProcessor.syncState.changes.pipe(exports_Stream2.take(1), exports_Stream2.runCollect, exports_Effect2.as(false));
|
|
@@ -387744,12 +388058,12 @@ function toTaskError(error44) {
|
|
|
387744
388058
|
}
|
|
387745
388059
|
|
|
387746
388060
|
// ../livekit/src/chat/llm/generate-task-title.ts
|
|
387747
|
-
var
|
|
388061
|
+
var logger17 = getLogger("generateTaskTitle");
|
|
387748
388062
|
async function generateTaskTitle(options4) {
|
|
387749
388063
|
const { title } = options4;
|
|
387750
388064
|
const newTitle = await generateTaskTitleImpl(options4);
|
|
387751
388065
|
if (newTitle !== undefined) {
|
|
387752
|
-
|
|
388066
|
+
logger17.debug(`Generating task title, old: ${title}, new: ${newTitle}`);
|
|
387753
388067
|
}
|
|
387754
388068
|
return newTitle;
|
|
387755
388069
|
}
|
|
@@ -387776,7 +388090,7 @@ async function generateTaskTitleImpl({
|
|
|
387776
388090
|
return title2;
|
|
387777
388091
|
}
|
|
387778
388092
|
} catch (err2) {
|
|
387779
|
-
|
|
388093
|
+
logger17.warn("Failed to generate title", err2);
|
|
387780
388094
|
}
|
|
387781
388095
|
}
|
|
387782
388096
|
if (title === null) {
|
|
@@ -387822,7 +388136,7 @@ async function generateTitle2(model3, inputMessages, abortSignal) {
|
|
|
387822
388136
|
}
|
|
387823
388137
|
|
|
387824
388138
|
// ../livekit/src/chat/background-job/manager.ts
|
|
387825
|
-
var
|
|
388139
|
+
var logger18 = getLogger("BackgroundJobManager");
|
|
387826
388140
|
|
|
387827
388141
|
class BackgroundJobManager {
|
|
387828
388142
|
jobs = Promise.resolve();
|
|
@@ -387836,7 +388150,7 @@ class BackgroundJobManager {
|
|
|
387836
388150
|
}
|
|
387837
388151
|
this.pendingJobs.delete(nextJob.id);
|
|
387838
388152
|
return nextJob.process().catch((error44) => {
|
|
387839
|
-
|
|
388153
|
+
logger18.error(`Failed to process job for task ${nextJob.id}`, error44);
|
|
387840
388154
|
});
|
|
387841
388155
|
});
|
|
387842
388156
|
job.waitUntil?.(this.jobs);
|
|
@@ -387845,7 +388159,7 @@ class BackgroundJobManager {
|
|
|
387845
388159
|
var backgroundJobManager = new BackgroundJobManager;
|
|
387846
388160
|
|
|
387847
388161
|
// ../livekit/src/chat/background-job/generate-title.ts
|
|
387848
|
-
var
|
|
388162
|
+
var logger19 = getLogger("GenerateTitleManager");
|
|
387849
388163
|
function scheduleGenerateTitleJob(job) {
|
|
387850
388164
|
backgroundJobManager.push({
|
|
387851
388165
|
id: `generate-title-${job.taskId}`,
|
|
@@ -387861,7 +388175,7 @@ async function process15({
|
|
|
387861
388175
|
}) {
|
|
387862
388176
|
const task = store.query(makeTaskQuery(taskId));
|
|
387863
388177
|
if (!task) {
|
|
387864
|
-
|
|
388178
|
+
logger19.warn(`Task not found for title generation: ${taskId}`);
|
|
387865
388179
|
return;
|
|
387866
388180
|
}
|
|
387867
388181
|
const newTitle = await generateTaskTitle({
|
|
@@ -387878,7 +388192,7 @@ async function process15({
|
|
|
387878
388192
|
}
|
|
387879
388193
|
}
|
|
387880
388194
|
// ../livekit/src/chat/llm/repair-tool-call.ts
|
|
387881
|
-
var
|
|
388195
|
+
var logger20 = getLogger("RepairToolCall");
|
|
387882
388196
|
var makeRepairToolCall = (model3) => async ({ toolCall, inputSchema, error: error44 }) => {
|
|
387883
388197
|
if (NoSuchToolError.isInstance(error44)) {
|
|
387884
388198
|
return null;
|
|
@@ -387922,11 +388236,11 @@ var makeRepairToolCall = (model3) => async ({ toolCall, inputSchema, error: erro
|
|
|
387922
388236
|
maxRetries: 0
|
|
387923
388237
|
});
|
|
387924
388238
|
const input2 = await result2.text;
|
|
387925
|
-
|
|
388239
|
+
logger20.debug("Repairing tool call:", toolCall.toolName, input2);
|
|
387926
388240
|
return { ...toolCall, input: input2 };
|
|
387927
388241
|
};
|
|
387928
388242
|
// ../livekit/src/chat/llm/compact-task.ts
|
|
387929
|
-
var
|
|
388243
|
+
var logger21 = getLogger("compactTask");
|
|
387930
388244
|
async function compactTask({
|
|
387931
388245
|
model: model3,
|
|
387932
388246
|
messages: messages2,
|
|
@@ -387948,7 +388262,7 @@ async function compactTask({
|
|
|
387948
388262
|
}
|
|
387949
388263
|
return text12;
|
|
387950
388264
|
} catch (err2) {
|
|
387951
|
-
|
|
388265
|
+
logger21.warn("Failed to create summary", err2);
|
|
387952
388266
|
}
|
|
387953
388267
|
}
|
|
387954
388268
|
async function createSummary(model3, abortSignal, inputMessages) {
|
|
@@ -388140,7 +388454,7 @@ function createReasoningMiddleware(tag9 = "think") {
|
|
|
388140
388454
|
};
|
|
388141
388455
|
}
|
|
388142
388456
|
// ../livekit/src/chat/middlewares/new-task-middleware.ts
|
|
388143
|
-
function createNewTaskMiddleware(store, parentTaskId, customAgents) {
|
|
388457
|
+
function createNewTaskMiddleware(store, cwd2, parentTaskId, customAgents) {
|
|
388144
388458
|
return {
|
|
388145
388459
|
middlewareVersion: "v2",
|
|
388146
388460
|
transformParams: async ({ params: params2 }) => {
|
|
@@ -388200,6 +388514,7 @@ function createNewTaskMiddleware(store, parentTaskId, customAgents) {
|
|
|
388200
388514
|
};
|
|
388201
388515
|
store.commit(events.taskInited({
|
|
388202
388516
|
id: uid,
|
|
388517
|
+
cwd: cwd2,
|
|
388203
388518
|
parentId: parentTaskId,
|
|
388204
388519
|
createdAt: new Date,
|
|
388205
388520
|
initMessage: {
|
|
@@ -389870,7 +390185,7 @@ function createOpenAICompatible(options4) {
|
|
|
389870
390185
|
}
|
|
389871
390186
|
|
|
389872
390187
|
// ../livekit/src/chat/models/openai.ts
|
|
389873
|
-
var
|
|
390188
|
+
var logger22 = getLogger("openai");
|
|
389874
390189
|
var OpenAIRequestParamsSchema = exports_external.object({
|
|
389875
390190
|
max_tokens: exports_external.number().positive().optional(),
|
|
389876
390191
|
max_completion_tokens: exports_external.number().positive().optional()
|
|
@@ -389919,7 +390234,7 @@ function overrideMaxOutputToken(body3) {
|
|
|
389919
390234
|
const json9 = JSON.parse(body3);
|
|
389920
390235
|
const result2 = OpenAIRequestParamsSchema.safeParse(json9);
|
|
389921
390236
|
if (!result2.success) {
|
|
389922
|
-
|
|
390237
|
+
logger22.error("OpenAI request body validation failed:", result2.error);
|
|
389923
390238
|
return;
|
|
389924
390239
|
}
|
|
389925
390240
|
const parsed = result2.data;
|
|
@@ -389928,7 +390243,7 @@ function overrideMaxOutputToken(body3) {
|
|
|
389928
390243
|
}
|
|
389929
390244
|
return JSON.stringify(parsed);
|
|
389930
390245
|
} catch (error44) {
|
|
389931
|
-
|
|
390246
|
+
logger22.error("Failed to parse OpenAI request body:", error44);
|
|
389932
390247
|
}
|
|
389933
390248
|
return;
|
|
389934
390249
|
}
|
|
@@ -389961,6 +390276,7 @@ class FlexibleChatTransport {
|
|
|
389961
390276
|
isCli;
|
|
389962
390277
|
store;
|
|
389963
390278
|
customAgent;
|
|
390279
|
+
cwd;
|
|
389964
390280
|
constructor(options4) {
|
|
389965
390281
|
this.onStart = options4.onStart;
|
|
389966
390282
|
this.getters = options4.getters;
|
|
@@ -389968,6 +390284,7 @@ class FlexibleChatTransport {
|
|
|
389968
390284
|
this.isCli = options4.isCli;
|
|
389969
390285
|
this.store = options4.store;
|
|
389970
390286
|
this.customAgent = overrideCustomAgentTools(options4.customAgent);
|
|
390287
|
+
this.cwd = options4.cwd;
|
|
389971
390288
|
}
|
|
389972
390289
|
sendMessages = async ({
|
|
389973
390290
|
chatId,
|
|
@@ -389986,7 +390303,7 @@ class FlexibleChatTransport {
|
|
|
389986
390303
|
});
|
|
389987
390304
|
const middlewares = [];
|
|
389988
390305
|
if (!this.isSubTask) {
|
|
389989
|
-
middlewares.push(createNewTaskMiddleware(this.store, chatId, customAgents));
|
|
390306
|
+
middlewares.push(createNewTaskMiddleware(this.store, this.cwd, chatId, customAgents));
|
|
389990
390307
|
}
|
|
389991
390308
|
if ("modelId" in llm && isWellKnownReasoningModel(llm.modelId)) {
|
|
389992
390309
|
middlewares.push(createReasoningMiddleware());
|
|
@@ -390078,16 +390395,18 @@ function estimateTotalTokens(messages2) {
|
|
|
390078
390395
|
}
|
|
390079
390396
|
|
|
390080
390397
|
// ../livekit/src/chat/live-chat-kit.ts
|
|
390081
|
-
var
|
|
390398
|
+
var logger23 = getLogger("LiveChatKit");
|
|
390082
390399
|
|
|
390083
390400
|
class LiveChatKit {
|
|
390084
390401
|
taskId;
|
|
390085
390402
|
store;
|
|
390086
390403
|
chat;
|
|
390087
390404
|
transport;
|
|
390405
|
+
cwd;
|
|
390088
390406
|
spawn;
|
|
390089
390407
|
constructor({
|
|
390090
390408
|
taskId,
|
|
390409
|
+
cwd: cwd2,
|
|
390091
390410
|
abortSignal,
|
|
390092
390411
|
store,
|
|
390093
390412
|
chatClass,
|
|
@@ -390099,6 +390418,7 @@ class LiveChatKit {
|
|
|
390099
390418
|
...chatInit
|
|
390100
390419
|
}) {
|
|
390101
390420
|
this.taskId = taskId;
|
|
390421
|
+
this.cwd = cwd2;
|
|
390102
390422
|
this.store = store;
|
|
390103
390423
|
this.transport = new FlexibleChatTransport({
|
|
390104
390424
|
store,
|
|
@@ -390106,7 +390426,8 @@ class LiveChatKit {
|
|
|
390106
390426
|
getters,
|
|
390107
390427
|
isSubTask,
|
|
390108
390428
|
isCli,
|
|
390109
|
-
customAgent
|
|
390429
|
+
customAgent,
|
|
390430
|
+
cwd: cwd2
|
|
390110
390431
|
});
|
|
390111
390432
|
this.chat = new chatClass({
|
|
390112
390433
|
...chatInit,
|
|
@@ -390134,7 +390455,7 @@ class LiveChatKit {
|
|
|
390134
390455
|
inline: true
|
|
390135
390456
|
});
|
|
390136
390457
|
} catch (err2) {
|
|
390137
|
-
|
|
390458
|
+
logger23.error("Failed to compact task", err2);
|
|
390138
390459
|
throw err2;
|
|
390139
390460
|
}
|
|
390140
390461
|
}
|
|
@@ -390156,6 +390477,7 @@ class LiveChatKit {
|
|
|
390156
390477
|
}
|
|
390157
390478
|
this.store.commit(events.taskInited({
|
|
390158
390479
|
id: taskId2,
|
|
390480
|
+
cwd: this.cwd,
|
|
390159
390481
|
createdAt: new Date,
|
|
390160
390482
|
initMessage: {
|
|
390161
390483
|
id: crypto.randomUUID(),
|
|
@@ -390177,6 +390499,7 @@ class LiveChatKit {
|
|
|
390177
390499
|
init(prompt) {
|
|
390178
390500
|
this.store.commit(events.taskInited({
|
|
390179
390501
|
id: this.taskId,
|
|
390502
|
+
cwd: this.cwd,
|
|
390180
390503
|
createdAt: new Date,
|
|
390181
390504
|
initMessage: {
|
|
390182
390505
|
id: crypto.randomUUID(),
|
|
@@ -390200,6 +390523,13 @@ class LiveChatKit {
|
|
|
390200
390523
|
const countTask = this.store.query(tables.tasks.where("id", "=", this.taskId).count());
|
|
390201
390524
|
return countTask > 0;
|
|
390202
390525
|
}
|
|
390526
|
+
updateIsPublicShared = (isPublicShared) => {
|
|
390527
|
+
this.store.commit(events.updateIsPublicShared({
|
|
390528
|
+
id: this.taskId,
|
|
390529
|
+
isPublicShared,
|
|
390530
|
+
updatedAt: new Date
|
|
390531
|
+
}));
|
|
390532
|
+
};
|
|
390203
390533
|
onStart = async ({
|
|
390204
390534
|
messages: messages2,
|
|
390205
390535
|
environment: environment2,
|
|
@@ -390211,6 +390541,7 @@ class LiveChatKit {
|
|
|
390211
390541
|
if (!this.inited) {
|
|
390212
390542
|
store.commit(events.taskInited({
|
|
390213
390543
|
id: this.taskId,
|
|
390544
|
+
cwd: this.cwd,
|
|
390214
390545
|
createdAt: new Date
|
|
390215
390546
|
}));
|
|
390216
390547
|
}
|
|
@@ -390254,7 +390585,7 @@ class LiveChatKit {
|
|
|
390254
390585
|
}));
|
|
390255
390586
|
};
|
|
390256
390587
|
onError = (error44) => {
|
|
390257
|
-
|
|
390588
|
+
logger23.error("onError", error44);
|
|
390258
390589
|
const lastMessage = this.chat.messages.at(-1) || null;
|
|
390259
390590
|
this.store.commit(events.chatStreamFailed({
|
|
390260
390591
|
id: this.taskId,
|
|
@@ -390347,7 +390678,7 @@ import * as nodePath from "node:path";
|
|
|
390347
390678
|
|
|
390348
390679
|
// ../common/src/diff-utils.ts
|
|
390349
390680
|
var import_fast_levenshtein = __toESM(require_levenshtein(), 1);
|
|
390350
|
-
var
|
|
390681
|
+
var logger24 = getLogger("diffUtils");
|
|
390351
390682
|
function normalize6(content3) {
|
|
390352
390683
|
return content3.replace(/\r\n/g, `
|
|
390353
390684
|
`).trimEnd();
|
|
@@ -390360,7 +390691,7 @@ class DiffError extends Error {
|
|
|
390360
390691
|
}
|
|
390361
390692
|
}
|
|
390362
390693
|
async function parseDiffAndApply(fileContent, searchContent, replaceContent, expectedReplacements = 1) {
|
|
390363
|
-
|
|
390694
|
+
logger24.trace(`Applying diff with expectedReplacements: ${expectedReplacements}`);
|
|
390364
390695
|
const isCRLF = fileContent.includes(`\r
|
|
390365
390696
|
`);
|
|
390366
390697
|
const normalizedFileContent = normalize6(fileContent);
|
|
@@ -390377,11 +390708,11 @@ async function parseDiffAndApply(fileContent, searchContent, replaceContent, exp
|
|
|
390377
390708
|
const matches2 = searchContentExact(normalizedFileContent, normalizedSearchContent);
|
|
390378
390709
|
if (matches2.length < expectedReplacements) {
|
|
390379
390710
|
matches2.push(...searchContentWithLineTrimmed(normalizedFileContent, normalizedSearchContent));
|
|
390380
|
-
|
|
390711
|
+
logger24.trace(`Found ${matches2.length} matches after line trimming search strategy`);
|
|
390381
390712
|
}
|
|
390382
390713
|
if (matches2.length < expectedReplacements) {
|
|
390383
390714
|
matches2.push(...searchContentByBlockAnchor(normalizedFileContent, normalizedSearchContent));
|
|
390384
|
-
|
|
390715
|
+
logger24.trace(`Found ${matches2.length} matches after block anchor search strategy`);
|
|
390385
390716
|
}
|
|
390386
390717
|
if (matches2.length === 0) {
|
|
390387
390718
|
throw new DiffError("Search content does not match the file content. Try to reread the file for the latest content.");
|
|
@@ -390390,7 +390721,7 @@ async function parseDiffAndApply(fileContent, searchContent, replaceContent, exp
|
|
|
390390
390721
|
throw new DiffError(`Expected ${expectedReplacements} occurrences but found ${matches2.length}. Please verify the search content and expectedReplacements parameter.`);
|
|
390391
390722
|
}
|
|
390392
390723
|
const result2 = replaceMatches(normalizedFileContent, matches2, replaceContent);
|
|
390393
|
-
|
|
390724
|
+
logger24.trace("Successfully applied diff");
|
|
390394
390725
|
if (isCRLF) {
|
|
390395
390726
|
return result2.replace(/\n/g, `\r
|
|
390396
390727
|
`);
|
|
@@ -390744,11 +391075,11 @@ var readFile13 = (context15) => async ({ path: path24, startLine, endLine }) =>
|
|
|
390744
391075
|
|
|
390745
391076
|
// src/tools/search-files.ts
|
|
390746
391077
|
import * as fs14 from "node:fs";
|
|
390747
|
-
var
|
|
391078
|
+
var logger25 = getLogger("searchFiles");
|
|
390748
391079
|
var searchFiles2 = (context15) => async ({ path: path24, regex: regex3, filePattern }, { abortSignal }) => {
|
|
390749
391080
|
const rgPath = context15.rg;
|
|
390750
391081
|
if (!rgPath || !fs14.existsSync(rgPath)) {
|
|
390751
|
-
|
|
391082
|
+
logger25.error("Ripgrep not found at path", rgPath);
|
|
390752
391083
|
throw new Error(`Ripgrep not found at path: ${rgPath}`);
|
|
390753
391084
|
}
|
|
390754
391085
|
return await searchFilesWithRipgrep(path24, regex3, rgPath, context15.cwd, filePattern, abortSignal);
|
|
@@ -390819,7 +391150,7 @@ function toErrorString(e11) {
|
|
|
390819
391150
|
}
|
|
390820
391151
|
|
|
390821
391152
|
// src/task-runner.ts
|
|
390822
|
-
var
|
|
391153
|
+
var logger26 = getLogger("TaskRunner");
|
|
390823
391154
|
|
|
390824
391155
|
class TaskRunner {
|
|
390825
391156
|
toolCallOptions;
|
|
@@ -390853,6 +391184,7 @@ class TaskRunner {
|
|
|
390853
391184
|
this.stepCount = new StepCount(options4.maxSteps, options4.maxRetries);
|
|
390854
391185
|
this.chatKit = new LiveChatKit({
|
|
390855
391186
|
taskId: options4.uid,
|
|
391187
|
+
cwd: options4.cwd,
|
|
390856
391188
|
store: options4.store,
|
|
390857
391189
|
chatClass: Chat,
|
|
390858
391190
|
isCli: true,
|
|
@@ -390884,9 +391216,9 @@ class TaskRunner {
|
|
|
390884
391216
|
return this.chatKit.task?.shareId;
|
|
390885
391217
|
}
|
|
390886
391218
|
async run() {
|
|
390887
|
-
|
|
391219
|
+
logger26.debug("Starting TaskRunner...");
|
|
390888
391220
|
try {
|
|
390889
|
-
|
|
391221
|
+
logger26.trace("Start step loop.");
|
|
390890
391222
|
this.stepCount.reset();
|
|
390891
391223
|
while (true) {
|
|
390892
391224
|
const stepResult = await this.step();
|
|
@@ -390901,7 +391233,7 @@ class TaskRunner {
|
|
|
390901
391233
|
}
|
|
390902
391234
|
} catch (e11) {
|
|
390903
391235
|
const error44 = toError2(e11);
|
|
390904
|
-
|
|
391236
|
+
logger26.trace("Failed:", error44);
|
|
390905
391237
|
}
|
|
390906
391238
|
}
|
|
390907
391239
|
async step() {
|
|
@@ -390939,24 +391271,24 @@ class TaskRunner {
|
|
|
390939
391271
|
throw new Error("Task is not loaded");
|
|
390940
391272
|
}
|
|
390941
391273
|
if ((task.status === "completed" || task.status === "pending-input") && isResultMessage(message)) {
|
|
390942
|
-
|
|
391274
|
+
logger26.trace("Task is completed or pending input, no more steps to process.");
|
|
390943
391275
|
return "finished";
|
|
390944
391276
|
}
|
|
390945
391277
|
if (task.status === "failed") {
|
|
390946
391278
|
if (task.error?.kind === "APICallError" && !task.error.isRetryable) {
|
|
390947
391279
|
return "finished";
|
|
390948
391280
|
}
|
|
390949
|
-
|
|
391281
|
+
logger26.error("Task is failed, trying to resend last message to resume it.", task.error);
|
|
390950
391282
|
return "retry";
|
|
390951
391283
|
}
|
|
390952
391284
|
if (message.role !== "assistant") {
|
|
390953
|
-
|
|
391285
|
+
logger26.trace("Last message is not a assistant message, resending it to resume the task.");
|
|
390954
391286
|
return "retry";
|
|
390955
391287
|
}
|
|
390956
391288
|
if (isAssistantMessageWithEmptyParts(message) || isAssistantMessageWithPartialToolCalls(message) || isAssistantMessageWithOutputError(message) || lastAssistantMessageIsCompleteWithToolCalls({
|
|
390957
391289
|
messages: this.chat.messages
|
|
390958
391290
|
})) {
|
|
390959
|
-
|
|
391291
|
+
logger26.trace("Last message is assistant with empty parts or partial/completed tool calls, resending it to resume the task.");
|
|
390960
391292
|
const processed = prepareLastMessageForRetry(message);
|
|
390961
391293
|
if (processed) {
|
|
390962
391294
|
this.chat.appendOrReplaceMessage(processed);
|
|
@@ -390964,28 +391296,28 @@ class TaskRunner {
|
|
|
390964
391296
|
return "retry";
|
|
390965
391297
|
}
|
|
390966
391298
|
if (isAssistantMessageWithNoToolCalls(message)) {
|
|
390967
|
-
|
|
391299
|
+
logger26.trace("Last message is assistant with no tool calls, sending a new user reminder.");
|
|
390968
391300
|
const message2 = createUserMessage(prompts.createSystemReminder("You should use tool calls to answer the question, for example, use attemptCompletion if the job is done, or use askFollowupQuestions to clarify the request."));
|
|
390969
391301
|
this.chat.appendOrReplaceMessage(message2);
|
|
390970
391302
|
return "next";
|
|
390971
391303
|
}
|
|
390972
391304
|
}
|
|
390973
391305
|
async processToolCalls(message) {
|
|
390974
|
-
|
|
391306
|
+
logger26.trace("Processing tool calls in the last message.");
|
|
390975
391307
|
for (const toolCall of message.parts.filter(isToolUIPart)) {
|
|
390976
391308
|
if (toolCall.state !== "input-available")
|
|
390977
391309
|
continue;
|
|
390978
391310
|
const toolName = getToolName(toolCall);
|
|
390979
|
-
|
|
391311
|
+
logger26.trace(`Found tool call: ${toolName} with args: ${JSON.stringify(toolCall.input)}`);
|
|
390980
391312
|
const toolResult = await executeToolCall(toolCall, this.toolCallOptions);
|
|
390981
391313
|
this.chatKit.chat.addToolResult({
|
|
390982
391314
|
tool: toolName,
|
|
390983
391315
|
toolCallId: toolCall.toolCallId,
|
|
390984
391316
|
output: toolResult
|
|
390985
391317
|
});
|
|
390986
|
-
|
|
391318
|
+
logger26.trace(`Tool call result: ${JSON.stringify(toolResult)}`);
|
|
390987
391319
|
}
|
|
390988
|
-
|
|
391320
|
+
logger26.trace("All tool calls processed in the last message.");
|
|
390989
391321
|
return "next";
|
|
390990
391322
|
}
|
|
390991
391323
|
}
|
|
@@ -391210,7 +391542,7 @@ async function downloadAndInstall(program5, release2) {
|
|
|
391210
391542
|
// package.json
|
|
391211
391543
|
var package_default2 = {
|
|
391212
391544
|
name: "@getpochi/cli",
|
|
391213
|
-
version: "0.5.
|
|
391545
|
+
version: "0.5.30",
|
|
391214
391546
|
type: "module",
|
|
391215
391547
|
bin: {
|
|
391216
391548
|
pochi: "src/cli.ts"
|
|
@@ -391326,8 +391658,8 @@ function registerUpgradeCommand(program5) {
|
|
|
391326
391658
|
});
|
|
391327
391659
|
}
|
|
391328
391660
|
// src/cli.ts
|
|
391329
|
-
var
|
|
391330
|
-
|
|
391661
|
+
var logger27 = getLogger("Pochi");
|
|
391662
|
+
logger27.debug(`pochi v${package_default.version}`);
|
|
391331
391663
|
var parsePositiveInt = (input2) => {
|
|
391332
391664
|
if (!input2) {
|
|
391333
391665
|
return program5.error("The value for this option must be a positive integer.");
|
|
@@ -391340,7 +391672,7 @@ var parsePositiveInt = (input2) => {
|
|
|
391340
391672
|
};
|
|
391341
391673
|
var program5 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`. Workflows can be triggered with `/workflow-name`, like `pochi -p /create-pr`.").optionsGroup("Options:").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "qwen/qwen3-coder").action(async (options4) => {
|
|
391342
391674
|
const { uid, prompt } = await parseTaskInput(options4, program5);
|
|
391343
|
-
const store = await createStore3(
|
|
391675
|
+
const store = await createStore3();
|
|
391344
391676
|
const llm = await createLLMConfig(program5, options4);
|
|
391345
391677
|
const rg2 = findRipgrep();
|
|
391346
391678
|
if (!rg2) {
|