@buildautomaton/cli 0.1.93 → 0.1.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +955 -1228
- package/dist/cli.js.map +4 -4
- package/dist/index.js +921 -1195
- package/dist/index.js.map +4 -4
- package/dist/worker.js +84 -161
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4086,10 +4086,10 @@ function mergeDefs(...defs) {
|
|
|
4086
4086
|
function cloneDef(schema) {
|
|
4087
4087
|
return mergeDefs(schema._zod.def);
|
|
4088
4088
|
}
|
|
4089
|
-
function getElementAtPath(obj,
|
|
4090
|
-
if (!
|
|
4089
|
+
function getElementAtPath(obj, path83) {
|
|
4090
|
+
if (!path83)
|
|
4091
4091
|
return obj;
|
|
4092
|
-
return
|
|
4092
|
+
return path83.reduce((acc, key) => acc?.[key], obj);
|
|
4093
4093
|
}
|
|
4094
4094
|
function promiseAllObject(promisesObj) {
|
|
4095
4095
|
const keys = Object.keys(promisesObj);
|
|
@@ -4417,11 +4417,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
4417
4417
|
}
|
|
4418
4418
|
return false;
|
|
4419
4419
|
}
|
|
4420
|
-
function prefixIssues(
|
|
4420
|
+
function prefixIssues(path83, issues) {
|
|
4421
4421
|
return issues.map((iss) => {
|
|
4422
4422
|
var _a4;
|
|
4423
4423
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
4424
|
-
iss.path.unshift(
|
|
4424
|
+
iss.path.unshift(path83);
|
|
4425
4425
|
return iss;
|
|
4426
4426
|
});
|
|
4427
4427
|
}
|
|
@@ -4638,16 +4638,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4638
4638
|
}
|
|
4639
4639
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
4640
4640
|
const fieldErrors = { _errors: [] };
|
|
4641
|
-
const processError = (error52,
|
|
4641
|
+
const processError = (error52, path83 = []) => {
|
|
4642
4642
|
for (const issue2 of error52.issues) {
|
|
4643
4643
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4644
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4644
|
+
issue2.errors.map((issues) => processError({ issues }, [...path83, ...issue2.path]));
|
|
4645
4645
|
} else if (issue2.code === "invalid_key") {
|
|
4646
|
-
processError({ issues: issue2.issues }, [...
|
|
4646
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4647
4647
|
} else if (issue2.code === "invalid_element") {
|
|
4648
|
-
processError({ issues: issue2.issues }, [...
|
|
4648
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4649
4649
|
} else {
|
|
4650
|
-
const fullpath = [...
|
|
4650
|
+
const fullpath = [...path83, ...issue2.path];
|
|
4651
4651
|
if (fullpath.length === 0) {
|
|
4652
4652
|
fieldErrors._errors.push(mapper(issue2));
|
|
4653
4653
|
} else {
|
|
@@ -4674,17 +4674,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4674
4674
|
}
|
|
4675
4675
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
4676
4676
|
const result = { errors: [] };
|
|
4677
|
-
const processError = (error52,
|
|
4677
|
+
const processError = (error52, path83 = []) => {
|
|
4678
4678
|
var _a4, _b;
|
|
4679
4679
|
for (const issue2 of error52.issues) {
|
|
4680
4680
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
4681
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
4681
|
+
issue2.errors.map((issues) => processError({ issues }, [...path83, ...issue2.path]));
|
|
4682
4682
|
} else if (issue2.code === "invalid_key") {
|
|
4683
|
-
processError({ issues: issue2.issues }, [...
|
|
4683
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4684
4684
|
} else if (issue2.code === "invalid_element") {
|
|
4685
|
-
processError({ issues: issue2.issues }, [...
|
|
4685
|
+
processError({ issues: issue2.issues }, [...path83, ...issue2.path]);
|
|
4686
4686
|
} else {
|
|
4687
|
-
const fullpath = [...
|
|
4687
|
+
const fullpath = [...path83, ...issue2.path];
|
|
4688
4688
|
if (fullpath.length === 0) {
|
|
4689
4689
|
result.errors.push(mapper(issue2));
|
|
4690
4690
|
continue;
|
|
@@ -4716,8 +4716,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
4716
4716
|
}
|
|
4717
4717
|
function toDotPath(_path) {
|
|
4718
4718
|
const segs = [];
|
|
4719
|
-
const
|
|
4720
|
-
for (const seg of
|
|
4719
|
+
const path83 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
4720
|
+
for (const seg of path83) {
|
|
4721
4721
|
if (typeof seg === "number")
|
|
4722
4722
|
segs.push(`[${seg}]`);
|
|
4723
4723
|
else if (typeof seg === "symbol")
|
|
@@ -18147,13 +18147,13 @@ function resolveRef(ref, ctx) {
|
|
|
18147
18147
|
if (!ref.startsWith("#")) {
|
|
18148
18148
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18149
18149
|
}
|
|
18150
|
-
const
|
|
18151
|
-
if (
|
|
18150
|
+
const path83 = ref.slice(1).split("/").filter(Boolean);
|
|
18151
|
+
if (path83.length === 0) {
|
|
18152
18152
|
return ctx.rootSchema;
|
|
18153
18153
|
}
|
|
18154
18154
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18155
|
-
if (
|
|
18156
|
-
const key =
|
|
18155
|
+
if (path83[0] === defsKey) {
|
|
18156
|
+
const key = path83[1];
|
|
18157
18157
|
if (!key || !ctx.defs[key]) {
|
|
18158
18158
|
throw new Error(`Reference not found: ${ref}`);
|
|
18159
18159
|
}
|
|
@@ -20756,12 +20756,22 @@ var init_acp = __esm({
|
|
|
20756
20756
|
}
|
|
20757
20757
|
});
|
|
20758
20758
|
|
|
20759
|
+
// ../bridge/src/runtime/yield-to-event-loop.ts
|
|
20760
|
+
function yieldToEventLoop() {
|
|
20761
|
+
return new Promise((resolve36) => setImmediate(resolve36));
|
|
20762
|
+
}
|
|
20763
|
+
var init_yield_to_event_loop = __esm({
|
|
20764
|
+
"../bridge/src/runtime/yield-to-event-loop.ts"() {
|
|
20765
|
+
}
|
|
20766
|
+
});
|
|
20767
|
+
|
|
20759
20768
|
// ../bridge/src/files/index/constants.ts
|
|
20760
20769
|
import path3 from "node:path";
|
|
20761
20770
|
import os from "node:os";
|
|
20762
20771
|
var INDEX_WORK_YIELD_EVERY, INDEX_DIR, INDEX_HASH_LEN;
|
|
20763
20772
|
var init_constants = __esm({
|
|
20764
20773
|
"../bridge/src/files/index/constants.ts"() {
|
|
20774
|
+
"use strict";
|
|
20765
20775
|
INDEX_WORK_YIELD_EVERY = 128;
|
|
20766
20776
|
INDEX_DIR = path3.join(os.homedir(), ".buildautomaton");
|
|
20767
20777
|
INDEX_HASH_LEN = 16;
|
|
@@ -21026,15 +21036,6 @@ var init_activity_tracker = __esm({
|
|
|
21026
21036
|
}
|
|
21027
21037
|
});
|
|
21028
21038
|
|
|
21029
|
-
// ../bridge/src/runtime/yield-to-event-loop.ts
|
|
21030
|
-
function yieldToEventLoop() {
|
|
21031
|
-
return new Promise((resolve36) => setImmediate(resolve36));
|
|
21032
|
-
}
|
|
21033
|
-
var init_yield_to_event_loop = __esm({
|
|
21034
|
-
"../bridge/src/runtime/yield-to-event-loop.ts"() {
|
|
21035
|
-
}
|
|
21036
|
-
});
|
|
21037
|
-
|
|
21038
21039
|
// ../bridge/src/code-nav/symbol-index/deferred-indexing.ts
|
|
21039
21040
|
function isSymbolIndexDeferredError(err) {
|
|
21040
21041
|
return err instanceof SymbolIndexDeferredError;
|
|
@@ -21125,7 +21126,6 @@ function isCliSqliteLockError(e) {
|
|
|
21125
21126
|
var CliSqliteInterrupted;
|
|
21126
21127
|
var init_sqlite_errors = __esm({
|
|
21127
21128
|
"../bridge/src/sqlite/sqlite-errors.ts"() {
|
|
21128
|
-
"use strict";
|
|
21129
21129
|
CliSqliteInterrupted = class extends Error {
|
|
21130
21130
|
name = "CliSqliteInterrupted";
|
|
21131
21131
|
constructor() {
|
|
@@ -21748,7 +21748,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
|
|
|
21748
21748
|
join2(moduleDir, "..", sub, filename),
|
|
21749
21749
|
join2(moduleDir, "..", "..", "dist", sub, filename)
|
|
21750
21750
|
]);
|
|
21751
|
-
const resolved = candidates.find((
|
|
21751
|
+
const resolved = candidates.find((path83) => existsSync(path83));
|
|
21752
21752
|
if (!resolved) {
|
|
21753
21753
|
throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
|
|
21754
21754
|
}
|
|
@@ -22065,7 +22065,6 @@ async function ensureCodeNavCacheSqliteInitialized() {
|
|
|
22065
22065
|
var safeCloseCodeNavCacheSqliteDatabase, openCodeNavCacheSqliteConnection;
|
|
22066
22066
|
var init_database = __esm({
|
|
22067
22067
|
"../bridge/src/sqlite/code-nav-cache/database.ts"() {
|
|
22068
|
-
"use strict";
|
|
22069
22068
|
init_code_nav_cache_availability();
|
|
22070
22069
|
init_instance();
|
|
22071
22070
|
init_sqlite_errors();
|
|
@@ -22138,31 +22137,18 @@ var init_cli_sqlite_paths = __esm({
|
|
|
22138
22137
|
}
|
|
22139
22138
|
});
|
|
22140
22139
|
|
|
22141
|
-
// ../bridge/src/prompt-turn-queue/paths.ts
|
|
22142
|
-
import path7 from "node:path";
|
|
22143
|
-
import os4 from "node:os";
|
|
22144
|
-
function getPromptQueuesDirectory() {
|
|
22145
|
-
const override = process.env.BUILDAMATON_PROMPT_QUEUES_DIR?.trim();
|
|
22146
|
-
if (override) return path7.resolve(override);
|
|
22147
|
-
return path7.join(os4.homedir(), ".buildautomaton", "queues");
|
|
22148
|
-
}
|
|
22149
|
-
var init_paths2 = __esm({
|
|
22150
|
-
"../bridge/src/prompt-turn-queue/paths.ts"() {
|
|
22151
|
-
}
|
|
22152
|
-
});
|
|
22153
|
-
|
|
22154
22140
|
// ../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts
|
|
22155
22141
|
import fs7 from "node:fs";
|
|
22156
|
-
import
|
|
22142
|
+
import path7 from "node:path";
|
|
22157
22143
|
function moveLegacyFileToOldVersionBackup(category, sourcePath) {
|
|
22158
|
-
const destDir =
|
|
22144
|
+
const destDir = path7.join(OLD_VERSION_DIR, category);
|
|
22159
22145
|
fs7.mkdirSync(destDir, { recursive: true });
|
|
22160
|
-
const base =
|
|
22161
|
-
let dest =
|
|
22146
|
+
const base = path7.basename(sourcePath);
|
|
22147
|
+
let dest = path7.join(destDir, base);
|
|
22162
22148
|
if (fs7.existsSync(dest)) {
|
|
22163
|
-
const ext =
|
|
22149
|
+
const ext = path7.extname(base);
|
|
22164
22150
|
const stem = ext ? base.slice(0, -ext.length) : base;
|
|
22165
|
-
dest =
|
|
22151
|
+
dest = path7.join(destDir, `${stem}-${Date.now()}${ext}`);
|
|
22166
22152
|
}
|
|
22167
22153
|
fs7.renameSync(sourcePath, dest);
|
|
22168
22154
|
}
|
|
@@ -22171,19 +22157,19 @@ var init_archive_to_old_version = __esm({
|
|
|
22171
22157
|
"../bridge/src/sqlite/legacy_migration/archive-to-old-version.ts"() {
|
|
22172
22158
|
"use strict";
|
|
22173
22159
|
init_constants();
|
|
22174
|
-
OLD_VERSION_DIR =
|
|
22160
|
+
OLD_VERSION_DIR = path7.join(INDEX_DIR, "old-version");
|
|
22175
22161
|
}
|
|
22176
22162
|
});
|
|
22177
22163
|
|
|
22178
22164
|
// ../bridge/src/sqlite/legacy_migration/archive-file-index-json.ts
|
|
22179
22165
|
import fs8 from "node:fs";
|
|
22180
|
-
import
|
|
22166
|
+
import path8 from "node:path";
|
|
22181
22167
|
function archiveLegacyFileIndexJsonFiles() {
|
|
22182
22168
|
try {
|
|
22183
22169
|
if (!fs8.existsSync(INDEX_DIR)) return;
|
|
22184
22170
|
for (const name of fs8.readdirSync(INDEX_DIR)) {
|
|
22185
22171
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) {
|
|
22186
|
-
const full =
|
|
22172
|
+
const full = path8.join(INDEX_DIR, name);
|
|
22187
22173
|
try {
|
|
22188
22174
|
moveLegacyFileToOldVersionBackup("file-index", full);
|
|
22189
22175
|
} catch (err) {
|
|
@@ -22205,15 +22191,15 @@ var init_archive_file_index_json = __esm({
|
|
|
22205
22191
|
|
|
22206
22192
|
// ../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts
|
|
22207
22193
|
import fs9 from "node:fs";
|
|
22208
|
-
import
|
|
22209
|
-
import
|
|
22194
|
+
import path9 from "node:path";
|
|
22195
|
+
import os4 from "node:os";
|
|
22210
22196
|
function importLegacyAgentSessionsFromDisk(db) {
|
|
22211
22197
|
try {
|
|
22212
22198
|
if (!fs9.existsSync(LEGACY_AGENT_SESSION_DIR)) return;
|
|
22213
22199
|
const names = fs9.readdirSync(LEGACY_AGENT_SESSION_DIR).filter((n) => n.endsWith(".json"));
|
|
22214
22200
|
for (const name of names) {
|
|
22215
22201
|
const sessionKey = name.slice(0, -".json".length);
|
|
22216
|
-
const full =
|
|
22202
|
+
const full = path9.join(LEGACY_AGENT_SESSION_DIR, name);
|
|
22217
22203
|
let raw;
|
|
22218
22204
|
try {
|
|
22219
22205
|
raw = fs9.readFileSync(full, "utf8");
|
|
@@ -22250,89 +22236,27 @@ var init_import_agent_sessions_from_disk = __esm({
|
|
|
22250
22236
|
"../bridge/src/sqlite/legacy_migration/import-agent-sessions-from-disk.ts"() {
|
|
22251
22237
|
"use strict";
|
|
22252
22238
|
init_archive_to_old_version();
|
|
22253
|
-
LEGACY_AGENT_SESSION_DIR =
|
|
22254
|
-
}
|
|
22255
|
-
});
|
|
22256
|
-
|
|
22257
|
-
// ../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts
|
|
22258
|
-
function parsePersistedQueueFromJson(raw) {
|
|
22259
|
-
try {
|
|
22260
|
-
const o = JSON.parse(raw);
|
|
22261
|
-
const queueKey = typeof o.queueKey === "string" ? o.queueKey : typeof o.queueKeyHash === "string" ? o.queueKeyHash : null;
|
|
22262
|
-
if (!queueKey || typeof o.updatedAt !== "string" || !Array.isArray(o.turns)) return null;
|
|
22263
|
-
return { queueKey, updatedAt: o.updatedAt, turns: o.turns };
|
|
22264
|
-
} catch {
|
|
22265
|
-
return null;
|
|
22266
|
-
}
|
|
22267
|
-
}
|
|
22268
|
-
var init_parse_persisted_queue_json = __esm({
|
|
22269
|
-
"../bridge/src/sqlite/legacy_migration/parse-persisted-queue-json.ts"() {
|
|
22270
|
-
"use strict";
|
|
22271
|
-
}
|
|
22272
|
-
});
|
|
22273
|
-
|
|
22274
|
-
// ../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts
|
|
22275
|
-
import fs10 from "node:fs";
|
|
22276
|
-
import path11 from "node:path";
|
|
22277
|
-
function importLegacyPromptQueuesFromDisk(db) {
|
|
22278
|
-
try {
|
|
22279
|
-
const dir = getPromptQueuesDirectory();
|
|
22280
|
-
if (!fs10.existsSync(dir)) return;
|
|
22281
|
-
for (const name of fs10.readdirSync(dir)) {
|
|
22282
|
-
if (!name.endsWith(".json")) continue;
|
|
22283
|
-
const full = path11.join(dir, name);
|
|
22284
|
-
let raw;
|
|
22285
|
-
try {
|
|
22286
|
-
raw = fs10.readFileSync(full, "utf8");
|
|
22287
|
-
} catch {
|
|
22288
|
-
continue;
|
|
22289
|
-
}
|
|
22290
|
-
const file2 = parsePersistedQueueFromJson(raw);
|
|
22291
|
-
if (!file2) continue;
|
|
22292
|
-
db.run(
|
|
22293
|
-
`INSERT OR REPLACE INTO prompt_queue (queue_key, updated_at, turns_json) VALUES (?, ?, ?)`,
|
|
22294
|
-
[file2.queueKey, file2.updatedAt, JSON.stringify(file2.turns)]
|
|
22295
|
-
);
|
|
22296
|
-
try {
|
|
22297
|
-
moveLegacyFileToOldVersionBackup("queues", full);
|
|
22298
|
-
} catch {
|
|
22299
|
-
}
|
|
22300
|
-
}
|
|
22301
|
-
} catch (e) {
|
|
22302
|
-
console.error("[cli-sqlite] legacy import: prompt queues from disk failed", e);
|
|
22303
|
-
}
|
|
22304
|
-
}
|
|
22305
|
-
var init_import_prompt_queues_from_disk = __esm({
|
|
22306
|
-
"../bridge/src/sqlite/legacy_migration/import-prompt-queues-from-disk.ts"() {
|
|
22307
|
-
"use strict";
|
|
22308
|
-
init_paths2();
|
|
22309
|
-
init_archive_to_old_version();
|
|
22310
|
-
init_parse_persisted_queue_json();
|
|
22239
|
+
LEGACY_AGENT_SESSION_DIR = path9.join(os4.homedir(), ".buildautomaton", "agent-sessions");
|
|
22311
22240
|
}
|
|
22312
22241
|
});
|
|
22313
22242
|
|
|
22314
22243
|
// ../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts
|
|
22315
|
-
import
|
|
22244
|
+
import fs10 from "node:fs";
|
|
22316
22245
|
function legacyCliDiskMigrationIsPending() {
|
|
22317
22246
|
try {
|
|
22318
|
-
if (
|
|
22319
|
-
for (const name of
|
|
22247
|
+
if (fs10.existsSync(INDEX_DIR)) {
|
|
22248
|
+
for (const name of fs10.readdirSync(INDEX_DIR)) {
|
|
22320
22249
|
if (name.startsWith(".file-index-") && name.endsWith(".json")) return true;
|
|
22321
22250
|
}
|
|
22322
22251
|
}
|
|
22323
22252
|
} catch {
|
|
22324
22253
|
}
|
|
22325
22254
|
try {
|
|
22326
|
-
if (
|
|
22327
|
-
if (
|
|
22255
|
+
if (fs10.existsSync(LEGACY_AGENT_SESSION_DIR)) {
|
|
22256
|
+
if (fs10.readdirSync(LEGACY_AGENT_SESSION_DIR).some((n) => n.endsWith(".json"))) return true;
|
|
22328
22257
|
}
|
|
22329
22258
|
} catch {
|
|
22330
22259
|
}
|
|
22331
|
-
try {
|
|
22332
|
-
const dir = getPromptQueuesDirectory();
|
|
22333
|
-
if (fs11.existsSync(dir) && fs11.readdirSync(dir).some((n) => n.endsWith(".json"))) return true;
|
|
22334
|
-
} catch {
|
|
22335
|
-
}
|
|
22336
22260
|
return false;
|
|
22337
22261
|
}
|
|
22338
22262
|
function importCliSqliteLegacyDiskData(db, log2) {
|
|
@@ -22342,7 +22266,6 @@ function importCliSqliteLegacyDiskData(db, log2) {
|
|
|
22342
22266
|
}
|
|
22343
22267
|
archiveLegacyFileIndexJsonFiles();
|
|
22344
22268
|
importLegacyAgentSessionsFromDisk(db);
|
|
22345
|
-
importLegacyPromptQueuesFromDisk(db);
|
|
22346
22269
|
if (pending2 && log2) {
|
|
22347
22270
|
log2("Legacy on-disk CLI data migration finished.");
|
|
22348
22271
|
}
|
|
@@ -22351,10 +22274,8 @@ var init_import_cli_legacy_disk_data = __esm({
|
|
|
22351
22274
|
"../bridge/src/sqlite/legacy_migration/import-cli-legacy-disk-data.ts"() {
|
|
22352
22275
|
"use strict";
|
|
22353
22276
|
init_constants();
|
|
22354
|
-
init_paths2();
|
|
22355
22277
|
init_archive_file_index_json();
|
|
22356
22278
|
init_import_agent_sessions_from_disk();
|
|
22357
|
-
init_import_prompt_queues_from_disk();
|
|
22358
22279
|
}
|
|
22359
22280
|
});
|
|
22360
22281
|
|
|
@@ -22464,15 +22385,15 @@ var init_cli_database = __esm({
|
|
|
22464
22385
|
});
|
|
22465
22386
|
|
|
22466
22387
|
// ../bridge/src/files/index/walk-workspace-tree.ts
|
|
22467
|
-
import
|
|
22468
|
-
import
|
|
22388
|
+
import fs11 from "node:fs";
|
|
22389
|
+
import path10 from "node:path";
|
|
22469
22390
|
function shouldSkipWorkspaceWalkEntry(name) {
|
|
22470
22391
|
return DEPENDENCY_INSTALL_DIR_NAMES.has(name);
|
|
22471
22392
|
}
|
|
22472
22393
|
async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
22473
22394
|
let names;
|
|
22474
22395
|
try {
|
|
22475
|
-
names = await
|
|
22396
|
+
names = await fs11.promises.readdir(dir);
|
|
22476
22397
|
} catch {
|
|
22477
22398
|
return;
|
|
22478
22399
|
}
|
|
@@ -22487,14 +22408,14 @@ async function walkWorkspaceTreeAsync(dir, baseDir, onFile, state) {
|
|
|
22487
22408
|
await yieldUntilFileBrowserReadsIdle();
|
|
22488
22409
|
}
|
|
22489
22410
|
state.n++;
|
|
22490
|
-
const full =
|
|
22411
|
+
const full = path10.join(dir, name);
|
|
22491
22412
|
let stat2;
|
|
22492
22413
|
try {
|
|
22493
|
-
stat2 = await
|
|
22414
|
+
stat2 = await fs11.promises.stat(full);
|
|
22494
22415
|
} catch {
|
|
22495
22416
|
continue;
|
|
22496
22417
|
}
|
|
22497
|
-
const relative6 =
|
|
22418
|
+
const relative6 = path10.relative(baseDir, full).replace(/\\/g, "/");
|
|
22498
22419
|
if (stat2.isDirectory()) {
|
|
22499
22420
|
await walkWorkspaceTreeAsync(full, baseDir, onFile, state);
|
|
22500
22421
|
} else if (stat2.isFile()) {
|
|
@@ -22823,7 +22744,7 @@ var require_ignore = __commonJS({
|
|
|
22823
22744
|
// path matching.
|
|
22824
22745
|
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
22825
22746
|
// @returns {TestResult} true if a file is ignored
|
|
22826
|
-
test(
|
|
22747
|
+
test(path83, checkUnignored, mode) {
|
|
22827
22748
|
let ignored = false;
|
|
22828
22749
|
let unignored = false;
|
|
22829
22750
|
let matchedRule;
|
|
@@ -22832,7 +22753,7 @@ var require_ignore = __commonJS({
|
|
|
22832
22753
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
22833
22754
|
return;
|
|
22834
22755
|
}
|
|
22835
|
-
const matched = rule[mode].test(
|
|
22756
|
+
const matched = rule[mode].test(path83);
|
|
22836
22757
|
if (!matched) {
|
|
22837
22758
|
return;
|
|
22838
22759
|
}
|
|
@@ -22853,17 +22774,17 @@ var require_ignore = __commonJS({
|
|
|
22853
22774
|
var throwError = (message, Ctor) => {
|
|
22854
22775
|
throw new Ctor(message);
|
|
22855
22776
|
};
|
|
22856
|
-
var checkPath = (
|
|
22857
|
-
if (!isString(
|
|
22777
|
+
var checkPath = (path83, originalPath, doThrow) => {
|
|
22778
|
+
if (!isString(path83)) {
|
|
22858
22779
|
return doThrow(
|
|
22859
22780
|
`path must be a string, but got \`${originalPath}\``,
|
|
22860
22781
|
TypeError
|
|
22861
22782
|
);
|
|
22862
22783
|
}
|
|
22863
|
-
if (!
|
|
22784
|
+
if (!path83) {
|
|
22864
22785
|
return doThrow(`path must not be empty`, TypeError);
|
|
22865
22786
|
}
|
|
22866
|
-
if (checkPath.isNotRelative(
|
|
22787
|
+
if (checkPath.isNotRelative(path83)) {
|
|
22867
22788
|
const r = "`path.relative()`d";
|
|
22868
22789
|
return doThrow(
|
|
22869
22790
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -22872,7 +22793,7 @@ var require_ignore = __commonJS({
|
|
|
22872
22793
|
}
|
|
22873
22794
|
return true;
|
|
22874
22795
|
};
|
|
22875
|
-
var isNotRelative = (
|
|
22796
|
+
var isNotRelative = (path83) => REGEX_TEST_INVALID_PATH.test(path83);
|
|
22876
22797
|
checkPath.isNotRelative = isNotRelative;
|
|
22877
22798
|
checkPath.convert = (p) => p;
|
|
22878
22799
|
var Ignore = class {
|
|
@@ -22902,19 +22823,19 @@ var require_ignore = __commonJS({
|
|
|
22902
22823
|
}
|
|
22903
22824
|
// @returns {TestResult}
|
|
22904
22825
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
22905
|
-
const
|
|
22826
|
+
const path83 = originalPath && checkPath.convert(originalPath);
|
|
22906
22827
|
checkPath(
|
|
22907
|
-
|
|
22828
|
+
path83,
|
|
22908
22829
|
originalPath,
|
|
22909
22830
|
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
22910
22831
|
);
|
|
22911
|
-
return this._t(
|
|
22832
|
+
return this._t(path83, cache2, checkUnignored, slices);
|
|
22912
22833
|
}
|
|
22913
|
-
checkIgnore(
|
|
22914
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
22915
|
-
return this.test(
|
|
22834
|
+
checkIgnore(path83) {
|
|
22835
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path83)) {
|
|
22836
|
+
return this.test(path83);
|
|
22916
22837
|
}
|
|
22917
|
-
const slices =
|
|
22838
|
+
const slices = path83.split(SLASH).filter(Boolean);
|
|
22918
22839
|
slices.pop();
|
|
22919
22840
|
if (slices.length) {
|
|
22920
22841
|
const parent = this._t(
|
|
@@ -22927,18 +22848,18 @@ var require_ignore = __commonJS({
|
|
|
22927
22848
|
return parent;
|
|
22928
22849
|
}
|
|
22929
22850
|
}
|
|
22930
|
-
return this._rules.test(
|
|
22851
|
+
return this._rules.test(path83, false, MODE_CHECK_IGNORE);
|
|
22931
22852
|
}
|
|
22932
|
-
_t(
|
|
22933
|
-
if (
|
|
22934
|
-
return cache2[
|
|
22853
|
+
_t(path83, cache2, checkUnignored, slices) {
|
|
22854
|
+
if (path83 in cache2) {
|
|
22855
|
+
return cache2[path83];
|
|
22935
22856
|
}
|
|
22936
22857
|
if (!slices) {
|
|
22937
|
-
slices =
|
|
22858
|
+
slices = path83.split(SLASH).filter(Boolean);
|
|
22938
22859
|
}
|
|
22939
22860
|
slices.pop();
|
|
22940
22861
|
if (!slices.length) {
|
|
22941
|
-
return cache2[
|
|
22862
|
+
return cache2[path83] = this._rules.test(path83, checkUnignored, MODE_IGNORE);
|
|
22942
22863
|
}
|
|
22943
22864
|
const parent = this._t(
|
|
22944
22865
|
slices.join(SLASH) + SLASH,
|
|
@@ -22946,29 +22867,29 @@ var require_ignore = __commonJS({
|
|
|
22946
22867
|
checkUnignored,
|
|
22947
22868
|
slices
|
|
22948
22869
|
);
|
|
22949
|
-
return cache2[
|
|
22870
|
+
return cache2[path83] = parent.ignored ? parent : this._rules.test(path83, checkUnignored, MODE_IGNORE);
|
|
22950
22871
|
}
|
|
22951
|
-
ignores(
|
|
22952
|
-
return this._test(
|
|
22872
|
+
ignores(path83) {
|
|
22873
|
+
return this._test(path83, this._ignoreCache, false).ignored;
|
|
22953
22874
|
}
|
|
22954
22875
|
createFilter() {
|
|
22955
|
-
return (
|
|
22876
|
+
return (path83) => !this.ignores(path83);
|
|
22956
22877
|
}
|
|
22957
22878
|
filter(paths) {
|
|
22958
22879
|
return makeArray(paths).filter(this.createFilter());
|
|
22959
22880
|
}
|
|
22960
22881
|
// @returns {TestResult}
|
|
22961
|
-
test(
|
|
22962
|
-
return this._test(
|
|
22882
|
+
test(path83) {
|
|
22883
|
+
return this._test(path83, this._testCache, true);
|
|
22963
22884
|
}
|
|
22964
22885
|
};
|
|
22965
22886
|
var factory = (options) => new Ignore(options);
|
|
22966
|
-
var isPathValid = (
|
|
22887
|
+
var isPathValid = (path83) => checkPath(path83 && checkPath.convert(path83), path83, RETURN_FALSE);
|
|
22967
22888
|
var setupWindows = () => {
|
|
22968
22889
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
22969
22890
|
checkPath.convert = makePosix;
|
|
22970
22891
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
22971
|
-
checkPath.isNotRelative = (
|
|
22892
|
+
checkPath.isNotRelative = (path83) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path83) || isNotRelative(path83);
|
|
22972
22893
|
};
|
|
22973
22894
|
if (
|
|
22974
22895
|
// Detect `process` so that it can run in browsers.
|
|
@@ -22984,8 +22905,8 @@ var require_ignore = __commonJS({
|
|
|
22984
22905
|
});
|
|
22985
22906
|
|
|
22986
22907
|
// ../bridge/src/code-nav/gitignore-filter.ts
|
|
22987
|
-
import
|
|
22988
|
-
import
|
|
22908
|
+
import fs12 from "node:fs";
|
|
22909
|
+
import path11 from "node:path";
|
|
22989
22910
|
function normalizeRelPath(relPath) {
|
|
22990
22911
|
return relPath.replace(/\\/g, "/");
|
|
22991
22912
|
}
|
|
@@ -22995,12 +22916,12 @@ function isUnderDir(relPath, dirRel) {
|
|
|
22995
22916
|
async function createGitignoreFilterForRelativePath(root, relPath) {
|
|
22996
22917
|
const filter = new GitignoreFilter();
|
|
22997
22918
|
await filter.enterDirectory(root, "");
|
|
22998
|
-
const dirRel = normalizeRelPath(
|
|
22919
|
+
const dirRel = normalizeRelPath(path11.dirname(relPath));
|
|
22999
22920
|
if (dirRel === "." || dirRel === "") return filter;
|
|
23000
22921
|
let abs = root;
|
|
23001
22922
|
let rel = "";
|
|
23002
22923
|
for (const segment of dirRel.split("/")) {
|
|
23003
|
-
abs =
|
|
22924
|
+
abs = path11.join(abs, segment);
|
|
23004
22925
|
rel = rel ? `${rel}/${segment}` : segment;
|
|
23005
22926
|
await filter.enterDirectory(abs, rel);
|
|
23006
22927
|
}
|
|
@@ -23022,7 +22943,7 @@ var init_gitignore_filter = __esm({
|
|
|
23022
22943
|
/** Load `.gitignore` in `absDir` and push a layer when the file exists. */
|
|
23023
22944
|
async enterDirectory(absDir, dirRel) {
|
|
23024
22945
|
try {
|
|
23025
|
-
const content = await
|
|
22946
|
+
const content = await fs12.promises.readFile(path11.join(absDir, ".gitignore"), "utf8");
|
|
23026
22947
|
this.layers.push({ dirRel, ig: (0, import_ignore.default)().add(content) });
|
|
23027
22948
|
} catch {
|
|
23028
22949
|
}
|
|
@@ -23049,7 +22970,7 @@ var init_gitignore_filter = __esm({
|
|
|
23049
22970
|
});
|
|
23050
22971
|
|
|
23051
22972
|
// ../bridge/src/code-nav/language-registry.ts
|
|
23052
|
-
import
|
|
22973
|
+
import path12 from "node:path";
|
|
23053
22974
|
function languageAssetPaths(key, wasmFile) {
|
|
23054
22975
|
return {
|
|
23055
22976
|
wasmFile,
|
|
@@ -23057,7 +22978,7 @@ function languageAssetPaths(key, wasmFile) {
|
|
|
23057
22978
|
};
|
|
23058
22979
|
}
|
|
23059
22980
|
function getLanguageKeyForFilePath(filePath) {
|
|
23060
|
-
const ext =
|
|
22981
|
+
const ext = path12.extname(filePath).replace(/^\./, "").toLowerCase();
|
|
23061
22982
|
if (!ext) return null;
|
|
23062
22983
|
return EXT_TO_LANGUAGE_KEY[ext] ?? null;
|
|
23063
22984
|
}
|
|
@@ -23107,13 +23028,13 @@ var init_language_registry = __esm({
|
|
|
23107
23028
|
});
|
|
23108
23029
|
|
|
23109
23030
|
// ../bridge/src/code-nav/walk-code-nav-files.ts
|
|
23110
|
-
import
|
|
23111
|
-
import
|
|
23031
|
+
import fs13 from "node:fs";
|
|
23032
|
+
import path13 from "node:path";
|
|
23112
23033
|
async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile, state) {
|
|
23113
23034
|
await filter.enterDirectory(dir, relDir);
|
|
23114
23035
|
let names;
|
|
23115
23036
|
try {
|
|
23116
|
-
names = await
|
|
23037
|
+
names = await fs13.promises.readdir(dir);
|
|
23117
23038
|
} catch {
|
|
23118
23039
|
filter.leaveDirectory(relDir);
|
|
23119
23040
|
return;
|
|
@@ -23130,10 +23051,10 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
23130
23051
|
}
|
|
23131
23052
|
state.n++;
|
|
23132
23053
|
const relPath = relDir ? `${relDir}/${name}` : name;
|
|
23133
|
-
const full =
|
|
23054
|
+
const full = path13.join(dir, name);
|
|
23134
23055
|
let stat2;
|
|
23135
23056
|
try {
|
|
23136
|
-
stat2 = await
|
|
23057
|
+
stat2 = await fs13.promises.stat(full);
|
|
23137
23058
|
} catch {
|
|
23138
23059
|
continue;
|
|
23139
23060
|
}
|
|
@@ -23150,7 +23071,7 @@ async function walkCodeNavFilesInDirectory(dir, baseDir, relDir, filter, onFile,
|
|
|
23150
23071
|
filter.leaveDirectory(relDir);
|
|
23151
23072
|
}
|
|
23152
23073
|
async function walkCodeNavFilesAsync(rootDir, onFile, state = createWalkYieldState()) {
|
|
23153
|
-
const resolved =
|
|
23074
|
+
const resolved = path13.resolve(rootDir);
|
|
23154
23075
|
const filter = new GitignoreFilter();
|
|
23155
23076
|
await walkCodeNavFilesInDirectory(resolved, resolved, "", filter, onFile, state);
|
|
23156
23077
|
}
|
|
@@ -23913,7 +23834,7 @@ var init_persist_single_file = __esm({
|
|
|
23913
23834
|
});
|
|
23914
23835
|
|
|
23915
23836
|
// ../bridge/src/code-nav/resolve-module-import-path.ts
|
|
23916
|
-
import
|
|
23837
|
+
import path14 from "node:path";
|
|
23917
23838
|
function normalizeWorkspacePath(filePath) {
|
|
23918
23839
|
return filePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
23919
23840
|
}
|
|
@@ -23953,28 +23874,28 @@ function tsJsImportCandidates(joined) {
|
|
|
23953
23874
|
function resolveModuleImportPath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
23954
23875
|
const spec = moduleSpecifier.trim();
|
|
23955
23876
|
if (!spec || !isRelativeModuleSpecifier(spec)) return null;
|
|
23956
|
-
const importerDir =
|
|
23957
|
-
const joined = normalizeWorkspacePath(
|
|
23877
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23878
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
23958
23879
|
return firstExistingPath(tsJsImportCandidates(joined), workspaceFiles);
|
|
23959
23880
|
}
|
|
23960
23881
|
function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFiles) {
|
|
23961
23882
|
const moduleName = moduleSpecifier.trim().replace(/\s+/g, "");
|
|
23962
23883
|
if (!moduleName) return null;
|
|
23963
|
-
const importerDir =
|
|
23884
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23964
23885
|
if (moduleName.startsWith(".")) {
|
|
23965
23886
|
const dotMatch = /^(\.+)(.*)$/.exec(moduleName);
|
|
23966
23887
|
const dotCount = dotMatch?.[1]?.length ?? 1;
|
|
23967
23888
|
const rest = (dotMatch?.[2] ?? "").replace(/^\./, "");
|
|
23968
23889
|
let baseDir = importerDir;
|
|
23969
23890
|
for (let i = 1; i < dotCount; i++) {
|
|
23970
|
-
baseDir =
|
|
23891
|
+
baseDir = path14.posix.dirname(baseDir);
|
|
23971
23892
|
}
|
|
23972
23893
|
const dottedPath2 = rest ? rest.split(".").join("/") : "";
|
|
23973
|
-
const relativeBase = dottedPath2 ?
|
|
23894
|
+
const relativeBase = dottedPath2 ? path14.posix.join(baseDir, dottedPath2) : baseDir;
|
|
23974
23895
|
return firstExistingPath(
|
|
23975
23896
|
[
|
|
23976
23897
|
...withSuffixes(relativeBase, PYTHON_EXTENSIONS),
|
|
23977
|
-
...withSuffixes(
|
|
23898
|
+
...withSuffixes(path14.posix.join(relativeBase, "__init__"), [".py"])
|
|
23978
23899
|
],
|
|
23979
23900
|
workspaceFiles
|
|
23980
23901
|
);
|
|
@@ -23983,7 +23904,7 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
23983
23904
|
return firstExistingPath(
|
|
23984
23905
|
[
|
|
23985
23906
|
...withSuffixes(dottedPath, PYTHON_EXTENSIONS),
|
|
23986
|
-
...withSuffixes(
|
|
23907
|
+
...withSuffixes(path14.posix.join(importerDir, dottedPath), PYTHON_EXTENSIONS)
|
|
23987
23908
|
],
|
|
23988
23909
|
workspaceFiles
|
|
23989
23910
|
);
|
|
@@ -23991,9 +23912,9 @@ function resolvePythonModulePath(importerFilePath, moduleSpecifier, workspaceFil
|
|
|
23991
23912
|
function resolveIncludePath(importerFilePath, includePath, workspaceFiles) {
|
|
23992
23913
|
const spec = includePath.trim().replace(/^["']|["']$/g, "");
|
|
23993
23914
|
if (!spec) return null;
|
|
23994
|
-
const importerDir =
|
|
23915
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23995
23916
|
const joined = normalizeWorkspacePath(
|
|
23996
|
-
|
|
23917
|
+
path14.posix.normalize(path14.posix.join(importerDir, spec.replace(/\\/g, "/")))
|
|
23997
23918
|
);
|
|
23998
23919
|
if (workspaceFiles.has(joined)) return joined;
|
|
23999
23920
|
return firstExistingPath(withSuffixes(joined, C_CPP_EXTENSIONS), workspaceFiles);
|
|
@@ -24012,8 +23933,8 @@ function resolveGoImportPath(importerFilePath, moduleSpecifier, workspaceFiles)
|
|
|
24012
23933
|
const spec = moduleSpecifier.trim();
|
|
24013
23934
|
if (!spec) return null;
|
|
24014
23935
|
if (isRelativeModuleSpecifier(spec)) {
|
|
24015
|
-
const importerDir =
|
|
24016
|
-
const joined = normalizeWorkspacePath(
|
|
23936
|
+
const importerDir = path14.posix.dirname(normalizeWorkspacePath(importerFilePath));
|
|
23937
|
+
const joined = normalizeWorkspacePath(path14.posix.normalize(path14.posix.join(importerDir, spec)));
|
|
24017
23938
|
if (workspaceFiles.has(joined)) return joined;
|
|
24018
23939
|
return firstExistingPath(withSuffixes(joined, [".go"]), workspaceFiles);
|
|
24019
23940
|
}
|
|
@@ -25441,12 +25362,12 @@ var init_workspace_files = __esm({
|
|
|
25441
25362
|
});
|
|
25442
25363
|
|
|
25443
25364
|
// ../bridge/src/code-nav/symbol-index/build/extract-file-symbol-data.ts
|
|
25444
|
-
import
|
|
25445
|
-
import
|
|
25365
|
+
import fs14 from "node:fs";
|
|
25366
|
+
import path15 from "node:path";
|
|
25446
25367
|
import { isMainThread as isMainThread3 } from "node:worker_threads";
|
|
25447
25368
|
async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride) {
|
|
25448
25369
|
await yieldForBridgeInteractivePriority();
|
|
25449
|
-
const absPath =
|
|
25370
|
+
const absPath = path15.join(resolved, relPath);
|
|
25450
25371
|
let tags = [];
|
|
25451
25372
|
let source = null;
|
|
25452
25373
|
if (isCodeNavSupportedPath(relPath) && !await isPathGitIgnored(resolved, relPath)) {
|
|
@@ -25454,16 +25375,16 @@ async function extractFileSymbolData(resolved, relPath, workspaceFilesOverride)
|
|
|
25454
25375
|
assertBackgroundIndexingAllowed();
|
|
25455
25376
|
let fileSource = null;
|
|
25456
25377
|
if (isMainThread3) {
|
|
25457
|
-
const stat2 = await
|
|
25378
|
+
const stat2 = await fs14.promises.stat(absPath);
|
|
25458
25379
|
if (stat2.isFile() && stat2.size <= MAX_INDEX_FILE_BYTES) {
|
|
25459
25380
|
assertBackgroundIndexingAllowed();
|
|
25460
|
-
fileSource = await
|
|
25381
|
+
fileSource = await fs14.promises.readFile(absPath, "utf8");
|
|
25461
25382
|
}
|
|
25462
25383
|
} else {
|
|
25463
|
-
const stat2 =
|
|
25384
|
+
const stat2 = fs14.statSync(absPath);
|
|
25464
25385
|
if (stat2.isFile() && stat2.size <= MAX_INDEX_FILE_BYTES) {
|
|
25465
25386
|
assertBackgroundIndexingAllowed();
|
|
25466
|
-
fileSource =
|
|
25387
|
+
fileSource = fs14.readFileSync(absPath, "utf8");
|
|
25467
25388
|
}
|
|
25468
25389
|
}
|
|
25469
25390
|
source = fileSource;
|
|
@@ -25665,12 +25586,12 @@ var init_ensure_symbol_index_file_host = __esm({
|
|
|
25665
25586
|
});
|
|
25666
25587
|
|
|
25667
25588
|
// ../bridge/src/code-nav/symbol-index/lifecycle/normalize-symbol-index-path.ts
|
|
25668
|
-
import
|
|
25589
|
+
import path16 from "node:path";
|
|
25669
25590
|
function normalizeSymbolIndexRelPath2(parentPath, changedPath) {
|
|
25670
|
-
const resolvedParent =
|
|
25671
|
-
const abs =
|
|
25672
|
-
const rel =
|
|
25673
|
-
if (rel.startsWith("..") ||
|
|
25591
|
+
const resolvedParent = path16.resolve(parentPath);
|
|
25592
|
+
const abs = path16.isAbsolute(changedPath) ? path16.resolve(changedPath) : path16.resolve(resolvedParent, changedPath);
|
|
25593
|
+
const rel = path16.relative(resolvedParent, abs).replace(/\\/g, "/");
|
|
25594
|
+
if (rel.startsWith("..") || path16.isAbsolute(rel)) return null;
|
|
25674
25595
|
return rel;
|
|
25675
25596
|
}
|
|
25676
25597
|
var init_normalize_symbol_index_path = __esm({
|
|
@@ -27051,7 +26972,7 @@ var require_has_flag = __commonJS({
|
|
|
27051
26972
|
var require_supports_color = __commonJS({
|
|
27052
26973
|
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
27053
26974
|
"use strict";
|
|
27054
|
-
var
|
|
26975
|
+
var os10 = __require("os");
|
|
27055
26976
|
var tty = __require("tty");
|
|
27056
26977
|
var hasFlag = require_has_flag();
|
|
27057
26978
|
var { env } = process;
|
|
@@ -27099,7 +27020,7 @@ var require_supports_color = __commonJS({
|
|
|
27099
27020
|
return min;
|
|
27100
27021
|
}
|
|
27101
27022
|
if (process.platform === "win32") {
|
|
27102
|
-
const osRelease =
|
|
27023
|
+
const osRelease = os10.release().split(".");
|
|
27103
27024
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
27104
27025
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
27105
27026
|
}
|
|
@@ -27345,10 +27266,10 @@ var require_src2 = __commonJS({
|
|
|
27345
27266
|
var fs_1 = __require("fs");
|
|
27346
27267
|
var debug_1 = __importDefault(require_src());
|
|
27347
27268
|
var log2 = debug_1.default("@kwsites/file-exists");
|
|
27348
|
-
function check2(
|
|
27349
|
-
log2(`checking %s`,
|
|
27269
|
+
function check2(path83, isFile, isDirectory) {
|
|
27270
|
+
log2(`checking %s`, path83);
|
|
27350
27271
|
try {
|
|
27351
|
-
const stat2 = fs_1.statSync(
|
|
27272
|
+
const stat2 = fs_1.statSync(path83);
|
|
27352
27273
|
if (stat2.isFile() && isFile) {
|
|
27353
27274
|
log2(`[OK] path represents a file`);
|
|
27354
27275
|
return true;
|
|
@@ -27368,8 +27289,8 @@ var require_src2 = __commonJS({
|
|
|
27368
27289
|
throw e;
|
|
27369
27290
|
}
|
|
27370
27291
|
}
|
|
27371
|
-
function exists2(
|
|
27372
|
-
return check2(
|
|
27292
|
+
function exists2(path83, type = exports.READABLE) {
|
|
27293
|
+
return check2(path83, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
27373
27294
|
}
|
|
27374
27295
|
exports.exists = exists2;
|
|
27375
27296
|
exports.FILE = 1;
|
|
@@ -27443,6 +27364,12 @@ var wrapper_default = import_websocket.default;
|
|
|
27443
27364
|
// ../bridge/src/connection/ws/cli-ws-client.ts
|
|
27444
27365
|
import https from "node:https";
|
|
27445
27366
|
var CLI_WEBSOCKET_CLIENT_PING_MS = 25e3;
|
|
27367
|
+
var CLI_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 15e3;
|
|
27368
|
+
var sharedWssAgent = null;
|
|
27369
|
+
function cliWssAgent() {
|
|
27370
|
+
sharedWssAgent ??= new https.Agent({ rejectUnauthorized: false, keepAlive: true });
|
|
27371
|
+
return sharedWssAgent;
|
|
27372
|
+
}
|
|
27446
27373
|
function attachWebSocketClientPing(ws, intervalMs) {
|
|
27447
27374
|
let timer = null;
|
|
27448
27375
|
function clear() {
|
|
@@ -27463,9 +27390,12 @@ function attachWebSocketClientPing(ws, intervalMs) {
|
|
|
27463
27390
|
return clear;
|
|
27464
27391
|
}
|
|
27465
27392
|
function buildCliWebSocketClientOptions(wsUrl) {
|
|
27466
|
-
const wsOptions = {
|
|
27393
|
+
const wsOptions = {
|
|
27394
|
+
perMessageDeflate: false,
|
|
27395
|
+
handshakeTimeout: CLI_WEBSOCKET_HANDSHAKE_TIMEOUT_MS
|
|
27396
|
+
};
|
|
27467
27397
|
if (wsUrl.startsWith("wss://")) {
|
|
27468
|
-
wsOptions.agent =
|
|
27398
|
+
wsOptions.agent = cliWssAgent();
|
|
27469
27399
|
}
|
|
27470
27400
|
return wsOptions;
|
|
27471
27401
|
}
|
|
@@ -27479,6 +27409,15 @@ function safeCloseWebSocket(ws) {
|
|
|
27479
27409
|
ws.removeAllListeners();
|
|
27480
27410
|
return;
|
|
27481
27411
|
}
|
|
27412
|
+
if (ws.readyState === wrapper_default.CONNECTING) {
|
|
27413
|
+
ws.once("error", () => {
|
|
27414
|
+
});
|
|
27415
|
+
ws.once("close", () => {
|
|
27416
|
+
ws.removeAllListeners();
|
|
27417
|
+
});
|
|
27418
|
+
ws.terminate();
|
|
27419
|
+
return;
|
|
27420
|
+
}
|
|
27482
27421
|
ws.once("close", () => {
|
|
27483
27422
|
ws.removeAllListeners();
|
|
27484
27423
|
});
|
|
@@ -28435,8 +28374,8 @@ function getErrorMap() {
|
|
|
28435
28374
|
|
|
28436
28375
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
28437
28376
|
var makeIssue = (params) => {
|
|
28438
|
-
const { data, path:
|
|
28439
|
-
const fullPath = [...
|
|
28377
|
+
const { data, path: path83, errorMaps, issueData } = params;
|
|
28378
|
+
const fullPath = [...path83, ...issueData.path || []];
|
|
28440
28379
|
const fullIssue = {
|
|
28441
28380
|
...issueData,
|
|
28442
28381
|
path: fullPath
|
|
@@ -28552,11 +28491,11 @@ var errorUtil;
|
|
|
28552
28491
|
|
|
28553
28492
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
28554
28493
|
var ParseInputLazyPath = class {
|
|
28555
|
-
constructor(parent, value,
|
|
28494
|
+
constructor(parent, value, path83, key) {
|
|
28556
28495
|
this._cachedPath = [];
|
|
28557
28496
|
this.parent = parent;
|
|
28558
28497
|
this.data = value;
|
|
28559
|
-
this._path =
|
|
28498
|
+
this._path = path83;
|
|
28560
28499
|
this._key = key;
|
|
28561
28500
|
}
|
|
28562
28501
|
get path() {
|
|
@@ -32466,83 +32405,8 @@ function isUserEndedSessionTurnErrorText(errorText) {
|
|
|
32466
32405
|
}
|
|
32467
32406
|
|
|
32468
32407
|
// ../types/src/session-kind.ts
|
|
32469
|
-
var SESSION_KINDS = ["regular", "
|
|
32408
|
+
var SESSION_KINDS = ["regular", "planned"];
|
|
32470
32409
|
var SESSION_KIND_SET = new Set(SESSION_KINDS);
|
|
32471
|
-
function parseSessionKind(raw) {
|
|
32472
|
-
if (raw === "todo") return "planned";
|
|
32473
|
-
if (typeof raw === "string" && SESSION_KIND_SET.has(raw)) return raw;
|
|
32474
|
-
return "regular";
|
|
32475
|
-
}
|
|
32476
|
-
|
|
32477
|
-
// ../types/src/planning-todo.ts
|
|
32478
|
-
function planningTodoTitle(item) {
|
|
32479
|
-
return item.content.title;
|
|
32480
|
-
}
|
|
32481
|
-
|
|
32482
|
-
// ../types/src/parse-planning-todo-agent-json.ts
|
|
32483
|
-
function parsePlanningTodoAgentJson(raw) {
|
|
32484
|
-
if (raw == null || raw.trim() === "") return [];
|
|
32485
|
-
let text = raw.trim();
|
|
32486
|
-
const fence = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
32487
|
-
if (fence?.[1]) text = fence[1].trim();
|
|
32488
|
-
let parsed;
|
|
32489
|
-
try {
|
|
32490
|
-
parsed = JSON.parse(text);
|
|
32491
|
-
} catch {
|
|
32492
|
-
const start = text.indexOf("[");
|
|
32493
|
-
const end = text.lastIndexOf("]");
|
|
32494
|
-
if (start < 0 || end <= start) return [];
|
|
32495
|
-
try {
|
|
32496
|
-
parsed = JSON.parse(text.slice(start, end + 1));
|
|
32497
|
-
} catch {
|
|
32498
|
-
return [];
|
|
32499
|
-
}
|
|
32500
|
-
}
|
|
32501
|
-
if (!Array.isArray(parsed)) return [];
|
|
32502
|
-
const rows = [];
|
|
32503
|
-
for (const item of parsed) {
|
|
32504
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
32505
|
-
const o = item;
|
|
32506
|
-
const title = typeof o.title === "string" ? o.title.trim() : "";
|
|
32507
|
-
const prompt = typeof o.prompt === "string" ? o.prompt.trim() : typeof o.promptText === "string" ? o.promptText.trim() : "";
|
|
32508
|
-
if (!title || !prompt) continue;
|
|
32509
|
-
rows.push({ title, prompt });
|
|
32510
|
-
}
|
|
32511
|
-
return rows;
|
|
32512
|
-
}
|
|
32513
|
-
|
|
32514
|
-
// ../types/src/build-planning-session-agent-prompt.ts
|
|
32515
|
-
var PLANNING_INSTRUCTIONS = [
|
|
32516
|
-
"PLANNING MODE: You must NOT make any changes to the codebase, filesystem, or environment.",
|
|
32517
|
-
"Do not run tools that modify files or execute commands that change state.",
|
|
32518
|
-
"Your only task is to analyze and produce a plan.",
|
|
32519
|
-
"",
|
|
32520
|
-
"Respond with ONLY a single JSON array \u2014 no markdown fences, no other text before or after.",
|
|
32521
|
-
"Each array element must be an object with exactly:",
|
|
32522
|
-
'- "title": a one-line summary of the task',
|
|
32523
|
-
'- "prompt": the full prompt to use when creating a new draft session from this todo',
|
|
32524
|
-
"",
|
|
32525
|
-
"Example:",
|
|
32526
|
-
'[{"title":"Add user login","prompt":"Implement a login form with email and password..."}]'
|
|
32527
|
-
].join("\n");
|
|
32528
|
-
function buildPlanningSessionAgentPrompt(userPrompt) {
|
|
32529
|
-
return [PLANNING_INSTRUCTIONS, "", "User request:", userPrompt.trim()].join("\n");
|
|
32530
|
-
}
|
|
32531
|
-
function buildPlanningSessionFollowUpAgentPrompt(userPrompt, existingTodos) {
|
|
32532
|
-
const todoLines = existingTodos.length > 0 ? existingTodos.map((t) => {
|
|
32533
|
-
const status = t.plannedSessionId ? "DONE (draft session already created)" : "OPEN";
|
|
32534
|
-
return `- [${status}] ${planningTodoTitle(t)}`;
|
|
32535
|
-
}).join("\n") : "(none yet)";
|
|
32536
|
-
return [
|
|
32537
|
-
PLANNING_INSTRUCTIONS,
|
|
32538
|
-
"",
|
|
32539
|
-
"Existing todo items from this planning session (consider these when responding; do not duplicate completed items):",
|
|
32540
|
-
todoLines,
|
|
32541
|
-
"",
|
|
32542
|
-
"User follow-up:",
|
|
32543
|
-
userPrompt.trim()
|
|
32544
|
-
].join("\n");
|
|
32545
|
-
}
|
|
32546
32410
|
|
|
32547
32411
|
// ../types/src/diff/line-diff.ts
|
|
32548
32412
|
function normalizeDiffLineText(line) {
|
|
@@ -32783,19 +32647,6 @@ function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
|
32783
32647
|
};
|
|
32784
32648
|
}
|
|
32785
32649
|
|
|
32786
|
-
// ../types/src/acp-agent-text-stream-bucket.ts
|
|
32787
|
-
function resolveAgentTextStreamBucket(params) {
|
|
32788
|
-
const k = params.transcriptRowKind;
|
|
32789
|
-
const su = params.sessionUpdate;
|
|
32790
|
-
if (k === "agent_thought_chunk" || su === "agent_thought_chunk" || k === "thinking" || su === "thinking") {
|
|
32791
|
-
return "thought";
|
|
32792
|
-
}
|
|
32793
|
-
if (k === "agent_message_chunk" || su === "agent_message_chunk" || k === "update" || su === "update") {
|
|
32794
|
-
return "message";
|
|
32795
|
-
}
|
|
32796
|
-
return null;
|
|
32797
|
-
}
|
|
32798
|
-
|
|
32799
32650
|
// ../types/src/agent-config.ts
|
|
32800
32651
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
32801
32652
|
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
@@ -33501,7 +33352,25 @@ function spawnSdkStdioProcess(options) {
|
|
|
33501
33352
|
return { child, stderrCapture };
|
|
33502
33353
|
}
|
|
33503
33354
|
|
|
33355
|
+
// ../bridge/src/agents/acp/clients/listen-for-acp-client-abort.ts
|
|
33356
|
+
function listenForAcpClientAbort(child, signal, onAbort) {
|
|
33357
|
+
if (!signal) return () => {
|
|
33358
|
+
};
|
|
33359
|
+
const fire = () => {
|
|
33360
|
+
killChildProcessTree(child, "SIGKILL");
|
|
33361
|
+
onAbort();
|
|
33362
|
+
};
|
|
33363
|
+
if (signal.aborted) {
|
|
33364
|
+
fire();
|
|
33365
|
+
return () => {
|
|
33366
|
+
};
|
|
33367
|
+
}
|
|
33368
|
+
signal.addEventListener("abort", fire, { once: true });
|
|
33369
|
+
return () => signal.removeEventListener("abort", fire);
|
|
33370
|
+
}
|
|
33371
|
+
|
|
33504
33372
|
// ../bridge/src/agents/acp/clients/sdk/sdk-stdio-acp-client.ts
|
|
33373
|
+
init_yield_to_event_loop();
|
|
33505
33374
|
async function createSdkStdioAcpClient(options) {
|
|
33506
33375
|
const { PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
33507
33376
|
const {
|
|
@@ -33519,13 +33388,18 @@ async function createSdkStdioAcpClient(options) {
|
|
|
33519
33388
|
onAcpConfigOptionsUpdated,
|
|
33520
33389
|
getActiveConfigOptions,
|
|
33521
33390
|
afterSessionEstablished,
|
|
33522
|
-
createExtNotificationHandler
|
|
33391
|
+
createExtNotificationHandler,
|
|
33392
|
+
signal
|
|
33523
33393
|
} = options;
|
|
33394
|
+
if (signal?.aborted) {
|
|
33395
|
+
throw new Error("ACP client aborted");
|
|
33396
|
+
}
|
|
33524
33397
|
const { child, stderrCapture } = spawnSdkStdioProcess({
|
|
33525
33398
|
command,
|
|
33526
33399
|
cwd,
|
|
33527
33400
|
onAgentSubprocessExit
|
|
33528
33401
|
});
|
|
33402
|
+
await yieldToEventLoop();
|
|
33529
33403
|
const sessionCtx = createSdkStdioSessionContext({
|
|
33530
33404
|
cwd,
|
|
33531
33405
|
mcpServers: options.mcpServers,
|
|
@@ -33541,7 +33415,11 @@ async function createSdkStdioAcpClient(options) {
|
|
|
33541
33415
|
});
|
|
33542
33416
|
return new Promise((resolve36, reject) => {
|
|
33543
33417
|
const init = createSdkStdioInitSettle(child);
|
|
33418
|
+
const stopAbort = listenForAcpClientAbort(child, signal, () => {
|
|
33419
|
+
init.settleReject(reject, new Error("ACP client aborted"));
|
|
33420
|
+
});
|
|
33544
33421
|
child.on("error", (err) => {
|
|
33422
|
+
stopAbort();
|
|
33545
33423
|
init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
|
|
33546
33424
|
});
|
|
33547
33425
|
attachSdkStdioStderrAuthWatch({
|
|
@@ -33575,7 +33453,9 @@ async function createSdkStdioAcpClient(options) {
|
|
|
33575
33453
|
killSubprocessAfterCancelMs
|
|
33576
33454
|
})
|
|
33577
33455
|
);
|
|
33456
|
+
stopAbort();
|
|
33578
33457
|
} catch (err) {
|
|
33458
|
+
stopAbort();
|
|
33579
33459
|
if (init.settled) return;
|
|
33580
33460
|
init.settleReject(
|
|
33581
33461
|
reject,
|
|
@@ -33847,22 +33727,12 @@ function installBridgeProcessResilience() {
|
|
|
33847
33727
|
init_log();
|
|
33848
33728
|
|
|
33849
33729
|
// ../bridge/src/agents/acp/clients/bridge-agent-path.ts
|
|
33850
|
-
import { execFileSync } from "node:child_process";
|
|
33851
33730
|
import { homedir } from "node:os";
|
|
33852
33731
|
import { join } from "node:path";
|
|
33853
33732
|
function getBridgeAgentPathEntries(home = process.env.HOME ?? homedir()) {
|
|
33854
|
-
const entries = [
|
|
33855
|
-
join(home, ".local", "bin"),
|
|
33856
|
-
join(home, ".npm-global", "bin"),
|
|
33857
|
-
"/usr/local/bin"
|
|
33858
|
-
];
|
|
33733
|
+
const entries = [join(home, ".local", "bin"), join(home, ".npm-global", "bin"), "/usr/local/bin"];
|
|
33859
33734
|
const prefix = process.env.NPM_CONFIG_PREFIX;
|
|
33860
33735
|
if (prefix) entries.push(join(prefix, "bin"));
|
|
33861
|
-
try {
|
|
33862
|
-
const npmBin = execFileSync("npm", ["bin", "-g"], { encoding: "utf8", timeout: 2e3 }).trim();
|
|
33863
|
-
if (npmBin) entries.push(npmBin);
|
|
33864
|
-
} catch {
|
|
33865
|
-
}
|
|
33866
33736
|
return entries;
|
|
33867
33737
|
}
|
|
33868
33738
|
function augmentPath(pathValue, extra) {
|
|
@@ -33887,7 +33757,7 @@ function bridgeAgentPathEnv(base = process.env) {
|
|
|
33887
33757
|
}
|
|
33888
33758
|
|
|
33889
33759
|
// ../bridge/src/files/watch-file-index.ts
|
|
33890
|
-
import
|
|
33760
|
+
import path21 from "node:path";
|
|
33891
33761
|
|
|
33892
33762
|
// ../bridge/src/files/index/index.ts
|
|
33893
33763
|
init_paths();
|
|
@@ -33896,7 +33766,7 @@ init_paths();
|
|
|
33896
33766
|
init_in_flight();
|
|
33897
33767
|
init_cli_process_interrupt();
|
|
33898
33768
|
init_database();
|
|
33899
|
-
import
|
|
33769
|
+
import path17 from "node:path";
|
|
33900
33770
|
|
|
33901
33771
|
// ../bridge/src/files/index/file-index-sqlite-lock.ts
|
|
33902
33772
|
var fileIndexChain = Promise.resolve();
|
|
@@ -34003,7 +33873,7 @@ function assertNotShutdown2() {
|
|
|
34003
33873
|
if (isCliImmediateShutdownRequested()) throw new CliSqliteInterrupted();
|
|
34004
33874
|
}
|
|
34005
33875
|
async function buildFileIndexAsync(cwd) {
|
|
34006
|
-
const resolved =
|
|
33876
|
+
const resolved = path17.resolve(cwd);
|
|
34007
33877
|
await yieldForBridgeInteractivePriority();
|
|
34008
33878
|
assertNotShutdown2();
|
|
34009
33879
|
const paths = await collectWorkspacePathsAsync(resolved);
|
|
@@ -34016,7 +33886,7 @@ async function buildFileIndexAsync(cwd) {
|
|
|
34016
33886
|
}
|
|
34017
33887
|
|
|
34018
33888
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
34019
|
-
import
|
|
33889
|
+
import path18 from "node:path";
|
|
34020
33890
|
|
|
34021
33891
|
// ../bridge/src/files/index/search-file-index.ts
|
|
34022
33892
|
init_yield_to_event_loop();
|
|
@@ -34071,7 +33941,7 @@ async function searchBridgeFilePathsAsync(resolvedCwd, query, limit = 100) {
|
|
|
34071
33941
|
|
|
34072
33942
|
// ../bridge/src/files/index/ensure-file-index.ts
|
|
34073
33943
|
async function ensureFileIndexAsync(cwd) {
|
|
34074
|
-
const resolved =
|
|
33944
|
+
const resolved = path18.resolve(cwd);
|
|
34075
33945
|
if (await bridgeFileIndexIsPopulated(resolved)) {
|
|
34076
33946
|
return { fromCache: true, pathCount: await bridgeFileIndexPathCount(resolved) };
|
|
34077
33947
|
}
|
|
@@ -34823,16 +34693,16 @@ init_database();
|
|
|
34823
34693
|
init_cli_process_interrupt();
|
|
34824
34694
|
|
|
34825
34695
|
// ../bridge/src/files/index/file-index-incremental-symbol-updates.ts
|
|
34826
|
-
import
|
|
34827
|
-
import
|
|
34696
|
+
import fs15 from "node:fs";
|
|
34697
|
+
import path19 from "node:path";
|
|
34828
34698
|
init_cli_process_interrupt();
|
|
34829
34699
|
init_yield_to_event_loop();
|
|
34830
34700
|
init_database();
|
|
34831
34701
|
async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
|
|
34832
34702
|
for (const rel of relPaths) {
|
|
34833
|
-
const absPath =
|
|
34703
|
+
const absPath = path19.join(resolved, rel);
|
|
34834
34704
|
try {
|
|
34835
|
-
const stat2 = await
|
|
34705
|
+
const stat2 = await fs15.promises.stat(absPath);
|
|
34836
34706
|
if (stat2.isFile()) {
|
|
34837
34707
|
await updateSymbolIndexForFile(resolved, absPath);
|
|
34838
34708
|
} else {
|
|
@@ -34946,11 +34816,11 @@ function createFileIndexFsWatcher(resolved, schedule) {
|
|
|
34946
34816
|
}
|
|
34947
34817
|
|
|
34948
34818
|
// ../bridge/src/files/index/file-index-initial-builds.ts
|
|
34949
|
-
import
|
|
34819
|
+
import path20 from "node:path";
|
|
34950
34820
|
init_database();
|
|
34951
34821
|
init_code_nav_cache_availability();
|
|
34952
34822
|
async function runInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
34953
|
-
const resolved =
|
|
34823
|
+
const resolved = path20.resolve(cwd);
|
|
34954
34824
|
try {
|
|
34955
34825
|
if (!await startCodeNavCacheInitialization()) return;
|
|
34956
34826
|
await buildFileIndexAsync(resolved);
|
|
@@ -34969,7 +34839,7 @@ function scheduleInitialIndexBuilds(cwd = getBridgeRoot()) {
|
|
|
34969
34839
|
|
|
34970
34840
|
// ../bridge/src/files/watch-file-index.ts
|
|
34971
34841
|
function startFileIndexWatcher(cwd = getBridgeRoot()) {
|
|
34972
|
-
const resolved =
|
|
34842
|
+
const resolved = path21.resolve(cwd);
|
|
34973
34843
|
const rebuildState = createFileIndexWatchRebuildState();
|
|
34974
34844
|
let timer = null;
|
|
34975
34845
|
const schedule = (relPath) => {
|
|
@@ -35104,6 +34974,22 @@ function beginDeferredDisconnectForReconnect(options) {
|
|
|
35104
34974
|
}
|
|
35105
34975
|
}
|
|
35106
34976
|
|
|
34977
|
+
// ../bridge/src/connection/ws/dispose-previous-bridge-socket.ts
|
|
34978
|
+
function disposePreviousBridgeSocket(ws) {
|
|
34979
|
+
if (!ws) return;
|
|
34980
|
+
ws.removeAllListeners();
|
|
34981
|
+
ws.once("error", () => {
|
|
34982
|
+
});
|
|
34983
|
+
ws.once("close", () => {
|
|
34984
|
+
ws.removeAllListeners();
|
|
34985
|
+
});
|
|
34986
|
+
try {
|
|
34987
|
+
if (ws.readyState === wrapper_default.CONNECTING) ws.terminate();
|
|
34988
|
+
else ws.close();
|
|
34989
|
+
} catch {
|
|
34990
|
+
}
|
|
34991
|
+
}
|
|
34992
|
+
|
|
35107
34993
|
// ../bridge/src/connection/runtime/close-bridge-connection.ts
|
|
35108
34994
|
async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
|
|
35109
34995
|
requestCliImmediateShutdown();
|
|
@@ -35120,16 +35006,7 @@ async function closeBridgeConnection(state, acpManager, previewEnvironmentManage
|
|
|
35120
35006
|
await acpManager.disconnect();
|
|
35121
35007
|
if (state.currentWs) {
|
|
35122
35008
|
say("Closing bridge connection to the cloud\u2026");
|
|
35123
|
-
state.currentWs
|
|
35124
|
-
const wsState = state.currentWs.readyState;
|
|
35125
|
-
if (wsState === 1 || wsState === 2) {
|
|
35126
|
-
state.currentWs.close();
|
|
35127
|
-
} else {
|
|
35128
|
-
state.currentWs.on("error", () => {
|
|
35129
|
-
});
|
|
35130
|
-
state.currentWs.on("close", () => {
|
|
35131
|
-
});
|
|
35132
|
-
}
|
|
35009
|
+
disposePreviousBridgeSocket(state.currentWs);
|
|
35133
35010
|
state.currentWs = null;
|
|
35134
35011
|
}
|
|
35135
35012
|
if (previewEnvironmentManager) {
|
|
@@ -35222,20 +35099,20 @@ async function cancelRun(ctx, runId) {
|
|
|
35222
35099
|
}
|
|
35223
35100
|
|
|
35224
35101
|
// ../bridge/src/agents/acp/ensure-acp-client.ts
|
|
35225
|
-
import * as
|
|
35226
|
-
import * as
|
|
35102
|
+
import * as fs18 from "node:fs";
|
|
35103
|
+
import * as path27 from "node:path";
|
|
35227
35104
|
|
|
35228
35105
|
// ../bridge/src/paths/session-layout-paths.ts
|
|
35229
|
-
import * as
|
|
35106
|
+
import * as path22 from "node:path";
|
|
35230
35107
|
function resolveIsolatedSessionParentPathFromCheckouts(worktreePaths) {
|
|
35231
|
-
const resolved = worktreePaths.map((p) =>
|
|
35108
|
+
const resolved = worktreePaths.map((p) => path22.resolve(p)).filter(Boolean);
|
|
35232
35109
|
if (resolved.length === 0) return null;
|
|
35233
35110
|
resolved.sort();
|
|
35234
35111
|
return resolved[0];
|
|
35235
35112
|
}
|
|
35236
35113
|
function resolveSessionParentPathForAgentProcess(resolvedSessionParentPath) {
|
|
35237
35114
|
if (resolvedSessionParentPath != null && String(resolvedSessionParentPath).trim() !== "") {
|
|
35238
|
-
return
|
|
35115
|
+
return path22.resolve(String(resolvedSessionParentPath).trim());
|
|
35239
35116
|
}
|
|
35240
35117
|
return getBridgeRoot();
|
|
35241
35118
|
}
|
|
@@ -35616,20 +35493,20 @@ var codexProvider = {
|
|
|
35616
35493
|
};
|
|
35617
35494
|
|
|
35618
35495
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
35619
|
-
import * as
|
|
35496
|
+
import * as fs16 from "node:fs";
|
|
35620
35497
|
|
|
35621
35498
|
// ../bridge/src/paths/session-plans-paths.ts
|
|
35622
|
-
import * as
|
|
35623
|
-
import * as
|
|
35499
|
+
import * as os5 from "node:os";
|
|
35500
|
+
import * as path23 from "node:path";
|
|
35624
35501
|
function getSessionPlansRootDir() {
|
|
35625
|
-
return
|
|
35502
|
+
return path23.join(os5.homedir(), ".buildautomaton", "plans");
|
|
35626
35503
|
}
|
|
35627
35504
|
function sanitizeSessionPlansKey(sessionId) {
|
|
35628
35505
|
const t = sessionId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 220);
|
|
35629
35506
|
return t || "session";
|
|
35630
35507
|
}
|
|
35631
35508
|
function getSessionPlansDir(sessionId) {
|
|
35632
|
-
return
|
|
35509
|
+
return path23.join(getSessionPlansRootDir(), sanitizeSessionPlansKey(sessionId));
|
|
35633
35510
|
}
|
|
35634
35511
|
|
|
35635
35512
|
// ../bridge/src/agents/providers/cursor/cleanup-session-plans.ts
|
|
@@ -35638,7 +35515,7 @@ function cleanupSessionPlans(sessionId) {
|
|
|
35638
35515
|
if (!id) return;
|
|
35639
35516
|
const dir = getSessionPlansDir(id);
|
|
35640
35517
|
try {
|
|
35641
|
-
|
|
35518
|
+
fs16.rmSync(dir, { recursive: true, force: true });
|
|
35642
35519
|
} catch {
|
|
35643
35520
|
}
|
|
35644
35521
|
}
|
|
@@ -36006,8 +35883,8 @@ function handleCursorIncomingPermissionRequest(id, method, msg, deps) {
|
|
|
36006
35883
|
}
|
|
36007
35884
|
|
|
36008
35885
|
// ../bridge/src/agents/providers/cursor/write-create-plan-file.ts
|
|
36009
|
-
import * as
|
|
36010
|
-
import * as
|
|
35886
|
+
import * as fs17 from "node:fs";
|
|
35887
|
+
import * as path24 from "node:path";
|
|
36011
35888
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
36012
35889
|
function sanitizePlanFileBase(toolCallId) {
|
|
36013
35890
|
const t = toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "_").slice(0, 120);
|
|
@@ -36015,9 +35892,9 @@ function sanitizePlanFileBase(toolCallId) {
|
|
|
36015
35892
|
}
|
|
36016
35893
|
function writeCreatePlanFile(params) {
|
|
36017
35894
|
const dir = getSessionPlansDir(params.cloudSessionId);
|
|
36018
|
-
|
|
36019
|
-
const filePath =
|
|
36020
|
-
|
|
35895
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
35896
|
+
const filePath = path24.join(dir, `${sanitizePlanFileBase(params.toolCallId)}.md`);
|
|
35897
|
+
fs17.writeFileSync(filePath, params.planMarkdown, "utf8");
|
|
36021
35898
|
return pathToFileURL2(filePath).href;
|
|
36022
35899
|
}
|
|
36023
35900
|
|
|
@@ -36323,7 +36200,8 @@ async function createCursorAcpClient(options) {
|
|
|
36323
36200
|
onAcpSessionEstablished,
|
|
36324
36201
|
onAcpConfigOptionsUpdated,
|
|
36325
36202
|
onAgentSubprocessExit,
|
|
36326
|
-
afterSessionEstablished
|
|
36203
|
+
afterSessionEstablished,
|
|
36204
|
+
signal
|
|
36327
36205
|
} = options;
|
|
36328
36206
|
const dbgFs = process.env.BUILDAUTOMATON_DEBUG_ACP_FS === "1";
|
|
36329
36207
|
const spawnEnv = bridgeInstalledAgentAuthProcessEnv(process.env);
|
|
@@ -36348,7 +36226,11 @@ async function createCursorAcpClient(options) {
|
|
|
36348
36226
|
stderrCapture
|
|
36349
36227
|
});
|
|
36350
36228
|
return new Promise((resolve36, reject) => {
|
|
36229
|
+
const stopAbort = listenForAcpClientAbort(child, signal, () => {
|
|
36230
|
+
reject(new Error("ACP client aborted"));
|
|
36231
|
+
});
|
|
36351
36232
|
child.on("error", (err) => {
|
|
36233
|
+
stopAbort();
|
|
36352
36234
|
killChildProcessTree(child, "SIGKILL");
|
|
36353
36235
|
reject(new Error(formatSpawnError(err, command[0])));
|
|
36354
36236
|
});
|
|
@@ -36360,6 +36242,7 @@ async function createCursorAcpClient(options) {
|
|
|
36360
36242
|
skipBrowserAuthenticate,
|
|
36361
36243
|
incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
|
|
36362
36244
|
});
|
|
36245
|
+
stopAbort();
|
|
36363
36246
|
resolve36(
|
|
36364
36247
|
createCursorAcpHandle({
|
|
36365
36248
|
child,
|
|
@@ -36372,6 +36255,7 @@ async function createCursorAcpClient(options) {
|
|
|
36372
36255
|
})
|
|
36373
36256
|
);
|
|
36374
36257
|
} catch (err) {
|
|
36258
|
+
stopAbort();
|
|
36375
36259
|
killChildProcessTree(child, "SIGKILL");
|
|
36376
36260
|
const merged = mergeErrorWithStderr(formatJsonRpcStyleError(err), stderrCapture.getText());
|
|
36377
36261
|
reject(merged ? new Error(merged) : err instanceof Error ? err : new Error(String(err)));
|
|
@@ -36538,7 +36422,7 @@ function getAgentTypeDisplayName(agentType) {
|
|
|
36538
36422
|
import { existsSync as existsSync4, statSync } from "node:fs";
|
|
36539
36423
|
|
|
36540
36424
|
// ../bridge/src/git/git-exec.ts
|
|
36541
|
-
import { execFile as execFile2, execFileSync
|
|
36425
|
+
import { execFile as execFile2, execFileSync, spawn as spawn4 } from "node:child_process";
|
|
36542
36426
|
import { promisify as promisify3 } from "node:util";
|
|
36543
36427
|
|
|
36544
36428
|
// ../bridge/src/git/git-runtime.ts
|
|
@@ -36596,7 +36480,7 @@ init_cli_process_interrupt();
|
|
|
36596
36480
|
var execFileAsync2 = promisify3(execFile2);
|
|
36597
36481
|
var GIT_SYNC_STDIO = ["ignore", "pipe", "pipe"];
|
|
36598
36482
|
function execGitFileSync(args, options) {
|
|
36599
|
-
return
|
|
36483
|
+
return execFileSync("git", args, {
|
|
36600
36484
|
encoding: "utf8",
|
|
36601
36485
|
maxBuffer: 10 * 1024 * 1024,
|
|
36602
36486
|
...options,
|
|
@@ -36624,16 +36508,16 @@ async function execGitFile(args, options) {
|
|
|
36624
36508
|
}
|
|
36625
36509
|
|
|
36626
36510
|
// ../bridge/src/git/get-git-repo-root-sync.ts
|
|
36627
|
-
import * as
|
|
36511
|
+
import * as path25 from "node:path";
|
|
36628
36512
|
var GIT_LOOKUP_TIMEOUT_MS = 2e3;
|
|
36629
36513
|
function getGitRepoRootSync(startDir) {
|
|
36630
36514
|
try {
|
|
36631
36515
|
const out = execGitFileSync(["rev-parse", "--show-toplevel"], {
|
|
36632
|
-
cwd:
|
|
36516
|
+
cwd: path25.resolve(startDir),
|
|
36633
36517
|
maxBuffer: 1024 * 1024,
|
|
36634
36518
|
timeout: GIT_LOOKUP_TIMEOUT_MS
|
|
36635
36519
|
}).trim();
|
|
36636
|
-
return out ?
|
|
36520
|
+
return out ? path25.resolve(out) : null;
|
|
36637
36521
|
} catch {
|
|
36638
36522
|
return null;
|
|
36639
36523
|
}
|
|
@@ -36641,26 +36525,26 @@ function getGitRepoRootSync(startDir) {
|
|
|
36641
36525
|
|
|
36642
36526
|
// ../bridge/src/agents/acp/workspace-files.ts
|
|
36643
36527
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
36644
|
-
import * as
|
|
36528
|
+
import * as path26 from "node:path";
|
|
36645
36529
|
var GIT_FILE_READ_TIMEOUT_MS = 2e3;
|
|
36646
36530
|
function resolveWorkspaceFilePath(sessionParentPath, rawPath) {
|
|
36647
36531
|
const trimmed2 = rawPath.trim();
|
|
36648
36532
|
if (!trimmed2) return null;
|
|
36649
|
-
const normalizedSessionParent =
|
|
36533
|
+
const normalizedSessionParent = path26.resolve(sessionParentPath);
|
|
36650
36534
|
let resolvedPath = resolveSafePathUnderCwd(sessionParentPath, trimmed2);
|
|
36651
36535
|
if (!resolvedPath) {
|
|
36652
|
-
const candidate =
|
|
36536
|
+
const candidate = path26.isAbsolute(trimmed2) ? path26.normalize(trimmed2) : path26.normalize(path26.resolve(normalizedSessionParent, trimmed2));
|
|
36653
36537
|
const gitRoot2 = getGitRepoRootSync(sessionParentPath);
|
|
36654
36538
|
if (!gitRoot2) return null;
|
|
36655
|
-
const rel =
|
|
36656
|
-
if (rel.startsWith("..") ||
|
|
36539
|
+
const rel = path26.relative(gitRoot2, candidate);
|
|
36540
|
+
if (rel.startsWith("..") || path26.isAbsolute(rel)) return null;
|
|
36657
36541
|
resolvedPath = candidate;
|
|
36658
36542
|
}
|
|
36659
36543
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
36660
36544
|
if (gitRoot) {
|
|
36661
|
-
const relFromRoot =
|
|
36662
|
-
if (!relFromRoot.startsWith("..") && !
|
|
36663
|
-
return { resolvedPath, display: relFromRoot.split(
|
|
36545
|
+
const relFromRoot = path26.relative(gitRoot, resolvedPath);
|
|
36546
|
+
if (!relFromRoot.startsWith("..") && !path26.isAbsolute(relFromRoot)) {
|
|
36547
|
+
return { resolvedPath, display: relFromRoot.split(path26.sep).join("/") };
|
|
36664
36548
|
}
|
|
36665
36549
|
}
|
|
36666
36550
|
return { resolvedPath, display: toDisplayPathRelativeToCwd(sessionParentPath, resolvedPath) };
|
|
@@ -36669,9 +36553,9 @@ function readUtf8WorkspaceFile(sessionParentPath, displayPath) {
|
|
|
36669
36553
|
if (!displayPath || displayPath.includes("..")) return "";
|
|
36670
36554
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
36671
36555
|
if (gitRoot) {
|
|
36672
|
-
const resolvedPath2 =
|
|
36673
|
-
const rel =
|
|
36674
|
-
if (!rel.startsWith("..") && !
|
|
36556
|
+
const resolvedPath2 = path26.resolve(gitRoot, displayPath);
|
|
36557
|
+
const rel = path26.relative(gitRoot, resolvedPath2);
|
|
36558
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) {
|
|
36675
36559
|
try {
|
|
36676
36560
|
return readFileSync4(resolvedPath2, "utf8");
|
|
36677
36561
|
} catch {
|
|
@@ -36690,9 +36574,9 @@ function tryWorkspaceDisplayToPath(sessionParentPath, displayPath) {
|
|
|
36690
36574
|
if (!displayPath || displayPath.includes("..")) return null;
|
|
36691
36575
|
const gitRoot = getGitRepoRootSync(sessionParentPath);
|
|
36692
36576
|
if (gitRoot) {
|
|
36693
|
-
const resolvedPath =
|
|
36694
|
-
const rel =
|
|
36695
|
-
if (!rel.startsWith("..") && !
|
|
36577
|
+
const resolvedPath = path26.resolve(gitRoot, displayPath);
|
|
36578
|
+
const rel = path26.relative(gitRoot, resolvedPath);
|
|
36579
|
+
if (!rel.startsWith("..") && !path26.isAbsolute(rel)) return resolvedPath;
|
|
36696
36580
|
}
|
|
36697
36581
|
return resolveSafePathUnderCwd(sessionParentPath, displayPath);
|
|
36698
36582
|
}
|
|
@@ -36992,11 +36876,13 @@ var PathSnapshotTracker = class {
|
|
|
36992
36876
|
};
|
|
36993
36877
|
|
|
36994
36878
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/send-session-info-title-update.ts
|
|
36879
|
+
var PLACEHOLDER_TITLES = /* @__PURE__ */ new Set(["session", "new session", "untitled"]);
|
|
36995
36880
|
function extractSessionInfoTitle(params) {
|
|
36996
36881
|
if (!params || typeof params !== "object") return null;
|
|
36997
36882
|
const p = params;
|
|
36998
36883
|
const title = typeof p.title === "string" ? p.title.trim() : "";
|
|
36999
|
-
|
|
36884
|
+
if (!title || PLACEHOLDER_TITLES.has(title.toLowerCase())) return null;
|
|
36885
|
+
return title;
|
|
37000
36886
|
}
|
|
37001
36887
|
function sendSessionInfoTitleUpdate(params) {
|
|
37002
36888
|
const title = extractSessionInfoTitle(params.payload);
|
|
@@ -37317,74 +37203,12 @@ function resolveBridgeToolPaths(params, isToolUpdate, sessionParentPath) {
|
|
|
37317
37203
|
return isToolUpdate ? extractToolTargetDisplayPaths(params, sessionParentPath) : [];
|
|
37318
37204
|
}
|
|
37319
37205
|
|
|
37320
|
-
// ../bridge/src/agents/planning/extract-session-update-message-text.ts
|
|
37321
|
-
function extractSessionUpdateMessageText(params) {
|
|
37322
|
-
if (params == null || typeof params !== "object" || Array.isArray(params)) return null;
|
|
37323
|
-
const o = params;
|
|
37324
|
-
if (typeof o.text === "string" && o.text.length > 0) return o.text;
|
|
37325
|
-
const content = o.content;
|
|
37326
|
-
if (typeof content === "string" && content.length > 0) return content;
|
|
37327
|
-
if (content != null && typeof content === "object" && !Array.isArray(content)) {
|
|
37328
|
-
const c = content;
|
|
37329
|
-
if (typeof c.text === "string" && c.text.length > 0) return c.text;
|
|
37330
|
-
}
|
|
37331
|
-
const update = o.update;
|
|
37332
|
-
if (typeof update === "string" && update.length > 0) return update;
|
|
37333
|
-
if (update != null && typeof update === "object" && !Array.isArray(update)) {
|
|
37334
|
-
const u = update;
|
|
37335
|
-
const innerContent = u.content;
|
|
37336
|
-
if (typeof innerContent === "string" && innerContent.length > 0) return innerContent;
|
|
37337
|
-
if (innerContent != null && typeof innerContent === "object" && !Array.isArray(innerContent)) {
|
|
37338
|
-
const ic = innerContent;
|
|
37339
|
-
if (typeof ic.text === "string" && ic.text.length > 0) return ic.text;
|
|
37340
|
-
}
|
|
37341
|
-
}
|
|
37342
|
-
return null;
|
|
37343
|
-
}
|
|
37344
|
-
|
|
37345
|
-
// ../bridge/src/agents/planning/planning-session-turn-buffer.ts
|
|
37346
|
-
var MAX_PLANNING_BUFFER_CHARS = 512 * 1024;
|
|
37347
|
-
var buffersByRunId = /* @__PURE__ */ new Map();
|
|
37348
|
-
function registerPlanningSessionTurn(runId) {
|
|
37349
|
-
buffersByRunId.set(runId, { messageBuffer: "" });
|
|
37350
|
-
}
|
|
37351
|
-
function clearPlanningSessionTurn(runId) {
|
|
37352
|
-
buffersByRunId.delete(runId);
|
|
37353
|
-
}
|
|
37354
|
-
function capturePlanningSessionUpdate(params) {
|
|
37355
|
-
const state = buffersByRunId.get(params.runId);
|
|
37356
|
-
if (!state) return false;
|
|
37357
|
-
const sessionUpdate = params.payload != null && typeof params.payload === "object" && !Array.isArray(params.payload) ? params.payload.sessionUpdate ?? params.payload.session_update : void 0;
|
|
37358
|
-
const bucket = resolveAgentTextStreamBucket({
|
|
37359
|
-
transcriptRowKind: params.updateKind,
|
|
37360
|
-
sessionUpdate: typeof sessionUpdate === "string" ? sessionUpdate : void 0
|
|
37361
|
-
});
|
|
37362
|
-
if (bucket !== "message") return false;
|
|
37363
|
-
const text = extractSessionUpdateMessageText(params.payload);
|
|
37364
|
-
if (text && state.messageBuffer.length < MAX_PLANNING_BUFFER_CHARS) {
|
|
37365
|
-
const room = MAX_PLANNING_BUFFER_CHARS - state.messageBuffer.length;
|
|
37366
|
-
state.messageBuffer += room >= text.length ? text : text.slice(0, room);
|
|
37367
|
-
}
|
|
37368
|
-
return true;
|
|
37369
|
-
}
|
|
37370
|
-
function getPlanningSessionTurnOutput(runId) {
|
|
37371
|
-
return buffersByRunId.get(runId)?.messageBuffer ?? "";
|
|
37372
|
-
}
|
|
37373
|
-
function consumePlanningSessionTurnOutput(runId) {
|
|
37374
|
-
const state = buffersByRunId.get(runId);
|
|
37375
|
-
buffersByRunId.delete(runId);
|
|
37376
|
-
return state?.messageBuffer ?? "";
|
|
37377
|
-
}
|
|
37378
|
-
|
|
37379
37206
|
// ../bridge/src/agents/acp/hooks/bridge-on-session-update/forward-bridge-session-update.ts
|
|
37380
37207
|
function forwardBridgeSessionUpdate(params) {
|
|
37381
37208
|
const { runId, sessionId, updateKind, payload, send, nextTranscriptStreamSeq, log: log2 } = params;
|
|
37382
37209
|
if (updateKind === "permission") {
|
|
37383
37210
|
return;
|
|
37384
37211
|
}
|
|
37385
|
-
if (capturePlanningSessionUpdate({ runId, updateKind, payload })) {
|
|
37386
|
-
return;
|
|
37387
|
-
}
|
|
37388
37212
|
try {
|
|
37389
37213
|
const transcriptStreamSeq = nextTranscriptStreamSeq?.(runId);
|
|
37390
37214
|
send({
|
|
@@ -37640,7 +37464,7 @@ async function ensureAcpClient(options) {
|
|
|
37640
37464
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
37641
37465
|
await state.acpStartPromise;
|
|
37642
37466
|
}
|
|
37643
|
-
if (state.acpHandle && state.lastAcpCwd != null &&
|
|
37467
|
+
if (state.acpHandle && state.lastAcpCwd != null && path27.resolve(state.lastAcpCwd) !== path27.resolve(targetSessionParentPath)) {
|
|
37644
37468
|
try {
|
|
37645
37469
|
state.acpHandle.disconnect();
|
|
37646
37470
|
} catch {
|
|
@@ -37672,7 +37496,7 @@ async function ensureAcpClient(options) {
|
|
|
37672
37496
|
if (!state.acpStartPromise) {
|
|
37673
37497
|
let statOk = false;
|
|
37674
37498
|
try {
|
|
37675
|
-
const st = await
|
|
37499
|
+
const st = await fs18.promises.stat(targetSessionParentPath);
|
|
37676
37500
|
statOk = st.isDirectory();
|
|
37677
37501
|
if (!statOk) {
|
|
37678
37502
|
state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
|
|
@@ -37832,8 +37656,8 @@ function augmentPromptResultAuthFields(agentType, errorText) {
|
|
|
37832
37656
|
init_yield_to_event_loop();
|
|
37833
37657
|
|
|
37834
37658
|
// ../bridge/src/git/changes/parse/normalize-git-diff-path.ts
|
|
37835
|
-
function normalizeGitDiffPath(
|
|
37836
|
-
return
|
|
37659
|
+
function normalizeGitDiffPath(path83) {
|
|
37660
|
+
return path83.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
|
|
37837
37661
|
}
|
|
37838
37662
|
|
|
37839
37663
|
// ../bridge/src/git/changes/parse/parse-name-status-entries.ts
|
|
@@ -37872,7 +37696,7 @@ function parseNameStatusLines(lines) {
|
|
|
37872
37696
|
}
|
|
37873
37697
|
|
|
37874
37698
|
// ../bridge/src/git/snapshot/diff/messages.ts
|
|
37875
|
-
import * as
|
|
37699
|
+
import * as path28 from "node:path";
|
|
37876
37700
|
|
|
37877
37701
|
// ../bridge/src/git/snapshot/diff/files.ts
|
|
37878
37702
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -37903,7 +37727,7 @@ async function buildTrackedChangeMessage(options) {
|
|
|
37903
37727
|
const diffArgs = entry.change === "moved" && oldRel ? ["diff", "--no-color", "-M", baselineRev, "--", oldRel, rel] : ["diff", "--no-color", "-M", baselineRev, "--", rel];
|
|
37904
37728
|
const { stdout: patchContent } = await execGitFile(diffArgs, { cwd: repoPath });
|
|
37905
37729
|
if (!patchContent.trim()) return null;
|
|
37906
|
-
const workspaceFilePath =
|
|
37730
|
+
const workspaceFilePath = path28.join(repoPath, rel);
|
|
37907
37731
|
const newText = entry.change === "removed" ? "" : await readWorkspaceFileAsUtf8(workspaceFilePath);
|
|
37908
37732
|
const oldText = entry.change === "added" ? "" : await readGitBlobAsUtf8(repoPath, baselineRev, oldRel ?? rel);
|
|
37909
37733
|
return {
|
|
@@ -37935,9 +37759,9 @@ function buildUntrackedChangeMessage(options) {
|
|
|
37935
37759
|
}
|
|
37936
37760
|
|
|
37937
37761
|
// ../bridge/src/git/snapshot/diff/paths.ts
|
|
37938
|
-
import * as
|
|
37762
|
+
import * as path29 from "node:path";
|
|
37939
37763
|
function repoDisplayPath(repoPath, multiRepo) {
|
|
37940
|
-
const slug =
|
|
37764
|
+
const slug = path29.basename(repoPath).replace(/[^\w.-]+/g, "_") || "repo";
|
|
37941
37765
|
return (rel) => multiRepo ? `${slug}/${rel}` : rel;
|
|
37942
37766
|
}
|
|
37943
37767
|
function safeRelPath(rel) {
|
|
@@ -37949,12 +37773,12 @@ function newUntrackedPaths(raw, baselineUntracked, seen) {
|
|
|
37949
37773
|
}
|
|
37950
37774
|
|
|
37951
37775
|
// ../bridge/src/git/snapshot/diff/move-pairs.ts
|
|
37952
|
-
import * as
|
|
37776
|
+
import * as path30 from "node:path";
|
|
37953
37777
|
async function readUntrackedTexts(repoPath, untracked) {
|
|
37954
37778
|
const out = /* @__PURE__ */ new Map();
|
|
37955
37779
|
await forEachWithGitYield(untracked, async (rel) => {
|
|
37956
37780
|
if (!safeRelPath(rel)) return;
|
|
37957
|
-
const newText = await readWorkspaceFileAsUtf8(
|
|
37781
|
+
const newText = await readWorkspaceFileAsUtf8(path30.join(repoPath, rel));
|
|
37958
37782
|
if (newText !== void 0) out.set(rel, newText);
|
|
37959
37783
|
});
|
|
37960
37784
|
return out;
|
|
@@ -38071,12 +37895,12 @@ async function collectRepoTurnChanges(options) {
|
|
|
38071
37895
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
38072
37896
|
|
|
38073
37897
|
// ../bridge/src/git/snapshot/types.ts
|
|
38074
|
-
import * as
|
|
37898
|
+
import * as path31 from "node:path";
|
|
38075
37899
|
function snapshotsDirForCwd(agentCwd) {
|
|
38076
|
-
return
|
|
37900
|
+
return path31.join(agentCwd, ".buildautomaton", "snapshots");
|
|
38077
37901
|
}
|
|
38078
37902
|
function snapshotFilePath(agentCwd, runId) {
|
|
38079
|
-
return
|
|
37903
|
+
return path31.join(snapshotsDirForCwd(agentCwd), `${runId}.json`);
|
|
38080
37904
|
}
|
|
38081
37905
|
|
|
38082
37906
|
// ../bridge/src/git/snapshot/diff/load-pre-turn-snapshot.ts
|
|
@@ -38153,22 +37977,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
38153
37977
|
promptId,
|
|
38154
37978
|
agentType,
|
|
38155
37979
|
agentCwd,
|
|
38156
|
-
isPlanningSession,
|
|
38157
37980
|
followUpCatalogPromptId,
|
|
38158
|
-
plugin,
|
|
38159
37981
|
sendResult,
|
|
38160
37982
|
sendSessionUpdate,
|
|
38161
37983
|
log: log2
|
|
38162
37984
|
} = params;
|
|
38163
37985
|
notifyAgentProvidersPromptTurnFinished(sessionId);
|
|
38164
|
-
const planningTodosSubmit = isPlanningSession && plugin?.cloud?.maybeSubmitPlanningTodos ? await plugin.cloud.maybeSubmitPlanningTodos({
|
|
38165
|
-
sessionId,
|
|
38166
|
-
runId,
|
|
38167
|
-
resultSuccess: result.success === true,
|
|
38168
|
-
output: result.output,
|
|
38169
|
-
log: log2
|
|
38170
|
-
}) : { suppressOutput: false };
|
|
38171
|
-
const planningFallbackOutput = !planningTodosSubmit.suppressOutput && isPlanningSession && runId ? consumePlanningSessionTurnOutput(runId) : "";
|
|
38172
37986
|
const errStr = typeof result.error === "string" ? result.error : void 0;
|
|
38173
37987
|
const resultStop = typeof result.stopReason === "string" ? result.stopReason.trim() : "";
|
|
38174
37988
|
const cancelledByAgent = resultStop.toLowerCase() === "cancelled" || errStr != null && isUserEndedSessionTurnErrorText(errStr);
|
|
@@ -38178,7 +37992,6 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
38178
37992
|
...sessionId ? { sessionId } : {},
|
|
38179
37993
|
...runId ? { runId } : {},
|
|
38180
37994
|
...result,
|
|
38181
|
-
...planningTodosSubmit.suppressOutput ? { output: void 0 } : planningFallbackOutput.trim() !== "" ? { output: planningFallbackOutput } : {},
|
|
38182
37995
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
38183
37996
|
...augmentPromptResultAuthFields(agentType, errStr),
|
|
38184
37997
|
...!result.success && cancelledByAgent ? { stopReason: "cancelled" } : {}
|
|
@@ -38206,14 +38019,12 @@ async function finalizeAndSendPromptResult(params) {
|
|
|
38206
38019
|
async function prepareAgentPromptText(params) {
|
|
38207
38020
|
const { promptText, sessionId, runId, isNewSession, plugin } = params;
|
|
38208
38021
|
if (plugin?.cloud?.prepareAgentPromptText) {
|
|
38209
|
-
|
|
38022
|
+
return plugin.cloud.prepareAgentPromptText({
|
|
38210
38023
|
promptText,
|
|
38211
38024
|
sessionId,
|
|
38212
38025
|
runId,
|
|
38213
38026
|
isNewSession
|
|
38214
38027
|
});
|
|
38215
|
-
if (prepared.isPlanningSession && runId) registerPlanningSessionTurn(runId);
|
|
38216
|
-
return prepared;
|
|
38217
38028
|
}
|
|
38218
38029
|
return { agentPromptText: promptText, isPlanningSession: false };
|
|
38219
38030
|
}
|
|
@@ -38289,7 +38100,6 @@ async function sendPromptToAgent(options) {
|
|
|
38289
38100
|
attachments,
|
|
38290
38101
|
isNewSession = false
|
|
38291
38102
|
} = options;
|
|
38292
|
-
let isPlanningSession = false;
|
|
38293
38103
|
try {
|
|
38294
38104
|
const prepared = await prepareAgentPromptText({
|
|
38295
38105
|
promptText,
|
|
@@ -38298,7 +38108,6 @@ async function sendPromptToAgent(options) {
|
|
|
38298
38108
|
isNewSession,
|
|
38299
38109
|
plugin
|
|
38300
38110
|
});
|
|
38301
|
-
isPlanningSession = prepared.isPlanningSession;
|
|
38302
38111
|
const imagesResolved = await resolveSendPromptImages({
|
|
38303
38112
|
attachments,
|
|
38304
38113
|
sessionId,
|
|
@@ -38327,7 +38136,6 @@ async function sendPromptToAgent(options) {
|
|
|
38327
38136
|
promptId,
|
|
38328
38137
|
agentType,
|
|
38329
38138
|
agentCwd,
|
|
38330
|
-
isPlanningSession,
|
|
38331
38139
|
followUpCatalogPromptId,
|
|
38332
38140
|
plugin,
|
|
38333
38141
|
sendResult,
|
|
@@ -38347,8 +38155,6 @@ async function sendPromptToAgent(options) {
|
|
|
38347
38155
|
...followUpCatalogPromptId != null && followUpCatalogPromptId !== "" ? { followUpCatalogPromptId } : {},
|
|
38348
38156
|
...augmentPromptResultAuthFields(agentType, errMsg)
|
|
38349
38157
|
});
|
|
38350
|
-
} finally {
|
|
38351
|
-
if (runId && isPlanningSession) clearPlanningSessionTurn(runId);
|
|
38352
38158
|
}
|
|
38353
38159
|
}
|
|
38354
38160
|
|
|
@@ -38523,6 +38329,7 @@ async function createAcpManager(options) {
|
|
|
38523
38329
|
logPromptReceivedFromBridge: (opts) => logPromptReceivedFromBridge(ctx, opts),
|
|
38524
38330
|
handlePrompt: (opts) => handlePrompt(ctx, opts),
|
|
38525
38331
|
cancelRun: (runId) => cancelRun(ctx, runId),
|
|
38332
|
+
isRegisteredRun: (runId) => ctx.promptRouting.isRegisteredRun(runId),
|
|
38526
38333
|
resolveRequest(requestId, result) {
|
|
38527
38334
|
for (const state of ctx.acpAgents.values()) {
|
|
38528
38335
|
state.acpHandle?.resolveRequest?.(requestId, result);
|
|
@@ -38885,7 +38692,7 @@ async function createBridgeAccessState(options) {
|
|
|
38885
38692
|
}
|
|
38886
38693
|
|
|
38887
38694
|
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
38888
|
-
import * as
|
|
38695
|
+
import * as path33 from "node:path";
|
|
38889
38696
|
|
|
38890
38697
|
// ../bridge/src/agents/detect-local-agent-types.ts
|
|
38891
38698
|
init_yield_to_event_loop();
|
|
@@ -38984,58 +38791,67 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
|
|
|
38984
38791
|
// ../bridge/src/agents/capabilities/probe-agent-capabilities-for-types.ts
|
|
38985
38792
|
init_cli_database();
|
|
38986
38793
|
|
|
38794
|
+
// ../bridge/src/agents/capabilities/agent-capability-warmup-run.ts
|
|
38795
|
+
init_cli_process_interrupt();
|
|
38796
|
+
var warmupEpoch = 0;
|
|
38797
|
+
var probedTypesThisProcess = /* @__PURE__ */ new Set();
|
|
38798
|
+
function cancelInFlightAgentCapabilityWarmup() {
|
|
38799
|
+
warmupEpoch += 1;
|
|
38800
|
+
}
|
|
38801
|
+
function beginAgentCapabilityWarmupRun() {
|
|
38802
|
+
const epoch = warmupEpoch += 1;
|
|
38803
|
+
return () => epoch === warmupEpoch && !isCliImmediateShutdownRequested();
|
|
38804
|
+
}
|
|
38805
|
+
function wasAgentCapabilityTypeProbedThisProcess(agentType) {
|
|
38806
|
+
return probedTypesThisProcess.has(agentType);
|
|
38807
|
+
}
|
|
38808
|
+
function markAgentCapabilityTypeProbedThisProcess(agentType) {
|
|
38809
|
+
probedTypesThisProcess.add(agentType);
|
|
38810
|
+
}
|
|
38811
|
+
function shouldSkipCapabilityProbeThisProcess(agentType) {
|
|
38812
|
+
if (process.env.BUILDAUTOMATON_FORCE_PROBE_ACP_CAPABILITIES === "1") return false;
|
|
38813
|
+
return wasAgentCapabilityTypeProbedThisProcess(agentType);
|
|
38814
|
+
}
|
|
38815
|
+
|
|
38987
38816
|
// ../bridge/src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
|
|
38988
|
-
import * as
|
|
38817
|
+
import * as path32 from "node:path";
|
|
38989
38818
|
init_cli_database();
|
|
38819
|
+
init_yield_to_event_loop();
|
|
38990
38820
|
init_cli_process_interrupt();
|
|
38821
|
+
var ACP_CAPABILITY_PROBE_TIMEOUT_MS = 12e3;
|
|
38991
38822
|
async function probeOneAgentTypeForCapabilities(params) {
|
|
38992
38823
|
const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
|
|
38993
|
-
const canContinue = () => shouldContinue?.() !== false;
|
|
38824
|
+
const canContinue = () => shouldContinue?.() !== false && !isCliImmediateShutdownRequested();
|
|
38994
38825
|
if (!canContinue()) return false;
|
|
38995
38826
|
const resolved = resolveAgentCommand(agentType);
|
|
38996
38827
|
if (!resolved) return false;
|
|
38997
|
-
|
|
38998
|
-
|
|
38999
|
-
|
|
39000
|
-
|
|
39001
|
-
|
|
39002
|
-
|
|
39003
|
-
|
|
39004
|
-
|
|
39005
|
-
|
|
39006
|
-
|
|
39007
|
-
|
|
39008
|
-
agentType,
|
|
39009
|
-
configOptions: co
|
|
39010
|
-
})
|
|
39011
|
-
);
|
|
39012
|
-
} catch {
|
|
39013
|
-
}
|
|
39014
|
-
sqliteChanged ||= changed;
|
|
39015
|
-
if (bridgeReport && changed) {
|
|
39016
|
-
reportAgentCapabilities?.({ agentType, configOptions: co });
|
|
39017
|
-
}
|
|
39018
|
-
};
|
|
38828
|
+
await yieldToEventLoop();
|
|
38829
|
+
if (!canContinue()) return false;
|
|
38830
|
+
markAgentCapabilityTypeProbedThisProcess(agentType);
|
|
38831
|
+
let pendingCo = null;
|
|
38832
|
+
const ac = new AbortController();
|
|
38833
|
+
const abortTimer = setTimeout(() => ac.abort(), ACP_CAPABILITY_PROBE_TIMEOUT_MS);
|
|
38834
|
+
abortTimer.unref?.();
|
|
38835
|
+
const abortIfStale = setInterval(() => {
|
|
38836
|
+
if (!canContinue()) ac.abort();
|
|
38837
|
+
}, 50);
|
|
38838
|
+
abortIfStale.unref?.();
|
|
39019
38839
|
let handle = null;
|
|
39020
|
-
const killTimer = setTimeout(() => {
|
|
39021
|
-
void handle?.disconnectGracefully();
|
|
39022
|
-
}, 28e3);
|
|
39023
|
-
killTimer.unref?.();
|
|
39024
38840
|
try {
|
|
39025
|
-
if (!canContinue()) return false;
|
|
39026
38841
|
handle = await resolved.createClient({
|
|
39027
38842
|
command: resolved.command,
|
|
39028
|
-
cwd:
|
|
38843
|
+
cwd: path32.resolve(cwd),
|
|
39029
38844
|
backendAgentType: agentType,
|
|
39030
38845
|
sessionMode: "agent",
|
|
39031
38846
|
persistedAcpSessionId: null,
|
|
39032
38847
|
agentConfig: null,
|
|
38848
|
+
signal: ac.signal,
|
|
39033
38849
|
getActiveConfigOptions: () => null,
|
|
39034
38850
|
onAcpSessionEstablished: (info) => {
|
|
39035
|
-
|
|
38851
|
+
if (Array.isArray(info.configOptions) && info.configOptions.length > 0) pendingCo = info.configOptions;
|
|
39036
38852
|
},
|
|
39037
38853
|
onAcpConfigOptionsUpdated: (co) => {
|
|
39038
|
-
|
|
38854
|
+
if (Array.isArray(co) && co.length > 0) pendingCo = co;
|
|
39039
38855
|
},
|
|
39040
38856
|
onAgentSubprocessExit: () => {
|
|
39041
38857
|
},
|
|
@@ -39048,13 +38864,21 @@ async function probeOneAgentTypeForCapabilities(params) {
|
|
|
39048
38864
|
`[Bridge service] Agent capability probe (${agentType}): ${e instanceof Error ? e.message : String(e)}`
|
|
39049
38865
|
);
|
|
39050
38866
|
} finally {
|
|
39051
|
-
clearTimeout(
|
|
38867
|
+
clearTimeout(abortTimer);
|
|
38868
|
+
clearInterval(abortIfStale);
|
|
39052
38869
|
try {
|
|
39053
38870
|
await handle?.disconnectGracefully();
|
|
39054
38871
|
} catch {
|
|
39055
38872
|
}
|
|
39056
38873
|
}
|
|
39057
|
-
return
|
|
38874
|
+
if (!pendingCo || !canContinue()) return false;
|
|
38875
|
+
const configOptions = pendingCo;
|
|
38876
|
+
await yieldToEventLoop();
|
|
38877
|
+
const changed = await withCliSqlite(
|
|
38878
|
+
(db) => upsertCliAgentCapabilityCache(db, { workspaceId, agentType, configOptions })
|
|
38879
|
+
);
|
|
38880
|
+
if (bridgeReport && changed) reportAgentCapabilities?.({ agentType, configOptions });
|
|
38881
|
+
return changed;
|
|
39058
38882
|
}
|
|
39059
38883
|
|
|
39060
38884
|
// ../bridge/src/agents/capabilities/probe-agent-capabilities-for-types.ts
|
|
@@ -39073,9 +38897,10 @@ async function probeAgentCapabilitiesForDetectedTypes(params) {
|
|
|
39073
38897
|
let changedCount = 0;
|
|
39074
38898
|
for (let i = 0; i < agentTypes.length; i++) {
|
|
39075
38899
|
if (!canContinue()) return changedCount;
|
|
39076
|
-
|
|
38900
|
+
await yieldToEventLoop();
|
|
39077
38901
|
const agentType = agentTypes[i];
|
|
39078
38902
|
if (!agentType.trim()) continue;
|
|
38903
|
+
if (shouldSkipCapabilityProbeThisProcess(agentType)) continue;
|
|
39079
38904
|
if (!forceAllTypes) {
|
|
39080
38905
|
try {
|
|
39081
38906
|
if (process.env.BUILDAUTOMATON_FORCE_PROBE_ACP_CAPABILITIES !== "1" && await withCliSqlite((db) => hasNonEmptyAgentCapabilityCache(db, workspaceId, agentType))) {
|
|
@@ -39101,32 +38926,18 @@ async function probeAgentCapabilitiesForDetectedTypes(params) {
|
|
|
39101
38926
|
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
39102
38927
|
init_yield_to_event_loop();
|
|
39103
38928
|
init_cli_database();
|
|
39104
|
-
|
|
39105
|
-
// ../bridge/src/agents/capabilities/agent-capability-warmup-run.ts
|
|
39106
|
-
init_cli_process_interrupt();
|
|
39107
|
-
var warmupEpoch = 0;
|
|
39108
|
-
function cancelInFlightAgentCapabilityWarmup() {
|
|
39109
|
-
warmupEpoch += 1;
|
|
39110
|
-
}
|
|
39111
|
-
function beginAgentCapabilityWarmupRun() {
|
|
39112
|
-
const epoch = warmupEpoch += 1;
|
|
39113
|
-
return () => epoch === warmupEpoch && !isCliImmediateShutdownRequested();
|
|
39114
|
-
}
|
|
39115
|
-
|
|
39116
|
-
// ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
|
|
39117
38929
|
async function warmupAgentCapabilitiesOnConnect(params) {
|
|
39118
38930
|
const { workspaceId, log: log2, getWs } = params;
|
|
39119
38931
|
const isCurrent = beginAgentCapabilityWarmupRun();
|
|
39120
38932
|
if (!isCurrent()) return;
|
|
39121
|
-
const cwd =
|
|
38933
|
+
const cwd = path33.resolve(getBridgeRoot());
|
|
39122
38934
|
async function sendBatchFromCache() {
|
|
39123
38935
|
if (!isCurrent()) return;
|
|
39124
38936
|
const socket = getWs();
|
|
39125
38937
|
if (!socket || socket.readyState !== wrapper_default.OPEN) return;
|
|
39126
38938
|
try {
|
|
39127
38939
|
const rows = await withCliSqlite((db) => listCliAgentCapabilityCacheForWorkspace(db, workspaceId));
|
|
39128
|
-
if (!isCurrent()) return;
|
|
39129
|
-
if (rows.length === 0) return;
|
|
38940
|
+
if (!isCurrent() || rows.length === 0) return;
|
|
39130
38941
|
sendWsMessage(socket, {
|
|
39131
38942
|
type: "agent_capabilities_batch",
|
|
39132
38943
|
items: rows.map((r) => ({ agentType: r.agentType, configOptions: r.configOptions }))
|
|
@@ -39140,46 +38951,30 @@ async function warmupAgentCapabilitiesOnConnect(params) {
|
|
|
39140
38951
|
}
|
|
39141
38952
|
await sendBatchFromCache();
|
|
39142
38953
|
if (!isCurrent()) return;
|
|
39143
|
-
let types = [];
|
|
39144
|
-
try {
|
|
39145
|
-
types = [...await detectLocalAgentTypes()];
|
|
39146
|
-
} catch (e) {
|
|
39147
|
-
log2(`[Bridge service] detectLocalAgentTypes failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
39148
|
-
}
|
|
39149
|
-
if (!isCurrent()) return;
|
|
39150
|
-
try {
|
|
39151
|
-
const n = await probeAgentCapabilitiesForDetectedTypes({
|
|
39152
|
-
agentTypes: types,
|
|
39153
|
-
cwd,
|
|
39154
|
-
workspaceId,
|
|
39155
|
-
log: log2,
|
|
39156
|
-
bridgeReport: false,
|
|
39157
|
-
forceAllTypes: false,
|
|
39158
|
-
shouldContinue: isCurrent
|
|
39159
|
-
});
|
|
39160
|
-
if (n > 0) await sendBatchFromCache();
|
|
39161
|
-
} catch (e) {
|
|
39162
|
-
if (e instanceof CliSqliteInterrupted) return;
|
|
39163
|
-
log2(`[Bridge service] Agent capability probe (missing cache) failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
39164
|
-
}
|
|
39165
|
-
if (!isCurrent()) return;
|
|
39166
38954
|
void (async () => {
|
|
39167
38955
|
try {
|
|
39168
38956
|
await yieldToEventLoop();
|
|
39169
38957
|
if (!isCurrent()) return;
|
|
38958
|
+
let types = [];
|
|
38959
|
+
try {
|
|
38960
|
+
types = [...await detectLocalAgentTypes()];
|
|
38961
|
+
} catch (e) {
|
|
38962
|
+
log2(`[Bridge service] detectLocalAgentTypes failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
38963
|
+
}
|
|
38964
|
+
if (!isCurrent()) return;
|
|
39170
38965
|
const n = await probeAgentCapabilitiesForDetectedTypes({
|
|
39171
38966
|
agentTypes: types,
|
|
39172
38967
|
cwd,
|
|
39173
38968
|
workspaceId,
|
|
39174
38969
|
log: log2,
|
|
39175
38970
|
bridgeReport: false,
|
|
39176
|
-
forceAllTypes:
|
|
38971
|
+
forceAllTypes: false,
|
|
39177
38972
|
shouldContinue: isCurrent
|
|
39178
38973
|
});
|
|
39179
38974
|
if (n > 0) await sendBatchFromCache();
|
|
39180
38975
|
} catch (e) {
|
|
39181
38976
|
if (e instanceof CliSqliteInterrupted) return;
|
|
39182
|
-
log2(`[Bridge service] Agent capability
|
|
38977
|
+
log2(`[Bridge service] Agent capability probe failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
39183
38978
|
}
|
|
39184
38979
|
})();
|
|
39185
38980
|
}
|
|
@@ -39244,7 +39039,7 @@ async function createBridgeAccessAndAcp(options) {
|
|
|
39244
39039
|
}
|
|
39245
39040
|
|
|
39246
39041
|
// ../bridge/src/connection/setup/create-bridge-preview-stack.ts
|
|
39247
|
-
import * as
|
|
39042
|
+
import * as path36 from "node:path";
|
|
39248
39043
|
|
|
39249
39044
|
// ../bridge/src/preview-environments/manager/firehose-messages.ts
|
|
39250
39045
|
function buildFirehoseSnapshotMessage(params) {
|
|
@@ -39562,7 +39357,7 @@ function attachChildErrorHandler(d) {
|
|
|
39562
39357
|
}
|
|
39563
39358
|
|
|
39564
39359
|
// ../bridge/src/preview-environments/process/wire/handle-exit.ts
|
|
39565
|
-
import
|
|
39360
|
+
import fs19 from "node:fs";
|
|
39566
39361
|
function logStopLine(d, code, signal) {
|
|
39567
39362
|
const { title } = d;
|
|
39568
39363
|
if (signal) {
|
|
@@ -39601,7 +39396,7 @@ function attachChildExitHandler(d) {
|
|
|
39601
39396
|
const cleanupDir = d.mergedCleanupDir;
|
|
39602
39397
|
const mergedPath = d.mergedLogPath;
|
|
39603
39398
|
if (mergedPath && !stale) {
|
|
39604
|
-
|
|
39399
|
+
fs19.readFile(mergedPath, (err, buf) => {
|
|
39605
39400
|
if (!err && buf.length > d.mergedReadPos.value) {
|
|
39606
39401
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
39607
39402
|
if (chunk.length > 0) {
|
|
@@ -39647,7 +39442,7 @@ function wireChildOutputPipes(d) {
|
|
|
39647
39442
|
}
|
|
39648
39443
|
|
|
39649
39444
|
// ../bridge/src/preview-environments/process/wire/poll-merged-log.ts
|
|
39650
|
-
import
|
|
39445
|
+
import fs20 from "node:fs";
|
|
39651
39446
|
function startMergedLogPoll(d) {
|
|
39652
39447
|
if (!d.mergedLogPath || !d.mergedCleanupDir) return;
|
|
39653
39448
|
const { environmentId } = d;
|
|
@@ -39657,7 +39452,7 @@ function startMergedLogPoll(d) {
|
|
|
39657
39452
|
d.setPollInterval(void 0);
|
|
39658
39453
|
return;
|
|
39659
39454
|
}
|
|
39660
|
-
|
|
39455
|
+
fs20.readFile(d.mergedLogPath, (err, buf) => {
|
|
39661
39456
|
if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
|
|
39662
39457
|
if (buf.length <= d.mergedReadPos.value) return;
|
|
39663
39458
|
const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
|
|
@@ -39872,7 +39667,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
|
|
|
39872
39667
|
}
|
|
39873
39668
|
|
|
39874
39669
|
// ../bridge/src/preview-environments/manager/shell-spawn/utils.ts
|
|
39875
|
-
import
|
|
39670
|
+
import fs21 from "node:fs";
|
|
39876
39671
|
function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
|
|
39877
39672
|
return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
|
|
39878
39673
|
}
|
|
@@ -39881,7 +39676,7 @@ function isSpawnEbadf(e) {
|
|
|
39881
39676
|
}
|
|
39882
39677
|
function rmDirQuiet(dir) {
|
|
39883
39678
|
try {
|
|
39884
|
-
|
|
39679
|
+
fs21.rmSync(dir, { recursive: true, force: true });
|
|
39885
39680
|
} catch {
|
|
39886
39681
|
}
|
|
39887
39682
|
}
|
|
@@ -39889,7 +39684,7 @@ var cachedDevNullReadFd;
|
|
|
39889
39684
|
function devNullReadFd() {
|
|
39890
39685
|
if (cachedDevNullReadFd === void 0) {
|
|
39891
39686
|
const devPath = process.platform === "win32" ? "nul" : "/dev/null";
|
|
39892
|
-
cachedDevNullReadFd =
|
|
39687
|
+
cachedDevNullReadFd = fs21.openSync(devPath, "r");
|
|
39893
39688
|
}
|
|
39894
39689
|
return cachedDevNullReadFd;
|
|
39895
39690
|
}
|
|
@@ -39969,15 +39764,15 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
|
|
|
39969
39764
|
|
|
39970
39765
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
|
|
39971
39766
|
import { spawn as spawn7 } from "node:child_process";
|
|
39972
|
-
import
|
|
39767
|
+
import fs22 from "node:fs";
|
|
39973
39768
|
import { tmpdir } from "node:os";
|
|
39974
|
-
import
|
|
39769
|
+
import path34 from "node:path";
|
|
39975
39770
|
function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
39976
|
-
const tmpRoot =
|
|
39977
|
-
const logPath =
|
|
39771
|
+
const tmpRoot = fs22.mkdtempSync(path34.join(tmpdir(), "ba-devsrv-log-"));
|
|
39772
|
+
const logPath = path34.join(tmpRoot, "combined.log");
|
|
39978
39773
|
let logFd;
|
|
39979
39774
|
try {
|
|
39980
|
-
logFd =
|
|
39775
|
+
logFd = fs22.openSync(logPath, "a");
|
|
39981
39776
|
} catch {
|
|
39982
39777
|
rmDirQuiet(tmpRoot);
|
|
39983
39778
|
return null;
|
|
@@ -40001,7 +39796,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
40001
39796
|
mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
|
|
40002
39797
|
);
|
|
40003
39798
|
}
|
|
40004
|
-
|
|
39799
|
+
fs22.closeSync(logFd);
|
|
40005
39800
|
return {
|
|
40006
39801
|
proc,
|
|
40007
39802
|
pipedStdoutStderr: true,
|
|
@@ -40010,7 +39805,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
40010
39805
|
};
|
|
40011
39806
|
} catch (e) {
|
|
40012
39807
|
try {
|
|
40013
|
-
|
|
39808
|
+
fs22.closeSync(logFd);
|
|
40014
39809
|
} catch {
|
|
40015
39810
|
}
|
|
40016
39811
|
rmDirQuiet(tmpRoot);
|
|
@@ -40021,22 +39816,22 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
|
|
|
40021
39816
|
|
|
40022
39817
|
// ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
|
|
40023
39818
|
import { spawn as spawn8 } from "node:child_process";
|
|
40024
|
-
import
|
|
39819
|
+
import fs23 from "node:fs";
|
|
40025
39820
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
40026
|
-
import
|
|
39821
|
+
import path35 from "node:path";
|
|
40027
39822
|
function shSingleQuote(s) {
|
|
40028
39823
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
40029
39824
|
}
|
|
40030
39825
|
function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
|
|
40031
|
-
const tmpRoot =
|
|
40032
|
-
const logPath =
|
|
40033
|
-
const innerPath =
|
|
40034
|
-
const runnerPath =
|
|
39826
|
+
const tmpRoot = fs23.mkdtempSync(path35.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
39827
|
+
const logPath = path35.join(tmpRoot, "combined.log");
|
|
39828
|
+
const innerPath = path35.join(tmpRoot, "_cmd.sh");
|
|
39829
|
+
const runnerPath = path35.join(tmpRoot, "_run.sh");
|
|
40035
39830
|
try {
|
|
40036
|
-
|
|
39831
|
+
fs23.writeFileSync(innerPath, `#!/bin/sh
|
|
40037
39832
|
${command}
|
|
40038
39833
|
`);
|
|
40039
|
-
|
|
39834
|
+
fs23.writeFileSync(
|
|
40040
39835
|
runnerPath,
|
|
40041
39836
|
`#!/bin/sh
|
|
40042
39837
|
cd ${shSingleQuote(cwd)}
|
|
@@ -40064,13 +39859,13 @@ cd ${shSingleQuote(cwd)}
|
|
|
40064
39859
|
}
|
|
40065
39860
|
}
|
|
40066
39861
|
function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
|
|
40067
|
-
const tmpRoot =
|
|
40068
|
-
const logPath =
|
|
40069
|
-
const runnerPath =
|
|
39862
|
+
const tmpRoot = fs23.mkdtempSync(path35.join(tmpdir2(), "ba-devsrv-sh-"));
|
|
39863
|
+
const logPath = path35.join(tmpRoot, "combined.log");
|
|
39864
|
+
const runnerPath = path35.join(tmpRoot, "_run.bat");
|
|
40070
39865
|
const q = (p) => `"${p.replace(/"/g, '""')}"`;
|
|
40071
39866
|
const com = process.env.ComSpec || "cmd.exe";
|
|
40072
39867
|
try {
|
|
40073
|
-
|
|
39868
|
+
fs23.writeFileSync(
|
|
40074
39869
|
runnerPath,
|
|
40075
39870
|
`@ECHO OFF\r
|
|
40076
39871
|
CD /D ${q(cwd)}\r
|
|
@@ -40388,8 +40183,8 @@ function createBridgePreviewStack(options) {
|
|
|
40388
40183
|
scheduleInitialIndexBuilds(getBridgeRoot());
|
|
40389
40184
|
};
|
|
40390
40185
|
const identifyReportedPaths = {
|
|
40391
|
-
bridgeRootPath:
|
|
40392
|
-
worktreesRootPath:
|
|
40186
|
+
bridgeRootPath: path36.resolve(getBridgeRoot()),
|
|
40187
|
+
worktreesRootPath: path36.resolve(options.worktreesRootPath),
|
|
40393
40188
|
localShortcutPort: 0,
|
|
40394
40189
|
localShortcutToken: ""
|
|
40395
40190
|
};
|
|
@@ -40591,7 +40386,7 @@ function createBridgeHeartbeatController(params) {
|
|
|
40591
40386
|
}
|
|
40592
40387
|
|
|
40593
40388
|
// ../bridge/src/cli/cli-version.ts
|
|
40594
|
-
var CLI_VERSION = "0.1.
|
|
40389
|
+
var CLI_VERSION = "0.1.95".length > 0 ? "0.1.95" : "0.0.0-dev";
|
|
40595
40390
|
|
|
40596
40391
|
// ../bridge/src/connection/identify/send-bridge-identify.ts
|
|
40597
40392
|
function sendBridgeIdentify(ws, params) {
|
|
@@ -40762,12 +40557,12 @@ function createBridgeRuntimeMessageSetup(options) {
|
|
|
40762
40557
|
}
|
|
40763
40558
|
|
|
40764
40559
|
// ../bridge/src/worktrees/worktree-layout-file.ts
|
|
40765
|
-
import * as
|
|
40766
|
-
import * as
|
|
40767
|
-
import
|
|
40560
|
+
import * as fs24 from "node:fs";
|
|
40561
|
+
import * as path37 from "node:path";
|
|
40562
|
+
import os6 from "node:os";
|
|
40768
40563
|
var LAYOUT_FILENAME = "worktree-launcher-layout.json";
|
|
40769
40564
|
function defaultWorktreeLayoutPath() {
|
|
40770
|
-
return
|
|
40565
|
+
return path37.join(os6.homedir(), ".buildautomaton", LAYOUT_FILENAME);
|
|
40771
40566
|
}
|
|
40772
40567
|
function normalizeLoadedLayout(raw) {
|
|
40773
40568
|
if (raw && typeof raw === "object" && "launcherCwds" in raw) {
|
|
@@ -40779,8 +40574,8 @@ function normalizeLoadedLayout(raw) {
|
|
|
40779
40574
|
function loadWorktreeLayout() {
|
|
40780
40575
|
try {
|
|
40781
40576
|
const p = defaultWorktreeLayoutPath();
|
|
40782
|
-
if (!
|
|
40783
|
-
const raw = JSON.parse(
|
|
40577
|
+
if (!fs24.existsSync(p)) return { launcherCwds: [] };
|
|
40578
|
+
const raw = JSON.parse(fs24.readFileSync(p, "utf8"));
|
|
40784
40579
|
return normalizeLoadedLayout(raw);
|
|
40785
40580
|
} catch {
|
|
40786
40581
|
return { launcherCwds: [] };
|
|
@@ -40788,24 +40583,24 @@ function loadWorktreeLayout() {
|
|
|
40788
40583
|
}
|
|
40789
40584
|
function saveWorktreeLayout(layout) {
|
|
40790
40585
|
try {
|
|
40791
|
-
const dir =
|
|
40792
|
-
|
|
40793
|
-
|
|
40586
|
+
const dir = path37.dirname(defaultWorktreeLayoutPath());
|
|
40587
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
40588
|
+
fs24.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
|
|
40794
40589
|
} catch {
|
|
40795
40590
|
}
|
|
40796
40591
|
}
|
|
40797
40592
|
function baseNameSafe(pathString) {
|
|
40798
|
-
return
|
|
40593
|
+
return path37.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
|
|
40799
40594
|
}
|
|
40800
40595
|
function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
|
|
40801
|
-
const norm =
|
|
40802
|
-
const existing = layout.launcherCwds.find((e) =>
|
|
40596
|
+
const norm = path37.resolve(bridgeRootPath2);
|
|
40597
|
+
const existing = layout.launcherCwds.find((e) => path37.resolve(e.absolutePath) === norm);
|
|
40803
40598
|
return existing?.dirName;
|
|
40804
40599
|
}
|
|
40805
40600
|
function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
|
|
40806
40601
|
const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
|
|
40807
40602
|
if (existing) return existing;
|
|
40808
|
-
const norm =
|
|
40603
|
+
const norm = path37.resolve(bridgeRootPath2);
|
|
40809
40604
|
const base = baseNameSafe(norm);
|
|
40810
40605
|
const used = new Set(layout.launcherCwds.map((e) => e.dirName));
|
|
40811
40606
|
let name = base;
|
|
@@ -40898,8 +40693,8 @@ function pathspec(...paths) {
|
|
|
40898
40693
|
cache.set(key, paths);
|
|
40899
40694
|
return key;
|
|
40900
40695
|
}
|
|
40901
|
-
function isPathSpec(
|
|
40902
|
-
return
|
|
40696
|
+
function isPathSpec(path83) {
|
|
40697
|
+
return path83 instanceof String && cache.has(path83);
|
|
40903
40698
|
}
|
|
40904
40699
|
function toPaths(pathSpec) {
|
|
40905
40700
|
return cache.get(pathSpec) || [];
|
|
@@ -40988,8 +40783,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
40988
40783
|
function forEachLineWithContent(input, callback) {
|
|
40989
40784
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
40990
40785
|
}
|
|
40991
|
-
function folderExists(
|
|
40992
|
-
return (0, import_file_exists.exists)(
|
|
40786
|
+
function folderExists(path83) {
|
|
40787
|
+
return (0, import_file_exists.exists)(path83, import_file_exists.FOLDER);
|
|
40993
40788
|
}
|
|
40994
40789
|
function append(target, item) {
|
|
40995
40790
|
if (Array.isArray(target)) {
|
|
@@ -41393,8 +41188,8 @@ function checkIsRepoRootTask() {
|
|
|
41393
41188
|
commands,
|
|
41394
41189
|
format: "utf-8",
|
|
41395
41190
|
onError,
|
|
41396
|
-
parser(
|
|
41397
|
-
return /^\.(git)?$/.test(
|
|
41191
|
+
parser(path83) {
|
|
41192
|
+
return /^\.(git)?$/.test(path83.trim());
|
|
41398
41193
|
}
|
|
41399
41194
|
};
|
|
41400
41195
|
}
|
|
@@ -41828,11 +41623,11 @@ function parseGrep(grep) {
|
|
|
41828
41623
|
const paths = /* @__PURE__ */ new Set();
|
|
41829
41624
|
const results = {};
|
|
41830
41625
|
forEachLineWithContent(grep, (input) => {
|
|
41831
|
-
const [
|
|
41832
|
-
paths.add(
|
|
41833
|
-
(results[
|
|
41626
|
+
const [path83, line, preview] = input.split(NULL);
|
|
41627
|
+
paths.add(path83);
|
|
41628
|
+
(results[path83] = results[path83] || []).push({
|
|
41834
41629
|
line: asNumber(line),
|
|
41835
|
-
path:
|
|
41630
|
+
path: path83,
|
|
41836
41631
|
preview
|
|
41837
41632
|
});
|
|
41838
41633
|
});
|
|
@@ -42597,14 +42392,14 @@ var init_hash_object = __esm2({
|
|
|
42597
42392
|
init_task();
|
|
42598
42393
|
}
|
|
42599
42394
|
});
|
|
42600
|
-
function parseInit(bare,
|
|
42395
|
+
function parseInit(bare, path83, text) {
|
|
42601
42396
|
const response = String(text).trim();
|
|
42602
42397
|
let result;
|
|
42603
42398
|
if (result = initResponseRegex.exec(response)) {
|
|
42604
|
-
return new InitSummary(bare,
|
|
42399
|
+
return new InitSummary(bare, path83, false, result[1]);
|
|
42605
42400
|
}
|
|
42606
42401
|
if (result = reInitResponseRegex.exec(response)) {
|
|
42607
|
-
return new InitSummary(bare,
|
|
42402
|
+
return new InitSummary(bare, path83, true, result[1]);
|
|
42608
42403
|
}
|
|
42609
42404
|
let gitDir = "";
|
|
42610
42405
|
const tokens = response.split(" ");
|
|
@@ -42615,7 +42410,7 @@ function parseInit(bare, path85, text) {
|
|
|
42615
42410
|
break;
|
|
42616
42411
|
}
|
|
42617
42412
|
}
|
|
42618
|
-
return new InitSummary(bare,
|
|
42413
|
+
return new InitSummary(bare, path83, /^re/i.test(response), gitDir);
|
|
42619
42414
|
}
|
|
42620
42415
|
var InitSummary;
|
|
42621
42416
|
var initResponseRegex;
|
|
@@ -42624,9 +42419,9 @@ var init_InitSummary = __esm2({
|
|
|
42624
42419
|
"src/lib/responses/InitSummary.ts"() {
|
|
42625
42420
|
"use strict";
|
|
42626
42421
|
InitSummary = class {
|
|
42627
|
-
constructor(bare,
|
|
42422
|
+
constructor(bare, path83, existing, gitDir) {
|
|
42628
42423
|
this.bare = bare;
|
|
42629
|
-
this.path =
|
|
42424
|
+
this.path = path83;
|
|
42630
42425
|
this.existing = existing;
|
|
42631
42426
|
this.gitDir = gitDir;
|
|
42632
42427
|
}
|
|
@@ -42638,7 +42433,7 @@ var init_InitSummary = __esm2({
|
|
|
42638
42433
|
function hasBareCommand(command) {
|
|
42639
42434
|
return command.includes(bareCommand);
|
|
42640
42435
|
}
|
|
42641
|
-
function initTask(bare = false,
|
|
42436
|
+
function initTask(bare = false, path83, customArgs) {
|
|
42642
42437
|
const commands = ["init", ...customArgs];
|
|
42643
42438
|
if (bare && !hasBareCommand(commands)) {
|
|
42644
42439
|
commands.splice(1, 0, bareCommand);
|
|
@@ -42647,7 +42442,7 @@ function initTask(bare = false, path85, customArgs) {
|
|
|
42647
42442
|
commands,
|
|
42648
42443
|
format: "utf-8",
|
|
42649
42444
|
parser(text) {
|
|
42650
|
-
return parseInit(commands.includes("--bare"),
|
|
42445
|
+
return parseInit(commands.includes("--bare"), path83, text);
|
|
42651
42446
|
}
|
|
42652
42447
|
};
|
|
42653
42448
|
}
|
|
@@ -43463,12 +43258,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
43463
43258
|
"use strict";
|
|
43464
43259
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
43465
43260
|
FileStatusSummary = class {
|
|
43466
|
-
constructor(
|
|
43467
|
-
this.path =
|
|
43261
|
+
constructor(path83, index, working_dir) {
|
|
43262
|
+
this.path = path83;
|
|
43468
43263
|
this.index = index;
|
|
43469
43264
|
this.working_dir = working_dir;
|
|
43470
43265
|
if (index === "R" || working_dir === "R") {
|
|
43471
|
-
const detail = fromPathRegex.exec(
|
|
43266
|
+
const detail = fromPathRegex.exec(path83) || [null, path83, path83];
|
|
43472
43267
|
this.from = detail[2] || "";
|
|
43473
43268
|
this.path = detail[1] || "";
|
|
43474
43269
|
}
|
|
@@ -43499,14 +43294,14 @@ function splitLine(result, lineStr) {
|
|
|
43499
43294
|
default:
|
|
43500
43295
|
return;
|
|
43501
43296
|
}
|
|
43502
|
-
function data(index, workingDir,
|
|
43297
|
+
function data(index, workingDir, path83) {
|
|
43503
43298
|
const raw = `${index}${workingDir}`;
|
|
43504
43299
|
const handler = parsers6.get(raw);
|
|
43505
43300
|
if (handler) {
|
|
43506
|
-
handler(result,
|
|
43301
|
+
handler(result, path83);
|
|
43507
43302
|
}
|
|
43508
43303
|
if (raw !== "##" && raw !== "!!") {
|
|
43509
|
-
result.files.push(new FileStatusSummary(
|
|
43304
|
+
result.files.push(new FileStatusSummary(path83, index, workingDir));
|
|
43510
43305
|
}
|
|
43511
43306
|
}
|
|
43512
43307
|
}
|
|
@@ -43815,9 +43610,9 @@ var init_simple_git_api = __esm2({
|
|
|
43815
43610
|
next
|
|
43816
43611
|
);
|
|
43817
43612
|
}
|
|
43818
|
-
hashObject(
|
|
43613
|
+
hashObject(path83, write) {
|
|
43819
43614
|
return this._runTask(
|
|
43820
|
-
hashObjectTask(
|
|
43615
|
+
hashObjectTask(path83, write === true),
|
|
43821
43616
|
trailingFunctionArgument(arguments)
|
|
43822
43617
|
);
|
|
43823
43618
|
}
|
|
@@ -44170,8 +43965,8 @@ var init_branch = __esm2({
|
|
|
44170
43965
|
}
|
|
44171
43966
|
});
|
|
44172
43967
|
function toPath(input) {
|
|
44173
|
-
const
|
|
44174
|
-
return
|
|
43968
|
+
const path83 = input.trim().replace(/^["']|["']$/g, "");
|
|
43969
|
+
return path83 && normalize3(path83);
|
|
44175
43970
|
}
|
|
44176
43971
|
var parseCheckIgnore;
|
|
44177
43972
|
var init_CheckIgnore = __esm2({
|
|
@@ -44485,8 +44280,8 @@ __export2(sub_module_exports, {
|
|
|
44485
44280
|
subModuleTask: () => subModuleTask,
|
|
44486
44281
|
updateSubModuleTask: () => updateSubModuleTask
|
|
44487
44282
|
});
|
|
44488
|
-
function addSubModuleTask(repo,
|
|
44489
|
-
return subModuleTask(["add", repo,
|
|
44283
|
+
function addSubModuleTask(repo, path83) {
|
|
44284
|
+
return subModuleTask(["add", repo, path83]);
|
|
44490
44285
|
}
|
|
44491
44286
|
function initSubModuleTask(customArgs) {
|
|
44492
44287
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -44819,8 +44614,8 @@ var require_git = __commonJS2({
|
|
|
44819
44614
|
}
|
|
44820
44615
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
44821
44616
|
};
|
|
44822
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
44823
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
44617
|
+
Git2.prototype.submoduleAdd = function(repo, path83, then) {
|
|
44618
|
+
return this._runTask(addSubModuleTask2(repo, path83), trailingFunctionArgument2(arguments));
|
|
44824
44619
|
};
|
|
44825
44620
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
44826
44621
|
return this._runTask(
|
|
@@ -45559,8 +45354,8 @@ function parseNumstatEntries(lines) {
|
|
|
45559
45354
|
}
|
|
45560
45355
|
function parseNumstat(lines) {
|
|
45561
45356
|
const m = /* @__PURE__ */ new Map();
|
|
45562
|
-
for (const [
|
|
45563
|
-
m.set(
|
|
45357
|
+
for (const [path83, entry] of parseNumstatEntries(lines)) {
|
|
45358
|
+
m.set(path83, { additions: entry.additions, deletions: entry.deletions });
|
|
45564
45359
|
}
|
|
45565
45360
|
return m;
|
|
45566
45361
|
}
|
|
@@ -45689,7 +45484,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
|
|
|
45689
45484
|
}
|
|
45690
45485
|
|
|
45691
45486
|
// ../bridge/src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
|
|
45692
|
-
import * as
|
|
45487
|
+
import * as path38 from "node:path";
|
|
45693
45488
|
var BASE_SHA_CACHE_TTL_MS = 3e4;
|
|
45694
45489
|
var baseShaCache = /* @__PURE__ */ new Map();
|
|
45695
45490
|
async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
@@ -45700,7 +45495,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
|
|
|
45700
45495
|
}
|
|
45701
45496
|
async function resolveBaseShaForUnpushedCommits(g, repoDir) {
|
|
45702
45497
|
if (repoDir) {
|
|
45703
|
-
const key =
|
|
45498
|
+
const key = path38.resolve(repoDir);
|
|
45704
45499
|
const now = Date.now();
|
|
45705
45500
|
const cached2 = baseShaCache.get(key);
|
|
45706
45501
|
if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
|
|
@@ -45835,17 +45630,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
|
|
|
45835
45630
|
}
|
|
45836
45631
|
|
|
45837
45632
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
45838
|
-
import * as
|
|
45633
|
+
import * as path48 from "node:path";
|
|
45839
45634
|
|
|
45840
45635
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
45841
|
-
import * as
|
|
45636
|
+
import * as path47 from "node:path";
|
|
45842
45637
|
|
|
45843
45638
|
// ../bridge/src/git/is-git-repo.ts
|
|
45844
|
-
import * as
|
|
45845
|
-
import * as
|
|
45639
|
+
import * as fs25 from "node:fs";
|
|
45640
|
+
import * as path39 from "node:path";
|
|
45846
45641
|
async function isGitRepoDirectory(dirPath) {
|
|
45847
45642
|
try {
|
|
45848
|
-
await
|
|
45643
|
+
await fs25.promises.access(path39.join(dirPath, ".git"));
|
|
45849
45644
|
return true;
|
|
45850
45645
|
} catch {
|
|
45851
45646
|
return false;
|
|
@@ -45853,8 +45648,8 @@ async function isGitRepoDirectory(dirPath) {
|
|
|
45853
45648
|
}
|
|
45854
45649
|
|
|
45855
45650
|
// ../bridge/src/git/changes/listing/apply-untracked-file-stats.ts
|
|
45856
|
-
import * as
|
|
45857
|
-
import * as
|
|
45651
|
+
import * as fs26 from "node:fs";
|
|
45652
|
+
import * as path40 from "node:path";
|
|
45858
45653
|
|
|
45859
45654
|
// ../bridge/src/git/changes/lines/count-lines.ts
|
|
45860
45655
|
import { createReadStream } from "node:fs";
|
|
@@ -45886,7 +45681,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
45886
45681
|
if (!options.untrackedSet.has(pathInRepo)) return;
|
|
45887
45682
|
if (options.nameByPath.has(pathInRepo)) return;
|
|
45888
45683
|
if (row.change === "moved") return;
|
|
45889
|
-
const repoFilePath =
|
|
45684
|
+
const repoFilePath = path40.join(options.repoGitCwd, pathInRepo);
|
|
45890
45685
|
const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
|
|
45891
45686
|
if (fromGit) {
|
|
45892
45687
|
row.additions = fromGit.additions;
|
|
@@ -45894,7 +45689,7 @@ function createUntrackedStatsApplier(options) {
|
|
|
45894
45689
|
return;
|
|
45895
45690
|
}
|
|
45896
45691
|
try {
|
|
45897
|
-
const st = await
|
|
45692
|
+
const st = await fs26.promises.stat(repoFilePath);
|
|
45898
45693
|
row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
|
|
45899
45694
|
} catch {
|
|
45900
45695
|
row.additions = 0;
|
|
@@ -45971,7 +45766,7 @@ async function buildChangedFileRowsFromPaths(options) {
|
|
|
45971
45766
|
}
|
|
45972
45767
|
|
|
45973
45768
|
// ../bridge/src/git/changes/listing/enrich-working-tree-file-rows.ts
|
|
45974
|
-
import * as
|
|
45769
|
+
import * as path42 from "node:path";
|
|
45975
45770
|
|
|
45976
45771
|
// ../bridge/src/git/changes/patch/patch-truncate.ts
|
|
45977
45772
|
function truncatePatch(s) {
|
|
@@ -46059,10 +45854,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
|
|
|
46059
45854
|
}
|
|
46060
45855
|
|
|
46061
45856
|
// ../bridge/src/git/changes/patch/hydrate/read-worktree-file-lines.ts
|
|
46062
|
-
import * as
|
|
45857
|
+
import * as fs27 from "node:fs";
|
|
46063
45858
|
async function readWorktreeFileLines(filePath) {
|
|
46064
45859
|
try {
|
|
46065
|
-
const raw = await
|
|
45860
|
+
const raw = await fs27.promises.readFile(filePath, "utf8");
|
|
46066
45861
|
return raw.split(/\r?\n/);
|
|
46067
45862
|
} catch {
|
|
46068
45863
|
return null;
|
|
@@ -46200,8 +45995,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
|
|
|
46200
45995
|
}
|
|
46201
45996
|
|
|
46202
45997
|
// ../bridge/src/git/changes/total-lines/resolve-changed-file-total-lines.ts
|
|
46203
|
-
import * as
|
|
46204
|
-
import * as
|
|
45998
|
+
import * as fs28 from "node:fs";
|
|
45999
|
+
import * as path41 from "node:path";
|
|
46205
46000
|
var MAX_BYTES = 512e3;
|
|
46206
46001
|
async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
46207
46002
|
const spec = `${ref}:${pathInRepo}`;
|
|
@@ -46221,13 +46016,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
|
|
|
46221
46016
|
}
|
|
46222
46017
|
async function resolveWorkingTreeFileTotalLines(options) {
|
|
46223
46018
|
if (options.isBinary) return null;
|
|
46224
|
-
const filePath =
|
|
46019
|
+
const filePath = path41.join(options.repoGitCwd, options.pathInRepo);
|
|
46225
46020
|
if (options.change === "removed") {
|
|
46226
46021
|
return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
|
|
46227
46022
|
}
|
|
46228
46023
|
if (options.change === "moved" || options.change === "modified") {
|
|
46229
46024
|
try {
|
|
46230
|
-
const st = await
|
|
46025
|
+
const st = await fs28.promises.stat(filePath);
|
|
46231
46026
|
if (!st.isFile()) return null;
|
|
46232
46027
|
return await countTextFileLines(filePath);
|
|
46233
46028
|
} catch {
|
|
@@ -46270,7 +46065,7 @@ async function enrichWorkingTreeFileRows(options) {
|
|
|
46270
46065
|
row.workspaceRelPath,
|
|
46271
46066
|
options.repoPathRelativeToWorkspaceRoot
|
|
46272
46067
|
);
|
|
46273
|
-
const filePath =
|
|
46068
|
+
const filePath = path42.join(options.repoGitCwd, filePathRelativeToRepoRoot);
|
|
46274
46069
|
const hydrateKind = row.change === "moved" ? "modified" : row.change;
|
|
46275
46070
|
let patch = await unifiedDiffForFile(
|
|
46276
46071
|
options.repoGitCwd,
|
|
@@ -46428,7 +46223,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
|
|
|
46428
46223
|
}
|
|
46429
46224
|
|
|
46430
46225
|
// ../bridge/src/git/changes/listing/list-changed-files-for-commit.ts
|
|
46431
|
-
import * as
|
|
46226
|
+
import * as path43 from "node:path";
|
|
46432
46227
|
|
|
46433
46228
|
// ../bridge/src/git/changes/listing/enrich-commit-file-rows.ts
|
|
46434
46229
|
async function enrichCommitFileRows(options) {
|
|
@@ -46473,7 +46268,7 @@ async function parentForCommitDiff(g, sha) {
|
|
|
46473
46268
|
var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
|
|
46474
46269
|
var commitFilesCache = /* @__PURE__ */ new Map();
|
|
46475
46270
|
function commitFilesCacheKey(repoGitCwd, commitSha) {
|
|
46476
|
-
return `${
|
|
46271
|
+
return `${path43.resolve(repoGitCwd)}:${commitSha}`;
|
|
46477
46272
|
}
|
|
46478
46273
|
async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
|
|
46479
46274
|
const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
|
|
@@ -46528,7 +46323,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
|
|
|
46528
46323
|
}
|
|
46529
46324
|
|
|
46530
46325
|
// ../bridge/src/git/commits/list-unpushed-commits.ts
|
|
46531
|
-
import * as
|
|
46326
|
+
import * as path44 from "node:path";
|
|
46532
46327
|
|
|
46533
46328
|
// ../bridge/src/git/commits/lib/parse-log-lines.ts
|
|
46534
46329
|
function parseLogShaDateSubjectLines(raw) {
|
|
@@ -46563,7 +46358,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
|
|
|
46563
46358
|
}
|
|
46564
46359
|
}
|
|
46565
46360
|
async function listUnpushedCommits(repoDir) {
|
|
46566
|
-
const key =
|
|
46361
|
+
const key = path44.resolve(repoDir);
|
|
46567
46362
|
const now = Date.now();
|
|
46568
46363
|
const cached2 = unpushedCache.get(key);
|
|
46569
46364
|
if (cached2 && cached2.expiresAt > now) return cached2.commits;
|
|
@@ -46624,7 +46419,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
|
|
|
46624
46419
|
}
|
|
46625
46420
|
|
|
46626
46421
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
46627
|
-
import * as
|
|
46422
|
+
import * as path45 from "node:path";
|
|
46628
46423
|
|
|
46629
46424
|
// ../bridge/src/git/remote-origin-url.ts
|
|
46630
46425
|
async function getRemoteOriginUrl(gitDir) {
|
|
@@ -46639,7 +46434,7 @@ async function getRemoteOriginUrl(gitDir) {
|
|
|
46639
46434
|
|
|
46640
46435
|
// ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
|
|
46641
46436
|
async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
46642
|
-
const resolvedCheckoutPath =
|
|
46437
|
+
const resolvedCheckoutPath = path45.resolve(checkoutPath);
|
|
46643
46438
|
const git = cliSimpleGit(resolvedCheckoutPath);
|
|
46644
46439
|
await yieldToEventLoop2();
|
|
46645
46440
|
const [branch, remoteUrl] = await Promise.all([
|
|
@@ -46654,14 +46449,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
|
|
|
46654
46449
|
}
|
|
46655
46450
|
|
|
46656
46451
|
// ../bridge/src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
|
|
46657
|
-
import * as
|
|
46452
|
+
import * as path46 from "node:path";
|
|
46658
46453
|
async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
46659
|
-
const checkoutPath =
|
|
46454
|
+
const checkoutPath = path46.resolve(options.checkoutPath);
|
|
46660
46455
|
const git = cliSimpleGit(checkoutPath);
|
|
46661
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46456
|
+
const sessionParentPath = options.sessionParentPath ? path46.resolve(options.sessionParentPath) : null;
|
|
46662
46457
|
let repoPathRelativeToWorkspaceRoot;
|
|
46663
46458
|
if (sessionParentPath) {
|
|
46664
|
-
const checkoutPathRelativeToSessionParent =
|
|
46459
|
+
const checkoutPathRelativeToSessionParent = path46.relative(sessionParentPath, checkoutPath);
|
|
46665
46460
|
repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
|
|
46666
46461
|
} else {
|
|
46667
46462
|
let gitTopLevel = checkoutPath;
|
|
@@ -46671,8 +46466,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
46671
46466
|
} catch {
|
|
46672
46467
|
gitTopLevel = checkoutPath;
|
|
46673
46468
|
}
|
|
46674
|
-
const gitTopLevelRelativeToBridgeRoot =
|
|
46675
|
-
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ?
|
|
46469
|
+
const gitTopLevelRelativeToBridgeRoot = path46.relative(options.bridgeRoot, path46.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
|
|
46470
|
+
repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path46.basename(path46.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
|
|
46676
46471
|
}
|
|
46677
46472
|
return normalizeRepoPathRelativeToWorkspaceRoot(
|
|
46678
46473
|
repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
|
|
@@ -46681,10 +46476,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
|
|
|
46681
46476
|
|
|
46682
46477
|
// ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
|
|
46683
46478
|
async function buildWorkingTreeChangeRepoDetail(options) {
|
|
46684
|
-
const checkoutPath =
|
|
46479
|
+
const checkoutPath = path47.resolve(options.targetPath);
|
|
46685
46480
|
if (!await isGitRepoDirectory(checkoutPath)) return null;
|
|
46686
46481
|
const isCommitView = options.basis.kind === "commit";
|
|
46687
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46482
|
+
const sessionParentPath = options.sessionParentPath ? path47.resolve(options.sessionParentPath) : null;
|
|
46688
46483
|
const git = cliSimpleGit(checkoutPath);
|
|
46689
46484
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
46690
46485
|
checkoutPath,
|
|
@@ -46732,8 +46527,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
|
|
|
46732
46527
|
|
|
46733
46528
|
// ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
|
|
46734
46529
|
async function getWorkingTreeChangeRepoDetails(options) {
|
|
46735
|
-
const bridgeRoot =
|
|
46736
|
-
const sessionParentPath = options.sessionParentPath ?
|
|
46530
|
+
const bridgeRoot = path48.resolve(getBridgeRoot());
|
|
46531
|
+
const sessionParentPath = options.sessionParentPath ? path48.resolve(options.sessionParentPath) : null;
|
|
46737
46532
|
const out = [];
|
|
46738
46533
|
const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
|
|
46739
46534
|
const basisInput = options.basis ?? { kind: "working" };
|
|
@@ -46764,9 +46559,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
|
|
|
46764
46559
|
}
|
|
46765
46560
|
|
|
46766
46561
|
// ../bridge/src/git/changes/repo/get-working-tree-change-file-patch.ts
|
|
46767
|
-
import * as
|
|
46562
|
+
import * as path49 from "node:path";
|
|
46768
46563
|
async function getWorkingTreeChangeFilePatch(options) {
|
|
46769
|
-
const repoGitCwd =
|
|
46564
|
+
const repoGitCwd = path49.resolve(options.repoGitCwd);
|
|
46770
46565
|
if (!await isGitRepoDirectory(repoGitCwd)) {
|
|
46771
46566
|
throw new Error("Not a git repository");
|
|
46772
46567
|
}
|
|
@@ -46805,7 +46600,7 @@ async function getWorkingTreeChangeFilePatch(options) {
|
|
|
46805
46600
|
});
|
|
46806
46601
|
return { patchContent: patchContent2, totalLines: totalLines2 };
|
|
46807
46602
|
}
|
|
46808
|
-
const filePath =
|
|
46603
|
+
const filePath = path49.join(repoGitCwd, filePathRelativeToRepoRoot);
|
|
46809
46604
|
const hydrateKind = options.change === "moved" ? "modified" : options.change;
|
|
46810
46605
|
let patchContent = await unifiedDiffForFile(
|
|
46811
46606
|
repoGitCwd,
|
|
@@ -46851,18 +46646,18 @@ function parseWorkingTreeChangeKind(value) {
|
|
|
46851
46646
|
}
|
|
46852
46647
|
|
|
46853
46648
|
// ../bridge/src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
|
|
46854
|
-
import * as
|
|
46649
|
+
import * as path50 from "node:path";
|
|
46855
46650
|
async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
|
|
46856
46651
|
const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
|
|
46857
|
-
const bridgeRoot =
|
|
46858
|
-
const sessionParentPath = cache2.getSessionParentPath(sessionId) ?
|
|
46652
|
+
const bridgeRoot = path50.resolve(getBridgeRoot());
|
|
46653
|
+
const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path50.resolve(cache2.getSessionParentPath(sessionId)) : null;
|
|
46859
46654
|
const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
46860
46655
|
opts.repoRelPath.trim()
|
|
46861
46656
|
);
|
|
46862
46657
|
let result = null;
|
|
46863
46658
|
await forEachWithGitYield(targets, async (targetPath) => {
|
|
46864
46659
|
if (result) return;
|
|
46865
|
-
const checkoutPath =
|
|
46660
|
+
const checkoutPath = path50.resolve(targetPath);
|
|
46866
46661
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
46867
46662
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
46868
46663
|
checkoutPath,
|
|
@@ -46895,13 +46690,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
|
|
|
46895
46690
|
}
|
|
46896
46691
|
|
|
46897
46692
|
// ../bridge/src/worktrees/remove-session-worktrees.ts
|
|
46898
|
-
import * as
|
|
46693
|
+
import * as fs31 from "node:fs";
|
|
46899
46694
|
|
|
46900
46695
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
46901
|
-
import * as
|
|
46696
|
+
import * as fs30 from "node:fs";
|
|
46902
46697
|
|
|
46903
46698
|
// ../bridge/src/worktrees/is-removable-session-worktree-checkout-path.ts
|
|
46904
|
-
import
|
|
46699
|
+
import path51 from "node:path";
|
|
46905
46700
|
init_normalize_resolved_path();
|
|
46906
46701
|
function isBridgeRootCheckoutPath(checkoutPath) {
|
|
46907
46702
|
return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
|
|
@@ -46910,23 +46705,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
|
|
|
46910
46705
|
if (isBridgeRootCheckoutPath(checkoutPath)) return false;
|
|
46911
46706
|
const normalized = normalizeResolvedPath(checkoutPath);
|
|
46912
46707
|
const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
|
|
46913
|
-
const rel =
|
|
46914
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
46708
|
+
const rel = path51.relative(worktreesRoot, normalized);
|
|
46709
|
+
if (rel === "" || rel.startsWith("..") || path51.isAbsolute(rel)) return false;
|
|
46915
46710
|
return true;
|
|
46916
46711
|
}
|
|
46917
46712
|
|
|
46918
46713
|
// ../bridge/src/git/worktrees/resolve-main-repo-from-git-file.ts
|
|
46919
|
-
import * as
|
|
46920
|
-
import * as
|
|
46714
|
+
import * as fs29 from "node:fs";
|
|
46715
|
+
import * as path52 from "node:path";
|
|
46921
46716
|
function resolveMainRepoFromWorktreeGitFile(wt) {
|
|
46922
|
-
const gitDirFile =
|
|
46923
|
-
if (!
|
|
46924
|
-
const first2 =
|
|
46717
|
+
const gitDirFile = path52.join(wt, ".git");
|
|
46718
|
+
if (!fs29.existsSync(gitDirFile) || !fs29.statSync(gitDirFile).isFile()) return "";
|
|
46719
|
+
const first2 = fs29.readFileSync(gitDirFile, "utf8").trim();
|
|
46925
46720
|
const m = first2.match(/^gitdir:\s*(.+)$/im);
|
|
46926
46721
|
if (!m) return "";
|
|
46927
|
-
const gitWorktreePath =
|
|
46928
|
-
const gitDir =
|
|
46929
|
-
return
|
|
46722
|
+
const gitWorktreePath = path52.resolve(wt, m[1].trim());
|
|
46723
|
+
const gitDir = path52.dirname(path52.dirname(gitWorktreePath));
|
|
46724
|
+
return path52.dirname(gitDir);
|
|
46930
46725
|
}
|
|
46931
46726
|
|
|
46932
46727
|
// ../bridge/src/git/worktrees/worktree-remove.ts
|
|
@@ -46937,7 +46732,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
|
|
|
46937
46732
|
return true;
|
|
46938
46733
|
}
|
|
46939
46734
|
if (isBridgeRootCheckoutPath(worktreePath)) return false;
|
|
46940
|
-
|
|
46735
|
+
fs30.rmSync(worktreePath, { recursive: true, force: true });
|
|
46941
46736
|
return true;
|
|
46942
46737
|
}
|
|
46943
46738
|
|
|
@@ -46959,7 +46754,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
|
|
|
46959
46754
|
log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
|
|
46960
46755
|
if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
|
|
46961
46756
|
try {
|
|
46962
|
-
|
|
46757
|
+
fs31.rmSync(wt, { recursive: true, force: true });
|
|
46963
46758
|
} catch {
|
|
46964
46759
|
}
|
|
46965
46760
|
}
|
|
@@ -47015,12 +46810,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
|
|
|
47015
46810
|
// ../bridge/src/worktrees/discovery/discover-session-worktree-on-disk.ts
|
|
47016
46811
|
init_cli_process_interrupt();
|
|
47017
46812
|
init_yield_to_event_loop();
|
|
47018
|
-
import * as
|
|
47019
|
-
import * as
|
|
46813
|
+
import * as fs35 from "node:fs";
|
|
46814
|
+
import * as path57 from "node:path";
|
|
47020
46815
|
|
|
47021
46816
|
// ../bridge/src/worktrees/discovery/collect-worktree-paths.ts
|
|
47022
|
-
import * as
|
|
47023
|
-
import * as
|
|
46817
|
+
import * as fs33 from "node:fs";
|
|
46818
|
+
import * as path54 from "node:path";
|
|
47024
46819
|
|
|
47025
46820
|
// ../bridge/src/worktrees/discovery/disk-walk-constants.ts
|
|
47026
46821
|
var DISK_WALK_YIELD_EVERY = 64;
|
|
@@ -47050,8 +46845,8 @@ function shouldSkipDiskWalkEntry(name) {
|
|
|
47050
46845
|
// ../bridge/src/worktrees/discovery/disk-walk-utils.ts
|
|
47051
46846
|
init_cli_process_interrupt();
|
|
47052
46847
|
init_yield_to_event_loop();
|
|
47053
|
-
import * as
|
|
47054
|
-
import * as
|
|
46848
|
+
import * as fs32 from "node:fs";
|
|
46849
|
+
import * as path53 from "node:path";
|
|
47055
46850
|
async function yieldDuringDiskWalk(state) {
|
|
47056
46851
|
state.entries++;
|
|
47057
46852
|
if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
|
|
@@ -47061,7 +46856,7 @@ async function yieldDuringDiskWalk(state) {
|
|
|
47061
46856
|
}
|
|
47062
46857
|
async function isGitDir(dirPath) {
|
|
47063
46858
|
try {
|
|
47064
|
-
await
|
|
46859
|
+
await fs32.promises.access(path53.join(dirPath, ".git"));
|
|
47065
46860
|
return true;
|
|
47066
46861
|
} catch {
|
|
47067
46862
|
return false;
|
|
@@ -47075,23 +46870,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
|
|
|
47075
46870
|
const walk = async (dir) => {
|
|
47076
46871
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
47077
46872
|
if (await isGitDir(dir)) {
|
|
47078
|
-
out.push(
|
|
46873
|
+
out.push(path54.resolve(dir));
|
|
47079
46874
|
return;
|
|
47080
46875
|
}
|
|
47081
46876
|
let entries;
|
|
47082
46877
|
try {
|
|
47083
|
-
entries = await
|
|
46878
|
+
entries = await fs33.promises.readdir(dir, { withFileTypes: true });
|
|
47084
46879
|
} catch {
|
|
47085
46880
|
return;
|
|
47086
46881
|
}
|
|
47087
46882
|
for (const e of entries) {
|
|
47088
46883
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
47089
|
-
const full =
|
|
46884
|
+
const full = path54.join(dir, e.name);
|
|
47090
46885
|
if (!e.isDirectory()) continue;
|
|
47091
46886
|
await walk(full);
|
|
47092
46887
|
}
|
|
47093
46888
|
};
|
|
47094
|
-
await walk(
|
|
46889
|
+
await walk(path54.resolve(rootPath));
|
|
47095
46890
|
return { paths: [...new Set(out)], entriesVisited: state.entries };
|
|
47096
46891
|
}
|
|
47097
46892
|
async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
|
|
@@ -47102,16 +46897,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
47102
46897
|
if (!await yieldDuringDiskWalk(state)) return;
|
|
47103
46898
|
let entries;
|
|
47104
46899
|
try {
|
|
47105
|
-
entries = await
|
|
46900
|
+
entries = await fs33.promises.readdir(dir, { withFileTypes: true });
|
|
47106
46901
|
} catch {
|
|
47107
46902
|
return;
|
|
47108
46903
|
}
|
|
47109
46904
|
for (const e of entries) {
|
|
47110
46905
|
if (shouldSkipDiskWalkEntry(e.name)) continue;
|
|
47111
|
-
const full =
|
|
46906
|
+
const full = path54.join(dir, e.name);
|
|
47112
46907
|
if (!e.isDirectory()) continue;
|
|
47113
46908
|
if (e.name === sessionId) {
|
|
47114
|
-
if (await isGitDir(full)) out.push(
|
|
46909
|
+
if (await isGitDir(full)) out.push(path54.resolve(full));
|
|
47115
46910
|
continue;
|
|
47116
46911
|
}
|
|
47117
46912
|
if (await isGitDir(full)) continue;
|
|
@@ -47123,14 +46918,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
|
|
|
47123
46918
|
}
|
|
47124
46919
|
|
|
47125
46920
|
// ../bridge/src/worktrees/discovery/layout-keys-for-bridge-root.ts
|
|
47126
|
-
import * as
|
|
46921
|
+
import * as path55 from "node:path";
|
|
47127
46922
|
function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
47128
|
-
const bridge =
|
|
46923
|
+
const bridge = path55.resolve(bridgeRoot);
|
|
47129
46924
|
const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
|
|
47130
46925
|
const relevant = layout.launcherCwds.filter((e) => {
|
|
47131
|
-
const entry =
|
|
47132
|
-
return bridge === entry || bridge.startsWith(entry +
|
|
47133
|
-
}).sort((a, b) =>
|
|
46926
|
+
const entry = path55.resolve(e.absolutePath);
|
|
46927
|
+
return bridge === entry || bridge.startsWith(entry + path55.sep) || entry.startsWith(bridge + path55.sep);
|
|
46928
|
+
}).sort((a, b) => path55.resolve(b.absolutePath).length - path55.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
|
|
47134
46929
|
const ordered = [];
|
|
47135
46930
|
const seen = /* @__PURE__ */ new Set();
|
|
47136
46931
|
const add = (k) => {
|
|
@@ -47148,19 +46943,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
|
|
|
47148
46943
|
}
|
|
47149
46944
|
|
|
47150
46945
|
// ../bridge/src/worktrees/discovery/try-binding-from-isolated-directory.ts
|
|
47151
|
-
import * as
|
|
47152
|
-
import * as
|
|
46946
|
+
import * as fs34 from "node:fs";
|
|
46947
|
+
import * as path56 from "node:path";
|
|
47153
46948
|
async function tryBindingFromIsolatedDirectory(scopeDir) {
|
|
47154
46949
|
let st;
|
|
47155
46950
|
try {
|
|
47156
|
-
st = await
|
|
46951
|
+
st = await fs34.promises.stat(scopeDir);
|
|
47157
46952
|
} catch {
|
|
47158
46953
|
return null;
|
|
47159
46954
|
}
|
|
47160
46955
|
if (!st.isDirectory()) return null;
|
|
47161
46956
|
const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
|
|
47162
46957
|
if (worktreePaths.length === 0) return null;
|
|
47163
|
-
const abs =
|
|
46958
|
+
const abs = path56.resolve(scopeDir);
|
|
47164
46959
|
return {
|
|
47165
46960
|
parentPath: abs,
|
|
47166
46961
|
repoCheckoutPaths: worktreePaths
|
|
@@ -47183,7 +46978,7 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47183
46978
|
const sid = sessionId.trim();
|
|
47184
46979
|
if (!sid) return null;
|
|
47185
46980
|
try {
|
|
47186
|
-
await
|
|
46981
|
+
await fs35.promises.access(worktreesRootPath);
|
|
47187
46982
|
} catch {
|
|
47188
46983
|
return null;
|
|
47189
46984
|
}
|
|
@@ -47192,13 +46987,13 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47192
46987
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
47193
46988
|
const scanState = { entries: 0 };
|
|
47194
46989
|
try {
|
|
47195
|
-
for (const name of await
|
|
46990
|
+
for (const name of await fs35.promises.readdir(worktreesRootPath)) {
|
|
47196
46991
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
47197
46992
|
if (name.startsWith(".")) continue;
|
|
47198
|
-
const p =
|
|
46993
|
+
const p = path57.join(worktreesRootPath, name);
|
|
47199
46994
|
let st;
|
|
47200
46995
|
try {
|
|
47201
|
-
st = await
|
|
46996
|
+
st = await fs35.promises.stat(p);
|
|
47202
46997
|
} catch {
|
|
47203
46998
|
continue;
|
|
47204
46999
|
}
|
|
@@ -47212,23 +47007,23 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47212
47007
|
for (const key of keys) {
|
|
47213
47008
|
if (isCliImmediateShutdownRequested()) return null;
|
|
47214
47009
|
await yieldToEventLoop();
|
|
47215
|
-
const layoutRoot =
|
|
47010
|
+
const layoutRoot = path57.join(worktreesRootPath, key);
|
|
47216
47011
|
let layoutSt;
|
|
47217
47012
|
try {
|
|
47218
|
-
layoutSt = await
|
|
47013
|
+
layoutSt = await fs35.promises.stat(layoutRoot);
|
|
47219
47014
|
} catch {
|
|
47220
47015
|
continue;
|
|
47221
47016
|
}
|
|
47222
47017
|
if (!layoutSt.isDirectory()) continue;
|
|
47223
|
-
const sessionDir =
|
|
47018
|
+
const sessionDir = path57.join(layoutRoot, sid);
|
|
47224
47019
|
const nested = await tryBindingFromSessionDirectory(sessionDir);
|
|
47225
47020
|
if (nested) return nested;
|
|
47226
47021
|
const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
|
|
47227
47022
|
if (legacy.paths.length > 0) {
|
|
47228
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ??
|
|
47023
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path57.resolve(legacy.paths[0]);
|
|
47229
47024
|
return {
|
|
47230
|
-
sessionParentPath:
|
|
47231
|
-
repoCheckoutPaths: legacy.paths.map((p) =>
|
|
47025
|
+
sessionParentPath: path57.resolve(isolated),
|
|
47026
|
+
repoCheckoutPaths: legacy.paths.map((p) => path57.resolve(p))
|
|
47232
47027
|
};
|
|
47233
47028
|
}
|
|
47234
47029
|
}
|
|
@@ -47236,31 +47031,31 @@ async function discoverSessionWorktreeOnDisk(options) {
|
|
|
47236
47031
|
}
|
|
47237
47032
|
|
|
47238
47033
|
// ../bridge/src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
|
|
47239
|
-
import * as
|
|
47240
|
-
import * as
|
|
47034
|
+
import * as fs36 from "node:fs";
|
|
47035
|
+
import * as path59 from "node:path";
|
|
47241
47036
|
|
|
47242
47037
|
// ../bridge/src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
|
|
47243
47038
|
init_cli_process_interrupt();
|
|
47244
47039
|
init_yield_to_event_loop();
|
|
47245
|
-
import * as
|
|
47040
|
+
import * as path58 from "node:path";
|
|
47246
47041
|
async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
|
|
47247
47042
|
const sid = sessionId.trim();
|
|
47248
47043
|
if (!sid) return null;
|
|
47249
|
-
const hintR =
|
|
47044
|
+
const hintR = path58.resolve(checkoutPath);
|
|
47250
47045
|
let best = null;
|
|
47251
|
-
let cur =
|
|
47046
|
+
let cur = path58.dirname(hintR);
|
|
47252
47047
|
for (let i = 0; i < 40; i++) {
|
|
47253
47048
|
if (isCliImmediateShutdownRequested()) return best;
|
|
47254
47049
|
await yieldToEventLoop();
|
|
47255
47050
|
const paths = await collectWorktreeRootsNamed(cur, sid);
|
|
47256
|
-
if (paths.paths.some((p) =>
|
|
47257
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ??
|
|
47051
|
+
if (paths.paths.some((p) => path58.resolve(p) === hintR)) {
|
|
47052
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path58.resolve(paths.paths[0]);
|
|
47258
47053
|
best = {
|
|
47259
|
-
sessionParentPath:
|
|
47260
|
-
repoCheckoutPaths: paths.paths.map((p) =>
|
|
47054
|
+
sessionParentPath: path58.resolve(isolated),
|
|
47055
|
+
repoCheckoutPaths: paths.paths.map((p) => path58.resolve(p))
|
|
47261
47056
|
};
|
|
47262
47057
|
}
|
|
47263
|
-
const next =
|
|
47058
|
+
const next = path58.dirname(cur);
|
|
47264
47059
|
if (next === cur) break;
|
|
47265
47060
|
cur = next;
|
|
47266
47061
|
}
|
|
@@ -47271,12 +47066,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
|
|
|
47271
47066
|
async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
|
|
47272
47067
|
const sid = sessionId.trim();
|
|
47273
47068
|
if (!sid) return null;
|
|
47274
|
-
const hint =
|
|
47275
|
-
const underHint = await tryBindingFromSessionDirectory(
|
|
47069
|
+
const hint = path59.resolve(sessionParentPathOrHint);
|
|
47070
|
+
const underHint = await tryBindingFromSessionDirectory(path59.join(hint, sid));
|
|
47276
47071
|
if (underHint) return underHint;
|
|
47277
47072
|
const direct = await tryBindingFromSessionDirectory(hint);
|
|
47278
47073
|
if (direct) {
|
|
47279
|
-
if (
|
|
47074
|
+
if (path59.basename(hint) === sid && await isGitDir(hint)) {
|
|
47280
47075
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
47281
47076
|
if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
|
|
47282
47077
|
return legacyFromCheckout;
|
|
@@ -47284,23 +47079,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
|
|
|
47284
47079
|
}
|
|
47285
47080
|
return direct;
|
|
47286
47081
|
}
|
|
47287
|
-
if (
|
|
47082
|
+
if (path59.basename(hint) === sid && await isGitDir(hint)) {
|
|
47288
47083
|
const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
|
|
47289
47084
|
if (legacyFromCheckout) return legacyFromCheckout;
|
|
47290
47085
|
}
|
|
47291
47086
|
let st;
|
|
47292
47087
|
try {
|
|
47293
|
-
st = await
|
|
47088
|
+
st = await fs36.promises.stat(hint);
|
|
47294
47089
|
} catch {
|
|
47295
47090
|
return null;
|
|
47296
47091
|
}
|
|
47297
47092
|
if (!st.isDirectory()) return null;
|
|
47298
47093
|
const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
|
|
47299
47094
|
if (legacyPaths.paths.length === 0) return null;
|
|
47300
|
-
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ??
|
|
47095
|
+
const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path59.resolve(legacyPaths.paths[0]);
|
|
47301
47096
|
return {
|
|
47302
|
-
sessionParentPath:
|
|
47303
|
-
repoCheckoutPaths: legacyPaths.paths.map((p) =>
|
|
47097
|
+
sessionParentPath: path59.resolve(isolated),
|
|
47098
|
+
repoCheckoutPaths: legacyPaths.paths.map((p) => path59.resolve(p))
|
|
47304
47099
|
};
|
|
47305
47100
|
}
|
|
47306
47101
|
|
|
@@ -47361,11 +47156,11 @@ function parseSessionParent(v) {
|
|
|
47361
47156
|
}
|
|
47362
47157
|
|
|
47363
47158
|
// ../bridge/src/worktrees/prepare/prepare-new-isolated-worktrees.ts
|
|
47364
|
-
import * as
|
|
47159
|
+
import * as fs40 from "node:fs";
|
|
47365
47160
|
|
|
47366
47161
|
// ../bridge/src/git/discover-repos.ts
|
|
47367
|
-
import * as
|
|
47368
|
-
import * as
|
|
47162
|
+
import * as fs37 from "node:fs";
|
|
47163
|
+
import * as path60 from "node:path";
|
|
47369
47164
|
init_yield_to_event_loop();
|
|
47370
47165
|
var GIT_DISCOVER_YIELD_EVERY = 32;
|
|
47371
47166
|
async function yieldGitDiscoverWork(entryCount) {
|
|
@@ -47375,14 +47170,14 @@ async function yieldGitDiscoverWork(entryCount) {
|
|
|
47375
47170
|
}
|
|
47376
47171
|
async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
47377
47172
|
const result = [];
|
|
47378
|
-
const cwdResolved =
|
|
47173
|
+
const cwdResolved = path60.resolve(cwd);
|
|
47379
47174
|
if (await isGitRepoDirectory(cwdResolved)) {
|
|
47380
47175
|
const remoteUrl = await getRemoteOriginUrl(cwdResolved);
|
|
47381
47176
|
result.push({ absolutePath: cwdResolved, remoteUrl });
|
|
47382
47177
|
}
|
|
47383
47178
|
let entries;
|
|
47384
47179
|
try {
|
|
47385
|
-
entries =
|
|
47180
|
+
entries = fs37.readdirSync(cwdResolved, { withFileTypes: true });
|
|
47386
47181
|
} catch {
|
|
47387
47182
|
return result;
|
|
47388
47183
|
}
|
|
@@ -47390,7 +47185,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
47390
47185
|
await yieldGitDiscoverWork(i + 1);
|
|
47391
47186
|
const ent = entries[i];
|
|
47392
47187
|
if (!ent.isDirectory()) continue;
|
|
47393
|
-
const childPath2 =
|
|
47188
|
+
const childPath2 = path60.join(cwdResolved, ent.name);
|
|
47394
47189
|
if (await isGitRepoDirectory(childPath2)) {
|
|
47395
47190
|
const remoteUrl = await getRemoteOriginUrl(childPath2);
|
|
47396
47191
|
result.push({ absolutePath: childPath2, remoteUrl });
|
|
@@ -47399,17 +47194,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
|
|
|
47399
47194
|
return result;
|
|
47400
47195
|
}
|
|
47401
47196
|
async function discoverGitReposUnderRoot(rootPath) {
|
|
47402
|
-
const root =
|
|
47197
|
+
const root = path60.resolve(rootPath);
|
|
47403
47198
|
const roots = [];
|
|
47404
47199
|
let walkEntries = 0;
|
|
47405
47200
|
async function walk(dir) {
|
|
47406
47201
|
if (await isGitRepoDirectory(dir)) {
|
|
47407
|
-
roots.push(
|
|
47202
|
+
roots.push(path60.resolve(dir));
|
|
47408
47203
|
return;
|
|
47409
47204
|
}
|
|
47410
47205
|
let entries;
|
|
47411
47206
|
try {
|
|
47412
|
-
entries =
|
|
47207
|
+
entries = fs37.readdirSync(dir, { withFileTypes: true });
|
|
47413
47208
|
} catch {
|
|
47414
47209
|
return;
|
|
47415
47210
|
}
|
|
@@ -47417,7 +47212,7 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
47417
47212
|
await yieldGitDiscoverWork(++walkEntries);
|
|
47418
47213
|
const ent = entries[i];
|
|
47419
47214
|
if (!ent.isDirectory() || ent.name === ".git") continue;
|
|
47420
|
-
await walk(
|
|
47215
|
+
await walk(path60.join(dir, ent.name));
|
|
47421
47216
|
}
|
|
47422
47217
|
}
|
|
47423
47218
|
await walk(root);
|
|
@@ -47433,8 +47228,8 @@ async function discoverGitReposUnderRoot(rootPath) {
|
|
|
47433
47228
|
}
|
|
47434
47229
|
|
|
47435
47230
|
// ../bridge/src/worktrees/prepare/add-isolated-repo-worktree.ts
|
|
47436
|
-
import * as
|
|
47437
|
-
import * as
|
|
47231
|
+
import * as fs39 from "node:fs";
|
|
47232
|
+
import * as path62 from "node:path";
|
|
47438
47233
|
|
|
47439
47234
|
// ../bridge/src/git/worktrees/worktree-add.ts
|
|
47440
47235
|
async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
|
|
@@ -47450,8 +47245,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
|
|
|
47450
47245
|
}
|
|
47451
47246
|
|
|
47452
47247
|
// ../bridge/src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
|
|
47453
|
-
import * as
|
|
47454
|
-
import * as
|
|
47248
|
+
import * as fs38 from "node:fs";
|
|
47249
|
+
import * as path61 from "node:path";
|
|
47455
47250
|
var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
|
|
47456
47251
|
function copyBridgeFilesAlongWorktreePath(options) {
|
|
47457
47252
|
const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
|
|
@@ -47460,19 +47255,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
|
|
|
47460
47255
|
const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
|
|
47461
47256
|
for (let i = 0; i < segments.length; i++) {
|
|
47462
47257
|
const prefix = segments.slice(0, i).join("/");
|
|
47463
|
-
const bridgeDir = prefix ?
|
|
47464
|
-
const destDir = prefix ?
|
|
47258
|
+
const bridgeDir = prefix ? path61.join(bridgeRoot, prefix) : bridgeRoot;
|
|
47259
|
+
const destDir = prefix ? path61.join(scopeDir, prefix) : scopeDir;
|
|
47465
47260
|
for (const fileName of fileNames) {
|
|
47466
47261
|
copyFileIfPresent(bridgeDir, destDir, fileName, log2);
|
|
47467
47262
|
}
|
|
47468
47263
|
}
|
|
47469
47264
|
}
|
|
47470
47265
|
function copyFileIfPresent(srcDir, destDir, fileName, log2) {
|
|
47471
|
-
const src =
|
|
47472
|
-
if (!
|
|
47473
|
-
const dest =
|
|
47266
|
+
const src = path61.join(srcDir, fileName);
|
|
47267
|
+
if (!fs38.existsSync(src)) return;
|
|
47268
|
+
const dest = path61.join(destDir, fileName);
|
|
47474
47269
|
try {
|
|
47475
|
-
|
|
47270
|
+
fs38.copyFileSync(src, dest);
|
|
47476
47271
|
log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
|
|
47477
47272
|
} catch (e) {
|
|
47478
47273
|
log2?.(
|
|
@@ -47504,16 +47299,16 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
47504
47299
|
worktreeBaseBranches,
|
|
47505
47300
|
log: log2
|
|
47506
47301
|
} = options;
|
|
47507
|
-
const repoPathRelativeToBridgeRootRaw =
|
|
47508
|
-
if (repoPathRelativeToBridgeRootRaw.startsWith("..") ||
|
|
47302
|
+
const repoPathRelativeToBridgeRootRaw = path62.relative(bridgeResolved, repoAbsolutePath);
|
|
47303
|
+
if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path62.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
|
|
47509
47304
|
return null;
|
|
47510
47305
|
}
|
|
47511
47306
|
const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
|
|
47512
47307
|
repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
|
|
47513
47308
|
);
|
|
47514
|
-
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir :
|
|
47309
|
+
const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path62.join(scopeDir, repoPathRelativeToBridgeRoot);
|
|
47515
47310
|
if (repoPathRelativeToBridgeRoot !== ".") {
|
|
47516
|
-
|
|
47311
|
+
fs39.mkdirSync(path62.dirname(worktreePath), { recursive: true });
|
|
47517
47312
|
copyBridgeFilesAlongWorktreePath({
|
|
47518
47313
|
bridgeRoot: bridgeResolved,
|
|
47519
47314
|
scopeDir,
|
|
@@ -47541,7 +47336,7 @@ async function addIsolatedRepoWorktree(options) {
|
|
|
47541
47336
|
}
|
|
47542
47337
|
|
|
47543
47338
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
47544
|
-
import * as
|
|
47339
|
+
import * as path63 from "node:path";
|
|
47545
47340
|
|
|
47546
47341
|
// ../bridge/src/worktrees/worktree-layout-kind.ts
|
|
47547
47342
|
function sanitizeWorktreeBranchSegment(value) {
|
|
@@ -47571,10 +47366,10 @@ function previewDeployBranchName(environmentId) {
|
|
|
47571
47366
|
|
|
47572
47367
|
// ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
|
|
47573
47368
|
function resolveIsolatedScopeDir(options) {
|
|
47574
|
-
const bridgeResolved =
|
|
47369
|
+
const bridgeResolved = path63.resolve(options.bridgeRoot);
|
|
47575
47370
|
const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
|
|
47576
|
-
const bridgeKeyDir =
|
|
47577
|
-
const scopeDir =
|
|
47371
|
+
const bridgeKeyDir = path63.join(options.worktreesRootPath, cwdKey);
|
|
47372
|
+
const scopeDir = path63.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
|
|
47578
47373
|
return { bridgeResolved, scopeDir };
|
|
47579
47374
|
}
|
|
47580
47375
|
|
|
@@ -47604,7 +47399,7 @@ async function prepareNewIsolatedWorktrees(options) {
|
|
|
47604
47399
|
return null;
|
|
47605
47400
|
}
|
|
47606
47401
|
const worktreePaths = [];
|
|
47607
|
-
|
|
47402
|
+
fs40.mkdirSync(scopeDir, { recursive: true });
|
|
47608
47403
|
await forEachWithGitYield(repos, async (repo) => {
|
|
47609
47404
|
const worktreePath = await addIsolatedRepoWorktree({
|
|
47610
47405
|
kind,
|
|
@@ -47676,10 +47471,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
|
|
|
47676
47471
|
}
|
|
47677
47472
|
|
|
47678
47473
|
// ../bridge/src/worktrees/manager/resolve-explicit-session-parent-path.ts
|
|
47679
|
-
import * as
|
|
47474
|
+
import * as path64 from "node:path";
|
|
47680
47475
|
init_yield_to_event_loop();
|
|
47681
47476
|
async function resolveExplicitSessionParentPath(params) {
|
|
47682
|
-
const resolved =
|
|
47477
|
+
const resolved = path64.resolve(params.parentPathRaw);
|
|
47683
47478
|
if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
|
|
47684
47479
|
return resolved;
|
|
47685
47480
|
}
|
|
@@ -47696,7 +47491,7 @@ async function resolveExplicitSessionParentPath(params) {
|
|
|
47696
47491
|
await yieldToEventLoop();
|
|
47697
47492
|
const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
|
|
47698
47493
|
if (tryRoot) return rememberAndReturn(tryRoot);
|
|
47699
|
-
const next =
|
|
47494
|
+
const next = path64.dirname(cur);
|
|
47700
47495
|
if (next === cur) break;
|
|
47701
47496
|
cur = next;
|
|
47702
47497
|
}
|
|
@@ -47857,15 +47652,15 @@ var SessionWorktreeManager = class {
|
|
|
47857
47652
|
};
|
|
47858
47653
|
|
|
47859
47654
|
// ../bridge/src/worktrees/discovery/discover-preview-worktree-on-disk.ts
|
|
47860
|
-
import * as
|
|
47861
|
-
import * as
|
|
47655
|
+
import * as fs41 from "node:fs";
|
|
47656
|
+
import * as path65 from "node:path";
|
|
47862
47657
|
init_yield_to_event_loop();
|
|
47863
47658
|
async function discoverPreviewWorktreeOnDisk(options) {
|
|
47864
47659
|
const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
|
|
47865
47660
|
const eid = environmentId.trim();
|
|
47866
47661
|
if (!eid) return null;
|
|
47867
47662
|
try {
|
|
47868
|
-
await
|
|
47663
|
+
await fs41.promises.access(worktreesRootPath);
|
|
47869
47664
|
} catch {
|
|
47870
47665
|
return null;
|
|
47871
47666
|
}
|
|
@@ -47874,13 +47669,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
47874
47669
|
if (preferredKey) keysOnDisk.push(preferredKey);
|
|
47875
47670
|
const scanState = { entries: 0 };
|
|
47876
47671
|
try {
|
|
47877
|
-
for (const name of await
|
|
47672
|
+
for (const name of await fs41.promises.readdir(worktreesRootPath)) {
|
|
47878
47673
|
if (!await yieldDuringDiskWalk(scanState)) break;
|
|
47879
47674
|
if (name.startsWith(".")) continue;
|
|
47880
|
-
const p =
|
|
47675
|
+
const p = path65.join(worktreesRootPath, name);
|
|
47881
47676
|
let st;
|
|
47882
47677
|
try {
|
|
47883
|
-
st = await
|
|
47678
|
+
st = await fs41.promises.stat(p);
|
|
47884
47679
|
} catch {
|
|
47885
47680
|
continue;
|
|
47886
47681
|
}
|
|
@@ -47894,7 +47689,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
|
|
|
47894
47689
|
const previewDirRel = layoutDirSegments("preview_environment", eid);
|
|
47895
47690
|
for (const key of keys) {
|
|
47896
47691
|
await yieldToEventLoop();
|
|
47897
|
-
const previewDir =
|
|
47692
|
+
const previewDir = path65.join(worktreesRootPath, key, ...previewDirRel);
|
|
47898
47693
|
const binding = await tryBindingFromIsolatedDirectory(previewDir);
|
|
47899
47694
|
if (binding) return binding;
|
|
47900
47695
|
}
|
|
@@ -48021,7 +47816,7 @@ var PreviewWorktreeManager = class {
|
|
|
48021
47816
|
};
|
|
48022
47817
|
|
|
48023
47818
|
// ../bridge/src/worktrees/deploy/deploy-session-to-preview-environment.ts
|
|
48024
|
-
import * as
|
|
47819
|
+
import * as path69 from "node:path";
|
|
48025
47820
|
|
|
48026
47821
|
// ../bridge/src/git/worktrees/reset-worktree-to-branch.ts
|
|
48027
47822
|
async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
@@ -48032,8 +47827,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
|
|
|
48032
47827
|
}
|
|
48033
47828
|
|
|
48034
47829
|
// ../bridge/src/worktrees/deploy/capture-and-apply-wip.ts
|
|
48035
|
-
import * as
|
|
48036
|
-
import * as
|
|
47830
|
+
import * as fs42 from "node:fs";
|
|
47831
|
+
import * as path66 from "node:path";
|
|
48037
47832
|
|
|
48038
47833
|
// ../bridge/src/git/is-not-a-git-repository-error.ts
|
|
48039
47834
|
function isNotAGitRepositoryError(e) {
|
|
@@ -48095,12 +47890,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
48095
47890
|
if (!ap.ok) return ap;
|
|
48096
47891
|
}
|
|
48097
47892
|
await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
|
|
48098
|
-
const src =
|
|
48099
|
-
const dst =
|
|
47893
|
+
const src = path66.join(sourceRepoPath, rel);
|
|
47894
|
+
const dst = path66.join(targetRepoPath, rel);
|
|
48100
47895
|
try {
|
|
48101
|
-
if (!
|
|
48102
|
-
|
|
48103
|
-
|
|
47896
|
+
if (!fs42.existsSync(src)) return;
|
|
47897
|
+
fs42.mkdirSync(path66.dirname(dst), { recursive: true });
|
|
47898
|
+
fs42.copyFileSync(src, dst);
|
|
48104
47899
|
} catch (e) {
|
|
48105
47900
|
log2(
|
|
48106
47901
|
`[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -48111,14 +47906,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
|
|
|
48111
47906
|
}
|
|
48112
47907
|
|
|
48113
47908
|
// ../bridge/src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
|
|
48114
|
-
import * as
|
|
47909
|
+
import * as path67 from "node:path";
|
|
48115
47910
|
async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
|
|
48116
47911
|
const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
|
|
48117
|
-
const resolvedSessionParentPath = sessionParentPath ?
|
|
47912
|
+
const resolvedSessionParentPath = sessionParentPath ? path67.resolve(sessionParentPath) : null;
|
|
48118
47913
|
let match = null;
|
|
48119
47914
|
await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
|
|
48120
47915
|
if (match) return;
|
|
48121
|
-
const resolvedCheckoutPath =
|
|
47916
|
+
const resolvedCheckoutPath = path67.resolve(checkoutPath);
|
|
48122
47917
|
if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
|
|
48123
47918
|
const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48124
47919
|
checkoutPath: resolvedCheckoutPath,
|
|
@@ -48172,7 +47967,7 @@ async function applySessionWipToPreviewCheckouts(options) {
|
|
|
48172
47967
|
}
|
|
48173
47968
|
|
|
48174
47969
|
// ../bridge/src/worktrees/deploy/collect-session-repo-deploy-states.ts
|
|
48175
|
-
import * as
|
|
47970
|
+
import * as path68 from "node:path";
|
|
48176
47971
|
|
|
48177
47972
|
// ../bridge/src/git/branches/create-or-update-branch.ts
|
|
48178
47973
|
async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
|
|
@@ -48209,19 +48004,19 @@ async function collectSessionRepoDeployStates(options) {
|
|
|
48209
48004
|
const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
|
|
48210
48005
|
const states = [];
|
|
48211
48006
|
await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
|
|
48212
|
-
const checkoutPath =
|
|
48007
|
+
const checkoutPath = path68.resolve(sessionCheckout);
|
|
48213
48008
|
if (!await isGitRepoDirectory(checkoutPath)) return;
|
|
48214
48009
|
const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
|
|
48215
48010
|
checkoutPath,
|
|
48216
48011
|
bridgeRoot,
|
|
48217
|
-
sessionParentPath: sessionParentPath ?
|
|
48012
|
+
sessionParentPath: sessionParentPath ? path68.resolve(sessionParentPath) : null
|
|
48218
48013
|
});
|
|
48219
48014
|
if (!repoPathRelativeToWorkspaceRoot) return;
|
|
48220
48015
|
const mainRepoPath = resolveMainRepoPath(checkoutPath);
|
|
48221
48016
|
const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
|
|
48222
48017
|
const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
|
|
48223
48018
|
checkoutPaths: previewCheckoutPaths,
|
|
48224
|
-
sessionParentPath: previewParentPath ?
|
|
48019
|
+
sessionParentPath: previewParentPath ? path68.resolve(previewParentPath) : null,
|
|
48225
48020
|
bridgeRoot,
|
|
48226
48021
|
repoPathRelativeToWorkspaceRoot
|
|
48227
48022
|
}) : null;
|
|
@@ -48241,7 +48036,7 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
48241
48036
|
const eid = options.environmentId.trim();
|
|
48242
48037
|
if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
|
|
48243
48038
|
const deployBranch = previewDeployBranchName(eid);
|
|
48244
|
-
const bridgeRoot =
|
|
48039
|
+
const bridgeRoot = path69.resolve(getBridgeRoot());
|
|
48245
48040
|
await previewWorktreeManager.ensureCached(eid);
|
|
48246
48041
|
const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
|
|
48247
48042
|
const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
|
|
@@ -48281,10 +48076,10 @@ async function deploySessionToPreviewEnvironment(options) {
|
|
|
48281
48076
|
}
|
|
48282
48077
|
|
|
48283
48078
|
// ../bridge/src/worktrees/manager/default-worktrees-root-path.ts
|
|
48284
|
-
import * as
|
|
48285
|
-
import
|
|
48079
|
+
import * as path70 from "node:path";
|
|
48080
|
+
import os7 from "node:os";
|
|
48286
48081
|
function defaultWorktreesRootPath() {
|
|
48287
|
-
return
|
|
48082
|
+
return path70.join(os7.homedir(), ".buildautomaton", "worktrees");
|
|
48288
48083
|
}
|
|
48289
48084
|
|
|
48290
48085
|
// ../bridge/src/connection/setup/create-bridge-worktree-managers.ts
|
|
@@ -48409,14 +48204,14 @@ function assertBridgeWorkspace(ctx) {
|
|
|
48409
48204
|
}
|
|
48410
48205
|
|
|
48411
48206
|
// ../bridge/src/files/list-dir/index.ts
|
|
48412
|
-
import
|
|
48207
|
+
import fs44 from "node:fs";
|
|
48413
48208
|
|
|
48414
48209
|
// ../bridge/src/files/ensure-under-cwd.ts
|
|
48415
|
-
import
|
|
48210
|
+
import path71 from "node:path";
|
|
48416
48211
|
function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
|
|
48417
|
-
const normalized =
|
|
48418
|
-
const resolved =
|
|
48419
|
-
if (!resolved.startsWith(cwd +
|
|
48212
|
+
const normalized = path71.normalize(relativePath).replace(/^(\.\/)+/, "");
|
|
48213
|
+
const resolved = path71.resolve(cwd, normalized);
|
|
48214
|
+
if (!resolved.startsWith(cwd + path71.sep) && resolved !== cwd) {
|
|
48420
48215
|
return null;
|
|
48421
48216
|
}
|
|
48422
48217
|
return resolved;
|
|
@@ -48429,15 +48224,15 @@ init_yield_to_event_loop();
|
|
|
48429
48224
|
var LIST_DIR_YIELD_EVERY = 256;
|
|
48430
48225
|
|
|
48431
48226
|
// ../bridge/src/files/list-dir/map-dir-entry.ts
|
|
48432
|
-
import
|
|
48433
|
-
import
|
|
48227
|
+
import path72 from "node:path";
|
|
48228
|
+
import fs43 from "node:fs";
|
|
48434
48229
|
async function mapDirEntry(d, relativePath, resolved) {
|
|
48435
|
-
const entryPath =
|
|
48436
|
-
const fullPath =
|
|
48230
|
+
const entryPath = path72.join(relativePath || ".", d.name).replace(/\\/g, "/");
|
|
48231
|
+
const fullPath = path72.join(resolved, d.name);
|
|
48437
48232
|
let isDir = d.isDirectory();
|
|
48438
48233
|
if (d.isSymbolicLink()) {
|
|
48439
48234
|
try {
|
|
48440
|
-
const targetStat = await
|
|
48235
|
+
const targetStat = await fs43.promises.stat(fullPath);
|
|
48441
48236
|
isDir = targetStat.isDirectory();
|
|
48442
48237
|
} catch {
|
|
48443
48238
|
isDir = false;
|
|
@@ -48467,7 +48262,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
48467
48262
|
return { error: "Path is outside working directory" };
|
|
48468
48263
|
}
|
|
48469
48264
|
try {
|
|
48470
|
-
const names = await
|
|
48265
|
+
const names = await fs44.promises.readdir(resolved, { withFileTypes: true });
|
|
48471
48266
|
const entries = [];
|
|
48472
48267
|
for (let i = 0; i < names.length; i++) {
|
|
48473
48268
|
if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
|
|
@@ -48483,13 +48278,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
|
|
|
48483
48278
|
}
|
|
48484
48279
|
|
|
48485
48280
|
// ../bridge/src/git/tree/resolve-repo-abs-path.ts
|
|
48486
|
-
import * as
|
|
48281
|
+
import * as path73 from "node:path";
|
|
48487
48282
|
function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
48488
|
-
const bridgeResolved =
|
|
48283
|
+
const bridgeResolved = path73.resolve(bridgeRoot);
|
|
48489
48284
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
48490
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
48491
|
-
const resolved =
|
|
48492
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
48285
|
+
const repoPath = rel === "" ? bridgeResolved : path73.join(bridgeResolved, rel);
|
|
48286
|
+
const resolved = path73.resolve(repoPath);
|
|
48287
|
+
if (!resolved.startsWith(bridgeResolved + path73.sep) && resolved !== bridgeResolved) {
|
|
48493
48288
|
return null;
|
|
48494
48289
|
}
|
|
48495
48290
|
return resolved;
|
|
@@ -48970,25 +48765,25 @@ async function GET2(ctx) {
|
|
|
48970
48765
|
init_in_flight();
|
|
48971
48766
|
|
|
48972
48767
|
// ../bridge/src/files/read/read-file-async.ts
|
|
48973
|
-
import
|
|
48768
|
+
import fs50 from "node:fs";
|
|
48974
48769
|
init_yield_to_event_loop();
|
|
48975
48770
|
|
|
48976
48771
|
// ../bridge/src/files/read/resolve-file-cache.ts
|
|
48977
|
-
import
|
|
48978
|
-
import
|
|
48772
|
+
import fs45 from "node:fs";
|
|
48773
|
+
import path74 from "node:path";
|
|
48979
48774
|
var RESOLVE_CACHE_MAX = 4096;
|
|
48980
48775
|
var resolveCache = /* @__PURE__ */ new Map();
|
|
48981
48776
|
function resolveCacheKey(sessionParentPath, relativePath) {
|
|
48982
48777
|
return `${sessionParentPath}\0${relativePath}`;
|
|
48983
48778
|
}
|
|
48984
48779
|
function pathStaysUnderParent(filePath, sessionParentPath) {
|
|
48985
|
-
const parent =
|
|
48986
|
-
const resolved =
|
|
48987
|
-
return resolved === parent || resolved.startsWith(`${parent}${
|
|
48780
|
+
const parent = path74.resolve(sessionParentPath);
|
|
48781
|
+
const resolved = path74.resolve(filePath);
|
|
48782
|
+
return resolved === parent || resolved.startsWith(`${parent}${path74.sep}`);
|
|
48988
48783
|
}
|
|
48989
48784
|
function statMatchesCacheSync(entry) {
|
|
48990
48785
|
try {
|
|
48991
|
-
const stat2 =
|
|
48786
|
+
const stat2 = fs45.statSync(entry.path);
|
|
48992
48787
|
return stat2.isFile() && stat2.mtimeMs === entry.mtimeMs && stat2.size === entry.size;
|
|
48993
48788
|
} catch {
|
|
48994
48789
|
return false;
|
|
@@ -49021,7 +48816,7 @@ function joinInflightResolve(cacheKey, factory) {
|
|
|
49021
48816
|
}
|
|
49022
48817
|
|
|
49023
48818
|
// ../bridge/src/files/read/resolve-file-for-read-core.ts
|
|
49024
|
-
import
|
|
48819
|
+
import fs46 from "node:fs";
|
|
49025
48820
|
import { isMainThread as isMainThread4 } from "node:worker_threads";
|
|
49026
48821
|
function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
49027
48822
|
const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
|
|
@@ -49031,13 +48826,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
|
|
|
49031
48826
|
let size;
|
|
49032
48827
|
let mtimeMs;
|
|
49033
48828
|
try {
|
|
49034
|
-
const lstat =
|
|
48829
|
+
const lstat = fs46.lstatSync(resolved);
|
|
49035
48830
|
if (lstat.isSymbolicLink()) {
|
|
49036
|
-
real =
|
|
48831
|
+
real = fs46.realpathSync(resolved);
|
|
49037
48832
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
49038
48833
|
return { error: "Path is outside working directory" };
|
|
49039
48834
|
}
|
|
49040
|
-
const stat2 =
|
|
48835
|
+
const stat2 = fs46.statSync(real);
|
|
49041
48836
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
49042
48837
|
size = stat2.size;
|
|
49043
48838
|
mtimeMs = stat2.mtimeMs;
|
|
@@ -49065,13 +48860,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
|
|
|
49065
48860
|
let size;
|
|
49066
48861
|
let mtimeMs;
|
|
49067
48862
|
try {
|
|
49068
|
-
const lstat = await
|
|
48863
|
+
const lstat = await fs46.promises.lstat(resolved);
|
|
49069
48864
|
if (lstat.isSymbolicLink()) {
|
|
49070
|
-
real = await
|
|
48865
|
+
real = await fs46.promises.realpath(resolved);
|
|
49071
48866
|
if (!pathStaysUnderParent(real, sessionParentPath)) {
|
|
49072
48867
|
return { error: "Path is outside working directory" };
|
|
49073
48868
|
}
|
|
49074
|
-
const stat2 = await
|
|
48869
|
+
const stat2 = await fs46.promises.stat(real);
|
|
49075
48870
|
if (!stat2.isFile()) return { error: "Not a file" };
|
|
49076
48871
|
size = stat2.size;
|
|
49077
48872
|
mtimeMs = stat2.mtimeMs;
|
|
@@ -49120,7 +48915,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
|
|
|
49120
48915
|
|
|
49121
48916
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
49122
48917
|
init_yield_to_event_loop();
|
|
49123
|
-
import
|
|
48918
|
+
import fs47 from "node:fs";
|
|
49124
48919
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
49125
48920
|
|
|
49126
48921
|
// ../bridge/src/files/read/read-file-range-line-zero.ts
|
|
@@ -49234,8 +49029,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
|
|
|
49234
49029
|
|
|
49235
49030
|
// ../bridge/src/files/read/read-file-range-async.ts
|
|
49236
49031
|
async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
|
|
49237
|
-
const fileSize = fileSizeIn ?? (await
|
|
49238
|
-
const fd = await
|
|
49032
|
+
const fileSize = fileSizeIn ?? (await fs47.promises.stat(filePath)).size;
|
|
49033
|
+
const fd = await fs47.promises.open(filePath, "r");
|
|
49239
49034
|
const bufSize = 64 * 1024;
|
|
49240
49035
|
const buf = Buffer.alloc(bufSize);
|
|
49241
49036
|
const decoder = new StringDecoder2("utf8");
|
|
@@ -49336,7 +49131,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
|
|
|
49336
49131
|
}
|
|
49337
49132
|
|
|
49338
49133
|
// ../bridge/src/files/read/read-small-file-range-async.ts
|
|
49339
|
-
import
|
|
49134
|
+
import fs48 from "node:fs";
|
|
49340
49135
|
import { isMainThread as isMainThread5 } from "node:worker_threads";
|
|
49341
49136
|
var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
|
|
49342
49137
|
function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
|
|
@@ -49366,7 +49161,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
|
|
|
49366
49161
|
};
|
|
49367
49162
|
}
|
|
49368
49163
|
function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
|
|
49369
|
-
const raw =
|
|
49164
|
+
const raw = fs48.readFileSync(filePath, "utf8");
|
|
49370
49165
|
const lines = raw.split(/\r?\n/);
|
|
49371
49166
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
49372
49167
|
}
|
|
@@ -49374,28 +49169,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
|
|
|
49374
49169
|
if (isMainThread5) {
|
|
49375
49170
|
return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
|
|
49376
49171
|
}
|
|
49377
|
-
const raw = await
|
|
49172
|
+
const raw = await fs48.promises.readFile(filePath, "utf8");
|
|
49378
49173
|
const lines = raw.split(/\r?\n/);
|
|
49379
49174
|
return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
|
|
49380
49175
|
}
|
|
49381
49176
|
|
|
49382
49177
|
// ../bridge/src/files/read/read-file-buffer-full-async.ts
|
|
49383
49178
|
init_yield_to_event_loop();
|
|
49384
|
-
import
|
|
49179
|
+
import fs49 from "node:fs";
|
|
49385
49180
|
import { isMainThread as isMainThread6 } from "node:worker_threads";
|
|
49386
49181
|
var READ_CHUNK_BYTES = 256 * 1024;
|
|
49387
49182
|
var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
|
|
49388
49183
|
async function readFileBufferFullAsync(filePath, knownSize) {
|
|
49389
49184
|
if (isMainThread6) {
|
|
49390
|
-
const size2 = knownSize ??
|
|
49185
|
+
const size2 = knownSize ?? fs49.statSync(filePath).size;
|
|
49391
49186
|
if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
|
|
49392
49187
|
await yieldToEventLoop();
|
|
49393
|
-
const buffer =
|
|
49188
|
+
const buffer = fs49.readFileSync(filePath);
|
|
49394
49189
|
return { buffer, size: buffer.length };
|
|
49395
49190
|
}
|
|
49396
49191
|
}
|
|
49397
|
-
const size = knownSize ?? (await
|
|
49398
|
-
const fd = await
|
|
49192
|
+
const size = knownSize ?? (await fs49.promises.stat(filePath)).size;
|
|
49193
|
+
const fd = await fs49.promises.open(filePath, "r");
|
|
49399
49194
|
const chunks = [];
|
|
49400
49195
|
let position = 0;
|
|
49401
49196
|
let bytesSinceYield = 0;
|
|
@@ -49498,7 +49293,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
|
|
|
49498
49293
|
}
|
|
49499
49294
|
if (hasRange) {
|
|
49500
49295
|
if (fileSize == null) {
|
|
49501
|
-
const stat2 = await
|
|
49296
|
+
const stat2 = await fs50.promises.stat(resolvedPath);
|
|
49502
49297
|
fileSize = stat2.size;
|
|
49503
49298
|
}
|
|
49504
49299
|
const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
|
|
@@ -49796,12 +49591,12 @@ function parseOptionalInt2(raw) {
|
|
|
49796
49591
|
return Number.isInteger(parsed) ? parsed : void 0;
|
|
49797
49592
|
}
|
|
49798
49593
|
function parseCodeNavParams(url2) {
|
|
49799
|
-
const
|
|
49594
|
+
const path83 = url2.searchParams.get("path") ?? "";
|
|
49800
49595
|
const opRaw = url2.searchParams.get("op")?.trim();
|
|
49801
49596
|
const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
|
|
49802
49597
|
const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
|
|
49803
49598
|
const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
|
|
49804
|
-
return { path:
|
|
49599
|
+
return { path: path83, op, line, column };
|
|
49805
49600
|
}
|
|
49806
49601
|
function parseCodeNavPath(url2) {
|
|
49807
49602
|
const raw = url2.searchParams.get("path")?.trim();
|
|
@@ -50490,7 +50285,6 @@ var handleBridgeIdentified = (msg, deps) => {
|
|
|
50490
50285
|
});
|
|
50491
50286
|
setImmediate(() => {
|
|
50492
50287
|
void (async () => {
|
|
50493
|
-
cancelInFlightAgentCapabilityWarmup();
|
|
50494
50288
|
try {
|
|
50495
50289
|
await deps.reportAutoDetectedAgents?.();
|
|
50496
50290
|
} catch (e) {
|
|
@@ -50498,13 +50292,11 @@ var handleBridgeIdentified = (msg, deps) => {
|
|
|
50498
50292
|
`[Bridge service] Auto-detect agents failed: ${e instanceof Error ? e.message : String(e)}`
|
|
50499
50293
|
);
|
|
50500
50294
|
}
|
|
50501
|
-
|
|
50502
|
-
await deps.warmupAgentCapabilitiesOnConnect?.();
|
|
50503
|
-
} catch (e) {
|
|
50295
|
+
void deps.warmupAgentCapabilitiesOnConnect?.()?.catch((e) => {
|
|
50504
50296
|
deps.log(
|
|
50505
50297
|
`[Bridge service] Agent capability warmup failed: ${e instanceof Error ? e.message : String(e)}`
|
|
50506
50298
|
);
|
|
50507
|
-
}
|
|
50299
|
+
});
|
|
50508
50300
|
})();
|
|
50509
50301
|
});
|
|
50510
50302
|
};
|
|
@@ -50737,19 +50529,34 @@ var handleAgentConfigMessage = (msg, deps) => {
|
|
|
50737
50529
|
handleBridgeAgentConfig(msg, deps);
|
|
50738
50530
|
};
|
|
50739
50531
|
|
|
50740
|
-
// ../bridge/src/prompt-
|
|
50532
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
50741
50533
|
init_yield_to_event_loop();
|
|
50742
50534
|
|
|
50743
|
-
// ../bridge/src/prompt-
|
|
50535
|
+
// ../bridge/src/prompt-queue/snapshots/types.ts
|
|
50536
|
+
function parseServerTurnSnapshot(raw) {
|
|
50537
|
+
if (!raw || typeof raw !== "object") return null;
|
|
50538
|
+
const o = raw;
|
|
50539
|
+
const turnId = typeof o.turnId === "string" ? o.turnId : "";
|
|
50540
|
+
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
50541
|
+
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
50542
|
+
const serverState = o.serverState ?? o.bridgeServerState;
|
|
50543
|
+
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
50544
|
+
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
50545
|
+
if (!turnId || !sessionId) return null;
|
|
50546
|
+
return { turnId, sessionId, turnOrd, serverState, lastCliState, payload };
|
|
50547
|
+
}
|
|
50548
|
+
function promptQueueSnapshotEntries(queues) {
|
|
50549
|
+
const entries = [];
|
|
50550
|
+
for (const [queueKey, rawTurns] of Object.entries(queues)) {
|
|
50551
|
+
if (!Array.isArray(rawTurns)) continue;
|
|
50552
|
+
const turns = rawTurns.map(parseServerTurnSnapshot).filter((t) => t !== null);
|
|
50553
|
+
entries.push([queueKey, turns]);
|
|
50554
|
+
}
|
|
50555
|
+
return entries;
|
|
50556
|
+
}
|
|
50557
|
+
|
|
50558
|
+
// ../bridge/src/prompt-queue/persistence/read-persisted-queue.ts
|
|
50744
50559
|
init_cli_database();
|
|
50745
|
-
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
50746
|
-
"queued",
|
|
50747
|
-
"requeued",
|
|
50748
|
-
"requeued_with_revert",
|
|
50749
|
-
"cancel_requested",
|
|
50750
|
-
"stopping",
|
|
50751
|
-
"discarded"
|
|
50752
|
-
]);
|
|
50753
50560
|
async function readPersistedQueue(queueKey) {
|
|
50754
50561
|
return withCliSqlite((db) => {
|
|
50755
50562
|
const row = db.get("SELECT queue_key, updated_at, turns_json FROM prompt_queue WHERE queue_key = ?", [
|
|
@@ -50765,6 +50572,9 @@ async function readPersistedQueue(queueKey) {
|
|
|
50765
50572
|
}
|
|
50766
50573
|
});
|
|
50767
50574
|
}
|
|
50575
|
+
|
|
50576
|
+
// ../bridge/src/prompt-queue/persistence/write-persisted-queue.ts
|
|
50577
|
+
init_cli_database();
|
|
50768
50578
|
async function writePersistedQueue(file2) {
|
|
50769
50579
|
await withCliSqlite((db) => {
|
|
50770
50580
|
db.run(
|
|
@@ -50774,36 +50584,103 @@ async function writePersistedQueue(file2) {
|
|
|
50774
50584
|
);
|
|
50775
50585
|
});
|
|
50776
50586
|
}
|
|
50777
|
-
|
|
50778
|
-
|
|
50587
|
+
|
|
50588
|
+
// ../bridge/src/prompt-queue/reconciliation/merge-turns.ts
|
|
50589
|
+
var MERGEABLE_BRIDGE_SERVER_STATES = /* @__PURE__ */ new Set([
|
|
50590
|
+
"queued",
|
|
50591
|
+
"requeued",
|
|
50592
|
+
"requeued_with_revert",
|
|
50593
|
+
"cancel_requested",
|
|
50594
|
+
"stopping",
|
|
50595
|
+
"discarded"
|
|
50596
|
+
]);
|
|
50597
|
+
function mergeServerSnapshotWithLocal(queueKey, serverTurns, prev) {
|
|
50779
50598
|
const turns = [];
|
|
50780
|
-
for (const
|
|
50781
|
-
if (!
|
|
50782
|
-
const
|
|
50783
|
-
const
|
|
50784
|
-
const sessionId = typeof o.sessionId === "string" ? o.sessionId : "";
|
|
50785
|
-
const turnOrd = typeof o.turnOrd === "number" ? o.turnOrd : Number(o.turnOrd) || 0;
|
|
50786
|
-
const bridgeServerState = o.serverState ?? o.bridgeServerState;
|
|
50787
|
-
const lastCliState = o.lastClientState ?? o.lastCliState ?? null;
|
|
50788
|
-
const payload = o.payload && typeof o.payload === "object" ? o.payload : {};
|
|
50789
|
-
if (!turnId || !sessionId) continue;
|
|
50790
|
-
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(bridgeServerState))) continue;
|
|
50791
|
-
const old = prev?.turns.find((t) => t.turnId === turnId);
|
|
50792
|
-
const mergedCli = old?.lastCliState === "running" && lastCliState == null ? "running" : lastCliState;
|
|
50599
|
+
for (const s of serverTurns) {
|
|
50600
|
+
if (!MERGEABLE_BRIDGE_SERVER_STATES.has(String(s.serverState))) continue;
|
|
50601
|
+
const old = prev?.turns.find((t) => t.turnId === s.turnId);
|
|
50602
|
+
const mergedCli = old?.lastCliState === "running" && s.lastCliState == null ? "running" : s.lastCliState;
|
|
50793
50603
|
turns.push({
|
|
50794
|
-
turnId,
|
|
50795
|
-
sessionId,
|
|
50796
|
-
turnOrd,
|
|
50797
|
-
bridgeServerState,
|
|
50604
|
+
turnId: s.turnId,
|
|
50605
|
+
sessionId: s.sessionId,
|
|
50606
|
+
turnOrd: s.turnOrd,
|
|
50607
|
+
bridgeServerState: s.serverState,
|
|
50798
50608
|
lastCliState: mergedCli,
|
|
50799
|
-
payload
|
|
50609
|
+
payload: s.payload
|
|
50800
50610
|
});
|
|
50801
50611
|
}
|
|
50802
50612
|
turns.sort((a, b) => a.turnOrd - b.turnOrd);
|
|
50803
50613
|
return { queueKey, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
50804
50614
|
}
|
|
50615
|
+
function hasLiveRunningTurn(turns, isLiveRun) {
|
|
50616
|
+
return turns.some((t) => t.lastCliState === "running" && isLiveRun(t.turnId));
|
|
50617
|
+
}
|
|
50618
|
+
function isTerminalCliState(state) {
|
|
50619
|
+
return state === "stopped" || state === "failed" || state === "cancelled";
|
|
50620
|
+
}
|
|
50621
|
+
function isSkippedServerState(state) {
|
|
50622
|
+
return state === "discarded" || state === "stopping" || state === "cancel_requested";
|
|
50623
|
+
}
|
|
50624
|
+
|
|
50625
|
+
// ../bridge/src/prompt-queue/reconciliation/pick-actions.ts
|
|
50626
|
+
function pickNextRunnableTurn(turns) {
|
|
50627
|
+
for (const t of turns) {
|
|
50628
|
+
if (isSkippedServerState(t.bridgeServerState)) continue;
|
|
50629
|
+
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
50630
|
+
if (isTerminalCliState(t.lastCliState) || t.lastCliState === "running") continue;
|
|
50631
|
+
return t;
|
|
50632
|
+
}
|
|
50633
|
+
return null;
|
|
50634
|
+
}
|
|
50635
|
+
function normalizeStaleRunning(turns, isLiveRun) {
|
|
50636
|
+
return turns.map((t) => {
|
|
50637
|
+
if (t.lastCliState !== "running") return t;
|
|
50638
|
+
if (isLiveRun(t.turnId)) return t;
|
|
50639
|
+
if (t.bridgeServerState === "cancel_requested") return t;
|
|
50640
|
+
return { ...t, lastCliState: null };
|
|
50641
|
+
});
|
|
50642
|
+
}
|
|
50643
|
+
function reconcileQueueActions(queueKey, turns, isLiveRun) {
|
|
50644
|
+
const actions = [];
|
|
50645
|
+
for (const t of turns) {
|
|
50646
|
+
if (t.bridgeServerState === "cancel_requested" && t.lastCliState === "running" && isLiveRun(t.turnId)) {
|
|
50647
|
+
actions.push({ type: "cancel_run", queueKey, turnId: t.turnId });
|
|
50648
|
+
}
|
|
50649
|
+
}
|
|
50650
|
+
for (const t of turns) {
|
|
50651
|
+
if (t.bridgeServerState !== "cancel_requested") continue;
|
|
50652
|
+
if (t.lastCliState !== "running") continue;
|
|
50653
|
+
if (isLiveRun(t.turnId)) continue;
|
|
50654
|
+
actions.push({ type: "finalize_stale", queueKey, turnId: t.turnId, cliState: "cancelled" });
|
|
50655
|
+
}
|
|
50656
|
+
const normalized = normalizeStaleRunning(turns, isLiveRun);
|
|
50657
|
+
if (hasLiveRunningTurn(normalized, isLiveRun)) return actions;
|
|
50658
|
+
const next = pickNextRunnableTurn(normalized);
|
|
50659
|
+
if (next) {
|
|
50660
|
+
actions.push({ type: "start_run", queueKey, turn: next });
|
|
50661
|
+
actions.push({ type: "report_cli_state", queueKey, turnId: next.turnId, cliState: "running" });
|
|
50662
|
+
}
|
|
50663
|
+
return actions;
|
|
50664
|
+
}
|
|
50665
|
+
function applyStaleRunningNormalization(turns, isLiveRun) {
|
|
50666
|
+
return normalizeStaleRunning(turns, isLiveRun);
|
|
50667
|
+
}
|
|
50668
|
+
|
|
50669
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
50670
|
+
init_yield_to_event_loop();
|
|
50805
50671
|
|
|
50806
|
-
// ../bridge/src/prompt-
|
|
50672
|
+
// ../bridge/src/prompt-queue/runner/client-report.ts
|
|
50673
|
+
function sendPromptQueueClientReport(ws, queues) {
|
|
50674
|
+
if (!ws) return false;
|
|
50675
|
+
const wireQueues = {};
|
|
50676
|
+
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
50677
|
+
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
50678
|
+
}
|
|
50679
|
+
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
50680
|
+
return true;
|
|
50681
|
+
}
|
|
50682
|
+
|
|
50683
|
+
// ../bridge/src/prompt-queue/runner/dispatch-local-prompt.ts
|
|
50807
50684
|
function dispatchLocalPrompt(next, deps) {
|
|
50808
50685
|
const pl = next.payload;
|
|
50809
50686
|
const rawParent = pl["sessionParent"];
|
|
@@ -50830,20 +50707,17 @@ function dispatchLocalPrompt(next, deps) {
|
|
|
50830
50707
|
handleBridgePrompt(msg, deps);
|
|
50831
50708
|
}
|
|
50832
50709
|
|
|
50833
|
-
// ../bridge/src/prompt-
|
|
50710
|
+
// ../bridge/src/prompt-queue/runner/run-id-queue-key-map.ts
|
|
50834
50711
|
var runIdToQueueKey = /* @__PURE__ */ new Map();
|
|
50835
|
-
var locallyDispatchedRunIds = /* @__PURE__ */ new Set();
|
|
50836
50712
|
function getRunIdQueueKey(runId) {
|
|
50837
50713
|
return runIdToQueueKey.get(runId);
|
|
50838
50714
|
}
|
|
50839
50715
|
function setRunIdQueueKey(runId, queueKey) {
|
|
50840
50716
|
runIdToQueueKey.set(runId, queueKey);
|
|
50841
|
-
locallyDispatchedRunIds.add(runId);
|
|
50842
50717
|
}
|
|
50843
50718
|
function deleteRunIdQueueKey(runId) {
|
|
50844
50719
|
const queueKey = runIdToQueueKey.get(runId);
|
|
50845
50720
|
runIdToQueueKey.delete(runId);
|
|
50846
|
-
locallyDispatchedRunIds.delete(runId);
|
|
50847
50721
|
return queueKey;
|
|
50848
50722
|
}
|
|
50849
50723
|
function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
@@ -50852,33 +50726,7 @@ function syncRunningTurnQueueKeys(turns, queueKey) {
|
|
|
50852
50726
|
}
|
|
50853
50727
|
}
|
|
50854
50728
|
|
|
50855
|
-
// ../bridge/src/prompt-
|
|
50856
|
-
async function dispatchStartedPromptQueueRuns(entries, started, deps) {
|
|
50857
|
-
for (const [queueKey] of entries) {
|
|
50858
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
50859
|
-
const running2 = file2?.turns.find((turn) => turn.lastCliState === "running");
|
|
50860
|
-
if (running2 && started.has(running2.turnId) && getRunIdQueueKey(running2.turnId) === queueKey) {
|
|
50861
|
-
dispatchLocalPrompt(running2, deps);
|
|
50862
|
-
}
|
|
50863
|
-
await yieldToEventLoop();
|
|
50864
|
-
}
|
|
50865
|
-
}
|
|
50866
|
-
|
|
50867
|
-
// ../bridge/src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
|
|
50868
|
-
init_yield_to_event_loop();
|
|
50869
|
-
|
|
50870
|
-
// ../bridge/src/prompt-turn-queue/client-report.ts
|
|
50871
|
-
function sendPromptQueueClientReport(ws, queues) {
|
|
50872
|
-
if (!ws) return false;
|
|
50873
|
-
const wireQueues = {};
|
|
50874
|
-
for (const [queueKey, rows] of Object.entries(queues)) {
|
|
50875
|
-
wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
|
|
50876
|
-
}
|
|
50877
|
-
sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
|
|
50878
|
-
return true;
|
|
50879
|
-
}
|
|
50880
|
-
|
|
50881
|
-
// ../bridge/src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
50729
|
+
// ../bridge/src/prompt-queue/runner/finalize-prompt-turn-on-bridge.ts
|
|
50882
50730
|
async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
50883
50731
|
if (!runId) return false;
|
|
50884
50732
|
const queueKey = deleteRunIdQueueKey(runId);
|
|
@@ -50893,79 +50741,19 @@ async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
|
|
|
50893
50741
|
return true;
|
|
50894
50742
|
}
|
|
50895
50743
|
|
|
50896
|
-
// ../bridge/src/prompt-
|
|
50897
|
-
|
|
50898
|
-
for (const [queueKey] of entries) {
|
|
50899
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
50900
|
-
const turn = file2?.turns.find((row) => row.bridgeServerState === "cancel_requested" && row.lastCliState === "running");
|
|
50901
|
-
if (!turn || getRunIdQueueKey(turn.turnId) !== queueKey) {
|
|
50902
|
-
await yieldToEventLoop();
|
|
50903
|
-
continue;
|
|
50904
|
-
}
|
|
50905
|
-
deps.log(`[Queue] Cancellation request received for turn ${turn.turnId.slice(0, 8)}\u2026`);
|
|
50906
|
-
if (await deps.acpManager.cancelRun(turn.turnId)) {
|
|
50907
|
-
await yieldToEventLoop();
|
|
50908
|
-
continue;
|
|
50909
|
-
}
|
|
50910
|
-
deps.log(`[Queue] No local ACP run remains for ${turn.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
50911
|
-
await finalizePromptTurnOnBridge(deps.getWs, turn.turnId, false, { terminalCliState: "cancelled" });
|
|
50912
|
-
await yieldToEventLoop();
|
|
50913
|
-
}
|
|
50914
|
-
}
|
|
50915
|
-
|
|
50916
|
-
// ../bridge/src/prompt-turn-queue/runner/persist-prompt-queue-snapshot.ts
|
|
50917
|
-
init_yield_to_event_loop();
|
|
50918
|
-
async function persistPromptQueueSnapshot(entries) {
|
|
50919
|
-
for (const [queueKey, serverTurns] of entries) {
|
|
50920
|
-
const file2 = await mergeBridgeServerQueueSnapshot(queueKey, serverTurns);
|
|
50921
|
-
await writePersistedQueue(file2);
|
|
50922
|
-
await yieldToEventLoop();
|
|
50923
|
-
}
|
|
50924
|
-
for (const [queueKey] of entries) {
|
|
50925
|
-
const file2 = await readPersistedQueue(queueKey);
|
|
50926
|
-
if (file2) syncRunningTurnQueueKeys(file2.turns, queueKey);
|
|
50927
|
-
await yieldToEventLoop();
|
|
50928
|
-
}
|
|
50929
|
-
}
|
|
50930
|
-
|
|
50931
|
-
// ../bridge/src/prompt-turn-queue/runner/prompt-queue-snapshot-types.ts
|
|
50932
|
-
function promptQueueSnapshotEntries(queues) {
|
|
50933
|
-
return Object.entries(queues).filter((entry) => Array.isArray(entry[1]));
|
|
50934
|
-
}
|
|
50935
|
-
|
|
50936
|
-
// ../bridge/src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
|
|
50937
|
-
init_yield_to_event_loop();
|
|
50938
|
-
|
|
50939
|
-
// ../bridge/src/prompt-turn-queue/runner/queue-selection.ts
|
|
50940
|
-
function pickNextRunnableTurn(turns) {
|
|
50941
|
-
for (const t of turns) {
|
|
50942
|
-
if (t.bridgeServerState === "discarded" || t.bridgeServerState === "stopping") continue;
|
|
50943
|
-
if (t.bridgeServerState === "cancel_requested") continue;
|
|
50944
|
-
if (!isRunnableBridgePromptTurnServerState(t.bridgeServerState)) continue;
|
|
50945
|
-
if (t.lastCliState === "running" || t.lastCliState === "stopped" || t.lastCliState === "failed" || t.lastCliState === "cancelled") {
|
|
50946
|
-
continue;
|
|
50947
|
-
}
|
|
50948
|
-
return t;
|
|
50949
|
-
}
|
|
50950
|
-
return null;
|
|
50951
|
-
}
|
|
50952
|
-
function hasRunningTurn(turns) {
|
|
50953
|
-
return turns.some((t) => t.lastCliState === "running");
|
|
50954
|
-
}
|
|
50955
|
-
|
|
50956
|
-
// ../bridge/src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
50957
|
-
import fs54 from "node:fs";
|
|
50744
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
50745
|
+
import fs53 from "node:fs";
|
|
50958
50746
|
|
|
50959
50747
|
// ../bridge/src/git/snapshot/capture.ts
|
|
50960
|
-
import * as
|
|
50961
|
-
import * as
|
|
50748
|
+
import * as fs52 from "node:fs";
|
|
50749
|
+
import * as path76 from "node:path";
|
|
50962
50750
|
|
|
50963
50751
|
// ../bridge/src/git/snapshot/apply-pre-turn-snapshot.ts
|
|
50964
|
-
import * as
|
|
50752
|
+
import * as fs51 from "node:fs";
|
|
50965
50753
|
async function applyPreTurnSnapshot(filePath, log2) {
|
|
50966
50754
|
let data;
|
|
50967
50755
|
try {
|
|
50968
|
-
data = JSON.parse(
|
|
50756
|
+
data = JSON.parse(fs51.readFileSync(filePath, "utf8"));
|
|
50969
50757
|
} catch (error51) {
|
|
50970
50758
|
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
50971
50759
|
}
|
|
@@ -50994,18 +50782,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
|
|
|
50994
50782
|
}
|
|
50995
50783
|
|
|
50996
50784
|
// ../bridge/src/git/snapshot/resolve-repo-roots.ts
|
|
50997
|
-
import * as
|
|
50785
|
+
import * as path75 from "node:path";
|
|
50998
50786
|
async function resolveSnapshotRepoRoots(options) {
|
|
50999
50787
|
const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
|
|
51000
50788
|
if (worktreePaths?.length) {
|
|
51001
|
-
const paths = [...new Set(worktreePaths.map((p) =>
|
|
50789
|
+
const paths = [...new Set(worktreePaths.map((p) => path75.resolve(p)))];
|
|
51002
50790
|
return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
|
|
51003
50791
|
}
|
|
51004
50792
|
try {
|
|
51005
50793
|
const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
|
|
51006
50794
|
const sid = sessionId?.trim();
|
|
51007
50795
|
if (!sid) return roots;
|
|
51008
|
-
const sessionRoots = roots.filter((root) =>
|
|
50796
|
+
const sessionRoots = roots.filter((root) => path75.basename(root) === sid);
|
|
51009
50797
|
return sessionRoots.length > 0 ? sessionRoots : roots;
|
|
51010
50798
|
} catch (error51) {
|
|
51011
50799
|
log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
@@ -51027,7 +50815,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51027
50815
|
});
|
|
51028
50816
|
const dir = snapshotsDirForCwd(agentCwd);
|
|
51029
50817
|
try {
|
|
51030
|
-
|
|
50818
|
+
fs52.mkdirSync(dir, { recursive: true });
|
|
51031
50819
|
} catch (e) {
|
|
51032
50820
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51033
50821
|
}
|
|
@@ -51036,9 +50824,9 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51036
50824
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51037
50825
|
repos
|
|
51038
50826
|
};
|
|
51039
|
-
const filePath =
|
|
50827
|
+
const filePath = path76.join(dir, `${runId}.json`);
|
|
51040
50828
|
try {
|
|
51041
|
-
|
|
50829
|
+
fs52.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
|
|
51042
50830
|
} catch (e) {
|
|
51043
50831
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
51044
50832
|
}
|
|
@@ -51049,7 +50837,7 @@ async function capturePreTurnSnapshot(options) {
|
|
|
51049
50837
|
return { ok: true, filePath, repos };
|
|
51050
50838
|
}
|
|
51051
50839
|
|
|
51052
|
-
// ../bridge/src/prompt-
|
|
50840
|
+
// ../bridge/src/prompt-queue/runner/run-local-revert-before-queued-prompt.ts
|
|
51053
50841
|
async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
51054
50842
|
if (next.bridgeServerState !== "requeued_with_revert") return true;
|
|
51055
50843
|
const sid = next.sessionId;
|
|
@@ -51058,7 +50846,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
51058
50846
|
const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
|
|
51059
50847
|
const file2 = snapshotFilePath(agentBase, tid);
|
|
51060
50848
|
try {
|
|
51061
|
-
await
|
|
50849
|
+
await fs53.promises.access(file2, fs53.constants.F_OK);
|
|
51062
50850
|
} catch {
|
|
51063
50851
|
deps.log(
|
|
51064
50852
|
`[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
|
|
@@ -51072,49 +50860,120 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
|
|
|
51072
50860
|
return res.ok;
|
|
51073
50861
|
}
|
|
51074
50862
|
|
|
51075
|
-
// ../bridge/src/prompt-
|
|
51076
|
-
async function
|
|
51077
|
-
const report = {};
|
|
50863
|
+
// ../bridge/src/prompt-queue/runner/execute-actions.ts
|
|
50864
|
+
async function executePromptQueueActions(actions, deps) {
|
|
51078
50865
|
const started = /* @__PURE__ */ new Set();
|
|
51079
|
-
|
|
51080
|
-
|
|
51081
|
-
if (
|
|
51082
|
-
|
|
51083
|
-
|
|
51084
|
-
|
|
51085
|
-
|
|
51086
|
-
await
|
|
51087
|
-
sendPromptQueueClientReport(deps.getWs(), { [queueKey]: [{ turnId: next.turnId, cliState: "failed" }] });
|
|
50866
|
+
const report = {};
|
|
50867
|
+
for (const action of actions) {
|
|
50868
|
+
if (action.type === "cancel_run") {
|
|
50869
|
+
if (getRunIdQueueKey(action.turnId) !== action.queueKey) continue;
|
|
50870
|
+
deps.log(`[Queue] Cancellation request received for turn ${action.turnId.slice(0, 8)}\u2026`);
|
|
50871
|
+
if (await deps.acpManager.cancelRun(action.turnId)) continue;
|
|
50872
|
+
deps.log(`[Queue] No local ACP run remains for ${action.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
|
|
50873
|
+
await finalizePromptTurnOnBridge(deps.getWs, action.turnId, false, { terminalCliState: "cancelled" });
|
|
51088
50874
|
continue;
|
|
51089
50875
|
}
|
|
51090
|
-
|
|
51091
|
-
|
|
51092
|
-
|
|
51093
|
-
|
|
51094
|
-
|
|
50876
|
+
if (action.type === "finalize_stale") {
|
|
50877
|
+
await applyCliState(action.queueKey, action.turnId, action.cliState);
|
|
50878
|
+
deleteRunIdQueueKey(action.turnId);
|
|
50879
|
+
report[action.queueKey] = [{ turnId: action.turnId, cliState: action.cliState }];
|
|
50880
|
+
continue;
|
|
50881
|
+
}
|
|
50882
|
+
if (action.type === "start_run") {
|
|
50883
|
+
const ok = await markTurnRunning(action.queueKey, action.turn, deps);
|
|
50884
|
+
if (!ok) {
|
|
50885
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "failed" }];
|
|
50886
|
+
continue;
|
|
50887
|
+
}
|
|
50888
|
+
started.add(action.turn.turnId);
|
|
50889
|
+
report[action.queueKey] = [{ turnId: action.turn.turnId, cliState: "running" }];
|
|
50890
|
+
}
|
|
51095
50891
|
await yieldToEventLoop();
|
|
51096
50892
|
}
|
|
51097
50893
|
if (Object.keys(report).length) sendPromptQueueClientReport(deps.getWs(), report);
|
|
50894
|
+
for (const runId of started) {
|
|
50895
|
+
const queueKey = getRunIdQueueKey(runId);
|
|
50896
|
+
if (!queueKey) continue;
|
|
50897
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
50898
|
+
const turn = file2?.turns.find((t) => t.turnId === runId);
|
|
50899
|
+
if (turn) dispatchLocalPrompt(turn, deps);
|
|
50900
|
+
await yieldToEventLoop();
|
|
50901
|
+
}
|
|
51098
50902
|
return started;
|
|
51099
50903
|
}
|
|
50904
|
+
async function markTurnRunning(queueKey, turn, deps) {
|
|
50905
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
50906
|
+
if (!file2) return false;
|
|
50907
|
+
const row = file2.turns.find((t) => t.turnId === turn.turnId);
|
|
50908
|
+
if (!row) return false;
|
|
50909
|
+
if (!await runLocalRevertBeforeQueuedPrompt(row, deps)) {
|
|
50910
|
+
row.lastCliState = "failed";
|
|
50911
|
+
await writePersistedQueue(file2);
|
|
50912
|
+
return false;
|
|
50913
|
+
}
|
|
50914
|
+
row.lastCliState = "running";
|
|
50915
|
+
await writePersistedQueue(file2);
|
|
50916
|
+
setRunIdQueueKey(row.turnId, queueKey);
|
|
50917
|
+
return true;
|
|
50918
|
+
}
|
|
50919
|
+
async function applyCliState(queueKey, turnId, cliState) {
|
|
50920
|
+
const file2 = await readPersistedQueue(queueKey);
|
|
50921
|
+
if (!file2) return;
|
|
50922
|
+
const turn = file2.turns.find((t) => t.turnId === turnId);
|
|
50923
|
+
if (!turn) return;
|
|
50924
|
+
turn.lastCliState = cliState;
|
|
50925
|
+
await writePersistedQueue(file2);
|
|
50926
|
+
}
|
|
51100
50927
|
|
|
51101
|
-
// ../bridge/src/prompt-
|
|
50928
|
+
// ../bridge/src/prompt-queue/runner/apply-prompt-queue-state-from-server.ts
|
|
51102
50929
|
var SLOW_QUEUE_SYNC_MS = 2e3;
|
|
50930
|
+
async function persistAndReconcileQueue(queueKey, serverTurns, deps) {
|
|
50931
|
+
const prev = await readPersistedQueue(queueKey);
|
|
50932
|
+
const merged = mergeServerSnapshotWithLocal(queueKey, serverTurns, prev);
|
|
50933
|
+
const liveCheck = (runId) => deps.acpManager.isRegisteredRun(runId);
|
|
50934
|
+
const actions = reconcileQueueActions(queueKey, merged.turns, liveCheck);
|
|
50935
|
+
merged.turns = applyStaleRunningNormalization(merged.turns, liveCheck);
|
|
50936
|
+
await writePersistedQueue(merged);
|
|
50937
|
+
syncRunningTurnQueueKeys(merged.turns, queueKey);
|
|
50938
|
+
return actions;
|
|
50939
|
+
}
|
|
51103
50940
|
async function applyPromptQueueStateFromServer(msg, deps) {
|
|
51104
50941
|
const raw = msg.queues;
|
|
51105
50942
|
if (!raw || typeof raw !== "object") return;
|
|
51106
50943
|
const startedAt = Date.now();
|
|
51107
50944
|
const entries = promptQueueSnapshotEntries(raw);
|
|
51108
|
-
|
|
51109
|
-
|
|
51110
|
-
|
|
51111
|
-
|
|
50945
|
+
const allActions = [];
|
|
50946
|
+
for (const [queueKey, serverTurns] of entries) {
|
|
50947
|
+
allActions.push(...await persistAndReconcileQueue(queueKey, serverTurns, deps));
|
|
50948
|
+
await yieldToEventLoop();
|
|
50949
|
+
}
|
|
50950
|
+
await executePromptQueueActions(allActions, deps);
|
|
51112
50951
|
const durationMs = Date.now() - startedAt;
|
|
51113
50952
|
if (durationMs >= SLOW_QUEUE_SYNC_MS) {
|
|
51114
50953
|
deps.log(`[Queue] Queue state sync and dispatch took ${durationMs}ms.`);
|
|
51115
50954
|
}
|
|
51116
50955
|
}
|
|
51117
50956
|
|
|
50957
|
+
// ../bridge/src/prompt-queue/runner/serial-prompt-queue-work.ts
|
|
50958
|
+
var running = false;
|
|
50959
|
+
var latestWork = null;
|
|
50960
|
+
async function drain() {
|
|
50961
|
+
while (latestWork) {
|
|
50962
|
+
const work = latestWork;
|
|
50963
|
+
latestWork = null;
|
|
50964
|
+
await work();
|
|
50965
|
+
}
|
|
50966
|
+
}
|
|
50967
|
+
function enqueueLatestPromptQueueStateWork(work) {
|
|
50968
|
+
latestWork = work;
|
|
50969
|
+
if (running) return;
|
|
50970
|
+
running = true;
|
|
50971
|
+
void drain().finally(() => {
|
|
50972
|
+
running = false;
|
|
50973
|
+
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
50974
|
+
});
|
|
50975
|
+
}
|
|
50976
|
+
|
|
51118
50977
|
// ../bridge/src/agents/acp/from-bridge/pending-prompt-results.ts
|
|
51119
50978
|
var pending = [];
|
|
51120
50979
|
function enqueuePendingPromptResult(message) {
|
|
@@ -51434,26 +51293,6 @@ var handlePromptMessage = (msg, deps) => {
|
|
|
51434
51293
|
handleBridgePrompt(msg, deps);
|
|
51435
51294
|
};
|
|
51436
51295
|
|
|
51437
|
-
// ../bridge/src/prompt-turn-queue/runner/serial-prompt-queue-work.ts
|
|
51438
|
-
var running = false;
|
|
51439
|
-
var latestWork = null;
|
|
51440
|
-
async function drain() {
|
|
51441
|
-
while (latestWork) {
|
|
51442
|
-
const work = latestWork;
|
|
51443
|
-
latestWork = null;
|
|
51444
|
-
await work();
|
|
51445
|
-
}
|
|
51446
|
-
}
|
|
51447
|
-
function enqueueLatestPromptQueueStateWork(work) {
|
|
51448
|
-
latestWork = work;
|
|
51449
|
-
if (running) return;
|
|
51450
|
-
running = true;
|
|
51451
|
-
void drain().finally(() => {
|
|
51452
|
-
running = false;
|
|
51453
|
-
if (latestWork) enqueueLatestPromptQueueStateWork(latestWork);
|
|
51454
|
-
});
|
|
51455
|
-
}
|
|
51456
|
-
|
|
51457
51296
|
// ../bridge/src/connection/routing/handlers/prompt-queue-state.ts
|
|
51458
51297
|
var handlePromptQueueStateMessage = (msg, deps) => {
|
|
51459
51298
|
enqueueLatestPromptQueueStateWork(async () => {
|
|
@@ -51716,7 +51555,7 @@ var handleSessionDiscardedMessage = (msg, deps) => {
|
|
|
51716
51555
|
};
|
|
51717
51556
|
|
|
51718
51557
|
// ../bridge/src/connection/routing/handlers/revert-turn-snapshot.ts
|
|
51719
|
-
import * as
|
|
51558
|
+
import * as fs54 from "node:fs";
|
|
51720
51559
|
var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
51721
51560
|
const id = typeof msg.id === "string" ? msg.id : "";
|
|
51722
51561
|
const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
|
|
@@ -51729,7 +51568,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
|
|
|
51729
51568
|
const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
|
|
51730
51569
|
const file2 = snapshotFilePath(agentBase, turnId);
|
|
51731
51570
|
try {
|
|
51732
|
-
await
|
|
51571
|
+
await fs54.promises.access(file2, fs54.constants.F_OK);
|
|
51733
51572
|
} catch {
|
|
51734
51573
|
sendWsMessage(s, {
|
|
51735
51574
|
type: "revert_turn_snapshot_result",
|
|
@@ -51843,13 +51682,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
|
|
|
51843
51682
|
|
|
51844
51683
|
// ../bridge/src/files/handle-file-browser-search.ts
|
|
51845
51684
|
init_yield_to_event_loop();
|
|
51846
|
-
import
|
|
51685
|
+
import path77 from "node:path";
|
|
51847
51686
|
var SEARCH_LIMIT = 100;
|
|
51848
51687
|
function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
|
|
51849
51688
|
void (async () => {
|
|
51850
51689
|
await yieldToEventLoop();
|
|
51851
51690
|
const q = typeof msg.q === "string" ? msg.q : "";
|
|
51852
|
-
const sessionParentPath =
|
|
51691
|
+
const sessionParentPath = path77.resolve(
|
|
51853
51692
|
sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
|
|
51854
51693
|
);
|
|
51855
51694
|
if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
|
|
@@ -51947,7 +51786,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
|
|
|
51947
51786
|
}
|
|
51948
51787
|
|
|
51949
51788
|
// ../bridge/src/git/bridge-git-context.ts
|
|
51950
|
-
import * as
|
|
51789
|
+
import * as path78 from "node:path";
|
|
51951
51790
|
init_yield_to_event_loop();
|
|
51952
51791
|
|
|
51953
51792
|
// ../bridge/src/git/branches/get-current-branch.ts
|
|
@@ -52015,12 +51854,12 @@ function listPendingCheckouts() {
|
|
|
52015
51854
|
// ../bridge/src/git/bridge-git-context.ts
|
|
52016
51855
|
function folderNameForRelPath(relPath, bridgeRoot) {
|
|
52017
51856
|
if (relPath === "." || relPath === "") {
|
|
52018
|
-
return
|
|
51857
|
+
return path78.basename(path78.resolve(bridgeRoot)) || "repo";
|
|
52019
51858
|
}
|
|
52020
|
-
return
|
|
51859
|
+
return path78.basename(relPath) || relPath;
|
|
52021
51860
|
}
|
|
52022
51861
|
async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
52023
|
-
const root =
|
|
51862
|
+
const root = path78.resolve(bridgeRoot);
|
|
52024
51863
|
if (await isGitRepoDirectory(root)) {
|
|
52025
51864
|
const remoteUrl = await getRemoteOriginUrl(root);
|
|
52026
51865
|
return [{ absolutePath: root, remoteUrl }];
|
|
@@ -52028,19 +51867,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
|
|
|
52028
51867
|
const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
|
|
52029
51868
|
const byPath = /* @__PURE__ */ new Map();
|
|
52030
51869
|
for (const repo of [...deep, ...shallow]) {
|
|
52031
|
-
byPath.set(
|
|
51870
|
+
byPath.set(path78.resolve(repo.absolutePath), repo);
|
|
52032
51871
|
}
|
|
52033
51872
|
return [...byPath.values()];
|
|
52034
51873
|
}
|
|
52035
51874
|
async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
52036
|
-
const bridgeResolved =
|
|
51875
|
+
const bridgeResolved = path78.resolve(bridgeRoot);
|
|
52037
51876
|
const repos = await discoverGitReposForBridgeContext(bridgeResolved);
|
|
52038
51877
|
const rows = [];
|
|
52039
51878
|
for (let i = 0; i < repos.length; i++) {
|
|
52040
51879
|
if (i > 0) await yieldToEventLoop();
|
|
52041
51880
|
const repo = repos[i];
|
|
52042
|
-
let rel =
|
|
52043
|
-
if (rel.startsWith("..") ||
|
|
51881
|
+
let rel = path78.relative(bridgeResolved, repo.absolutePath);
|
|
51882
|
+
if (rel.startsWith("..") || path78.isAbsolute(rel)) continue;
|
|
52044
51883
|
const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
|
|
52045
51884
|
const currentBranch = await getCurrentBranch(repo.absolutePath);
|
|
52046
51885
|
const remoteUrl = repo.remoteUrl.trim() || null;
|
|
@@ -52071,11 +51910,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
|
|
|
52071
51910
|
return rows;
|
|
52072
51911
|
}
|
|
52073
51912
|
async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
|
|
52074
|
-
const bridgeResolved =
|
|
51913
|
+
const bridgeResolved = path78.resolve(bridgeRoot);
|
|
52075
51914
|
const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
|
|
52076
|
-
const repoPath = rel === "" ? bridgeResolved :
|
|
52077
|
-
const resolved =
|
|
52078
|
-
if (!resolved.startsWith(bridgeResolved +
|
|
51915
|
+
const repoPath = rel === "" ? bridgeResolved : path78.join(bridgeResolved, rel);
|
|
51916
|
+
const resolved = path78.resolve(repoPath);
|
|
51917
|
+
if (!resolved.startsWith(bridgeResolved + path78.sep) && resolved !== bridgeResolved) {
|
|
52079
51918
|
return [];
|
|
52080
51919
|
}
|
|
52081
51920
|
return listRepoBranchRefs(resolved);
|
|
@@ -52125,8 +51964,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
|
|
|
52125
51964
|
}
|
|
52126
51965
|
|
|
52127
51966
|
// ../bridge/src/git/checkout/bridge-git-checkout.ts
|
|
52128
|
-
import * as
|
|
52129
|
-
import * as
|
|
51967
|
+
import * as fs56 from "node:fs/promises";
|
|
51968
|
+
import * as path80 from "node:path";
|
|
52130
51969
|
|
|
52131
51970
|
// ../bridge/src/git/checkout/normalize-clone-url.ts
|
|
52132
51971
|
function normalizeCloneUrl(url2) {
|
|
@@ -52146,12 +51985,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
|
|
|
52146
51985
|
}
|
|
52147
51986
|
|
|
52148
51987
|
// ../bridge/src/git/checkout/resolve-checkout-target.ts
|
|
52149
|
-
import * as
|
|
52150
|
-
import * as
|
|
51988
|
+
import * as fs55 from "node:fs/promises";
|
|
51989
|
+
import * as path79 from "node:path";
|
|
52151
51990
|
var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
52152
51991
|
async function pathExists(p) {
|
|
52153
51992
|
try {
|
|
52154
|
-
await
|
|
51993
|
+
await fs55.access(p);
|
|
52155
51994
|
return true;
|
|
52156
51995
|
} catch {
|
|
52157
51996
|
return false;
|
|
@@ -52163,7 +52002,7 @@ async function resolveCheckoutTarget(opts) {
|
|
|
52163
52002
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
52164
52003
|
throw new Error("Bridge root is already a git repository");
|
|
52165
52004
|
}
|
|
52166
|
-
const entries = await
|
|
52005
|
+
const entries = await fs55.readdir(bridgeRoot).catch(() => []);
|
|
52167
52006
|
if (entries.length > 0) {
|
|
52168
52007
|
throw new Error("Bridge root must be empty to initialize a monorepo checkout");
|
|
52169
52008
|
}
|
|
@@ -52176,8 +52015,8 @@ async function resolveCheckoutTarget(opts) {
|
|
|
52176
52015
|
if (await isGitRepoDirectory(bridgeRoot)) {
|
|
52177
52016
|
throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
|
|
52178
52017
|
}
|
|
52179
|
-
const targetDir =
|
|
52180
|
-
if (!targetDir.startsWith(bridgeRoot +
|
|
52018
|
+
const targetDir = path79.resolve(bridgeRoot, folder);
|
|
52019
|
+
if (!targetDir.startsWith(bridgeRoot + path79.sep)) {
|
|
52181
52020
|
throw new Error("Invalid folderName");
|
|
52182
52021
|
}
|
|
52183
52022
|
if (await pathExists(targetDir)) {
|
|
@@ -52196,10 +52035,10 @@ async function bridgeGitCheckout(params) {
|
|
|
52196
52035
|
});
|
|
52197
52036
|
const folderName = relPath === "." ? "repo" : relPath;
|
|
52198
52037
|
beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
|
|
52199
|
-
const parent =
|
|
52200
|
-
await
|
|
52038
|
+
const parent = path80.dirname(targetDir);
|
|
52039
|
+
await fs56.mkdir(parent, { recursive: true });
|
|
52201
52040
|
if (relPath !== ".") {
|
|
52202
|
-
await
|
|
52041
|
+
await fs56.mkdir(targetDir, { recursive: true });
|
|
52203
52042
|
}
|
|
52204
52043
|
const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
|
|
52205
52044
|
try {
|
|
@@ -52210,7 +52049,7 @@ async function bridgeGitCheckout(params) {
|
|
|
52210
52049
|
return { relPath, folderName };
|
|
52211
52050
|
} catch (e) {
|
|
52212
52051
|
if (relPath !== ".") {
|
|
52213
|
-
await
|
|
52052
|
+
await fs56.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
|
|
52214
52053
|
}
|
|
52215
52054
|
const msg = e instanceof Error ? e.message : String(e);
|
|
52216
52055
|
throw new Error(
|
|
@@ -52392,6 +52231,7 @@ function createMainBridgeCloseHandler(params, connect) {
|
|
|
52392
52231
|
const { state, logFn, bridgeHeartbeat } = params;
|
|
52393
52232
|
return (code, reason, closedWs) => {
|
|
52394
52233
|
if (state.currentWs !== closedWs) return;
|
|
52234
|
+
cancelInFlightAgentCapabilityWarmup();
|
|
52395
52235
|
bridgeHeartbeat?.stop();
|
|
52396
52236
|
try {
|
|
52397
52237
|
state.currentWs = null;
|
|
@@ -52519,20 +52359,8 @@ function createMainBridgeWebSocketLifecycle(params) {
|
|
|
52519
52359
|
}
|
|
52520
52360
|
}
|
|
52521
52361
|
bridgeHeartbeat?.stop();
|
|
52522
|
-
|
|
52523
|
-
|
|
52524
|
-
prev.removeAllListeners();
|
|
52525
|
-
prev.once("error", () => {
|
|
52526
|
-
});
|
|
52527
|
-
prev.once("close", () => {
|
|
52528
|
-
prev.removeAllListeners();
|
|
52529
|
-
});
|
|
52530
|
-
try {
|
|
52531
|
-
prev.close();
|
|
52532
|
-
} catch {
|
|
52533
|
-
}
|
|
52534
|
-
state.currentWs = null;
|
|
52535
|
-
}
|
|
52362
|
+
disposePreviousBridgeSocket(state.currentWs);
|
|
52363
|
+
state.currentWs = null;
|
|
52536
52364
|
try {
|
|
52537
52365
|
const url2 = plugin.transport.resolveControlPlaneUrl({
|
|
52538
52366
|
workspaceId,
|
|
@@ -52862,30 +52690,30 @@ function startStreamingProxy(ws, log2, pr) {
|
|
|
52862
52690
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
52863
52691
|
import process8 from "node:process";
|
|
52864
52692
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
52865
|
-
import
|
|
52693
|
+
import path81 from "node:path";
|
|
52866
52694
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
52867
52695
|
import { promisify as promisify8 } from "node:util";
|
|
52868
52696
|
import childProcess from "node:child_process";
|
|
52869
|
-
import
|
|
52697
|
+
import fs61, { constants as fsConstants2 } from "node:fs/promises";
|
|
52870
52698
|
|
|
52871
52699
|
// ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
|
|
52872
52700
|
import process4 from "node:process";
|
|
52873
|
-
import
|
|
52701
|
+
import fs60, { constants as fsConstants } from "node:fs/promises";
|
|
52874
52702
|
|
|
52875
52703
|
// ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
52876
52704
|
import process3 from "node:process";
|
|
52877
|
-
import
|
|
52878
|
-
import
|
|
52705
|
+
import os8 from "node:os";
|
|
52706
|
+
import fs59 from "node:fs";
|
|
52879
52707
|
|
|
52880
52708
|
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
52881
|
-
import
|
|
52709
|
+
import fs58 from "node:fs";
|
|
52882
52710
|
|
|
52883
52711
|
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
52884
|
-
import
|
|
52712
|
+
import fs57 from "node:fs";
|
|
52885
52713
|
var isDockerCached;
|
|
52886
52714
|
function hasDockerEnv() {
|
|
52887
52715
|
try {
|
|
52888
|
-
|
|
52716
|
+
fs57.statSync("/.dockerenv");
|
|
52889
52717
|
return true;
|
|
52890
52718
|
} catch {
|
|
52891
52719
|
return false;
|
|
@@ -52893,7 +52721,7 @@ function hasDockerEnv() {
|
|
|
52893
52721
|
}
|
|
52894
52722
|
function hasDockerCGroup() {
|
|
52895
52723
|
try {
|
|
52896
|
-
return
|
|
52724
|
+
return fs57.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
52897
52725
|
} catch {
|
|
52898
52726
|
return false;
|
|
52899
52727
|
}
|
|
@@ -52909,7 +52737,7 @@ function isDocker() {
|
|
|
52909
52737
|
var cachedResult;
|
|
52910
52738
|
var hasContainerEnv = () => {
|
|
52911
52739
|
try {
|
|
52912
|
-
|
|
52740
|
+
fs58.statSync("/run/.containerenv");
|
|
52913
52741
|
return true;
|
|
52914
52742
|
} catch {
|
|
52915
52743
|
return false;
|
|
@@ -52927,19 +52755,19 @@ var isWsl = () => {
|
|
|
52927
52755
|
if (process3.platform !== "linux") {
|
|
52928
52756
|
return false;
|
|
52929
52757
|
}
|
|
52930
|
-
if (
|
|
52758
|
+
if (os8.release().toLowerCase().includes("microsoft")) {
|
|
52931
52759
|
if (isInsideContainer()) {
|
|
52932
52760
|
return false;
|
|
52933
52761
|
}
|
|
52934
52762
|
return true;
|
|
52935
52763
|
}
|
|
52936
52764
|
try {
|
|
52937
|
-
if (
|
|
52765
|
+
if (fs59.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
52938
52766
|
return !isInsideContainer();
|
|
52939
52767
|
}
|
|
52940
52768
|
} catch {
|
|
52941
52769
|
}
|
|
52942
|
-
if (
|
|
52770
|
+
if (fs59.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs59.existsSync("/run/WSL")) {
|
|
52943
52771
|
return !isInsideContainer();
|
|
52944
52772
|
}
|
|
52945
52773
|
return false;
|
|
@@ -52957,14 +52785,14 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
|
52957
52785
|
const configFilePath2 = "/etc/wsl.conf";
|
|
52958
52786
|
let isConfigFileExists = false;
|
|
52959
52787
|
try {
|
|
52960
|
-
await
|
|
52788
|
+
await fs60.access(configFilePath2, fsConstants.F_OK);
|
|
52961
52789
|
isConfigFileExists = true;
|
|
52962
52790
|
} catch {
|
|
52963
52791
|
}
|
|
52964
52792
|
if (!isConfigFileExists) {
|
|
52965
52793
|
return defaultMountPoint;
|
|
52966
52794
|
}
|
|
52967
|
-
const configContent = await
|
|
52795
|
+
const configContent = await fs60.readFile(configFilePath2, { encoding: "utf8" });
|
|
52968
52796
|
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
52969
52797
|
if (!configMountPoint) {
|
|
52970
52798
|
return defaultMountPoint;
|
|
@@ -53029,7 +52857,7 @@ async function defaultBrowserId() {
|
|
|
53029
52857
|
// ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
53030
52858
|
import process6 from "node:process";
|
|
53031
52859
|
import { promisify as promisify5 } from "node:util";
|
|
53032
|
-
import { execFile as execFile4, execFileSync as
|
|
52860
|
+
import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
|
|
53033
52861
|
var execFileAsync4 = promisify5(execFile4);
|
|
53034
52862
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
53035
52863
|
if (process6.platform !== "darwin") {
|
|
@@ -53118,8 +52946,8 @@ async function defaultBrowser2() {
|
|
|
53118
52946
|
|
|
53119
52947
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
53120
52948
|
var execFile7 = promisify8(childProcess.execFile);
|
|
53121
|
-
var __dirname =
|
|
53122
|
-
var localXdgOpenPath =
|
|
52949
|
+
var __dirname = path81.dirname(fileURLToPath7(import.meta.url));
|
|
52950
|
+
var localXdgOpenPath = path81.join(__dirname, "xdg-open");
|
|
53123
52951
|
var { platform, arch } = process8;
|
|
53124
52952
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
53125
52953
|
const powershellPath = await powerShellPath();
|
|
@@ -53269,7 +53097,7 @@ var baseOpen = async (options) => {
|
|
|
53269
53097
|
const isBundled = !__dirname || __dirname === "/";
|
|
53270
53098
|
let exeLocalXdgOpen = false;
|
|
53271
53099
|
try {
|
|
53272
|
-
await
|
|
53100
|
+
await fs61.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
53273
53101
|
exeLocalXdgOpen = true;
|
|
53274
53102
|
} catch {
|
|
53275
53103
|
}
|
|
@@ -53516,7 +53344,7 @@ function createPendingAuthOnMessage(params) {
|
|
|
53516
53344
|
}
|
|
53517
53345
|
|
|
53518
53346
|
// src/cli-version.ts
|
|
53519
|
-
var CLI_VERSION2 = "0.1.
|
|
53347
|
+
var CLI_VERSION2 = "0.1.95".length > 0 ? "0.1.95" : "0.0.0-dev";
|
|
53520
53348
|
|
|
53521
53349
|
// src/auth/pending/pending-auth-on-open.ts
|
|
53522
53350
|
function createPendingAuthOnOpen(params) {
|
|
@@ -53627,12 +53455,12 @@ async function refreshBridgeTokens(params) {
|
|
|
53627
53455
|
}
|
|
53628
53456
|
|
|
53629
53457
|
// src/config.ts
|
|
53630
|
-
import
|
|
53631
|
-
import
|
|
53632
|
-
import
|
|
53458
|
+
import fs62 from "node:fs";
|
|
53459
|
+
import path82 from "node:path";
|
|
53460
|
+
import os9 from "node:os";
|
|
53633
53461
|
function getConfigPath() {
|
|
53634
|
-
const dir =
|
|
53635
|
-
return
|
|
53462
|
+
const dir = path82.join(os9.homedir(), ".buildautomaton");
|
|
53463
|
+
return path82.join(dir, "config.json");
|
|
53636
53464
|
}
|
|
53637
53465
|
function normalizeApiUrl(url2) {
|
|
53638
53466
|
return url2.replace(/\/$/, "");
|
|
@@ -53640,7 +53468,7 @@ function normalizeApiUrl(url2) {
|
|
|
53640
53468
|
function readRawConfig() {
|
|
53641
53469
|
try {
|
|
53642
53470
|
const p = getConfigPath();
|
|
53643
|
-
const raw =
|
|
53471
|
+
const raw = fs62.readFileSync(p, "utf8");
|
|
53644
53472
|
return JSON.parse(raw);
|
|
53645
53473
|
} catch {
|
|
53646
53474
|
return null;
|
|
@@ -53648,14 +53476,14 @@ function readRawConfig() {
|
|
|
53648
53476
|
}
|
|
53649
53477
|
function writeConfigForApi(apiUrl, auth) {
|
|
53650
53478
|
const p = getConfigPath();
|
|
53651
|
-
const dir =
|
|
53479
|
+
const dir = path82.dirname(p);
|
|
53652
53480
|
const key = normalizeApiUrl(apiUrl);
|
|
53653
53481
|
const prev = readRawConfig() ?? {};
|
|
53654
53482
|
const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
|
|
53655
53483
|
const next = { ...prev, servers };
|
|
53656
53484
|
try {
|
|
53657
|
-
if (!
|
|
53658
|
-
|
|
53485
|
+
if (!fs62.existsSync(dir)) fs62.mkdirSync(dir, { recursive: true });
|
|
53486
|
+
fs62.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
53659
53487
|
} catch (e) {
|
|
53660
53488
|
console.error("Could not save authentication config:", e);
|
|
53661
53489
|
}
|
|
@@ -53664,22 +53492,22 @@ function clearConfigForApi(apiUrl) {
|
|
|
53664
53492
|
const key = normalizeApiUrl(apiUrl);
|
|
53665
53493
|
try {
|
|
53666
53494
|
const p = getConfigPath();
|
|
53667
|
-
if (!
|
|
53495
|
+
if (!fs62.existsSync(p)) return;
|
|
53668
53496
|
const prev = readRawConfig();
|
|
53669
53497
|
if (!prev) return;
|
|
53670
53498
|
const servers = { ...prev.servers ?? {} };
|
|
53671
53499
|
delete servers[key];
|
|
53672
53500
|
const next = { ...prev, servers };
|
|
53673
53501
|
if (Object.keys(servers).length === 0 && !prev.workspaceId) {
|
|
53674
|
-
|
|
53502
|
+
fs62.unlinkSync(p);
|
|
53675
53503
|
return;
|
|
53676
53504
|
}
|
|
53677
53505
|
if (Object.keys(servers).length === 0 && prev.workspaceId && prev.apiUrl && normalizeApiUrl(prev.apiUrl) === key) {
|
|
53678
53506
|
const { workspaceId: _w, token: _t, refreshToken: _r, apiUrl: _a4, ...rest } = prev;
|
|
53679
|
-
|
|
53507
|
+
fs62.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
|
|
53680
53508
|
return;
|
|
53681
53509
|
}
|
|
53682
|
-
|
|
53510
|
+
fs62.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
|
|
53683
53511
|
} catch {
|
|
53684
53512
|
}
|
|
53685
53513
|
}
|
|
@@ -54252,34 +54080,10 @@ function enrichIntegrationContentPromptForAgent(params) {
|
|
|
54252
54080
|
return injectIntegrationContentAgentPromptNote(params.agentPromptText, params.sessionId);
|
|
54253
54081
|
}
|
|
54254
54082
|
|
|
54255
|
-
// src/agents/planning/enrich-planning-session-prompt-for-agent.ts
|
|
54256
|
-
async function enrichPlanningSessionPromptForAgent(params) {
|
|
54257
|
-
const meta3 = await fetchCloudSessionMeta({
|
|
54258
|
-
sessionId: params.sessionId,
|
|
54259
|
-
cloudApiBaseUrl: params.cloudApiBaseUrl,
|
|
54260
|
-
getCloudAccessToken: params.getCloudAccessToken
|
|
54261
|
-
});
|
|
54262
|
-
if (!meta3.ok) return { promptText: params.promptText, isPlanningSession: false };
|
|
54263
|
-
const sessionKind = parseSessionKind(meta3.data.sessionKind);
|
|
54264
|
-
if (sessionKind !== "planning") return { promptText: params.promptText, isPlanningSession: false };
|
|
54265
|
-
const todos = Array.isArray(meta3.data.planningTodos) ? meta3.data.planningTodos : [];
|
|
54266
|
-
if (params.isNewSession || todos.length === 0) {
|
|
54267
|
-
return {
|
|
54268
|
-
promptText: buildPlanningSessionAgentPrompt(params.promptText),
|
|
54269
|
-
isPlanningSession: true
|
|
54270
|
-
};
|
|
54271
|
-
}
|
|
54272
|
-
return {
|
|
54273
|
-
promptText: buildPlanningSessionFollowUpAgentPrompt(params.promptText, todos),
|
|
54274
|
-
isPlanningSession: true
|
|
54275
|
-
};
|
|
54276
|
-
}
|
|
54277
|
-
|
|
54278
54083
|
// src/plugin/prepare-ba-agent-prompt.ts
|
|
54279
54084
|
async function prepareBuildAutomatonAgentPrompt(params) {
|
|
54280
|
-
const { promptText, sessionId,
|
|
54085
|
+
const { promptText, sessionId, cloudApiBaseUrl, getCloudAccessToken } = params;
|
|
54281
54086
|
let agentPromptText = promptText;
|
|
54282
|
-
let isPlanningSession = false;
|
|
54283
54087
|
if (sessionId) {
|
|
54284
54088
|
agentPromptText = await enrichForkedSessionPromptForAgent({
|
|
54285
54089
|
sessionId,
|
|
@@ -54287,88 +54091,15 @@ async function prepareBuildAutomatonAgentPrompt(params) {
|
|
|
54287
54091
|
cloudApiBaseUrl,
|
|
54288
54092
|
getCloudAccessToken
|
|
54289
54093
|
});
|
|
54290
|
-
const planningEnriched = await enrichPlanningSessionPromptForAgent({
|
|
54291
|
-
sessionId,
|
|
54292
|
-
promptText: agentPromptText,
|
|
54293
|
-
isNewSession,
|
|
54294
|
-
cloudApiBaseUrl,
|
|
54295
|
-
getCloudAccessToken
|
|
54296
|
-
});
|
|
54297
|
-
agentPromptText = planningEnriched.promptText;
|
|
54298
|
-
isPlanningSession = planningEnriched.isPlanningSession;
|
|
54299
|
-
}
|
|
54300
|
-
if (sessionId) {
|
|
54301
54094
|
agentPromptText = enrichIntegrationContentPromptForAgent({
|
|
54302
54095
|
sessionId,
|
|
54303
54096
|
originalPromptText: promptText,
|
|
54304
54097
|
agentPromptText
|
|
54305
54098
|
});
|
|
54306
54099
|
}
|
|
54307
|
-
|
|
54308
|
-
|
|
54309
|
-
|
|
54310
|
-
// src/agents/planning/submit-planning-todos-for-turn.ts
|
|
54311
|
-
var PLANNING_TODO_SUBMIT_TIMEOUT_MS = 3e3;
|
|
54312
|
-
async function submitPlanningTodosForTurn(params) {
|
|
54313
|
-
const token = params.getCloudAccessToken();
|
|
54314
|
-
if (!token.trim()) return { ok: false, error: "Missing cloud access token" };
|
|
54315
|
-
const base = params.cloudApiBaseUrl.replace(/\/$/, "");
|
|
54316
|
-
const url2 = `${base}/internal/sessions/todos/submit`;
|
|
54317
|
-
let res;
|
|
54318
|
-
try {
|
|
54319
|
-
res = await fetch(url2, {
|
|
54320
|
-
method: "POST",
|
|
54321
|
-
signal: AbortSignal.timeout(PLANNING_TODO_SUBMIT_TIMEOUT_MS),
|
|
54322
|
-
headers: {
|
|
54323
|
-
Authorization: `Bearer ${token}`,
|
|
54324
|
-
"Content-Type": "application/json"
|
|
54325
|
-
},
|
|
54326
|
-
body: JSON.stringify({
|
|
54327
|
-
sessionId: params.sessionId,
|
|
54328
|
-
turnId: params.turnId,
|
|
54329
|
-
items: params.items
|
|
54330
|
-
})
|
|
54331
|
-
});
|
|
54332
|
-
} catch (error51) {
|
|
54333
|
-
return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
|
|
54334
|
-
}
|
|
54335
|
-
if (!res.ok) {
|
|
54336
|
-
const body = await res.json().catch(() => null);
|
|
54337
|
-
return { ok: false, error: body?.error ?? `Planning todo submit failed (${res.status})` };
|
|
54338
|
-
}
|
|
54339
|
-
return { ok: true };
|
|
54340
|
-
}
|
|
54341
|
-
|
|
54342
|
-
// src/agents/planning/maybe-submit-planning-todos-after-agent-success.ts
|
|
54343
|
-
async function maybeSubmitPlanningTodosAfterAgentSuccess(params) {
|
|
54344
|
-
const { sessionId, runId, resultSuccess, output, cloudApiBaseUrl, getCloudAccessToken, log: log2 } = params;
|
|
54345
|
-
const buffered = runId ? getPlanningSessionTurnOutput(runId) : "";
|
|
54346
|
-
const outputFromResult = typeof output === "string" ? output : "";
|
|
54347
|
-
const outputStr = buffered.trim() !== "" ? buffered : outputFromResult;
|
|
54348
|
-
if (!sessionId || !runId || !resultSuccess || outputStr.trim() === "") {
|
|
54349
|
-
return { submitted: false, suppressOutput: false };
|
|
54350
|
-
}
|
|
54351
|
-
if (!cloudApiBaseUrl || !getCloudAccessToken) {
|
|
54352
|
-
return { submitted: false, suppressOutput: false };
|
|
54353
|
-
}
|
|
54354
|
-
const items = parsePlanningTodoAgentJson(outputStr);
|
|
54355
|
-
if (items.length === 0) {
|
|
54356
|
-
return { submitted: false, suppressOutput: false };
|
|
54357
|
-
}
|
|
54358
|
-
const result = await submitPlanningTodosForTurn({
|
|
54359
|
-
sessionId,
|
|
54360
|
-
turnId: runId,
|
|
54361
|
-
items,
|
|
54362
|
-
cloudApiBaseUrl,
|
|
54363
|
-
getCloudAccessToken
|
|
54364
|
-
});
|
|
54365
|
-
if (!result.ok) {
|
|
54366
|
-
log2(`[Agent] Planning todo submit failed: ${result.error}`);
|
|
54367
|
-
return { submitted: false, suppressOutput: false };
|
|
54368
|
-
}
|
|
54369
|
-
if (runId) consumePlanningSessionTurnOutput(runId);
|
|
54370
|
-
log2(`[Agent] Planning session: stored ${items.length} todo(s) via internal API`);
|
|
54371
|
-
return { submitted: true, suppressOutput: true };
|
|
54100
|
+
void params.runId;
|
|
54101
|
+
void params.isNewSession;
|
|
54102
|
+
return { agentPromptText, isPlanningSession: false };
|
|
54372
54103
|
}
|
|
54373
54104
|
|
|
54374
54105
|
// src/e2e-certificates/open-import-url.ts
|
|
@@ -54727,11 +54458,6 @@ function createBuildAutomatonPlugin(options) {
|
|
|
54727
54458
|
cloudApiBaseUrl: apiUrl,
|
|
54728
54459
|
getCloudAccessToken: getAccessToken
|
|
54729
54460
|
}),
|
|
54730
|
-
maybeSubmitPlanningTodos: (params) => maybeSubmitPlanningTodosAfterAgentSuccess({
|
|
54731
|
-
...params,
|
|
54732
|
-
cloudApiBaseUrl: apiUrl,
|
|
54733
|
-
getCloudAccessToken: getAccessToken
|
|
54734
|
-
}),
|
|
54735
54461
|
persistTokens: (tokens) => writeConfigForApi(apiUrl, {
|
|
54736
54462
|
workspaceId: tokens.workspaceId,
|
|
54737
54463
|
token: tokens.token,
|