@cmmd-center/forge 0.13.88 → 0.13.90
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/bin.cjs +156 -22
- package/dist/bin.mjs +180 -46
- package/dist/client/assets/{DiffPanel-CYNKb6rV.js → DiffPanel-D3VfL4MM.js} +2 -2
- package/dist/client/assets/{DiffPanel.logic-C2oTg0F3.js → DiffPanel.logic-CsIeMtPL.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-D2jrFGJ8.js → DiffWorkerPoolProvider-CXmnKCb1.js} +2 -2
- package/dist/client/assets/{PullRequestCodePanel-V2Hpw_yq.js → PullRequestCodePanel-CXxGoEWK.js} +2 -2
- package/dist/client/assets/{Virtualizer-CRqhCU4I.js → Virtualizer-DN-C3hND.js} +2 -2
- package/dist/client/assets/{WorkerPoolContext-BwqlIoS2.js → WorkerPoolContext-DfUYmGn-.js} +3 -3
- package/dist/client/assets/{index-BdKqG5iV.js → index-C2WSp678.js} +6 -6
- package/dist/client/index.html +4 -4
- package/dist/forge-build.json +1 -1
- package/dist/{open-yHTUkd2Y.mjs → open-2-reBrpv.mjs} +3 -3
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
|
|
|
23
23
|
import * as FS$1 from "node:fs";
|
|
24
24
|
import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
25
25
|
import * as NodeOS from "node:os";
|
|
26
|
-
import
|
|
26
|
+
import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
|
|
27
27
|
import * as Path$1 from "node:path";
|
|
28
28
|
import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
29
29
|
import { pathToFileURL } from "node:url";
|
|
@@ -50617,7 +50617,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
50617
50617
|
const min = forceColor || 0;
|
|
50618
50618
|
if (env.TERM === "dumb") return min;
|
|
50619
50619
|
if (process$1.platform === "win32") {
|
|
50620
|
-
const osRelease =
|
|
50620
|
+
const osRelease = $U.release().split(".");
|
|
50621
50621
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
50622
50622
|
return 1;
|
|
50623
50623
|
}
|
|
@@ -53060,7 +53060,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
53060
53060
|
exports.processDetector = void 0;
|
|
53061
53061
|
const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
|
|
53062
53062
|
const semconv_1 = require_semconv$1();
|
|
53063
|
-
const os$
|
|
53063
|
+
const os$3 = __require("os");
|
|
53064
53064
|
/**
|
|
53065
53065
|
* ProcessDetector will be used to detect the resources related current process running
|
|
53066
53066
|
* and being instrumented from the NodeJS Process module.
|
|
@@ -53082,7 +53082,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
53082
53082
|
};
|
|
53083
53083
|
if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
|
|
53084
53084
|
try {
|
|
53085
|
-
const userInfo = os$
|
|
53085
|
+
const userInfo = os$3.userInfo();
|
|
53086
53086
|
attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
|
|
53087
53087
|
} catch (e) {
|
|
53088
53088
|
api_1.diag.debug(`error obtaining process owner: ${e}`);
|
|
@@ -66005,7 +66005,7 @@ function normalizeNumberish(value) {
|
|
|
66005
66005
|
}
|
|
66006
66006
|
//#endregion
|
|
66007
66007
|
//#region package.json
|
|
66008
|
-
var version$1 = "0.13.
|
|
66008
|
+
var version$1 = "0.13.90";
|
|
66009
66009
|
//#endregion
|
|
66010
66010
|
//#region src/sentry.ts
|
|
66011
66011
|
const SERVER_APP_NAME = "forge-server";
|
|
@@ -76051,7 +76051,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
76051
76051
|
var fs$6 = __require("fs");
|
|
76052
76052
|
var path$5 = __require("path");
|
|
76053
76053
|
var url$1 = __require("url");
|
|
76054
|
-
var os$
|
|
76054
|
+
var os$2 = __require("os");
|
|
76055
76055
|
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
76056
76056
|
var vars = process.config && process.config.variables || {};
|
|
76057
76057
|
var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
|
|
@@ -76059,8 +76059,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
76059
76059
|
var abi = versions.modules;
|
|
76060
76060
|
if (versions.deno || process.isBun) abi = "unsupported";
|
|
76061
76061
|
var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
|
|
76062
|
-
var arch = process.env.npm_config_arch || os$
|
|
76063
|
-
var platform = process.env.npm_config_platform || os$
|
|
76062
|
+
var arch = process.env.npm_config_arch || os$2.arch();
|
|
76063
|
+
var platform = process.env.npm_config_platform || os$2.platform();
|
|
76064
76064
|
var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
|
|
76065
76065
|
var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
|
|
76066
76066
|
var uv = (versions.uv || "").split(".")[0];
|
|
@@ -93893,7 +93893,7 @@ const launchDetached = (launch) => gen(function* () {
|
|
|
93893
93893
|
});
|
|
93894
93894
|
const OpenLive = effect(Open, gen(function* () {
|
|
93895
93895
|
const open = yield* tryPromise({
|
|
93896
|
-
try: () => import("./open-
|
|
93896
|
+
try: () => import("./open-2-reBrpv.mjs"),
|
|
93897
93897
|
catch: (cause) => new OpenError$1({
|
|
93898
93898
|
message: "failed to load browser opener",
|
|
93899
93899
|
cause
|
|
@@ -152366,7 +152366,8 @@ async function issueCmmdRuntimeProviderEgressCredential(input) {
|
|
|
152366
152366
|
body: JSON.stringify({
|
|
152367
152367
|
provider: input.provider,
|
|
152368
152368
|
...providerEgressModelBodyFields(input),
|
|
152369
|
-
...input.provider === "openai" && input.providerAccountId ? { provider_account_id: input.providerAccountId } : {}
|
|
152369
|
+
...input.provider === "openai" && input.providerAccountId ? { provider_account_id: input.providerAccountId } : {},
|
|
152370
|
+
...input.threadId ? { thread_id: input.threadId } : {}
|
|
152370
152371
|
})
|
|
152371
152372
|
});
|
|
152372
152373
|
if (!response.ok) throw new Error(await describeProviderTokenFailure(response));
|
|
@@ -191832,7 +191833,7 @@ var Vce = {
|
|
|
191832
191833
|
function Ve() {
|
|
191833
191834
|
return Vce;
|
|
191834
191835
|
}
|
|
191835
|
-
var Us =
|
|
191836
|
+
var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
|
|
191836
191837
|
let t = path.join(Us, "Library");
|
|
191837
191838
|
return {
|
|
191838
191839
|
data: path.join(t, "Application Support", e),
|
|
@@ -202032,12 +202033,12 @@ function qZ(e, t) {
|
|
|
202032
202033
|
}
|
|
202033
202034
|
return n;
|
|
202034
202035
|
}
|
|
202035
|
-
var os$
|
|
202036
|
+
var os$1 = "https://code.claude.com/docs/en", kKe = [
|
|
202036
202037
|
{
|
|
202037
202038
|
matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
|
|
202038
202039
|
tip: {
|
|
202039
202040
|
suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
|
|
202040
|
-
docLink: `${os$
|
|
202041
|
+
docLink: `${os$1}/iam#permission-modes`
|
|
202041
202042
|
}
|
|
202042
202043
|
},
|
|
202043
202044
|
{
|
|
@@ -202052,7 +202053,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
|
|
|
202052
202053
|
matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
|
|
202053
202054
|
tip: {
|
|
202054
202055
|
suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
|
|
202055
|
-
docLink: `${os$
|
|
202056
|
+
docLink: `${os$1}/settings#environment-variables`
|
|
202056
202057
|
}
|
|
202057
202058
|
},
|
|
202058
202059
|
{
|
|
@@ -202063,14 +202064,14 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
|
|
|
202063
202064
|
matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
|
|
202064
202065
|
tip: {
|
|
202065
202066
|
suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
|
|
202066
|
-
docLink: `${os$
|
|
202067
|
+
docLink: `${os$1}/hooks`
|
|
202067
202068
|
}
|
|
202068
202069
|
},
|
|
202069
202070
|
{
|
|
202070
202071
|
matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
|
|
202071
202072
|
tip: {
|
|
202072
202073
|
suggestion: "Command hooks require `command`. For exec form (no shell), set `command` to the executable and `args` to its arguments: {\"type\": \"command\", \"command\": \"echo\", \"args\": [\"hi\"]}. For shell form, set `command` to the full shell string: {\"type\": \"command\", \"command\": \"echo hi\"}.",
|
|
202073
|
-
docLink: `${os$
|
|
202074
|
+
docLink: `${os$1}/hooks#exec-form-and-shell-form`
|
|
202074
202075
|
}
|
|
202075
202076
|
},
|
|
202076
202077
|
{
|
|
@@ -202085,7 +202086,7 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
|
|
|
202085
202086
|
matches: (e) => e.code === "unrecognized_keys",
|
|
202086
202087
|
tip: {
|
|
202087
202088
|
suggestion: "Check for typos or refer to the documentation for valid fields",
|
|
202088
|
-
docLink: `${os$
|
|
202089
|
+
docLink: `${os$1}/settings`
|
|
202089
202090
|
}
|
|
202090
202091
|
},
|
|
202091
202092
|
{
|
|
@@ -202100,13 +202101,13 @@ var os$2 = "https://code.claude.com/docs/en", kKe = [
|
|
|
202100
202101
|
matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
|
|
202101
202102
|
tip: {
|
|
202102
202103
|
suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
|
|
202103
|
-
docLink: `${os$
|
|
202104
|
+
docLink: `${os$1}/iam#working-directories`
|
|
202104
202105
|
}
|
|
202105
202106
|
}
|
|
202106
202107
|
], AKe = {
|
|
202107
|
-
permissions: `${os$
|
|
202108
|
-
env: `${os$
|
|
202109
|
-
hooks: `${os$
|
|
202108
|
+
permissions: `${os$1}/iam#configuring-permissions`,
|
|
202109
|
+
env: `${os$1}/settings#environment-variables`,
|
|
202110
|
+
hooks: `${os$1}/hooks`
|
|
202110
202111
|
};
|
|
202111
202112
|
function GZ(e) {
|
|
202112
202113
|
let t = kKe.find((r) => r.matches(e));
|
|
@@ -241348,6 +241349,22 @@ function resolveSpriteTaskHoldConfig(env = process.env) {
|
|
|
241348
241349
|
function spriteTaskHoldName(namePrefix, turnId) {
|
|
241349
241350
|
return `${namePrefix}${turnId}`;
|
|
241350
241351
|
}
|
|
241352
|
+
/**
|
|
241353
|
+
* Thrown by the production transport when the guest API answers a non-2xx
|
|
241354
|
+
* status. Carries the status so a caller can tell a 409 (already held, and
|
|
241355
|
+
* generally benign) apart from a real transport failure.
|
|
241356
|
+
*/
|
|
241357
|
+
var SpriteTaskHoldTransportError = class extends Error {
|
|
241358
|
+
status;
|
|
241359
|
+
constructor(status) {
|
|
241360
|
+
super(`sprite task API responded ${status}`);
|
|
241361
|
+
this.name = "SpriteTaskHoldTransportError";
|
|
241362
|
+
this.status = status;
|
|
241363
|
+
}
|
|
241364
|
+
};
|
|
241365
|
+
function transportStatus(cause) {
|
|
241366
|
+
return cause instanceof SpriteTaskHoldTransportError ? cause.status : void 0;
|
|
241367
|
+
}
|
|
241351
241368
|
const noTimer = () => {};
|
|
241352
241369
|
/**
|
|
241353
241370
|
* Resolve with `promise`, but stop waiting after `timeoutMs`. Rejections pass
|
|
@@ -241381,12 +241398,25 @@ var SpriteTaskHoldManager = class {
|
|
|
241381
241398
|
#transport;
|
|
241382
241399
|
#timer;
|
|
241383
241400
|
#onError;
|
|
241401
|
+
#onEvent;
|
|
241384
241402
|
#holds = /* @__PURE__ */ new Map();
|
|
241385
241403
|
constructor(options) {
|
|
241386
241404
|
this.#config = options.config;
|
|
241387
241405
|
this.#transport = options.transport;
|
|
241388
241406
|
this.#timer = options.timer ?? DEFAULT_TIMER;
|
|
241389
241407
|
this.#onError = options.onError ?? (() => {});
|
|
241408
|
+
this.#onEvent = options.onEvent ?? (() => {});
|
|
241409
|
+
}
|
|
241410
|
+
/** Compose and report one acquire/refresh/release outcome, if a caller wants to log it. */
|
|
241411
|
+
#emitEvent(action, holdKey, hold, outcome, status) {
|
|
241412
|
+
this.#onEvent({
|
|
241413
|
+
action,
|
|
241414
|
+
holdKey,
|
|
241415
|
+
holdName: hold.name,
|
|
241416
|
+
threadId: hold.threadId,
|
|
241417
|
+
outcome,
|
|
241418
|
+
...status !== void 0 ? { status } : {}
|
|
241419
|
+
});
|
|
241390
241420
|
}
|
|
241391
241421
|
/** Turn ids that currently hold the sprite awake. Test/diagnostic surface. */
|
|
241392
241422
|
activeTurnIds() {
|
|
@@ -241395,10 +241425,19 @@ var SpriteTaskHoldManager = class {
|
|
|
241395
241425
|
/**
|
|
241396
241426
|
* `maxRefreshes` bounds a hold that has no terminal event of its own, such as a launch
|
|
241397
241427
|
* whose turn may never start. When the budget is spent the hold releases itself.
|
|
241428
|
+
*
|
|
241429
|
+
* Resolves to whether this hold has ever landed a PUT, never throwing (a
|
|
241430
|
+
* hold problem must not fail a turn). A caller handing off from a
|
|
241431
|
+
* predecessor hold (forge#3589) must not release it on anything less than
|
|
241432
|
+
* "succeeded": a failed initial PUT still installs the refresher below and
|
|
241433
|
+
* keeps retrying every `SPRITE_TASK_HOLD_REFRESH_MS`, so the predecessor is
|
|
241434
|
+
* the only thing covering the sprite until one of those retries lands. A
|
|
241435
|
+
* duplicate call against a live, unreleased hold reports that hold's own
|
|
241436
|
+
* confirmed state rather than a blanket "succeeded", for the same reason.
|
|
241398
241437
|
*/
|
|
241399
241438
|
async acquire(turnId, threadId = null, options = {}) {
|
|
241400
|
-
const existing = this.#
|
|
241401
|
-
if (existing !== void 0
|
|
241439
|
+
const existing = this.#liveHold(turnId);
|
|
241440
|
+
if (existing !== void 0) return existing.confirmed ? "succeeded" : "failed";
|
|
241402
241441
|
let refreshesLeft = options.maxRefreshes ?? Number.POSITIVE_INFINITY;
|
|
241403
241442
|
const name = spriteTaskHoldName(this.#config.namePrefix, turnId);
|
|
241404
241443
|
const hold = {
|
|
@@ -241410,24 +241449,54 @@ var SpriteTaskHoldManager = class {
|
|
|
241410
241449
|
phase: "idle",
|
|
241411
241450
|
releaseAttempt: null,
|
|
241412
241451
|
deletion: null,
|
|
241413
|
-
uncertainPut: false
|
|
241452
|
+
uncertainPut: false,
|
|
241453
|
+
confirmed: false
|
|
241414
241454
|
};
|
|
241415
241455
|
this.#holds.set(turnId, hold);
|
|
241416
241456
|
const put = this.#transport.put(name, 300);
|
|
241417
241457
|
const tracked = put.then(() => "succeeded", () => "failed");
|
|
241418
241458
|
hold.inFlight.add(tracked);
|
|
241459
|
+
let outcome = "succeeded";
|
|
241419
241460
|
try {
|
|
241420
241461
|
await put;
|
|
241421
241462
|
hold.uncertainPut = false;
|
|
241463
|
+
hold.confirmed = true;
|
|
241464
|
+
this.#emitEvent("acquire", turnId, hold, "success");
|
|
241422
241465
|
} catch (cause) {
|
|
241466
|
+
outcome = "failed";
|
|
241423
241467
|
hold.uncertainPut = true;
|
|
241424
241468
|
hold.inFlight.delete(tracked);
|
|
241425
241469
|
this.#onError(`failed to acquire sprite task hold for turn ${turnId}`, cause);
|
|
241426
|
-
|
|
241470
|
+
this.#emitEvent("acquire", turnId, hold, "failure", transportStatus(cause));
|
|
241471
|
+
if (this.#isStale(turnId, hold)) return outcome;
|
|
241427
241472
|
}
|
|
241428
241473
|
hold.inFlight.delete(tracked);
|
|
241429
|
-
if (
|
|
241430
|
-
hold.refresher = this.#
|
|
241474
|
+
if (this.#isStale(turnId, hold)) return outcome;
|
|
241475
|
+
hold.refresher = this.#installRefresher(turnId, hold, name, refreshesLeft);
|
|
241476
|
+
return outcome;
|
|
241477
|
+
}
|
|
241478
|
+
/** The hold registered for `turnId`, if it is still live: not mid-release or concluded. */
|
|
241479
|
+
#liveHold(turnId) {
|
|
241480
|
+
const existing = this.#holds.get(turnId);
|
|
241481
|
+
return existing !== void 0 && !existing.released ? existing : void 0;
|
|
241482
|
+
}
|
|
241483
|
+
/**
|
|
241484
|
+
* Whether `hold` has been superseded since the caller last checked: either
|
|
241485
|
+
* released, or no longer the map's current entry for `turnId` (a fresh
|
|
241486
|
+
* acquire replaced it). Both `acquire`'s post-await fences use this so
|
|
241487
|
+
* neither has to repeat the compound condition inline.
|
|
241488
|
+
*/
|
|
241489
|
+
#isStale(turnId, hold) {
|
|
241490
|
+
return hold.released || this.#holds.get(turnId) !== hold;
|
|
241491
|
+
}
|
|
241492
|
+
/**
|
|
241493
|
+
* Install a hold's refresh interval. Extracted out of `acquire` so that
|
|
241494
|
+
* method's own branching stays flat; the ordering and identity-fence rules
|
|
241495
|
+
* around it are unchanged, and this closure owns only the refresh tick.
|
|
241496
|
+
*/
|
|
241497
|
+
#installRefresher(turnId, hold, name, initialBudget) {
|
|
241498
|
+
let refreshesLeft = initialBudget;
|
|
241499
|
+
return this.#timer.setInterval(() => {
|
|
241431
241500
|
if (hold.inFlight.size > 0) return;
|
|
241432
241501
|
if (refreshesLeft <= 0) {
|
|
241433
241502
|
if (this.#holds.get(turnId) === hold) this.release(turnId);
|
|
@@ -241436,10 +241505,13 @@ var SpriteTaskHoldManager = class {
|
|
|
241436
241505
|
refreshesLeft -= 1;
|
|
241437
241506
|
const refresh = this.#transport.put(name, 300).then(() => {
|
|
241438
241507
|
hold.uncertainPut = false;
|
|
241508
|
+
hold.confirmed = true;
|
|
241509
|
+
this.#emitEvent("refresh", turnId, hold, "success");
|
|
241439
241510
|
return "succeeded";
|
|
241440
241511
|
}, (cause) => {
|
|
241441
241512
|
hold.uncertainPut = true;
|
|
241442
241513
|
this.#onError(`failed to refresh sprite task hold for turn ${turnId}`, cause);
|
|
241514
|
+
this.#emitEvent("refresh", turnId, hold, "failure", transportStatus(cause));
|
|
241443
241515
|
return "failed";
|
|
241444
241516
|
});
|
|
241445
241517
|
hold.inFlight.add(refresh);
|
|
@@ -241483,6 +241555,7 @@ var SpriteTaskHoldManager = class {
|
|
|
241483
241555
|
hold.phase = "joining";
|
|
241484
241556
|
const attempt = (async () => {
|
|
241485
241557
|
const outcome = await this.#concludeRelease(hold, turnId, options);
|
|
241558
|
+
this.#emitEvent("release", turnId, hold, outcome);
|
|
241486
241559
|
if (outcome === "unreleased") {
|
|
241487
241560
|
hold.phase = "idle";
|
|
241488
241561
|
this.#removeIfCurrent(turnId, hold);
|
|
@@ -241666,7 +241739,7 @@ function makeSpriteTaskHoldTransport(config, fetchImpl = fetch) {
|
|
|
241666
241739
|
signal: controller.signal,
|
|
241667
241740
|
unix: config.socketPath
|
|
241668
241741
|
});
|
|
241669
|
-
if (!response.ok) throw new
|
|
241742
|
+
if (!response.ok) throw new SpriteTaskHoldTransportError(response.status);
|
|
241670
241743
|
} finally {
|
|
241671
241744
|
clearTimeout(deadline);
|
|
241672
241745
|
}
|
|
@@ -241702,13 +241775,14 @@ function makeSpriteTaskHoldTransport(config, fetchImpl = fetch) {
|
|
|
241702
241775
|
* Build a manager for this process, or null when the runtime is not a sprite.
|
|
241703
241776
|
* Callers treat null as "this feature does not apply here".
|
|
241704
241777
|
*/
|
|
241705
|
-
function makeSpriteTaskHoldManager(env = process.env, onError) {
|
|
241778
|
+
function makeSpriteTaskHoldManager(env = process.env, onError, onEvent) {
|
|
241706
241779
|
const config = resolveSpriteTaskHoldConfig(env);
|
|
241707
241780
|
if (config === null) return null;
|
|
241708
241781
|
return new SpriteTaskHoldManager({
|
|
241709
241782
|
config,
|
|
241710
241783
|
transport: makeSpriteTaskHoldTransport(config),
|
|
241711
|
-
...onError ? { onError } : {}
|
|
241784
|
+
...onError ? { onError } : {},
|
|
241785
|
+
...onEvent ? { onEvent } : {}
|
|
241712
241786
|
});
|
|
241713
241787
|
}
|
|
241714
241788
|
//#endregion
|
|
@@ -270335,7 +270409,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
|
|
|
270335
270409
|
var dgram = __require("dgram");
|
|
270336
270410
|
var thunky = require_thunky();
|
|
270337
270411
|
var events = __require("events");
|
|
270338
|
-
var os
|
|
270412
|
+
var os = __require("os");
|
|
270339
270413
|
var noop = function() {};
|
|
270340
270414
|
module.exports = function(opts) {
|
|
270341
270415
|
if (!opts) opts = {};
|
|
@@ -270466,14 +270540,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
|
|
|
270466
270540
|
return that;
|
|
270467
270541
|
};
|
|
270468
270542
|
function defaultInterface() {
|
|
270469
|
-
var networks = os
|
|
270543
|
+
var networks = os.networkInterfaces();
|
|
270470
270544
|
var names = Object.keys(networks);
|
|
270471
270545
|
for (var i = 0; i < names.length; i++) {
|
|
270472
270546
|
var net = networks[names[i]];
|
|
270473
270547
|
for (var j = 0; j < net.length; j++) {
|
|
270474
270548
|
var iface = net[j];
|
|
270475
270549
|
if (isIPv4(iface.family) && !iface.internal) {
|
|
270476
|
-
if (os
|
|
270550
|
+
if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
|
|
270477
270551
|
return "0.0.0.0";
|
|
270478
270552
|
}
|
|
270479
270553
|
}
|
|
@@ -270481,7 +270555,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
|
|
|
270481
270555
|
return "127.0.0.1";
|
|
270482
270556
|
}
|
|
270483
270557
|
function allInterfaces() {
|
|
270484
|
-
var networks = os
|
|
270558
|
+
var networks = os.networkInterfaces();
|
|
270485
270559
|
var names = Object.keys(networks);
|
|
270486
270560
|
var res = [];
|
|
270487
270561
|
for (var i = 0; i < names.length; i++) {
|
|
@@ -286288,7 +286362,7 @@ const AgentBrowserManagerLive = effect(BrowserManager, gen(function* () {
|
|
|
286288
286362
|
const displayPeers = createWebRtcDisplaySessionManager({
|
|
286289
286363
|
mediaSourceFactory: displayCaptureRuntime.mediaSourceFactory,
|
|
286290
286364
|
taskHold: displayTaskHoldManager ? {
|
|
286291
|
-
acquire: (holdId) => displayTaskHoldManager.acquire(holdId),
|
|
286365
|
+
acquire: (holdId) => displayTaskHoldManager.acquire(holdId).then(() => {}),
|
|
286292
286366
|
release: (holdId) => displayTaskHoldManager.release(holdId).then(() => {})
|
|
286293
286367
|
} : void 0
|
|
286294
286368
|
});
|
|
@@ -294626,6 +294700,15 @@ const SpriteTaskHoldReactorLive = effect(SpriteTaskHoldReactor, gen(function* ()
|
|
|
294626
294700
|
const providerService = yield* ProviderService;
|
|
294627
294701
|
const manager = makeSpriteTaskHoldManager(process.env, (message, cause) => {
|
|
294628
294702
|
runFork(logWarning$1(message, { cause: cause instanceof Error ? cause.message : cause }));
|
|
294703
|
+
}, (event) => {
|
|
294704
|
+
runFork(logInfo("sprite task hold", {
|
|
294705
|
+
action: event.action,
|
|
294706
|
+
holdKey: event.holdKey,
|
|
294707
|
+
holdName: event.holdName,
|
|
294708
|
+
threadId: event.threadId,
|
|
294709
|
+
outcome: event.outcome,
|
|
294710
|
+
...event.status !== void 0 ? { status: event.status } : {}
|
|
294711
|
+
}));
|
|
294629
294712
|
});
|
|
294630
294713
|
/**
|
|
294631
294714
|
* Run a manager call, or nothing on runtimes that are not sprites. One
|
|
@@ -294641,27 +294724,58 @@ const SpriteTaskHoldReactorLive = effect(SpriteTaskHoldReactor, gen(function* ()
|
|
|
294641
294724
|
deleteTimeoutMs: SPRITE_TASK_HOLD_RELEASE_DELETE_TIMEOUT_MS
|
|
294642
294725
|
})));
|
|
294643
294726
|
const launchCallers = /* @__PURE__ */ new Map();
|
|
294727
|
+
const launchGeneration = /* @__PURE__ */ new Map();
|
|
294728
|
+
const turnLaunchGeneration = /* @__PURE__ */ new Map();
|
|
294729
|
+
/**
|
|
294730
|
+
* Belt-and-braces cleanup for a turn reaching a terminal state
|
|
294731
|
+
* (turn.completed or turn.aborted): a launch hold whose hand-off never
|
|
294732
|
+
* confirmed (the turn hold's PUT kept failing) is still up, refreshing on
|
|
294733
|
+
* its own budget, and the turn ending either way means the launch phase is
|
|
294734
|
+
* over. `manager.release(String(turnId))` above can itself wait on the
|
|
294735
|
+
* guest API, so by the time this runs the NEXT stage's own dispatch may
|
|
294736
|
+
* already have acquired a fresh launch hold for the same thread; only
|
|
294737
|
+
* release it here when no such newer launch has started since this turn's
|
|
294738
|
+
* own turn.started was processed (CodeRabbit review, forge#3592). A no-op
|
|
294739
|
+
* when this turn's own generation is stale, or when the hold was already
|
|
294740
|
+
* released.
|
|
294741
|
+
*/
|
|
294742
|
+
const releaseLingeringLaunchHold = async (turnId, threadId) => {
|
|
294743
|
+
const capturedGeneration = turnLaunchGeneration.get(turnId);
|
|
294744
|
+
turnLaunchGeneration.delete(turnId);
|
|
294745
|
+
if (manager === null || capturedGeneration === void 0) return;
|
|
294746
|
+
if (launchGeneration.get(threadId) !== capturedGeneration) return;
|
|
294747
|
+
await manager.release(launchHoldId(threadId));
|
|
294748
|
+
};
|
|
294644
294749
|
const start = fn$1("start")(function* () {
|
|
294645
294750
|
if (manager === null) return;
|
|
294646
294751
|
yield* forkScoped(runForEach(providerService.streamEvents, (event) => {
|
|
294647
294752
|
if (event.type === "turn.started") {
|
|
294648
294753
|
const turnId = event.turnId;
|
|
294649
294754
|
if (turnId === void 0) return void_$1;
|
|
294755
|
+
const threadId = String(event.threadId);
|
|
294756
|
+
const generation = launchGeneration.get(threadId) ?? 0;
|
|
294650
294757
|
return promise(async () => {
|
|
294651
|
-
await manager.acquire(String(turnId),
|
|
294652
|
-
launchCallers.delete(
|
|
294653
|
-
|
|
294758
|
+
const outcome = await manager.acquire(String(turnId), threadId);
|
|
294759
|
+
launchCallers.delete(threadId);
|
|
294760
|
+
turnLaunchGeneration.set(String(turnId), generation);
|
|
294761
|
+
if (outcome === "succeeded") await manager.release(launchHoldId(threadId));
|
|
294654
294762
|
});
|
|
294655
294763
|
}
|
|
294656
294764
|
if (event.type === "turn.completed") {
|
|
294657
294765
|
const turnId = event.turnId;
|
|
294658
294766
|
if (turnId === void 0) return void_$1;
|
|
294659
|
-
return promise(
|
|
294767
|
+
return promise(async () => {
|
|
294768
|
+
await manager.release(String(turnId));
|
|
294769
|
+
await releaseLingeringLaunchHold(String(turnId), String(event.threadId));
|
|
294770
|
+
});
|
|
294660
294771
|
}
|
|
294661
294772
|
if (event.type === "turn.aborted") {
|
|
294662
294773
|
const turnId = event.turnId;
|
|
294663
294774
|
if (turnId === void 0) return void_$1;
|
|
294664
|
-
return promise(
|
|
294775
|
+
return promise(async () => {
|
|
294776
|
+
await manager.release(String(turnId));
|
|
294777
|
+
await releaseLingeringLaunchHold(String(turnId), String(event.threadId));
|
|
294778
|
+
});
|
|
294665
294779
|
}
|
|
294666
294780
|
if (event.type === "session.exited") {
|
|
294667
294781
|
launchCallers.delete(String(event.threadId));
|
|
@@ -294673,7 +294787,9 @@ const SpriteTaskHoldReactorLive = effect(SpriteTaskHoldReactor, gen(function* ()
|
|
|
294673
294787
|
/** Takes the launch hold for one more caller. The budget bounds a launch that never starts a turn. */
|
|
294674
294788
|
const holdLaunch = (threadId) => promise(async () => {
|
|
294675
294789
|
if (manager === null) return;
|
|
294676
|
-
|
|
294790
|
+
const callers = launchCallers.get(threadId) ?? 0;
|
|
294791
|
+
launchCallers.set(threadId, callers + 1);
|
|
294792
|
+
if (callers === 0) launchGeneration.set(threadId, (launchGeneration.get(threadId) ?? 0) + 1);
|
|
294677
294793
|
await manager.acquire(launchHoldId(threadId), threadId, { maxRefreshes: LAUNCH_HOLD_MAX_REFRESHES });
|
|
294678
294794
|
});
|
|
294679
294795
|
/** Lets one caller go. The hold itself is released when the last caller has let go. */
|
|
@@ -298813,7 +298929,7 @@ function resolveBuildCommitFromEnv(env) {
|
|
|
298813
298929
|
* environment descriptor down instead of reporting an honest "unknown".
|
|
298814
298930
|
*/
|
|
298815
298931
|
function readBakedBuildCommit() {
|
|
298816
|
-
return "
|
|
298932
|
+
return "9608e243c924d4030658e7cc80c7be65887b2073";
|
|
298817
298933
|
}
|
|
298818
298934
|
async function resolveServerBuildCommit(input) {
|
|
298819
298935
|
if (isFullCommitSha(input.baked)) return input.baked;
|
|
@@ -316167,6 +316283,7 @@ const PipelineRunCoordinatorLive = effect(PipelineRunCoordinator, gen(function*
|
|
|
316167
316283
|
const policy = yield* PipelineStagePolicy;
|
|
316168
316284
|
const secretStore = yield* ServerSecretStore;
|
|
316169
316285
|
const orchestration = yield* OrchestrationEngineService;
|
|
316286
|
+
const spriteTaskHoldReactor = yield* serviceOption(SpriteTaskHoldReactor);
|
|
316170
316287
|
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
|
|
316171
316288
|
const projectionTurns = yield* ProjectionTurnRepository;
|
|
316172
316289
|
const changeInspector = yield* PipelineChangeInspector;
|
|
@@ -316894,6 +317011,23 @@ const PipelineRunCoordinatorLive = effect(PipelineRunCoordinator, gen(function*
|
|
|
316894
317011
|
});
|
|
316895
317012
|
yield* drainReports();
|
|
316896
317013
|
});
|
|
317014
|
+
/**
|
|
317015
|
+
* Holds the sprite awake around a freshly dispatched thread.turn.start, the
|
|
317016
|
+
* same way bootstrapLaunch.ts's withLaunchHold does for a turn started from
|
|
317017
|
+
* the Forge web composer or a bootstrap launch (forge#3589). A turn kicked
|
|
317018
|
+
* from a CMMD card reaches the engine through dispatchStage /
|
|
317019
|
+
* recoverMissingProviderStart below, never through that HTTP dispatch
|
|
317020
|
+
* route, so nothing else covers the window between this dispatch and the
|
|
317021
|
+
* provider's own turn.started.
|
|
317022
|
+
*
|
|
317023
|
+
* Releases only on error: a successful dispatch hands the hold off to the
|
|
317024
|
+
* turn's own, in SpriteTaskHoldReactor's turn.started handler.
|
|
317025
|
+
*/
|
|
317026
|
+
const withPipelineLaunchHold = (threadId, dispatch) => {
|
|
317027
|
+
if (isNone(spriteTaskHoldReactor)) return dispatch;
|
|
317028
|
+
const reactor = spriteTaskHoldReactor.value;
|
|
317029
|
+
return uninterruptible(reactor.holdLaunch(threadId)).pipe(andThen(yieldNow), andThen(dispatch), onError$1(() => reactor.releaseLaunch(threadId)));
|
|
317030
|
+
};
|
|
316897
317031
|
const dispatchStage = (binding, snapshot, authority) => gen(function* () {
|
|
316898
317032
|
const thread = (yield* orchestration.getReadModel()).threads.find((candidate) => candidate.id === ThreadId.make(binding.threadId) && candidate.deletedAt === null);
|
|
316899
317033
|
if (thread === void 0) {
|
|
@@ -316969,7 +317103,7 @@ const PipelineRunCoordinatorLive = effect(PipelineRunCoordinator, gen(function*
|
|
|
316969
317103
|
messageId: `${commandId}:message`,
|
|
316970
317104
|
createdAt: startedAt
|
|
316971
317105
|
});
|
|
316972
|
-
yield* orchestration.dispatch(command).pipe(tapError(() => store.resetDispatch(binding.runId, commandId)));
|
|
317106
|
+
yield* withPipelineLaunchHold(binding.threadId, orchestration.dispatch(command)).pipe(tapError(() => store.resetDispatch(binding.runId, commandId)));
|
|
316973
317107
|
yield* store.markDispatched(binding.runId, commandId);
|
|
316974
317108
|
});
|
|
316975
317109
|
const resumeRun = (runId) => gen(function* () {
|
|
@@ -317609,7 +317743,7 @@ const PipelineRunCoordinatorLive = effect(PipelineRunCoordinator, gen(function*
|
|
|
317609
317743
|
});
|
|
317610
317744
|
if (workerCoordination.kind !== "single" && workerCoordination.kind !== "ready") return;
|
|
317611
317745
|
const commandId = `${originalCommandId}:provider-start-recovery`;
|
|
317612
|
-
yield* orchestration.dispatch(buildStageTurnCommand({
|
|
317746
|
+
yield* withPipelineLaunchHold(input.binding.threadId, orchestration.dispatch(buildStageTurnCommand({
|
|
317613
317747
|
binding: input.binding,
|
|
317614
317748
|
attempt: input.binding.attempt,
|
|
317615
317749
|
snapshot: input.snapshot,
|
|
@@ -317620,7 +317754,7 @@ const PipelineRunCoordinatorLive = effect(PipelineRunCoordinator, gen(function*
|
|
|
317620
317754
|
commandId,
|
|
317621
317755
|
messageId: `${commandId}:message`,
|
|
317622
317756
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
317623
|
-
}));
|
|
317757
|
+
})));
|
|
317624
317758
|
});
|
|
317625
317759
|
}
|
|
317626
317760
|
function reconcileActiveThread(input) {
|
|
@@ -323444,7 +323578,7 @@ const connectLoginCommand = make$34("login", {
|
|
|
323444
323578
|
})).json();
|
|
323445
323579
|
},
|
|
323446
323580
|
openBrowser: async (url) => {
|
|
323447
|
-
const open = (await import("./open-
|
|
323581
|
+
const open = (await import("./open-2-reBrpv.mjs")).default;
|
|
323448
323582
|
await open(url);
|
|
323449
323583
|
return true;
|
|
323450
323584
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as r,Wa as i}from"./Stream-mUTFnSY9.js";import{Fn as a,Gr as o,Hl as s,Jr as c,Or as l,Tn as u,Wr as d,al as f,c as p,d as m,fn as h,fr as g,gr as _,hr as v,ii as y,jn as b,js as x,m as S,ni as C,o as w,ol as T,qo as E,qt as D,rl as O,rs as k,s as A,t as j,tl as M,u as N}from"./WorkerPoolContext-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as r,Wa as i}from"./Stream-mUTFnSY9.js";import{Fn as a,Gr as o,Hl as s,Jr as c,Or as l,Tn as u,Wr as d,al as f,c as p,d as m,fn as h,fr as g,gr as _,hr as v,ii as y,jn as b,js as x,m as S,ni as C,o as w,ol as T,qo as E,qt as D,rl as O,rs as k,s as A,t as j,tl as M,u as N}from"./WorkerPoolContext-DfUYmGn-.js";import{hn as P}from"./CompositeItem-DU4kdAw6.js";import{a as F,c as I,f as L,i as R,l as z,m as B,n as V,o as H,p as U,r as W,s as G,t as K}from"./Virtualizer-DN-C3hND.js";import{Dn as q,at as J,it as ee}from"./src-CF8xm6xH.js";import"./cmmdAuthRedirect-CCwq2L-I.js";import{a as te,c as ne,d as re,h as ie,i as ae,l as oe,m as se,n as ce,o as Y,p as le,r as ue,s as de,t as fe,u as pe}from"./DiffPanel.logic-CsIeMtPL.js";var X=e(i(),1),me=typeof window>`u`?X.useEffect:X.useLayoutEffect;function he({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=V(),f=i!==void 0,m=(0,X.useContext)(j),h=A(),g=(0,X.useRef)(null),_=p(n=>{if(n!=null){if(g.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?g.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:m,!0):g.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:m,!0),g.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(g.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);g.current.cleanUp(),g.current=null}});return me(()=>{let{current:n}=g;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!D(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&g.current!=null){if(h===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=h(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(g.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:_,getHoveredLine:(0,X.useCallback)(()=>g.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?w:e?.renderCustomHeader,renderGutterUtility:r?w:e?.renderGutterUtility}:e}var Q=r();function ge({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:m,disableWorkerPool:g=!1,edit:_=!1}){let{ref:v,getHoveredLine:y}=he({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c,hasGutterRenderUtility:m!=null,hasCustomHeader:u!=null,disableWorkerPool:g,edit:_});return(0,Q.jsx)(h,{ref:v,className:o,style:s,children:W(oe({fileDiff:e,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderAnnotation:l,renderGutterUtility:m,lineAnnotations:i,getHoveredLine:y}),c)})}var $=t();function _e(e){return e.fromTurnCount===0?q(ee)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`fullThreadDiff`,input:e}))):q(J)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`turnDiff`,input:e})))}function ve(e){return e instanceof Error?e.message:typeof e==`string`?e:``}function ye(e){let t=ve(e).trim();if(t.length===0)return`Failed to load checkpoint diff.`;let n=t.toLowerCase();if(n.includes(`not a git repository`))return`Turn diffs are unavailable because this project is not a git repository.`;if(n.includes(`checkpoint unavailable for thread`)||n.includes(`checkpoint invariant violation`)){let e=t.indexOf(`:`);if(e>=0){let n=t.slice(e+1).trim();if(n.length>0)return n}}return t}function be(e){let t=ve(e).toLowerCase();return t.includes(`exceeds current turn count`)||t.includes(`checkpoint is unavailable for turn`)||t.includes(`filesystem checkpoint is unavailable`)}function xe(e){let t=_e(e);return f({queryKey:x.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=c(e.environmentId);try{return t.value.kind===`fullThreadDiff`?await r.orchestration.getFullThreadDiff(t.value.input,{signal:n}):await r.orchestration.getTurnDiff(t.value.input,{signal:n})}catch(e){throw Error(ye(e),{cause:e})}},enabled:(e.enabled??!0)&&!!e.environmentId&&!!e.threadId&&t._tag===`Some`,staleTime:1/0,retry:(e,t)=>be(t)?e<12:e<3,retryDelay:(e,t)=>be(t)?Math.min(5e3,250*2**(e-1)):Math.min(1e3,100*2**(e-1))})}function Se(e){if(!(!e.canScrollLeft&&!e.canScrollRight))return{maskImage:`linear-gradient(to right, ${e.canScrollLeft?`transparent 24px, black 72px`:`black`}, ${e.canScrollRight?`black calc(100% - 72px), transparent calc(100% - 24px)`:`black`})`}}function Ce(e){return e instanceof Error?e.message:e?`Failed to load checkpoint diff.`:null}function we(e){return{environmentId:e.environmentId??null,threadId:e.threadId,fromTurnCount:e.range?.fromTurnCount??null,toTurnCount:e.range?.toTurnCount??null,cacheScope:e.selectedTurnId?`turn:${e.selectedTurnId}`:e.conversationCacheScope,enabled:e.enabled}}function Te(){let e=(0,$.c)(8),t=(0,X.useRef)(null),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e){r(!1),a(!1);return}let n=de({scrollLeft:e.scrollLeft,scrollWidth:e.scrollWidth,clientWidth:e.clientWidth});r(n.canScrollLeft),a(n.canScrollRight)},e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{t.current?.scrollBy({left:e,behavior:`smooth`})},e[1]=c):c=e[1];let l=c,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let n=t.current;n&&ne({scrollWidth:n.scrollWidth,clientWidth:n.clientWidth,deltaX:e.deltaX,deltaY:e.deltaY})&&(e.preventDefault(),n.scrollBy({left:e.deltaY,behavior:`auto`}))},e[2]=u):u=e[2];let d=u,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=t.current;if(!e)return;let n=window.requestAnimationFrame(s),r=()=>s();e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(()=>s());return i.observe(e),()=>{window.cancelAnimationFrame(n),e.removeEventListener(`scroll`,r),i.disconnect()}},p=[s],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,X.useEffect)(f,p);let m;return e[5]!==n||e[6]!==i?(m={ref:t,canScrollLeft:n,canScrollRight:i,scrollBy:l,onWheel:d,remeasure:s},e[5]=n,e[6]=i,e[7]=m):m=e[7],m}function Ee(e,t){let n=(0,$.c)(5),r;n[0]===e.current?r=n[1]:(r=()=>{(e.current?.querySelector(`[data-turn-chip-selected='true']`))?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},n[0]=e.current,n[1]=r);let i;n[2]!==e||n[3]!==t?(i=[e,t],n[2]=e,n[3]=t,n[4]=i):i=n[4],(0,X.useEffect)(r,i)}var De=`
|
|
2
2
|
[data-diffs-header],
|
|
3
3
|
[data-diff],
|
|
4
4
|
[data-file],
|
|
@@ -61,4 +61,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as
|
|
|
61
61
|
text-decoration-color: currentColor;
|
|
62
62
|
}
|
|
63
63
|
`;function Oe(e){let t=(0,$.c)(44),{mode:n}=e,r=n===void 0?`inline`:n,{resolvedTheme:i}=v(),s=_(),[c,d]=(0,X.useState)(`stacked`),[f,p]=(0,X.useState)(s.diffWordWrap),h=(0,X.useRef)(null),g=(0,X.useRef)(!1),y=Te(),{activeCwd:b,activeThread:x,bodyState:S,diffOpen:C,inferredCheckpointTurnCountByTurnId:w,orderedTurnDiffSummaries:T,renderableFiles:E,renderablePatch:D,selectedFilePath:k,selectedTurn:A,selectedTurnId:j}=Le(i),N,P;t[0]!==C||t[1]!==s.diffWordWrap?(N=()=>{C&&!g.current&&p(s.diffWordWrap),g.current=C},P=[C,s.diffWordWrap],t[0]=C,t[1]=s.diffWordWrap,t[2]=N,t[3]=P):(N=t[2],P=t[3]),(0,X.useEffect)(N,P);let F;t[4]===k?F=t[5]:(F=()=>{!k||!h.current||Array.from(h.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===k)?.scrollIntoView({block:`nearest`})},t[4]=k,t[5]=F);let I;t[6]!==E||t[7]!==k?(I=[k,E],t[6]=E,t[7]=k,t[8]=I):I=t[8],(0,X.useEffect)(F,I);let L;t[9]===b?L=t[10]:(L=e=>{let t=l();if(!t)return;let n=b?u(e,b):e;o(t,n).catch(ke)},t[9]=b,t[10]=L);let R=L,z;t[11]===x?z=t[12]:(z=e=>{x&&a.getState().openDiff(O(M(x.environmentId,x.id)),e)},t[11]=x,t[12]=z);let B=z,V;t[13]===x?V=t[14]:(V=()=>{x&&a.getState().openDiff(O(M(x.environmentId,x.id)))},t[13]=x,t[14]=V);let H=V,U;t[15]===y.remeasure?U=t[16]:(U=()=>{let e=window.requestAnimationFrame(y.remeasure);return()=>window.cancelAnimationFrame(e)},t[15]=y.remeasure,t[16]=U);let W;t[17]!==T||t[18]!==j||t[19]!==y.remeasure?(W=[T,j,y.remeasure],t[17]=T,t[18]=j,t[19]=y.remeasure,t[20]=W):W=t[20],(0,X.useEffect)(U,W),Ee(y.ref,A?.turnId??j);let G;t[21]!==c||t[22]!==f||t[23]!==w||t[24]!==T||t[25]!==B||t[26]!==H||t[27]!==A||t[28]!==j||t[29]!==s||t[30]!==y?(G=(0,Q.jsx)(Ae,{diffRenderMode:c,diffWordWrap:f,inferredCheckpointTurnCountByTurnId:w,orderedTurnDiffSummaries:T,selectTurn:B,selectWholeConversation:H,selectedTurn:A,selectedTurnId:j,setDiffRenderMode:d,setDiffWordWrap:p,settings:s,turnStrip:y}),t[21]=c,t[22]=f,t[23]=w,t[24]=T,t[25]=B,t[26]=H,t[27]=A,t[28]=j,t[29]=s,t[30]=y,t[31]=G):G=t[31];let K=G,q;t[32]!==S||t[33]!==c||t[34]!==f||t[35]!==R||t[36]!==E||t[37]!==D||t[38]!==i?(q=(0,Q.jsx)(je,{bodyState:S,diffRenderMode:c,diffWordWrap:f,openDiffFileInEditor:R,patchViewportRef:h,renderableFiles:E,renderablePatch:D,resolvedTheme:i}),t[32]=S,t[33]=c,t[34]=f,t[35]=R,t[36]=E,t[37]=D,t[38]=i,t[39]=q):q=t[39];let J;return t[40]!==K||t[41]!==r||t[42]!==q?(J=(0,Q.jsx)(m,{mode:r,header:K,children:q}),t[40]=K,t[41]=r,t[42]=q,t[43]=J):J=t[43],J}function ke(e){console.warn(`Failed to open diff file in editor.`,e)}function Ae(e){let t=(0,$.c)(59),{diffRenderMode:n,diffWordWrap:r,inferredCheckpointTurnCountByTurnId:i,orderedTurnDiffSummaries:a,selectTurn:o,selectWholeConversation:s,selectedTurn:c,selectedTurnId:l,setDiffRenderMode:u,setDiffWordWrap:d,settings:f,turnStrip:p}=e,m,h;t[0]===p?(m=t[1],h=t[2]):(m=(0,Q.jsx)(Be,{direction:`left`,strip:p}),h=(0,Q.jsx)(Be,{direction:`right`,strip:p}),t[0]=p,t[1]=m,t[2]=h);let g=p.ref,_;t[3]!==p.canScrollLeft||t[4]!==p.canScrollRight?(_=Se({canScrollLeft:p.canScrollLeft,canScrollRight:p.canScrollRight}),t[3]=p.canScrollLeft,t[4]=p.canScrollRight,t[5]=_):_=t[5];let v=p.onWheel,y=l===null,b=l===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,x;t[6]===b?x=t[7]:(x=P(`rounded-md border px-2 py-1 text-left transition-colors`,b),t[6]=b,t[7]=x);let S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`}),t[8]=S):S=t[8];let C;t[9]===x?C=t[10]:(C=(0,Q.jsx)(`div`,{className:x,children:S}),t[9]=x,t[10]=C);let w;t[11]!==s||t[12]!==C||t[13]!==y?(w=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,"data-turn-chip-selected":y,children:C}),t[11]=s,t[12]=C,t[13]=y,t[14]=w):w=t[14];let T;if(t[15]!==i||t[16]!==a||t[17]!==o||t[18]!==c?.turnId||t[19]!==f){let e;t[21]!==i||t[22]!==o||t[23]!==c?.turnId||t[24]!==f?(e=e=>(0,Q.jsx)(Ve,{summary:e,selected:e.turnId===c?.turnId,turnCount:e.checkpointTurnCount??i[e.turnId],timestampFormat:f.timestampFormat,onSelect:o},e.turnId),t[21]=i,t[22]=o,t[23]=c?.turnId,t[24]=f,t[25]=e):e=t[25],T=a.map(e),t[15]=i,t[16]=a,t[17]=o,t[18]=c?.turnId,t[19]=f,t[20]=T}else T=t[20];let E;t[26]!==w||t[27]!==T||t[28]!==_||t[29]!==p.onWheel||t[30]!==p.ref?(E=(0,Q.jsxs)(`div`,{ref:g,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,style:_,onWheel:v,children:[w,T]}),t[26]=w,t[27]=T,t[28]=_,t[29]=p.onWheel,t[30]=p.ref,t[31]=E):E=t[31];let D;t[32]!==m||t[33]!==E||t[34]!==h?(D=(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 [-webkit-app-region:no-drag]`,children:[m,h,E]}),t[32]=m,t[33]=E,t[34]=h,t[35]=D):D=t[35];let O;t[36]===n?O=t[37]:(O=[n],t[36]=n,t[37]=O);let k;t[38]===u?k=t[39]:(k=e=>{let t=e[0];(t===`stacked`||t===`split`)&&u(t)},t[38]=u,t[39]=k);let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(R,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,Q.jsx)(se,{className:`size-3`})}),t[40]=A):A=t[40];let j;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(R,{"aria-label":`Split diff view`,value:`split`,children:(0,Q.jsx)(ie,{className:`size-3`})}),t[41]=j):j=t[41];let M;t[42]!==O||t[43]!==k?(M=(0,Q.jsxs)(F,{className:`shrink-0`,variant:`outline`,size:`xs`,value:O,onValueChange:k,children:[A,j]}),t[42]=O,t[43]=k,t[44]=M):M=t[44];let N=r?`Disable diff line wrapping`:`Enable diff line wrapping`,I=r?`Disable line wrapping`:`Enable line wrapping`,L;t[45]===d?L=t[46]:(L=e=>{d(!!e)},t[45]=d,t[46]=L);let z;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(le,{className:`size-3`}),t[47]=z):z=t[47];let B;t[48]!==r||t[49]!==N||t[50]!==I||t[51]!==L?(B=(0,Q.jsx)(R,{"aria-label":N,title:I,variant:`outline`,size:`xs`,pressed:r,onPressedChange:L,children:z}),t[48]=r,t[49]=N,t[50]=I,t[51]=L,t[52]=B):B=t[52];let V;t[53]!==M||t[54]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[M,B]}),t[53]=M,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==D||t[57]!==V?(H=(0,Q.jsxs)(Q.Fragment,{children:[D,V]}),t[56]=D,t[57]=V,t[58]=H):H=t[58],H}function je(e){let t=(0,$.c)(18),{bodyState:n,diffRenderMode:r,diffWordWrap:i,openDiffFileInEditor:a,patchViewportRef:o,renderableFiles:s,renderablePatch:c,resolvedTheme:l}=e;if(n.kind===`no-thread`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Select a thread to inspect turn diffs.`}),t[0]=e):e=t[0],e}if(n.kind===`not-git-repo`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Turn diffs are unavailable because this project is not a git repository.`}),t[1]=e):e=t[1],e}if(n.kind===`no-completed-turns`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`No completed turns yet.`}),t[2]=e):e=t[2],e}let u;t[3]!==n.error||t[4]!==c?(u=n.error&&!c&&(0,Q.jsx)(`div`,{className:`px-3`,children:(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-destructive-foreground`,children:n.error})}),t[3]=n.error,t[4]=c,t[5]=u):u=t[5];let d;t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(d=c?c.kind===`files`?(0,Q.jsx)(K,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:s.map(e=>{let t=Y(e),n=`${fe(e)}:${l}`;return(0,Q.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,onClickCapture:e=>{(e.nativeEvent.composedPath?.()??[]).some(Me)&&a(t)},children:(0,Q.jsx)(ge,{fileDiff:e,options:{diffStyle:r===`split`?`split`:`unified`,lineDiffType:`none`,overflow:i?`wrap`:`scroll`,theme:S(l),themeType:l,unsafeCSS:De}})},n)})}):(0,Q.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:c.reason}),(0,Q.jsx)(`pre`,{className:P(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,i?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:c.text})]})}):(0,Q.jsx)(Re,{bodyState:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;return t[14]!==o||t[15]!==u||t[16]!==d?(f=(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{ref:o,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:[u,d]})}),t[14]=o,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Me(e){return e instanceof Element&&e.hasAttribute(`data-title`)}function Ne(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r}function Pe(){let e=(0,$.c)(19),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={strict:!1,select:Ie},e[0]=t):t=e[0];let n=s(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={strict:!1,select:Fe},e[1]=r):r=e[1];let i=B(r),a=i.rightPanel===`diff`,o=n?.threadId??null,c,l;e[2]===n?l=e[3]:(l=b(n),e[2]=n,e[3]=l),c=l;let u=k(c),f=He(u),p=u?.worktreePath,m=f?.cwd,h;e[4]!==p||e[5]!==m?(h=I({threadWorktreePath:p,projectCwd:m}),e[4]=p,e[5]=m,e[6]=h):h=e[6];let g=h,_=u?.environmentId??null,v=g??null,y;e[7]!==_||e[8]!==v?(y={environmentId:_,cwd:v},e[7]=_,e[8]=v,e[9]=y):y=e[9];let x=d(y),S;e[10]===x.data?S=e[11]:(S=z(x.data),e[10]=x.data,e[11]=S);let C=S,w;return e[12]!==g||e[13]!==u||e[14]!==o||e[15]!==a||e[16]!==i||e[17]!==C?(w={activeThread:u,activeThreadId:o,activeCwd:g,isGitRepo:C,diffSearch:i,diffOpen:a},e[12]=g,e[13]=u,e[14]=o,e[15]=a,e[16]=i,e[17]=C,e[18]=w):w=e[18],w}function Fe(e){return G(e)}function Ie(e){return C(e)}function Le(e){let{activeThread:t,activeThreadId:n,activeCwd:r,isGitRepo:i,diffSearch:a,diffOpen:o}=Pe(),{turnDiffSummaries:s,inferredCheckpointTurnCountByTurnId:c}=H(t),l=a.diffTurnId??null,u=l===null?null:a.diffFilePath??null,{activeCheckpointRange:d,conversationCacheScope:f,orderedTurnDiffSummaries:p,selectedTurn:m}=(0,X.useMemo)(()=>te({summaries:s,inferredCheckpointTurnCountByTurnId:c,selectedTurnId:l}),[c,l,s]),h=T(xe(we({environmentId:t?.environmentId,threadId:n,range:d,selectedTurnId:m?.turnId,conversationCacheScope:f,enabled:i}))),g=h.isLoading,_=Ce(h.error),v=h.data?.diff,y=typeof v==`string`&&v.trim().length===0,{emptyDiffMessage:b}=(0,X.useMemo)(()=>ae(m),[m]),x=(0,X.useMemo)(()=>ce(v,`diff-panel:${e}`),[e,v]),S=(0,X.useMemo)(()=>Ue(x),[x]);return{activeCwd:r,activeThread:t,bodyState:ue({hasActiveThread:!!t,isGitRepo:i,turnSummaryCount:p.length,checkpointDiffError:_,hasRenderablePatch:!!x,isLoadingCheckpointDiff:g,hasNoNetChanges:y,emptyDiffMessage:b}),diffOpen:o,inferredCheckpointTurnCountByTurnId:c,orderedTurnDiffSummaries:p,renderableFiles:S,renderablePatch:x,selectedFilePath:u,selectedTurn:m,selectedTurnId:l}}function Re(e){let t=(0,$.c)(4),{bodyState:n}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(N,{label:`Loading checkpoint diff...`}),t[0]=e):e=t[0],e}let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(L,{className:`size-7 text-muted-foreground/25`}),t[1]=r):r=t[1];let i=n.kind===`empty`?n.message:`No diff is available for this range.`,a;return t[2]===i?a=t[3]:(a=(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-5 py-2 text-center`,children:[r,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:i})]}),t[2]=i,t[3]=a),a}var ze=180;function Be(e){let t=(0,$.c)(14),{direction:n,strip:r}=e,i=n===`left`,a=i?r.canScrollLeft:r.canScrollRight,o=i?U:y,s=i?`left-0`:`right-0`,c=a?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`,l;t[0]!==s||t[1]!==c?(l=P(`absolute top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==i||t[4]!==r?(u=()=>r.scrollBy(i?-180:ze),t[3]=i,t[4]=r,t[5]=u):u=t[5];let d=!a,f=`Scroll turn list ${n}`,p;t[6]===o?p=t[7]:(p=(0,Q.jsx)(o,{className:`size-3.5`}),t[6]=o,t[7]=p);let m;return t[8]!==l||t[9]!==u||t[10]!==d||t[11]!==f||t[12]!==p?(m=(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:u,disabled:d,"aria-label":f,children:p}),t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m):m=t[13],m}function Ve(e){let t=(0,$.c)(23),{summary:n,selected:r,turnCount:i,timestampFormat:a,onSelect:o}=e,s;t[0]!==o||t[1]!==n.turnId?(s=()=>o(n.turnId),t[0]=o,t[1]=n.turnId,t[2]=s):s=t[2];let c=n.turnId,l=r?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,u;t[3]===l?u=t[4]:(u=P(`rounded-md border px-2 py-1 text-left transition-colors`,l),t[3]=l,t[4]=u);let d=i??`?`,f;t[5]===d?f=t[6]:(f=(0,Q.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,d]}),t[5]=d,t[6]=f);let p;t[7]!==n.completedAt||t[8]!==a?(p=g(n.completedAt,a),t[7]=n.completedAt,t[8]=a,t[9]=p):p=t[9];let m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:p}),t[10]=p,t[11]=m);let h;t[12]!==f||t[13]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14];let _;t[15]!==u||t[16]!==h?(_=(0,Q.jsx)(`div`,{className:u,children:h}),t[15]=u,t[16]=h,t[17]=_):_=t[17];let v;return t[18]!==r||t[19]!==n.turnId||t[20]!==s||t[21]!==_?(v=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,title:c,"data-turn-chip-selected":r,children:_}),t[18]=r,t[19]=n.turnId,t[20]=s,t[21]=_,t[22]=v):v=t[22],v}function He(e){let t=(0,$.c)(3),n=e?.environmentId,r=e?.projectId,i;return t[0]!==n||t[1]!==r?(i=e=>n&&r?E(e,{environmentId:n,projectId:r}):void 0,t[0]=n,t[1]=r,t[2]=i):i=t[2],k(i)}function Ue(e){return!e||e.kind!==`files`?[]:e.files.toSorted((e,t)=>Y(e).localeCompare(Y(t),void 0,{numeric:!0,sensitivity:`base`}))}export{Oe as default};
|
|
64
|
-
//# sourceMappingURL=DiffPanel-
|
|
64
|
+
//# sourceMappingURL=DiffPanel-D3VfL4MM.js.map
|