chatroom-cli 1.35.1 → 1.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2968 -231
- package/dist/index.js.map +57 -17
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -10503,7 +10503,7 @@ class PiRpcReader {
|
|
|
10503
10503
|
var init_pi_rpc_reader = () => {};
|
|
10504
10504
|
|
|
10505
10505
|
// src/infrastructure/services/remote-agents/pi/pi-agent-service.ts
|
|
10506
|
-
var PI_COMMAND = "pi",
|
|
10506
|
+
var PI_COMMAND = "pi", PiAgentService;
|
|
10507
10507
|
var init_pi_agent_service = __esm(() => {
|
|
10508
10508
|
init_base_cli_agent_service();
|
|
10509
10509
|
init_pi_rpc_reader();
|
|
@@ -10549,8 +10549,7 @@ var init_pi_agent_service = __esm(() => {
|
|
|
10549
10549
|
}
|
|
10550
10550
|
}
|
|
10551
10551
|
async spawn(options) {
|
|
10552
|
-
const { systemPrompt, model } = options;
|
|
10553
|
-
const prompt = options.prompt?.trim() ? options.prompt : DEFAULT_TRIGGER_PROMPT;
|
|
10552
|
+
const { prompt, systemPrompt, model } = options;
|
|
10554
10553
|
const args = ["--mode", "rpc", "--no-session"];
|
|
10555
10554
|
if (model) {
|
|
10556
10555
|
args.push("--model", model);
|
|
@@ -11040,7 +11039,7 @@ var init_copilot_stream_reader = __esm(() => {
|
|
|
11040
11039
|
});
|
|
11041
11040
|
|
|
11042
11041
|
// src/infrastructure/services/remote-agents/copilot/copilot-agent-service.ts
|
|
11043
|
-
var COPILOT_COMMAND = "copilot",
|
|
11042
|
+
var COPILOT_COMMAND = "copilot", CopilotAgentService;
|
|
11044
11043
|
var init_copilot_agent_service = __esm(() => {
|
|
11045
11044
|
init_base_cli_agent_service();
|
|
11046
11045
|
init_copilot_stream_reader();
|
|
@@ -11072,7 +11071,7 @@ var init_copilot_agent_service = __esm(() => {
|
|
|
11072
11071
|
];
|
|
11073
11072
|
}
|
|
11074
11073
|
async spawn(options) {
|
|
11075
|
-
const prompt = options
|
|
11074
|
+
const { prompt } = options;
|
|
11076
11075
|
const args = ["-p"];
|
|
11077
11076
|
args.push("--stream", "on");
|
|
11078
11077
|
if (options.model) {
|
|
@@ -11228,7 +11227,7 @@ class ClaudeStreamReader {
|
|
|
11228
11227
|
var init_claude_stream_reader = () => {};
|
|
11229
11228
|
|
|
11230
11229
|
// src/infrastructure/services/remote-agents/claude/claude-code-agent-service.ts
|
|
11231
|
-
var
|
|
11230
|
+
var CLAUDE_COMMAND = "claude", DEFAULT_MAX_TURNS = 200, ClaudeCodeAgentService;
|
|
11232
11231
|
var init_claude_code_agent_service = __esm(() => {
|
|
11233
11232
|
init_base_cli_agent_service();
|
|
11234
11233
|
init_claude_stream_reader();
|
|
@@ -11249,8 +11248,7 @@ var init_claude_code_agent_service = __esm(() => {
|
|
|
11249
11248
|
return ["claude-haiku-4-5", "claude-sonnet-4-6", "claude-opus-4-6"];
|
|
11250
11249
|
}
|
|
11251
11250
|
async spawn(options) {
|
|
11252
|
-
const { systemPrompt, model } = options;
|
|
11253
|
-
const prompt = options.prompt?.trim() ? options.prompt : DEFAULT_TRIGGER_PROMPT3;
|
|
11251
|
+
const { prompt, systemPrompt, model } = options;
|
|
11254
11252
|
const args = ["-p", "--output-format", "stream-json", "--verbose"];
|
|
11255
11253
|
args.push("--max-turns", String(DEFAULT_MAX_TURNS));
|
|
11256
11254
|
if (model) {
|
|
@@ -11380,11 +11378,2333 @@ var init_claude = __esm(() => {
|
|
|
11380
11378
|
init_claude_code_agent_service();
|
|
11381
11379
|
});
|
|
11382
11380
|
|
|
11381
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/types.gen.js
|
|
11382
|
+
var init_types_gen = () => {};
|
|
11383
|
+
|
|
11384
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/serverSentEvents.gen.js
|
|
11385
|
+
var createSseClient = ({ onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
11386
|
+
let lastEventId;
|
|
11387
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
11388
|
+
const createStream = async function* () {
|
|
11389
|
+
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
11390
|
+
let attempt = 0;
|
|
11391
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
11392
|
+
while (true) {
|
|
11393
|
+
if (signal.aborted)
|
|
11394
|
+
break;
|
|
11395
|
+
attempt++;
|
|
11396
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
11397
|
+
if (lastEventId !== undefined) {
|
|
11398
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
11399
|
+
}
|
|
11400
|
+
try {
|
|
11401
|
+
const response = await fetch(url, { ...options, headers, signal });
|
|
11402
|
+
if (!response.ok)
|
|
11403
|
+
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
11404
|
+
if (!response.body)
|
|
11405
|
+
throw new Error("No body in SSE response");
|
|
11406
|
+
const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
|
|
11407
|
+
let buffer = "";
|
|
11408
|
+
const abortHandler = () => {
|
|
11409
|
+
try {
|
|
11410
|
+
reader.cancel();
|
|
11411
|
+
} catch {}
|
|
11412
|
+
};
|
|
11413
|
+
signal.addEventListener("abort", abortHandler);
|
|
11414
|
+
try {
|
|
11415
|
+
while (true) {
|
|
11416
|
+
const { done, value } = await reader.read();
|
|
11417
|
+
if (done)
|
|
11418
|
+
break;
|
|
11419
|
+
buffer += value;
|
|
11420
|
+
const chunks = buffer.split(`
|
|
11421
|
+
|
|
11422
|
+
`);
|
|
11423
|
+
buffer = chunks.pop() ?? "";
|
|
11424
|
+
for (const chunk of chunks) {
|
|
11425
|
+
const lines = chunk.split(`
|
|
11426
|
+
`);
|
|
11427
|
+
const dataLines = [];
|
|
11428
|
+
let eventName;
|
|
11429
|
+
for (const line of lines) {
|
|
11430
|
+
if (line.startsWith("data:")) {
|
|
11431
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
11432
|
+
} else if (line.startsWith("event:")) {
|
|
11433
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
11434
|
+
} else if (line.startsWith("id:")) {
|
|
11435
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
11436
|
+
} else if (line.startsWith("retry:")) {
|
|
11437
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
11438
|
+
if (!Number.isNaN(parsed)) {
|
|
11439
|
+
retryDelay = parsed;
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
}
|
|
11443
|
+
let data;
|
|
11444
|
+
let parsedJson = false;
|
|
11445
|
+
if (dataLines.length) {
|
|
11446
|
+
const rawData = dataLines.join(`
|
|
11447
|
+
`);
|
|
11448
|
+
try {
|
|
11449
|
+
data = JSON.parse(rawData);
|
|
11450
|
+
parsedJson = true;
|
|
11451
|
+
} catch {
|
|
11452
|
+
data = rawData;
|
|
11453
|
+
}
|
|
11454
|
+
}
|
|
11455
|
+
if (parsedJson) {
|
|
11456
|
+
if (responseValidator) {
|
|
11457
|
+
await responseValidator(data);
|
|
11458
|
+
}
|
|
11459
|
+
if (responseTransformer) {
|
|
11460
|
+
data = await responseTransformer(data);
|
|
11461
|
+
}
|
|
11462
|
+
}
|
|
11463
|
+
onSseEvent?.({
|
|
11464
|
+
data,
|
|
11465
|
+
event: eventName,
|
|
11466
|
+
id: lastEventId,
|
|
11467
|
+
retry: retryDelay
|
|
11468
|
+
});
|
|
11469
|
+
if (dataLines.length) {
|
|
11470
|
+
yield data;
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
}
|
|
11474
|
+
} finally {
|
|
11475
|
+
signal.removeEventListener("abort", abortHandler);
|
|
11476
|
+
reader.releaseLock();
|
|
11477
|
+
}
|
|
11478
|
+
break;
|
|
11479
|
+
} catch (error) {
|
|
11480
|
+
onSseError?.(error);
|
|
11481
|
+
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
11482
|
+
break;
|
|
11483
|
+
}
|
|
11484
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
11485
|
+
await sleep(backoff);
|
|
11486
|
+
}
|
|
11487
|
+
}
|
|
11488
|
+
};
|
|
11489
|
+
const stream = createStream();
|
|
11490
|
+
return { stream };
|
|
11491
|
+
};
|
|
11492
|
+
|
|
11493
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/auth.gen.js
|
|
11494
|
+
var getAuthToken = async (auth, callback) => {
|
|
11495
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
11496
|
+
if (!token) {
|
|
11497
|
+
return;
|
|
11498
|
+
}
|
|
11499
|
+
if (auth.scheme === "bearer") {
|
|
11500
|
+
return `Bearer ${token}`;
|
|
11501
|
+
}
|
|
11502
|
+
if (auth.scheme === "basic") {
|
|
11503
|
+
return `Basic ${btoa(token)}`;
|
|
11504
|
+
}
|
|
11505
|
+
return token;
|
|
11506
|
+
};
|
|
11507
|
+
|
|
11508
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/bodySerializer.gen.js
|
|
11509
|
+
var jsonBodySerializer;
|
|
11510
|
+
var init_bodySerializer_gen = __esm(() => {
|
|
11511
|
+
jsonBodySerializer = {
|
|
11512
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
11513
|
+
};
|
|
11514
|
+
});
|
|
11515
|
+
|
|
11516
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/pathSerializer.gen.js
|
|
11517
|
+
var separatorArrayExplode = (style) => {
|
|
11518
|
+
switch (style) {
|
|
11519
|
+
case "label":
|
|
11520
|
+
return ".";
|
|
11521
|
+
case "matrix":
|
|
11522
|
+
return ";";
|
|
11523
|
+
case "simple":
|
|
11524
|
+
return ",";
|
|
11525
|
+
default:
|
|
11526
|
+
return "&";
|
|
11527
|
+
}
|
|
11528
|
+
}, separatorArrayNoExplode = (style) => {
|
|
11529
|
+
switch (style) {
|
|
11530
|
+
case "form":
|
|
11531
|
+
return ",";
|
|
11532
|
+
case "pipeDelimited":
|
|
11533
|
+
return "|";
|
|
11534
|
+
case "spaceDelimited":
|
|
11535
|
+
return "%20";
|
|
11536
|
+
default:
|
|
11537
|
+
return ",";
|
|
11538
|
+
}
|
|
11539
|
+
}, separatorObjectExplode = (style) => {
|
|
11540
|
+
switch (style) {
|
|
11541
|
+
case "label":
|
|
11542
|
+
return ".";
|
|
11543
|
+
case "matrix":
|
|
11544
|
+
return ";";
|
|
11545
|
+
case "simple":
|
|
11546
|
+
return ",";
|
|
11547
|
+
default:
|
|
11548
|
+
return "&";
|
|
11549
|
+
}
|
|
11550
|
+
}, serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
11551
|
+
if (!explode) {
|
|
11552
|
+
const joinedValues2 = (allowReserved ? value : value.map((v3) => encodeURIComponent(v3))).join(separatorArrayNoExplode(style));
|
|
11553
|
+
switch (style) {
|
|
11554
|
+
case "label":
|
|
11555
|
+
return `.${joinedValues2}`;
|
|
11556
|
+
case "matrix":
|
|
11557
|
+
return `;${name}=${joinedValues2}`;
|
|
11558
|
+
case "simple":
|
|
11559
|
+
return joinedValues2;
|
|
11560
|
+
default:
|
|
11561
|
+
return `${name}=${joinedValues2}`;
|
|
11562
|
+
}
|
|
11563
|
+
}
|
|
11564
|
+
const separator = separatorArrayExplode(style);
|
|
11565
|
+
const joinedValues = value.map((v3) => {
|
|
11566
|
+
if (style === "label" || style === "simple") {
|
|
11567
|
+
return allowReserved ? v3 : encodeURIComponent(v3);
|
|
11568
|
+
}
|
|
11569
|
+
return serializePrimitiveParam({
|
|
11570
|
+
allowReserved,
|
|
11571
|
+
name,
|
|
11572
|
+
value: v3
|
|
11573
|
+
});
|
|
11574
|
+
}).join(separator);
|
|
11575
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
11576
|
+
}, serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
11577
|
+
if (value === undefined || value === null) {
|
|
11578
|
+
return "";
|
|
11579
|
+
}
|
|
11580
|
+
if (typeof value === "object") {
|
|
11581
|
+
throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
11582
|
+
}
|
|
11583
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
11584
|
+
}, serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
11585
|
+
if (value instanceof Date) {
|
|
11586
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
11587
|
+
}
|
|
11588
|
+
if (style !== "deepObject" && !explode) {
|
|
11589
|
+
let values = [];
|
|
11590
|
+
Object.entries(value).forEach(([key, v3]) => {
|
|
11591
|
+
values = [...values, key, allowReserved ? v3 : encodeURIComponent(v3)];
|
|
11592
|
+
});
|
|
11593
|
+
const joinedValues2 = values.join(",");
|
|
11594
|
+
switch (style) {
|
|
11595
|
+
case "form":
|
|
11596
|
+
return `${name}=${joinedValues2}`;
|
|
11597
|
+
case "label":
|
|
11598
|
+
return `.${joinedValues2}`;
|
|
11599
|
+
case "matrix":
|
|
11600
|
+
return `;${name}=${joinedValues2}`;
|
|
11601
|
+
default:
|
|
11602
|
+
return joinedValues2;
|
|
11603
|
+
}
|
|
11604
|
+
}
|
|
11605
|
+
const separator = separatorObjectExplode(style);
|
|
11606
|
+
const joinedValues = Object.entries(value).map(([key, v3]) => serializePrimitiveParam({
|
|
11607
|
+
allowReserved,
|
|
11608
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
11609
|
+
value: v3
|
|
11610
|
+
})).join(separator);
|
|
11611
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
11612
|
+
};
|
|
11613
|
+
|
|
11614
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/utils.gen.js
|
|
11615
|
+
var PATH_PARAM_RE, defaultPathSerializer = ({ path, url: _url }) => {
|
|
11616
|
+
let url = _url;
|
|
11617
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
11618
|
+
if (matches) {
|
|
11619
|
+
for (const match of matches) {
|
|
11620
|
+
let explode = false;
|
|
11621
|
+
let name = match.substring(1, match.length - 1);
|
|
11622
|
+
let style = "simple";
|
|
11623
|
+
if (name.endsWith("*")) {
|
|
11624
|
+
explode = true;
|
|
11625
|
+
name = name.substring(0, name.length - 1);
|
|
11626
|
+
}
|
|
11627
|
+
if (name.startsWith(".")) {
|
|
11628
|
+
name = name.substring(1);
|
|
11629
|
+
style = "label";
|
|
11630
|
+
} else if (name.startsWith(";")) {
|
|
11631
|
+
name = name.substring(1);
|
|
11632
|
+
style = "matrix";
|
|
11633
|
+
}
|
|
11634
|
+
const value = path[name];
|
|
11635
|
+
if (value === undefined || value === null) {
|
|
11636
|
+
continue;
|
|
11637
|
+
}
|
|
11638
|
+
if (Array.isArray(value)) {
|
|
11639
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
11640
|
+
continue;
|
|
11641
|
+
}
|
|
11642
|
+
if (typeof value === "object") {
|
|
11643
|
+
url = url.replace(match, serializeObjectParam({
|
|
11644
|
+
explode,
|
|
11645
|
+
name,
|
|
11646
|
+
style,
|
|
11647
|
+
value,
|
|
11648
|
+
valueOnly: true
|
|
11649
|
+
}));
|
|
11650
|
+
continue;
|
|
11651
|
+
}
|
|
11652
|
+
if (style === "matrix") {
|
|
11653
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
11654
|
+
name,
|
|
11655
|
+
value
|
|
11656
|
+
})}`);
|
|
11657
|
+
continue;
|
|
11658
|
+
}
|
|
11659
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
11660
|
+
url = url.replace(match, replaceValue);
|
|
11661
|
+
}
|
|
11662
|
+
}
|
|
11663
|
+
return url;
|
|
11664
|
+
}, getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
|
|
11665
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
11666
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
11667
|
+
if (path) {
|
|
11668
|
+
url = defaultPathSerializer({ path, url });
|
|
11669
|
+
}
|
|
11670
|
+
let search = query ? querySerializer(query) : "";
|
|
11671
|
+
if (search.startsWith("?")) {
|
|
11672
|
+
search = search.substring(1);
|
|
11673
|
+
}
|
|
11674
|
+
if (search) {
|
|
11675
|
+
url += `?${search}`;
|
|
11676
|
+
}
|
|
11677
|
+
return url;
|
|
11678
|
+
};
|
|
11679
|
+
var init_utils_gen = __esm(() => {
|
|
11680
|
+
PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
11681
|
+
});
|
|
11682
|
+
|
|
11683
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client/utils.gen.js
|
|
11684
|
+
class Interceptors {
|
|
11685
|
+
_fns;
|
|
11686
|
+
constructor() {
|
|
11687
|
+
this._fns = [];
|
|
11688
|
+
}
|
|
11689
|
+
clear() {
|
|
11690
|
+
this._fns = [];
|
|
11691
|
+
}
|
|
11692
|
+
getInterceptorIndex(id) {
|
|
11693
|
+
if (typeof id === "number") {
|
|
11694
|
+
return this._fns[id] ? id : -1;
|
|
11695
|
+
} else {
|
|
11696
|
+
return this._fns.indexOf(id);
|
|
11697
|
+
}
|
|
11698
|
+
}
|
|
11699
|
+
exists(id) {
|
|
11700
|
+
const index = this.getInterceptorIndex(id);
|
|
11701
|
+
return !!this._fns[index];
|
|
11702
|
+
}
|
|
11703
|
+
eject(id) {
|
|
11704
|
+
const index = this.getInterceptorIndex(id);
|
|
11705
|
+
if (this._fns[index]) {
|
|
11706
|
+
this._fns[index] = null;
|
|
11707
|
+
}
|
|
11708
|
+
}
|
|
11709
|
+
update(id, fn) {
|
|
11710
|
+
const index = this.getInterceptorIndex(id);
|
|
11711
|
+
if (this._fns[index]) {
|
|
11712
|
+
this._fns[index] = fn;
|
|
11713
|
+
return id;
|
|
11714
|
+
} else {
|
|
11715
|
+
return false;
|
|
11716
|
+
}
|
|
11717
|
+
}
|
|
11718
|
+
use(fn) {
|
|
11719
|
+
this._fns = [...this._fns, fn];
|
|
11720
|
+
return this._fns.length - 1;
|
|
11721
|
+
}
|
|
11722
|
+
}
|
|
11723
|
+
var createQuerySerializer = ({ allowReserved, array, object } = {}) => {
|
|
11724
|
+
const querySerializer = (queryParams) => {
|
|
11725
|
+
const search = [];
|
|
11726
|
+
if (queryParams && typeof queryParams === "object") {
|
|
11727
|
+
for (const name in queryParams) {
|
|
11728
|
+
const value = queryParams[name];
|
|
11729
|
+
if (value === undefined || value === null) {
|
|
11730
|
+
continue;
|
|
11731
|
+
}
|
|
11732
|
+
if (Array.isArray(value)) {
|
|
11733
|
+
const serializedArray = serializeArrayParam({
|
|
11734
|
+
allowReserved,
|
|
11735
|
+
explode: true,
|
|
11736
|
+
name,
|
|
11737
|
+
style: "form",
|
|
11738
|
+
value,
|
|
11739
|
+
...array
|
|
11740
|
+
});
|
|
11741
|
+
if (serializedArray)
|
|
11742
|
+
search.push(serializedArray);
|
|
11743
|
+
} else if (typeof value === "object") {
|
|
11744
|
+
const serializedObject = serializeObjectParam({
|
|
11745
|
+
allowReserved,
|
|
11746
|
+
explode: true,
|
|
11747
|
+
name,
|
|
11748
|
+
style: "deepObject",
|
|
11749
|
+
value,
|
|
11750
|
+
...object
|
|
11751
|
+
});
|
|
11752
|
+
if (serializedObject)
|
|
11753
|
+
search.push(serializedObject);
|
|
11754
|
+
} else {
|
|
11755
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
11756
|
+
allowReserved,
|
|
11757
|
+
name,
|
|
11758
|
+
value
|
|
11759
|
+
});
|
|
11760
|
+
if (serializedPrimitive)
|
|
11761
|
+
search.push(serializedPrimitive);
|
|
11762
|
+
}
|
|
11763
|
+
}
|
|
11764
|
+
}
|
|
11765
|
+
return search.join("&");
|
|
11766
|
+
};
|
|
11767
|
+
return querySerializer;
|
|
11768
|
+
}, getParseAs = (contentType) => {
|
|
11769
|
+
if (!contentType) {
|
|
11770
|
+
return "stream";
|
|
11771
|
+
}
|
|
11772
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
11773
|
+
if (!cleanContent) {
|
|
11774
|
+
return;
|
|
11775
|
+
}
|
|
11776
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
11777
|
+
return "json";
|
|
11778
|
+
}
|
|
11779
|
+
if (cleanContent === "multipart/form-data") {
|
|
11780
|
+
return "formData";
|
|
11781
|
+
}
|
|
11782
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
11783
|
+
return "blob";
|
|
11784
|
+
}
|
|
11785
|
+
if (cleanContent.startsWith("text/")) {
|
|
11786
|
+
return "text";
|
|
11787
|
+
}
|
|
11788
|
+
return;
|
|
11789
|
+
}, checkForExistence = (options, name) => {
|
|
11790
|
+
if (!name) {
|
|
11791
|
+
return false;
|
|
11792
|
+
}
|
|
11793
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
11794
|
+
return true;
|
|
11795
|
+
}
|
|
11796
|
+
return false;
|
|
11797
|
+
}, setAuthParams = async ({ security, ...options }) => {
|
|
11798
|
+
for (const auth of security) {
|
|
11799
|
+
if (checkForExistence(options, auth.name)) {
|
|
11800
|
+
continue;
|
|
11801
|
+
}
|
|
11802
|
+
const token = await getAuthToken(auth, options.auth);
|
|
11803
|
+
if (!token) {
|
|
11804
|
+
continue;
|
|
11805
|
+
}
|
|
11806
|
+
const name = auth.name ?? "Authorization";
|
|
11807
|
+
switch (auth.in) {
|
|
11808
|
+
case "query":
|
|
11809
|
+
if (!options.query) {
|
|
11810
|
+
options.query = {};
|
|
11811
|
+
}
|
|
11812
|
+
options.query[name] = token;
|
|
11813
|
+
break;
|
|
11814
|
+
case "cookie":
|
|
11815
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
11816
|
+
break;
|
|
11817
|
+
case "header":
|
|
11818
|
+
default:
|
|
11819
|
+
options.headers.set(name, token);
|
|
11820
|
+
break;
|
|
11821
|
+
}
|
|
11822
|
+
}
|
|
11823
|
+
}, buildUrl = (options) => getUrl({
|
|
11824
|
+
baseUrl: options.baseUrl,
|
|
11825
|
+
path: options.path,
|
|
11826
|
+
query: options.query,
|
|
11827
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
11828
|
+
url: options.url
|
|
11829
|
+
}), mergeConfigs = (a, b) => {
|
|
11830
|
+
const config = { ...a, ...b };
|
|
11831
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
11832
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
11833
|
+
}
|
|
11834
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
11835
|
+
return config;
|
|
11836
|
+
}, mergeHeaders = (...headers) => {
|
|
11837
|
+
const mergedHeaders = new Headers;
|
|
11838
|
+
for (const header of headers) {
|
|
11839
|
+
if (!header || typeof header !== "object") {
|
|
11840
|
+
continue;
|
|
11841
|
+
}
|
|
11842
|
+
const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
|
|
11843
|
+
for (const [key, value] of iterator) {
|
|
11844
|
+
if (value === null) {
|
|
11845
|
+
mergedHeaders.delete(key);
|
|
11846
|
+
} else if (Array.isArray(value)) {
|
|
11847
|
+
for (const v3 of value) {
|
|
11848
|
+
mergedHeaders.append(key, v3);
|
|
11849
|
+
}
|
|
11850
|
+
} else if (value !== undefined) {
|
|
11851
|
+
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
11852
|
+
}
|
|
11853
|
+
}
|
|
11854
|
+
}
|
|
11855
|
+
return mergedHeaders;
|
|
11856
|
+
}, createInterceptors = () => ({
|
|
11857
|
+
error: new Interceptors,
|
|
11858
|
+
request: new Interceptors,
|
|
11859
|
+
response: new Interceptors
|
|
11860
|
+
}), defaultQuerySerializer, defaultHeaders, createConfig = (override = {}) => ({
|
|
11861
|
+
...jsonBodySerializer,
|
|
11862
|
+
headers: defaultHeaders,
|
|
11863
|
+
parseAs: "auto",
|
|
11864
|
+
querySerializer: defaultQuerySerializer,
|
|
11865
|
+
...override
|
|
11866
|
+
});
|
|
11867
|
+
var init_utils_gen2 = __esm(() => {
|
|
11868
|
+
init_bodySerializer_gen();
|
|
11869
|
+
init_utils_gen();
|
|
11870
|
+
defaultQuerySerializer = createQuerySerializer({
|
|
11871
|
+
allowReserved: false,
|
|
11872
|
+
array: {
|
|
11873
|
+
explode: true,
|
|
11874
|
+
style: "form"
|
|
11875
|
+
},
|
|
11876
|
+
object: {
|
|
11877
|
+
explode: true,
|
|
11878
|
+
style: "deepObject"
|
|
11879
|
+
}
|
|
11880
|
+
});
|
|
11881
|
+
defaultHeaders = {
|
|
11882
|
+
"Content-Type": "application/json"
|
|
11883
|
+
};
|
|
11884
|
+
});
|
|
11885
|
+
|
|
11886
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client/client.gen.js
|
|
11887
|
+
var createClient = (config = {}) => {
|
|
11888
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
11889
|
+
const getConfig = () => ({ ..._config });
|
|
11890
|
+
const setConfig = (config2) => {
|
|
11891
|
+
_config = mergeConfigs(_config, config2);
|
|
11892
|
+
return getConfig();
|
|
11893
|
+
};
|
|
11894
|
+
const interceptors = createInterceptors();
|
|
11895
|
+
const beforeRequest = async (options) => {
|
|
11896
|
+
const opts = {
|
|
11897
|
+
..._config,
|
|
11898
|
+
...options,
|
|
11899
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
11900
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
11901
|
+
serializedBody: undefined
|
|
11902
|
+
};
|
|
11903
|
+
if (opts.security) {
|
|
11904
|
+
await setAuthParams({
|
|
11905
|
+
...opts,
|
|
11906
|
+
security: opts.security
|
|
11907
|
+
});
|
|
11908
|
+
}
|
|
11909
|
+
if (opts.requestValidator) {
|
|
11910
|
+
await opts.requestValidator(opts);
|
|
11911
|
+
}
|
|
11912
|
+
if (opts.body && opts.bodySerializer) {
|
|
11913
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
11914
|
+
}
|
|
11915
|
+
if (opts.serializedBody === undefined || opts.serializedBody === "") {
|
|
11916
|
+
opts.headers.delete("Content-Type");
|
|
11917
|
+
}
|
|
11918
|
+
const url = buildUrl(opts);
|
|
11919
|
+
return { opts, url };
|
|
11920
|
+
};
|
|
11921
|
+
const request = async (options) => {
|
|
11922
|
+
const { opts, url } = await beforeRequest(options);
|
|
11923
|
+
const requestInit = {
|
|
11924
|
+
redirect: "follow",
|
|
11925
|
+
...opts,
|
|
11926
|
+
body: opts.serializedBody
|
|
11927
|
+
};
|
|
11928
|
+
let request2 = new Request(url, requestInit);
|
|
11929
|
+
for (const fn of interceptors.request._fns) {
|
|
11930
|
+
if (fn) {
|
|
11931
|
+
request2 = await fn(request2, opts);
|
|
11932
|
+
}
|
|
11933
|
+
}
|
|
11934
|
+
const _fetch = opts.fetch;
|
|
11935
|
+
let response = await _fetch(request2);
|
|
11936
|
+
for (const fn of interceptors.response._fns) {
|
|
11937
|
+
if (fn) {
|
|
11938
|
+
response = await fn(response, request2, opts);
|
|
11939
|
+
}
|
|
11940
|
+
}
|
|
11941
|
+
const result = {
|
|
11942
|
+
request: request2,
|
|
11943
|
+
response
|
|
11944
|
+
};
|
|
11945
|
+
if (response.ok) {
|
|
11946
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
11947
|
+
return opts.responseStyle === "data" ? {} : {
|
|
11948
|
+
data: {},
|
|
11949
|
+
...result
|
|
11950
|
+
};
|
|
11951
|
+
}
|
|
11952
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
11953
|
+
let data;
|
|
11954
|
+
switch (parseAs) {
|
|
11955
|
+
case "arrayBuffer":
|
|
11956
|
+
case "blob":
|
|
11957
|
+
case "formData":
|
|
11958
|
+
case "json":
|
|
11959
|
+
case "text":
|
|
11960
|
+
data = await response[parseAs]();
|
|
11961
|
+
break;
|
|
11962
|
+
case "stream":
|
|
11963
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
11964
|
+
data: response.body,
|
|
11965
|
+
...result
|
|
11966
|
+
};
|
|
11967
|
+
}
|
|
11968
|
+
if (parseAs === "json") {
|
|
11969
|
+
if (opts.responseValidator) {
|
|
11970
|
+
await opts.responseValidator(data);
|
|
11971
|
+
}
|
|
11972
|
+
if (opts.responseTransformer) {
|
|
11973
|
+
data = await opts.responseTransformer(data);
|
|
11974
|
+
}
|
|
11975
|
+
}
|
|
11976
|
+
return opts.responseStyle === "data" ? data : {
|
|
11977
|
+
data,
|
|
11978
|
+
...result
|
|
11979
|
+
};
|
|
11980
|
+
}
|
|
11981
|
+
const textError = await response.text();
|
|
11982
|
+
let jsonError;
|
|
11983
|
+
try {
|
|
11984
|
+
jsonError = JSON.parse(textError);
|
|
11985
|
+
} catch {}
|
|
11986
|
+
const error = jsonError ?? textError;
|
|
11987
|
+
let finalError = error;
|
|
11988
|
+
for (const fn of interceptors.error._fns) {
|
|
11989
|
+
if (fn) {
|
|
11990
|
+
finalError = await fn(error, response, request2, opts);
|
|
11991
|
+
}
|
|
11992
|
+
}
|
|
11993
|
+
finalError = finalError || {};
|
|
11994
|
+
if (opts.throwOnError) {
|
|
11995
|
+
throw finalError;
|
|
11996
|
+
}
|
|
11997
|
+
return opts.responseStyle === "data" ? undefined : {
|
|
11998
|
+
error: finalError,
|
|
11999
|
+
...result
|
|
12000
|
+
};
|
|
12001
|
+
};
|
|
12002
|
+
const makeMethod = (method) => {
|
|
12003
|
+
const fn = (options) => request({ ...options, method });
|
|
12004
|
+
fn.sse = async (options) => {
|
|
12005
|
+
const { opts, url } = await beforeRequest(options);
|
|
12006
|
+
return createSseClient({
|
|
12007
|
+
...opts,
|
|
12008
|
+
body: opts.body,
|
|
12009
|
+
headers: opts.headers,
|
|
12010
|
+
method,
|
|
12011
|
+
url
|
|
12012
|
+
});
|
|
12013
|
+
};
|
|
12014
|
+
return fn;
|
|
12015
|
+
};
|
|
12016
|
+
return {
|
|
12017
|
+
buildUrl,
|
|
12018
|
+
connect: makeMethod("CONNECT"),
|
|
12019
|
+
delete: makeMethod("DELETE"),
|
|
12020
|
+
get: makeMethod("GET"),
|
|
12021
|
+
getConfig,
|
|
12022
|
+
head: makeMethod("HEAD"),
|
|
12023
|
+
interceptors,
|
|
12024
|
+
options: makeMethod("OPTIONS"),
|
|
12025
|
+
patch: makeMethod("PATCH"),
|
|
12026
|
+
post: makeMethod("POST"),
|
|
12027
|
+
put: makeMethod("PUT"),
|
|
12028
|
+
request,
|
|
12029
|
+
setConfig,
|
|
12030
|
+
trace: makeMethod("TRACE")
|
|
12031
|
+
};
|
|
12032
|
+
};
|
|
12033
|
+
var init_client_gen = __esm(() => {
|
|
12034
|
+
init_utils_gen2();
|
|
12035
|
+
});
|
|
12036
|
+
|
|
12037
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/core/params.gen.js
|
|
12038
|
+
var extraPrefixesMap, extraPrefixes;
|
|
12039
|
+
var init_params_gen = __esm(() => {
|
|
12040
|
+
extraPrefixesMap = {
|
|
12041
|
+
$body_: "body",
|
|
12042
|
+
$headers_: "headers",
|
|
12043
|
+
$path_: "path",
|
|
12044
|
+
$query_: "query"
|
|
12045
|
+
};
|
|
12046
|
+
extraPrefixes = Object.entries(extraPrefixesMap);
|
|
12047
|
+
});
|
|
12048
|
+
|
|
12049
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client/index.js
|
|
12050
|
+
var init_client3 = __esm(() => {
|
|
12051
|
+
init_bodySerializer_gen();
|
|
12052
|
+
init_params_gen();
|
|
12053
|
+
init_client_gen();
|
|
12054
|
+
init_utils_gen2();
|
|
12055
|
+
});
|
|
12056
|
+
|
|
12057
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/client.gen.js
|
|
12058
|
+
var client2;
|
|
12059
|
+
var init_client_gen2 = __esm(() => {
|
|
12060
|
+
init_client3();
|
|
12061
|
+
client2 = createClient(createConfig({
|
|
12062
|
+
baseUrl: "http://localhost:4096"
|
|
12063
|
+
}));
|
|
12064
|
+
});
|
|
12065
|
+
|
|
12066
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/gen/sdk.gen.js
|
|
12067
|
+
class _HeyApiClient {
|
|
12068
|
+
_client = client2;
|
|
12069
|
+
constructor(args) {
|
|
12070
|
+
if (args?.client) {
|
|
12071
|
+
this._client = args.client;
|
|
12072
|
+
}
|
|
12073
|
+
}
|
|
12074
|
+
}
|
|
12075
|
+
var Global, Project, Pty, Config, Tool, Instance, Path, Vcs, Session, Command2, Oauth, Provider, Find, File, App, Auth, Mcp, Lsp, Formatter, Control, Tui, Event, OpencodeClient;
|
|
12076
|
+
var init_sdk_gen = __esm(() => {
|
|
12077
|
+
init_client_gen2();
|
|
12078
|
+
Global = class Global extends _HeyApiClient {
|
|
12079
|
+
event(options) {
|
|
12080
|
+
return (options?.client ?? this._client).get.sse({
|
|
12081
|
+
url: "/global/event",
|
|
12082
|
+
...options
|
|
12083
|
+
});
|
|
12084
|
+
}
|
|
12085
|
+
};
|
|
12086
|
+
Project = class Project extends _HeyApiClient {
|
|
12087
|
+
list(options) {
|
|
12088
|
+
return (options?.client ?? this._client).get({
|
|
12089
|
+
url: "/project",
|
|
12090
|
+
...options
|
|
12091
|
+
});
|
|
12092
|
+
}
|
|
12093
|
+
current(options) {
|
|
12094
|
+
return (options?.client ?? this._client).get({
|
|
12095
|
+
url: "/project/current",
|
|
12096
|
+
...options
|
|
12097
|
+
});
|
|
12098
|
+
}
|
|
12099
|
+
};
|
|
12100
|
+
Pty = class Pty extends _HeyApiClient {
|
|
12101
|
+
list(options) {
|
|
12102
|
+
return (options?.client ?? this._client).get({
|
|
12103
|
+
url: "/pty",
|
|
12104
|
+
...options
|
|
12105
|
+
});
|
|
12106
|
+
}
|
|
12107
|
+
create(options) {
|
|
12108
|
+
return (options?.client ?? this._client).post({
|
|
12109
|
+
url: "/pty",
|
|
12110
|
+
...options,
|
|
12111
|
+
headers: {
|
|
12112
|
+
"Content-Type": "application/json",
|
|
12113
|
+
...options?.headers
|
|
12114
|
+
}
|
|
12115
|
+
});
|
|
12116
|
+
}
|
|
12117
|
+
remove(options) {
|
|
12118
|
+
return (options.client ?? this._client).delete({
|
|
12119
|
+
url: "/pty/{id}",
|
|
12120
|
+
...options
|
|
12121
|
+
});
|
|
12122
|
+
}
|
|
12123
|
+
get(options) {
|
|
12124
|
+
return (options.client ?? this._client).get({
|
|
12125
|
+
url: "/pty/{id}",
|
|
12126
|
+
...options
|
|
12127
|
+
});
|
|
12128
|
+
}
|
|
12129
|
+
update(options) {
|
|
12130
|
+
return (options.client ?? this._client).put({
|
|
12131
|
+
url: "/pty/{id}",
|
|
12132
|
+
...options,
|
|
12133
|
+
headers: {
|
|
12134
|
+
"Content-Type": "application/json",
|
|
12135
|
+
...options.headers
|
|
12136
|
+
}
|
|
12137
|
+
});
|
|
12138
|
+
}
|
|
12139
|
+
connect(options) {
|
|
12140
|
+
return (options.client ?? this._client).get({
|
|
12141
|
+
url: "/pty/{id}/connect",
|
|
12142
|
+
...options
|
|
12143
|
+
});
|
|
12144
|
+
}
|
|
12145
|
+
};
|
|
12146
|
+
Config = class Config extends _HeyApiClient {
|
|
12147
|
+
get(options) {
|
|
12148
|
+
return (options?.client ?? this._client).get({
|
|
12149
|
+
url: "/config",
|
|
12150
|
+
...options
|
|
12151
|
+
});
|
|
12152
|
+
}
|
|
12153
|
+
update(options) {
|
|
12154
|
+
return (options?.client ?? this._client).patch({
|
|
12155
|
+
url: "/config",
|
|
12156
|
+
...options,
|
|
12157
|
+
headers: {
|
|
12158
|
+
"Content-Type": "application/json",
|
|
12159
|
+
...options?.headers
|
|
12160
|
+
}
|
|
12161
|
+
});
|
|
12162
|
+
}
|
|
12163
|
+
providers(options) {
|
|
12164
|
+
return (options?.client ?? this._client).get({
|
|
12165
|
+
url: "/config/providers",
|
|
12166
|
+
...options
|
|
12167
|
+
});
|
|
12168
|
+
}
|
|
12169
|
+
};
|
|
12170
|
+
Tool = class Tool extends _HeyApiClient {
|
|
12171
|
+
ids(options) {
|
|
12172
|
+
return (options?.client ?? this._client).get({
|
|
12173
|
+
url: "/experimental/tool/ids",
|
|
12174
|
+
...options
|
|
12175
|
+
});
|
|
12176
|
+
}
|
|
12177
|
+
list(options) {
|
|
12178
|
+
return (options.client ?? this._client).get({
|
|
12179
|
+
url: "/experimental/tool",
|
|
12180
|
+
...options
|
|
12181
|
+
});
|
|
12182
|
+
}
|
|
12183
|
+
};
|
|
12184
|
+
Instance = class Instance extends _HeyApiClient {
|
|
12185
|
+
dispose(options) {
|
|
12186
|
+
return (options?.client ?? this._client).post({
|
|
12187
|
+
url: "/instance/dispose",
|
|
12188
|
+
...options
|
|
12189
|
+
});
|
|
12190
|
+
}
|
|
12191
|
+
};
|
|
12192
|
+
Path = class Path extends _HeyApiClient {
|
|
12193
|
+
get(options) {
|
|
12194
|
+
return (options?.client ?? this._client).get({
|
|
12195
|
+
url: "/path",
|
|
12196
|
+
...options
|
|
12197
|
+
});
|
|
12198
|
+
}
|
|
12199
|
+
};
|
|
12200
|
+
Vcs = class Vcs extends _HeyApiClient {
|
|
12201
|
+
get(options) {
|
|
12202
|
+
return (options?.client ?? this._client).get({
|
|
12203
|
+
url: "/vcs",
|
|
12204
|
+
...options
|
|
12205
|
+
});
|
|
12206
|
+
}
|
|
12207
|
+
};
|
|
12208
|
+
Session = class Session extends _HeyApiClient {
|
|
12209
|
+
list(options) {
|
|
12210
|
+
return (options?.client ?? this._client).get({
|
|
12211
|
+
url: "/session",
|
|
12212
|
+
...options
|
|
12213
|
+
});
|
|
12214
|
+
}
|
|
12215
|
+
create(options) {
|
|
12216
|
+
return (options?.client ?? this._client).post({
|
|
12217
|
+
url: "/session",
|
|
12218
|
+
...options,
|
|
12219
|
+
headers: {
|
|
12220
|
+
"Content-Type": "application/json",
|
|
12221
|
+
...options?.headers
|
|
12222
|
+
}
|
|
12223
|
+
});
|
|
12224
|
+
}
|
|
12225
|
+
status(options) {
|
|
12226
|
+
return (options?.client ?? this._client).get({
|
|
12227
|
+
url: "/session/status",
|
|
12228
|
+
...options
|
|
12229
|
+
});
|
|
12230
|
+
}
|
|
12231
|
+
delete(options) {
|
|
12232
|
+
return (options.client ?? this._client).delete({
|
|
12233
|
+
url: "/session/{id}",
|
|
12234
|
+
...options
|
|
12235
|
+
});
|
|
12236
|
+
}
|
|
12237
|
+
get(options) {
|
|
12238
|
+
return (options.client ?? this._client).get({
|
|
12239
|
+
url: "/session/{id}",
|
|
12240
|
+
...options
|
|
12241
|
+
});
|
|
12242
|
+
}
|
|
12243
|
+
update(options) {
|
|
12244
|
+
return (options.client ?? this._client).patch({
|
|
12245
|
+
url: "/session/{id}",
|
|
12246
|
+
...options,
|
|
12247
|
+
headers: {
|
|
12248
|
+
"Content-Type": "application/json",
|
|
12249
|
+
...options.headers
|
|
12250
|
+
}
|
|
12251
|
+
});
|
|
12252
|
+
}
|
|
12253
|
+
children(options) {
|
|
12254
|
+
return (options.client ?? this._client).get({
|
|
12255
|
+
url: "/session/{id}/children",
|
|
12256
|
+
...options
|
|
12257
|
+
});
|
|
12258
|
+
}
|
|
12259
|
+
todo(options) {
|
|
12260
|
+
return (options.client ?? this._client).get({
|
|
12261
|
+
url: "/session/{id}/todo",
|
|
12262
|
+
...options
|
|
12263
|
+
});
|
|
12264
|
+
}
|
|
12265
|
+
init(options) {
|
|
12266
|
+
return (options.client ?? this._client).post({
|
|
12267
|
+
url: "/session/{id}/init",
|
|
12268
|
+
...options,
|
|
12269
|
+
headers: {
|
|
12270
|
+
"Content-Type": "application/json",
|
|
12271
|
+
...options.headers
|
|
12272
|
+
}
|
|
12273
|
+
});
|
|
12274
|
+
}
|
|
12275
|
+
fork(options) {
|
|
12276
|
+
return (options.client ?? this._client).post({
|
|
12277
|
+
url: "/session/{id}/fork",
|
|
12278
|
+
...options,
|
|
12279
|
+
headers: {
|
|
12280
|
+
"Content-Type": "application/json",
|
|
12281
|
+
...options.headers
|
|
12282
|
+
}
|
|
12283
|
+
});
|
|
12284
|
+
}
|
|
12285
|
+
abort(options) {
|
|
12286
|
+
return (options.client ?? this._client).post({
|
|
12287
|
+
url: "/session/{id}/abort",
|
|
12288
|
+
...options
|
|
12289
|
+
});
|
|
12290
|
+
}
|
|
12291
|
+
unshare(options) {
|
|
12292
|
+
return (options.client ?? this._client).delete({
|
|
12293
|
+
url: "/session/{id}/share",
|
|
12294
|
+
...options
|
|
12295
|
+
});
|
|
12296
|
+
}
|
|
12297
|
+
share(options) {
|
|
12298
|
+
return (options.client ?? this._client).post({
|
|
12299
|
+
url: "/session/{id}/share",
|
|
12300
|
+
...options
|
|
12301
|
+
});
|
|
12302
|
+
}
|
|
12303
|
+
diff(options) {
|
|
12304
|
+
return (options.client ?? this._client).get({
|
|
12305
|
+
url: "/session/{id}/diff",
|
|
12306
|
+
...options
|
|
12307
|
+
});
|
|
12308
|
+
}
|
|
12309
|
+
summarize(options) {
|
|
12310
|
+
return (options.client ?? this._client).post({
|
|
12311
|
+
url: "/session/{id}/summarize",
|
|
12312
|
+
...options,
|
|
12313
|
+
headers: {
|
|
12314
|
+
"Content-Type": "application/json",
|
|
12315
|
+
...options.headers
|
|
12316
|
+
}
|
|
12317
|
+
});
|
|
12318
|
+
}
|
|
12319
|
+
messages(options) {
|
|
12320
|
+
return (options.client ?? this._client).get({
|
|
12321
|
+
url: "/session/{id}/message",
|
|
12322
|
+
...options
|
|
12323
|
+
});
|
|
12324
|
+
}
|
|
12325
|
+
prompt(options) {
|
|
12326
|
+
return (options.client ?? this._client).post({
|
|
12327
|
+
url: "/session/{id}/message",
|
|
12328
|
+
...options,
|
|
12329
|
+
headers: {
|
|
12330
|
+
"Content-Type": "application/json",
|
|
12331
|
+
...options.headers
|
|
12332
|
+
}
|
|
12333
|
+
});
|
|
12334
|
+
}
|
|
12335
|
+
message(options) {
|
|
12336
|
+
return (options.client ?? this._client).get({
|
|
12337
|
+
url: "/session/{id}/message/{messageID}",
|
|
12338
|
+
...options
|
|
12339
|
+
});
|
|
12340
|
+
}
|
|
12341
|
+
promptAsync(options) {
|
|
12342
|
+
return (options.client ?? this._client).post({
|
|
12343
|
+
url: "/session/{id}/prompt_async",
|
|
12344
|
+
...options,
|
|
12345
|
+
headers: {
|
|
12346
|
+
"Content-Type": "application/json",
|
|
12347
|
+
...options.headers
|
|
12348
|
+
}
|
|
12349
|
+
});
|
|
12350
|
+
}
|
|
12351
|
+
command(options) {
|
|
12352
|
+
return (options.client ?? this._client).post({
|
|
12353
|
+
url: "/session/{id}/command",
|
|
12354
|
+
...options,
|
|
12355
|
+
headers: {
|
|
12356
|
+
"Content-Type": "application/json",
|
|
12357
|
+
...options.headers
|
|
12358
|
+
}
|
|
12359
|
+
});
|
|
12360
|
+
}
|
|
12361
|
+
shell(options) {
|
|
12362
|
+
return (options.client ?? this._client).post({
|
|
12363
|
+
url: "/session/{id}/shell",
|
|
12364
|
+
...options,
|
|
12365
|
+
headers: {
|
|
12366
|
+
"Content-Type": "application/json",
|
|
12367
|
+
...options.headers
|
|
12368
|
+
}
|
|
12369
|
+
});
|
|
12370
|
+
}
|
|
12371
|
+
revert(options) {
|
|
12372
|
+
return (options.client ?? this._client).post({
|
|
12373
|
+
url: "/session/{id}/revert",
|
|
12374
|
+
...options,
|
|
12375
|
+
headers: {
|
|
12376
|
+
"Content-Type": "application/json",
|
|
12377
|
+
...options.headers
|
|
12378
|
+
}
|
|
12379
|
+
});
|
|
12380
|
+
}
|
|
12381
|
+
unrevert(options) {
|
|
12382
|
+
return (options.client ?? this._client).post({
|
|
12383
|
+
url: "/session/{id}/unrevert",
|
|
12384
|
+
...options
|
|
12385
|
+
});
|
|
12386
|
+
}
|
|
12387
|
+
};
|
|
12388
|
+
Command2 = class Command2 extends _HeyApiClient {
|
|
12389
|
+
list(options) {
|
|
12390
|
+
return (options?.client ?? this._client).get({
|
|
12391
|
+
url: "/command",
|
|
12392
|
+
...options
|
|
12393
|
+
});
|
|
12394
|
+
}
|
|
12395
|
+
};
|
|
12396
|
+
Oauth = class Oauth extends _HeyApiClient {
|
|
12397
|
+
authorize(options) {
|
|
12398
|
+
return (options.client ?? this._client).post({
|
|
12399
|
+
url: "/provider/{id}/oauth/authorize",
|
|
12400
|
+
...options,
|
|
12401
|
+
headers: {
|
|
12402
|
+
"Content-Type": "application/json",
|
|
12403
|
+
...options.headers
|
|
12404
|
+
}
|
|
12405
|
+
});
|
|
12406
|
+
}
|
|
12407
|
+
callback(options) {
|
|
12408
|
+
return (options.client ?? this._client).post({
|
|
12409
|
+
url: "/provider/{id}/oauth/callback",
|
|
12410
|
+
...options,
|
|
12411
|
+
headers: {
|
|
12412
|
+
"Content-Type": "application/json",
|
|
12413
|
+
...options.headers
|
|
12414
|
+
}
|
|
12415
|
+
});
|
|
12416
|
+
}
|
|
12417
|
+
};
|
|
12418
|
+
Provider = class Provider extends _HeyApiClient {
|
|
12419
|
+
list(options) {
|
|
12420
|
+
return (options?.client ?? this._client).get({
|
|
12421
|
+
url: "/provider",
|
|
12422
|
+
...options
|
|
12423
|
+
});
|
|
12424
|
+
}
|
|
12425
|
+
auth(options) {
|
|
12426
|
+
return (options?.client ?? this._client).get({
|
|
12427
|
+
url: "/provider/auth",
|
|
12428
|
+
...options
|
|
12429
|
+
});
|
|
12430
|
+
}
|
|
12431
|
+
oauth = new Oauth({ client: this._client });
|
|
12432
|
+
};
|
|
12433
|
+
Find = class Find extends _HeyApiClient {
|
|
12434
|
+
text(options) {
|
|
12435
|
+
return (options.client ?? this._client).get({
|
|
12436
|
+
url: "/find",
|
|
12437
|
+
...options
|
|
12438
|
+
});
|
|
12439
|
+
}
|
|
12440
|
+
files(options) {
|
|
12441
|
+
return (options.client ?? this._client).get({
|
|
12442
|
+
url: "/find/file",
|
|
12443
|
+
...options
|
|
12444
|
+
});
|
|
12445
|
+
}
|
|
12446
|
+
symbols(options) {
|
|
12447
|
+
return (options.client ?? this._client).get({
|
|
12448
|
+
url: "/find/symbol",
|
|
12449
|
+
...options
|
|
12450
|
+
});
|
|
12451
|
+
}
|
|
12452
|
+
};
|
|
12453
|
+
File = class File extends _HeyApiClient {
|
|
12454
|
+
list(options) {
|
|
12455
|
+
return (options.client ?? this._client).get({
|
|
12456
|
+
url: "/file",
|
|
12457
|
+
...options
|
|
12458
|
+
});
|
|
12459
|
+
}
|
|
12460
|
+
read(options) {
|
|
12461
|
+
return (options.client ?? this._client).get({
|
|
12462
|
+
url: "/file/content",
|
|
12463
|
+
...options
|
|
12464
|
+
});
|
|
12465
|
+
}
|
|
12466
|
+
status(options) {
|
|
12467
|
+
return (options?.client ?? this._client).get({
|
|
12468
|
+
url: "/file/status",
|
|
12469
|
+
...options
|
|
12470
|
+
});
|
|
12471
|
+
}
|
|
12472
|
+
};
|
|
12473
|
+
App = class App extends _HeyApiClient {
|
|
12474
|
+
log(options) {
|
|
12475
|
+
return (options?.client ?? this._client).post({
|
|
12476
|
+
url: "/log",
|
|
12477
|
+
...options,
|
|
12478
|
+
headers: {
|
|
12479
|
+
"Content-Type": "application/json",
|
|
12480
|
+
...options?.headers
|
|
12481
|
+
}
|
|
12482
|
+
});
|
|
12483
|
+
}
|
|
12484
|
+
agents(options) {
|
|
12485
|
+
return (options?.client ?? this._client).get({
|
|
12486
|
+
url: "/agent",
|
|
12487
|
+
...options
|
|
12488
|
+
});
|
|
12489
|
+
}
|
|
12490
|
+
};
|
|
12491
|
+
Auth = class Auth extends _HeyApiClient {
|
|
12492
|
+
remove(options) {
|
|
12493
|
+
return (options.client ?? this._client).delete({
|
|
12494
|
+
url: "/mcp/{name}/auth",
|
|
12495
|
+
...options
|
|
12496
|
+
});
|
|
12497
|
+
}
|
|
12498
|
+
start(options) {
|
|
12499
|
+
return (options.client ?? this._client).post({
|
|
12500
|
+
url: "/mcp/{name}/auth",
|
|
12501
|
+
...options
|
|
12502
|
+
});
|
|
12503
|
+
}
|
|
12504
|
+
callback(options) {
|
|
12505
|
+
return (options.client ?? this._client).post({
|
|
12506
|
+
url: "/mcp/{name}/auth/callback",
|
|
12507
|
+
...options,
|
|
12508
|
+
headers: {
|
|
12509
|
+
"Content-Type": "application/json",
|
|
12510
|
+
...options.headers
|
|
12511
|
+
}
|
|
12512
|
+
});
|
|
12513
|
+
}
|
|
12514
|
+
authenticate(options) {
|
|
12515
|
+
return (options.client ?? this._client).post({
|
|
12516
|
+
url: "/mcp/{name}/auth/authenticate",
|
|
12517
|
+
...options
|
|
12518
|
+
});
|
|
12519
|
+
}
|
|
12520
|
+
set(options) {
|
|
12521
|
+
return (options.client ?? this._client).put({
|
|
12522
|
+
url: "/auth/{id}",
|
|
12523
|
+
...options,
|
|
12524
|
+
headers: {
|
|
12525
|
+
"Content-Type": "application/json",
|
|
12526
|
+
...options.headers
|
|
12527
|
+
}
|
|
12528
|
+
});
|
|
12529
|
+
}
|
|
12530
|
+
};
|
|
12531
|
+
Mcp = class Mcp extends _HeyApiClient {
|
|
12532
|
+
status(options) {
|
|
12533
|
+
return (options?.client ?? this._client).get({
|
|
12534
|
+
url: "/mcp",
|
|
12535
|
+
...options
|
|
12536
|
+
});
|
|
12537
|
+
}
|
|
12538
|
+
add(options) {
|
|
12539
|
+
return (options?.client ?? this._client).post({
|
|
12540
|
+
url: "/mcp",
|
|
12541
|
+
...options,
|
|
12542
|
+
headers: {
|
|
12543
|
+
"Content-Type": "application/json",
|
|
12544
|
+
...options?.headers
|
|
12545
|
+
}
|
|
12546
|
+
});
|
|
12547
|
+
}
|
|
12548
|
+
connect(options) {
|
|
12549
|
+
return (options.client ?? this._client).post({
|
|
12550
|
+
url: "/mcp/{name}/connect",
|
|
12551
|
+
...options
|
|
12552
|
+
});
|
|
12553
|
+
}
|
|
12554
|
+
disconnect(options) {
|
|
12555
|
+
return (options.client ?? this._client).post({
|
|
12556
|
+
url: "/mcp/{name}/disconnect",
|
|
12557
|
+
...options
|
|
12558
|
+
});
|
|
12559
|
+
}
|
|
12560
|
+
auth = new Auth({ client: this._client });
|
|
12561
|
+
};
|
|
12562
|
+
Lsp = class Lsp extends _HeyApiClient {
|
|
12563
|
+
status(options) {
|
|
12564
|
+
return (options?.client ?? this._client).get({
|
|
12565
|
+
url: "/lsp",
|
|
12566
|
+
...options
|
|
12567
|
+
});
|
|
12568
|
+
}
|
|
12569
|
+
};
|
|
12570
|
+
Formatter = class Formatter extends _HeyApiClient {
|
|
12571
|
+
status(options) {
|
|
12572
|
+
return (options?.client ?? this._client).get({
|
|
12573
|
+
url: "/formatter",
|
|
12574
|
+
...options
|
|
12575
|
+
});
|
|
12576
|
+
}
|
|
12577
|
+
};
|
|
12578
|
+
Control = class Control extends _HeyApiClient {
|
|
12579
|
+
next(options) {
|
|
12580
|
+
return (options?.client ?? this._client).get({
|
|
12581
|
+
url: "/tui/control/next",
|
|
12582
|
+
...options
|
|
12583
|
+
});
|
|
12584
|
+
}
|
|
12585
|
+
response(options) {
|
|
12586
|
+
return (options?.client ?? this._client).post({
|
|
12587
|
+
url: "/tui/control/response",
|
|
12588
|
+
...options,
|
|
12589
|
+
headers: {
|
|
12590
|
+
"Content-Type": "application/json",
|
|
12591
|
+
...options?.headers
|
|
12592
|
+
}
|
|
12593
|
+
});
|
|
12594
|
+
}
|
|
12595
|
+
};
|
|
12596
|
+
Tui = class Tui extends _HeyApiClient {
|
|
12597
|
+
appendPrompt(options) {
|
|
12598
|
+
return (options?.client ?? this._client).post({
|
|
12599
|
+
url: "/tui/append-prompt",
|
|
12600
|
+
...options,
|
|
12601
|
+
headers: {
|
|
12602
|
+
"Content-Type": "application/json",
|
|
12603
|
+
...options?.headers
|
|
12604
|
+
}
|
|
12605
|
+
});
|
|
12606
|
+
}
|
|
12607
|
+
openHelp(options) {
|
|
12608
|
+
return (options?.client ?? this._client).post({
|
|
12609
|
+
url: "/tui/open-help",
|
|
12610
|
+
...options
|
|
12611
|
+
});
|
|
12612
|
+
}
|
|
12613
|
+
openSessions(options) {
|
|
12614
|
+
return (options?.client ?? this._client).post({
|
|
12615
|
+
url: "/tui/open-sessions",
|
|
12616
|
+
...options
|
|
12617
|
+
});
|
|
12618
|
+
}
|
|
12619
|
+
openThemes(options) {
|
|
12620
|
+
return (options?.client ?? this._client).post({
|
|
12621
|
+
url: "/tui/open-themes",
|
|
12622
|
+
...options
|
|
12623
|
+
});
|
|
12624
|
+
}
|
|
12625
|
+
openModels(options) {
|
|
12626
|
+
return (options?.client ?? this._client).post({
|
|
12627
|
+
url: "/tui/open-models",
|
|
12628
|
+
...options
|
|
12629
|
+
});
|
|
12630
|
+
}
|
|
12631
|
+
submitPrompt(options) {
|
|
12632
|
+
return (options?.client ?? this._client).post({
|
|
12633
|
+
url: "/tui/submit-prompt",
|
|
12634
|
+
...options
|
|
12635
|
+
});
|
|
12636
|
+
}
|
|
12637
|
+
clearPrompt(options) {
|
|
12638
|
+
return (options?.client ?? this._client).post({
|
|
12639
|
+
url: "/tui/clear-prompt",
|
|
12640
|
+
...options
|
|
12641
|
+
});
|
|
12642
|
+
}
|
|
12643
|
+
executeCommand(options) {
|
|
12644
|
+
return (options?.client ?? this._client).post({
|
|
12645
|
+
url: "/tui/execute-command",
|
|
12646
|
+
...options,
|
|
12647
|
+
headers: {
|
|
12648
|
+
"Content-Type": "application/json",
|
|
12649
|
+
...options?.headers
|
|
12650
|
+
}
|
|
12651
|
+
});
|
|
12652
|
+
}
|
|
12653
|
+
showToast(options) {
|
|
12654
|
+
return (options?.client ?? this._client).post({
|
|
12655
|
+
url: "/tui/show-toast",
|
|
12656
|
+
...options,
|
|
12657
|
+
headers: {
|
|
12658
|
+
"Content-Type": "application/json",
|
|
12659
|
+
...options?.headers
|
|
12660
|
+
}
|
|
12661
|
+
});
|
|
12662
|
+
}
|
|
12663
|
+
publish(options) {
|
|
12664
|
+
return (options?.client ?? this._client).post({
|
|
12665
|
+
url: "/tui/publish",
|
|
12666
|
+
...options,
|
|
12667
|
+
headers: {
|
|
12668
|
+
"Content-Type": "application/json",
|
|
12669
|
+
...options?.headers
|
|
12670
|
+
}
|
|
12671
|
+
});
|
|
12672
|
+
}
|
|
12673
|
+
control = new Control({ client: this._client });
|
|
12674
|
+
};
|
|
12675
|
+
Event = class Event extends _HeyApiClient {
|
|
12676
|
+
subscribe(options) {
|
|
12677
|
+
return (options?.client ?? this._client).get.sse({
|
|
12678
|
+
url: "/event",
|
|
12679
|
+
...options
|
|
12680
|
+
});
|
|
12681
|
+
}
|
|
12682
|
+
};
|
|
12683
|
+
OpencodeClient = class OpencodeClient extends _HeyApiClient {
|
|
12684
|
+
postSessionIdPermissionsPermissionId(options) {
|
|
12685
|
+
return (options.client ?? this._client).post({
|
|
12686
|
+
url: "/session/{id}/permissions/{permissionID}",
|
|
12687
|
+
...options,
|
|
12688
|
+
headers: {
|
|
12689
|
+
"Content-Type": "application/json",
|
|
12690
|
+
...options.headers
|
|
12691
|
+
}
|
|
12692
|
+
});
|
|
12693
|
+
}
|
|
12694
|
+
global = new Global({ client: this._client });
|
|
12695
|
+
project = new Project({ client: this._client });
|
|
12696
|
+
pty = new Pty({ client: this._client });
|
|
12697
|
+
config = new Config({ client: this._client });
|
|
12698
|
+
tool = new Tool({ client: this._client });
|
|
12699
|
+
instance = new Instance({ client: this._client });
|
|
12700
|
+
path = new Path({ client: this._client });
|
|
12701
|
+
vcs = new Vcs({ client: this._client });
|
|
12702
|
+
session = new Session({ client: this._client });
|
|
12703
|
+
command = new Command2({ client: this._client });
|
|
12704
|
+
provider = new Provider({ client: this._client });
|
|
12705
|
+
find = new Find({ client: this._client });
|
|
12706
|
+
file = new File({ client: this._client });
|
|
12707
|
+
app = new App({ client: this._client });
|
|
12708
|
+
mcp = new Mcp({ client: this._client });
|
|
12709
|
+
lsp = new Lsp({ client: this._client });
|
|
12710
|
+
formatter = new Formatter({ client: this._client });
|
|
12711
|
+
tui = new Tui({ client: this._client });
|
|
12712
|
+
auth = new Auth({ client: this._client });
|
|
12713
|
+
event = new Event({ client: this._client });
|
|
12714
|
+
};
|
|
12715
|
+
});
|
|
12716
|
+
|
|
12717
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/client.js
|
|
12718
|
+
function pick(value, fallback) {
|
|
12719
|
+
if (!value)
|
|
12720
|
+
return;
|
|
12721
|
+
if (!fallback)
|
|
12722
|
+
return value;
|
|
12723
|
+
if (value === fallback)
|
|
12724
|
+
return fallback;
|
|
12725
|
+
if (value === encodeURIComponent(fallback))
|
|
12726
|
+
return fallback;
|
|
12727
|
+
return value;
|
|
12728
|
+
}
|
|
12729
|
+
function rewrite(request, directory) {
|
|
12730
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
12731
|
+
return request;
|
|
12732
|
+
const value = pick(request.headers.get("x-opencode-directory"), directory);
|
|
12733
|
+
if (!value)
|
|
12734
|
+
return request;
|
|
12735
|
+
const url = new URL(request.url);
|
|
12736
|
+
if (!url.searchParams.has("directory")) {
|
|
12737
|
+
url.searchParams.set("directory", value);
|
|
12738
|
+
}
|
|
12739
|
+
const next = new Request(url, request);
|
|
12740
|
+
next.headers.delete("x-opencode-directory");
|
|
12741
|
+
return next;
|
|
12742
|
+
}
|
|
12743
|
+
function createOpencodeClient(config) {
|
|
12744
|
+
if (!config?.fetch) {
|
|
12745
|
+
const customFetch = (req) => {
|
|
12746
|
+
req.timeout = false;
|
|
12747
|
+
return fetch(req);
|
|
12748
|
+
};
|
|
12749
|
+
config = {
|
|
12750
|
+
...config,
|
|
12751
|
+
fetch: customFetch
|
|
12752
|
+
};
|
|
12753
|
+
}
|
|
12754
|
+
if (config?.directory) {
|
|
12755
|
+
config.headers = {
|
|
12756
|
+
...config.headers,
|
|
12757
|
+
"x-opencode-directory": encodeURIComponent(config.directory)
|
|
12758
|
+
};
|
|
12759
|
+
}
|
|
12760
|
+
const client3 = createClient(config);
|
|
12761
|
+
client3.interceptors.request.use((request) => rewrite(request, config?.directory));
|
|
12762
|
+
return new OpencodeClient({ client: client3 });
|
|
12763
|
+
}
|
|
12764
|
+
var init_client4 = __esm(() => {
|
|
12765
|
+
init_client_gen();
|
|
12766
|
+
init_sdk_gen();
|
|
12767
|
+
init_types_gen();
|
|
12768
|
+
});
|
|
12769
|
+
|
|
12770
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
12771
|
+
var require_windows = __commonJS((exports, module) => {
|
|
12772
|
+
module.exports = isexe;
|
|
12773
|
+
isexe.sync = sync;
|
|
12774
|
+
var fs = __require("fs");
|
|
12775
|
+
function checkPathExt(path, options) {
|
|
12776
|
+
var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
|
|
12777
|
+
if (!pathext) {
|
|
12778
|
+
return true;
|
|
12779
|
+
}
|
|
12780
|
+
pathext = pathext.split(";");
|
|
12781
|
+
if (pathext.indexOf("") !== -1) {
|
|
12782
|
+
return true;
|
|
12783
|
+
}
|
|
12784
|
+
for (var i2 = 0;i2 < pathext.length; i2++) {
|
|
12785
|
+
var p = pathext[i2].toLowerCase();
|
|
12786
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
12787
|
+
return true;
|
|
12788
|
+
}
|
|
12789
|
+
}
|
|
12790
|
+
return false;
|
|
12791
|
+
}
|
|
12792
|
+
function checkStat(stat, path, options) {
|
|
12793
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
12794
|
+
return false;
|
|
12795
|
+
}
|
|
12796
|
+
return checkPathExt(path, options);
|
|
12797
|
+
}
|
|
12798
|
+
function isexe(path, options, cb) {
|
|
12799
|
+
fs.stat(path, function(er, stat) {
|
|
12800
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
12801
|
+
});
|
|
12802
|
+
}
|
|
12803
|
+
function sync(path, options) {
|
|
12804
|
+
return checkStat(fs.statSync(path), path, options);
|
|
12805
|
+
}
|
|
12806
|
+
});
|
|
12807
|
+
|
|
12808
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
12809
|
+
var require_mode = __commonJS((exports, module) => {
|
|
12810
|
+
module.exports = isexe;
|
|
12811
|
+
isexe.sync = sync;
|
|
12812
|
+
var fs = __require("fs");
|
|
12813
|
+
function isexe(path, options, cb) {
|
|
12814
|
+
fs.stat(path, function(er, stat) {
|
|
12815
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
12816
|
+
});
|
|
12817
|
+
}
|
|
12818
|
+
function sync(path, options) {
|
|
12819
|
+
return checkStat(fs.statSync(path), options);
|
|
12820
|
+
}
|
|
12821
|
+
function checkStat(stat, options) {
|
|
12822
|
+
return stat.isFile() && checkMode(stat, options);
|
|
12823
|
+
}
|
|
12824
|
+
function checkMode(stat, options) {
|
|
12825
|
+
var mod = stat.mode;
|
|
12826
|
+
var uid = stat.uid;
|
|
12827
|
+
var gid = stat.gid;
|
|
12828
|
+
var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
|
|
12829
|
+
var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
|
|
12830
|
+
var u = parseInt("100", 8);
|
|
12831
|
+
var g = parseInt("010", 8);
|
|
12832
|
+
var o = parseInt("001", 8);
|
|
12833
|
+
var ug = u | g;
|
|
12834
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
12835
|
+
return ret;
|
|
12836
|
+
}
|
|
12837
|
+
});
|
|
12838
|
+
|
|
12839
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
12840
|
+
var require_isexe = __commonJS((exports, module) => {
|
|
12841
|
+
var fs = __require("fs");
|
|
12842
|
+
var core;
|
|
12843
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
12844
|
+
core = require_windows();
|
|
12845
|
+
} else {
|
|
12846
|
+
core = require_mode();
|
|
12847
|
+
}
|
|
12848
|
+
module.exports = isexe;
|
|
12849
|
+
isexe.sync = sync;
|
|
12850
|
+
function isexe(path, options, cb) {
|
|
12851
|
+
if (typeof options === "function") {
|
|
12852
|
+
cb = options;
|
|
12853
|
+
options = {};
|
|
12854
|
+
}
|
|
12855
|
+
if (!cb) {
|
|
12856
|
+
if (typeof Promise !== "function") {
|
|
12857
|
+
throw new TypeError("callback not provided");
|
|
12858
|
+
}
|
|
12859
|
+
return new Promise(function(resolve, reject) {
|
|
12860
|
+
isexe(path, options || {}, function(er, is) {
|
|
12861
|
+
if (er) {
|
|
12862
|
+
reject(er);
|
|
12863
|
+
} else {
|
|
12864
|
+
resolve(is);
|
|
12865
|
+
}
|
|
12866
|
+
});
|
|
12867
|
+
});
|
|
12868
|
+
}
|
|
12869
|
+
core(path, options || {}, function(er, is) {
|
|
12870
|
+
if (er) {
|
|
12871
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
12872
|
+
er = null;
|
|
12873
|
+
is = false;
|
|
12874
|
+
}
|
|
12875
|
+
}
|
|
12876
|
+
cb(er, is);
|
|
12877
|
+
});
|
|
12878
|
+
}
|
|
12879
|
+
function sync(path, options) {
|
|
12880
|
+
try {
|
|
12881
|
+
return core.sync(path, options || {});
|
|
12882
|
+
} catch (er) {
|
|
12883
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
12884
|
+
return false;
|
|
12885
|
+
} else {
|
|
12886
|
+
throw er;
|
|
12887
|
+
}
|
|
12888
|
+
}
|
|
12889
|
+
}
|
|
12890
|
+
});
|
|
12891
|
+
|
|
12892
|
+
// ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
12893
|
+
var require_which = __commonJS((exports, module) => {
|
|
12894
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
12895
|
+
var path = __require("path");
|
|
12896
|
+
var COLON = isWindows ? ";" : ":";
|
|
12897
|
+
var isexe = require_isexe();
|
|
12898
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
12899
|
+
var getPathInfo = (cmd, opt) => {
|
|
12900
|
+
const colon = opt.colon || COLON;
|
|
12901
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
12902
|
+
...isWindows ? [process.cwd()] : [],
|
|
12903
|
+
...(opt.path || process.env.PATH || "").split(colon)
|
|
12904
|
+
];
|
|
12905
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
12906
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
12907
|
+
if (isWindows) {
|
|
12908
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
12909
|
+
pathExt.unshift("");
|
|
12910
|
+
}
|
|
12911
|
+
return {
|
|
12912
|
+
pathEnv,
|
|
12913
|
+
pathExt,
|
|
12914
|
+
pathExtExe
|
|
12915
|
+
};
|
|
12916
|
+
};
|
|
12917
|
+
var which = (cmd, opt, cb) => {
|
|
12918
|
+
if (typeof opt === "function") {
|
|
12919
|
+
cb = opt;
|
|
12920
|
+
opt = {};
|
|
12921
|
+
}
|
|
12922
|
+
if (!opt)
|
|
12923
|
+
opt = {};
|
|
12924
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
12925
|
+
const found = [];
|
|
12926
|
+
const step = (i2) => new Promise((resolve, reject) => {
|
|
12927
|
+
if (i2 === pathEnv.length)
|
|
12928
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
12929
|
+
const ppRaw = pathEnv[i2];
|
|
12930
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12931
|
+
const pCmd = path.join(pathPart, cmd);
|
|
12932
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12933
|
+
resolve(subStep(p, i2, 0));
|
|
12934
|
+
});
|
|
12935
|
+
const subStep = (p, i2, ii) => new Promise((resolve, reject) => {
|
|
12936
|
+
if (ii === pathExt.length)
|
|
12937
|
+
return resolve(step(i2 + 1));
|
|
12938
|
+
const ext = pathExt[ii];
|
|
12939
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
12940
|
+
if (!er && is) {
|
|
12941
|
+
if (opt.all)
|
|
12942
|
+
found.push(p + ext);
|
|
12943
|
+
else
|
|
12944
|
+
return resolve(p + ext);
|
|
12945
|
+
}
|
|
12946
|
+
return resolve(subStep(p, i2, ii + 1));
|
|
12947
|
+
});
|
|
12948
|
+
});
|
|
12949
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
12950
|
+
};
|
|
12951
|
+
var whichSync = (cmd, opt) => {
|
|
12952
|
+
opt = opt || {};
|
|
12953
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
12954
|
+
const found = [];
|
|
12955
|
+
for (let i2 = 0;i2 < pathEnv.length; i2++) {
|
|
12956
|
+
const ppRaw = pathEnv[i2];
|
|
12957
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
12958
|
+
const pCmd = path.join(pathPart, cmd);
|
|
12959
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
12960
|
+
for (let j = 0;j < pathExt.length; j++) {
|
|
12961
|
+
const cur = p + pathExt[j];
|
|
12962
|
+
try {
|
|
12963
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
12964
|
+
if (is) {
|
|
12965
|
+
if (opt.all)
|
|
12966
|
+
found.push(cur);
|
|
12967
|
+
else
|
|
12968
|
+
return cur;
|
|
12969
|
+
}
|
|
12970
|
+
} catch (ex) {}
|
|
12971
|
+
}
|
|
12972
|
+
}
|
|
12973
|
+
if (opt.all && found.length)
|
|
12974
|
+
return found;
|
|
12975
|
+
if (opt.nothrow)
|
|
12976
|
+
return null;
|
|
12977
|
+
throw getNotFoundError(cmd);
|
|
12978
|
+
};
|
|
12979
|
+
module.exports = which;
|
|
12980
|
+
which.sync = whichSync;
|
|
12981
|
+
});
|
|
12982
|
+
|
|
12983
|
+
// ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
12984
|
+
var require_path_key = __commonJS((exports, module) => {
|
|
12985
|
+
var pathKey = (options = {}) => {
|
|
12986
|
+
const environment = options.env || process.env;
|
|
12987
|
+
const platform = options.platform || process.platform;
|
|
12988
|
+
if (platform !== "win32") {
|
|
12989
|
+
return "PATH";
|
|
12990
|
+
}
|
|
12991
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
12992
|
+
};
|
|
12993
|
+
module.exports = pathKey;
|
|
12994
|
+
module.exports.default = pathKey;
|
|
12995
|
+
});
|
|
12996
|
+
|
|
12997
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
12998
|
+
var require_resolveCommand = __commonJS((exports, module) => {
|
|
12999
|
+
var path = __require("path");
|
|
13000
|
+
var which = require_which();
|
|
13001
|
+
var getPathKey = require_path_key();
|
|
13002
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
13003
|
+
const env = parsed.options.env || process.env;
|
|
13004
|
+
const cwd = process.cwd();
|
|
13005
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
13006
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
|
|
13007
|
+
if (shouldSwitchCwd) {
|
|
13008
|
+
try {
|
|
13009
|
+
process.chdir(parsed.options.cwd);
|
|
13010
|
+
} catch (err) {}
|
|
13011
|
+
}
|
|
13012
|
+
let resolved;
|
|
13013
|
+
try {
|
|
13014
|
+
resolved = which.sync(parsed.command, {
|
|
13015
|
+
path: env[getPathKey({ env })],
|
|
13016
|
+
pathExt: withoutPathExt ? path.delimiter : undefined
|
|
13017
|
+
});
|
|
13018
|
+
} catch (e) {} finally {
|
|
13019
|
+
if (shouldSwitchCwd) {
|
|
13020
|
+
process.chdir(cwd);
|
|
13021
|
+
}
|
|
13022
|
+
}
|
|
13023
|
+
if (resolved) {
|
|
13024
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
13025
|
+
}
|
|
13026
|
+
return resolved;
|
|
13027
|
+
}
|
|
13028
|
+
function resolveCommand(parsed) {
|
|
13029
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
13030
|
+
}
|
|
13031
|
+
module.exports = resolveCommand;
|
|
13032
|
+
});
|
|
13033
|
+
|
|
13034
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
13035
|
+
var require_escape = __commonJS((exports, module) => {
|
|
13036
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
13037
|
+
function escapeCommand(arg) {
|
|
13038
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
13039
|
+
return arg;
|
|
13040
|
+
}
|
|
13041
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
13042
|
+
arg = `${arg}`;
|
|
13043
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
13044
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
13045
|
+
arg = `"${arg}"`;
|
|
13046
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
13047
|
+
if (doubleEscapeMetaChars) {
|
|
13048
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
13049
|
+
}
|
|
13050
|
+
return arg;
|
|
13051
|
+
}
|
|
13052
|
+
exports.command = escapeCommand;
|
|
13053
|
+
exports.argument = escapeArgument;
|
|
13054
|
+
});
|
|
13055
|
+
|
|
13056
|
+
// ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
13057
|
+
var require_shebang_regex = __commonJS((exports, module) => {
|
|
13058
|
+
module.exports = /^#!(.*)/;
|
|
13059
|
+
});
|
|
13060
|
+
|
|
13061
|
+
// ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
13062
|
+
var require_shebang_command = __commonJS((exports, module) => {
|
|
13063
|
+
var shebangRegex = require_shebang_regex();
|
|
13064
|
+
module.exports = (string = "") => {
|
|
13065
|
+
const match = string.match(shebangRegex);
|
|
13066
|
+
if (!match) {
|
|
13067
|
+
return null;
|
|
13068
|
+
}
|
|
13069
|
+
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
13070
|
+
const binary = path.split("/").pop();
|
|
13071
|
+
if (binary === "env") {
|
|
13072
|
+
return argument;
|
|
13073
|
+
}
|
|
13074
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
13075
|
+
};
|
|
13076
|
+
});
|
|
13077
|
+
|
|
13078
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
13079
|
+
var require_readShebang = __commonJS((exports, module) => {
|
|
13080
|
+
var fs = __require("fs");
|
|
13081
|
+
var shebangCommand = require_shebang_command();
|
|
13082
|
+
function readShebang(command) {
|
|
13083
|
+
const size = 150;
|
|
13084
|
+
const buffer = Buffer.alloc(size);
|
|
13085
|
+
let fd;
|
|
13086
|
+
try {
|
|
13087
|
+
fd = fs.openSync(command, "r");
|
|
13088
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
13089
|
+
fs.closeSync(fd);
|
|
13090
|
+
} catch (e) {}
|
|
13091
|
+
return shebangCommand(buffer.toString());
|
|
13092
|
+
}
|
|
13093
|
+
module.exports = readShebang;
|
|
13094
|
+
});
|
|
13095
|
+
|
|
13096
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
13097
|
+
var require_parse = __commonJS((exports, module) => {
|
|
13098
|
+
var path = __require("path");
|
|
13099
|
+
var resolveCommand = require_resolveCommand();
|
|
13100
|
+
var escape = require_escape();
|
|
13101
|
+
var readShebang = require_readShebang();
|
|
13102
|
+
var isWin = process.platform === "win32";
|
|
13103
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
13104
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
13105
|
+
function detectShebang(parsed) {
|
|
13106
|
+
parsed.file = resolveCommand(parsed);
|
|
13107
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
13108
|
+
if (shebang) {
|
|
13109
|
+
parsed.args.unshift(parsed.file);
|
|
13110
|
+
parsed.command = shebang;
|
|
13111
|
+
return resolveCommand(parsed);
|
|
13112
|
+
}
|
|
13113
|
+
return parsed.file;
|
|
13114
|
+
}
|
|
13115
|
+
function parseNonShell(parsed) {
|
|
13116
|
+
if (!isWin) {
|
|
13117
|
+
return parsed;
|
|
13118
|
+
}
|
|
13119
|
+
const commandFile = detectShebang(parsed);
|
|
13120
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
13121
|
+
if (parsed.options.forceShell || needsShell) {
|
|
13122
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
13123
|
+
parsed.command = path.normalize(parsed.command);
|
|
13124
|
+
parsed.command = escape.command(parsed.command);
|
|
13125
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
13126
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
13127
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
13128
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
13129
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
13130
|
+
}
|
|
13131
|
+
return parsed;
|
|
13132
|
+
}
|
|
13133
|
+
function parse(command, args, options) {
|
|
13134
|
+
if (args && !Array.isArray(args)) {
|
|
13135
|
+
options = args;
|
|
13136
|
+
args = null;
|
|
13137
|
+
}
|
|
13138
|
+
args = args ? args.slice(0) : [];
|
|
13139
|
+
options = Object.assign({}, options);
|
|
13140
|
+
const parsed = {
|
|
13141
|
+
command,
|
|
13142
|
+
args,
|
|
13143
|
+
options,
|
|
13144
|
+
file: undefined,
|
|
13145
|
+
original: {
|
|
13146
|
+
command,
|
|
13147
|
+
args
|
|
13148
|
+
}
|
|
13149
|
+
};
|
|
13150
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
13151
|
+
}
|
|
13152
|
+
module.exports = parse;
|
|
13153
|
+
});
|
|
13154
|
+
|
|
13155
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
13156
|
+
var require_enoent = __commonJS((exports, module) => {
|
|
13157
|
+
var isWin = process.platform === "win32";
|
|
13158
|
+
function notFoundError(original, syscall) {
|
|
13159
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
13160
|
+
code: "ENOENT",
|
|
13161
|
+
errno: "ENOENT",
|
|
13162
|
+
syscall: `${syscall} ${original.command}`,
|
|
13163
|
+
path: original.command,
|
|
13164
|
+
spawnargs: original.args
|
|
13165
|
+
});
|
|
13166
|
+
}
|
|
13167
|
+
function hookChildProcess(cp, parsed) {
|
|
13168
|
+
if (!isWin) {
|
|
13169
|
+
return;
|
|
13170
|
+
}
|
|
13171
|
+
const originalEmit = cp.emit;
|
|
13172
|
+
cp.emit = function(name, arg1) {
|
|
13173
|
+
if (name === "exit") {
|
|
13174
|
+
const err = verifyENOENT(arg1, parsed);
|
|
13175
|
+
if (err) {
|
|
13176
|
+
return originalEmit.call(cp, "error", err);
|
|
13177
|
+
}
|
|
13178
|
+
}
|
|
13179
|
+
return originalEmit.apply(cp, arguments);
|
|
13180
|
+
};
|
|
13181
|
+
}
|
|
13182
|
+
function verifyENOENT(status, parsed) {
|
|
13183
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
13184
|
+
return notFoundError(parsed.original, "spawn");
|
|
13185
|
+
}
|
|
13186
|
+
return null;
|
|
13187
|
+
}
|
|
13188
|
+
function verifyENOENTSync(status, parsed) {
|
|
13189
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
13190
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
13191
|
+
}
|
|
13192
|
+
return null;
|
|
13193
|
+
}
|
|
13194
|
+
module.exports = {
|
|
13195
|
+
hookChildProcess,
|
|
13196
|
+
verifyENOENT,
|
|
13197
|
+
verifyENOENTSync,
|
|
13198
|
+
notFoundError
|
|
13199
|
+
};
|
|
13200
|
+
});
|
|
13201
|
+
|
|
13202
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
13203
|
+
var require_cross_spawn = __commonJS((exports, module) => {
|
|
13204
|
+
var cp = __require("child_process");
|
|
13205
|
+
var parse = require_parse();
|
|
13206
|
+
var enoent = require_enoent();
|
|
13207
|
+
function spawn2(command, args, options) {
|
|
13208
|
+
const parsed = parse(command, args, options);
|
|
13209
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
13210
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
13211
|
+
return spawned;
|
|
13212
|
+
}
|
|
13213
|
+
function spawnSync(command, args, options) {
|
|
13214
|
+
const parsed = parse(command, args, options);
|
|
13215
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
13216
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
13217
|
+
return result;
|
|
13218
|
+
}
|
|
13219
|
+
module.exports = spawn2;
|
|
13220
|
+
module.exports.spawn = spawn2;
|
|
13221
|
+
module.exports.sync = spawnSync;
|
|
13222
|
+
module.exports._parse = parse;
|
|
13223
|
+
module.exports._enoent = enoent;
|
|
13224
|
+
});
|
|
13225
|
+
|
|
13226
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/process.js
|
|
13227
|
+
var init_process = () => {};
|
|
13228
|
+
|
|
13229
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/server.js
|
|
13230
|
+
var import_cross_spawn;
|
|
13231
|
+
var init_server2 = __esm(() => {
|
|
13232
|
+
init_process();
|
|
13233
|
+
import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
13234
|
+
});
|
|
13235
|
+
|
|
13236
|
+
// ../../node_modules/.pnpm/@opencode-ai+sdk@1.14.22/node_modules/@opencode-ai/sdk/dist/index.js
|
|
13237
|
+
var init_dist = __esm(() => {
|
|
13238
|
+
init_client4();
|
|
13239
|
+
init_server2();
|
|
13240
|
+
init_client4();
|
|
13241
|
+
init_server2();
|
|
13242
|
+
});
|
|
13243
|
+
|
|
13244
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/select-agent.ts
|
|
13245
|
+
function selectAgent(agents) {
|
|
13246
|
+
const primaries = agents.filter((a) => a.mode !== "subagent");
|
|
13247
|
+
if (primaries.length === 0) {
|
|
13248
|
+
throw new Error("No usable opencode agent available (server returned 0 non-subagent agents)");
|
|
13249
|
+
}
|
|
13250
|
+
const buildAgent = primaries.find((a) => a.name === "build");
|
|
13251
|
+
return buildAgent ?? primaries[0];
|
|
13252
|
+
}
|
|
13253
|
+
|
|
13254
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/compose-system-prompt.ts
|
|
13255
|
+
function composeSystemPrompt(agentPrompt, chatroomSystemPrompt) {
|
|
13256
|
+
const trimmedAgent = agentPrompt?.trim() ?? "";
|
|
13257
|
+
const trimmedChatroom = chatroomSystemPrompt.trim();
|
|
13258
|
+
if (!trimmedAgent && !trimmedChatroom) {
|
|
13259
|
+
return;
|
|
13260
|
+
}
|
|
13261
|
+
if (!trimmedAgent) {
|
|
13262
|
+
return trimmedChatroom;
|
|
13263
|
+
}
|
|
13264
|
+
if (!trimmedChatroom) {
|
|
13265
|
+
return trimmedAgent;
|
|
13266
|
+
}
|
|
13267
|
+
return `${trimmedAgent}${CHATROOM_PROMPT_SEPARATOR}${trimmedChatroom}`;
|
|
13268
|
+
}
|
|
13269
|
+
var CHATROOM_PROMPT_SEPARATOR = `
|
|
13270
|
+
|
|
13271
|
+
# Chatroom Role & Instructions (Important)
|
|
13272
|
+
|
|
13273
|
+
`;
|
|
13274
|
+
|
|
13275
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/parse-listening-url.ts
|
|
13276
|
+
async function waitForListeningUrl(child, options) {
|
|
13277
|
+
return new Promise((resolve, reject) => {
|
|
13278
|
+
const buffers = { stdout: "", stderr: "" };
|
|
13279
|
+
const cleanup = () => {
|
|
13280
|
+
clearTimeout(timer);
|
|
13281
|
+
child.stdout?.removeListener("data", onStdout);
|
|
13282
|
+
child.stderr?.removeListener("data", onStderr);
|
|
13283
|
+
child.removeListener("exit", onExit);
|
|
13284
|
+
};
|
|
13285
|
+
const tryMatch = (key, chunk) => {
|
|
13286
|
+
buffers[key] += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
13287
|
+
const match = buffers[key].match(LISTENING_URL_RE);
|
|
13288
|
+
if (match) {
|
|
13289
|
+
cleanup();
|
|
13290
|
+
resolve(match[1]);
|
|
13291
|
+
return;
|
|
13292
|
+
}
|
|
13293
|
+
const lastNl = buffers[key].lastIndexOf(`
|
|
13294
|
+
`);
|
|
13295
|
+
if (lastNl >= 0) {
|
|
13296
|
+
buffers[key] = buffers[key].slice(lastNl + 1);
|
|
13297
|
+
}
|
|
13298
|
+
};
|
|
13299
|
+
const onStdout = (chunk) => tryMatch("stdout", chunk);
|
|
13300
|
+
const onStderr = (chunk) => tryMatch("stderr", chunk);
|
|
13301
|
+
const onExit = (code2, signal) => {
|
|
13302
|
+
cleanup();
|
|
13303
|
+
reject(new Error(`opencode serve exited unexpectedly during startup (code=${code2}, signal=${signal})`));
|
|
13304
|
+
};
|
|
13305
|
+
child.stdout?.on("data", onStdout);
|
|
13306
|
+
child.stderr?.on("data", onStderr);
|
|
13307
|
+
child.on("exit", onExit);
|
|
13308
|
+
const timer = setTimeout(() => {
|
|
13309
|
+
cleanup();
|
|
13310
|
+
reject(new Error(`opencode serve did not print a listening URL within ${options.timeoutMs}ms`));
|
|
13311
|
+
}, options.timeoutMs);
|
|
13312
|
+
});
|
|
13313
|
+
}
|
|
13314
|
+
var LISTENING_URL_RE;
|
|
13315
|
+
var init_parse_listening_url = __esm(() => {
|
|
13316
|
+
LISTENING_URL_RE = /opencode server listening on (https?:\/\/127\.0\.0\.1:\d+(?:\/[^\s]*)?)/;
|
|
13317
|
+
});
|
|
13318
|
+
|
|
13319
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/session-metadata-store.ts
|
|
13320
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
13321
|
+
import { dirname as dirname2, join as join3 } from "node:path";
|
|
13322
|
+
import { homedir as homedir2 } from "node:os";
|
|
13323
|
+
|
|
13324
|
+
class FileSessionMetadataStore {
|
|
13325
|
+
filePath;
|
|
13326
|
+
constructor(filePath) {
|
|
13327
|
+
this.filePath = filePath ?? join3(homedir2(), ".chatroom", "opencode-sdk-sessions.json");
|
|
13328
|
+
}
|
|
13329
|
+
load() {
|
|
13330
|
+
try {
|
|
13331
|
+
if (existsSync2(this.filePath)) {
|
|
13332
|
+
return JSON.parse(readFileSync3(this.filePath, "utf-8"));
|
|
13333
|
+
}
|
|
13334
|
+
} catch {}
|
|
13335
|
+
return {};
|
|
13336
|
+
}
|
|
13337
|
+
save(sessions) {
|
|
13338
|
+
try {
|
|
13339
|
+
const dir = dirname2(this.filePath);
|
|
13340
|
+
if (!existsSync2(dir)) {
|
|
13341
|
+
mkdirSync2(dir, { recursive: true });
|
|
13342
|
+
}
|
|
13343
|
+
writeFileSync2(this.filePath, JSON.stringify(sessions, null, 2));
|
|
13344
|
+
} catch {}
|
|
13345
|
+
}
|
|
13346
|
+
get(sessionId) {
|
|
13347
|
+
return this.load()[sessionId];
|
|
13348
|
+
}
|
|
13349
|
+
findByPid(pid) {
|
|
13350
|
+
const sessions = this.load();
|
|
13351
|
+
return Object.values(sessions).find((m) => m.pid === pid);
|
|
13352
|
+
}
|
|
13353
|
+
upsert(meta) {
|
|
13354
|
+
const sessions = this.load();
|
|
13355
|
+
sessions[meta.sessionId] = meta;
|
|
13356
|
+
this.save(sessions);
|
|
13357
|
+
}
|
|
13358
|
+
remove(sessionId) {
|
|
13359
|
+
const sessions = this.load();
|
|
13360
|
+
delete sessions[sessionId];
|
|
13361
|
+
this.save(sessions);
|
|
13362
|
+
}
|
|
13363
|
+
}
|
|
13364
|
+
var init_session_metadata_store = () => {};
|
|
13365
|
+
|
|
13366
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/node-streams.ts
|
|
13367
|
+
function forwardFiltered(source, target, shouldDrop) {
|
|
13368
|
+
if (!source)
|
|
13369
|
+
return;
|
|
13370
|
+
let buf = "";
|
|
13371
|
+
source.on("data", (chunk) => {
|
|
13372
|
+
buf += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
13373
|
+
let nl;
|
|
13374
|
+
while ((nl = buf.indexOf(`
|
|
13375
|
+
`)) !== -1) {
|
|
13376
|
+
const line = buf.slice(0, nl);
|
|
13377
|
+
buf = buf.slice(nl + 1);
|
|
13378
|
+
if (!shouldDrop(line))
|
|
13379
|
+
target.write(line + `
|
|
13380
|
+
`);
|
|
13381
|
+
}
|
|
13382
|
+
});
|
|
13383
|
+
source.on("end", () => {
|
|
13384
|
+
if (buf.length > 0 && !shouldDrop(buf))
|
|
13385
|
+
target.write(buf);
|
|
13386
|
+
buf = "";
|
|
13387
|
+
});
|
|
13388
|
+
}
|
|
13389
|
+
|
|
13390
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/pure.ts
|
|
13391
|
+
function parseModelId(model) {
|
|
13392
|
+
if (!model)
|
|
13393
|
+
return;
|
|
13394
|
+
const slashIdx = model.indexOf("/");
|
|
13395
|
+
if (slashIdx === -1)
|
|
13396
|
+
return;
|
|
13397
|
+
const providerID = model.substring(0, slashIdx);
|
|
13398
|
+
const modelID = model.substring(slashIdx + 1);
|
|
13399
|
+
if (!providerID || !modelID)
|
|
13400
|
+
return;
|
|
13401
|
+
return { providerID, modelID };
|
|
13402
|
+
}
|
|
13403
|
+
var isInfoLine = (line) => line.trimStart().startsWith("INFO ");
|
|
13404
|
+
|
|
13405
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/session-event-forwarder.ts
|
|
13406
|
+
function formatLogLine(options, kind, payload) {
|
|
13407
|
+
const ts = options.now ? options.now() : new Date().toISOString();
|
|
13408
|
+
return `[${ts}] role:${options.role} ${kind}]${payload ? ` ${payload}` : ""}`;
|
|
13409
|
+
}
|
|
13410
|
+
function eventSessionId(event) {
|
|
13411
|
+
const p = event.properties;
|
|
13412
|
+
if (!p || typeof p !== "object")
|
|
13413
|
+
return;
|
|
13414
|
+
if ("sessionID" in p && typeof p.sessionID === "string")
|
|
13415
|
+
return p.sessionID;
|
|
13416
|
+
if ("part" in p && p.part && typeof p.part === "object") {
|
|
13417
|
+
return p.part.sessionID;
|
|
13418
|
+
}
|
|
13419
|
+
if ("info" in p && p.info && typeof p.info === "object") {
|
|
13420
|
+
return p.info.sessionID;
|
|
13421
|
+
}
|
|
13422
|
+
return;
|
|
13423
|
+
}
|
|
13424
|
+
function startSessionEventForwarder(client4, options) {
|
|
13425
|
+
const target = options.target ?? process.stdout;
|
|
13426
|
+
const errorTarget = options.errorTarget ?? process.stderr;
|
|
13427
|
+
let cancelled = false;
|
|
13428
|
+
let doneResolve;
|
|
13429
|
+
const donePromise = new Promise((resolve) => {
|
|
13430
|
+
doneResolve = resolve;
|
|
13431
|
+
});
|
|
13432
|
+
async function run() {
|
|
13433
|
+
try {
|
|
13434
|
+
const result = await client4.event.subscribe();
|
|
13435
|
+
const stream = result.stream;
|
|
13436
|
+
if (cancelled) {
|
|
13437
|
+
await stream.return?.(undefined);
|
|
13438
|
+
return;
|
|
13439
|
+
}
|
|
13440
|
+
for await (const event of stream) {
|
|
13441
|
+
if (cancelled) {
|
|
13442
|
+
await stream.return?.(undefined);
|
|
13443
|
+
break;
|
|
13444
|
+
}
|
|
13445
|
+
const eventSession = eventSessionId(event);
|
|
13446
|
+
if (eventSession && eventSession !== options.sessionId)
|
|
13447
|
+
continue;
|
|
13448
|
+
if (eventSession === undefined && event.type !== "session.idle" && event.type !== "session.compacted" && event.type !== "session.error" && event.type !== "session.status" && event.type !== "file.edited")
|
|
13449
|
+
continue;
|
|
13450
|
+
switch (event.type) {
|
|
13451
|
+
case "message.part.updated": {
|
|
13452
|
+
const props = event.properties;
|
|
13453
|
+
const part = props?.part;
|
|
13454
|
+
if (part?.type === "text" && part.delta) {
|
|
13455
|
+
target.write(formatLogLine(options, "text", part.delta) + `
|
|
13456
|
+
`);
|
|
13457
|
+
} else if (part?.type === "tool" && part.tool) {
|
|
13458
|
+
const state = props?.state ?? "started";
|
|
13459
|
+
target.write(formatLogLine(options, "tool: " + part.tool, state) + `
|
|
13460
|
+
`);
|
|
13461
|
+
}
|
|
13462
|
+
break;
|
|
13463
|
+
}
|
|
13464
|
+
case "file.edited": {
|
|
13465
|
+
const props = event.properties;
|
|
13466
|
+
target.write(formatLogLine(options, "file", props?.file) + `
|
|
13467
|
+
`);
|
|
13468
|
+
break;
|
|
13469
|
+
}
|
|
13470
|
+
case "session.idle": {
|
|
13471
|
+
target.write(formatLogLine(options, "agent_end") + `
|
|
13472
|
+
`);
|
|
13473
|
+
break;
|
|
13474
|
+
}
|
|
13475
|
+
case "session.compacted": {
|
|
13476
|
+
target.write(formatLogLine(options, "compacted") + `
|
|
13477
|
+
`);
|
|
13478
|
+
break;
|
|
13479
|
+
}
|
|
13480
|
+
case "session.status": {
|
|
13481
|
+
const props = event.properties;
|
|
13482
|
+
target.write(formatLogLine(options, "status", props?.status?.type) + `
|
|
13483
|
+
`);
|
|
13484
|
+
break;
|
|
13485
|
+
}
|
|
13486
|
+
case "session.error": {
|
|
13487
|
+
const props = event.properties;
|
|
13488
|
+
const err = props?.error;
|
|
13489
|
+
const errMsg = err?.name ? `${err.name}${err?.data?.message ? ": " + err.data.message : ""}` : String(err ?? "unknown");
|
|
13490
|
+
errorTarget.write(formatLogLine(options, "error", errMsg) + `
|
|
13491
|
+
`);
|
|
13492
|
+
break;
|
|
13493
|
+
}
|
|
13494
|
+
default:
|
|
13495
|
+
break;
|
|
13496
|
+
}
|
|
13497
|
+
}
|
|
13498
|
+
} catch (err) {
|
|
13499
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
13500
|
+
errorTarget.write(formatLogLine(options, "error", message) + `
|
|
13501
|
+
`);
|
|
13502
|
+
} finally {
|
|
13503
|
+
doneResolve();
|
|
13504
|
+
}
|
|
13505
|
+
}
|
|
13506
|
+
run();
|
|
13507
|
+
return {
|
|
13508
|
+
stop: () => {
|
|
13509
|
+
cancelled = true;
|
|
13510
|
+
},
|
|
13511
|
+
done: donePromise
|
|
13512
|
+
};
|
|
13513
|
+
}
|
|
13514
|
+
|
|
13515
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/opencode-sdk-agent-service.ts
|
|
13516
|
+
async function withTimeout(p, ms, label) {
|
|
13517
|
+
let timer;
|
|
13518
|
+
try {
|
|
13519
|
+
return await Promise.race([
|
|
13520
|
+
p,
|
|
13521
|
+
new Promise((_, reject) => {
|
|
13522
|
+
timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
|
|
13523
|
+
})
|
|
13524
|
+
]);
|
|
13525
|
+
} finally {
|
|
13526
|
+
if (timer)
|
|
13527
|
+
clearTimeout(timer);
|
|
13528
|
+
}
|
|
13529
|
+
}
|
|
13530
|
+
var OPENCODE_COMMAND2 = "opencode", SERVE_STARTUP_TIMEOUT_MS = 1e4, SESSION_CREATE_TIMEOUT_MS = 30000, PROMPT_ASYNC_TIMEOUT_MS = 60000, SESSION_ABORT_TIMEOUT_MS = 5000, AGENTS_LIST_TIMEOUT_MS = 1e4, OpenCodeSdkAgentService;
|
|
13531
|
+
var init_opencode_sdk_agent_service = __esm(() => {
|
|
13532
|
+
init_dist();
|
|
13533
|
+
init_base_cli_agent_service();
|
|
13534
|
+
init_parse_listening_url();
|
|
13535
|
+
init_session_metadata_store();
|
|
13536
|
+
OpenCodeSdkAgentService = class OpenCodeSdkAgentService extends BaseCLIAgentService {
|
|
13537
|
+
id = "opencode-sdk";
|
|
13538
|
+
displayName = "OpenCode (SDK)";
|
|
13539
|
+
command = OPENCODE_COMMAND2;
|
|
13540
|
+
sessionStore;
|
|
13541
|
+
forwarders = new Map;
|
|
13542
|
+
constructor(deps) {
|
|
13543
|
+
super(deps);
|
|
13544
|
+
this.sessionStore = deps?.sessionMetadataStore ?? new FileSessionMetadataStore;
|
|
13545
|
+
}
|
|
13546
|
+
isInstalled() {
|
|
13547
|
+
return this.checkInstalled(OPENCODE_COMMAND2);
|
|
13548
|
+
}
|
|
13549
|
+
getVersion() {
|
|
13550
|
+
return this.checkVersion(OPENCODE_COMMAND2);
|
|
13551
|
+
}
|
|
13552
|
+
async listModels() {
|
|
13553
|
+
try {
|
|
13554
|
+
const output = this.deps.execSync(`${OPENCODE_COMMAND2} models`, {
|
|
13555
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
13556
|
+
timeout: 1e4
|
|
13557
|
+
}).toString().trim();
|
|
13558
|
+
if (!output)
|
|
13559
|
+
return [];
|
|
13560
|
+
return output.split(`
|
|
13561
|
+
`).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
13562
|
+
} catch {
|
|
13563
|
+
return [];
|
|
13564
|
+
}
|
|
13565
|
+
}
|
|
13566
|
+
async stop(pid) {
|
|
13567
|
+
const forwarder = this.forwarders.get(pid);
|
|
13568
|
+
if (forwarder) {
|
|
13569
|
+
forwarder.stop();
|
|
13570
|
+
this.forwarders.delete(pid);
|
|
13571
|
+
}
|
|
13572
|
+
const meta = this.sessionStore.findByPid(pid);
|
|
13573
|
+
if (meta) {
|
|
13574
|
+
try {
|
|
13575
|
+
const client4 = createOpencodeClient({ baseUrl: meta.baseUrl });
|
|
13576
|
+
await withTimeout(client4.session.abort({ path: { id: meta.sessionId } }), SESSION_ABORT_TIMEOUT_MS, "session.abort");
|
|
13577
|
+
} catch (err) {
|
|
13578
|
+
console.warn(`[opencode-sdk] session.abort for pid=${pid} sessionId=${meta.sessionId} failed (continuing with SIGTERM):`, err instanceof Error ? err.message : err);
|
|
13579
|
+
}
|
|
13580
|
+
}
|
|
13581
|
+
await super.stop(pid);
|
|
13582
|
+
}
|
|
13583
|
+
async spawn(options) {
|
|
13584
|
+
const { prompt, systemPrompt, model, context } = options;
|
|
13585
|
+
const childProcess = this.deps.spawn(OPENCODE_COMMAND2, ["serve", "--print-logs"], {
|
|
13586
|
+
cwd: options.workingDir,
|
|
13587
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
13588
|
+
shell: false,
|
|
13589
|
+
detached: true,
|
|
13590
|
+
env: {
|
|
13591
|
+
...process.env,
|
|
13592
|
+
GIT_EDITOR: "true",
|
|
13593
|
+
GIT_SEQUENCE_EDITOR: "true"
|
|
13594
|
+
}
|
|
13595
|
+
});
|
|
13596
|
+
if (!childProcess.pid) {
|
|
13597
|
+
throw new Error("Failed to spawn opencode serve process");
|
|
13598
|
+
}
|
|
13599
|
+
const pid = childProcess.pid;
|
|
13600
|
+
const baseUrl = await waitForListeningUrl(childProcess, {
|
|
13601
|
+
timeoutMs: SERVE_STARTUP_TIMEOUT_MS
|
|
13602
|
+
}).catch((err) => {
|
|
13603
|
+
childProcess.kill();
|
|
13604
|
+
throw err;
|
|
13605
|
+
});
|
|
13606
|
+
const client4 = createOpencodeClient({
|
|
13607
|
+
baseUrl
|
|
13608
|
+
});
|
|
13609
|
+
let sessionId;
|
|
13610
|
+
let forwarder;
|
|
13611
|
+
try {
|
|
13612
|
+
const sessionCreateResult = await withTimeout(client4.session.create({ body: {} }), SESSION_CREATE_TIMEOUT_MS, "session.create");
|
|
13613
|
+
if (!sessionCreateResult.data?.id) {
|
|
13614
|
+
throw new Error("Failed to create session");
|
|
13615
|
+
}
|
|
13616
|
+
sessionId = sessionCreateResult.data.id;
|
|
13617
|
+
forwarder = startSessionEventForwarder(client4, {
|
|
13618
|
+
sessionId,
|
|
13619
|
+
role: context.role
|
|
13620
|
+
});
|
|
13621
|
+
const agentsResponse = await withTimeout(client4.app.agents(), AGENTS_LIST_TIMEOUT_MS, "app.agents");
|
|
13622
|
+
const availableAgents = agentsResponse.data ?? [];
|
|
13623
|
+
const selected = selectAgent(availableAgents);
|
|
13624
|
+
const composedSystem = composeSystemPrompt(selected.prompt, systemPrompt);
|
|
13625
|
+
const modelParts = model ? parseModelId(model) : undefined;
|
|
13626
|
+
await withTimeout(client4.session.promptAsync({
|
|
13627
|
+
path: { id: sessionId },
|
|
13628
|
+
body: {
|
|
13629
|
+
agent: selected.name,
|
|
13630
|
+
...composedSystem ? { system: composedSystem } : {},
|
|
13631
|
+
parts: [{ type: "text", text: prompt }],
|
|
13632
|
+
...modelParts ? { model: modelParts } : {}
|
|
13633
|
+
}
|
|
13634
|
+
}), PROMPT_ASYNC_TIMEOUT_MS, "session.promptAsync");
|
|
13635
|
+
} catch (err) {
|
|
13636
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
13637
|
+
process.stderr.write(`[${new Date().toISOString()}] role:${context.role} spawn-error] ${reason}
|
|
13638
|
+
`);
|
|
13639
|
+
forwarder?.stop();
|
|
13640
|
+
childProcess.kill();
|
|
13641
|
+
if (sessionId)
|
|
13642
|
+
this.sessionStore.remove(sessionId);
|
|
13643
|
+
throw err;
|
|
13644
|
+
}
|
|
13645
|
+
const meta = {
|
|
13646
|
+
sessionId,
|
|
13647
|
+
machineId: context.machineId,
|
|
13648
|
+
chatroomId: context.chatroomId,
|
|
13649
|
+
role: context.role,
|
|
13650
|
+
pid,
|
|
13651
|
+
createdAt: new Date().toISOString(),
|
|
13652
|
+
baseUrl
|
|
13653
|
+
};
|
|
13654
|
+
this.sessionStore.upsert(meta);
|
|
13655
|
+
const entry = this.registerProcess(pid, context);
|
|
13656
|
+
if (forwarder)
|
|
13657
|
+
this.forwarders.set(pid, forwarder);
|
|
13658
|
+
const outputCallbacks = [];
|
|
13659
|
+
forwardFiltered(childProcess.stdout, process.stdout, isInfoLine);
|
|
13660
|
+
forwardFiltered(childProcess.stderr, process.stderr, isInfoLine);
|
|
13661
|
+
if (childProcess.stdout) {
|
|
13662
|
+
childProcess.stdout.on("data", () => {
|
|
13663
|
+
entry.lastOutputAt = Date.now();
|
|
13664
|
+
for (const cb of outputCallbacks)
|
|
13665
|
+
cb();
|
|
13666
|
+
});
|
|
13667
|
+
}
|
|
13668
|
+
if (childProcess.stderr) {
|
|
13669
|
+
childProcess.stderr.on("data", () => {
|
|
13670
|
+
entry.lastOutputAt = Date.now();
|
|
13671
|
+
for (const cb of outputCallbacks)
|
|
13672
|
+
cb();
|
|
13673
|
+
});
|
|
13674
|
+
}
|
|
13675
|
+
return {
|
|
13676
|
+
pid,
|
|
13677
|
+
onExit: (cb) => {
|
|
13678
|
+
childProcess.on("exit", (code2, signal) => {
|
|
13679
|
+
const fwd = this.forwarders.get(pid);
|
|
13680
|
+
if (fwd) {
|
|
13681
|
+
fwd.stop();
|
|
13682
|
+
this.forwarders.delete(pid);
|
|
13683
|
+
}
|
|
13684
|
+
this.sessionStore.remove(sessionId);
|
|
13685
|
+
this.deleteProcess(pid);
|
|
13686
|
+
cb({ code: code2, signal, context });
|
|
13687
|
+
});
|
|
13688
|
+
},
|
|
13689
|
+
onOutput: (cb) => {
|
|
13690
|
+
outputCallbacks.push(cb);
|
|
13691
|
+
}
|
|
13692
|
+
};
|
|
13693
|
+
}
|
|
13694
|
+
};
|
|
13695
|
+
});
|
|
13696
|
+
|
|
13697
|
+
// src/infrastructure/services/remote-agents/opencode-sdk/index.ts
|
|
13698
|
+
var init_opencode_sdk = __esm(() => {
|
|
13699
|
+
init_opencode_sdk_agent_service();
|
|
13700
|
+
});
|
|
13701
|
+
|
|
11383
13702
|
// src/infrastructure/services/remote-agents/init-registry.ts
|
|
11384
13703
|
function initHarnessRegistry() {
|
|
11385
13704
|
if (initialized)
|
|
11386
13705
|
return;
|
|
11387
13706
|
registerHarness(new OpenCodeAgentService);
|
|
13707
|
+
registerHarness(new OpenCodeSdkAgentService);
|
|
11388
13708
|
registerHarness(new PiAgentService);
|
|
11389
13709
|
registerHarness(new CursorAgentService);
|
|
11390
13710
|
registerHarness(new ClaudeCodeAgentService);
|
|
@@ -11397,6 +13717,7 @@ var init_init_registry = __esm(() => {
|
|
|
11397
13717
|
init_copilot();
|
|
11398
13718
|
init_cursor();
|
|
11399
13719
|
init_opencode();
|
|
13720
|
+
init_opencode_sdk();
|
|
11400
13721
|
init_pi();
|
|
11401
13722
|
init_registry();
|
|
11402
13723
|
});
|
|
@@ -11442,28 +13763,28 @@ var MACHINE_CONFIG_VERSION = "1";
|
|
|
11442
13763
|
|
|
11443
13764
|
// src/infrastructure/machine/storage.ts
|
|
11444
13765
|
import { randomUUID } from "node:crypto";
|
|
11445
|
-
import { existsSync as
|
|
11446
|
-
import { homedir as
|
|
11447
|
-
import { join as
|
|
13766
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync3, renameSync } from "node:fs";
|
|
13767
|
+
import { homedir as homedir3, hostname as hostname2 } from "node:os";
|
|
13768
|
+
import { join as join4 } from "node:path";
|
|
11448
13769
|
function chatroomConfigDir() {
|
|
11449
|
-
return
|
|
13770
|
+
return join4(homedir3(), ".chatroom");
|
|
11450
13771
|
}
|
|
11451
13772
|
function ensureConfigDir2() {
|
|
11452
13773
|
const dir = chatroomConfigDir();
|
|
11453
|
-
if (!
|
|
11454
|
-
|
|
13774
|
+
if (!existsSync3(dir)) {
|
|
13775
|
+
mkdirSync3(dir, { recursive: true, mode: 448 });
|
|
11455
13776
|
}
|
|
11456
13777
|
}
|
|
11457
13778
|
function getMachineConfigPath() {
|
|
11458
|
-
return
|
|
13779
|
+
return join4(chatroomConfigDir(), MACHINE_FILE);
|
|
11459
13780
|
}
|
|
11460
13781
|
function loadConfigFile() {
|
|
11461
13782
|
const configPath = getMachineConfigPath();
|
|
11462
|
-
if (!
|
|
13783
|
+
if (!existsSync3(configPath)) {
|
|
11463
13784
|
return null;
|
|
11464
13785
|
}
|
|
11465
13786
|
try {
|
|
11466
|
-
const content =
|
|
13787
|
+
const content = readFileSync4(configPath, "utf-8");
|
|
11467
13788
|
return JSON.parse(content);
|
|
11468
13789
|
} catch (error) {
|
|
11469
13790
|
console.warn(`⚠️ Failed to read machine config at ${configPath}: ${error.message}`);
|
|
@@ -11477,7 +13798,7 @@ function saveConfigFile(configFile) {
|
|
|
11477
13798
|
const configPath = getMachineConfigPath();
|
|
11478
13799
|
const tempPath = `${configPath}.tmp`;
|
|
11479
13800
|
const content = JSON.stringify(configFile, null, 2);
|
|
11480
|
-
|
|
13801
|
+
writeFileSync3(tempPath, content, { encoding: "utf-8", mode: 384 });
|
|
11481
13802
|
renameSync(tempPath, configPath);
|
|
11482
13803
|
}
|
|
11483
13804
|
function loadMachineConfig() {
|
|
@@ -11545,27 +13866,27 @@ var init_storage2 = __esm(() => {
|
|
|
11545
13866
|
});
|
|
11546
13867
|
|
|
11547
13868
|
// src/infrastructure/machine/daemon-state.ts
|
|
11548
|
-
import { existsSync as
|
|
11549
|
-
import { homedir as
|
|
11550
|
-
import { join as
|
|
13869
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4, renameSync as renameSync2 } from "node:fs";
|
|
13870
|
+
import { homedir as homedir4 } from "node:os";
|
|
13871
|
+
import { join as join5 } from "node:path";
|
|
11551
13872
|
function agentKey(chatroomId, role) {
|
|
11552
13873
|
return `${chatroomId}/${role}`;
|
|
11553
13874
|
}
|
|
11554
13875
|
function ensureStateDir() {
|
|
11555
|
-
if (!
|
|
11556
|
-
|
|
13876
|
+
if (!existsSync4(STATE_DIR)) {
|
|
13877
|
+
mkdirSync4(STATE_DIR, { recursive: true, mode: 448 });
|
|
11557
13878
|
}
|
|
11558
13879
|
}
|
|
11559
13880
|
function stateFilePath(machineId) {
|
|
11560
|
-
return
|
|
13881
|
+
return join5(STATE_DIR, `${machineId}.json`);
|
|
11561
13882
|
}
|
|
11562
13883
|
function loadDaemonState(machineId) {
|
|
11563
13884
|
const filePath = stateFilePath(machineId);
|
|
11564
|
-
if (!
|
|
13885
|
+
if (!existsSync4(filePath)) {
|
|
11565
13886
|
return null;
|
|
11566
13887
|
}
|
|
11567
13888
|
try {
|
|
11568
|
-
const content =
|
|
13889
|
+
const content = readFileSync5(filePath, "utf-8");
|
|
11569
13890
|
return JSON.parse(content);
|
|
11570
13891
|
} catch {
|
|
11571
13892
|
return null;
|
|
@@ -11576,7 +13897,7 @@ function saveDaemonState(state) {
|
|
|
11576
13897
|
const filePath = stateFilePath(state.machineId);
|
|
11577
13898
|
const tempPath = `${filePath}.tmp`;
|
|
11578
13899
|
const content = JSON.stringify(state, null, 2);
|
|
11579
|
-
|
|
13900
|
+
writeFileSync4(tempPath, content, { encoding: "utf-8", mode: 384 });
|
|
11580
13901
|
renameSync2(tempPath, filePath);
|
|
11581
13902
|
}
|
|
11582
13903
|
function loadOrCreate(machineId) {
|
|
@@ -11639,8 +13960,8 @@ function loadEventCursor(machineId) {
|
|
|
11639
13960
|
}
|
|
11640
13961
|
var CHATROOM_DIR2, STATE_DIR, STATE_VERSION = "1";
|
|
11641
13962
|
var init_daemon_state = __esm(() => {
|
|
11642
|
-
CHATROOM_DIR2 =
|
|
11643
|
-
STATE_DIR =
|
|
13963
|
+
CHATROOM_DIR2 = join5(homedir4(), ".chatroom");
|
|
13964
|
+
STATE_DIR = join5(CHATROOM_DIR2, "machines", "state");
|
|
11644
13965
|
});
|
|
11645
13966
|
|
|
11646
13967
|
// src/infrastructure/machine/index.ts
|
|
@@ -11679,10 +14000,10 @@ __export(exports_auth_status, {
|
|
|
11679
14000
|
authStatus: () => authStatus
|
|
11680
14001
|
});
|
|
11681
14002
|
async function createDefaultDeps3() {
|
|
11682
|
-
const
|
|
14003
|
+
const client4 = await getConvexClient();
|
|
11683
14004
|
return {
|
|
11684
14005
|
backend: {
|
|
11685
|
-
query: (endpoint, args) =>
|
|
14006
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
11686
14007
|
},
|
|
11687
14008
|
session: {
|
|
11688
14009
|
loadAuthData,
|
|
@@ -12001,9 +14322,9 @@ var init_init = __esm(() => {
|
|
|
12001
14322
|
});
|
|
12002
14323
|
|
|
12003
14324
|
// src/tools/output.ts
|
|
12004
|
-
import { join as
|
|
14325
|
+
import { join as join6 } from "node:path";
|
|
12005
14326
|
function resolveChatroomDir(workingDir) {
|
|
12006
|
-
return
|
|
14327
|
+
return join6(workingDir, CHATROOM_DIR3);
|
|
12007
14328
|
}
|
|
12008
14329
|
async function ensureChatroomDir(deps, workingDir) {
|
|
12009
14330
|
const dir = resolveChatroomDir(workingDir);
|
|
@@ -12011,7 +14332,7 @@ async function ensureChatroomDir(deps, workingDir) {
|
|
|
12011
14332
|
return dir;
|
|
12012
14333
|
}
|
|
12013
14334
|
async function ensureGitignore(deps, workingDir) {
|
|
12014
|
-
const gitignorePath =
|
|
14335
|
+
const gitignorePath = join6(workingDir, ".gitignore");
|
|
12015
14336
|
const entry = CHATROOM_DIR3;
|
|
12016
14337
|
let content = "";
|
|
12017
14338
|
try {
|
|
@@ -12041,7 +14362,7 @@ function formatOutputTimestamp(date = new Date) {
|
|
|
12041
14362
|
function generateOutputPath(workingDir, toolName, extension, date) {
|
|
12042
14363
|
const timestamp = formatOutputTimestamp(date);
|
|
12043
14364
|
const filename = `${toolName}-${timestamp}.${extension}`;
|
|
12044
|
-
return
|
|
14365
|
+
return join6(resolveChatroomDir(workingDir), filename);
|
|
12045
14366
|
}
|
|
12046
14367
|
var CHATROOM_DIR3 = ".chatroom";
|
|
12047
14368
|
var init_output = () => {};
|
|
@@ -18055,7 +20376,7 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
18055
20376
|
var LDD_PATH = "/usr/bin/ldd";
|
|
18056
20377
|
var SELF_PATH = "/proc/self/exe";
|
|
18057
20378
|
var MAX_LENGTH = 2048;
|
|
18058
|
-
var
|
|
20379
|
+
var readFileSync6 = (path2) => {
|
|
18059
20380
|
const fd = fs.openSync(path2, "r");
|
|
18060
20381
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
18061
20382
|
const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
@@ -18078,7 +20399,7 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
18078
20399
|
module.exports = {
|
|
18079
20400
|
LDD_PATH,
|
|
18080
20401
|
SELF_PATH,
|
|
18081
|
-
readFileSync:
|
|
20402
|
+
readFileSync: readFileSync6,
|
|
18082
20403
|
readFile
|
|
18083
20404
|
};
|
|
18084
20405
|
});
|
|
@@ -18121,7 +20442,7 @@ var require_elf = __commonJS((exports, module) => {
|
|
|
18121
20442
|
var require_detect_libc = __commonJS((exports, module) => {
|
|
18122
20443
|
var childProcess = __require("child_process");
|
|
18123
20444
|
var { isLinux, getReport } = require_process();
|
|
18124
|
-
var { LDD_PATH, SELF_PATH, readFile, readFileSync:
|
|
20445
|
+
var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync6 } = require_filesystem();
|
|
18125
20446
|
var { interpreterPath } = require_elf();
|
|
18126
20447
|
var cachedFamilyInterpreter;
|
|
18127
20448
|
var cachedFamilyFilesystem;
|
|
@@ -18212,7 +20533,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
18212
20533
|
}
|
|
18213
20534
|
cachedFamilyFilesystem = null;
|
|
18214
20535
|
try {
|
|
18215
|
-
const lddContent =
|
|
20536
|
+
const lddContent = readFileSync6(LDD_PATH);
|
|
18216
20537
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
18217
20538
|
} catch (e) {}
|
|
18218
20539
|
return cachedFamilyFilesystem;
|
|
@@ -18235,7 +20556,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
18235
20556
|
}
|
|
18236
20557
|
cachedFamilyInterpreter = null;
|
|
18237
20558
|
try {
|
|
18238
|
-
const selfContent =
|
|
20559
|
+
const selfContent = readFileSync6(SELF_PATH);
|
|
18239
20560
|
const path2 = interpreterPath(selfContent);
|
|
18240
20561
|
cachedFamilyInterpreter = familyFromInterpreterPath(path2);
|
|
18241
20562
|
} catch (e) {}
|
|
@@ -18297,7 +20618,7 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
18297
20618
|
}
|
|
18298
20619
|
cachedVersionFilesystem = null;
|
|
18299
20620
|
try {
|
|
18300
|
-
const lddContent =
|
|
20621
|
+
const lddContent = readFileSync6(LDD_PATH);
|
|
18301
20622
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
18302
20623
|
if (versionMatch) {
|
|
18303
20624
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -18790,7 +21111,7 @@ var require_semver = __commonJS((exports, module) => {
|
|
|
18790
21111
|
});
|
|
18791
21112
|
|
|
18792
21113
|
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/parse.js
|
|
18793
|
-
var
|
|
21114
|
+
var require_parse2 = __commonJS((exports, module) => {
|
|
18794
21115
|
var SemVer = require_semver();
|
|
18795
21116
|
var parse = (version2, options, throwErrors = false) => {
|
|
18796
21117
|
if (version2 instanceof SemVer) {
|
|
@@ -18811,7 +21132,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
18811
21132
|
// ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/functions/coerce.js
|
|
18812
21133
|
var require_coerce = __commonJS((exports, module) => {
|
|
18813
21134
|
var SemVer = require_semver();
|
|
18814
|
-
var parse =
|
|
21135
|
+
var parse = require_parse2();
|
|
18815
21136
|
var { safeRe: re, t } = require_re();
|
|
18816
21137
|
var coerce = (version2, options) => {
|
|
18817
21138
|
if (version2 instanceof SemVer) {
|
|
@@ -24493,11 +26814,11 @@ var init_pdfium_renderer = __esm(() => {
|
|
|
24493
26814
|
|
|
24494
26815
|
// ../../node_modules/.pnpm/@llamaindex+liteparse@1.4.6/node_modules/@llamaindex/liteparse/dist/src/engines/pdf/pdfjsImporter.js
|
|
24495
26816
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
24496
|
-
import { dirname as
|
|
26817
|
+
import { dirname as dirname3 } from "node:path";
|
|
24497
26818
|
async function importPdfJs() {
|
|
24498
26819
|
const pdfUrl = new URL("../../vendor/pdfjs/pdf.mjs", import.meta.url);
|
|
24499
26820
|
const pdfjs = await import(pdfUrl.href);
|
|
24500
|
-
const dirPath =
|
|
26821
|
+
const dirPath = dirname3(fileURLToPath2(pdfUrl));
|
|
24501
26822
|
return {
|
|
24502
26823
|
fn: pdfjs.getDocument,
|
|
24503
26824
|
dir: dirPath
|
|
@@ -27997,11 +30318,11 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
27997
30318
|
}
|
|
27998
30319
|
var MAP = Symbol("map");
|
|
27999
30320
|
|
|
28000
|
-
class
|
|
30321
|
+
class Headers2 {
|
|
28001
30322
|
constructor() {
|
|
28002
30323
|
let init2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
28003
30324
|
this[MAP] = Object.create(null);
|
|
28004
|
-
if (init2 instanceof
|
|
30325
|
+
if (init2 instanceof Headers2) {
|
|
28005
30326
|
const rawHeaders = init2.raw();
|
|
28006
30327
|
const headerNames = Object.keys(rawHeaders);
|
|
28007
30328
|
for (const headerName of headerNames) {
|
|
@@ -28109,14 +30430,14 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28109
30430
|
return createHeadersIterator(this, "key+value");
|
|
28110
30431
|
}
|
|
28111
30432
|
}
|
|
28112
|
-
|
|
28113
|
-
Object.defineProperty(
|
|
30433
|
+
Headers2.prototype.entries = Headers2.prototype[Symbol.iterator];
|
|
30434
|
+
Object.defineProperty(Headers2.prototype, Symbol.toStringTag, {
|
|
28114
30435
|
value: "Headers",
|
|
28115
30436
|
writable: false,
|
|
28116
30437
|
enumerable: false,
|
|
28117
30438
|
configurable: true
|
|
28118
30439
|
});
|
|
28119
|
-
Object.defineProperties(
|
|
30440
|
+
Object.defineProperties(Headers2.prototype, {
|
|
28120
30441
|
get: { enumerable: true },
|
|
28121
30442
|
forEach: { enumerable: true },
|
|
28122
30443
|
set: { enumerable: true },
|
|
@@ -28185,7 +30506,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28185
30506
|
return obj;
|
|
28186
30507
|
}
|
|
28187
30508
|
function createHeadersLenient(obj) {
|
|
28188
|
-
const headers = new
|
|
30509
|
+
const headers = new Headers2;
|
|
28189
30510
|
for (const name of Object.keys(obj)) {
|
|
28190
30511
|
if (invalidTokenRegex.test(name)) {
|
|
28191
30512
|
continue;
|
|
@@ -28216,7 +30537,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28216
30537
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28217
30538
|
Body.call(this, body, opts);
|
|
28218
30539
|
const status = opts.status || 200;
|
|
28219
|
-
const headers = new
|
|
30540
|
+
const headers = new Headers2(opts.headers);
|
|
28220
30541
|
if (body != null && !headers.has("Content-Type")) {
|
|
28221
30542
|
const contentType = extractContentType(body);
|
|
28222
30543
|
if (contentType) {
|
|
@@ -28295,7 +30616,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28295
30616
|
return !!(proto && proto.constructor.name === "AbortSignal");
|
|
28296
30617
|
}
|
|
28297
30618
|
|
|
28298
|
-
class
|
|
30619
|
+
class Request2 {
|
|
28299
30620
|
constructor(input) {
|
|
28300
30621
|
let init2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28301
30622
|
let parsedURL;
|
|
@@ -28319,7 +30640,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28319
30640
|
timeout: init2.timeout || input.timeout || 0,
|
|
28320
30641
|
size: init2.size || input.size || 0
|
|
28321
30642
|
});
|
|
28322
|
-
const headers = new
|
|
30643
|
+
const headers = new Headers2(init2.headers || input.headers || {});
|
|
28323
30644
|
if (inputBody != null && !headers.has("Content-Type")) {
|
|
28324
30645
|
const contentType = extractContentType(inputBody);
|
|
28325
30646
|
if (contentType) {
|
|
@@ -28360,17 +30681,17 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28360
30681
|
return this[INTERNALS$2].signal;
|
|
28361
30682
|
}
|
|
28362
30683
|
clone() {
|
|
28363
|
-
return new
|
|
30684
|
+
return new Request2(this);
|
|
28364
30685
|
}
|
|
28365
30686
|
}
|
|
28366
|
-
Body.mixIn(
|
|
28367
|
-
Object.defineProperty(
|
|
30687
|
+
Body.mixIn(Request2.prototype);
|
|
30688
|
+
Object.defineProperty(Request2.prototype, Symbol.toStringTag, {
|
|
28368
30689
|
value: "Request",
|
|
28369
30690
|
writable: false,
|
|
28370
30691
|
enumerable: false,
|
|
28371
30692
|
configurable: true
|
|
28372
30693
|
});
|
|
28373
|
-
Object.defineProperties(
|
|
30694
|
+
Object.defineProperties(Request2.prototype, {
|
|
28374
30695
|
method: { enumerable: true },
|
|
28375
30696
|
url: { enumerable: true },
|
|
28376
30697
|
headers: { enumerable: true },
|
|
@@ -28380,7 +30701,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28380
30701
|
});
|
|
28381
30702
|
function getNodeRequestOptions(request) {
|
|
28382
30703
|
const parsedURL = request[INTERNALS$2].parsedURL;
|
|
28383
|
-
const headers = new
|
|
30704
|
+
const headers = new Headers2(request[INTERNALS$2].headers);
|
|
28384
30705
|
if (!headers.has("Accept")) {
|
|
28385
30706
|
headers.set("Accept", "*/*");
|
|
28386
30707
|
}
|
|
@@ -28449,7 +30770,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28449
30770
|
}
|
|
28450
30771
|
Body.Promise = fetch2.Promise;
|
|
28451
30772
|
return new fetch2.Promise(function(resolve, reject) {
|
|
28452
|
-
const request = new
|
|
30773
|
+
const request = new Request2(url, opts);
|
|
28453
30774
|
const options = getNodeRequestOptions(request);
|
|
28454
30775
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
28455
30776
|
const signal = request.signal;
|
|
@@ -28557,7 +30878,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28557
30878
|
return;
|
|
28558
30879
|
}
|
|
28559
30880
|
const requestOpts = {
|
|
28560
|
-
headers: new
|
|
30881
|
+
headers: new Headers2(request.headers),
|
|
28561
30882
|
follow: request.follow,
|
|
28562
30883
|
counter: request.counter + 1,
|
|
28563
30884
|
agent: request.agent,
|
|
@@ -28583,7 +30904,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28583
30904
|
requestOpts.body = undefined;
|
|
28584
30905
|
requestOpts.headers.delete("content-length");
|
|
28585
30906
|
}
|
|
28586
|
-
resolve(fetch2(new
|
|
30907
|
+
resolve(fetch2(new Request2(locationURL, requestOpts)));
|
|
28587
30908
|
finalize();
|
|
28588
30909
|
return;
|
|
28589
30910
|
}
|
|
@@ -28683,8 +31004,8 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
28683
31004
|
module.exports = exports = fetch2;
|
|
28684
31005
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28685
31006
|
exports.default = exports;
|
|
28686
|
-
exports.Headers =
|
|
28687
|
-
exports.Request =
|
|
31007
|
+
exports.Headers = Headers2;
|
|
31008
|
+
exports.Request = Request2;
|
|
28688
31009
|
exports.Response = Response2;
|
|
28689
31010
|
exports.FetchError = FetchError;
|
|
28690
31011
|
exports.AbortError = AbortError;
|
|
@@ -40467,7 +42788,7 @@ var init_AxiosHeaders = __esm(() => {
|
|
|
40467
42788
|
constructor(headers) {
|
|
40468
42789
|
headers && this.set(headers);
|
|
40469
42790
|
}
|
|
40470
|
-
set(header, valueOrRewrite,
|
|
42791
|
+
set(header, valueOrRewrite, rewrite2) {
|
|
40471
42792
|
const self2 = this;
|
|
40472
42793
|
function setHeader(_value, _header, _rewrite) {
|
|
40473
42794
|
const lHeader = normalizeHeader(_header);
|
|
@@ -40495,7 +42816,7 @@ var init_AxiosHeaders = __esm(() => {
|
|
|
40495
42816
|
}
|
|
40496
42817
|
setHeaders(obj, valueOrRewrite);
|
|
40497
42818
|
} else {
|
|
40498
|
-
header != null && setHeader(valueOrRewrite, header,
|
|
42819
|
+
header != null && setHeader(valueOrRewrite, header, rewrite2);
|
|
40499
42820
|
}
|
|
40500
42821
|
return this;
|
|
40501
42822
|
}
|
|
@@ -43643,19 +45964,19 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
|
|
|
43643
45964
|
env = utils_default.merge.call({
|
|
43644
45965
|
skipUndefined: true
|
|
43645
45966
|
}, globalFetchAPI, env);
|
|
43646
|
-
const { fetch: envFetch, Request, Response: Response2 } = env;
|
|
45967
|
+
const { fetch: envFetch, Request: Request2, Response: Response2 } = env;
|
|
43647
45968
|
const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
|
|
43648
|
-
const isRequestSupported = isFunction2(
|
|
45969
|
+
const isRequestSupported = isFunction2(Request2);
|
|
43649
45970
|
const isResponseSupported = isFunction2(Response2);
|
|
43650
45971
|
if (!isFetchSupported) {
|
|
43651
45972
|
return false;
|
|
43652
45973
|
}
|
|
43653
45974
|
const isReadableStreamSupported = isFetchSupported && isFunction2(ReadableStream2);
|
|
43654
|
-
const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder2) : async (str) => new Uint8Array(await new
|
|
45975
|
+
const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder2) : async (str) => new Uint8Array(await new Request2(str).arrayBuffer()));
|
|
43655
45976
|
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
43656
45977
|
let duplexAccessed = false;
|
|
43657
45978
|
const body = new ReadableStream2;
|
|
43658
|
-
const hasContentType = new
|
|
45979
|
+
const hasContentType = new Request2(platform_default.origin, {
|
|
43659
45980
|
body,
|
|
43660
45981
|
method: "POST",
|
|
43661
45982
|
get duplex() {
|
|
@@ -43689,7 +46010,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
|
|
|
43689
46010
|
return body.size;
|
|
43690
46011
|
}
|
|
43691
46012
|
if (utils_default.isSpecCompliantForm(body)) {
|
|
43692
|
-
const _request = new
|
|
46013
|
+
const _request = new Request2(platform_default.origin, {
|
|
43693
46014
|
method: "POST",
|
|
43694
46015
|
body
|
|
43695
46016
|
});
|
|
@@ -43734,7 +46055,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
|
|
|
43734
46055
|
let requestContentLength;
|
|
43735
46056
|
try {
|
|
43736
46057
|
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
43737
|
-
let _request = new
|
|
46058
|
+
let _request = new Request2(url2, {
|
|
43738
46059
|
method: "POST",
|
|
43739
46060
|
body: data,
|
|
43740
46061
|
duplex: "half"
|
|
@@ -43751,7 +46072,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
|
|
|
43751
46072
|
if (!utils_default.isString(withCredentials)) {
|
|
43752
46073
|
withCredentials = withCredentials ? "include" : "omit";
|
|
43753
46074
|
}
|
|
43754
|
-
const isCredentialsSupported = isRequestSupported && "credentials" in
|
|
46075
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request2.prototype;
|
|
43755
46076
|
const resolvedOptions = {
|
|
43756
46077
|
...fetchOptions,
|
|
43757
46078
|
signal: composedSignal,
|
|
@@ -43761,7 +46082,7 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
|
|
|
43761
46082
|
duplex: "half",
|
|
43762
46083
|
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
43763
46084
|
};
|
|
43764
|
-
request = isRequestSupported && new
|
|
46085
|
+
request = isRequestSupported && new Request2(url2, resolvedOptions);
|
|
43765
46086
|
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
|
|
43766
46087
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
43767
46088
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
@@ -43801,8 +46122,8 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
|
|
|
43801
46122
|
};
|
|
43802
46123
|
}, seedCache, getFetch = (config) => {
|
|
43803
46124
|
let env = config && config.env || {};
|
|
43804
|
-
const { fetch: fetch2, Request, Response: Response2 } = env;
|
|
43805
|
-
const seeds = [
|
|
46125
|
+
const { fetch: fetch2, Request: Request2, Response: Response2 } = env;
|
|
46126
|
+
const seeds = [Request2, Response2, fetch2];
|
|
43806
46127
|
let len2 = seeds.length, i2 = len2, seed, target, map = seedCache;
|
|
43807
46128
|
while (i2--) {
|
|
43808
46129
|
seed = seeds[i2];
|
|
@@ -43823,8 +46144,8 @@ var init_fetch = __esm(() => {
|
|
|
43823
46144
|
init_settle();
|
|
43824
46145
|
DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
43825
46146
|
({ isFunction: isFunction2 } = utils_default);
|
|
43826
|
-
globalFetchAPI = (({ Request, Response: Response2 }) => ({
|
|
43827
|
-
Request,
|
|
46147
|
+
globalFetchAPI = (({ Request: Request2, Response: Response2 }) => ({
|
|
46148
|
+
Request: Request2,
|
|
43828
46149
|
Response: Response2
|
|
43829
46150
|
}))(utils_default.global);
|
|
43830
46151
|
({ ReadableStream: ReadableStream2, TextEncoder: TextEncoder2 } = utils_default.global);
|
|
@@ -47347,13 +49668,13 @@ class ZipHandler {
|
|
|
47347
49668
|
if (entries) {
|
|
47348
49669
|
return this.iterateOverCentralDirectory(entries, fileCb);
|
|
47349
49670
|
}
|
|
47350
|
-
let
|
|
49671
|
+
let stop2 = false;
|
|
47351
49672
|
do {
|
|
47352
49673
|
const zipHeader = await this.readLocalFileHeader();
|
|
47353
49674
|
if (!zipHeader)
|
|
47354
49675
|
break;
|
|
47355
49676
|
const next = fileCb(zipHeader);
|
|
47356
|
-
|
|
49677
|
+
stop2 = !!next.stop;
|
|
47357
49678
|
let fileData;
|
|
47358
49679
|
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
47359
49680
|
if (zipHeader.dataDescriptor && zipHeader.compressedSize === 0) {
|
|
@@ -47395,7 +49716,7 @@ class ZipHandler {
|
|
|
47395
49716
|
throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position - DataDescriptor.len}`);
|
|
47396
49717
|
}
|
|
47397
49718
|
}
|
|
47398
|
-
} while (!
|
|
49719
|
+
} while (!stop2);
|
|
47399
49720
|
}
|
|
47400
49721
|
async iterateOverCentralDirectory(entries, fileCb) {
|
|
47401
49722
|
for (const fileHeader of entries) {
|
|
@@ -50111,7 +52432,7 @@ var init_core2 = __esm(() => {
|
|
|
50111
52432
|
return callback(uncompressedData);
|
|
50112
52433
|
};
|
|
50113
52434
|
ZipHandler.prototype.unzip = async function(fileCallback) {
|
|
50114
|
-
let
|
|
52435
|
+
let stop2 = false;
|
|
50115
52436
|
let zipEntryCount = 0;
|
|
50116
52437
|
const zipScanStart = this.tokenizer.position;
|
|
50117
52438
|
this.knownSizeDescriptorScannedBytes = 0;
|
|
@@ -50128,7 +52449,7 @@ var init_core2 = __esm(() => {
|
|
|
50128
52449
|
throw new Error(`ZIP entry count exceeds ${maximumZipEntryCount}`);
|
|
50129
52450
|
}
|
|
50130
52451
|
const next = fileCallback(zipHeader);
|
|
50131
|
-
|
|
52452
|
+
stop2 = Boolean(next.stop);
|
|
50132
52453
|
await this.tokenizer.ignore(zipHeader.extraFieldLength);
|
|
50133
52454
|
const fileData = await readZipEntryData(this, zipHeader, {
|
|
50134
52455
|
shouldBuffer: Boolean(next.handler),
|
|
@@ -50147,7 +52468,7 @@ var init_core2 = __esm(() => {
|
|
|
50147
52468
|
if (hasExceededUnknownSizeScanBudget(this.tokenizer, zipScanStart, maximumUntrustedSkipSizeInBytes)) {
|
|
50148
52469
|
throw new ParserHardLimitError(`ZIP stream probing exceeds ${maximumUntrustedSkipSizeInBytes} bytes`);
|
|
50149
52470
|
}
|
|
50150
|
-
} while (!
|
|
52471
|
+
} while (!stop2);
|
|
50151
52472
|
};
|
|
50152
52473
|
supportedExtensions = new Set(extensions);
|
|
50153
52474
|
supportedMimeTypes = new Set(mimeTypes);
|
|
@@ -51065,11 +53386,11 @@ __export(exports_register_agent, {
|
|
|
51065
53386
|
registerAgent: () => registerAgent
|
|
51066
53387
|
});
|
|
51067
53388
|
async function createDefaultDeps7() {
|
|
51068
|
-
const
|
|
53389
|
+
const client4 = await getConvexClient();
|
|
51069
53390
|
return {
|
|
51070
53391
|
backend: {
|
|
51071
|
-
mutation: (endpoint, args) =>
|
|
51072
|
-
query: (endpoint, args) =>
|
|
53392
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
53393
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
51073
53394
|
},
|
|
51074
53395
|
session: {
|
|
51075
53396
|
getSessionId,
|
|
@@ -51530,7 +53851,7 @@ __export(exports_get_next_task, {
|
|
|
51530
53851
|
GetNextTaskSession: () => GetNextTaskSession
|
|
51531
53852
|
});
|
|
51532
53853
|
async function getNextTask(chatroomId, options) {
|
|
51533
|
-
const
|
|
53854
|
+
const client4 = await getConvexClient();
|
|
51534
53855
|
const { role, silent } = options;
|
|
51535
53856
|
const convexUrl = getConvexUrl();
|
|
51536
53857
|
const cliEnvPrefix = getCliEnvPrefix(convexUrl);
|
|
@@ -51563,7 +53884,7 @@ async function getNextTask(chatroomId, options) {
|
|
|
51563
53884
|
}
|
|
51564
53885
|
let chatroom;
|
|
51565
53886
|
try {
|
|
51566
|
-
chatroom = await
|
|
53887
|
+
chatroom = await client4.query(api.chatrooms.get, {
|
|
51567
53888
|
sessionId,
|
|
51568
53889
|
chatroomId
|
|
51569
53890
|
});
|
|
@@ -51581,14 +53902,14 @@ async function getNextTask(chatroomId, options) {
|
|
|
51581
53902
|
const connectionId = `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
51582
53903
|
let participantAgentType;
|
|
51583
53904
|
try {
|
|
51584
|
-
const teamConfigs = await
|
|
53905
|
+
const teamConfigs = await client4.query(api.machines.getTeamAgentConfigs, {
|
|
51585
53906
|
sessionId,
|
|
51586
53907
|
chatroomId
|
|
51587
53908
|
});
|
|
51588
53909
|
const roleConfig = teamConfigs?.find((c) => c.role.toLowerCase() === role.toLowerCase());
|
|
51589
53910
|
participantAgentType = roleConfig?.type;
|
|
51590
53911
|
} catch {}
|
|
51591
|
-
await
|
|
53912
|
+
await client4.mutation(api.participants.join, {
|
|
51592
53913
|
sessionId,
|
|
51593
53914
|
chatroomId,
|
|
51594
53915
|
role,
|
|
@@ -51601,7 +53922,7 @@ async function getNextTask(chatroomId, options) {
|
|
|
51601
53922
|
console.log(`[${connectionTime}] ⏳ Connecting to chatroom as "${role}"...`);
|
|
51602
53923
|
}
|
|
51603
53924
|
try {
|
|
51604
|
-
const initPromptResult = await
|
|
53925
|
+
const initPromptResult = await client4.query(api.messages.getInitPrompt, {
|
|
51605
53926
|
sessionId,
|
|
51606
53927
|
chatroomId,
|
|
51607
53928
|
role,
|
|
@@ -51639,7 +53960,7 @@ async function getNextTask(chatroomId, options) {
|
|
|
51639
53960
|
sessionId,
|
|
51640
53961
|
connectionId,
|
|
51641
53962
|
cliEnvPrefix,
|
|
51642
|
-
client:
|
|
53963
|
+
client: client4
|
|
51643
53964
|
});
|
|
51644
53965
|
await session.start();
|
|
51645
53966
|
}
|
|
@@ -51660,11 +53981,11 @@ __export(exports_classify, {
|
|
|
51660
53981
|
classify: () => classify
|
|
51661
53982
|
});
|
|
51662
53983
|
async function createDefaultDeps8() {
|
|
51663
|
-
const
|
|
53984
|
+
const client4 = await getConvexClient();
|
|
51664
53985
|
return {
|
|
51665
53986
|
backend: {
|
|
51666
|
-
mutation: (endpoint, args) =>
|
|
51667
|
-
query: (endpoint, args) =>
|
|
53987
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
53988
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
51668
53989
|
},
|
|
51669
53990
|
session: {
|
|
51670
53991
|
getSessionId,
|
|
@@ -51944,11 +54265,11 @@ __export(exports_handoff, {
|
|
|
51944
54265
|
handoff: () => handoff
|
|
51945
54266
|
});
|
|
51946
54267
|
async function createDefaultDeps9() {
|
|
51947
|
-
const
|
|
54268
|
+
const client4 = await getConvexClient();
|
|
51948
54269
|
return {
|
|
51949
54270
|
backend: {
|
|
51950
|
-
mutation: (endpoint, args) =>
|
|
51951
|
-
query: (endpoint, args) =>
|
|
54271
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
54272
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
51952
54273
|
},
|
|
51953
54274
|
session: {
|
|
51954
54275
|
getSessionId,
|
|
@@ -52149,11 +54470,11 @@ __export(exports_report_progress, {
|
|
|
52149
54470
|
reportProgress: () => reportProgress
|
|
52150
54471
|
});
|
|
52151
54472
|
async function createDefaultDeps10() {
|
|
52152
|
-
const
|
|
54473
|
+
const client4 = await getConvexClient();
|
|
52153
54474
|
return {
|
|
52154
54475
|
backend: {
|
|
52155
|
-
mutation: (endpoint, args) =>
|
|
52156
|
-
query: (endpoint, args) =>
|
|
54476
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
54477
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
52157
54478
|
},
|
|
52158
54479
|
session: {
|
|
52159
54480
|
getSessionId,
|
|
@@ -52264,12 +54585,12 @@ __export(exports_backlog, {
|
|
|
52264
54585
|
import { createHash } from "node:crypto";
|
|
52265
54586
|
import * as nodePath from "node:path";
|
|
52266
54587
|
async function createDefaultDeps11() {
|
|
52267
|
-
const
|
|
54588
|
+
const client4 = await getConvexClient();
|
|
52268
54589
|
const fs6 = await import("node:fs/promises");
|
|
52269
54590
|
return {
|
|
52270
54591
|
backend: {
|
|
52271
|
-
mutation: (endpoint, args) =>
|
|
52272
|
-
query: (endpoint, args) =>
|
|
54592
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
54593
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
52273
54594
|
},
|
|
52274
54595
|
session: {
|
|
52275
54596
|
getSessionId,
|
|
@@ -52893,12 +55214,12 @@ var exports_file_content = {};
|
|
|
52893
55214
|
__export(exports_file_content, {
|
|
52894
55215
|
readFileContent: () => readFileContent
|
|
52895
55216
|
});
|
|
52896
|
-
import { readFileSync as
|
|
52897
|
-
import { resolve as resolve2 } from "path";
|
|
55217
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
55218
|
+
import { resolve as resolve2 } from "node:path";
|
|
52898
55219
|
function readFileContent(filePath, optionName) {
|
|
52899
55220
|
const absolutePath = resolve2(process.cwd(), filePath);
|
|
52900
55221
|
try {
|
|
52901
|
-
return
|
|
55222
|
+
return readFileSync6(absolutePath, "utf-8");
|
|
52902
55223
|
} catch (err) {
|
|
52903
55224
|
const nodeErr = err;
|
|
52904
55225
|
throw new Error(`Cannot read file for --${optionName}: ${absolutePath}
|
|
@@ -52920,11 +55241,11 @@ __export(exports_workflow, {
|
|
|
52920
55241
|
completeStep: () => completeStep
|
|
52921
55242
|
});
|
|
52922
55243
|
async function createDefaultDeps12() {
|
|
52923
|
-
const
|
|
55244
|
+
const client4 = await getConvexClient();
|
|
52924
55245
|
return {
|
|
52925
55246
|
backend: {
|
|
52926
|
-
mutation: (endpoint, args) =>
|
|
52927
|
-
query: (endpoint, args) =>
|
|
55247
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
55248
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
52928
55249
|
},
|
|
52929
55250
|
session: {
|
|
52930
55251
|
getSessionId,
|
|
@@ -53412,11 +55733,11 @@ __export(exports_read, {
|
|
|
53412
55733
|
taskRead: () => taskRead
|
|
53413
55734
|
});
|
|
53414
55735
|
async function createDefaultDeps13() {
|
|
53415
|
-
const
|
|
55736
|
+
const client4 = await getConvexClient();
|
|
53416
55737
|
return {
|
|
53417
55738
|
backend: {
|
|
53418
|
-
mutation: (endpoint, args) =>
|
|
53419
|
-
query: (endpoint, args) =>
|
|
55739
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
55740
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
53420
55741
|
},
|
|
53421
55742
|
session: {
|
|
53422
55743
|
getSessionId,
|
|
@@ -53540,11 +55861,11 @@ __export(exports_skill, {
|
|
|
53540
55861
|
activateSkill: () => activateSkill
|
|
53541
55862
|
});
|
|
53542
55863
|
async function createDefaultDeps14() {
|
|
53543
|
-
const
|
|
55864
|
+
const client4 = await getConvexClient();
|
|
53544
55865
|
return {
|
|
53545
55866
|
backend: {
|
|
53546
|
-
mutation: (endpoint, args) =>
|
|
53547
|
-
query: (endpoint, args) =>
|
|
55867
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
55868
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
53548
55869
|
},
|
|
53549
55870
|
session: {
|
|
53550
55871
|
getSessionId,
|
|
@@ -53621,11 +55942,11 @@ __export(exports_messages, {
|
|
|
53621
55942
|
listBySenderRole: () => listBySenderRole
|
|
53622
55943
|
});
|
|
53623
55944
|
async function createDefaultDeps15() {
|
|
53624
|
-
const
|
|
55945
|
+
const client4 = await getConvexClient();
|
|
53625
55946
|
return {
|
|
53626
55947
|
backend: {
|
|
53627
|
-
mutation: (endpoint, args) =>
|
|
53628
|
-
query: (endpoint, args) =>
|
|
55948
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
55949
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
53629
55950
|
},
|
|
53630
55951
|
session: {
|
|
53631
55952
|
getSessionId,
|
|
@@ -53776,11 +56097,11 @@ __export(exports_context, {
|
|
|
53776
56097
|
inspectContext: () => inspectContext
|
|
53777
56098
|
});
|
|
53778
56099
|
async function createDefaultDeps16() {
|
|
53779
|
-
const
|
|
56100
|
+
const client4 = await getConvexClient();
|
|
53780
56101
|
return {
|
|
53781
56102
|
backend: {
|
|
53782
|
-
mutation: (endpoint, args) =>
|
|
53783
|
-
query: (endpoint, args) =>
|
|
56103
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
56104
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
53784
56105
|
},
|
|
53785
56106
|
session: {
|
|
53786
56107
|
getSessionId,
|
|
@@ -54071,11 +56392,11 @@ __export(exports_guidelines, {
|
|
|
54071
56392
|
listGuidelineTypes: () => listGuidelineTypes
|
|
54072
56393
|
});
|
|
54073
56394
|
async function createDefaultDeps17() {
|
|
54074
|
-
const
|
|
56395
|
+
const client4 = await getConvexClient();
|
|
54075
56396
|
return {
|
|
54076
56397
|
backend: {
|
|
54077
|
-
mutation: (endpoint, args) =>
|
|
54078
|
-
query: (endpoint, args) =>
|
|
56398
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
56399
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
54079
56400
|
},
|
|
54080
56401
|
session: {
|
|
54081
56402
|
getSessionId,
|
|
@@ -54163,11 +56484,11 @@ __export(exports_artifact, {
|
|
|
54163
56484
|
createArtifact: () => createArtifact
|
|
54164
56485
|
});
|
|
54165
56486
|
async function createDefaultDeps18() {
|
|
54166
|
-
const
|
|
56487
|
+
const client4 = await getConvexClient();
|
|
54167
56488
|
return {
|
|
54168
56489
|
backend: {
|
|
54169
|
-
mutation: (endpoint, args) =>
|
|
54170
|
-
query: (endpoint, args) =>
|
|
56490
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
56491
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
54171
56492
|
},
|
|
54172
56493
|
session: {
|
|
54173
56494
|
getSessionId,
|
|
@@ -54342,11 +56663,11 @@ __export(exports_get_system_prompt, {
|
|
|
54342
56663
|
getSystemPrompt: () => getSystemPrompt
|
|
54343
56664
|
});
|
|
54344
56665
|
async function createDefaultDeps19() {
|
|
54345
|
-
const
|
|
56666
|
+
const client4 = await getConvexClient();
|
|
54346
56667
|
return {
|
|
54347
56668
|
backend: {
|
|
54348
|
-
mutation: (endpoint, args) =>
|
|
54349
|
-
query: (endpoint, args) =>
|
|
56669
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
56670
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
54350
56671
|
},
|
|
54351
56672
|
session: {
|
|
54352
56673
|
getSessionId,
|
|
@@ -54404,10 +56725,10 @@ __export(exports_telegram, {
|
|
|
54404
56725
|
sendMessage: () => sendMessage
|
|
54405
56726
|
});
|
|
54406
56727
|
async function createDefaultDeps20() {
|
|
54407
|
-
const
|
|
56728
|
+
const client4 = await getConvexClient();
|
|
54408
56729
|
return {
|
|
54409
56730
|
backend: {
|
|
54410
|
-
action: (endpoint, args) =>
|
|
56731
|
+
action: (endpoint, args) => client4.action(endpoint, args)
|
|
54411
56732
|
},
|
|
54412
56733
|
session: {
|
|
54413
56734
|
getSessionId,
|
|
@@ -54488,7 +56809,7 @@ var init_telegram = __esm(() => {
|
|
|
54488
56809
|
});
|
|
54489
56810
|
|
|
54490
56811
|
// ../../services/backend/config/reliability.ts
|
|
54491
|
-
var DAEMON_HEARTBEAT_INTERVAL_MS = 30000, AGENT_REQUEST_DEADLINE_MS = 120000;
|
|
56812
|
+
var DAEMON_HEARTBEAT_INTERVAL_MS = 30000, AGENT_REQUEST_DEADLINE_MS = 120000, OBSERVATION_TTL_MS = 60000, OBSERVED_SAFETY_POLL_MS = 30000;
|
|
54492
56813
|
|
|
54493
56814
|
// src/events/daemon/agent/on-request-start-agent.ts
|
|
54494
56815
|
async function onRequestStartAgent(ctx, event) {
|
|
@@ -54569,9 +56890,9 @@ var init_on_request_stop_agent = () => {};
|
|
|
54569
56890
|
|
|
54570
56891
|
// src/commands/machine/pid.ts
|
|
54571
56892
|
import { createHash as createHash2 } from "node:crypto";
|
|
54572
|
-
import { existsSync as
|
|
54573
|
-
import { homedir as
|
|
54574
|
-
import { join as
|
|
56893
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7, writeFileSync as writeFileSync5, unlinkSync as unlinkSync2, mkdirSync as mkdirSync5 } from "node:fs";
|
|
56894
|
+
import { homedir as homedir5 } from "node:os";
|
|
56895
|
+
import { join as join8 } from "node:path";
|
|
54575
56896
|
function getUrlHash() {
|
|
54576
56897
|
const url2 = getConvexUrl();
|
|
54577
56898
|
return createHash2("sha256").update(url2).digest("hex").substring(0, 8);
|
|
@@ -54580,12 +56901,12 @@ function getPidFileName() {
|
|
|
54580
56901
|
return `daemon-${getUrlHash()}.pid`;
|
|
54581
56902
|
}
|
|
54582
56903
|
function ensureChatroomDir2() {
|
|
54583
|
-
if (!
|
|
54584
|
-
|
|
56904
|
+
if (!existsSync5(CHATROOM_DIR4)) {
|
|
56905
|
+
mkdirSync5(CHATROOM_DIR4, { recursive: true, mode: 448 });
|
|
54585
56906
|
}
|
|
54586
56907
|
}
|
|
54587
56908
|
function getPidFilePath() {
|
|
54588
|
-
return
|
|
56909
|
+
return join8(CHATROOM_DIR4, getPidFileName());
|
|
54589
56910
|
}
|
|
54590
56911
|
function isProcessRunning(pid) {
|
|
54591
56912
|
try {
|
|
@@ -54597,11 +56918,11 @@ function isProcessRunning(pid) {
|
|
|
54597
56918
|
}
|
|
54598
56919
|
function readPid() {
|
|
54599
56920
|
const pidPath = getPidFilePath();
|
|
54600
|
-
if (!
|
|
56921
|
+
if (!existsSync5(pidPath)) {
|
|
54601
56922
|
return null;
|
|
54602
56923
|
}
|
|
54603
56924
|
try {
|
|
54604
|
-
const content =
|
|
56925
|
+
const content = readFileSync7(pidPath, "utf-8").trim();
|
|
54605
56926
|
const pid = parseInt(content, 10);
|
|
54606
56927
|
if (isNaN(pid) || pid <= 0) {
|
|
54607
56928
|
return null;
|
|
@@ -54614,12 +56935,12 @@ function readPid() {
|
|
|
54614
56935
|
function writePid() {
|
|
54615
56936
|
ensureChatroomDir2();
|
|
54616
56937
|
const pidPath = getPidFilePath();
|
|
54617
|
-
|
|
56938
|
+
writeFileSync5(pidPath, process.pid.toString(), "utf-8");
|
|
54618
56939
|
}
|
|
54619
56940
|
function removePid() {
|
|
54620
56941
|
const pidPath = getPidFilePath();
|
|
54621
56942
|
try {
|
|
54622
|
-
if (
|
|
56943
|
+
if (existsSync5(pidPath)) {
|
|
54623
56944
|
unlinkSync2(pidPath);
|
|
54624
56945
|
}
|
|
54625
56946
|
} catch {}
|
|
@@ -54650,9 +56971,58 @@ function releaseLock() {
|
|
|
54650
56971
|
var CHATROOM_DIR4;
|
|
54651
56972
|
var init_pid = __esm(() => {
|
|
54652
56973
|
init_client2();
|
|
54653
|
-
CHATROOM_DIR4 =
|
|
56974
|
+
CHATROOM_DIR4 = join8(homedir5(), ".chatroom");
|
|
54654
56975
|
});
|
|
54655
56976
|
|
|
56977
|
+
// src/infrastructure/git/git-state-pipeline.ts
|
|
56978
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
56979
|
+
|
|
56980
|
+
class GitStatePipeline {
|
|
56981
|
+
fields;
|
|
56982
|
+
constructor(fields) {
|
|
56983
|
+
this.fields = fields;
|
|
56984
|
+
}
|
|
56985
|
+
async collect(workingDir, preCollected) {
|
|
56986
|
+
const results = new Map(preCollected);
|
|
56987
|
+
if (this.fields.length === 0)
|
|
56988
|
+
return results;
|
|
56989
|
+
const entries = await Promise.all(this.fields.filter((f) => !results.has(f.key)).map(async (field) => {
|
|
56990
|
+
try {
|
|
56991
|
+
const raw = await field.collect(workingDir);
|
|
56992
|
+
return { key: field.key, raw };
|
|
56993
|
+
} catch {
|
|
56994
|
+
return { key: field.key, raw: field.defaultValue };
|
|
56995
|
+
}
|
|
56996
|
+
}));
|
|
56997
|
+
for (const { key, raw } of entries) {
|
|
56998
|
+
results.set(key, raw);
|
|
56999
|
+
}
|
|
57000
|
+
return results;
|
|
57001
|
+
}
|
|
57002
|
+
computeHash(values, slim) {
|
|
57003
|
+
const hashInput = {};
|
|
57004
|
+
for (const field of this.fields) {
|
|
57005
|
+
if (slim && !field.includeInSlim)
|
|
57006
|
+
continue;
|
|
57007
|
+
const raw = values.get(field.key) ?? field.defaultValue;
|
|
57008
|
+
hashInput[field.key] = field.toHashable(raw);
|
|
57009
|
+
}
|
|
57010
|
+
return createHash3("md5").update(JSON.stringify(hashInput)).digest("hex");
|
|
57011
|
+
}
|
|
57012
|
+
toMutationArgs(values, slim) {
|
|
57013
|
+
const args = {};
|
|
57014
|
+
for (const field of this.fields) {
|
|
57015
|
+
if (slim && !field.includeInSlim)
|
|
57016
|
+
continue;
|
|
57017
|
+
const raw = values.get(field.key) ?? field.defaultValue;
|
|
57018
|
+
Object.assign(args, field.toMutationPartial(raw));
|
|
57019
|
+
}
|
|
57020
|
+
args.pipelineMode = slim ? "slim" : "full";
|
|
57021
|
+
return args;
|
|
57022
|
+
}
|
|
57023
|
+
}
|
|
57024
|
+
var init_git_state_pipeline = () => {};
|
|
57025
|
+
|
|
54656
57026
|
// src/commands/machine/daemon-start/utils.ts
|
|
54657
57027
|
function formatTimestamp() {
|
|
54658
57028
|
return new Date().toISOString().replace("T", " ").substring(0, 19);
|
|
@@ -55292,6 +57662,28 @@ async function processMoreCommits(ctx, req) {
|
|
|
55292
57662
|
});
|
|
55293
57663
|
console.log(`[${formatTimestamp()}] \uD83D\uDCDC More commits appended: ${req.workingDir} (+${commits.length} commits, offset=${offset})`);
|
|
55294
57664
|
}
|
|
57665
|
+
async function processAllPullRequests(ctx, req) {
|
|
57666
|
+
const pullRequests = await getAllPRs(req.workingDir);
|
|
57667
|
+
await ctx.deps.backend.mutation(api.workspaces.upsertAllPullRequests, {
|
|
57668
|
+
sessionId: ctx.sessionId,
|
|
57669
|
+
machineId: ctx.machineId,
|
|
57670
|
+
workingDir: req.workingDir,
|
|
57671
|
+
pullRequests
|
|
57672
|
+
});
|
|
57673
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDCCB All pull requests pushed: ${req.workingDir} (${pullRequests.length} PRs)`);
|
|
57674
|
+
}
|
|
57675
|
+
async function processRecentCommits(ctx, req) {
|
|
57676
|
+
const commits = await getRecentCommits(req.workingDir, COMMITS_PER_PAGE, 0);
|
|
57677
|
+
const hasMoreCommits = commits.length >= COMMITS_PER_PAGE;
|
|
57678
|
+
await ctx.deps.backend.mutation(api.workspaces.upsertRecentCommits, {
|
|
57679
|
+
sessionId: ctx.sessionId,
|
|
57680
|
+
machineId: ctx.machineId,
|
|
57681
|
+
workingDir: req.workingDir,
|
|
57682
|
+
commits,
|
|
57683
|
+
hasMoreCommits
|
|
57684
|
+
});
|
|
57685
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDCDC Recent commits pushed: ${req.workingDir} (${commits.length} commits)`);
|
|
57686
|
+
}
|
|
55295
57687
|
async function processRequests(ctx, requests, processedRequestIds, dedupTtlMs) {
|
|
55296
57688
|
const evictBefore = Date.now() - dedupTtlMs;
|
|
55297
57689
|
for (const [id, ts] of processedRequestIds) {
|
|
@@ -55328,6 +57720,12 @@ async function processRequests(ctx, requests, processedRequestIds, dedupTtlMs) {
|
|
|
55328
57720
|
case "pr_commits":
|
|
55329
57721
|
await processPRCommits(ctx, req);
|
|
55330
57722
|
break;
|
|
57723
|
+
case "all_pull_requests":
|
|
57724
|
+
await processAllPullRequests(ctx, req);
|
|
57725
|
+
break;
|
|
57726
|
+
case "recent_commits":
|
|
57727
|
+
await processRecentCommits(ctx, req);
|
|
57728
|
+
break;
|
|
55331
57729
|
}
|
|
55332
57730
|
await ctx.deps.backend.mutation(api.workspaces.updateRequestStatus, {
|
|
55333
57731
|
sessionId: ctx.sessionId,
|
|
@@ -55352,7 +57750,26 @@ var init_git_subscription = __esm(() => {
|
|
|
55352
57750
|
});
|
|
55353
57751
|
|
|
55354
57752
|
// src/commands/machine/daemon-start/git-heartbeat.ts
|
|
55355
|
-
|
|
57753
|
+
function makeBranchDependentFields(branch) {
|
|
57754
|
+
return [
|
|
57755
|
+
{
|
|
57756
|
+
key: "openPullRequests",
|
|
57757
|
+
includeInSlim: true,
|
|
57758
|
+
collect: (wd) => getOpenPRsForBranch(wd, branch),
|
|
57759
|
+
toHashable: (raw) => raw.map((pr) => pr.prNumber),
|
|
57760
|
+
toMutationPartial: (raw) => ({ openPullRequests: raw }),
|
|
57761
|
+
defaultValue: []
|
|
57762
|
+
},
|
|
57763
|
+
{
|
|
57764
|
+
key: "headCommitStatus",
|
|
57765
|
+
includeInSlim: true,
|
|
57766
|
+
collect: (wd) => getCommitStatusChecks(wd, branch),
|
|
57767
|
+
toHashable: (raw) => raw,
|
|
57768
|
+
toMutationPartial: (raw) => ({ headCommitStatus: raw }),
|
|
57769
|
+
defaultValue: null
|
|
57770
|
+
}
|
|
57771
|
+
];
|
|
57772
|
+
}
|
|
55356
57773
|
async function pushGitState(ctx) {
|
|
55357
57774
|
let workspaces;
|
|
55358
57775
|
try {
|
|
@@ -55379,8 +57796,8 @@ async function pushSingleWorkspaceGitState(ctx, workingDir) {
|
|
|
55379
57796
|
const stateKey = makeGitStateKey(ctx.machineId, workingDir);
|
|
55380
57797
|
const isRepo = await isGitRepo(workingDir);
|
|
55381
57798
|
if (!isRepo) {
|
|
55382
|
-
const
|
|
55383
|
-
if (ctx.lastPushedGitState.get(stateKey) ===
|
|
57799
|
+
const stateHash = "not_found";
|
|
57800
|
+
if (ctx.lastPushedGitState.get(stateKey) === stateHash)
|
|
55384
57801
|
return;
|
|
55385
57802
|
await ctx.deps.backend.mutation(api.workspaces.upsertWorkspaceGitState, {
|
|
55386
57803
|
sessionId: ctx.sessionId,
|
|
@@ -55388,20 +57805,13 @@ async function pushSingleWorkspaceGitState(ctx, workingDir) {
|
|
|
55388
57805
|
workingDir,
|
|
55389
57806
|
status: "not_found"
|
|
55390
57807
|
});
|
|
55391
|
-
ctx.lastPushedGitState.set(stateKey,
|
|
57808
|
+
ctx.lastPushedGitState.set(stateKey, stateHash);
|
|
55392
57809
|
return;
|
|
55393
57810
|
}
|
|
55394
|
-
const
|
|
55395
|
-
getBranch(workingDir),
|
|
55396
|
-
isDirty(workingDir),
|
|
55397
|
-
getDiffStat(workingDir),
|
|
55398
|
-
getRecentCommits(workingDir, COMMITS_PER_PAGE),
|
|
55399
|
-
getCommitsAhead(workingDir)
|
|
55400
|
-
]);
|
|
55401
|
-
const remotes = await getRemotes(workingDir);
|
|
57811
|
+
const branchResult = await getBranch(workingDir);
|
|
55402
57812
|
if (branchResult.status === "error") {
|
|
55403
|
-
const
|
|
55404
|
-
if (ctx.lastPushedGitState.get(stateKey) ===
|
|
57813
|
+
const stateHash = `error:${branchResult.message}`;
|
|
57814
|
+
if (ctx.lastPushedGitState.get(stateKey) === stateHash)
|
|
55405
57815
|
return;
|
|
55406
57816
|
await ctx.deps.backend.mutation(api.workspaces.upsertWorkspaceGitState, {
|
|
55407
57817
|
sessionId: ctx.sessionId,
|
|
@@ -55410,21 +57820,21 @@ async function pushSingleWorkspaceGitState(ctx, workingDir) {
|
|
|
55410
57820
|
status: "error",
|
|
55411
57821
|
errorMessage: branchResult.message
|
|
55412
57822
|
});
|
|
55413
|
-
ctx.lastPushedGitState.set(stateKey,
|
|
57823
|
+
ctx.lastPushedGitState.set(stateKey, stateHash);
|
|
55414
57824
|
return;
|
|
55415
57825
|
}
|
|
55416
57826
|
if (branchResult.status === "not_found") {
|
|
55417
57827
|
return;
|
|
55418
57828
|
}
|
|
55419
|
-
const openPRs = await getOpenPRsForBranch(workingDir, branchResult.branch);
|
|
55420
|
-
const allPRs = await getAllPRs(workingDir);
|
|
55421
|
-
const headCommitStatus = await getCommitStatusChecks(workingDir, branchResult.branch);
|
|
55422
57829
|
const branch = branchResult.branch;
|
|
55423
|
-
const
|
|
55424
|
-
const
|
|
57830
|
+
const allFields = [branchField, ...GIT_STATE_FIELDS, ...makeBranchDependentFields(branch)];
|
|
57831
|
+
const pipeline2 = new GitStatePipeline(allFields);
|
|
57832
|
+
const preCollected = new Map([["branch", branchResult]]);
|
|
57833
|
+
const values = await pipeline2.collect(workingDir, preCollected);
|
|
57834
|
+
const commits = values.get("commits");
|
|
55425
57835
|
const hasMoreCommits = commits.length >= COMMITS_PER_PAGE;
|
|
55426
|
-
const
|
|
55427
|
-
if (ctx.lastPushedGitState.get(stateKey) ===
|
|
57836
|
+
const hash = pipeline2.computeHash(values, false);
|
|
57837
|
+
if (ctx.lastPushedGitState.get(stateKey) === hash) {
|
|
55428
57838
|
return;
|
|
55429
57839
|
}
|
|
55430
57840
|
await ctx.deps.backend.mutation(api.workspaces.upsertWorkspaceGitState, {
|
|
@@ -55432,23 +57842,73 @@ async function pushSingleWorkspaceGitState(ctx, workingDir) {
|
|
|
55432
57842
|
machineId: ctx.machineId,
|
|
55433
57843
|
workingDir,
|
|
55434
57844
|
status: "available",
|
|
55435
|
-
|
|
55436
|
-
isDirty: isDirty2,
|
|
55437
|
-
diffStat,
|
|
57845
|
+
...pipeline2.toMutationArgs(values, false),
|
|
55438
57846
|
recentCommits: commits,
|
|
55439
|
-
hasMoreCommits
|
|
55440
|
-
openPullRequests: openPRs,
|
|
55441
|
-
allPullRequests: allPRs,
|
|
55442
|
-
remotes,
|
|
55443
|
-
commitsAhead,
|
|
55444
|
-
headCommitStatus
|
|
57847
|
+
hasMoreCommits
|
|
55445
57848
|
});
|
|
55446
|
-
ctx.lastPushedGitState.set(stateKey,
|
|
55447
|
-
console.log(`[${formatTimestamp()}] \uD83D\uDD00 Git state pushed: ${workingDir} (${branch}${
|
|
57849
|
+
ctx.lastPushedGitState.set(stateKey, hash);
|
|
57850
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDD00 Git state pushed: ${workingDir} (${branch}${values.get("isDirty") ? ", dirty" : ", clean"})`);
|
|
55448
57851
|
prefetchMissingCommitDetails(ctx, workingDir, commits).catch((err) => {
|
|
55449
57852
|
console.warn(`[${formatTimestamp()}] ⚠️ Commit pre-fetch failed for ${workingDir}: ${getErrorMessage(err)}`);
|
|
55450
57853
|
});
|
|
55451
57854
|
}
|
|
57855
|
+
async function pushSingleWorkspaceGitSummaryForObserved(ctx, workingDir, reason = "safety-poll") {
|
|
57856
|
+
const stateKey = makeGitStateKey(ctx.machineId, workingDir);
|
|
57857
|
+
const isRepo = await isGitRepo(workingDir);
|
|
57858
|
+
if (!isRepo) {
|
|
57859
|
+
const stateHash = "not_found";
|
|
57860
|
+
if (reason !== "refresh" && ctx.lastPushedGitState.get(stateKey) === stateHash)
|
|
57861
|
+
return;
|
|
57862
|
+
await ctx.deps.backend.mutation(api.workspaces.upsertWorkspaceGitState, {
|
|
57863
|
+
sessionId: ctx.sessionId,
|
|
57864
|
+
machineId: ctx.machineId,
|
|
57865
|
+
workingDir,
|
|
57866
|
+
status: "not_found"
|
|
57867
|
+
});
|
|
57868
|
+
ctx.lastPushedGitState.set(stateKey, stateHash);
|
|
57869
|
+
return;
|
|
57870
|
+
}
|
|
57871
|
+
const branchResult = await getBranch(workingDir);
|
|
57872
|
+
if (branchResult.status === "error") {
|
|
57873
|
+
const stateHash = `error:${branchResult.message}`;
|
|
57874
|
+
if (reason !== "refresh" && ctx.lastPushedGitState.get(stateKey) === stateHash)
|
|
57875
|
+
return;
|
|
57876
|
+
await ctx.deps.backend.mutation(api.workspaces.upsertWorkspaceGitState, {
|
|
57877
|
+
sessionId: ctx.sessionId,
|
|
57878
|
+
machineId: ctx.machineId,
|
|
57879
|
+
workingDir,
|
|
57880
|
+
status: "error",
|
|
57881
|
+
errorMessage: branchResult.message
|
|
57882
|
+
});
|
|
57883
|
+
ctx.lastPushedGitState.set(stateKey, stateHash);
|
|
57884
|
+
return;
|
|
57885
|
+
}
|
|
57886
|
+
if (branchResult.status === "not_found") {
|
|
57887
|
+
return;
|
|
57888
|
+
}
|
|
57889
|
+
const branch = branchResult.branch;
|
|
57890
|
+
const slimFields = [
|
|
57891
|
+
branchField,
|
|
57892
|
+
...GIT_STATE_FIELDS.filter((f) => f.includeInSlim),
|
|
57893
|
+
...makeBranchDependentFields(branch)
|
|
57894
|
+
];
|
|
57895
|
+
const pipeline2 = new GitStatePipeline(slimFields);
|
|
57896
|
+
const preCollected = new Map([["branch", branchResult]]);
|
|
57897
|
+
const values = await pipeline2.collect(workingDir, preCollected);
|
|
57898
|
+
const hash = pipeline2.computeHash(values, true);
|
|
57899
|
+
if (reason !== "refresh" && ctx.lastPushedGitState.get(stateKey) === hash) {
|
|
57900
|
+
return;
|
|
57901
|
+
}
|
|
57902
|
+
await ctx.deps.backend.mutation(api.workspaces.upsertWorkspaceGitState, {
|
|
57903
|
+
sessionId: ctx.sessionId,
|
|
57904
|
+
machineId: ctx.machineId,
|
|
57905
|
+
workingDir,
|
|
57906
|
+
status: "available",
|
|
57907
|
+
...pipeline2.toMutationArgs(values, true)
|
|
57908
|
+
});
|
|
57909
|
+
ctx.lastPushedGitState.set(stateKey, hash);
|
|
57910
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Observed git summary pushed: ${workingDir} (${branch}${values.get("isDirty") ? ", dirty" : ", clean"})${reason === "refresh" ? " [refresh]" : ""}`);
|
|
57911
|
+
}
|
|
55452
57912
|
async function prefetchMissingCommitDetails(ctx, workingDir, commits) {
|
|
55453
57913
|
if (commits.length === 0)
|
|
55454
57914
|
return;
|
|
@@ -55519,29 +57979,105 @@ async function prefetchSingleCommit(ctx, workingDir, sha, commits) {
|
|
|
55519
57979
|
});
|
|
55520
57980
|
console.log(`[${formatTimestamp()}] ✅ Pre-fetched: ${sha.slice(0, 7)} in ${workingDir}`);
|
|
55521
57981
|
}
|
|
57982
|
+
var branchField, GIT_STATE_FIELDS;
|
|
55522
57983
|
var init_git_heartbeat = __esm(() => {
|
|
57984
|
+
init_git_state_pipeline();
|
|
55523
57985
|
init_git_subscription();
|
|
55524
57986
|
init_api3();
|
|
55525
57987
|
init_git_reader();
|
|
55526
57988
|
init_convex_error();
|
|
57989
|
+
branchField = {
|
|
57990
|
+
key: "branch",
|
|
57991
|
+
includeInSlim: true,
|
|
57992
|
+
collect: () => {
|
|
57993
|
+
throw new Error("branch must be pre-collected");
|
|
57994
|
+
},
|
|
57995
|
+
toHashable: (raw) => {
|
|
57996
|
+
const r = raw;
|
|
57997
|
+
return r.status === "available" ? r.branch : "unknown";
|
|
57998
|
+
},
|
|
57999
|
+
toMutationPartial: (raw) => {
|
|
58000
|
+
const r = raw;
|
|
58001
|
+
return r.status === "available" ? { branch: r.branch } : {};
|
|
58002
|
+
},
|
|
58003
|
+
defaultValue: { status: "not_found" }
|
|
58004
|
+
};
|
|
58005
|
+
GIT_STATE_FIELDS = [
|
|
58006
|
+
{
|
|
58007
|
+
key: "isDirty",
|
|
58008
|
+
includeInSlim: true,
|
|
58009
|
+
collect: (wd) => isDirty(wd),
|
|
58010
|
+
toHashable: (raw) => raw,
|
|
58011
|
+
toMutationPartial: (raw) => ({ isDirty: raw }),
|
|
58012
|
+
defaultValue: false
|
|
58013
|
+
},
|
|
58014
|
+
{
|
|
58015
|
+
key: "diffStat",
|
|
58016
|
+
includeInSlim: false,
|
|
58017
|
+
collect: (wd) => getDiffStat(wd),
|
|
58018
|
+
toHashable: (raw) => {
|
|
58019
|
+
const r = raw;
|
|
58020
|
+
return r.status === "available" ? r.diffStat : { filesChanged: 0, insertions: 0, deletions: 0 };
|
|
58021
|
+
},
|
|
58022
|
+
toMutationPartial: (raw) => {
|
|
58023
|
+
const r = raw;
|
|
58024
|
+
return {
|
|
58025
|
+
diffStat: r.status === "available" ? r.diffStat : { filesChanged: 0, insertions: 0, deletions: 0 }
|
|
58026
|
+
};
|
|
58027
|
+
},
|
|
58028
|
+
defaultValue: { status: "not_found" }
|
|
58029
|
+
},
|
|
58030
|
+
{
|
|
58031
|
+
key: "commits",
|
|
58032
|
+
includeInSlim: false,
|
|
58033
|
+
collect: (wd) => getRecentCommits(wd, COMMITS_PER_PAGE),
|
|
58034
|
+
toHashable: (raw) => raw.map((c) => c.sha),
|
|
58035
|
+
toMutationPartial: () => ({}),
|
|
58036
|
+
defaultValue: []
|
|
58037
|
+
},
|
|
58038
|
+
{
|
|
58039
|
+
key: "commitsAhead",
|
|
58040
|
+
includeInSlim: false,
|
|
58041
|
+
collect: (wd) => getCommitsAhead(wd),
|
|
58042
|
+
toHashable: (raw) => raw,
|
|
58043
|
+
toMutationPartial: (raw) => ({ commitsAhead: raw }),
|
|
58044
|
+
defaultValue: 0
|
|
58045
|
+
},
|
|
58046
|
+
{
|
|
58047
|
+
key: "remotes",
|
|
58048
|
+
includeInSlim: false,
|
|
58049
|
+
collect: (wd) => getRemotes(wd),
|
|
58050
|
+
toHashable: (raw) => raw.map((r) => `${r.name}:${r.url}`),
|
|
58051
|
+
toMutationPartial: (raw) => ({ remotes: raw }),
|
|
58052
|
+
defaultValue: []
|
|
58053
|
+
},
|
|
58054
|
+
{
|
|
58055
|
+
key: "allPullRequests",
|
|
58056
|
+
includeInSlim: false,
|
|
58057
|
+
collect: (wd) => getAllPRs(wd),
|
|
58058
|
+
toHashable: (raw) => raw.map((pr) => `${pr.prNumber}:${pr.state}`),
|
|
58059
|
+
toMutationPartial: (raw) => ({ allPullRequests: raw }),
|
|
58060
|
+
defaultValue: []
|
|
58061
|
+
}
|
|
58062
|
+
];
|
|
55527
58063
|
});
|
|
55528
58064
|
|
|
55529
58065
|
// src/infrastructure/services/workspace/workspace-resolver.ts
|
|
55530
58066
|
import { readFile as readFile2, readdir, stat } from "node:fs/promises";
|
|
55531
|
-
import { join as
|
|
58067
|
+
import { join as join9, basename, resolve as resolve3 } from "node:path";
|
|
55532
58068
|
async function resolveGlobPattern(rootDir, pattern) {
|
|
55533
58069
|
const cleaned = pattern.replace(/\/+$/, "");
|
|
55534
58070
|
if (cleaned.includes("..")) {
|
|
55535
58071
|
return [];
|
|
55536
58072
|
}
|
|
55537
58073
|
if (cleaned.endsWith("/*")) {
|
|
55538
|
-
const parentDir =
|
|
58074
|
+
const parentDir = join9(rootDir, cleaned.slice(0, -2));
|
|
55539
58075
|
try {
|
|
55540
58076
|
const entries = await readdir(parentDir, { withFileTypes: true });
|
|
55541
58077
|
const dirs = [];
|
|
55542
58078
|
for (const entry of entries) {
|
|
55543
58079
|
if (entry.isDirectory()) {
|
|
55544
|
-
const dirPath =
|
|
58080
|
+
const dirPath = join9(parentDir, entry.name);
|
|
55545
58081
|
if (resolve3(dirPath).startsWith(resolve3(rootDir))) {
|
|
55546
58082
|
dirs.push(dirPath);
|
|
55547
58083
|
}
|
|
@@ -55552,7 +58088,7 @@ async function resolveGlobPattern(rootDir, pattern) {
|
|
|
55552
58088
|
return [];
|
|
55553
58089
|
}
|
|
55554
58090
|
} else {
|
|
55555
|
-
const dir =
|
|
58091
|
+
const dir = join9(rootDir, cleaned);
|
|
55556
58092
|
try {
|
|
55557
58093
|
if (!resolve3(dir).startsWith(resolve3(rootDir)))
|
|
55558
58094
|
return [];
|
|
@@ -55565,7 +58101,7 @@ async function resolveGlobPattern(rootDir, pattern) {
|
|
|
55565
58101
|
}
|
|
55566
58102
|
async function readPackageJson(dir) {
|
|
55567
58103
|
try {
|
|
55568
|
-
const content = await readFile2(
|
|
58104
|
+
const content = await readFile2(join9(dir, "package.json"), "utf-8");
|
|
55569
58105
|
const pkg = JSON.parse(content);
|
|
55570
58106
|
return {
|
|
55571
58107
|
name: pkg.name || basename(dir),
|
|
@@ -55577,7 +58113,7 @@ async function readPackageJson(dir) {
|
|
|
55577
58113
|
}
|
|
55578
58114
|
async function readPnpmWorkspacePatterns(rootDir) {
|
|
55579
58115
|
try {
|
|
55580
|
-
const content = await readFile2(
|
|
58116
|
+
const content = await readFile2(join9(rootDir, "pnpm-workspace.yaml"), "utf-8");
|
|
55581
58117
|
const patterns = [];
|
|
55582
58118
|
let inPackages = false;
|
|
55583
58119
|
for (const line of content.split(`
|
|
@@ -55604,7 +58140,7 @@ async function readPnpmWorkspacePatterns(rootDir) {
|
|
|
55604
58140
|
}
|
|
55605
58141
|
async function readPackageJsonWorkspacePatterns(rootDir) {
|
|
55606
58142
|
try {
|
|
55607
|
-
const content = await readFile2(
|
|
58143
|
+
const content = await readFile2(join9(rootDir, "package.json"), "utf-8");
|
|
55608
58144
|
const pkg = JSON.parse(content);
|
|
55609
58145
|
if (!pkg.workspaces)
|
|
55610
58146
|
return [];
|
|
@@ -55654,11 +58190,11 @@ var init_workspace_resolver = () => {};
|
|
|
55654
58190
|
// src/infrastructure/services/workspace/command-discovery.ts
|
|
55655
58191
|
import { access as access2 } from "node:fs/promises";
|
|
55656
58192
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
55657
|
-
import { join as
|
|
58193
|
+
import { join as join10, relative, basename as basename2 } from "node:path";
|
|
55658
58194
|
async function detectPackageManager(workingDir) {
|
|
55659
58195
|
for (const { file, manager } of LOCKFILE_MAP) {
|
|
55660
58196
|
try {
|
|
55661
|
-
await access2(
|
|
58197
|
+
await access2(join10(workingDir, file));
|
|
55662
58198
|
return manager;
|
|
55663
58199
|
} catch {}
|
|
55664
58200
|
}
|
|
@@ -55705,7 +58241,7 @@ async function discoverCommands(workingDir) {
|
|
|
55705
58241
|
const turboTaskNames = [];
|
|
55706
58242
|
let rootPackageName = basename2(workingDir);
|
|
55707
58243
|
try {
|
|
55708
|
-
const pkgPath =
|
|
58244
|
+
const pkgPath = join10(workingDir, "package.json");
|
|
55709
58245
|
const pkgContent = await readFile3(pkgPath, "utf-8");
|
|
55710
58246
|
const pkg = JSON.parse(pkgContent);
|
|
55711
58247
|
if (pkg.name)
|
|
@@ -55726,7 +58262,7 @@ async function discoverCommands(workingDir) {
|
|
|
55726
58262
|
} catch {}
|
|
55727
58263
|
const rootSubWorkspace = { type: "npm", path: ".", name: rootPackageName };
|
|
55728
58264
|
try {
|
|
55729
|
-
const turboPath =
|
|
58265
|
+
const turboPath = join10(workingDir, "turbo.json");
|
|
55730
58266
|
const turboContent = await readFile3(turboPath, "utf-8");
|
|
55731
58267
|
const turbo = JSON.parse(turboContent);
|
|
55732
58268
|
if (turbo.tasks && typeof turbo.tasks === "object") {
|
|
@@ -56164,6 +58700,176 @@ var init_file_tree_subscription = __esm(() => {
|
|
|
56164
58700
|
init_convex_error();
|
|
56165
58701
|
});
|
|
56166
58702
|
|
|
58703
|
+
// src/commands/machine/daemon-start/observed-sync.ts
|
|
58704
|
+
function startObservedSyncSubscription(ctx, wsClient2) {
|
|
58705
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Starting observed-sync subscription (reactive)`);
|
|
58706
|
+
const observedWorkingDirs = new Map;
|
|
58707
|
+
const chatroomRefreshState = new Map;
|
|
58708
|
+
const skippedPushCount = new Map;
|
|
58709
|
+
const pendingRefresh = new Map;
|
|
58710
|
+
let stopped = false;
|
|
58711
|
+
let reconcileInFlight = false;
|
|
58712
|
+
const unsubscribe = wsClient2.onUpdate(api.machines.getObservedChatroomsForMachine, {
|
|
58713
|
+
sessionId: ctx.sessionId,
|
|
58714
|
+
machineId: ctx.machineId
|
|
58715
|
+
}, (observed) => {
|
|
58716
|
+
if (stopped)
|
|
58717
|
+
return;
|
|
58718
|
+
handleObservedChange(observed ?? []);
|
|
58719
|
+
}, (err) => {
|
|
58720
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Observed-sync subscription error: ${getErrorMessage(err)}`);
|
|
58721
|
+
});
|
|
58722
|
+
const reconcileIntervalMs = Math.max(OBSERVATION_TTL_MS / 2, OBSERVED_SAFETY_POLL_MS);
|
|
58723
|
+
const reconcileTimer = setInterval(() => {
|
|
58724
|
+
if (stopped || reconcileInFlight)
|
|
58725
|
+
return;
|
|
58726
|
+
reconcileInFlight = true;
|
|
58727
|
+
ctx.deps.backend.query(api.machines.getObservedChatroomsForMachine, {
|
|
58728
|
+
sessionId: ctx.sessionId,
|
|
58729
|
+
machineId: ctx.machineId
|
|
58730
|
+
}).then((observed) => {
|
|
58731
|
+
if (!stopped)
|
|
58732
|
+
handleObservedChange(observed ?? []);
|
|
58733
|
+
}).catch((err) => {
|
|
58734
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Observed-sync reconcile query failed: ${getErrorMessage(err)}`);
|
|
58735
|
+
}).finally(() => {
|
|
58736
|
+
reconcileInFlight = false;
|
|
58737
|
+
});
|
|
58738
|
+
}, reconcileIntervalMs);
|
|
58739
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Observed-sync subscription started`);
|
|
58740
|
+
return {
|
|
58741
|
+
stop: () => {
|
|
58742
|
+
stopped = true;
|
|
58743
|
+
unsubscribe();
|
|
58744
|
+
clearInterval(reconcileTimer);
|
|
58745
|
+
for (const [wd, state] of observedWorkingDirs) {
|
|
58746
|
+
clearInterval(state.intervalHandle);
|
|
58747
|
+
const skips = skippedPushCount.get(wd) ?? 0;
|
|
58748
|
+
if (skips > 0) {
|
|
58749
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Stopped observing ${wd} (skipped ${skips} overlapping pushes)`);
|
|
58750
|
+
} else {
|
|
58751
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Stopped observing ${wd}`);
|
|
58752
|
+
}
|
|
58753
|
+
}
|
|
58754
|
+
observedWorkingDirs.clear();
|
|
58755
|
+
skippedPushCount.clear();
|
|
58756
|
+
pendingRefresh.clear();
|
|
58757
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Observed-sync subscription stopped`);
|
|
58758
|
+
}
|
|
58759
|
+
};
|
|
58760
|
+
function handleObservedChange(observed) {
|
|
58761
|
+
const newWorkingDirs = new Set;
|
|
58762
|
+
const refreshedWorkingDirs = new Set;
|
|
58763
|
+
for (const chatroom of observed) {
|
|
58764
|
+
const chatroomId = chatroom.chatroomId;
|
|
58765
|
+
const currentRefresh = chatroom.lastRefreshedAt;
|
|
58766
|
+
const previous = chatroomRefreshState.get(chatroomId);
|
|
58767
|
+
const wasRefreshed = currentRefresh !== null && currentRefresh !== undefined && (previous === undefined || (previous.lastRefreshedAt ?? 0) < currentRefresh);
|
|
58768
|
+
if (wasRefreshed) {
|
|
58769
|
+
chatroomRefreshState.set(chatroomId, { lastRefreshedAt: currentRefresh });
|
|
58770
|
+
for (const wd of chatroom.workingDirs) {
|
|
58771
|
+
refreshedWorkingDirs.add(wd);
|
|
58772
|
+
}
|
|
58773
|
+
}
|
|
58774
|
+
for (const wd of chatroom.workingDirs) {
|
|
58775
|
+
newWorkingDirs.add(wd);
|
|
58776
|
+
}
|
|
58777
|
+
}
|
|
58778
|
+
for (const [chatroomId] of chatroomRefreshState) {
|
|
58779
|
+
const stillObserved = observed.some((c) => c.chatroomId === chatroomId);
|
|
58780
|
+
if (!stillObserved) {
|
|
58781
|
+
chatroomRefreshState.delete(chatroomId);
|
|
58782
|
+
}
|
|
58783
|
+
}
|
|
58784
|
+
const currentWorkingDirs = new Set(observedWorkingDirs.keys());
|
|
58785
|
+
let addedCount = 0;
|
|
58786
|
+
let removedCount = 0;
|
|
58787
|
+
for (const wd of currentWorkingDirs) {
|
|
58788
|
+
if (!newWorkingDirs.has(wd)) {
|
|
58789
|
+
const state = observedWorkingDirs.get(wd);
|
|
58790
|
+
if (state) {
|
|
58791
|
+
clearInterval(state.intervalHandle);
|
|
58792
|
+
observedWorkingDirs.delete(wd);
|
|
58793
|
+
const skips = skippedPushCount.get(wd) ?? 0;
|
|
58794
|
+
if (skips > 0) {
|
|
58795
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Stopped observing ${wd} (skipped ${skips} overlapping pushes)`);
|
|
58796
|
+
} else {
|
|
58797
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Stopped observing ${wd}`);
|
|
58798
|
+
}
|
|
58799
|
+
skippedPushCount.delete(wd);
|
|
58800
|
+
pendingRefresh.delete(wd);
|
|
58801
|
+
removedCount++;
|
|
58802
|
+
}
|
|
58803
|
+
}
|
|
58804
|
+
}
|
|
58805
|
+
for (const wd of newWorkingDirs) {
|
|
58806
|
+
if (!observedWorkingDirs.has(wd)) {
|
|
58807
|
+
observedWorkingDirs.set(wd, {
|
|
58808
|
+
intervalHandle: setInterval(() => {
|
|
58809
|
+
schedulePushForWorkingDir(wd, "safety-poll");
|
|
58810
|
+
}, OBSERVED_SAFETY_POLL_MS),
|
|
58811
|
+
pushInFlight: false
|
|
58812
|
+
});
|
|
58813
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Started observing ${wd}`);
|
|
58814
|
+
schedulePushForWorkingDir(wd, "safety-poll");
|
|
58815
|
+
addedCount++;
|
|
58816
|
+
}
|
|
58817
|
+
}
|
|
58818
|
+
if (addedCount > 0 || removedCount > 0) {
|
|
58819
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Observing ${observedWorkingDirs.size} working dir(s)`);
|
|
58820
|
+
}
|
|
58821
|
+
for (const wd of refreshedWorkingDirs) {
|
|
58822
|
+
if (observedWorkingDirs.has(wd)) {
|
|
58823
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDD04 Refresh triggered for ${wd}`);
|
|
58824
|
+
schedulePushForWorkingDir(wd, "refresh");
|
|
58825
|
+
}
|
|
58826
|
+
}
|
|
58827
|
+
}
|
|
58828
|
+
function schedulePushForWorkingDir(workingDir, reason = "safety-poll") {
|
|
58829
|
+
if (stopped)
|
|
58830
|
+
return;
|
|
58831
|
+
const state = observedWorkingDirs.get(workingDir);
|
|
58832
|
+
if (!state)
|
|
58833
|
+
return;
|
|
58834
|
+
if (state.pushInFlight) {
|
|
58835
|
+
if (reason === "refresh") {
|
|
58836
|
+
pendingRefresh.set(workingDir, true);
|
|
58837
|
+
}
|
|
58838
|
+
const current = skippedPushCount.get(workingDir) ?? 0;
|
|
58839
|
+
skippedPushCount.set(workingDir, current + 1);
|
|
58840
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Skipping observed push for ${workingDir} (${reason}, in flight)`);
|
|
58841
|
+
return;
|
|
58842
|
+
}
|
|
58843
|
+
state.pushInFlight = true;
|
|
58844
|
+
pushForWorkingDir(workingDir, reason).catch((err) => {
|
|
58845
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Push failed for ${workingDir}: ${getErrorMessage(err)}`);
|
|
58846
|
+
}).finally(() => {
|
|
58847
|
+
const s = observedWorkingDirs.get(workingDir);
|
|
58848
|
+
if (s) {
|
|
58849
|
+
s.pushInFlight = false;
|
|
58850
|
+
if (pendingRefresh.get(workingDir)) {
|
|
58851
|
+
pendingRefresh.delete(workingDir);
|
|
58852
|
+
schedulePushForWorkingDir(workingDir, "refresh");
|
|
58853
|
+
}
|
|
58854
|
+
}
|
|
58855
|
+
});
|
|
58856
|
+
}
|
|
58857
|
+
async function pushForWorkingDir(workingDir, reason = "safety-poll") {
|
|
58858
|
+
await pushSingleWorkspaceGitSummaryForObserved(ctx, workingDir, reason).catch((err) => {
|
|
58859
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Observed git summary push failed for ${workingDir}: ${getErrorMessage(err)}`);
|
|
58860
|
+
});
|
|
58861
|
+
await pushSingleWorkspaceCommands(ctx, workingDir).catch((err) => {
|
|
58862
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Command sync failed for ${workingDir}: ${getErrorMessage(err)}`);
|
|
58863
|
+
});
|
|
58864
|
+
}
|
|
58865
|
+
}
|
|
58866
|
+
var init_observed_sync = __esm(() => {
|
|
58867
|
+
init_api3();
|
|
58868
|
+
init_git_heartbeat();
|
|
58869
|
+
init_command_sync_heartbeat();
|
|
58870
|
+
init_convex_error();
|
|
58871
|
+
});
|
|
58872
|
+
|
|
56167
58873
|
// src/commands/machine/daemon-start/handlers/ping.ts
|
|
56168
58874
|
function handlePing() {
|
|
56169
58875
|
console.log(` ↪ Responding: pong`);
|
|
@@ -56661,7 +59367,7 @@ function ts() {
|
|
|
56661
59367
|
}
|
|
56662
59368
|
async function startLocalApi(ctx, port = resolvePort()) {
|
|
56663
59369
|
const router = createRouter();
|
|
56664
|
-
const
|
|
59370
|
+
const server2 = createServer(async (req, res) => {
|
|
56665
59371
|
try {
|
|
56666
59372
|
const localReq = await normalizeRequest(req);
|
|
56667
59373
|
const localRes = await router.handleRequest(localReq, ctx);
|
|
@@ -56671,11 +59377,11 @@ async function startLocalApi(ctx, port = resolvePort()) {
|
|
|
56671
59377
|
}
|
|
56672
59378
|
});
|
|
56673
59379
|
await new Promise((resolve5) => {
|
|
56674
|
-
|
|
59380
|
+
server2.listen(port, "127.0.0.1", () => {
|
|
56675
59381
|
console.log(`[${ts()}] \uD83C\uDF10 Local API started on http://localhost:${port}`);
|
|
56676
59382
|
resolve5();
|
|
56677
59383
|
});
|
|
56678
|
-
|
|
59384
|
+
server2.on("error", (err) => {
|
|
56679
59385
|
if (err.code === "EADDRINUSE") {
|
|
56680
59386
|
console.warn(`[${ts()}] ⚠️ Local API port ${port} already in use — skipping local API`);
|
|
56681
59387
|
} else {
|
|
@@ -56684,12 +59390,12 @@ async function startLocalApi(ctx, port = resolvePort()) {
|
|
|
56684
59390
|
resolve5();
|
|
56685
59391
|
});
|
|
56686
59392
|
});
|
|
56687
|
-
const
|
|
56688
|
-
if (!
|
|
59393
|
+
const stop2 = () => new Promise((resolve5, reject) => {
|
|
59394
|
+
if (!server2.listening) {
|
|
56689
59395
|
resolve5();
|
|
56690
59396
|
return;
|
|
56691
59397
|
}
|
|
56692
|
-
|
|
59398
|
+
server2.close((err) => {
|
|
56693
59399
|
if (err) {
|
|
56694
59400
|
reject(err);
|
|
56695
59401
|
} else {
|
|
@@ -56698,10 +59404,10 @@ async function startLocalApi(ctx, port = resolvePort()) {
|
|
|
56698
59404
|
}
|
|
56699
59405
|
});
|
|
56700
59406
|
});
|
|
56701
|
-
return { stop };
|
|
59407
|
+
return { stop: stop2 };
|
|
56702
59408
|
}
|
|
56703
59409
|
var LOCAL_API_PORT = 19847;
|
|
56704
|
-
var
|
|
59410
|
+
var init_server3 = __esm(() => {
|
|
56705
59411
|
init_identity();
|
|
56706
59412
|
init_open_finder();
|
|
56707
59413
|
init_open_github_desktop();
|
|
@@ -56711,7 +59417,7 @@ var init_server2 = __esm(() => {
|
|
|
56711
59417
|
|
|
56712
59418
|
// src/infrastructure/local-api/index.ts
|
|
56713
59419
|
var init_local_api = __esm(() => {
|
|
56714
|
-
|
|
59420
|
+
init_server3();
|
|
56715
59421
|
});
|
|
56716
59422
|
|
|
56717
59423
|
// src/events/daemon/event-bus.ts
|
|
@@ -56958,6 +59664,13 @@ function resolveStopReason(code2, signal) {
|
|
|
56958
59664
|
return "agent_process.crashed";
|
|
56959
59665
|
}
|
|
56960
59666
|
|
|
59667
|
+
// src/infrastructure/services/remote-agents/spawn-prompt.ts
|
|
59668
|
+
function createSpawnPrompt(raw) {
|
|
59669
|
+
const trimmed = raw?.trim();
|
|
59670
|
+
return trimmed && trimmed.length > 0 ? trimmed : DEFAULT_TRIGGER_PROMPT;
|
|
59671
|
+
}
|
|
59672
|
+
var DEFAULT_TRIGGER_PROMPT = "Please read your system prompt carefully and follow the Getting Started instructions.";
|
|
59673
|
+
|
|
56961
59674
|
// src/infrastructure/services/agent-process-manager/agent-process-manager.ts
|
|
56962
59675
|
function agentKey2(chatroomId, role) {
|
|
56963
59676
|
return `${chatroomId}:${role.toLowerCase()}`;
|
|
@@ -57266,7 +59979,7 @@ class AgentProcessManager {
|
|
|
57266
59979
|
try {
|
|
57267
59980
|
spawnResult = await service.spawn({
|
|
57268
59981
|
workingDir: opts.workingDir,
|
|
57269
|
-
prompt: initPromptResult.initialMessage,
|
|
59982
|
+
prompt: createSpawnPrompt(initPromptResult.initialMessage),
|
|
57270
59983
|
systemPrompt: initPromptResult.rolePrompt,
|
|
57271
59984
|
model: opts.model,
|
|
57272
59985
|
context: {
|
|
@@ -57399,6 +60112,15 @@ var init_agent_process_manager = __esm(() => {
|
|
|
57399
60112
|
init_api3();
|
|
57400
60113
|
});
|
|
57401
60114
|
|
|
60115
|
+
// ../../services/backend/config/featureFlags.ts
|
|
60116
|
+
var featureFlags;
|
|
60117
|
+
var init_featureFlags = __esm(() => {
|
|
60118
|
+
featureFlags = {
|
|
60119
|
+
observedSyncEnabled: false,
|
|
60120
|
+
disableLogin: false
|
|
60121
|
+
};
|
|
60122
|
+
});
|
|
60123
|
+
|
|
57402
60124
|
// src/commands/machine/daemon-start/init.ts
|
|
57403
60125
|
import { stat as stat2 } from "node:fs/promises";
|
|
57404
60126
|
async function discoverModels(agentServices) {
|
|
@@ -57481,8 +60203,8 @@ Run: chatroom auth login`);
|
|
|
57481
60203
|
⏳ Waiting for authentication (timeout: 5 minutes)...`);
|
|
57482
60204
|
return waitForAuthentication(convexUrl);
|
|
57483
60205
|
}
|
|
57484
|
-
async function validateSession(
|
|
57485
|
-
const validation = await
|
|
60206
|
+
async function validateSession(client4, sessionId, convexUrl) {
|
|
60207
|
+
const validation = await client4.query(api.cliAuth.validateSession, { sessionId });
|
|
57486
60208
|
if (validation.valid) {
|
|
57487
60209
|
return sessionId;
|
|
57488
60210
|
}
|
|
@@ -57493,7 +60215,7 @@ Run: chatroom auth login`);
|
|
|
57493
60215
|
⏳ Waiting for re-authentication (timeout: 5 minutes)...`);
|
|
57494
60216
|
const newSessionId2 = await waitForAuthentication(convexUrl);
|
|
57495
60217
|
const typedNewSession = newSessionId2;
|
|
57496
|
-
const revalidation = await
|
|
60218
|
+
const revalidation = await client4.query(api.cliAuth.validateSession, {
|
|
57497
60219
|
sessionId: typedNewSession
|
|
57498
60220
|
});
|
|
57499
60221
|
if (!revalidation.valid) {
|
|
@@ -57508,11 +60230,11 @@ function setupMachine() {
|
|
|
57508
60230
|
const config3 = loadMachineConfig();
|
|
57509
60231
|
return config3;
|
|
57510
60232
|
}
|
|
57511
|
-
async function registerCapabilities(
|
|
60233
|
+
async function registerCapabilities(client4, sessionId, config3, agentServices) {
|
|
57512
60234
|
const { machineId } = config3;
|
|
57513
60235
|
const availableModels = await discoverModels(agentServices);
|
|
57514
60236
|
try {
|
|
57515
|
-
await
|
|
60237
|
+
await client4.mutation(api.machines.register, {
|
|
57516
60238
|
sessionId,
|
|
57517
60239
|
machineId,
|
|
57518
60240
|
hostname: config3.hostname,
|
|
@@ -57526,9 +60248,9 @@ async function registerCapabilities(client2, sessionId, config3, agentServices)
|
|
|
57526
60248
|
}
|
|
57527
60249
|
return availableModels;
|
|
57528
60250
|
}
|
|
57529
|
-
async function connectDaemon(
|
|
60251
|
+
async function connectDaemon(client4, sessionId, machineId, convexUrl) {
|
|
57530
60252
|
try {
|
|
57531
|
-
await
|
|
60253
|
+
await client4.mutation(api.machines.updateDaemonStatus, {
|
|
57532
60254
|
sessionId,
|
|
57533
60255
|
machineId,
|
|
57534
60256
|
connected: true
|
|
@@ -57579,25 +60301,25 @@ async function initDaemon() {
|
|
|
57579
60301
|
}
|
|
57580
60302
|
const convexUrl = getConvexUrl();
|
|
57581
60303
|
const sessionId = await validateAuthentication(convexUrl);
|
|
57582
|
-
const
|
|
60304
|
+
const client4 = await getConvexClient();
|
|
57583
60305
|
let typedSessionId = sessionId;
|
|
57584
60306
|
let consecutiveFailures = 0;
|
|
57585
60307
|
while (true) {
|
|
57586
60308
|
try {
|
|
57587
|
-
typedSessionId = await validateSession(
|
|
60309
|
+
typedSessionId = await validateSession(client4, typedSessionId, convexUrl);
|
|
57588
60310
|
const config3 = setupMachine();
|
|
57589
60311
|
const { machineId } = config3;
|
|
57590
60312
|
initHarnessRegistry();
|
|
57591
60313
|
const agentServices = new Map(getAllHarnesses().map((s) => [s.id, s]));
|
|
57592
|
-
const availableModels = await registerCapabilities(
|
|
57593
|
-
await connectDaemon(
|
|
60314
|
+
const availableModels = await registerCapabilities(client4, typedSessionId, config3, agentServices);
|
|
60315
|
+
await connectDaemon(client4, typedSessionId, machineId, convexUrl);
|
|
57594
60316
|
if (consecutiveFailures > 0) {
|
|
57595
60317
|
console.log(`[${formatTimestamp()}] ✅ Backend reachable again at ${convexUrl}`);
|
|
57596
60318
|
consecutiveFailures = 0;
|
|
57597
60319
|
}
|
|
57598
60320
|
const deps = createDefaultDeps21();
|
|
57599
|
-
deps.backend.mutation = (endpoint, args) =>
|
|
57600
|
-
deps.backend.query = (endpoint, args) =>
|
|
60321
|
+
deps.backend.mutation = (endpoint, args) => client4.mutation(endpoint, args);
|
|
60322
|
+
deps.backend.query = (endpoint, args) => client4.query(endpoint, args);
|
|
57601
60323
|
deps.agentProcessManager = new AgentProcessManager({
|
|
57602
60324
|
agentServices,
|
|
57603
60325
|
backend: deps.backend,
|
|
@@ -57613,7 +60335,7 @@ async function initDaemon() {
|
|
|
57613
60335
|
});
|
|
57614
60336
|
const events = new DaemonEventBus;
|
|
57615
60337
|
const ctx = {
|
|
57616
|
-
client:
|
|
60338
|
+
client: client4,
|
|
57617
60339
|
sessionId: typedSessionId,
|
|
57618
60340
|
machineId,
|
|
57619
60341
|
config: config3,
|
|
@@ -57621,7 +60343,8 @@ async function initDaemon() {
|
|
|
57621
60343
|
events,
|
|
57622
60344
|
agentServices,
|
|
57623
60345
|
lastPushedGitState: new Map,
|
|
57624
|
-
lastPushedModels: availableModels
|
|
60346
|
+
lastPushedModels: availableModels,
|
|
60347
|
+
observedSyncEnabled: featureFlags.observedSyncEnabled ?? false
|
|
57625
60348
|
};
|
|
57626
60349
|
registerEventListeners(ctx);
|
|
57627
60350
|
logStartup(ctx, availableModels);
|
|
@@ -57663,6 +60386,7 @@ var init_init2 = __esm(() => {
|
|
|
57663
60386
|
init_convex_error();
|
|
57664
60387
|
init_version();
|
|
57665
60388
|
init_pid();
|
|
60389
|
+
init_featureFlags();
|
|
57666
60390
|
AUTH_WAIT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
57667
60391
|
});
|
|
57668
60392
|
|
|
@@ -58006,12 +60730,14 @@ async function startCommandLoop(ctx) {
|
|
|
58006
60730
|
}).then(() => {
|
|
58007
60731
|
heartbeatCount++;
|
|
58008
60732
|
console.log(`[${formatTimestamp()}] \uD83D\uDC93 Daemon heartbeat #${heartbeatCount} OK`);
|
|
58009
|
-
|
|
58010
|
-
|
|
58011
|
-
|
|
58012
|
-
|
|
58013
|
-
|
|
58014
|
-
|
|
60733
|
+
if (!ctx.observedSyncEnabled) {
|
|
60734
|
+
pushGitState(ctx).catch((err) => {
|
|
60735
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Git state push failed: ${getErrorMessage(err)}`);
|
|
60736
|
+
});
|
|
60737
|
+
pushCommands(ctx).catch((err) => {
|
|
60738
|
+
console.warn(`[${formatTimestamp()}] ⚠️ Command sync failed: ${getErrorMessage(err)}`);
|
|
60739
|
+
});
|
|
60740
|
+
}
|
|
58015
60741
|
}).catch((err) => {
|
|
58016
60742
|
console.warn(`[${formatTimestamp()}] ⚠️ Daemon heartbeat failed: ${getErrorMessage(err)}`);
|
|
58017
60743
|
});
|
|
@@ -58020,8 +60746,13 @@ async function startCommandLoop(ctx) {
|
|
|
58020
60746
|
let gitSubscriptionHandle = null;
|
|
58021
60747
|
let fileContentSubscriptionHandle = null;
|
|
58022
60748
|
let fileTreeSubscriptionHandle = null;
|
|
58023
|
-
|
|
58024
|
-
|
|
60749
|
+
let observedSyncSubscriptionHandle = null;
|
|
60750
|
+
if (ctx.observedSyncEnabled) {
|
|
60751
|
+
console.log(`[${formatTimestamp()}] \uD83D\uDC41️ Observed-sync enabled, skipping immediate push`);
|
|
60752
|
+
} else {
|
|
60753
|
+
pushGitState(ctx).catch(() => {});
|
|
60754
|
+
pushCommands(ctx).catch(() => {});
|
|
60755
|
+
}
|
|
58025
60756
|
const shutdown = async () => {
|
|
58026
60757
|
console.log(`
|
|
58027
60758
|
[${formatTimestamp()}] Shutting down...`);
|
|
@@ -58032,6 +60763,8 @@ async function startCommandLoop(ctx) {
|
|
|
58032
60763
|
fileContentSubscriptionHandle.stop();
|
|
58033
60764
|
if (fileTreeSubscriptionHandle)
|
|
58034
60765
|
fileTreeSubscriptionHandle.stop();
|
|
60766
|
+
if (observedSyncSubscriptionHandle)
|
|
60767
|
+
observedSyncSubscriptionHandle.stop();
|
|
58035
60768
|
await onDaemonShutdown(ctx);
|
|
58036
60769
|
if (ctx.stopLocalApi) {
|
|
58037
60770
|
await ctx.stopLocalApi().catch(() => {});
|
|
@@ -58046,6 +60779,9 @@ async function startCommandLoop(ctx) {
|
|
|
58046
60779
|
gitSubscriptionHandle = startGitRequestSubscription(ctx, wsClient2);
|
|
58047
60780
|
fileContentSubscriptionHandle = startFileContentSubscription(ctx, wsClient2);
|
|
58048
60781
|
fileTreeSubscriptionHandle = startFileTreeSubscription(ctx, wsClient2);
|
|
60782
|
+
if (ctx.observedSyncEnabled) {
|
|
60783
|
+
observedSyncSubscriptionHandle = startObservedSyncSubscription(ctx, wsClient2);
|
|
60784
|
+
}
|
|
58049
60785
|
console.log(`
|
|
58050
60786
|
Listening for commands...`);
|
|
58051
60787
|
console.log(`Press Ctrl+C to stop
|
|
@@ -58092,6 +60828,7 @@ var init_command_loop = __esm(() => {
|
|
|
58092
60828
|
init_file_content_subscription();
|
|
58093
60829
|
init_file_tree_subscription();
|
|
58094
60830
|
init_git_subscription();
|
|
60831
|
+
init_observed_sync();
|
|
58095
60832
|
init_command_runner();
|
|
58096
60833
|
init_init2();
|
|
58097
60834
|
init_api3();
|
|
@@ -58188,12 +60925,12 @@ async function isChatroomInstalledDefault() {
|
|
|
58188
60925
|
}
|
|
58189
60926
|
}
|
|
58190
60927
|
async function createDefaultDeps22() {
|
|
58191
|
-
const
|
|
60928
|
+
const client4 = await getConvexClient();
|
|
58192
60929
|
const fs6 = await import("fs/promises");
|
|
58193
60930
|
return {
|
|
58194
60931
|
backend: {
|
|
58195
|
-
mutation: (endpoint, args) =>
|
|
58196
|
-
query: (endpoint, args) =>
|
|
60932
|
+
mutation: (endpoint, args) => client4.mutation(endpoint, args),
|
|
60933
|
+
query: (endpoint, args) => client4.query(endpoint, args)
|
|
58197
60934
|
},
|
|
58198
60935
|
session: {
|
|
58199
60936
|
getSessionId,
|
|
@@ -58618,8 +61355,8 @@ var exports_lifecycle_heartbeat = {};
|
|
|
58618
61355
|
__export(exports_lifecycle_heartbeat, {
|
|
58619
61356
|
sendLifecycleHeartbeat: () => sendLifecycleHeartbeat
|
|
58620
61357
|
});
|
|
58621
|
-
function sendLifecycleHeartbeat(
|
|
58622
|
-
withRetry(() =>
|
|
61358
|
+
function sendLifecycleHeartbeat(client4, opts) {
|
|
61359
|
+
withRetry(() => client4.mutation(api.participants.join, {
|
|
58623
61360
|
sessionId: opts.sessionId,
|
|
58624
61361
|
chatroomId: opts.chatroomId,
|
|
58625
61362
|
role: opts.role,
|
|
@@ -59192,10 +61929,10 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
59192
61929
|
const sessionId = getSessionId2();
|
|
59193
61930
|
if (!sessionId)
|
|
59194
61931
|
return;
|
|
59195
|
-
const
|
|
59196
|
-
sendLifecycleHeartbeat2(
|
|
61932
|
+
const client4 = await getConvexClient2();
|
|
61933
|
+
sendLifecycleHeartbeat2(client4, { sessionId, chatroomId, role, action: actionCommand.name() });
|
|
59197
61934
|
});
|
|
59198
61935
|
program2.parse();
|
|
59199
61936
|
|
|
59200
|
-
//# debugId=
|
|
61937
|
+
//# debugId=C6BB51F249BBA12864756E2164756E21
|
|
59201
61938
|
//# sourceMappingURL=index.js.map
|