@runweave/server-win32-x64 0.1.26 → 0.1.28
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/manifest.json +156 -154
- package/native.tar.gz +0 -0
- package/package.json +1 -1
- package/payload/app-server/build-info.json +4 -4
- package/payload/app-server/index.cjs +663 -333
- package/payload/app-server/index.cjs.map +1 -1
- package/payload/backend/build-info.json +4 -4
- package/payload/backend/index.cjs +694 -301
- package/payload/frontend/dist/assets/{_baseUniq-CvQ_Kf6J.js → _baseUniq-CMN8EMJe.js} +1 -1
- package/payload/frontend/dist/assets/{access-BM48T8pi.js → access-DFaVCfwr.js} +1 -1
- package/payload/frontend/dist/assets/{advanced-tiNwdsWg.js → advanced-CKAJ9tXg.js} +1 -1
- package/payload/frontend/dist/assets/{appearance-BkACCLPd.js → appearance-CKvvyFpM.js} +1 -1
- package/payload/frontend/dist/assets/{arc-CG4ZorIz.js → arc-Cbf15wI1.js} +1 -1
- package/payload/frontend/dist/assets/{architectureDiagram-Q4EWVU46-ChTaJQWa.js → architectureDiagram-Q4EWVU46-Bvi3ZBt1.js} +1 -1
- package/payload/frontend/dist/assets/{blockDiagram-DXYQGD6D-wyOyxXn6.js → blockDiagram-DXYQGD6D-DgDkN-KK.js} +1 -1
- package/payload/frontend/dist/assets/{c4Diagram-AHTNJAMY-aTSGv6b-.js → c4Diagram-AHTNJAMY-CWt609Q-.js} +1 -1
- package/payload/frontend/dist/assets/channel-CdBTczzC.js +1 -0
- package/payload/frontend/dist/assets/{chunk-4BX2VUAB-CL1i1VLL.js → chunk-4BX2VUAB-BFqHquBR.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-4TB4RGXK-DIeWEhjD.js → chunk-4TB4RGXK-CW5WaIJq.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-55IACEB6-Cggk_br2.js → chunk-55IACEB6-DHJtIfsv.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-EDXVE4YY-B9bwitXJ.js → chunk-EDXVE4YY-CGOb1mZr.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-FMBD7UC4-BY4GYa45.js → chunk-FMBD7UC4-CSoB33q_.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-OYMX7WX6-CsZ8Gk1p.js → chunk-OYMX7WX6-C01d--Rs.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-QZHKN3VN-m0WQ1QIW.js → chunk-QZHKN3VN-CUx1bRVL.js} +1 -1
- package/payload/frontend/dist/assets/{chunk-YZCP3GAM-BJFF_8vq.js → chunk-YZCP3GAM-ClNvKMAO.js} +1 -1
- package/payload/frontend/dist/assets/classDiagram-6PBFFD2Q-DarZ1ILp.js +1 -0
- package/payload/frontend/dist/assets/classDiagram-v2-HSJHXN6E-DarZ1ILp.js +1 -0
- package/payload/frontend/dist/assets/clone--jdpc5ik.js +1 -0
- package/payload/frontend/dist/assets/{connection-xS-NfZnK.js → connection-DVMHE60_.js} +1 -1
- package/payload/frontend/dist/assets/{connections-BNpmNrpN.js → connections-C_lEmoKc.js} +1 -1
- package/payload/frontend/dist/assets/{cose-bilkent-S5V4N54A-Dfl9Zac8.js → cose-bilkent-S5V4N54A-1sgd6Ms5.js} +1 -1
- package/payload/frontend/dist/assets/{dagre-KV5264BT-CbufX2f3.js → dagre-KV5264BT-DPn4YqGI.js} +1 -1
- package/payload/frontend/dist/assets/{desktop-CJFLIWqk.js → desktop-CSZOBxgD.js} +1 -1
- package/payload/frontend/dist/assets/{diagram-5BDNPKRD-Bv4HpQAy.js → diagram-5BDNPKRD-BHjywjmP.js} +1 -1
- package/payload/frontend/dist/assets/{diagram-G4DWMVQ6-qCQp8RdH.js → diagram-G4DWMVQ6-S7iEdHyz.js} +1 -1
- package/payload/frontend/dist/assets/{diagram-MMDJMWI5-B_XnhIdh.js → diagram-MMDJMWI5-DqMZnrHB.js} +1 -1
- package/payload/frontend/dist/assets/{diagram-TYMM5635-CLa1LRaH.js → diagram-TYMM5635-BYTMiif1.js} +1 -1
- package/payload/frontend/dist/assets/{erDiagram-SMLLAGMA-CeaiozYq.js → erDiagram-SMLLAGMA-B4hCkvwX.js} +1 -1
- package/payload/frontend/dist/assets/{flowDiagram-DWJPFMVM-DvZ6HuiB.js → flowDiagram-DWJPFMVM-DDkmdUVE.js} +1 -1
- package/payload/frontend/dist/assets/{ganttDiagram-T4ZO3ILL-Cr27GUzO.js → ganttDiagram-T4ZO3ILL-BGIkOL1N.js} +1 -1
- package/payload/frontend/dist/assets/{gitGraphDiagram-UUTBAWPF-D7cLIKdE.js → gitGraphDiagram-UUTBAWPF-CqEnUqEN.js} +1 -1
- package/payload/frontend/dist/assets/{graph-D3h2OtRH.js → graph-CE7npIW2.js} +1 -1
- package/payload/frontend/dist/assets/{image-pr8iiZ6b.js → image-BsntFN4u.js} +1 -1
- package/payload/frontend/dist/assets/{index-BTUcEYWC.js → index-DY03KvB5.js} +6 -6
- package/payload/frontend/dist/assets/{infoDiagram-42DDH7IO-D-898NXw.js → infoDiagram-42DDH7IO-DKWMe4K7.js} +1 -1
- package/payload/frontend/dist/assets/{ishikawaDiagram-UXIWVN3A-FCDV3drO.js → ishikawaDiagram-UXIWVN3A-DeYvcKaA.js} +1 -1
- package/payload/frontend/dist/assets/{journeyDiagram-VCZTEJTY-CGbhVJdx.js → journeyDiagram-VCZTEJTY-BQ8mdvF0.js} +1 -1
- package/payload/frontend/dist/assets/{kanban-definition-6JOO6SKY-BdZMqjYd.js → kanban-definition-6JOO6SKY-B7Ke9FjO.js} +1 -1
- package/payload/frontend/dist/assets/{layout-CSVX6YJ2.js → layout-DcxgNsVh.js} +1 -1
- package/payload/frontend/dist/assets/{linear-BC2CbN34.js → linear-DSV9ubbU.js} +1 -1
- package/payload/frontend/dist/assets/{main-B5-ZQCYl.js → main-CpzvlGm1.js} +144 -144
- package/payload/frontend/dist/assets/{min-BOM36O-V.js → min-Dd3QZ8lP.js} +1 -1
- package/payload/frontend/dist/assets/{mindmap-definition-QFDTVHPH-K1lKJajL.js → mindmap-definition-QFDTVHPH-DaFx6hc6.js} +1 -1
- package/payload/frontend/dist/assets/{monitoring-Cper7Dw-.js → monitoring-CsBkbvRU.js} +1 -1
- package/payload/frontend/dist/assets/{notifications-DrRwAV8g.js → notifications-BYk1WjVP.js} +1 -1
- package/payload/frontend/dist/assets/{pieDiagram-DEJITSTG-Cln37rnp.js → pieDiagram-DEJITSTG-VQsbwxkg.js} +1 -1
- package/payload/frontend/dist/assets/{quadrantDiagram-34T5L4WZ-DBP5Cea5.js → quadrantDiagram-34T5L4WZ-tLKlVC0j.js} +1 -1
- package/payload/frontend/dist/assets/{record-content-CsOXQ3vx.js → record-content-DWUPk_tO.js} +1 -1
- package/payload/frontend/dist/assets/{requirementDiagram-MS252O5E-C6DUCDR4.js → requirementDiagram-MS252O5E-DDfjmbNt.js} +1 -1
- package/payload/frontend/dist/assets/{sankeyDiagram-XADWPNL6-D-neOSXc.js → sankeyDiagram-XADWPNL6-SaxuUxjL.js} +1 -1
- package/payload/frontend/dist/assets/{sequenceDiagram-FGHM5R23-ok7v11We.js → sequenceDiagram-FGHM5R23-C2bw8Wko.js} +1 -1
- package/payload/frontend/dist/assets/{stateDiagram-FHFEXIEX-t2YXr83_.js → stateDiagram-FHFEXIEX-BgrY776w.js} +1 -1
- package/payload/frontend/dist/assets/stateDiagram-v2-QKLJ7IA2-BuYWor8l.js +1 -0
- package/payload/frontend/dist/assets/{status-DEsW_4J3.js → status-BQ_1tMq6.js} +1 -1
- package/payload/frontend/dist/assets/suiji-Bct1RCM_.js +1 -0
- package/payload/frontend/dist/assets/{svg-BATDsnTM.js → svg-CrC4YdVu.js} +1 -1
- package/payload/frontend/dist/assets/{tabs-dzJwAbvS.js → tabs-BvO6o4wK.js} +1 -1
- package/payload/frontend/dist/assets/{timeline-definition-GMOUNBTQ-DeW1BaAA.js → timeline-definition-GMOUNBTQ-N9V5Dskh.js} +1 -1
- package/payload/frontend/dist/assets/{vennDiagram-DHZGUBPP-DIaLa_Oo.js → vennDiagram-DHZGUBPP-gAjWqrE-.js} +1 -1
- package/payload/frontend/dist/assets/{wardley-RL74JXVD-DcfvLEAe.js → wardley-RL74JXVD-DV4R7zd5.js} +1 -1
- package/payload/frontend/dist/assets/{wardleyDiagram-NUSXRM2D-C0FuVPkb.js → wardleyDiagram-NUSXRM2D-DBzyAlhE.js} +1 -1
- package/payload/frontend/dist/assets/{xychartDiagram-5P7HB3ND-DIa6gq2O.js → xychartDiagram-5P7HB3ND-BGAjyxZd.js} +1 -1
- package/payload/frontend/dist/build-info.json +4 -4
- package/payload/frontend/dist/companion.html +1 -1
- package/payload/frontend/dist/index.html +2 -2
- package/payload/frontend/dist/assets/channel-CsCfvOaJ.js +0 -1
- package/payload/frontend/dist/assets/classDiagram-6PBFFD2Q-esUmDk_l.js +0 -1
- package/payload/frontend/dist/assets/classDiagram-v2-HSJHXN6E-esUmDk_l.js +0 -1
- package/payload/frontend/dist/assets/clone-DIPLBiAi.js +0 -1
- package/payload/frontend/dist/assets/stateDiagram-v2-QKLJ7IA2-Bl3BtoZ6.js +0 -1
- package/payload/frontend/dist/assets/suiji-C5flJh58.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* runweave:build-info */var __RUNWEAVE_BUILD_INFO__={"version":"0.1.0","buildId":"
|
|
1
|
+
/* runweave:build-info */var __RUNWEAVE_BUILD_INFO__={"version":"0.1.0","buildId":"20261115T232603953Z-06d2bd51","sourceRevision":"06d2bd5167dce947cb3e3e42805a5e97c5a8563f","sourceDirty":false,"builtAt":"2026-11-15T23:26:03.953Z","contentSha256":"9b4cbfd2795b1f9b2203cb34617573bcb0bb4dc51d4303eb2aad2db95b82d662"};
|
|
2
2
|
const __IMPORT_META_URL__ = require('url').pathToFileURL(__filename).href;
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -69936,10 +69936,10 @@ var FeishuBridgeConnector = class {
|
|
|
69936
69936
|
for (const item of [...this.pending.values()])
|
|
69937
69937
|
item.reject(new FeishuBridgeError("input_unknown"));
|
|
69938
69938
|
if (!this.stopped) {
|
|
69939
|
-
const
|
|
69939
|
+
const delay11 = Math.min(3e4, 1e3 * 2 ** Math.min(this.retry++, 5));
|
|
69940
69940
|
this.reconnect = setTimeout(
|
|
69941
69941
|
() => this.connect(),
|
|
69942
|
-
Math.min(3e4,
|
|
69942
|
+
Math.min(3e4, delay11 * (1 + Math.random() * 0.2))
|
|
69943
69943
|
);
|
|
69944
69944
|
}
|
|
69945
69945
|
});
|
|
@@ -73364,6 +73364,22 @@ function ensureZshHookDirectory(command, env) {
|
|
|
73364
73364
|
cachedZshHookDirs.set(key2, hookShellDir);
|
|
73365
73365
|
return hookShellDir;
|
|
73366
73366
|
}
|
|
73367
|
+
function isShellIntegrationLaunch(launch) {
|
|
73368
|
+
if (terminalShellName(launch.command) !== "bash") {
|
|
73369
|
+
return isInteractiveShellLaunch(launch);
|
|
73370
|
+
}
|
|
73371
|
+
const args = [];
|
|
73372
|
+
for (let index = 0; index < launch.args.length; index += 1) {
|
|
73373
|
+
const arg = launch.args[index];
|
|
73374
|
+
if (arg === "--rcfile" || arg === "--init-file") {
|
|
73375
|
+
if (index + 1 >= launch.args.length) return false;
|
|
73376
|
+
index += 1;
|
|
73377
|
+
} else {
|
|
73378
|
+
args.push(arg);
|
|
73379
|
+
}
|
|
73380
|
+
}
|
|
73381
|
+
return isInteractiveShellLaunch({ command: launch.command, args });
|
|
73382
|
+
}
|
|
73367
73383
|
function applyShellIntegration(command, env) {
|
|
73368
73384
|
const shellName = terminalShellName(command);
|
|
73369
73385
|
if (shellName === "zsh") {
|
|
@@ -74654,7 +74670,7 @@ var TmuxProcess = class {
|
|
|
74654
74670
|
return ["-S", socketPath, "-f", this.configPath];
|
|
74655
74671
|
}
|
|
74656
74672
|
buildShellIntegrationEnvArgs(launchCommand) {
|
|
74657
|
-
if (!
|
|
74673
|
+
if (!isShellIntegrationLaunch(launchCommand)) {
|
|
74658
74674
|
return [];
|
|
74659
74675
|
}
|
|
74660
74676
|
const integratedEnv = applyShellIntegration(launchCommand.command, {
|
|
@@ -75163,17 +75179,12 @@ var TmuxPaneService = class extends TmuxSessionService {
|
|
|
75163
75179
|
"-P",
|
|
75164
75180
|
"-F",
|
|
75165
75181
|
"#{pane_id}",
|
|
75182
|
+
...launch ? this.buildShellIntegrationEnvArgs(launch) : [],
|
|
75166
75183
|
"-t",
|
|
75167
75184
|
target2.paneId,
|
|
75168
75185
|
"-c",
|
|
75169
75186
|
params.cwd,
|
|
75170
|
-
...fallback ? [""] :
|
|
75171
|
-
formatShellCommand({
|
|
75172
|
-
command: params.command,
|
|
75173
|
-
args: params.args ?? [],
|
|
75174
|
-
env: params.env
|
|
75175
|
-
})
|
|
75176
|
-
] : []
|
|
75187
|
+
...fallback ? [""] : launch ? [formatShellCommand(launch)] : []
|
|
75177
75188
|
],
|
|
75178
75189
|
target2
|
|
75179
75190
|
);
|
|
@@ -77441,7 +77452,7 @@ function createResourceSampler(helperPath) {
|
|
|
77441
77452
|
);
|
|
77442
77453
|
if (match) rss.set(Number(match[1]), Number(match[2]) / 1024);
|
|
77443
77454
|
}
|
|
77444
|
-
const
|
|
77455
|
+
const processes2 = [];
|
|
77445
77456
|
const apps = /* @__PURE__ */ new Map();
|
|
77446
77457
|
let matched = 0;
|
|
77447
77458
|
for (const identity2 of [...all.values()].slice(0, 4096)) {
|
|
@@ -77473,7 +77484,7 @@ function createResourceSampler(helperPath) {
|
|
|
77473
77484
|
actionKind: identity2.actionKind,
|
|
77474
77485
|
actionReason: reason
|
|
77475
77486
|
};
|
|
77476
|
-
|
|
77487
|
+
processes2.push(item);
|
|
77477
77488
|
const group = apps.get(appKey) ?? {
|
|
77478
77489
|
appKey,
|
|
77479
77490
|
appName,
|
|
@@ -77552,7 +77563,7 @@ function createResourceSampler(helperPath) {
|
|
|
77552
77563
|
dischargePowerW
|
|
77553
77564
|
} : { available: false },
|
|
77554
77565
|
apps: [...apps.values()],
|
|
77555
|
-
processes
|
|
77566
|
+
processes: processes2
|
|
77556
77567
|
}
|
|
77557
77568
|
};
|
|
77558
77569
|
};
|
|
@@ -79537,15 +79548,18 @@ var import_node_path31 = __toESM(require("node:path"), 1);
|
|
|
79537
79548
|
var INPUT_BUDGET_BYTES = 18e4;
|
|
79538
79549
|
var digest = (text5) => (0, import_node_crypto26.createHash)("sha256").update(text5).digest("hex");
|
|
79539
79550
|
var isSupervisionPrompt = (text5) => text5.includes("[runweave-task-supervision:") || text5.startsWith("[runweave-code-review-feedback:");
|
|
79540
|
-
async function readWatchContext(watch, threadId, read) {
|
|
79551
|
+
async function readWatchContext(watch, threadId, read, recentOnly = false) {
|
|
79541
79552
|
const current = watch.target.threadId === threadId;
|
|
79542
79553
|
const ids = current ? [
|
|
79543
79554
|
.../* @__PURE__ */ new Set([
|
|
79544
|
-
watch.
|
|
79545
|
-
...
|
|
79546
|
-
|
|
79547
|
-
|
|
79548
|
-
|
|
79555
|
+
...watch.contextStartMessageId ? [watch.contextStartMessageId] : [],
|
|
79556
|
+
...recentOnly ? [] : [
|
|
79557
|
+
watch.taskStartMessageId,
|
|
79558
|
+
...watch.evidenceMessageIds ?? [],
|
|
79559
|
+
...watch.completedReplyIds ?? [],
|
|
79560
|
+
...watch.goalDefinition?.sourceMessageIds ?? [],
|
|
79561
|
+
...watch.goalDefinition?.plans.flatMap((p) => [p.sourceMessageId, p.authorizationMessageId]) ?? []
|
|
79562
|
+
]
|
|
79549
79563
|
])
|
|
79550
79564
|
].filter((id7) => !id7.startsWith("pending:") && !id7.startsWith("goal-manual:")) : [];
|
|
79551
79565
|
if (ids.length > 63)
|
|
@@ -79557,7 +79571,23 @@ async function readWatchContext(watch, threadId, read) {
|
|
|
79557
79571
|
throw new Error(
|
|
79558
79572
|
"CONTEXT_SOURCE_CHANGED: \u539F\u59CB\u4F1A\u8BDD\u5DF2\u66FF\u6362\uFF0C\u65E7\u6765\u6E90\u4E0D\u53EF\u590D\u7528\uFF1B\u8BF7\u5728\u65B0\u4F1A\u8BDD\u7EE7\u7EED\u4EFB\u52A1\u3002"
|
|
79559
79573
|
);
|
|
79560
|
-
return source2;
|
|
79574
|
+
return scopeWatchContext(current ? watch.contextStartMessageId : void 0, source2);
|
|
79575
|
+
}
|
|
79576
|
+
function scopeWatchContext(startMessageId, source2) {
|
|
79577
|
+
if (!startMessageId) return source2;
|
|
79578
|
+
const messages = messagesFrom(source2);
|
|
79579
|
+
if (!messages.some((message2) => message2.id === startMessageId && message2.role === "user"))
|
|
79580
|
+
throw new Error("\u76D1\u63A7\u91CD\u7F6E\u8D77\u70B9\u4E0D\u53EF\u8BFB\uFF0C\u672A\u4F7F\u7528\u65E7\u4E0A\u4E0B\u6587\uFF1B\u8BF7\u4ECE\u6700\u65B0\u8BF7\u6C42\u91CD\u65B0\u91CD\u7F6E\u3002");
|
|
79581
|
+
let started = false;
|
|
79582
|
+
const turns = source2.turns.map((turn) => ({
|
|
79583
|
+
...turn,
|
|
79584
|
+
messages: turn.messages.filter((message2) => {
|
|
79585
|
+
if (message2.id === startMessageId) started = true;
|
|
79586
|
+
return started;
|
|
79587
|
+
})
|
|
79588
|
+
})).filter((turn) => turn.messages.length);
|
|
79589
|
+
const runtimeError = source2.runtimeError && turns.some((turn) => turn.messages.some((message2) => message2.rawTurnId === source2.runtimeError?.turnId)) ? source2.runtimeError : void 0;
|
|
79590
|
+
return { ...source2, turns, runtimeError };
|
|
79561
79591
|
}
|
|
79562
79592
|
function messagesFrom(content) {
|
|
79563
79593
|
if (content.availability !== "available" || content.partial)
|
|
@@ -80236,6 +80266,7 @@ function synchronizeTarget(watch, target2, cancel) {
|
|
|
80236
80266
|
const pendingId = `pending:${(0, import_node_crypto28.randomUUID)()}`;
|
|
80237
80267
|
watch.taskStartMessageId = pendingId;
|
|
80238
80268
|
delete watch.sourceVersion;
|
|
80269
|
+
delete watch.contextStartMessageId;
|
|
80239
80270
|
watch.task = { id: pendingId, role: "user", text: "" };
|
|
80240
80271
|
watch.goal = "";
|
|
80241
80272
|
watch.plans = [];
|
|
@@ -80360,7 +80391,7 @@ function alreadyProcessedReply(watch, threadId, reply) {
|
|
|
80360
80391
|
(decision3) => decision3.threadId === threadId && decision3.contextRevision === watch.contextRevision && decision3.goalVersion === watch.goalDefinition?.version && decision3.currentReplyId === reply.id && decision3.rawTurnId === (reply.rawTurnId ?? reply.id)
|
|
80361
80392
|
);
|
|
80362
80393
|
}
|
|
80363
|
-
async function readFinalReply(read, event, signal) {
|
|
80394
|
+
async function readFinalReply(read, event, signal, afterReset = false) {
|
|
80364
80395
|
let source2 = await read();
|
|
80365
80396
|
const readError = () => runtimeErrorReply(source2, event);
|
|
80366
80397
|
let messages = messagesFrom(source2);
|
|
@@ -80370,8 +80401,11 @@ async function readFinalReply(read, event, signal) {
|
|
|
80370
80401
|
))
|
|
80371
80402
|
);
|
|
80372
80403
|
const failure3 = readError();
|
|
80373
|
-
if (event.error && !failure3)
|
|
80404
|
+
if (event.error && !failure3) {
|
|
80405
|
+
if (afterReset && event.turnId && !messages.some((message2) => message2.rawTurnId === event.turnId))
|
|
80406
|
+
return { source: source2, messages, native: void 0 };
|
|
80374
80407
|
throw new Error(`${event.error.code}: ${event.error.message}`);
|
|
80408
|
+
}
|
|
80375
80409
|
let native = failure3 ?? locate();
|
|
80376
80410
|
for (let attempt = 0; !native && attempt < 3 && !signal.aborted; attempt++) {
|
|
80377
80411
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
@@ -80379,6 +80413,7 @@ async function readFinalReply(read, event, signal) {
|
|
|
80379
80413
|
messages = messagesFrom(source2);
|
|
80380
80414
|
native = readError() ?? locate();
|
|
80381
80415
|
}
|
|
80416
|
+
if (!native && afterReset) return { source: source2, messages, native: void 0 };
|
|
80382
80417
|
if (!native)
|
|
80383
80418
|
throw new Error("\u6700\u7EC8\u56DE\u590D\u4E8B\u4EF6\u5DF2\u6536\u5230\uFF0C\u4F46\u5B8C\u6574\u4F1A\u8BDD\u5C1A\u4E0D\u53EF\u8BFB\uFF1B\u7B49\u5F85\u4E0B\u4E00\u6761\u56DE\u590D\u3002");
|
|
80384
80419
|
return { source: source2, messages, native };
|
|
@@ -80876,8 +80911,18 @@ async function processSupervisionReply(operations, id7, target2, event, controll
|
|
|
80876
80911
|
const { source: source2, messages, native } = await readFinalReply(
|
|
80877
80912
|
() => operations.readContext(id7, target2.threadId),
|
|
80878
80913
|
event,
|
|
80879
|
-
controller.signal
|
|
80914
|
+
controller.signal,
|
|
80915
|
+
!!operations.find(id7).contextStartMessageId
|
|
80880
80916
|
);
|
|
80917
|
+
if (!native) {
|
|
80918
|
+
await operations.transaction(() => {
|
|
80919
|
+
if (controller.signal.aborted) return;
|
|
80920
|
+
const watch = operations.find(id7);
|
|
80921
|
+
if (watch.pendingReply?.eventId === event.eventId) delete watch.pendingReply;
|
|
80922
|
+
});
|
|
80923
|
+
skip("reply_not_in_reset_context");
|
|
80924
|
+
return ALLOW;
|
|
80925
|
+
}
|
|
80881
80926
|
const finalKey = `${target2.threadId}:${native.id}`;
|
|
80882
80927
|
stage = "prepare_context";
|
|
80883
80928
|
let snapshot2 = await operations.transaction(async () => {
|
|
@@ -81297,7 +81342,7 @@ var SupervisionGoalEditor = class {
|
|
|
81297
81342
|
for (; ; ) {
|
|
81298
81343
|
signal.throwIfAborted();
|
|
81299
81344
|
try {
|
|
81300
|
-
const source3 = await (recent ? ops.readRecent(watch.target.threadId, signal) : ops.read(id7, watch.target.threadId, signal));
|
|
81345
|
+
const source3 = await (recent ? ops.readRecent(id7, watch.target.threadId, signal) : ops.read(id7, watch.target.threadId, signal));
|
|
81301
81346
|
signal.throwIfAborted();
|
|
81302
81347
|
return source3;
|
|
81303
81348
|
} catch (error2) {
|
|
@@ -81359,7 +81404,7 @@ var SupervisionGoalEditor = class {
|
|
|
81359
81404
|
if (preview.needsClarification)
|
|
81360
81405
|
throw new SupervisionError("\u5FC5\u8981\u6765\u6E90\u4E0D\u8DB3\uFF0C\u8BF7\u660E\u786E\u76EE\u6807\u540E\u518D\u91C7\u7528\u3002", 422);
|
|
81361
81406
|
const signal = AbortSignal.timeout(ops.timeoutMs());
|
|
81362
|
-
const source2 = await (entry.recent ? ops.readRecent(preview.target.threadId, signal) : ops.read(id7, preview.target.threadId, signal));
|
|
81407
|
+
const source2 = await (entry.recent ? ops.readRecent(id7, preview.target.threadId, signal) : ops.read(id7, preview.target.threadId, signal));
|
|
81363
81408
|
let adopted = false;
|
|
81364
81409
|
const updated = await ops.transaction(() => {
|
|
81365
81410
|
const watch = ops.find(id7);
|
|
@@ -81435,6 +81480,7 @@ var SupervisionGoalEditor = class {
|
|
|
81435
81480
|
|
|
81436
81481
|
// backend/src/task-supervision/service.ts
|
|
81437
81482
|
var import_node_path37 = __toESM(require("node:path"), 1);
|
|
81483
|
+
var import_node_crypto33 = require("node:crypto");
|
|
81438
81484
|
var import_promises21 = require("node:timers/promises");
|
|
81439
81485
|
|
|
81440
81486
|
// backend/src/app-server/handlers/agent-event-payload.ts
|
|
@@ -82503,7 +82549,7 @@ var TaskSupervisionService = class {
|
|
|
82503
82549
|
find: (id7) => this.find(id7),
|
|
82504
82550
|
read: (id7, thread, signal) => this.readContext(id7, thread, signal),
|
|
82505
82551
|
current: (target2) => this.current(target2),
|
|
82506
|
-
readRecent: (thread, signal) => this.
|
|
82552
|
+
readRecent: (id7, thread, signal) => this.readContext(id7, thread, signal, true),
|
|
82507
82553
|
timeoutMs: () => this.modelOptions().timeoutMs,
|
|
82508
82554
|
root: (target2) => this.resolve(target2.terminalSessionId, target2.panelId).root,
|
|
82509
82555
|
inputRevision: (target2) => terminalInputAdmission(this.manager.getSession(target2.terminalSessionId)).revision,
|
|
@@ -82624,8 +82670,8 @@ var TaskSupervisionService = class {
|
|
|
82624
82670
|
});
|
|
82625
82671
|
return [];
|
|
82626
82672
|
}
|
|
82627
|
-
readContext(id7, threadId, signal) {
|
|
82628
|
-
return readWatchContext(this.find(id7), threadId, (thread, ids) => this.history.getSupervisionContext(thread, ids, signal));
|
|
82673
|
+
readContext(id7, threadId, signal, recentOnly = false) {
|
|
82674
|
+
return readWatchContext(this.find(id7), threadId, (thread, ids) => this.history.getSupervisionContext(thread, ids, signal), recentOnly);
|
|
82629
82675
|
}
|
|
82630
82676
|
async discover(terminalSessionId, panelId, _expectedThreadId) {
|
|
82631
82677
|
void _expectedThreadId;
|
|
@@ -82705,8 +82751,40 @@ var TaskSupervisionService = class {
|
|
|
82705
82751
|
}
|
|
82706
82752
|
async change(id7, request2) {
|
|
82707
82753
|
if (request2.action === "retry-continuation") return retryContinuation(request2, this.continuationOperations(id7));
|
|
82754
|
+
if (request2.action === "reset") return this.reset(id7, request2.expectedRevision);
|
|
82708
82755
|
return this.transaction(() => changeWatch(id7, request2, this.watchControls()));
|
|
82709
82756
|
}
|
|
82757
|
+
async reset(id7, expectedRevision) {
|
|
82758
|
+
const before = await this.get(id7);
|
|
82759
|
+
if (before.revision !== expectedRevision || !this.current(before.target))
|
|
82760
|
+
throw new SupervisionError("\u76D1\u63A7\u72B6\u6001\u6216\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u5237\u65B0\u540E\u91CD\u7F6E\u3002");
|
|
82761
|
+
const session = this.manager.getSession(before.target.terminalSessionId);
|
|
82762
|
+
const inputRevision = terminalInputAdmission(session).inputWriteRevision;
|
|
82763
|
+
const source2 = await this.history.getSupervisionContext(before.target.threadId, []);
|
|
82764
|
+
const task = taskCandidates(source2).at(-1);
|
|
82765
|
+
if (!task) throw new SupervisionError("\u5F53\u524D\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u53EF\u8BFB\u7684\u7528\u6237\u8BF7\u6C42\uFF0C\u672A\u91CD\u7F6E\u76D1\u63A7\u3002", 422);
|
|
82766
|
+
return this.transaction(() => {
|
|
82767
|
+
if (!this.current(before.target) || terminalInputAdmission(session).inputWriteRevision !== inputRevision)
|
|
82768
|
+
throw new SupervisionError("\u8BFB\u53D6\u671F\u95F4\u4F1A\u8BDD\u6216\u8F93\u5165\u5DF2\u53D8\u5316\uFF0C\u8BF7\u6838\u5BF9\u6700\u65B0\u8BF7\u6C42\u540E\u91CD\u7F6E\u3002");
|
|
82769
|
+
const controls = this.watchControls();
|
|
82770
|
+
changeWatch(id7, { action: "pause", expectedRevision }, controls);
|
|
82771
|
+
const watch = startWatch(this.journal, {
|
|
82772
|
+
target: before.target,
|
|
82773
|
+
requestId: (0, import_node_crypto33.randomUUID)(),
|
|
82774
|
+
taskStartMessageId: "",
|
|
82775
|
+
goal: "",
|
|
82776
|
+
planPaths: []
|
|
82777
|
+
}, controls);
|
|
82778
|
+
watch.contextStartMessageId = task.id;
|
|
82779
|
+
watch.taskStartMessageId = task.id;
|
|
82780
|
+
watch.lastUserMessageId = task.id;
|
|
82781
|
+
watch.task = task;
|
|
82782
|
+
watch.goal = task.text;
|
|
82783
|
+
watch.goalState = "checking";
|
|
82784
|
+
watch.sourceVersion = source2.sourceVersion;
|
|
82785
|
+
return watch;
|
|
82786
|
+
});
|
|
82787
|
+
}
|
|
82710
82788
|
continuationOperations(id7) {
|
|
82711
82789
|
return {
|
|
82712
82790
|
get: () => this.get(id7),
|
|
@@ -82930,7 +83008,7 @@ var start = external_exports.object({
|
|
|
82930
83008
|
expectedRevision: external_exports.number().int().positive().optional()
|
|
82931
83009
|
}).strict();
|
|
82932
83010
|
var change = external_exports.object({
|
|
82933
|
-
action: external_exports.enum(["pause", "resume", "update-context", "retry-continuation"]),
|
|
83011
|
+
action: external_exports.enum(["pause", "resume", "reset", "update-context", "retry-continuation"]),
|
|
82934
83012
|
expectedRevision: external_exports.number().int().positive(),
|
|
82935
83013
|
goal: external_exports.string().trim().min(1).max(8e3).optional(),
|
|
82936
83014
|
decisionId: external_exports.string().uuid().optional(),
|
|
@@ -83163,7 +83241,7 @@ function registerTerminalTaskRoutes(app, services, requireAuth, requireTunnelAut
|
|
|
83163
83241
|
|
|
83164
83242
|
// backend/src/bootstrap/bound-cli.ts
|
|
83165
83243
|
var import_node_fs21 = require("node:fs");
|
|
83166
|
-
var
|
|
83244
|
+
var import_node_crypto34 = require("node:crypto");
|
|
83167
83245
|
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
83168
83246
|
function installBoundCli(context) {
|
|
83169
83247
|
const directory4 = import_node_path38.default.dirname(process.argv[1] ?? "");
|
|
@@ -83181,13 +83259,13 @@ function installBoundCli(context) {
|
|
|
83181
83259
|
if (!modules) throw new Error("CONFIG_BOUND_CLI_DEPENDENCIES_REQUIRED");
|
|
83182
83260
|
const bin = import_node_path38.default.join(context.configRoot, "runtime", "bin");
|
|
83183
83261
|
(0, import_node_fs21.mkdirSync)(bin, { recursive: true, mode: 448 });
|
|
83184
|
-
const digest8 = (0,
|
|
83262
|
+
const digest8 = (0, import_node_crypto34.createHash)("sha256").update((0, import_node_fs21.readFileSync)(entry)).digest("hex");
|
|
83185
83263
|
const versionFile = ["release.json", "build-info.json"].map((name) => import_node_path38.default.join(import_node_path38.default.dirname(entry), name)).find(import_node_fs21.existsSync);
|
|
83186
83264
|
const versionBytes = versionFile ? (0, import_node_fs21.readFileSync)(versionFile) : null;
|
|
83187
|
-
const versionDigest = versionBytes ? (0,
|
|
83265
|
+
const versionDigest = versionBytes ? (0, import_node_crypto34.createHash)("sha256").update(versionBytes).digest("hex").slice(0, 16) : "unknown";
|
|
83188
83266
|
const release = import_node_path38.default.join(context.configRoot, "runtime", "cli", `${digest8}-${versionDigest}-cjs`);
|
|
83189
83267
|
if (!(0, import_node_fs21.existsSync)(import_node_path38.default.join(release, "index.cjs"))) {
|
|
83190
|
-
const temporary = `${release}.${(0,
|
|
83268
|
+
const temporary = `${release}.${(0, import_node_crypto34.randomUUID)()}.tmp`;
|
|
83191
83269
|
(0, import_node_fs21.mkdirSync)(temporary, { recursive: true, mode: 448 });
|
|
83192
83270
|
(0, import_node_fs21.cpSync)(entry, import_node_path38.default.join(temporary, "index.cjs"));
|
|
83193
83271
|
if (versionBytes && versionFile) (0, import_node_fs21.writeFileSync)(import_node_path38.default.join(temporary, import_node_path38.default.basename(versionFile)), versionBytes);
|
|
@@ -83216,7 +83294,7 @@ process.exit(result.status??1);
|
|
|
83216
83294
|
exec env ELECTRON_RUN_AS_NODE=1 ${quote(process.execPath)} ${quote(runner)} "$@"
|
|
83217
83295
|
`, 448]
|
|
83218
83296
|
]) {
|
|
83219
|
-
const temporary = `${file}.${(0,
|
|
83297
|
+
const temporary = `${file}.${(0, import_node_crypto34.randomUUID)()}.tmp`;
|
|
83220
83298
|
(0, import_node_fs21.writeFileSync)(temporary, content, { mode, flag: "wx" });
|
|
83221
83299
|
(0, import_node_fs21.renameSync)(temporary, file);
|
|
83222
83300
|
}
|
|
@@ -83467,7 +83545,7 @@ var ExperienceError = class extends Error {
|
|
|
83467
83545
|
};
|
|
83468
83546
|
|
|
83469
83547
|
// backend/src/experience/candidate-lifecycle.ts
|
|
83470
|
-
var
|
|
83548
|
+
var import_node_crypto35 = require("node:crypto");
|
|
83471
83549
|
|
|
83472
83550
|
// backend/src/experience/storage.ts
|
|
83473
83551
|
var import_node_fs22 = require("node:fs");
|
|
@@ -83558,7 +83636,7 @@ var ExperienceStore = class {
|
|
|
83558
83636
|
function candidateView(candidate) {
|
|
83559
83637
|
return {
|
|
83560
83638
|
candidate,
|
|
83561
|
-
version: (0,
|
|
83639
|
+
version: (0, import_node_crypto35.createHash)("sha256").update(JSON.stringify(candidate)).digest("hex")
|
|
83562
83640
|
};
|
|
83563
83641
|
}
|
|
83564
83642
|
function readCandidate(directory4, candidateId) {
|
|
@@ -83676,12 +83754,12 @@ function readExperienceCatalog(storage, repositoryId, sourceAvailable, kind2, li
|
|
|
83676
83754
|
}
|
|
83677
83755
|
|
|
83678
83756
|
// backend/src/experience/maintenance-review.ts
|
|
83679
|
-
var
|
|
83757
|
+
var import_node_crypto37 = require("node:crypto");
|
|
83680
83758
|
var import_node_fs25 = require("node:fs");
|
|
83681
83759
|
var import_node_path42 = __toESM(require("node:path"), 1);
|
|
83682
83760
|
|
|
83683
83761
|
// backend/src/experience/evidence.ts
|
|
83684
|
-
var
|
|
83762
|
+
var import_node_crypto36 = require("node:crypto");
|
|
83685
83763
|
var import_node_fs24 = require("node:fs");
|
|
83686
83764
|
var import_promises22 = require("node:fs/promises");
|
|
83687
83765
|
var import_node_readline = require("node:readline");
|
|
@@ -83702,7 +83780,7 @@ function redactActivityText(value) {
|
|
|
83702
83780
|
|
|
83703
83781
|
// backend/src/experience/evidence.ts
|
|
83704
83782
|
var import_node_path41 = __toESM(require("node:path"), 1);
|
|
83705
|
-
var hash2 = (value) => (0,
|
|
83783
|
+
var hash2 = (value) => (0, import_node_crypto36.createHash)("sha256").update(value).digest("hex");
|
|
83706
83784
|
var IncompleteEvidence = class extends Error {
|
|
83707
83785
|
constructor(sourceSha256) {
|
|
83708
83786
|
super("experience_evidence_lines_missing");
|
|
@@ -83717,7 +83795,7 @@ async function readEvidence(input2, archive = false) {
|
|
|
83717
83795
|
throw new Error("experience_evidence_must_be_a_file");
|
|
83718
83796
|
}
|
|
83719
83797
|
const stream = (0, import_node_fs24.createReadStream)(input2.path);
|
|
83720
|
-
const observed = (0,
|
|
83798
|
+
const observed = (0, import_node_crypto36.createHash)("sha256");
|
|
83721
83799
|
stream.on("data", (chunk) => {
|
|
83722
83800
|
observed.update(chunk);
|
|
83723
83801
|
});
|
|
@@ -83795,7 +83873,7 @@ function redactExcerpt(value) {
|
|
|
83795
83873
|
}
|
|
83796
83874
|
|
|
83797
83875
|
// backend/src/experience/maintenance-review.ts
|
|
83798
|
-
var digest2 = (value) => (0,
|
|
83876
|
+
var digest2 = (value) => (0, import_node_crypto37.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
83799
83877
|
var reviewKey = (policy, kind2, itemId2, version2) => digest2([policy, kind2, itemId2, version2]);
|
|
83800
83878
|
var reviewDirectory = (storage, repositoryId) => import_node_path42.default.join(storage.home, storage.namespace, repositoryId);
|
|
83801
83879
|
function readExperienceMaintenanceReview(storage, repositoryId, requestId) {
|
|
@@ -84037,7 +84115,7 @@ function replayReceipt(stored, repositoryId, namespace, requestHash) {
|
|
|
84037
84115
|
}
|
|
84038
84116
|
|
|
84039
84117
|
// backend/src/experience/service.ts
|
|
84040
|
-
var
|
|
84118
|
+
var import_node_crypto39 = require("node:crypto");
|
|
84041
84119
|
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
84042
84120
|
|
|
84043
84121
|
// backend/src/experience/schema.ts
|
|
@@ -84084,7 +84162,7 @@ var cwdSchema = external_exports.string().trim().min(1).max(4e3);
|
|
|
84084
84162
|
|
|
84085
84163
|
// backend/src/repository/identity.ts
|
|
84086
84164
|
var import_node_child_process9 = require("node:child_process");
|
|
84087
|
-
var
|
|
84165
|
+
var import_node_crypto38 = require("node:crypto");
|
|
84088
84166
|
var import_promises23 = require("node:fs/promises");
|
|
84089
84167
|
var import_node_path43 = __toESM(require("node:path"), 1);
|
|
84090
84168
|
var import_node_util5 = require("node:util");
|
|
@@ -84111,7 +84189,7 @@ async function resolveRepositoryIdentity(cwd) {
|
|
|
84111
84189
|
]);
|
|
84112
84190
|
const commonDirectory = await (0, import_promises23.realpath)(common.stdout.trim());
|
|
84113
84191
|
return {
|
|
84114
|
-
repositoryId: (0,
|
|
84192
|
+
repositoryId: (0, import_node_crypto38.createHash)("sha256").update(commonDirectory).digest("hex"),
|
|
84115
84193
|
commonDirectory,
|
|
84116
84194
|
worktreeRoot: await (0, import_promises23.realpath)(root.stdout.trim())
|
|
84117
84195
|
};
|
|
@@ -84182,7 +84260,7 @@ var ExperienceService = class {
|
|
|
84182
84260
|
(a, b) => b.matchedTerms.length - a.matchedTerms.length || a.record.id.localeCompare(b.record.id)
|
|
84183
84261
|
);
|
|
84184
84262
|
const result = {
|
|
84185
|
-
lookupId: (0,
|
|
84263
|
+
lookupId: (0, import_node_crypto39.randomUUID)(),
|
|
84186
84264
|
repositoryId: scope.repositoryId,
|
|
84187
84265
|
namespace: scope.namespace,
|
|
84188
84266
|
matches: matches2.slice(0, 3).map((match) => ({
|
|
@@ -84315,7 +84393,7 @@ var ExperienceService = class {
|
|
|
84315
84393
|
...parsed,
|
|
84316
84394
|
repositoryId: scope.repositoryId,
|
|
84317
84395
|
namespace: scope.namespace,
|
|
84318
|
-
revision: (0,
|
|
84396
|
+
revision: (0, import_node_crypto39.randomUUID)(),
|
|
84319
84397
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
84320
84398
|
evidence: await Promise.all(parsed.evidence.map(snapshotEvidence))
|
|
84321
84399
|
};
|
|
@@ -84451,7 +84529,7 @@ var ExperienceService = class {
|
|
|
84451
84529
|
throw new ExperienceError("experience_not_in_lookup", 409);
|
|
84452
84530
|
const result = {
|
|
84453
84531
|
...input2,
|
|
84454
|
-
feedbackId: (0,
|
|
84532
|
+
feedbackId: (0, import_node_crypto39.randomUUID)(),
|
|
84455
84533
|
repositoryId: scope.repositoryId,
|
|
84456
84534
|
namespace: scope.namespace,
|
|
84457
84535
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -84467,7 +84545,7 @@ var ExperienceService = class {
|
|
|
84467
84545
|
const invalidated = {
|
|
84468
84546
|
...withoutLegacyCodeHashes(record3),
|
|
84469
84547
|
state: "needs_revalidation",
|
|
84470
|
-
revision: (0,
|
|
84548
|
+
revision: (0, import_node_crypto39.randomUUID)(),
|
|
84471
84549
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
84472
84550
|
};
|
|
84473
84551
|
store.put("revisions", invalidated.revision, invalidated);
|
|
@@ -84811,7 +84889,7 @@ function trimTrailingSlash(value) {
|
|
|
84811
84889
|
}
|
|
84812
84890
|
|
|
84813
84891
|
// packages/config-node/src/app-server/runtime-release.ts
|
|
84814
|
-
var
|
|
84892
|
+
var import_node_crypto40 = require("node:crypto");
|
|
84815
84893
|
var import_node_fs26 = require("node:fs");
|
|
84816
84894
|
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
84817
84895
|
function resolveCurrentAppServerRuntimeRelease(options = {}) {
|
|
@@ -84857,7 +84935,7 @@ function readJsonFile(filePath) {
|
|
|
84857
84935
|
}
|
|
84858
84936
|
}
|
|
84859
84937
|
function sha256(filePath) {
|
|
84860
|
-
return (0,
|
|
84938
|
+
return (0, import_node_crypto40.createHash)("sha256").update((0, import_node_fs26.readFileSync)(filePath)).digest("hex");
|
|
84861
84939
|
}
|
|
84862
84940
|
function isSafeRelativePath(value) {
|
|
84863
84941
|
if (typeof value !== "string") {
|
|
@@ -85116,7 +85194,7 @@ function createCodexQuotaRouter() {
|
|
|
85116
85194
|
var import_express17 = __toESM(require_express2(), 1);
|
|
85117
85195
|
|
|
85118
85196
|
// backend/src/device-monitor/subscriptions.ts
|
|
85119
|
-
var
|
|
85197
|
+
var import_node_crypto41 = require("node:crypto");
|
|
85120
85198
|
|
|
85121
85199
|
// backend/src/device-monitor/push-client.ts
|
|
85122
85200
|
var PushClientError = class extends Error {
|
|
@@ -85357,7 +85435,7 @@ var DeviceSubscriptions = class {
|
|
|
85357
85435
|
if (!existing && Object.values(data.subscriptions).filter((s) => s.enabled).length >= 100)
|
|
85358
85436
|
throw new SubscriptionError(429, "\u8BA2\u9605\u6570\u91CF\u5DF2\u8FBE\u4E0A\u9650");
|
|
85359
85437
|
const next = {
|
|
85360
|
-
id: existing?.id ?? (0,
|
|
85438
|
+
id: existing?.id ?? (0, import_node_crypto41.randomUUID)(),
|
|
85361
85439
|
installationId,
|
|
85362
85440
|
connectionId: owner.connectionId,
|
|
85363
85441
|
sessionId,
|
|
@@ -85630,7 +85708,7 @@ function normalizeMobileLoginBaseUrl(raw) {
|
|
|
85630
85708
|
}
|
|
85631
85709
|
|
|
85632
85710
|
// backend/src/auth/mobile-login.ts
|
|
85633
|
-
var
|
|
85711
|
+
var import_node_crypto42 = require("node:crypto");
|
|
85634
85712
|
var MobileLoginError = class extends Error {
|
|
85635
85713
|
constructor(status, code, retryAfter) {
|
|
85636
85714
|
super(code);
|
|
@@ -85640,8 +85718,8 @@ var MobileLoginError = class extends Error {
|
|
|
85640
85718
|
}
|
|
85641
85719
|
};
|
|
85642
85720
|
var unissued = (state) => ["waiting_scan", "pending_approval", "approved"].includes(state);
|
|
85643
|
-
var hash3 = (secret2) => (0,
|
|
85644
|
-
var matches = (secret2, expected) => !!expected && (0,
|
|
85721
|
+
var hash3 = (secret2) => (0, import_node_crypto42.createHash)("sha256").update(secret2).digest();
|
|
85722
|
+
var matches = (secret2, expected) => !!expected && (0, import_node_crypto42.timingSafeEqual)(hash3(secret2), expected);
|
|
85645
85723
|
var MobileLoginService = class {
|
|
85646
85724
|
constructor(auth) {
|
|
85647
85725
|
this.auth = auth;
|
|
@@ -85681,8 +85759,8 @@ var MobileLoginService = class {
|
|
|
85681
85759
|
if (activeCount - (previous ? 1 : 0) >= 64 || this.requests.size >= 256) {
|
|
85682
85760
|
throw new MobileLoginError(429, "capacity", 60);
|
|
85683
85761
|
}
|
|
85684
|
-
const id7 = (0,
|
|
85685
|
-
const qrSecret = (0,
|
|
85762
|
+
const id7 = (0, import_node_crypto42.randomUUID)();
|
|
85763
|
+
const qrSecret = (0, import_node_crypto42.randomBytes)(32).toString("base64url");
|
|
85686
85764
|
const expiresAt = Date.now() + MOBILE_LOGIN_TTL_MS;
|
|
85687
85765
|
const qr = {
|
|
85688
85766
|
kind: "runweave.mobile-login",
|
|
@@ -85712,7 +85790,7 @@ var MobileLoginService = class {
|
|
|
85712
85790
|
this.requireUnexpired(request2);
|
|
85713
85791
|
if (request2.state === "waiting_scan") {
|
|
85714
85792
|
request2.claimantTokenHash = hash3(input2.claimantToken);
|
|
85715
|
-
request2.claimId = (0,
|
|
85793
|
+
request2.claimId = (0, import_node_crypto42.randomUUID)();
|
|
85716
85794
|
request2.deviceName = input2.deviceName;
|
|
85717
85795
|
request2.connectionId = input2.connectionId;
|
|
85718
85796
|
request2.state = "pending_approval";
|
|
@@ -86064,13 +86142,13 @@ var AppServerEventConsumer = class {
|
|
|
86064
86142
|
if (this.stopped || this.reconnectTimer) {
|
|
86065
86143
|
return;
|
|
86066
86144
|
}
|
|
86067
|
-
const
|
|
86145
|
+
const delay11 = this.reconnectDelayMs;
|
|
86068
86146
|
this.reconnectDelayMs = Math.min(this.reconnectDelayMs * 2, 3e4);
|
|
86069
86147
|
this.updateStatus({
|
|
86070
86148
|
state: "connecting",
|
|
86071
86149
|
failureSince: this.state.failureSince ?? Date.now(),
|
|
86072
86150
|
reconnectAttempt: this.state.reconnectAttempt + 1,
|
|
86073
|
-
nextAttemptAt: Date.now() +
|
|
86151
|
+
nextAttemptAt: Date.now() + delay11
|
|
86074
86152
|
});
|
|
86075
86153
|
this.reconnectTimer = setTimeout(async () => {
|
|
86076
86154
|
this.reconnectTimer = null;
|
|
@@ -86078,7 +86156,7 @@ var AppServerEventConsumer = class {
|
|
|
86078
86156
|
this.options.consumerId
|
|
86079
86157
|
);
|
|
86080
86158
|
this.connect(cursor);
|
|
86081
|
-
},
|
|
86159
|
+
}, delay11);
|
|
86082
86160
|
}
|
|
86083
86161
|
handleSocketError(error2) {
|
|
86084
86162
|
if (this.stopped) return;
|
|
@@ -88804,7 +88882,7 @@ var import_express26 = __toESM(require_express2(), 1);
|
|
|
88804
88882
|
|
|
88805
88883
|
// backend/src/race/race-service.ts
|
|
88806
88884
|
var import_node_child_process12 = require("node:child_process");
|
|
88807
|
-
var
|
|
88885
|
+
var import_node_crypto45 = require("node:crypto");
|
|
88808
88886
|
|
|
88809
88887
|
// packages/shared/src/terminal/project-context.ts
|
|
88810
88888
|
var CHILD_PROJECT_ID_PREFIX = "wt";
|
|
@@ -88883,10 +88961,10 @@ function resolveTerminalParentProjectId(projectId) {
|
|
|
88883
88961
|
}
|
|
88884
88962
|
|
|
88885
88963
|
// backend/src/terminal/application/agent-preparation.ts
|
|
88886
|
-
var
|
|
88964
|
+
var import_node_crypto44 = require("node:crypto");
|
|
88887
88965
|
|
|
88888
88966
|
// backend/src/terminal/application/panel-split.ts
|
|
88889
|
-
var
|
|
88967
|
+
var import_node_crypto43 = require("node:crypto");
|
|
88890
88968
|
function assertUniqueAlias(panels, alias) {
|
|
88891
88969
|
if (!alias) {
|
|
88892
88970
|
return;
|
|
@@ -88938,7 +89016,7 @@ async function createTerminalPanelSplit(terminalSessionManager, session, options
|
|
|
88938
89016
|
session,
|
|
88939
89017
|
sourcePanel
|
|
88940
89018
|
);
|
|
88941
|
-
const panelId = (0,
|
|
89019
|
+
const panelId = (0, import_node_crypto43.randomUUID)();
|
|
88942
89020
|
const { command, args } = resolveTerminalLaunchConfig(params);
|
|
88943
89021
|
const cwd = params.cwd?.trim() || sourcePanel.cwd || session.cwd;
|
|
88944
89022
|
const previousWorkspace = terminalSessionManager.getPanelWorkspace(
|
|
@@ -89177,7 +89255,7 @@ var CODEX_SKIP_UPDATE_ON_STARTUP_ARGS3 = [
|
|
|
89177
89255
|
"check_for_update_on_startup=false"
|
|
89178
89256
|
];
|
|
89179
89257
|
async function prepareTerminalAgent(terminalSessionManager, session, options, request2, internalOptions) {
|
|
89180
|
-
const operationId = `terminal_agent_prepare_${(0,
|
|
89258
|
+
const operationId = `terminal_agent_prepare_${(0, import_node_crypto44.randomUUID)()}`;
|
|
89181
89259
|
let target2 = null;
|
|
89182
89260
|
let createdPanel = false;
|
|
89183
89261
|
let preparationPanelId = null;
|
|
@@ -89403,7 +89481,7 @@ async function prepareTerminalAgent(terminalSessionManager, session, options, re
|
|
|
89403
89481
|
operationId,
|
|
89404
89482
|
paneTarget
|
|
89405
89483
|
);
|
|
89406
|
-
if (
|
|
89484
|
+
if (internalOptions?.stageResumeCommand) {
|
|
89407
89485
|
await withStagedAgentLaunch(launchCommand, submit);
|
|
89408
89486
|
} else {
|
|
89409
89487
|
await submit(launchCommand);
|
|
@@ -89927,7 +90005,7 @@ var RaceService = class {
|
|
|
89927
90005
|
});
|
|
89928
90006
|
this.creationSettled = creationSettled;
|
|
89929
90007
|
const record3 = {
|
|
89930
|
-
raceId: `race_${(0,
|
|
90008
|
+
raceId: `race_${(0, import_node_crypto45.randomUUID)()}`,
|
|
89931
90009
|
goal: request2.goal,
|
|
89932
90010
|
plan: request2.plan,
|
|
89933
90011
|
baseRef: request2.baseRef,
|
|
@@ -90298,10 +90376,10 @@ var ACTIVITY_EVENT_NAMES = [
|
|
|
90298
90376
|
];
|
|
90299
90377
|
|
|
90300
90378
|
// backend/src/routes/activity/index.ts
|
|
90301
|
-
var
|
|
90379
|
+
var import_node_crypto47 = __toESM(require("node:crypto"), 1);
|
|
90302
90380
|
|
|
90303
90381
|
// backend/src/activity/security/canonical.ts
|
|
90304
|
-
var
|
|
90382
|
+
var import_node_crypto46 = __toESM(require("node:crypto"), 1);
|
|
90305
90383
|
function canonicalJson(value) {
|
|
90306
90384
|
if (value === null || typeof value !== "object") {
|
|
90307
90385
|
return JSON.stringify(value);
|
|
@@ -90313,7 +90391,7 @@ function canonicalJson(value) {
|
|
|
90313
90391
|
return `{${entries.map(([key2, child]) => `${JSON.stringify(key2)}:${canonicalJson(child)}`).join(",")}}`;
|
|
90314
90392
|
}
|
|
90315
90393
|
function sha2562(value) {
|
|
90316
|
-
return
|
|
90394
|
+
return import_node_crypto46.default.createHash("sha256").update(value).digest("hex");
|
|
90317
90395
|
}
|
|
90318
90396
|
function canonicalActivityScope(scope) {
|
|
90319
90397
|
const scopeType = typeof scope.projectId === "string" ? "project" : "thread";
|
|
@@ -90560,7 +90638,7 @@ async function writeIngressBatch(params) {
|
|
|
90560
90638
|
const firstProducer = firstEvent.producer && typeof firstEvent.producer === "object" ? firstEvent.producer : {};
|
|
90561
90639
|
const message2 = error2 instanceof Error ? error2.message : "activity_schema_rejected";
|
|
90562
90640
|
const reasonCode = message2.startsWith("activity_") ? message2.slice(0, 256) : "activity_schema_rejected";
|
|
90563
|
-
const requestSha256 =
|
|
90641
|
+
const requestSha256 = import_node_crypto47.default.createHash("sha256").update(JSON.stringify(params.body ?? null)).digest("hex");
|
|
90564
90642
|
await params.store.recordRejection({
|
|
90565
90643
|
requestSha256,
|
|
90566
90644
|
reasonCode,
|
|
@@ -90646,7 +90724,7 @@ function createActivityRouter(options) {
|
|
|
90646
90724
|
response2.status(401).json({ message: "Unauthorized" });
|
|
90647
90725
|
return;
|
|
90648
90726
|
}
|
|
90649
|
-
const requestId =
|
|
90727
|
+
const requestId = import_node_crypto47.default.randomUUID();
|
|
90650
90728
|
const authSubjectHmac = await options.store.auditSubjectHmac(subject);
|
|
90651
90729
|
const content = await options.store.content(request2.params.contentId);
|
|
90652
90730
|
await options.store.recordAccessAudit({
|
|
@@ -90683,7 +90761,7 @@ function createActivityRouter(options) {
|
|
|
90683
90761
|
response2.status(413).json({ message: "activity_export_scope_too_large" });
|
|
90684
90762
|
return;
|
|
90685
90763
|
}
|
|
90686
|
-
const requestId =
|
|
90764
|
+
const requestId = import_node_crypto47.default.randomUUID();
|
|
90687
90765
|
const authSubjectHmac = await options.store.auditSubjectHmac(auditSubject);
|
|
90688
90766
|
if (parsed.action === "export") {
|
|
90689
90767
|
const facts = await options.store.exportSnapshot({
|
|
@@ -90838,7 +90916,7 @@ async function recoverCodexToolConversation(manager, panel, threadId, operationI
|
|
|
90838
90916
|
|
|
90839
90917
|
// backend/src/routes/terminal/state.ts
|
|
90840
90918
|
var import_express28 = __toESM(require_express2(), 1);
|
|
90841
|
-
var
|
|
90919
|
+
var import_node_crypto48 = __toESM(require("node:crypto"), 1);
|
|
90842
90920
|
var terminalStateLogger = logger.child({ component: "terminal-state" });
|
|
90843
90921
|
var AGENT_HOOKS = ["codex", "claude", "trae", "traecli", "traex", "pi"];
|
|
90844
90922
|
var agentHookStateSchema = external_exports.object({
|
|
@@ -91090,7 +91168,7 @@ function recordAgentHookActivity(activity, hook2, hookActivityEvents, cwd) {
|
|
|
91090
91168
|
if (content !== void 0 && content !== null) {
|
|
91091
91169
|
const text5 = typeof content === "string" ? content : JSON.stringify(content);
|
|
91092
91170
|
event.contents.push({
|
|
91093
|
-
contentId:
|
|
91171
|
+
contentId: import_node_crypto48.default.randomUUID(),
|
|
91094
91172
|
role: hook2.hookEvent === "ToolRequested" ? "tool_args" : hook2.hookEvent === "ToolCompleted" ? "tool_result" : hook2.hookEvent === "UserPromptSubmit" ? "query" : "response",
|
|
91095
91173
|
mediaType: typeof content === "string" ? "text/plain; charset=utf-8" : "application/json",
|
|
91096
91174
|
bytesBase64: Buffer.from(text5, "utf8").toString("base64")
|
|
@@ -91481,7 +91559,7 @@ function resolveCompletionPane(terminalSessionManager, terminalSessionId, panelI
|
|
|
91481
91559
|
}
|
|
91482
91560
|
|
|
91483
91561
|
// backend/src/terminal/code-review/store.ts
|
|
91484
|
-
var
|
|
91562
|
+
var import_node_crypto49 = require("node:crypto");
|
|
91485
91563
|
var import_node_fs27 = require("node:fs");
|
|
91486
91564
|
var import_promises30 = require("node:fs/promises");
|
|
91487
91565
|
var import_node_path52 = __toESM(require("node:path"), 1);
|
|
@@ -91493,7 +91571,7 @@ var CodeReviewError = class extends Error {
|
|
|
91493
91571
|
}
|
|
91494
91572
|
};
|
|
91495
91573
|
async function atomicJson(file, value) {
|
|
91496
|
-
const temporary = `${file}.${(0,
|
|
91574
|
+
const temporary = `${file}.${(0, import_node_crypto49.randomUUID)()}.tmp`;
|
|
91497
91575
|
const handle2 = await (0, import_promises30.open)(temporary, "wx", 384);
|
|
91498
91576
|
try {
|
|
91499
91577
|
await handle2.writeFile(JSON.stringify(value));
|
|
@@ -91540,7 +91618,7 @@ var CodeReviewStore = class {
|
|
|
91540
91618
|
constructor(directory4) {
|
|
91541
91619
|
this.directory = directory4;
|
|
91542
91620
|
}
|
|
91543
|
-
backendIdentity = (0,
|
|
91621
|
+
backendIdentity = (0, import_node_crypto49.randomUUID)();
|
|
91544
91622
|
records = /* @__PURE__ */ new Map();
|
|
91545
91623
|
tail = Promise.resolve();
|
|
91546
91624
|
failed = false;
|
|
@@ -91715,7 +91793,7 @@ function createTerminalUnreadRouter(service, desktopAccess = null, auth) {
|
|
|
91715
91793
|
}
|
|
91716
91794
|
|
|
91717
91795
|
// backend/src/terminal/questions/gateway.ts
|
|
91718
|
-
var
|
|
91796
|
+
var import_node_crypto50 = require("node:crypto");
|
|
91719
91797
|
var questionParams = external_exports.object({
|
|
91720
91798
|
threadId: external_exports.string(),
|
|
91721
91799
|
turnId: external_exports.string(),
|
|
@@ -91762,7 +91840,7 @@ var TerminalQuestionGateway = class {
|
|
|
91762
91840
|
}, 2e4);
|
|
91763
91841
|
this.heartbeat.unref();
|
|
91764
91842
|
}
|
|
91765
|
-
generation = (0,
|
|
91843
|
+
generation = (0, import_node_crypto50.randomUUID)();
|
|
91766
91844
|
socket;
|
|
91767
91845
|
nextId = 0;
|
|
91768
91846
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -91831,7 +91909,7 @@ var TerminalQuestionGateway = class {
|
|
|
91831
91909
|
const parsed = questionParams.safeParse(message2.params);
|
|
91832
91910
|
if (!parsed.success || parsed.data.threadId !== this.threadId || typeof message2.id !== "string" && typeof message2.id !== "number") return;
|
|
91833
91911
|
if ([...this.entries.values()].some((entry) => entry.rawId === message2.id)) return;
|
|
91834
|
-
const requestId = (0,
|
|
91912
|
+
const requestId = (0, import_node_crypto50.randomUUID)();
|
|
91835
91913
|
this.entries.set(requestId, { rawId: message2.id, value: { ...parsed.data, requestId, generation: this.generation, state: "pending" } });
|
|
91836
91914
|
if (this.entries.size > 100) {
|
|
91837
91915
|
const old = [...this.entries].find(([, entry]) => entry.value.state === "expired" || entry.value.state === "resolved");
|
|
@@ -92113,7 +92191,7 @@ async function createTerminalSession(manager, request2, options, source2) {
|
|
|
92113
92191
|
kind: "terminal_session_created",
|
|
92114
92192
|
terminalSessionId: created.id,
|
|
92115
92193
|
projectId: created.projectId,
|
|
92116
|
-
payload: { session: toSessionListItem(created, resolveEffectiveTerminalState(manager, options.terminalStateService, created), toPanelWorkspacePayload(manager, created.id)) }
|
|
92194
|
+
payload: { session: toSessionListItem(created, resolveEffectiveTerminalState(manager, options.terminalStateService, created), toPanelWorkspacePayload(manager, created.id)), ...options.activate ? { activate: true } : {} }
|
|
92117
92195
|
});
|
|
92118
92196
|
recordTerminalSessionCreated(options.activity, created);
|
|
92119
92197
|
return created;
|
|
@@ -92251,7 +92329,7 @@ var TerminalAgentForkService = class {
|
|
|
92251
92329
|
};
|
|
92252
92330
|
|
|
92253
92331
|
// backend/src/terminal/tasks/service.ts
|
|
92254
|
-
var
|
|
92332
|
+
var import_node_crypto51 = require("node:crypto");
|
|
92255
92333
|
|
|
92256
92334
|
// packages/config-node/src/claude.ts
|
|
92257
92335
|
var import_node_os16 = __toESM(require("node:os"), 1);
|
|
@@ -92278,21 +92356,21 @@ async function readClaudeConversationIdentity(session, panel, tmux) {
|
|
|
92278
92356
|
if (!Number.isSafeInteger(panePid) || panePid <= 0) return null;
|
|
92279
92357
|
const psOptions = { env: { TZ: "UTC", LC_ALL: "C" }, timeout: 2e3, maxBuffer: 4 * 1024 * 1024 };
|
|
92280
92358
|
const { stdout } = await tmux.execFileImpl("ps", ["-axo", "pid=,ppid=,comm="], psOptions);
|
|
92281
|
-
const
|
|
92359
|
+
const processes2 = /* @__PURE__ */ new Map();
|
|
92282
92360
|
for (const line of stdout.split("\n")) {
|
|
92283
92361
|
const match = /^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(line);
|
|
92284
|
-
if (match)
|
|
92362
|
+
if (match) processes2.set(Number(match[1]), { parent: Number(match[2]), agent: getAgentForCommand(match[3]) });
|
|
92285
92363
|
}
|
|
92286
|
-
const candidates = [...
|
|
92364
|
+
const candidates = [...processes2].filter(([pid2, info]) => {
|
|
92287
92365
|
if (info.agent !== "claude") return false;
|
|
92288
92366
|
if (pid2 === panePid) return true;
|
|
92289
|
-
if (
|
|
92367
|
+
if (processes2.get(panePid)?.agent) return false;
|
|
92290
92368
|
const visited = /* @__PURE__ */ new Set([pid2]);
|
|
92291
92369
|
let parent = info.parent;
|
|
92292
92370
|
while (parent !== panePid) {
|
|
92293
92371
|
if (visited.has(parent)) return false;
|
|
92294
92372
|
visited.add(parent);
|
|
92295
|
-
const ancestor =
|
|
92373
|
+
const ancestor = processes2.get(parent);
|
|
92296
92374
|
if (!ancestor || ancestor.agent) return false;
|
|
92297
92375
|
parent = ancestor.parent;
|
|
92298
92376
|
}
|
|
@@ -92431,7 +92509,7 @@ function conflict(code, message2) {
|
|
|
92431
92509
|
throw new TerminalTaskError(409, code, message2);
|
|
92432
92510
|
}
|
|
92433
92511
|
function digest3(value) {
|
|
92434
|
-
return (0,
|
|
92512
|
+
return (0, import_node_crypto51.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
92435
92513
|
}
|
|
92436
92514
|
var TerminalTaskService = class {
|
|
92437
92515
|
constructor(store, manager, options, history = new AppServerHistoryGateway()) {
|
|
@@ -93078,7 +93156,7 @@ function registerTerminalSessionUpdateRoute(router, terminalSessionManager, term
|
|
|
93078
93156
|
var import_express31 = __toESM(require_express2(), 1);
|
|
93079
93157
|
|
|
93080
93158
|
// backend/src/terminal/browser-assistance/service.ts
|
|
93081
|
-
var
|
|
93159
|
+
var import_node_crypto52 = require("node:crypto");
|
|
93082
93160
|
var TTL_MS2 = 30 * 6e4;
|
|
93083
93161
|
var ACTIVE = /* @__PURE__ */ new Set([
|
|
93084
93162
|
"requesting",
|
|
@@ -93177,7 +93255,7 @@ ${recovery.nextStep}`.slice(
|
|
|
93177
93255
|
requestId
|
|
93178
93256
|
);
|
|
93179
93257
|
}
|
|
93180
|
-
create(sessionId, input2, requestId = (0,
|
|
93258
|
+
create(sessionId, input2, requestId = (0, import_node_crypto52.randomUUID)()) {
|
|
93181
93259
|
const { session, panel, threadId } = this.panel(sessionId, input2.panelId);
|
|
93182
93260
|
const admission = terminalInputAdmission(session);
|
|
93183
93261
|
if (admission.writers || admission.returning)
|
|
@@ -93385,7 +93463,7 @@ function registerBrowserAssistanceRoutes(router, manager, options) {
|
|
|
93385
93463
|
|
|
93386
93464
|
// backend/src/terminal/preview/change-content.ts
|
|
93387
93465
|
var import_node_child_process13 = require("node:child_process");
|
|
93388
|
-
var
|
|
93466
|
+
var import_node_crypto53 = require("node:crypto");
|
|
93389
93467
|
var import_node_fs30 = require("node:fs");
|
|
93390
93468
|
var import_promises32 = require("node:fs/promises");
|
|
93391
93469
|
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
@@ -93526,7 +93604,7 @@ async function readChangeContent(options) {
|
|
|
93526
93604
|
bytes = await git2(repoRoot, ["cat-file", "blob", oid], IMAGE_PREVIEW_MAX_BYTES + 1);
|
|
93527
93605
|
}
|
|
93528
93606
|
side.sizeBytes = bytes.length;
|
|
93529
|
-
side.version = (0,
|
|
93607
|
+
side.version = (0, import_node_crypto53.createHash)("sha256").update(bytes).digest("hex");
|
|
93530
93608
|
const mime = detectImageMimeType(bytes, filePath);
|
|
93531
93609
|
const isImage = mime && mime !== "image/svg+xml";
|
|
93532
93610
|
let binary = isLikelyBinary(bytes) || bytes.subarray(0, 5).toString("ascii") === "%PDF-";
|
|
@@ -97524,7 +97602,7 @@ function scheduledTaskErrorFromStorage(error2) {
|
|
|
97524
97602
|
}
|
|
97525
97603
|
|
|
97526
97604
|
// backend/src/terminal/quick-input/service.ts
|
|
97527
|
-
var
|
|
97605
|
+
var import_node_crypto54 = require("node:crypto");
|
|
97528
97606
|
var QUICK_INPUT_MODES = /* @__PURE__ */ new Set([
|
|
97529
97607
|
"line",
|
|
97530
97608
|
"codex_slash_command",
|
|
@@ -97645,7 +97723,7 @@ var TerminalQuickInputService = class {
|
|
|
97645
97723
|
replaceItem(items, result);
|
|
97646
97724
|
} else {
|
|
97647
97725
|
result = {
|
|
97648
|
-
id: (0,
|
|
97726
|
+
id: (0, import_node_crypto54.randomUUID)(),
|
|
97649
97727
|
title: normalized.title,
|
|
97650
97728
|
data: normalized.data,
|
|
97651
97729
|
mode: normalized.mode,
|
|
@@ -97779,7 +97857,7 @@ var TerminalQuickInputService = class {
|
|
|
97779
97857
|
replaceItem(items, result);
|
|
97780
97858
|
} else {
|
|
97781
97859
|
result = {
|
|
97782
|
-
id: (0,
|
|
97860
|
+
id: (0, import_node_crypto54.randomUUID)(),
|
|
97783
97861
|
title: normalized.title,
|
|
97784
97862
|
data: normalized.data,
|
|
97785
97863
|
mode: normalized.mode,
|
|
@@ -97920,7 +97998,7 @@ function ensureManualOrders(items) {
|
|
|
97920
97998
|
});
|
|
97921
97999
|
}
|
|
97922
98000
|
function hash4(value) {
|
|
97923
|
-
return (0,
|
|
98001
|
+
return (0, import_node_crypto54.createHash)("sha256").update(value).digest("hex");
|
|
97924
98002
|
}
|
|
97925
98003
|
function encodeCursor(offset, fingerprint3) {
|
|
97926
98004
|
return Buffer.from(JSON.stringify({ offset, fingerprint: fingerprint3 })).toString("base64url");
|
|
@@ -98128,7 +98206,7 @@ function registerTerminalQuickInputRoutes(router, quickInputService, scheduledTa
|
|
|
98128
98206
|
var import_node_fs33 = require("node:fs");
|
|
98129
98207
|
var import_promises43 = require("node:fs/promises");
|
|
98130
98208
|
var import_node_path69 = __toESM(require("node:path"), 1);
|
|
98131
|
-
var
|
|
98209
|
+
var import_node_crypto55 = require("node:crypto");
|
|
98132
98210
|
|
|
98133
98211
|
// packages/shared/src/terminal/runtime/text-attachments.ts
|
|
98134
98212
|
var TERMINAL_TEXT_ATTACHMENT_LIMITS = {
|
|
@@ -98177,7 +98255,7 @@ var TextAttachmentError = class extends Error {
|
|
|
98177
98255
|
}
|
|
98178
98256
|
};
|
|
98179
98257
|
function attachmentFingerprint(value) {
|
|
98180
|
-
return (0,
|
|
98258
|
+
return (0, import_node_crypto55.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
98181
98259
|
}
|
|
98182
98260
|
var TerminalTextAttachmentService = class {
|
|
98183
98261
|
constructor(root) {
|
|
@@ -98245,7 +98323,7 @@ var TerminalTextAttachmentService = class {
|
|
|
98245
98323
|
}
|
|
98246
98324
|
}
|
|
98247
98325
|
async atomic(file, data) {
|
|
98248
|
-
const temporary = `${file}.${(0,
|
|
98326
|
+
const temporary = `${file}.${(0, import_node_crypto55.randomUUID)()}.tmp`;
|
|
98249
98327
|
const handle2 = await (0, import_promises43.open)(temporary, "wx", 384);
|
|
98250
98328
|
try {
|
|
98251
98329
|
await handle2.writeFile(data);
|
|
@@ -98294,7 +98372,7 @@ var TerminalTextAttachmentService = class {
|
|
|
98294
98372
|
);
|
|
98295
98373
|
const bytes = await this.readFile(this.describe(record3).filePath);
|
|
98296
98374
|
const text5 = bytes.toString("utf8");
|
|
98297
|
-
if (bytes.length !== record3.utf8Bytes || text5.length !== record3.utf16Length || (0,
|
|
98375
|
+
if (bytes.length !== record3.utf8Bytes || text5.length !== record3.utf16Length || (0, import_node_crypto55.createHash)("sha256").update(bytes).digest("hex") !== record3.sha256)
|
|
98298
98376
|
throw new TextAttachmentError(410, "\u9644\u4EF6\u5185\u5BB9\u6821\u9A8C\u5931\u8D25");
|
|
98299
98377
|
return text5;
|
|
98300
98378
|
}
|
|
@@ -98367,7 +98445,7 @@ var TerminalTextAttachmentService = class {
|
|
|
98367
98445
|
await this.ensureDirectory(this.directory(sessionId));
|
|
98368
98446
|
const record3 = {
|
|
98369
98447
|
schemaVersion: 1,
|
|
98370
|
-
id: (0,
|
|
98448
|
+
id: (0, import_node_crypto55.randomUUID)(),
|
|
98371
98449
|
sessionId,
|
|
98372
98450
|
panelId: request2.panelId,
|
|
98373
98451
|
threadId: request2.expectedThreadId ?? null,
|
|
@@ -98375,7 +98453,7 @@ var TerminalTextAttachmentService = class {
|
|
|
98375
98453
|
purpose: request2.purpose,
|
|
98376
98454
|
utf16Length: request2.text.length,
|
|
98377
98455
|
utf8Bytes: bytes.length,
|
|
98378
|
-
sha256: (0,
|
|
98456
|
+
sha256: (0, import_node_crypto55.createHash)("sha256").update(bytes).digest("hex"),
|
|
98379
98457
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98380
98458
|
retainedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
98381
98459
|
state: "draft"
|
|
@@ -98653,7 +98731,7 @@ function registerTerminalTextAttachmentRoutes(router, manager, delivery) {
|
|
|
98653
98731
|
}
|
|
98654
98732
|
|
|
98655
98733
|
// backend/src/terminal/application/hosted-agent-recovery.ts
|
|
98656
|
-
var
|
|
98734
|
+
var import_node_crypto56 = require("node:crypto");
|
|
98657
98735
|
async function recoverHostedAgent(manager, session, options, request2) {
|
|
98658
98736
|
if (!options.runtimeRegistry || request2.panelId && request2.panelId !== "default")
|
|
98659
98737
|
throw new TerminalPanelError(409, "Hosted terminal recovery unavailable for this target");
|
|
@@ -98665,7 +98743,7 @@ async function recoverHostedAgent(manager, session, options, request2) {
|
|
|
98665
98743
|
);
|
|
98666
98744
|
const target2 = resolve();
|
|
98667
98745
|
if (!target2) throw new TerminalPanelError(409, "Only an idle hosted terminal with a saved agent thread can be recovered");
|
|
98668
|
-
const operationId = `terminal_agent_recover_${(0,
|
|
98746
|
+
const operationId = `terminal_agent_recover_${(0, import_node_crypto56.randomUUID)()}`;
|
|
98669
98747
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
98670
98748
|
try {
|
|
98671
98749
|
await recoverHostedTerminal({
|
|
@@ -99210,7 +99288,7 @@ function registerTerminalPanelRoutes(router, terminalSessionManager, options) {
|
|
|
99210
99288
|
}
|
|
99211
99289
|
|
|
99212
99290
|
// backend/src/routes/terminal/input/clipboard-image.ts
|
|
99213
|
-
var
|
|
99291
|
+
var import_node_crypto57 = require("node:crypto");
|
|
99214
99292
|
var import_promises44 = require("node:fs/promises");
|
|
99215
99293
|
var import_node_os18 = __toESM(require("node:os"), 1);
|
|
99216
99294
|
var import_node_path70 = __toESM(require("node:path"), 1);
|
|
@@ -99259,7 +99337,7 @@ function resolveClipboardImageExtension(mimeType) {
|
|
|
99259
99337
|
throw new Error(`Unsupported clipboard image mime type: ${mimeType}`);
|
|
99260
99338
|
}
|
|
99261
99339
|
}
|
|
99262
|
-
function buildClipboardImageFileName(now2, extension, randomHex = (0,
|
|
99340
|
+
function buildClipboardImageFileName(now2, extension, randomHex = (0, import_node_crypto57.randomBytes)(3).toString("hex")) {
|
|
99263
99341
|
const date3 = now2.toISOString().slice(0, 10).replaceAll("-", "");
|
|
99264
99342
|
const time4 = now2.toISOString().slice(11, 19).replaceAll(":", "");
|
|
99265
99343
|
return `runweave-terminal-image-${date3}-${time4}-${randomHex}.${extension}`;
|
|
@@ -99655,7 +99733,7 @@ function registerTerminalInputRoutes(router, terminalSessionManager, options) {
|
|
|
99655
99733
|
}
|
|
99656
99734
|
|
|
99657
99735
|
// backend/src/terminal/runtime/terminal-agent-settings.ts
|
|
99658
|
-
var
|
|
99736
|
+
var import_node_crypto58 = require("node:crypto");
|
|
99659
99737
|
|
|
99660
99738
|
// backend/src/agent-model-catalog/types.ts
|
|
99661
99739
|
var import_node_child_process20 = require("node:child_process");
|
|
@@ -99974,7 +100052,7 @@ async function readThread(provider3, threadId) {
|
|
|
99974
100052
|
function settingsFor(target2, thread, models) {
|
|
99975
100053
|
const model = normalizedModel(thread.model, models);
|
|
99976
100054
|
const reasoningEffort = thread.reasoningEffort;
|
|
99977
|
-
const revision2 = (0,
|
|
100055
|
+
const revision2 = (0, import_node_crypto58.createHash)("sha256").update(JSON.stringify([target2.provider, target2.threadId, thread.model, reasoningEffort])).digest("hex");
|
|
99978
100056
|
return {
|
|
99979
100057
|
terminalSessionId: target2.session.id,
|
|
99980
100058
|
panelId: target2.panelId,
|
|
@@ -101481,7 +101559,7 @@ function registerMonitoringRoutes(app, requireAuth, services) {
|
|
|
101481
101559
|
var import_express40 = __toESM(require_express2(), 1);
|
|
101482
101560
|
|
|
101483
101561
|
// backend/src/evolution/knowledge/lifecycle.ts
|
|
101484
|
-
var
|
|
101562
|
+
var import_node_crypto59 = require("node:crypto");
|
|
101485
101563
|
function defaultEvolutionScopePolicy(learningScopeId, now2 = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
101486
101564
|
return {
|
|
101487
101565
|
learningScopeId,
|
|
@@ -101520,7 +101598,7 @@ function validateEvolutionScopePolicy(policy) {
|
|
|
101520
101598
|
return policy;
|
|
101521
101599
|
}
|
|
101522
101600
|
function nextRevision(candidate, lifecycle, reason, now2, audit) {
|
|
101523
|
-
const revisionId = `arev_${(0,
|
|
101601
|
+
const revisionId = `arev_${(0, import_node_crypto59.createHash)("sha256").update(`${candidate.revisionId}
|
|
101524
101602
|
${lifecycle}
|
|
101525
101603
|
${reason}
|
|
101526
101604
|
${now2}`).digest("hex").slice(0, 20)}`;
|
|
@@ -101532,7 +101610,7 @@ ${now2}`).digest("hex").slice(0, 20)}`;
|
|
|
101532
101610
|
lifecycleHistory: [
|
|
101533
101611
|
...candidate.lifecycleHistory,
|
|
101534
101612
|
{
|
|
101535
|
-
eventId: `ale_${(0,
|
|
101613
|
+
eventId: `ale_${(0, import_node_crypto59.createHash)("sha256").update(`${revisionId}
|
|
101536
101614
|
${audit.actor}
|
|
101537
101615
|
${reason}`).digest("hex").slice(0, 20)}`,
|
|
101538
101616
|
from: candidate.lifecycle,
|
|
@@ -113434,7 +113512,7 @@ function createHttpUpgradeRouter(server) {
|
|
|
113434
113512
|
}
|
|
113435
113513
|
|
|
113436
113514
|
// backend/src/server/profile-lock.ts
|
|
113437
|
-
var
|
|
113515
|
+
var import_node_crypto60 = require("node:crypto");
|
|
113438
113516
|
var import_node_child_process23 = require("node:child_process");
|
|
113439
113517
|
var import_promises46 = require("node:fs/promises");
|
|
113440
113518
|
var import_node_path75 = __toESM(require("node:path"), 1);
|
|
@@ -113612,7 +113690,7 @@ async function replaceLockFile(profileDir, lockFile, expectedOwner, nextOwner) {
|
|
|
113612
113690
|
async function createLockCandidate(lockFile, owner) {
|
|
113613
113691
|
const candidatePath = import_node_path75.default.join(
|
|
113614
113692
|
import_node_path75.default.dirname(lockFile),
|
|
113615
|
-
`.${import_node_path75.default.basename(lockFile)}.${(0,
|
|
113693
|
+
`.${import_node_path75.default.basename(lockFile)}.${(0, import_node_crypto60.randomUUID)()}.tmp`
|
|
113616
113694
|
);
|
|
113617
113695
|
let handle2;
|
|
113618
113696
|
try {
|
|
@@ -113955,7 +114033,7 @@ function isRemoteBrowserProfileState(value) {
|
|
|
113955
114033
|
}
|
|
113956
114034
|
|
|
113957
114035
|
// backend/src/remote/browser-bindings.ts
|
|
113958
|
-
var
|
|
114036
|
+
var import_node_crypto61 = require("node:crypto");
|
|
113959
114037
|
function matchesOwner(owner, binding) {
|
|
113960
114038
|
return owner.desktopId === binding.desktopId && owner.hostId === binding.hostId && (owner.ownerKeyHash ? owner.ownerKeyHash === binding.ownerKeyHash : owner.ownerSessionId === binding.ownerSessionId);
|
|
113961
114039
|
}
|
|
@@ -113994,7 +114072,7 @@ var DesktopBrowserBindings = class {
|
|
|
113994
114072
|
};
|
|
113995
114073
|
if (!this.recoveryRequests.has(key2) && this.recoveryRequests.size >= 64)
|
|
113996
114074
|
throw new RemoteBrowserError("BROWSER_CAPACITY_EXCEEDED", 503, "Too many pending Browser recoveries");
|
|
113997
|
-
const request2 = { owner: { ...owner }, requestedAt: Date.now(), requestId: (0,
|
|
114075
|
+
const request2 = { owner: { ...owner }, requestedAt: Date.now(), requestId: (0, import_node_crypto61.randomUUID)(), complete: false };
|
|
113998
114076
|
this.recoveryRequests.set(key2, request2);
|
|
113999
114077
|
return { requestId: request2.requestId, requestedAt: request2.requestedAt, status: "pending" };
|
|
114000
114078
|
}
|
|
@@ -114010,7 +114088,7 @@ var DesktopBrowserBindings = class {
|
|
|
114010
114088
|
"Invalid desktop binding"
|
|
114011
114089
|
);
|
|
114012
114090
|
}
|
|
114013
|
-
const ownerKeyHash = input2.ownerKey ? (0,
|
|
114091
|
+
const ownerKeyHash = input2.ownerKey ? (0, import_node_crypto61.createHash)("sha256").update(input2.ownerKey).digest("hex") : void 0;
|
|
114014
114092
|
this.pruneRecoveryRequests();
|
|
114015
114093
|
for (const request2 of this.recoveryRequests.values()) {
|
|
114016
114094
|
if (request2.complete || !matchesOwner(request2.owner, { ...input2, ownerSessionId, ownerKeyHash })) continue;
|
|
@@ -114048,7 +114126,7 @@ var DesktopBrowserBindings = class {
|
|
|
114048
114126
|
}
|
|
114049
114127
|
}
|
|
114050
114128
|
const record3 = {
|
|
114051
|
-
id: existingId ?? (0,
|
|
114129
|
+
id: existingId ?? (0, import_node_crypto61.randomUUID)(),
|
|
114052
114130
|
protocolVersion: 2,
|
|
114053
114131
|
ownerSessionId,
|
|
114054
114132
|
ownerKeyHash,
|
|
@@ -114179,7 +114257,7 @@ var DesktopBrowserBindings = class {
|
|
|
114179
114257
|
this.capabilities.delete(token2);
|
|
114180
114258
|
}
|
|
114181
114259
|
const binding = this.selectedBinding(terminalSessionId);
|
|
114182
|
-
const token = (0,
|
|
114260
|
+
const token = (0, import_node_crypto61.randomBytes)(32).toString("hex");
|
|
114183
114261
|
this.capabilities.set(token, {
|
|
114184
114262
|
bindingId: binding.id,
|
|
114185
114263
|
generation: binding.generation,
|
|
@@ -114280,7 +114358,7 @@ var DesktopBrowserBindings = class {
|
|
|
114280
114358
|
};
|
|
114281
114359
|
|
|
114282
114360
|
// backend/src/remote/installation-id.ts
|
|
114283
|
-
var
|
|
114361
|
+
var import_node_crypto62 = require("node:crypto");
|
|
114284
114362
|
var import_promises47 = require("node:fs/promises");
|
|
114285
114363
|
var import_node_path77 = __toESM(require("node:path"), 1);
|
|
114286
114364
|
async function loadInstallationId(storageDirectory) {
|
|
@@ -114293,7 +114371,7 @@ async function loadInstallationId(storageDirectory) {
|
|
|
114293
114371
|
} catch (error2) {
|
|
114294
114372
|
if (error2.code !== "ENOENT") throw error2;
|
|
114295
114373
|
}
|
|
114296
|
-
const id7 = (0,
|
|
114374
|
+
const id7 = (0, import_node_crypto62.randomUUID)();
|
|
114297
114375
|
try {
|
|
114298
114376
|
await (0, import_promises47.writeFile)(file, `${id7}
|
|
114299
114377
|
`, { flag: "wx", mode: 384 });
|
|
@@ -114330,12 +114408,12 @@ function registerRemoteCapabilitiesRoute(app, requireTunnelAuth, requireAuth, br
|
|
|
114330
114408
|
}
|
|
114331
114409
|
|
|
114332
114410
|
// backend/src/remote/terminal-hook-auth.ts
|
|
114333
|
-
var
|
|
114411
|
+
var import_node_crypto63 = require("node:crypto");
|
|
114334
114412
|
function matchesToken2(value, expected) {
|
|
114335
114413
|
if (!expected) return false;
|
|
114336
114414
|
const supplied = Buffer.from(value);
|
|
114337
114415
|
const actual = Buffer.from(expected);
|
|
114338
|
-
return supplied.length === actual.length && (0,
|
|
114416
|
+
return supplied.length === actual.length && (0, import_node_crypto63.timingSafeEqual)(supplied, actual);
|
|
114339
114417
|
}
|
|
114340
114418
|
async function authenticatesTerminal(value, terminalId, sessions, signal) {
|
|
114341
114419
|
signal.throwIfAborted();
|
|
@@ -114496,7 +114574,7 @@ function registerRemoteBrowserRoutes(app, auth, sessions, requireTunnelAuth, bro
|
|
|
114496
114574
|
}
|
|
114497
114575
|
|
|
114498
114576
|
// backend/src/ws/terminal-events-server.ts
|
|
114499
|
-
var
|
|
114577
|
+
var import_node_crypto64 = require("node:crypto");
|
|
114500
114578
|
|
|
114501
114579
|
// backend/src/ws/heartbeat.ts
|
|
114502
114580
|
function createHeartbeatController(socket, state, onTimeout) {
|
|
@@ -114588,7 +114666,7 @@ function attachTerminalEventsWebSocketServer(upgradeRouter, authService, termina
|
|
|
114588
114666
|
});
|
|
114589
114667
|
wss.on("connection", (socket, request2) => {
|
|
114590
114668
|
const connectedAt = Date.now();
|
|
114591
|
-
const clientId = (0,
|
|
114669
|
+
const clientId = (0, import_node_crypto64.randomUUID)();
|
|
114592
114670
|
const identifier = (name) => {
|
|
114593
114671
|
const value = request2.headers[name];
|
|
114594
114672
|
return typeof value === "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(value) ? value : void 0;
|
|
@@ -114674,7 +114752,7 @@ function attachTerminalEventsWebSocketServer(upgradeRouter, authService, termina
|
|
|
114674
114752
|
}
|
|
114675
114753
|
|
|
114676
114754
|
// backend/src/ws/terminal-server.ts
|
|
114677
|
-
var
|
|
114755
|
+
var import_node_crypto65 = require("node:crypto");
|
|
114678
114756
|
|
|
114679
114757
|
// backend/src/terminal/runtime/output-batcher.ts
|
|
114680
114758
|
var OUTPUT_BATCH_DURATION_MS = 16;
|
|
@@ -115722,7 +115800,7 @@ function attachTerminalWebSocketServer(upgradeRouter, terminalSessionManager, ru
|
|
|
115722
115800
|
const session = terminalSessionManager.getSession(terminalSessionId);
|
|
115723
115801
|
const params = new URL(request2.url ?? "/", "http://localhost").searchParams;
|
|
115724
115802
|
const requestedViewerId = params.get("resumeClientId");
|
|
115725
|
-
const viewerId = requestedViewerId && /^[a-zA-Z0-9_-]{16,128}$/.test(requestedViewerId) ? requestedViewerId : (0,
|
|
115803
|
+
const viewerId = requestedViewerId && /^[a-zA-Z0-9_-]{16,128}$/.test(requestedViewerId) ? requestedViewerId : (0, import_node_crypto65.randomUUID)();
|
|
115726
115804
|
const runtimeId = session && isTmuxBackedSession(session) ? runtimeRegistry.displayRuntimeId(terminalSessionId, viewerId) : terminalSessionId;
|
|
115727
115805
|
const sendInitialSnapshot = shouldSendInitialSnapshot(request2);
|
|
115728
115806
|
const settleInitialTmuxRepaint = shouldSettleInitialTmuxRepaint(
|
|
@@ -116215,7 +116293,7 @@ async function collectAgentEvidence(history, collector, deviceID, effectiveFrom,
|
|
|
116215
116293
|
}
|
|
116216
116294
|
|
|
116217
116295
|
// backend/src/screen-recording-analysis/runtime.ts
|
|
116218
|
-
var
|
|
116296
|
+
var import_node_crypto66 = require("node:crypto");
|
|
116219
116297
|
var import_promises50 = require("node:fs/promises");
|
|
116220
116298
|
var import_node_path80 = __toESM(require("node:path"), 1);
|
|
116221
116299
|
|
|
@@ -116268,9 +116346,39 @@ var import_node_path79 = __toESM(require("node:path"), 1);
|
|
|
116268
116346
|
// backend/src/screen-recording-analysis/batching.ts
|
|
116269
116347
|
function representativeFrames(manifest, maximum = 15) {
|
|
116270
116348
|
const frames = manifest.captures.filter((frame) => !frame.privacyPlaceholder);
|
|
116271
|
-
if (
|
|
116349
|
+
if (!Number.isSafeInteger(maximum) || maximum < 1) return [];
|
|
116350
|
+
if (maximum === 1) return frames.slice(0, 1);
|
|
116351
|
+
const priorities = frames.map((frame, index) => {
|
|
116352
|
+
const previous = frames[index - 1];
|
|
116353
|
+
const app = frame.frontmostApplication?.id, previousApp = previous?.frontmostApplication?.id;
|
|
116354
|
+
if (previous && (frame.sessionID !== previous.sessionID || frame.displayID !== previous.displayID || app && previousApp && app !== previousApp)) return 3;
|
|
116355
|
+
if (frame.visualChanged === true && previous?.visualChanged === false) return 2;
|
|
116356
|
+
return frame.visualChanged === false ? 0 : 1;
|
|
116357
|
+
});
|
|
116358
|
+
const candidates = frames.map((_, index) => index).filter((index) => index === 0 || index === frames.length - 1 || priorities[index] > 0);
|
|
116359
|
+
if (candidates.length <= maximum) return candidates.map((index) => frames[index]);
|
|
116272
116360
|
const indices = /* @__PURE__ */ new Set();
|
|
116273
|
-
|
|
116361
|
+
const interior = candidates.slice(1, -1);
|
|
116362
|
+
if (interior.every((index) => priorities[index] === priorities[interior[0]])) {
|
|
116363
|
+
for (let i = 0; i < maximum; i++) indices.add(candidates[Math.round(i * (candidates.length - 1) / (maximum - 1))]);
|
|
116364
|
+
} else {
|
|
116365
|
+
indices.add(0);
|
|
116366
|
+
indices.add(frames.length - 1);
|
|
116367
|
+
while (indices.size < maximum) {
|
|
116368
|
+
let best = -1, bestPriority = -1, bestDistance = -1;
|
|
116369
|
+
for (const index of interior) {
|
|
116370
|
+
if (indices.has(index)) continue;
|
|
116371
|
+
const priority = priorities[index];
|
|
116372
|
+
const distance = Math.min(...[...indices].map((selected) => Math.abs(index - selected)));
|
|
116373
|
+
if (priority > bestPriority || priority === bestPriority && distance > bestDistance) {
|
|
116374
|
+
best = index;
|
|
116375
|
+
bestPriority = priority;
|
|
116376
|
+
bestDistance = distance;
|
|
116377
|
+
}
|
|
116378
|
+
}
|
|
116379
|
+
indices.add(best);
|
|
116380
|
+
}
|
|
116381
|
+
}
|
|
116274
116382
|
return [...indices].sort((a, b) => a - b).map((index) => frames[index]);
|
|
116275
116383
|
}
|
|
116276
116384
|
function idleObservation(manifest) {
|
|
@@ -116496,7 +116604,7 @@ var ScreenRecordingAnalysisRuntime = class {
|
|
|
116496
116604
|
constructor(history) {
|
|
116497
116605
|
this.history = history;
|
|
116498
116606
|
}
|
|
116499
|
-
workerID = (0,
|
|
116607
|
+
workerID = (0, import_node_crypto66.randomUUID)();
|
|
116500
116608
|
collector = new AnalysisCollector();
|
|
116501
116609
|
timer;
|
|
116502
116610
|
active;
|
|
@@ -116510,7 +116618,7 @@ var ScreenRecordingAnalysisRuntime = class {
|
|
|
116510
116618
|
});
|
|
116511
116619
|
this.schedule(0);
|
|
116512
116620
|
}
|
|
116513
|
-
schedule(
|
|
116621
|
+
schedule(delay11) {
|
|
116514
116622
|
if (this.closed) return;
|
|
116515
116623
|
this.timer = setTimeout(() => {
|
|
116516
116624
|
this.active = this.tick().catch(() => {
|
|
@@ -116519,7 +116627,7 @@ var ScreenRecordingAnalysisRuntime = class {
|
|
|
116519
116627
|
this.active = void 0;
|
|
116520
116628
|
this.schedule(6e4);
|
|
116521
116629
|
});
|
|
116522
|
-
},
|
|
116630
|
+
}, delay11);
|
|
116523
116631
|
this.timer.unref();
|
|
116524
116632
|
}
|
|
116525
116633
|
async tick() {
|
|
@@ -116710,10 +116818,10 @@ var ScreenRecordingService = class {
|
|
|
116710
116818
|
};
|
|
116711
116819
|
|
|
116712
116820
|
// backend/src/side-chat/service.ts
|
|
116713
|
-
var
|
|
116821
|
+
var import_node_crypto68 = require("node:crypto");
|
|
116714
116822
|
|
|
116715
116823
|
// backend/src/side-chat/provider.ts
|
|
116716
|
-
var
|
|
116824
|
+
var import_node_crypto67 = require("node:crypto");
|
|
116717
116825
|
var import_node_child_process25 = require("node:child_process");
|
|
116718
116826
|
var import_node_fs37 = require("node:fs");
|
|
116719
116827
|
var import_node_path81 = __toESM(require("node:path"), 1);
|
|
@@ -116732,7 +116840,7 @@ var SideChatProvider = class {
|
|
|
116732
116840
|
this.binary = binary;
|
|
116733
116841
|
this.env = env;
|
|
116734
116842
|
}
|
|
116735
|
-
profile = `runweave_side_chat_${(0,
|
|
116843
|
+
profile = `runweave_side_chat_${(0, import_node_crypto67.randomUUID)().replaceAll("-", "")}`;
|
|
116736
116844
|
child = null;
|
|
116737
116845
|
pending = /* @__PURE__ */ new Map();
|
|
116738
116846
|
buffer = "";
|
|
@@ -117124,7 +117232,7 @@ var SideChatService = class {
|
|
|
117124
117232
|
const repeated = this.repeated(operationId, fingerprint3);
|
|
117125
117233
|
if (repeated) return { chat: this.requireChat(repeated.sideChatId), operation: repeated, created: false };
|
|
117126
117234
|
const active3 = this.store.active(this.owner, sourceKey(source2));
|
|
117127
|
-
const chat = active3 ?? { id: (0,
|
|
117235
|
+
const chat = active3 ?? { id: (0, import_node_crypto68.randomUUID)(), ownerScope: this.owner, sourceKey: sourceKey(source2), source: source2, providerThreadId: null, status: "creating", version: 1, createdAt: now(), endedAt: null };
|
|
117128
117236
|
if (!active3) this.store.saveChat(chat);
|
|
117129
117237
|
const operation2 = this.accept(operationId, fingerprint3, "create", chat, null, active3 ? "completed" : "accepted");
|
|
117130
117238
|
return { chat, operation: operation2, created: !active3 };
|
|
@@ -117161,7 +117269,7 @@ var SideChatService = class {
|
|
|
117161
117269
|
if (chat.status !== "active") throw new SideChatError(409, "CHAT_NOT_ACTIVE", "\u65C1\u804A\u5F53\u524D\u4E0D\u80FD\u7EE7\u7EED\u63D0\u95EE");
|
|
117162
117270
|
const current = this.store.current(id7);
|
|
117163
117271
|
if (current && SIDE_CHAT_BUSY_STATES.includes(current.state)) throw new SideChatError(409, "TURN_IN_FLIGHT", "\u5F53\u524D\u56DE\u7B54\u5C1A\u672A\u7ED3\u675F\u6216\u7ED3\u679C\u4E0D\u660E\uFF0C\u8BF7\u5148\u6838\u5BF9\u72B6\u6001");
|
|
117164
|
-
const turn = { id: (0,
|
|
117272
|
+
const turn = { id: (0, import_node_crypto68.randomUUID)(), sideChatId: id7, clientOperationId: request2.operationId, providerTurnId: null, state: "accepted", acceptedAt: now(), finishedAt: null, errorCode: null };
|
|
117165
117273
|
chat.version++;
|
|
117166
117274
|
this.store.saveChat(chat);
|
|
117167
117275
|
this.store.saveTurn(turn);
|
|
@@ -117262,7 +117370,7 @@ var SideChatService = class {
|
|
|
117262
117370
|
}
|
|
117263
117371
|
}
|
|
117264
117372
|
acquire(chat) {
|
|
117265
|
-
const execution = { provider: new SideChatProvider(chat.source.cwd), generation: (0,
|
|
117373
|
+
const execution = { provider: new SideChatProvider(chat.source.cwd), generation: (0, import_node_crypto68.randomUUID)(), turnId: null, items: /* @__PURE__ */ new Map(), completed: null };
|
|
117266
117374
|
this.executions.set(chat.id, execution);
|
|
117267
117375
|
execution.provider.observe((event) => {
|
|
117268
117376
|
const current = this.executions.get(chat.id);
|
|
@@ -117545,9 +117653,9 @@ var SideChatStore = class {
|
|
|
117545
117653
|
};
|
|
117546
117654
|
|
|
117547
117655
|
// backend/src/auth/connection-identity.ts
|
|
117548
|
-
var import_node_crypto68 = require("node:crypto");
|
|
117549
|
-
var import_promises51 = require("node:fs/promises");
|
|
117550
117656
|
var import_node_crypto69 = require("node:crypto");
|
|
117657
|
+
var import_promises51 = require("node:fs/promises");
|
|
117658
|
+
var import_node_crypto70 = require("node:crypto");
|
|
117551
117659
|
var import_node_path84 = __toESM(require("node:path"), 1);
|
|
117552
117660
|
|
|
117553
117661
|
// packages/shared/src/auth/connection-identity.ts
|
|
@@ -117570,9 +117678,9 @@ var ConnectionIdentityService = class _ConnectionIdentityService {
|
|
|
117570
117678
|
await (0, import_promises51.lstat)(file);
|
|
117571
117679
|
} catch (error2) {
|
|
117572
117680
|
if (error2.code !== "ENOENT") throw error2;
|
|
117573
|
-
const { privateKey } = (0,
|
|
117681
|
+
const { privateKey } = (0, import_node_crypto69.generateKeyPairSync)("ed25519");
|
|
117574
117682
|
const data = JSON.stringify({ schemaVersion: 1, privateKey: privateKey.export({ format: "jwk" }) });
|
|
117575
|
-
const temporary = `${file}.${(0,
|
|
117683
|
+
const temporary = `${file}.${(0, import_node_crypto70.randomUUID)()}.tmp`;
|
|
117576
117684
|
const handle2 = await (0, import_promises51.open)(temporary, "wx", 384);
|
|
117577
117685
|
try {
|
|
117578
117686
|
await handle2.writeFile(data);
|
|
@@ -117593,10 +117701,10 @@ var ConnectionIdentityService = class _ConnectionIdentityService {
|
|
|
117593
117701
|
assertWindowsPrivatePath(file);
|
|
117594
117702
|
const stored = JSON.parse(await (0, import_promises51.readFile)(file, "utf8"));
|
|
117595
117703
|
if (stored.schemaVersion !== 1 || stored.privateKey?.crv !== "Ed25519" || !stored.privateKey.d) throw new Error("Invalid identity key");
|
|
117596
|
-
const key2 = (0,
|
|
117597
|
-
if (key2.asymmetricKeyType !== "ed25519" || (0,
|
|
117704
|
+
const key2 = (0, import_node_crypto69.createPrivateKey)({ key: stored.privateKey, format: "jwk" });
|
|
117705
|
+
if (key2.asymmetricKeyType !== "ed25519" || (0, import_node_crypto69.createPublicKey)(key2).export({ format: "jwk" }).x !== stored.privateKey.x) throw new Error("Invalid identity key");
|
|
117598
117706
|
const challenge = Buffer.from("runweave-identity-file-check-v1");
|
|
117599
|
-
if (!(0,
|
|
117707
|
+
if (!(0, import_node_crypto69.verify)(null, challenge, (0, import_node_crypto69.createPublicKey)(key2), (0, import_node_crypto69.sign)(null, challenge, key2))) throw new Error("Invalid identity key pair");
|
|
117600
117708
|
return new _ConnectionIdentityService(key2);
|
|
117601
117709
|
} catch {
|
|
117602
117710
|
return new _ConnectionIdentityService(null);
|
|
@@ -117604,13 +117712,13 @@ var ConnectionIdentityService = class _ConnectionIdentityService {
|
|
|
117604
117712
|
}
|
|
117605
117713
|
identity() {
|
|
117606
117714
|
if (!this.key) return null;
|
|
117607
|
-
const publicKey = (0,
|
|
117608
|
-
return { version: 1, identityId: (0,
|
|
117715
|
+
const publicKey = (0, import_node_crypto69.createPublicKey)(this.key).export({ format: "jwk" }).x;
|
|
117716
|
+
return { version: 1, identityId: (0, import_node_crypto69.createHash)("sha256").update(Buffer.from(publicKey, "base64url")).digest("hex"), publicKey };
|
|
117609
117717
|
}
|
|
117610
117718
|
prove(nonce) {
|
|
117611
117719
|
const identity2 = this.identity();
|
|
117612
117720
|
if (!identity2 || !this.key) return null;
|
|
117613
|
-
return { ...identity2, nonce, signature: (0,
|
|
117721
|
+
return { ...identity2, nonce, signature: (0, import_node_crypto69.sign)(null, Buffer.from(connectionProbeMessage(identity2.identityId, nonce)), this.key).toString("base64url") };
|
|
117614
117722
|
}
|
|
117615
117723
|
};
|
|
117616
117724
|
|
|
@@ -117917,11 +118025,11 @@ var LowDbAuthStore = class {
|
|
|
117917
118025
|
};
|
|
117918
118026
|
|
|
117919
118027
|
// backend/src/auth/service.ts
|
|
117920
|
-
var
|
|
117921
|
-
var
|
|
118028
|
+
var import_node_crypto72 = __toESM(require("node:crypto"), 1);
|
|
118029
|
+
var import_node_crypto73 = require("node:crypto");
|
|
117922
118030
|
|
|
117923
118031
|
// backend/src/auth/jwt.ts
|
|
117924
|
-
var
|
|
118032
|
+
var import_node_crypto71 = __toESM(require("node:crypto"), 1);
|
|
117925
118033
|
function encodePayload(payload) {
|
|
117926
118034
|
return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
|
|
117927
118035
|
}
|
|
@@ -117956,7 +118064,7 @@ function decodePayload(encodedPayload) {
|
|
|
117956
118064
|
}
|
|
117957
118065
|
}
|
|
117958
118066
|
function signPayload(encodedPayload, secret2) {
|
|
117959
|
-
return
|
|
118067
|
+
return import_node_crypto71.default.createHmac("sha256", secret2).update(encodedPayload).digest("base64url");
|
|
117960
118068
|
}
|
|
117961
118069
|
function issueToken(params) {
|
|
117962
118070
|
const nowMs = Date.now();
|
|
@@ -117965,7 +118073,7 @@ function issueToken(params) {
|
|
|
117965
118073
|
sub: params.username,
|
|
117966
118074
|
sid: params.sessionId,
|
|
117967
118075
|
exp: Math.floor(nowMs / 1e3) + expiresIn,
|
|
117968
|
-
jti:
|
|
118076
|
+
jti: import_node_crypto71.default.randomUUID(),
|
|
117969
118077
|
type: params.tokenType,
|
|
117970
118078
|
resource: params.resource
|
|
117971
118079
|
};
|
|
@@ -117991,7 +118099,7 @@ function verifyToken(token, secret2) {
|
|
|
117991
118099
|
if (receivedBuffer.length !== expectedBuffer.length) {
|
|
117992
118100
|
return { valid: false };
|
|
117993
118101
|
}
|
|
117994
|
-
if (!
|
|
118102
|
+
if (!import_node_crypto71.default.timingSafeEqual(receivedBuffer, expectedBuffer)) {
|
|
117995
118103
|
return { valid: false };
|
|
117996
118104
|
}
|
|
117997
118105
|
const payload = decodePayload(encodedPayload);
|
|
@@ -118009,7 +118117,7 @@ function verifyToken(token, secret2) {
|
|
|
118009
118117
|
|
|
118010
118118
|
// backend/src/auth/service.ts
|
|
118011
118119
|
function hashToken(token) {
|
|
118012
|
-
return
|
|
118120
|
+
return import_node_crypto72.default.createHash("sha256").update(token).digest("hex");
|
|
118013
118121
|
}
|
|
118014
118122
|
function toIsoAfter(ttlMs) {
|
|
118015
118123
|
return new Date(Date.now() + ttlMs).toISOString();
|
|
@@ -118058,7 +118166,7 @@ var AuthService = class {
|
|
|
118058
118166
|
return result;
|
|
118059
118167
|
}
|
|
118060
118168
|
async issueSession(username, params) {
|
|
118061
|
-
const sessionId = (0,
|
|
118169
|
+
const sessionId = (0, import_node_crypto73.randomUUID)();
|
|
118062
118170
|
const accessToken = issueToken({
|
|
118063
118171
|
username,
|
|
118064
118172
|
sessionId,
|
|
@@ -118277,7 +118385,7 @@ async function createAuthRuntime(storagePaths, resources) {
|
|
|
118277
118385
|
}
|
|
118278
118386
|
|
|
118279
118387
|
// backend/src/dev-resources/service.ts
|
|
118280
|
-
var
|
|
118388
|
+
var import_node_crypto74 = require("node:crypto");
|
|
118281
118389
|
var import_node_fs40 = require("node:fs");
|
|
118282
118390
|
var import_promises55 = __toESM(require("node:fs/promises"), 1);
|
|
118283
118391
|
var import_node_os20 = __toESM(require("node:os"), 1);
|
|
@@ -118299,7 +118407,7 @@ function signature(pid) {
|
|
|
118299
118407
|
}
|
|
118300
118408
|
}
|
|
118301
118409
|
var DevResourcesService = class {
|
|
118302
|
-
generation = (0,
|
|
118410
|
+
generation = (0, import_node_crypto74.randomUUID)();
|
|
118303
118411
|
directory = import_node_path87.default.join(
|
|
118304
118412
|
import_node_os20.default.homedir(),
|
|
118305
118413
|
".runweave",
|
|
@@ -118331,7 +118439,7 @@ var DevResourcesService = class {
|
|
|
118331
118439
|
file(key2) {
|
|
118332
118440
|
return import_node_path87.default.join(
|
|
118333
118441
|
this.directory,
|
|
118334
|
-
(0,
|
|
118442
|
+
(0, import_node_crypto74.createHash)("sha256").update(key2).digest("hex") + ".json"
|
|
118335
118443
|
);
|
|
118336
118444
|
}
|
|
118337
118445
|
async read(file) {
|
|
@@ -118354,7 +118462,7 @@ var DevResourcesService = class {
|
|
|
118354
118462
|
}
|
|
118355
118463
|
}
|
|
118356
118464
|
async save(file, record3) {
|
|
118357
|
-
const temporary = `${file}.${(0,
|
|
118465
|
+
const temporary = `${file}.${(0, import_node_crypto74.randomUUID)()}.tmp`;
|
|
118358
118466
|
await import_promises55.default.writeFile(temporary, JSON.stringify(record3), {
|
|
118359
118467
|
mode: 384,
|
|
118360
118468
|
flag: "wx"
|
|
@@ -118438,7 +118546,7 @@ var DevResourcesService = class {
|
|
|
118438
118546
|
ownerId: resource?.owner?.id ?? null,
|
|
118439
118547
|
generation: this.generation,
|
|
118440
118548
|
result: {
|
|
118441
|
-
operationId: (0,
|
|
118549
|
+
operationId: (0, import_node_crypto74.randomUUID)(),
|
|
118442
118550
|
state: "running",
|
|
118443
118551
|
message: "\u6B63\u5728\u6838\u5BF9\u5360\u7528\u5E76\u91CA\u653E\u8D44\u6E90"
|
|
118444
118552
|
},
|
|
@@ -118530,18 +118638,18 @@ var DevResourcesService = class {
|
|
|
118530
118638
|
};
|
|
118531
118639
|
|
|
118532
118640
|
// backend/src/terminal/code-review/service.ts
|
|
118533
|
-
var
|
|
118641
|
+
var import_node_crypto76 = require("node:crypto");
|
|
118534
118642
|
var import_promises58 = require("node:fs/promises");
|
|
118535
118643
|
var import_node_path93 = __toESM(require("node:path"), 1);
|
|
118536
118644
|
|
|
118537
118645
|
// backend/src/terminal/code-review/snapshot.ts
|
|
118538
118646
|
var import_node_child_process27 = require("node:child_process");
|
|
118539
|
-
var
|
|
118647
|
+
var import_node_crypto75 = require("node:crypto");
|
|
118540
118648
|
var import_promises56 = require("node:fs/promises");
|
|
118541
118649
|
var import_node_path88 = __toESM(require("node:path"), 1);
|
|
118542
118650
|
var import_node_util15 = require("node:util");
|
|
118543
118651
|
var exec4 = (0, import_node_util15.promisify)(import_node_child_process27.execFile);
|
|
118544
|
-
var reviewDigest = (value) => (0,
|
|
118652
|
+
var reviewDigest = (value) => (0, import_node_crypto75.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
118545
118653
|
async function git3(root, args) {
|
|
118546
118654
|
return (await exec4("git", args, {
|
|
118547
118655
|
cwd: root,
|
|
@@ -118618,7 +118726,7 @@ async function captureReviewSnapshot(projectId, rootPath) {
|
|
|
118618
118726
|
if (!first.stable || !second.stable || first.fingerprint !== second.fingerprint) continue;
|
|
118619
118727
|
return {
|
|
118620
118728
|
schemaVersion: 1,
|
|
118621
|
-
snapshotId: (0,
|
|
118729
|
+
snapshotId: (0, import_node_crypto75.randomUUID)(),
|
|
118622
118730
|
rootPath,
|
|
118623
118731
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
118624
118732
|
head: first.head,
|
|
@@ -119146,7 +119254,7 @@ var CodeReviewService = class {
|
|
|
119146
119254
|
}
|
|
119147
119255
|
if (continuing && ["pending", "writing"].includes(previous.run.delivery))
|
|
119148
119256
|
throw new CodeReviewError(409, "delivery_pending", "\u672C\u8F6E\u7ED3\u679C\u5C1A\u5728\u56DE\u4F20\uFF0C\u8BF7\u7B49\u5F85\u56DE\u4F20\u7ED3\u675F\u540E\u590D\u5BA1");
|
|
119149
|
-
const id7 = (0,
|
|
119257
|
+
const id7 = (0, import_node_crypto76.randomUUID)();
|
|
119150
119258
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
119151
119259
|
const candidate = continuing && previous.reviewerThreadId && previous.run.reviewerTerminalId ? await this.tasks.observe(previous.reviewerTaskId).catch(() => null) : null;
|
|
119152
119260
|
const reuse = candidate?.availability === "available" && candidate.task.phase === "ready" && candidate.task.control === "supervisor" && candidate.task.threadId === previous?.reviewerThreadId && candidate.task.terminalSessionId === previous?.run.reviewerTerminalId && candidate.terminalState?.state === "agent_idle";
|
|
@@ -119252,8 +119360,8 @@ var CodeReviewService = class {
|
|
|
119252
119360
|
}
|
|
119253
119361
|
if (run2.phase === "preparing") {
|
|
119254
119362
|
await this.store.prepare(id7);
|
|
119363
|
+
const snapshot3 = record3.snapshotId ? await this.store.snapshot(id7) : await captureReviewSnapshot(record3.source.projectId, record3.source.rootPath);
|
|
119255
119364
|
if (!record3.snapshotId) {
|
|
119256
|
-
const snapshot3 = await captureReviewSnapshot(record3.source.projectId, record3.source.rootPath);
|
|
119257
119365
|
if (!snapshot3.entries.length) throw new CodeReviewError(409, "no_changes", "\u5F53\u524D\u5DE5\u4F5C\u533A\u6CA1\u6709\u5F85\u5BA1\u67E5\u7684\u6539\u52A8");
|
|
119258
119366
|
const requirements2 = await readReviewRequirements(this.manager, this.options, record3.source.terminalId, record3.source.rootPath);
|
|
119259
119367
|
await atomicJson(import_node_path93.default.join(this.store.input(id7), "requirements.json"), requirements2);
|
|
@@ -119262,9 +119370,9 @@ var CodeReviewService = class {
|
|
|
119262
119370
|
await (0, import_promises58.chmod)(import_node_path93.default.join(this.store.input(id7), "snapshot.json"), 256);
|
|
119263
119371
|
record3.snapshotId = snapshot3.snapshotId;
|
|
119264
119372
|
await this.touch(record3);
|
|
119265
|
-
await (0, import_promises58.chmod)(this.store.input(id7), 320);
|
|
119266
|
-
if (snapshot3.entries.every((entry) => entry.omission)) throw new CodeReviewError(422, "no_reviewable_changes", "\u5168\u90E8\u53D8\u66F4\u5747\u4E0D\u53EF\u8BFB\u53D6\uFF0C\u8986\u76D6\u7F3A\u53E3\u5DF2\u4FDD\u5B58");
|
|
119267
119373
|
}
|
|
119374
|
+
await (0, import_promises58.chmod)(this.store.input(id7), 320);
|
|
119375
|
+
if (snapshot3.entries.every((entry) => entry.omission)) throw new CodeReviewError(422, "no_reviewable_changes", "\u5168\u90E8\u53D8\u66F4\u5747\u4E0D\u53EF\u8BFB\u53D6\uFF0C\u8986\u76D6\u7F3A\u53E3\u5DF2\u4FDD\u5B58");
|
|
119268
119376
|
if (record3.recovered && !this.tasks.list().some((task2) => task2.taskId === record3.reviewerTaskId) && !run2.reviewerTerminalId) {
|
|
119269
119377
|
record3.recovered = false;
|
|
119270
119378
|
}
|
|
@@ -119370,7 +119478,7 @@ var CodeReviewService = class {
|
|
|
119370
119478
|
};
|
|
119371
119479
|
|
|
119372
119480
|
// backend/src/terminal/tasks/store.ts
|
|
119373
|
-
var
|
|
119481
|
+
var import_node_crypto77 = require("node:crypto");
|
|
119374
119482
|
var import_promises59 = require("node:fs/promises");
|
|
119375
119483
|
var import_node_path94 = __toESM(require("node:path"), 1);
|
|
119376
119484
|
var TerminalTaskStore = class {
|
|
@@ -119406,7 +119514,7 @@ var TerminalTaskStore = class {
|
|
|
119406
119514
|
this.assertWritable();
|
|
119407
119515
|
const body2 = JSON.stringify({ version: 1, tasks: [...this.tasks.values()] });
|
|
119408
119516
|
const work = this.tail.then(async () => {
|
|
119409
|
-
const temporary = `${this.file}.${(0,
|
|
119517
|
+
const temporary = `${this.file}.${(0, import_node_crypto77.randomUUID)()}.tmp`;
|
|
119410
119518
|
const handle2 = await (0, import_promises59.open)(temporary, "wx", 384);
|
|
119411
119519
|
try {
|
|
119412
119520
|
await handle2.writeFile(body2);
|
|
@@ -119434,7 +119542,7 @@ var TerminalTaskStore = class {
|
|
|
119434
119542
|
var import_node_path97 = __toESM(require("node:path"), 1);
|
|
119435
119543
|
|
|
119436
119544
|
// backend/src/task-handoff/service.ts
|
|
119437
|
-
var
|
|
119545
|
+
var import_node_crypto78 = require("node:crypto");
|
|
119438
119546
|
var import_promises61 = require("node:fs/promises");
|
|
119439
119547
|
var import_node_path96 = __toESM(require("node:path"), 1);
|
|
119440
119548
|
|
|
@@ -119763,7 +119871,7 @@ var TaskHandoffService = class {
|
|
|
119763
119871
|
queue = Promise.resolve();
|
|
119764
119872
|
analysis;
|
|
119765
119873
|
key(target2) {
|
|
119766
|
-
return (0,
|
|
119874
|
+
return (0, import_node_crypto78.createHash)("sha256").update(JSON.stringify(target2)).digest("hex");
|
|
119767
119875
|
}
|
|
119768
119876
|
resolve(terminalSessionId, panelId) {
|
|
119769
119877
|
const session = this.manager.getSession(terminalSessionId);
|
|
@@ -119855,7 +119963,7 @@ var TaskHandoffService = class {
|
|
|
119855
119963
|
async save(card) {
|
|
119856
119964
|
await (0, import_promises61.mkdir)(this.directory, { recursive: true, mode: 448 });
|
|
119857
119965
|
const filename = import_node_path96.default.join(this.directory, `${this.key(card.target)}.json`);
|
|
119858
|
-
const temporary = `${filename}.${(0,
|
|
119966
|
+
const temporary = `${filename}.${(0, import_node_crypto78.randomUUID)()}.tmp`;
|
|
119859
119967
|
await (0, import_promises61.writeFile)(temporary, JSON.stringify(card), { mode: 384 });
|
|
119860
119968
|
await (0, import_promises61.rename)(temporary, filename);
|
|
119861
119969
|
}
|
|
@@ -120179,10 +120287,10 @@ var TerminalBadges = class {
|
|
|
120179
120287
|
};
|
|
120180
120288
|
|
|
120181
120289
|
// backend/src/device-monitor/terminal-replies.ts
|
|
120182
|
-
var
|
|
120290
|
+
var import_node_crypto80 = require("node:crypto");
|
|
120183
120291
|
|
|
120184
120292
|
// backend/src/device-monitor/alerts.ts
|
|
120185
|
-
var
|
|
120293
|
+
var import_node_crypto79 = require("node:crypto");
|
|
120186
120294
|
var targetFor = (s) => `${s.installationId}:${s.environment}`;
|
|
120187
120295
|
function updateAlerts(data, snapshot2, recipients, now2 = Date.now()) {
|
|
120188
120296
|
const level2 = batteryAlertLevel(snapshot2);
|
|
@@ -120192,7 +120300,7 @@ function updateAlerts(data, snapshot2, recipients, now2 = Date.now()) {
|
|
|
120192
120300
|
data.cycle = null;
|
|
120193
120301
|
}
|
|
120194
120302
|
if (level2 && !data.cycle)
|
|
120195
|
-
data.cycle = { id: (0,
|
|
120303
|
+
data.cycle = { id: (0, import_node_crypto79.randomUUID)(), highest: level2, startedAt: now2 };
|
|
120196
120304
|
if (data.cycle && level2 === 10) data.cycle.highest = 10;
|
|
120197
120305
|
const targets = new Set(recipients.map(targetFor));
|
|
120198
120306
|
for (const delivery of Object.values(data.deliveries)) {
|
|
@@ -120203,7 +120311,7 @@ function updateAlerts(data, snapshot2, recipients, now2 = Date.now()) {
|
|
|
120203
120311
|
}
|
|
120204
120312
|
if (level2 && data.cycle && level2 === data.cycle.highest) {
|
|
120205
120313
|
for (const target2 of targets) {
|
|
120206
|
-
const id7 = (0,
|
|
120314
|
+
const id7 = (0, import_node_crypto79.createHash)("sha256").update(`${data.hostId}:${data.cycle.id}:${level2}:${target2}`).digest("hex");
|
|
120207
120315
|
if (!data.deliveries[id7])
|
|
120208
120316
|
data.deliveries[id7] = {
|
|
120209
120317
|
id: id7,
|
|
@@ -120253,7 +120361,7 @@ var TerminalReplyNotifications = class {
|
|
|
120253
120361
|
if (this.stopped) return;
|
|
120254
120362
|
const recipients = Object.values(this.subscriptions.store.snapshot().subscriptions).filter((s) => s.sessionId === sessionId && this.eligible(s));
|
|
120255
120363
|
if (!recipients.length) return;
|
|
120256
|
-
const id7 = (0,
|
|
120364
|
+
const id7 = (0, import_node_crypto80.randomUUID)();
|
|
120257
120365
|
await this.subscriptions.store.update((data) => {
|
|
120258
120366
|
const state = data.terminalReplies ??= { inputs: {}, turns: {}, deliveries: {} };
|
|
120259
120367
|
const key2 = panelKey(terminalId, panelId);
|
|
@@ -120291,7 +120399,7 @@ var TerminalReplyNotifications = class {
|
|
|
120291
120399
|
}
|
|
120292
120400
|
if (!input2 && !previous) return;
|
|
120293
120401
|
state.turns[key2] = {
|
|
120294
|
-
id: (0,
|
|
120402
|
+
id: (0, import_node_crypto80.randomUUID)(),
|
|
120295
120403
|
threadId,
|
|
120296
120404
|
source: source2,
|
|
120297
120405
|
startEventId,
|
|
@@ -120318,7 +120426,7 @@ var TerminalReplyNotifications = class {
|
|
|
120318
120426
|
if (subscription2?.sessionId === turn.sessionId && this.eligible(subscription2)) recipients.set(targetFor(subscription2), subscription2);
|
|
120319
120427
|
}
|
|
120320
120428
|
for (const [target2, subscription2] of recipients) {
|
|
120321
|
-
const id7 = (0,
|
|
120429
|
+
const id7 = (0, import_node_crypto80.createHash)("sha256").update(`${input2.terminalSessionId}:${turn.id}:${target2}`).digest("hex");
|
|
120322
120430
|
state.deliveries[id7] ??= {
|
|
120323
120431
|
id: id7,
|
|
120324
120432
|
terminalSessionId: session.id,
|
|
@@ -120418,11 +120526,11 @@ function panelKey(terminalId, panelId) {
|
|
|
120418
120526
|
return JSON.stringify([terminalId, panelId]);
|
|
120419
120527
|
}
|
|
120420
120528
|
function hashPrompt(text5) {
|
|
120421
|
-
return (0,
|
|
120529
|
+
return (0, import_node_crypto80.createHash)("sha256").update(text5.replace(/\r\n/g, "\n").trim().slice(0, 8e3)).digest("hex");
|
|
120422
120530
|
}
|
|
120423
120531
|
|
|
120424
120532
|
// backend/src/device-monitor/desktop-badge-access.ts
|
|
120425
|
-
var
|
|
120533
|
+
var import_node_crypto81 = require("node:crypto");
|
|
120426
120534
|
|
|
120427
120535
|
// packages/shared/src/push-notifications.ts
|
|
120428
120536
|
function pushBadgeTargetIdentity(environment2, installationId) {
|
|
@@ -120430,7 +120538,7 @@ function pushBadgeTargetIdentity(environment2, installationId) {
|
|
|
120430
120538
|
}
|
|
120431
120539
|
|
|
120432
120540
|
// backend/src/device-monitor/desktop-badge-access.ts
|
|
120433
|
-
var digest4 = (value) => (0,
|
|
120541
|
+
var digest4 = (value) => (0, import_node_crypto81.createHash)("sha256").update(value).digest("hex");
|
|
120434
120542
|
var DesktopBadgeAccess = class {
|
|
120435
120543
|
constructor(auth, subscriptions) {
|
|
120436
120544
|
this.auth = auth;
|
|
@@ -120470,7 +120578,7 @@ var DesktopBadgeAccess = class {
|
|
|
120470
120578
|
};
|
|
120471
120579
|
|
|
120472
120580
|
// backend/src/terminal/questions/service.ts
|
|
120473
|
-
var
|
|
120581
|
+
var import_node_crypto82 = require("node:crypto");
|
|
120474
120582
|
|
|
120475
120583
|
// backend/src/terminal/questions/executor.ts
|
|
120476
120584
|
var import_node_child_process30 = require("node:child_process");
|
|
@@ -120532,18 +120640,18 @@ function remoteSocket(args) {
|
|
|
120532
120640
|
}
|
|
120533
120641
|
async function findQuestionExecutor(panePid) {
|
|
120534
120642
|
const { stdout } = await exec6("ps", ["-ww", "-axo", "pid=,ppid=,uid="], { timeout: 3e3, maxBuffer: 4 * 1024 * 1024 });
|
|
120535
|
-
const
|
|
120643
|
+
const processes2 = stdout.split("\n").flatMap((line) => {
|
|
120536
120644
|
const match = line.match(/^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/);
|
|
120537
120645
|
return match ? [{ pid: Number(match[1]), parent: Number(match[2]), uid: Number(match[3]) }] : [];
|
|
120538
120646
|
});
|
|
120539
120647
|
const descendants = /* @__PURE__ */ new Set([panePid]);
|
|
120540
|
-
for (let iteration = 0; iteration <
|
|
120648
|
+
for (let iteration = 0; iteration < processes2.length; iteration++) {
|
|
120541
120649
|
const before = descendants.size;
|
|
120542
|
-
for (const entry of
|
|
120650
|
+
for (const entry of processes2) if (descendants.has(entry.parent)) descendants.add(entry.pid);
|
|
120543
120651
|
if (before === descendants.size) break;
|
|
120544
120652
|
}
|
|
120545
120653
|
const candidates = [];
|
|
120546
|
-
for (const entry of
|
|
120654
|
+
for (const entry of processes2) {
|
|
120547
120655
|
if (!descendants.has(entry.pid) || entry.uid !== process.getuid?.()) continue;
|
|
120548
120656
|
const args = await readCodexProcessArguments(entry.pid);
|
|
120549
120657
|
const socket = args && remoteSocket(args);
|
|
@@ -120560,7 +120668,7 @@ var TerminalQuestionsService = class {
|
|
|
120560
120668
|
this.manager = manager;
|
|
120561
120669
|
this.tmux = tmux;
|
|
120562
120670
|
}
|
|
120563
|
-
generation = (0,
|
|
120671
|
+
generation = (0, import_node_crypto82.randomUUID)();
|
|
120564
120672
|
closed = false;
|
|
120565
120673
|
connections = /* @__PURE__ */ new Map();
|
|
120566
120674
|
async target(terminalId, panelId) {
|
|
@@ -120648,10 +120756,10 @@ var TerminalQuestionsService = class {
|
|
|
120648
120756
|
|
|
120649
120757
|
// backend/src/resource-monitor/service.ts
|
|
120650
120758
|
var import_node_os21 = __toESM(require("node:os"), 1);
|
|
120651
|
-
var
|
|
120759
|
+
var import_node_crypto84 = require("node:crypto");
|
|
120652
120760
|
|
|
120653
120761
|
// backend/src/resource-monitor/observations.ts
|
|
120654
|
-
var
|
|
120762
|
+
var import_node_crypto83 = require("node:crypto");
|
|
120655
120763
|
var ResourceObservations = class {
|
|
120656
120764
|
observations = /* @__PURE__ */ new Map();
|
|
120657
120765
|
ready = /* @__PURE__ */ new Set();
|
|
@@ -120731,7 +120839,7 @@ var ResourceObservations = class {
|
|
|
120731
120839
|
if (alert) Object.assign(alert, evidence);
|
|
120732
120840
|
else if ((state.cooldowns[key2] ?? 0) <= now2 && (state.snoozes[app.appKey] ?? 0) <= now2) {
|
|
120733
120841
|
state.alerts.push({
|
|
120734
|
-
alertId: (0,
|
|
120842
|
+
alertId: (0, import_node_crypto83.randomUUID)(),
|
|
120735
120843
|
hostId,
|
|
120736
120844
|
appKey: app.appKey,
|
|
120737
120845
|
appName: app.appName,
|
|
@@ -120785,7 +120893,7 @@ var ResourceMonitorService = class {
|
|
|
120785
120893
|
this.observations.reset("energy");
|
|
120786
120894
|
});
|
|
120787
120895
|
}
|
|
120788
|
-
streamId = (0,
|
|
120896
|
+
streamId = (0, import_node_crypto84.randomUUID)();
|
|
120789
120897
|
revision = 0;
|
|
120790
120898
|
latest = null;
|
|
120791
120899
|
timer;
|
|
@@ -120964,7 +121072,7 @@ var ResourceMonitorService = class {
|
|
|
120964
121072
|
};
|
|
120965
121073
|
|
|
120966
121074
|
// backend/src/resource-monitor/store.ts
|
|
120967
|
-
var
|
|
121075
|
+
var import_node_crypto85 = require("node:crypto");
|
|
120968
121076
|
var import_promises64 = require("node:fs/promises");
|
|
120969
121077
|
var import_node_path99 = __toESM(require("node:path"), 1);
|
|
120970
121078
|
var alertSchema = external_exports.object({
|
|
@@ -121031,7 +121139,7 @@ var ResourceMonitorStore = class _ResourceMonitorStore {
|
|
|
121031
121139
|
const next = structuredClone(this.data);
|
|
121032
121140
|
const result = mutate(next);
|
|
121033
121141
|
schema2.parse(next);
|
|
121034
|
-
const temporary = `${this.file}.${(0,
|
|
121142
|
+
const temporary = `${this.file}.${(0, import_node_crypto85.randomUUID)()}.tmp`;
|
|
121035
121143
|
const handle2 = await (0, import_promises64.open)(temporary, "wx", 384);
|
|
121036
121144
|
try {
|
|
121037
121145
|
await handle2.writeFile(JSON.stringify(next));
|
|
@@ -121055,7 +121163,7 @@ var ResourceMonitorStore = class _ResourceMonitorStore {
|
|
|
121055
121163
|
};
|
|
121056
121164
|
|
|
121057
121165
|
// backend/src/terminal/attachments/text-attachment-delivery.ts
|
|
121058
|
-
var
|
|
121166
|
+
var import_node_crypto86 = require("node:crypto");
|
|
121059
121167
|
var TerminalTextAttachmentDelivery = class {
|
|
121060
121168
|
constructor(files, manager, tmux, registry2, pty) {
|
|
121061
121169
|
this.files = files;
|
|
@@ -121082,7 +121190,7 @@ var TerminalTextAttachmentDelivery = class {
|
|
|
121082
121190
|
if (this.preparations.size >= 1e3)
|
|
121083
121191
|
throw new TextAttachmentError(429, "\u5F85\u5904\u7406\u7C98\u8D34\u8FC7\u591A");
|
|
121084
121192
|
const target2 = this.target(sessionId, panelId);
|
|
121085
|
-
const preparationId = (0,
|
|
121193
|
+
const preparationId = (0, import_node_crypto86.randomUUID)();
|
|
121086
121194
|
const expiresAt = Date.now() + 12e4;
|
|
121087
121195
|
this.preparations.set(preparationId, {
|
|
121088
121196
|
target: target2,
|
|
@@ -121418,7 +121526,7 @@ var import_node_os22 = __toESM(require("node:os"), 1);
|
|
|
121418
121526
|
var import_node_path101 = __toESM(require("node:path"), 1);
|
|
121419
121527
|
|
|
121420
121528
|
// backend/src/knowledge-inbox/projection.ts
|
|
121421
|
-
var
|
|
121529
|
+
var import_node_crypto87 = require("node:crypto");
|
|
121422
121530
|
function publicText(value) {
|
|
121423
121531
|
return redactExcerpt(value).replace(/file:\/\/[^\s<>"'`]+/giu, "[\u8DEF\u5F84]").replace(
|
|
121424
121532
|
/(?:[A-Za-z]:\\|~\/|(?<![\w:/])\/)[^\s<>"'`,。;))]+/gu,
|
|
@@ -121446,7 +121554,7 @@ function itemId(source2, repositoryId, sourceId) {
|
|
|
121446
121554
|
return digest5(JSON.stringify([source2, repositoryId, sourceId]));
|
|
121447
121555
|
}
|
|
121448
121556
|
function digest5(value) {
|
|
121449
|
-
return (0,
|
|
121557
|
+
return (0, import_node_crypto87.createHash)("sha256").update(value).digest("hex");
|
|
121450
121558
|
}
|
|
121451
121559
|
function publicContent(content) {
|
|
121452
121560
|
return {
|
|
@@ -121673,7 +121781,7 @@ async function readStable(source2, repositories) {
|
|
|
121673
121781
|
var import_node_fs42 = require("node:fs");
|
|
121674
121782
|
var import_node_module3 = require("node:module");
|
|
121675
121783
|
var import_node_path100 = __toESM(require("node:path"), 1);
|
|
121676
|
-
var
|
|
121784
|
+
var import_node_crypto88 = require("node:crypto");
|
|
121677
121785
|
var require4 = (0, import_node_module3.createRequire)(__IMPORT_META_URL__);
|
|
121678
121786
|
var InboxStorage = class {
|
|
121679
121787
|
constructor(directory4) {
|
|
@@ -121705,7 +121813,7 @@ var InboxStorage = class {
|
|
|
121705
121813
|
CREATE TABLE IF NOT EXISTS share_identity (id INTEGER PRIMARY KEY CHECK(id=1), identity TEXT NOT NULL);
|
|
121706
121814
|
CREATE TABLE IF NOT EXISTS knowledge_shares (id TEXT PRIMARY KEY, username TEXT NOT NULL, snapshot TEXT NOT NULL);
|
|
121707
121815
|
`);
|
|
121708
|
-
db.prepare("INSERT OR IGNORE INTO share_identity VALUES(1,?)").run((0,
|
|
121816
|
+
db.prepare("INSERT OR IGNORE INTO share_identity VALUES(1,?)").run((0, import_node_crypto88.randomUUID)());
|
|
121709
121817
|
const columns = db.prepare("PRAGMA table_info(user_state)").all();
|
|
121710
121818
|
if (!columns.some((column) => column.name === "snapshot")) {
|
|
121711
121819
|
db.transaction(() => {
|
|
@@ -121728,7 +121836,7 @@ var InboxDatabase = class {
|
|
|
121728
121836
|
return this.db.prepare("SELECT identity FROM share_identity WHERE id=1").get().identity;
|
|
121729
121837
|
}
|
|
121730
121838
|
saveShare(username, snapshot2) {
|
|
121731
|
-
const id7 = (0,
|
|
121839
|
+
const id7 = (0, import_node_crypto88.randomUUID)();
|
|
121732
121840
|
this.db.prepare("INSERT INTO knowledge_shares VALUES(?,?,?)").run(id7, username, JSON.stringify(snapshot2));
|
|
121733
121841
|
return `rw-knowledge:v1:${this.shareIdentity()}:${id7}`;
|
|
121734
121842
|
}
|
|
@@ -122178,12 +122286,12 @@ function createKnowledgeInbox(resources, dependencies) {
|
|
|
122178
122286
|
}
|
|
122179
122287
|
|
|
122180
122288
|
// backend/src/evolution/tools/token-registry.ts
|
|
122181
|
-
var
|
|
122289
|
+
var import_node_crypto89 = __toESM(require("node:crypto"), 1);
|
|
122182
122290
|
var EvolutionToolTokenRegistry = class {
|
|
122183
122291
|
grants = /* @__PURE__ */ new Map();
|
|
122184
122292
|
runToolCalls = /* @__PURE__ */ new Map();
|
|
122185
122293
|
issue(input2) {
|
|
122186
|
-
const token =
|
|
122294
|
+
const token = import_node_crypto89.default.randomBytes(32).toString("base64url");
|
|
122187
122295
|
const grant = {
|
|
122188
122296
|
runId: input2.runId,
|
|
122189
122297
|
attemptId: input2.attemptId,
|
|
@@ -122238,7 +122346,7 @@ var EvolutionToolTokenRegistry = class {
|
|
|
122238
122346
|
}
|
|
122239
122347
|
};
|
|
122240
122348
|
function tokenDigest(token) {
|
|
122241
|
-
return
|
|
122349
|
+
return import_node_crypto89.default.createHash("sha256").update(token).digest("hex");
|
|
122242
122350
|
}
|
|
122243
122351
|
function cloneGrant(grant) {
|
|
122244
122352
|
return { ...grant, allowedTools: [...grant.allowedTools] };
|
|
@@ -122290,9 +122398,9 @@ function resolveEvolutionLearningScope(projectId) {
|
|
|
122290
122398
|
}
|
|
122291
122399
|
|
|
122292
122400
|
// backend/src/evolution/repository-store.ts
|
|
122293
|
-
var
|
|
122401
|
+
var import_node_crypto90 = require("node:crypto");
|
|
122294
122402
|
function repositoryRegistrationVersion(repository) {
|
|
122295
|
-
return (0,
|
|
122403
|
+
return (0, import_node_crypto90.createHash)("sha256").update(JSON.stringify(repository)).digest("hex");
|
|
122296
122404
|
}
|
|
122297
122405
|
function repositoryRegistrationRemoved(repository) {
|
|
122298
122406
|
return repository.registrationHistory?.at(-1)?.action === "removed";
|
|
@@ -122807,7 +122915,7 @@ async function readRunConclusions(runId, analysisStore, activationStore) {
|
|
|
122807
122915
|
}
|
|
122808
122916
|
|
|
122809
122917
|
// backend/src/evolution/service.ts
|
|
122810
|
-
var
|
|
122918
|
+
var import_node_crypto91 = __toESM(require("node:crypto"), 1);
|
|
122811
122919
|
|
|
122812
122920
|
// backend/src/evolution/cron.ts
|
|
122813
122921
|
var MINUTE_MS2 = 6e4;
|
|
@@ -123065,7 +123173,7 @@ var EvolutionService = class {
|
|
|
123065
123173
|
const requestedAfterWatermark = request2.dataRange?.afterWatermark;
|
|
123066
123174
|
const storedWatermark = requestedAfterWatermark === void 0 ? await store.getWatermark(learningScopeId, "activity") : null;
|
|
123067
123175
|
const run2 = {
|
|
123068
|
-
runId:
|
|
123176
|
+
runId: import_node_crypto91.default.randomUUID(),
|
|
123069
123177
|
repository,
|
|
123070
123178
|
learningScopeId,
|
|
123071
123179
|
trigger: { type: "manual", requestedBy },
|
|
@@ -123161,7 +123269,7 @@ var EvolutionService = class {
|
|
|
123161
123269
|
if (!this.repositories) throw new Error("evolution_repository_unavailable");
|
|
123162
123270
|
const repository = await this.repositories.resolve(request2);
|
|
123163
123271
|
const schedule2 = {
|
|
123164
|
-
scheduleId:
|
|
123272
|
+
scheduleId: import_node_crypto91.default.randomUUID(),
|
|
123165
123273
|
repository,
|
|
123166
123274
|
learningScopeId: repository.repositoryId,
|
|
123167
123275
|
name: request2.name.trim(),
|
|
@@ -123227,7 +123335,7 @@ var EvolutionService = class {
|
|
|
123227
123335
|
schedule2.timezone,
|
|
123228
123336
|
at
|
|
123229
123337
|
).toISOString();
|
|
123230
|
-
const runId =
|
|
123338
|
+
const runId = import_node_crypto91.default.randomUUID();
|
|
123231
123339
|
const watermark = await store.getWatermark(
|
|
123232
123340
|
schedule2.learningScopeId,
|
|
123233
123341
|
"activity"
|
|
@@ -123330,7 +123438,7 @@ var EvolutionService = class {
|
|
|
123330
123438
|
)
|
|
123331
123439
|
);
|
|
123332
123440
|
const batch = {
|
|
123333
|
-
batchId:
|
|
123441
|
+
batchId: import_node_crypto91.default.randomUUID(),
|
|
123334
123442
|
idempotencyKey,
|
|
123335
123443
|
createdAt: now2,
|
|
123336
123444
|
snapshotBoundary: boundary,
|
|
@@ -123476,7 +123584,7 @@ var import_node_fs46 = require("node:fs");
|
|
|
123476
123584
|
var import_node_path108 = __toESM(require("node:path"), 1);
|
|
123477
123585
|
|
|
123478
123586
|
// backend/src/evolution/storage/repository-migration-audit.ts
|
|
123479
|
-
var
|
|
123587
|
+
var import_node_crypto93 = require("node:crypto");
|
|
123480
123588
|
var import_promises65 = require("node:fs/promises");
|
|
123481
123589
|
var import_node_path104 = __toESM(require("node:path"), 1);
|
|
123482
123590
|
|
|
@@ -123543,7 +123651,7 @@ function queryActivityEvolutionEvidenceAvailability(database, requestedEventIds)
|
|
|
123543
123651
|
}
|
|
123544
123652
|
|
|
123545
123653
|
// backend/src/evolution/storage/repository-migration-integrity.ts
|
|
123546
|
-
var
|
|
123654
|
+
var import_node_crypto92 = require("node:crypto");
|
|
123547
123655
|
|
|
123548
123656
|
// backend/src/evolution/storage/sqlite-driver.ts
|
|
123549
123657
|
var import_node_module5 = require("node:module");
|
|
@@ -123555,7 +123663,7 @@ function openEvolutionDatabase(file, options = {}) {
|
|
|
123555
123663
|
|
|
123556
123664
|
// backend/src/evolution/storage/repository-migration-integrity.ts
|
|
123557
123665
|
function hash5(value) {
|
|
123558
|
-
return (0,
|
|
123666
|
+
return (0, import_node_crypto92.createHash)("sha256").update(value).digest("hex");
|
|
123559
123667
|
}
|
|
123560
123668
|
function manifestDigest(manifest) {
|
|
123561
123669
|
const content = { ...manifest, digest: void 0 };
|
|
@@ -123576,7 +123684,7 @@ function tables(database) {
|
|
|
123576
123684
|
}
|
|
123577
123685
|
function tableDigest(database, table) {
|
|
123578
123686
|
if (!/^[a-z_]+$/u.test(table)) throw new Error("invalid_table");
|
|
123579
|
-
const digest8 = (0,
|
|
123687
|
+
const digest8 = (0, import_node_crypto92.createHash)("sha256");
|
|
123580
123688
|
for (const row of database.prepare(`SELECT * FROM ${table} ORDER BY rowid`).iterate())
|
|
123581
123689
|
digest8.update(JSON.stringify(row) + "\n");
|
|
123582
123690
|
return digest8.digest("hex");
|
|
@@ -123886,7 +123994,7 @@ async function auditRepositoryMigration(dataDir) {
|
|
|
123886
123994
|
}
|
|
123887
123995
|
const manifest = {
|
|
123888
123996
|
version: 1,
|
|
123889
|
-
migrationId: (0,
|
|
123997
|
+
migrationId: (0, import_node_crypto93.randomUUID)(),
|
|
123890
123998
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
123891
123999
|
source: source2,
|
|
123892
124000
|
fingerprints: {
|
|
@@ -124536,7 +124644,7 @@ async function prepareEvolutionRepositoryMigration() {
|
|
|
124536
124644
|
|
|
124537
124645
|
// backend/src/browser-local/service.ts
|
|
124538
124646
|
var import_node_net5 = __toESM(require("node:net"), 1);
|
|
124539
|
-
var
|
|
124647
|
+
var import_node_crypto94 = require("node:crypto");
|
|
124540
124648
|
var import_node_tls = __toESM(require("node:tls"), 1);
|
|
124541
124649
|
function loopback(host) {
|
|
124542
124650
|
if (host === "localhost" || /^[a-z0-9-]+(?:\.[a-z0-9-]+)*\.localhost$/.test(host))
|
|
@@ -124557,7 +124665,7 @@ var LocalBrowserService = class {
|
|
|
124557
124665
|
issueGrant(authId, open19) {
|
|
124558
124666
|
for (const [key2, grant] of this.grants) if (grant.expiresAt <= Date.now()) this.grants.delete(key2);
|
|
124559
124667
|
if (this.disposed || !this.enabled || !this.sourceAvailable(authId, open19.terminalSessionId) || !loopback(open19.host) || !Number.isInteger(open19.port) || open19.port < 1 || open19.port > 65535 || this.grants.size >= 1024) return null;
|
|
124560
|
-
const token = (0,
|
|
124668
|
+
const token = (0, import_node_crypto94.randomBytes)(32).toString("base64url");
|
|
124561
124669
|
this.grants.set(token, { authId, open: open19, expiresAt: Date.now() + 6e4 });
|
|
124562
124670
|
return token;
|
|
124563
124671
|
}
|
|
@@ -124862,7 +124970,7 @@ var BatteryAlerts = class {
|
|
|
124862
124970
|
};
|
|
124863
124971
|
|
|
124864
124972
|
// backend/src/device-monitor/service.ts
|
|
124865
|
-
var
|
|
124973
|
+
var import_node_crypto95 = require("node:crypto");
|
|
124866
124974
|
|
|
124867
124975
|
// backend/src/device-monitor/sampler.ts
|
|
124868
124976
|
var import_node_child_process33 = require("node:child_process");
|
|
@@ -124893,7 +125001,7 @@ var DeviceMonitorService = class {
|
|
|
124893
125001
|
this.snapshotValue = {
|
|
124894
125002
|
protocolVersion: 1,
|
|
124895
125003
|
hostId: store.snapshot().hostId,
|
|
124896
|
-
streamId: (0,
|
|
125004
|
+
streamId: (0, import_node_crypto95.randomUUID)(),
|
|
124897
125005
|
revision: 0,
|
|
124898
125006
|
sampleStatus: "pending",
|
|
124899
125007
|
observedAt: null,
|
|
@@ -124968,7 +125076,7 @@ var DeviceMonitorService = class {
|
|
|
124968
125076
|
};
|
|
124969
125077
|
|
|
124970
125078
|
// backend/src/device-monitor/store.ts
|
|
124971
|
-
var
|
|
125079
|
+
var import_node_crypto96 = require("node:crypto");
|
|
124972
125080
|
var import_promises66 = require("node:fs/promises");
|
|
124973
125081
|
var import_node_path109 = __toESM(require("node:path"), 1);
|
|
124974
125082
|
|
|
@@ -125114,7 +125222,7 @@ var DeviceMonitorStore = class _DeviceMonitorStore {
|
|
|
125114
125222
|
if (error2.code !== "ENOENT") throw error2;
|
|
125115
125223
|
data = {
|
|
125116
125224
|
schemaVersion: 1,
|
|
125117
|
-
hostId: (0,
|
|
125225
|
+
hostId: (0, import_node_crypto96.randomUUID)(),
|
|
125118
125226
|
cycle: null,
|
|
125119
125227
|
subscriptions: {},
|
|
125120
125228
|
deliveries: {}
|
|
@@ -125137,7 +125245,7 @@ var DeviceMonitorStore = class _DeviceMonitorStore {
|
|
|
125137
125245
|
const work = this.tail.catch(() => void 0).then(async () => {
|
|
125138
125246
|
const next = structuredClone(this.data);
|
|
125139
125247
|
const result = mutate(next);
|
|
125140
|
-
const temporary = `${this.file}.${(0,
|
|
125248
|
+
const temporary = `${this.file}.${(0, import_node_crypto96.randomUUID)()}.tmp`;
|
|
125141
125249
|
const handle2 = await (0, import_promises66.open)(temporary, "wx", 384);
|
|
125142
125250
|
try {
|
|
125143
125251
|
await handle2.writeFile(JSON.stringify(next));
|
|
@@ -125208,9 +125316,9 @@ var import_promises67 = require("node:fs/promises");
|
|
|
125208
125316
|
var import_node_path112 = __toESM(require("node:path"), 1);
|
|
125209
125317
|
|
|
125210
125318
|
// backend/src/experience/learning-queue.ts
|
|
125211
|
-
var
|
|
125319
|
+
var import_node_crypto97 = require("node:crypto");
|
|
125212
125320
|
var import_node_path111 = __toESM(require("node:path"), 1);
|
|
125213
|
-
var digest6 = (text5) => (0,
|
|
125321
|
+
var digest6 = (text5) => (0, import_node_crypto97.createHash)("sha256").update(text5).digest("hex");
|
|
125214
125322
|
var ExperienceLearningQueue = class {
|
|
125215
125323
|
directory;
|
|
125216
125324
|
store;
|
|
@@ -125269,7 +125377,7 @@ var ExperienceLearningQueue = class {
|
|
|
125269
125377
|
...job,
|
|
125270
125378
|
status: "running",
|
|
125271
125379
|
attempts: job.attempts + 1,
|
|
125272
|
-
claim: (0,
|
|
125380
|
+
claim: (0, import_node_crypto97.randomUUID)(),
|
|
125273
125381
|
leaseUntil: now2 + 5 * 6e4,
|
|
125274
125382
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
125275
125383
|
};
|
|
@@ -125529,7 +125637,7 @@ compatible \u53EA\u8868\u793A\u672C\u6BB5\u672A\u53D1\u73B0\u95EE\u9898\uFF0C\u4
|
|
|
125529
125637
|
};
|
|
125530
125638
|
|
|
125531
125639
|
// backend/src/experience/learning-failure.ts
|
|
125532
|
-
var
|
|
125640
|
+
var import_node_crypto98 = require("node:crypto");
|
|
125533
125641
|
function learningFailureReceipt(error2, input2) {
|
|
125534
125642
|
const raw = error2 instanceof ProviderOutputError || error2 instanceof ProviderProcessError ? error2.raw : input2.output === void 0 ? "" : JSON.stringify(input2.output);
|
|
125535
125643
|
let normalized = raw;
|
|
@@ -125557,7 +125665,7 @@ function learningFailureReceipt(error2, input2) {
|
|
|
125557
125665
|
}
|
|
125558
125666
|
const code = error2 instanceof ProviderOutputError ? error2.ioCode ?? error2.message : error2 instanceof external_exports.ZodError ? "provider_output_schema_invalid" : error2 instanceof Error && /^provider_[a-z_]+$/u.test(error2.message) ? error2.message : "provider_failed";
|
|
125559
125667
|
return {
|
|
125560
|
-
receiptId: (0,
|
|
125668
|
+
receiptId: (0, import_node_crypto98.randomUUID)(),
|
|
125561
125669
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
125562
125670
|
attempt: input2.attempt,
|
|
125563
125671
|
phase: input2.phase,
|
|
@@ -126022,7 +126130,7 @@ function hasToolPair(facts, ids) {
|
|
|
126022
126130
|
}
|
|
126023
126131
|
|
|
126024
126132
|
// backend/src/experience/learning-source.ts
|
|
126025
|
-
var
|
|
126133
|
+
var import_node_crypto99 = require("node:crypto");
|
|
126026
126134
|
async function readLearningFacts(store, source2) {
|
|
126027
126135
|
if (!store) throw new Error("experience_activity_unavailable");
|
|
126028
126136
|
const selected = [];
|
|
@@ -126118,7 +126226,7 @@ function projectToolImages(text5) {
|
|
|
126118
126226
|
type: "omitted_image",
|
|
126119
126227
|
reason: "Image not inspected by text-only experience analysis; not outcome evidence",
|
|
126120
126228
|
sourceBytes: Buffer.byteLength(block.image_url),
|
|
126121
|
-
sha256: (0,
|
|
126229
|
+
sha256: (0, import_node_crypto99.createHash)("sha256").update(block.image_url).digest("hex")
|
|
126122
126230
|
};
|
|
126123
126231
|
});
|
|
126124
126232
|
return {
|
|
@@ -126688,7 +126796,7 @@ function readVersion(output) {
|
|
|
126688
126796
|
}
|
|
126689
126797
|
|
|
126690
126798
|
// backend/src/activity/runtime.ts
|
|
126691
|
-
var
|
|
126799
|
+
var import_node_crypto101 = __toESM(require("node:crypto"), 1);
|
|
126692
126800
|
var import_node_path115 = __toESM(require("node:path"), 1);
|
|
126693
126801
|
|
|
126694
126802
|
// backend/src/activity/database/service.ts
|
|
@@ -126743,17 +126851,17 @@ var ActivityQueryService = class {
|
|
|
126743
126851
|
};
|
|
126744
126852
|
|
|
126745
126853
|
// backend/src/activity/recording/event-factory.ts
|
|
126746
|
-
var
|
|
126854
|
+
var import_node_crypto100 = __toESM(require("node:crypto"), 1);
|
|
126747
126855
|
var ActivityEventFactory = class {
|
|
126748
126856
|
constructor(identity2) {
|
|
126749
126857
|
this.identity = identity2;
|
|
126750
126858
|
}
|
|
126751
|
-
bootId =
|
|
126859
|
+
bootId = import_node_crypto100.default.randomUUID();
|
|
126752
126860
|
bootStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
126753
126861
|
sequence = 0;
|
|
126754
126862
|
create(params) {
|
|
126755
126863
|
return {
|
|
126756
|
-
eventId:
|
|
126864
|
+
eventId: import_node_crypto100.default.randomUUID(),
|
|
126757
126865
|
eventName: params.eventName,
|
|
126758
126866
|
schemaVersion: 1,
|
|
126759
126867
|
occurredAt: params.occurredAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -127347,7 +127455,7 @@ var ActivityRuntime = class _ActivityRuntime {
|
|
|
127347
127455
|
this.instanceId = instanceId;
|
|
127348
127456
|
this.recorder = new ActivityRecorder(store);
|
|
127349
127457
|
this.queryService = new ActivityQueryService(store, unavailableReason);
|
|
127350
|
-
this.maintenanceOwnerId = `${instanceId}:${
|
|
127458
|
+
this.maintenanceOwnerId = `${instanceId}:${import_node_crypto101.default.randomUUID()}`;
|
|
127351
127459
|
}
|
|
127352
127460
|
recorder;
|
|
127353
127461
|
queryService;
|
|
@@ -127358,7 +127466,7 @@ var ActivityRuntime = class _ActivityRuntime {
|
|
|
127358
127466
|
maintenanceOwnerId;
|
|
127359
127467
|
static async create(input2) {
|
|
127360
127468
|
const { env, browserProfileDir, runtimeChannel } = input2;
|
|
127361
|
-
const instanceId = env.RUNWEAVE_DESKTOP_INSTANCE_ID?.trim() || `backend:${process.pid}:${
|
|
127469
|
+
const instanceId = env.RUNWEAVE_DESKTOP_INSTANCE_ID?.trim() || `backend:${process.pid}:${import_node_crypto101.default.createHash("sha256").update(browserProfileDir).digest("hex").slice(0, 12)}`;
|
|
127362
127470
|
const eventFactory = new ActivityEventFactory({
|
|
127363
127471
|
producerName: "runweave-backend",
|
|
127364
127472
|
producerVersion: env.RUNWEAVE_RUNTIME_RELEASE_ID?.trim() || "builtin",
|
|
@@ -127501,7 +127609,7 @@ var LowDbTerminalQuickInputStore = class {
|
|
|
127501
127609
|
|
|
127502
127610
|
// backend/src/terminal/application/hook-token.ts
|
|
127503
127611
|
var import_node_fs47 = require("node:fs");
|
|
127504
|
-
var
|
|
127612
|
+
var import_node_crypto102 = require("node:crypto");
|
|
127505
127613
|
var import_node_path117 = __toESM(require("node:path"), 1);
|
|
127506
127614
|
var HOOK_TOKEN_BYTES = 32;
|
|
127507
127615
|
function loadOrCreateHookToken(filePath) {
|
|
@@ -127515,7 +127623,7 @@ function loadOrCreateHookToken(filePath) {
|
|
|
127515
127623
|
throw error2;
|
|
127516
127624
|
}
|
|
127517
127625
|
}
|
|
127518
|
-
const generated = (0,
|
|
127626
|
+
const generated = (0, import_node_crypto102.randomBytes)(HOOK_TOKEN_BYTES).toString("hex");
|
|
127519
127627
|
(0, import_node_fs47.mkdirSync)(import_node_path117.default.dirname(filePath), { recursive: true });
|
|
127520
127628
|
(0, import_node_fs47.writeFileSync)(filePath, generated, "utf8");
|
|
127521
127629
|
try {
|
|
@@ -128392,7 +128500,7 @@ var TmuxLifecycleCoordinator = class {
|
|
|
128392
128500
|
};
|
|
128393
128501
|
|
|
128394
128502
|
// backend/src/terminal/tmux/output-watcher.ts
|
|
128395
|
-
var
|
|
128503
|
+
var import_node_crypto103 = require("node:crypto");
|
|
128396
128504
|
var import_promises72 = require("node:fs/promises");
|
|
128397
128505
|
var import_node_string_decoder2 = require("node:string_decoder");
|
|
128398
128506
|
|
|
@@ -128808,7 +128916,7 @@ var TmuxOutputWatcher = class {
|
|
|
128808
128916
|
const markerSearchCursor = captureScrollbackBufferCursor(
|
|
128809
128917
|
watched.outputBuffer
|
|
128810
128918
|
);
|
|
128811
|
-
const markerId = (0,
|
|
128919
|
+
const markerId = (0, import_node_crypto103.randomUUID)();
|
|
128812
128920
|
const marker = `\x1B]777;runweave-pane-boundary=${markerId}\x07`;
|
|
128813
128921
|
const release = beginTerminalInput(session, target2.paneId, { kind: "edit", source: "pane-command", submit: true });
|
|
128814
128922
|
try {
|
|
@@ -129393,11 +129501,11 @@ function getInitialTerminalActiveCommand(command) {
|
|
|
129393
129501
|
}
|
|
129394
129502
|
|
|
129395
129503
|
// backend/src/terminal/runtime/session-id.ts
|
|
129396
|
-
var
|
|
129504
|
+
var import_node_crypto104 = require("node:crypto");
|
|
129397
129505
|
var TERMINAL_SESSION_ID_BYTES = 4;
|
|
129398
129506
|
var MAX_TERMINAL_SESSION_ID_GENERATION_ATTEMPTS = 16;
|
|
129399
129507
|
function createTerminalSessionId() {
|
|
129400
|
-
return (0,
|
|
129508
|
+
return (0, import_node_crypto104.randomBytes)(TERMINAL_SESSION_ID_BYTES).toString("hex");
|
|
129401
129509
|
}
|
|
129402
129510
|
function createUniqueTerminalSessionId(hasSessionId) {
|
|
129403
129511
|
for (let attempt = 0; attempt < MAX_TERMINAL_SESSION_ID_GENERATION_ATTEMPTS; attempt += 1) {
|
|
@@ -129420,7 +129528,7 @@ function isExistingDirectory2(value) {
|
|
|
129420
129528
|
}
|
|
129421
129529
|
|
|
129422
129530
|
// backend/src/terminal/completion/feishu-policy.ts
|
|
129423
|
-
var
|
|
129531
|
+
var import_node_crypto105 = require("node:crypto");
|
|
129424
129532
|
var MIN_DURATION_MS = 6e4;
|
|
129425
129533
|
var GRACE_MS = 3e4;
|
|
129426
129534
|
var INPUT_TTL_MS = 12e4;
|
|
@@ -129449,7 +129557,7 @@ var TerminalFeishuPolicy = class {
|
|
|
129449
129557
|
if (!feishuReply || previous.feishuReply) return;
|
|
129450
129558
|
previous.feishuReply = true;
|
|
129451
129559
|
} else {
|
|
129452
|
-
state.turns[key2] = { id: (0,
|
|
129560
|
+
state.turns[key2] = { id: (0, import_node_crypto105.randomUUID)(), startEventId, threadId, source: source2, startedAt: Date.now(), completed: false, feishuReply };
|
|
129453
129561
|
}
|
|
129454
129562
|
await this.save(id7, state);
|
|
129455
129563
|
}
|
|
@@ -129536,7 +129644,7 @@ var TerminalFeishuPolicy = class {
|
|
|
129536
129644
|
async attention(id7, panelId) {
|
|
129537
129645
|
const state = this.state(id7);
|
|
129538
129646
|
if (!state) return null;
|
|
129539
|
-
const notificationId = (0,
|
|
129647
|
+
const notificationId = (0, import_node_crypto105.randomUUID)();
|
|
129540
129648
|
state.completions[notificationId] = {
|
|
129541
129649
|
panelId,
|
|
129542
129650
|
turnId: null,
|
|
@@ -129575,7 +129683,7 @@ var TerminalFeishuPolicy = class {
|
|
|
129575
129683
|
}
|
|
129576
129684
|
};
|
|
129577
129685
|
function hashPrompt2(text5) {
|
|
129578
|
-
return (0,
|
|
129686
|
+
return (0, import_node_crypto105.createHash)("sha256").update(text5.replace(/\r\n/g, "\n").trim().slice(0, 8e3)).digest("hex");
|
|
129579
129687
|
}
|
|
129580
129688
|
|
|
129581
129689
|
// backend/src/terminal/workspace-service/worktree-project-registry.ts
|
|
@@ -131232,7 +131340,7 @@ var import_node_fs50 = require("node:fs");
|
|
|
131232
131340
|
var import_node_util19 = require("node:util");
|
|
131233
131341
|
var import_promises74 = require("node:fs/promises");
|
|
131234
131342
|
var import_node_path122 = __toESM(require("node:path"), 1);
|
|
131235
|
-
var
|
|
131343
|
+
var import_node_crypto106 = require("node:crypto");
|
|
131236
131344
|
|
|
131237
131345
|
// packages/shared/src/terminal/workspace-service.ts
|
|
131238
131346
|
var WORKSPACE_SERVICE_CONFIG_FILE_NAME = "runweave.json";
|
|
@@ -131388,7 +131496,7 @@ var WorkspaceServiceConfigLoader = class {
|
|
|
131388
131496
|
return {
|
|
131389
131497
|
config: {
|
|
131390
131498
|
status: "valid",
|
|
131391
|
-
revision: (0,
|
|
131499
|
+
revision: (0, import_node_crypto106.createHash)("sha256").update(content).digest("hex"),
|
|
131392
131500
|
error: null
|
|
131393
131501
|
},
|
|
131394
131502
|
definitions
|
|
@@ -131482,7 +131590,7 @@ async function waitForWorkspaceServiceReady(input2) {
|
|
|
131482
131590
|
}
|
|
131483
131591
|
|
|
131484
131592
|
// backend/src/terminal/workspace-service/identity.ts
|
|
131485
|
-
var
|
|
131593
|
+
var import_node_crypto107 = require("node:crypto");
|
|
131486
131594
|
var WORKSPACE_SERVICE_HASH_LENGTH = 12;
|
|
131487
131595
|
var HOST_LABEL_MAX_LENGTH = 63;
|
|
131488
131596
|
function slugify(value, fallback) {
|
|
@@ -131493,7 +131601,7 @@ function buildWorkspaceServiceIdentity(input2) {
|
|
|
131493
131601
|
const key2 = [input2.parentProjectId, input2.projectId, input2.serviceName].join(
|
|
131494
131602
|
"\0"
|
|
131495
131603
|
);
|
|
131496
|
-
const hash7 = (0,
|
|
131604
|
+
const hash7 = (0, import_node_crypto107.createHash)("sha256").update(key2).digest("hex").slice(0, WORKSPACE_SERVICE_HASH_LENGTH);
|
|
131497
131605
|
const readable = [
|
|
131498
131606
|
slugify(input2.serviceName, "service"),
|
|
131499
131607
|
slugify(input2.contextName, "workspace"),
|
|
@@ -132388,7 +132496,7 @@ var TerminalCompletionEventService = class {
|
|
|
132388
132496
|
};
|
|
132389
132497
|
|
|
132390
132498
|
// backend/src/terminal/state/terminal-event-service.ts
|
|
132391
|
-
var
|
|
132499
|
+
var import_node_crypto108 = require("node:crypto");
|
|
132392
132500
|
var MAX_TERMINAL_EVENTS = 500;
|
|
132393
132501
|
var terminalEventServiceLogger = logger.child({
|
|
132394
132502
|
component: "terminal-event-service"
|
|
@@ -132396,7 +132504,7 @@ var terminalEventServiceLogger = logger.child({
|
|
|
132396
132504
|
var TerminalEventService = class {
|
|
132397
132505
|
events = [];
|
|
132398
132506
|
nextId = 1;
|
|
132399
|
-
streamId = (0,
|
|
132507
|
+
streamId = (0, import_node_crypto108.randomUUID)();
|
|
132400
132508
|
listeners = /* @__PURE__ */ new Set();
|
|
132401
132509
|
record(input2) {
|
|
132402
132510
|
const event = {
|
|
@@ -133974,7 +134082,7 @@ var import_promises79 = require("node:fs/promises");
|
|
|
133974
134082
|
var import_node_path127 = __toESM(require("node:path"), 1);
|
|
133975
134083
|
|
|
133976
134084
|
// backend/src/evolution/trace-segmenter.ts
|
|
133977
|
-
var
|
|
134085
|
+
var import_node_crypto109 = require("node:crypto");
|
|
133978
134086
|
function segmentContextPack(manifest) {
|
|
133979
134087
|
const groups = /* @__PURE__ */ new Map();
|
|
133980
134088
|
for (const evidence of manifest.evidence) {
|
|
@@ -134024,7 +134132,7 @@ function strongestRelation(evidence) {
|
|
|
134024
134132
|
return { kind: "standalone", id: evidence.sourceRecordId };
|
|
134025
134133
|
}
|
|
134026
134134
|
function stableId(prefix, values) {
|
|
134027
|
-
return `${prefix}_${(0,
|
|
134135
|
+
return `${prefix}_${(0, import_node_crypto109.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 24)}`;
|
|
134028
134136
|
}
|
|
134029
134137
|
|
|
134030
134138
|
// backend/src/evolution/providers/trae.ts
|
|
@@ -134106,7 +134214,7 @@ function selectEvolutionProviders(params) {
|
|
|
134106
134214
|
}
|
|
134107
134215
|
|
|
134108
134216
|
// backend/src/evolution/analysis/episode-builder.ts
|
|
134109
|
-
var
|
|
134217
|
+
var import_node_crypto110 = require("node:crypto");
|
|
134110
134218
|
function buildEpisodes(manifest, segments) {
|
|
134111
134219
|
const evidenceById = new Map(
|
|
134112
134220
|
manifest.evidence.map((evidence) => [evidence.evidenceId, evidence])
|
|
@@ -134205,11 +134313,11 @@ function evidenceRole(evidence) {
|
|
|
134205
134313
|
return "fact";
|
|
134206
134314
|
}
|
|
134207
134315
|
function stableId2(prefix, values) {
|
|
134208
|
-
return `${prefix}_${(0,
|
|
134316
|
+
return `${prefix}_${(0, import_node_crypto110.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 24)}`;
|
|
134209
134317
|
}
|
|
134210
134318
|
|
|
134211
134319
|
// backend/src/evolution/analysis/claim-ledger.ts
|
|
134212
|
-
var
|
|
134320
|
+
var import_node_crypto111 = require("node:crypto");
|
|
134213
134321
|
function buildClaimLedger(params) {
|
|
134214
134322
|
const crossByTopic = new Map(
|
|
134215
134323
|
(params.crossQuestion?.reviews ?? []).map((review) => [
|
|
@@ -134283,7 +134391,7 @@ function unique(values) {
|
|
|
134283
134391
|
return [...new Set(values)].sort();
|
|
134284
134392
|
}
|
|
134285
134393
|
function stableId3(prefix, values) {
|
|
134286
|
-
return `${prefix}_${(0,
|
|
134394
|
+
return `${prefix}_${(0, import_node_crypto111.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 24)}`;
|
|
134287
134395
|
}
|
|
134288
134396
|
|
|
134289
134397
|
// backend/src/evolution/analysis/novelty-gate.ts
|
|
@@ -134601,13 +134709,13 @@ function buildCrossQuestionPrompt(params) {
|
|
|
134601
134709
|
}
|
|
134602
134710
|
|
|
134603
134711
|
// backend/src/evolution/knowledge/insight-service.ts
|
|
134604
|
-
var
|
|
134712
|
+
var import_node_crypto113 = require("node:crypto");
|
|
134605
134713
|
|
|
134606
134714
|
// backend/src/evolution/knowledge/candidate-factory.ts
|
|
134607
|
-
var
|
|
134715
|
+
var import_node_crypto112 = require("node:crypto");
|
|
134608
134716
|
var GENERATOR_VERSION = "candidate-factory-v1";
|
|
134609
134717
|
function stableId4(prefix, values) {
|
|
134610
|
-
return `${prefix}_${(0,
|
|
134718
|
+
return `${prefix}_${(0, import_node_crypto112.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 20)}`;
|
|
134611
134719
|
}
|
|
134612
134720
|
function createCandidateAsset(input2, now2 = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
134613
134721
|
if (input2.evidenceRefs.length === 0) {
|
|
@@ -134779,11 +134887,11 @@ function edge(revision2, evidenceId, relation) {
|
|
|
134779
134887
|
};
|
|
134780
134888
|
}
|
|
134781
134889
|
function stableId5(prefix, values) {
|
|
134782
|
-
return `${prefix}_${(0,
|
|
134890
|
+
return `${prefix}_${(0, import_node_crypto113.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 24)}`;
|
|
134783
134891
|
}
|
|
134784
134892
|
|
|
134785
134893
|
// backend/src/evolution/analysis/orchestrator-helpers.ts
|
|
134786
|
-
var
|
|
134894
|
+
var import_node_crypto114 = require("node:crypto");
|
|
134787
134895
|
var import_promises78 = require("node:fs/promises");
|
|
134788
134896
|
var import_node_path126 = __toESM(require("node:path"), 1);
|
|
134789
134897
|
var ANALYSIS_TOOLS = [
|
|
@@ -134913,7 +135021,7 @@ function providerErrorCode(error2) {
|
|
|
134913
135021
|
return "provider_failed";
|
|
134914
135022
|
}
|
|
134915
135023
|
function stableId6(prefix, values) {
|
|
134916
|
-
return `${prefix}_${(0,
|
|
135024
|
+
return `${prefix}_${(0, import_node_crypto114.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 24)}`;
|
|
134917
135025
|
}
|
|
134918
135026
|
|
|
134919
135027
|
// backend/src/evolution/analysis/orchestrator.ts
|
|
@@ -135581,7 +135689,7 @@ function unavailableContentIssues(evidence) {
|
|
|
135581
135689
|
}
|
|
135582
135690
|
|
|
135583
135691
|
// backend/src/evolution/knowledge/evidence-reconciler.ts
|
|
135584
|
-
var
|
|
135692
|
+
var import_node_crypto115 = require("node:crypto");
|
|
135585
135693
|
var ACTIVITY_EVIDENCE_PREFIX = "activity:";
|
|
135586
135694
|
var AVAILABILITY_BATCH_SIZE = 1e3;
|
|
135587
135695
|
var EvolutionEvidenceReconciler = class {
|
|
@@ -135717,11 +135825,11 @@ function reconciledRevision(current, edges, createdAt) {
|
|
|
135717
135825
|
};
|
|
135718
135826
|
}
|
|
135719
135827
|
function stableId7(prefix, values) {
|
|
135720
|
-
return `${prefix}_${(0,
|
|
135828
|
+
return `${prefix}_${(0, import_node_crypto115.createHash)("sha256").update(values.join("\n")).digest("hex").slice(0, 24)}`;
|
|
135721
135829
|
}
|
|
135722
135830
|
|
|
135723
135831
|
// backend/src/evolution/runtime.ts
|
|
135724
|
-
var
|
|
135832
|
+
var import_node_crypto116 = __toESM(require("node:crypto"), 1);
|
|
135725
135833
|
var RECOVERY_INTERVAL_MS = 5e3;
|
|
135726
135834
|
var LEASE_TTL_MS = 45e3;
|
|
135727
135835
|
var HEARTBEAT_INTERVAL_MS = 1e4;
|
|
@@ -135748,7 +135856,7 @@ var EvolutionRuntime = class {
|
|
|
135748
135856
|
lastMaintenanceFailedAt = null;
|
|
135749
135857
|
lastLeaseHeartbeatAt = null;
|
|
135750
135858
|
consecutiveMaintenanceFailures = 0;
|
|
135751
|
-
ownerId = `evolution-runtime:${process.pid}:${
|
|
135859
|
+
ownerId = `evolution-runtime:${process.pid}:${import_node_crypto116.default.randomUUID()}`;
|
|
135752
135860
|
start(controlPlaneBaseUrl) {
|
|
135753
135861
|
if (!this.store || this.recoveryTimer || this.stopping) return;
|
|
135754
135862
|
this.controlPlaneBaseUrl = controlPlaneBaseUrl;
|
|
@@ -136082,7 +136190,7 @@ function withinRoot(root, candidate) {
|
|
|
136082
136190
|
var import_promises82 = require("node:fs/promises");
|
|
136083
136191
|
|
|
136084
136192
|
// backend/src/utils/json-file.ts
|
|
136085
|
-
var
|
|
136193
|
+
var import_node_crypto117 = require("node:crypto");
|
|
136086
136194
|
var import_promises81 = require("node:fs/promises");
|
|
136087
136195
|
var import_node_path129 = __toESM(require("node:path"), 1);
|
|
136088
136196
|
async function readJsonFile2(filePath) {
|
|
@@ -136094,7 +136202,7 @@ async function readJsonFile2(filePath) {
|
|
|
136094
136202
|
}
|
|
136095
136203
|
async function writeJsonFile(filePath, value) {
|
|
136096
136204
|
await (0, import_promises81.mkdir)(import_node_path129.default.dirname(filePath), { recursive: true });
|
|
136097
|
-
const temporaryPath = `${filePath}.${process.pid}.${(0,
|
|
136205
|
+
const temporaryPath = `${filePath}.${process.pid}.${(0, import_node_crypto117.randomUUID)()}.tmp`;
|
|
136098
136206
|
try {
|
|
136099
136207
|
await (0, import_promises81.writeFile)(temporaryPath, `${JSON.stringify(value, null, 2)}
|
|
136100
136208
|
`, {
|
|
@@ -136670,7 +136778,7 @@ var BackendRuntimeStatusService = class {
|
|
|
136670
136778
|
var import_node_path135 = __toESM(require("node:path"), 1);
|
|
136671
136779
|
|
|
136672
136780
|
// backend/src/scheduled-tasks/migration.ts
|
|
136673
|
-
var
|
|
136781
|
+
var import_node_crypto119 = require("node:crypto");
|
|
136674
136782
|
var import_node_child_process39 = require("node:child_process");
|
|
136675
136783
|
var import_node_fs51 = require("node:fs");
|
|
136676
136784
|
var import_node_path131 = __toESM(require("node:path"), 1);
|
|
@@ -136705,7 +136813,7 @@ try {
|
|
|
136705
136813
|
}
|
|
136706
136814
|
|
|
136707
136815
|
// backend/src/scheduled-tasks/storage/migrations.ts
|
|
136708
|
-
var
|
|
136816
|
+
var import_node_crypto118 = require("node:crypto");
|
|
136709
136817
|
var import_better_sqlite33 = __toESM(require("better-sqlite3"), 1);
|
|
136710
136818
|
|
|
136711
136819
|
// backend/src/scheduled-tasks/storage/migrations/001-initial-schema.ts
|
|
@@ -136896,13 +137004,13 @@ function parseScheduledResult(text5) {
|
|
|
136896
137004
|
throw new Error("provider_result_invalid");
|
|
136897
137005
|
}
|
|
136898
137006
|
}
|
|
136899
|
-
function scheduledPrompt(prompt, runId) {
|
|
137007
|
+
function scheduledPrompt(prompt, runId, terminal = false) {
|
|
136900
137008
|
return `${prompt}
|
|
136901
137009
|
|
|
136902
137010
|
<scheduled_run_context>
|
|
136903
|
-
\u8FD9\u662F\u540E\u53F0\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u8FD0\u884C ID\uFF1A${runId}\u3002\u6CA1\u6709\u4EA4\u4E92\u5F0F Runweave \u7EC8\u7AEF\u8EAB\u4EFD\uFF0C\u4E0D\u5F97\u501F\u7528\u5176\u4ED6\u7EC8\u7AEF\u7684 Runweave \u6807\u8BC6\u6216\u4F2A\u9020 terminalSessionId\uFF1B\u8FD9\u4E0D\u9650\u5236\u5E38\u89C4\u5DE5\u5177\u4F7F\u7528\u5F53\u524D\u7CFB\u7EDF\u8D26\u53F7\u5DF2\u6709\u7684\u5408\u6CD5\u51ED\u8BC1\u3002\u9700\u8981\u8C03\u7528 Runweave CLI \u65F6\uFF0C\u82E5 RUNWEAVE_CLI_BIN \u5DF2\u8BBE\u7F6E\uFF0C\u5FC5\u987B\u4F7F\u7528 "$RUNWEAVE_CLI_BIN"\uFF1B\u767B\u5F55 shell \u4E2D PATH \u91CC\u7684 rw \u53EF\u80FD\u5C5E\u4E8E\u5176\u4ED6\u8FD0\u884C\u5B9E\u4F8B\u3002
|
|
137011
|
+
\u8FD9\u662F\u540E\u53F0\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u8FD0\u884C ID\uFF1A${runId}\u3002${terminal ? "\u8FD9\u662F\u5728\u4E13\u7528 Runweave \u7EC8\u7AEF\u4E2D\u6267\u884C\u7684\u4EFB\u52A1\uFF0C\u4F7F\u7528\u5F53\u524D\u7EC8\u7AEF\u7684\u771F\u5B9E\u8EAB\u4EFD\uFF0C\u4E0D\u5F97\u501F\u7528\u5176\u4ED6\u7EC8\u7AEF\u7684\u6807\u8BC6\u3002\u672C\u8F6E\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C\u540E\u7531\u8C03\u5EA6\u5668\u5173\u95ED\u7EC8\u7AEF\uFF0C\u4E0D\u8981\u81EA\u884C\u5173\u95ED\u7EC8\u7AEF\u3002" : "\u6CA1\u6709\u4EA4\u4E92\u5F0F Runweave \u7EC8\u7AEF\u8EAB\u4EFD\uFF0C\u4E0D\u5F97\u501F\u7528\u5176\u4ED6\u7EC8\u7AEF\u7684 Runweave \u6807\u8BC6\u6216\u4F2A\u9020 terminalSessionId\uFF1B\u8FD9\u4E0D\u9650\u5236\u5E38\u89C4\u5DE5\u5177\u4F7F\u7528\u5F53\u524D\u7CFB\u7EDF\u8D26\u53F7\u5DF2\u6709\u7684\u5408\u6CD5\u51ED\u8BC1\u3002"}\u9700\u8981\u8C03\u7528 Runweave CLI \u65F6\uFF0C\u82E5 RUNWEAVE_CLI_BIN \u5DF2\u8BBE\u7F6E\uFF0C\u5FC5\u987B\u4F7F\u7528 "$RUNWEAVE_CLI_BIN"\uFF1B\u767B\u5F55 shell \u4E2D PATH \u91CC\u7684 rw \u53EF\u80FD\u5C5E\u4E8E\u5176\u4ED6\u8FD0\u884C\u5B9E\u4F8B\u3002
|
|
136904
137012
|
Runweave \u53F3\u4FA7\u6D4F\u89C8\u5668\u4F7F\u7528 toolkit:playwright-cli\uFF0C\u4E0D\u662F Computer Use \u7684 iab\u3002\u9700\u8981\u6D4F\u89C8\u5668\u65F6\u5148\u8FD0\u884C rw browser profile resolve --json\uFF0C\u518D\u9644\u7740\u8FD4\u56DE\u7684 cdpEndpoint\uFF1B\u4E0D\u5F97\u76F4\u63A5\u628A\u7A7A\u5206\u7EC4\u9519\u8BEF\u89E3\u91CA\u4E3A\u6D4F\u89C8\u5668\u4E0D\u53EF\u7528\uFF0C\u4E5F\u4E0D\u8981\u56E0\u6B64\u6539\u7528\u72EC\u7ACB Chrome\u3002\u82E5\u9700\u7528\u6237\u767B\u5F55\u6216\u64CD\u4F5C\u9875\u9762\uFF0C\u8C03\u7528 rw browser assist request --browser-profile <1|2|3> --group-id <\u89E3\u6790\u8FD4\u56DE\u7684\u5206\u7EC4> --target-id <\u771F\u5B9E\u9875\u9762 targetId> --reason <\u5177\u4F53\u64CD\u4F5C> --json\uFF1B\u540E\u53F0\u6A21\u5F0F\u4F1A\u8FD4\u56DE\u5F85\u63D0\u4EA4\u7684 blocked \u7ED3\u679C\uFF0C\u987B\u4F5C\u4E3A\u672C\u8F6E\u6700\u7EC8 JSON \u8FD4\u56DE\u540E\u505C\u6B62\u64CD\u4F5C\u9875\u9762\uFF0C\u8BA9\u7528\u6237\u4ECE\u8FD0\u884C\u8BB0\u5F55\u63A5\u7BA1\u539F\u4F1A\u8BDD\u3002\u6CA1\u6709\u6D4F\u89C8\u5668\u534F\u52A9\u65F6 recovery.browser \u4E3A null\u3002
|
|
136905
|
-
\u8BF7\u6267\u884C\u4EFB\u52A1\uFF0C\u5E76\u901A\u8FC7\u6307\u5B9A JSON schema \u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C\
|
|
137013
|
+
\u8BF7\u6267\u884C\u4EFB\u52A1\uFF0C\u5E76${terminal ? `\u6700\u7EC8\u56DE\u590D\u5FC5\u987B\u662F\u5355\u4E2A JSON \u5BF9\u8C61\uFF0C\u4E0D\u4F7F\u7528 Markdown \u4EE3\u7801\u5757\uFF0C\u7B26\u5408\u4EE5\u4E0B schema\uFF1A${JSON.stringify(scheduledResultSchema)}\u3002` : "\u901A\u8FC7\u6307\u5B9A JSON schema \u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C\u3002"}outcome \u4EC5\u5728\u7528\u6237\u8981\u6C42\u7684\u5DE5\u4F5C\u548C\u5FC5\u8981\u9A8C\u8BC1\u5B9E\u9645\u5B8C\u6210\u65F6\u4E3A succeeded\uFF1B\u6743\u9650\u3001\u7F51\u7EDC\u3001\u8BA4\u8BC1\u3001\u5BA1\u6279\u62D2\u7EDD\u6216\u7F3A\u5C11\u5FC5\u8981\u8F93\u5165\u5BFC\u81F4\u4E0D\u80FD\u7EE7\u7EED\u65F6\u4E3A blocked\uFF1B\u6267\u884C\u5931\u8D25\u4E3A failed\u3002summary \u7528\u4E2D\u6587 Markdown \u8BF4\u660E\u5B9E\u9645\u6210\u679C\u548C\u8BC1\u636E\uFF0Creason \u8BF4\u660E\u963B\u585E\u6216\u5931\u8D25\u7684\u5177\u4F53\u539F\u56E0\u4E0E\u4E0B\u4E00\u6B65\uFF08\u6210\u529F\u65F6\u4E3A\u7A7A\uFF09\u3002\u8FDB\u7A0B\u6B63\u5E38\u9000\u51FA\u3001\u8BFB\u5B8C\u6280\u80FD\u6216\u751F\u6210\u8BA1\u5212\u5747\u4E0D\u7B49\u4E8E\u4EFB\u52A1\u6210\u529F\u3002\u672A\u5B8C\u6210\u65F6\u5FC5\u987B\u63D0\u4F9B recovery \u5EFA\u8BAE\uFF1A\u539F\u6388\u6743\u5185\u4ECD\u6709\u5177\u4F53\u4E0B\u4E00\u6B65\u7528 continue/remaining-work\uFF1B\u6709\u8BC1\u636E\u7684\u4E34\u65F6\u670D\u52A1\u6545\u969C\u7528 wait/transient\uFF1B\u7B49\u5F85 CI \u6216\u53EF\u9A8C\u8BC1\u7684\u5916\u90E8\u6761\u4EF6\u7528 wait/external-wait\uFF1B\u7F3A\u5C11\u7528\u6237\u8F93\u5165\u7528 needs-input/input\uFF0C\u6743\u9650\u6216\u5BA1\u6279\u62D2\u7EDD\u7528 needs-input/permission\uFF1B\u672A\u77E5\u7ED3\u679C\u6216\u4E0D\u53EF\u6062\u590D\u7528 stop/unknown\u3002evidence \u5199\u4E8B\u5B9E\u4F9D\u636E\uFF0CnextStep \u5199\u6838\u5BF9\u6761\u4EF6\u53CA\u5269\u4F59\u5DE5\u4F5C\uFF0CnotBefore \u4EC5\u5728\u6709\u660E\u786E\u6700\u65E9\u6062\u590D\u65F6\u95F4\u65F6\u5199 UTC ISO \u65F6\u95F4\uFF0C\u5426\u5219\u4E3A null\u3002\u82E5\u53EA\u5DEE\u7528\u6237\u660E\u786E\u540C\u610F\uFF0C\u5728 confirmation \u4E2D\u5199\u6E05\u70B9\u51FB\u5141\u8BB8\u5C06\u786E\u8BA4\u7684\u5177\u4F53\u52A8\u4F5C\u3001\u8303\u56F4\u53CA\u5FC5\u8981\u6761\u4EF6\uFF1B\u4E0D\u8981\u53EA\u5199\u201C\u7EE7\u7EED\u201D\uFF0C\u4E5F\u4E0D\u8981\u628A\u5F00\u653E\u6027\u95EE\u9898\u4F2A\u88C5\u6210\u6388\u6743\uFF0C\u5176\u4ED6\u60C5\u51B5 confirmation \u4E3A null\u3002\u7528\u6237\u5DF2\u660E\u786E\u56DE\u7B54\u7684\u95EE\u9898\u65E0\u9700\u91CD\u590D\u8BE2\u95EE\uFF1B\u4EC5\u6709\u8FDB\u7A0B\u5B58\u5728\u4E0D\u80FD\u8BC1\u660E\u4ECD\u6709\u5E76\u53D1\u5199\u5165\uFF0C\u5E94\u5148\u6838\u5BF9\u5B9E\u9645\u53D8\u5316\u3002\u6210\u529F\u65F6 recovery \u4E3A null\u3002\u7EE7\u7EED\u5EFA\u8BAE\u4E0D\u4EE3\u8868\u6269\u5C55\u6388\u6743\uFF0C\u8303\u56F4\u4E0D\u660E\u6216\u5E76\u53D1\u5199\u5165\u5F52\u5C5E\u4E0D\u660E\u4E0D\u80FD\u53EA\u9760\u7B49\u5F85\u81EA\u52A8\u89E3\u51B3\u3002\u7F51\u7EDC\u6216\u8BA4\u8BC1\u68C0\u67E5\u8D85\u65F6\u4E0D\u7B49\u4E8E\u51ED\u8BC1\u5931\u6548\u6216\u6743\u9650\u62D2\u7EDD\uFF1B\u5148\u6309\u6240\u7528\u6280\u80FD\u533A\u5206\u7F51\u7EDC\u8FDE\u901A\u3001\u51ED\u8BC1\u8BFB\u53D6\u4E0E\u5B9E\u9645\u8BA4\u8BC1\u7ED3\u679C\uFF0C\u5E76\u5728\u83B7\u51C6\u8DEF\u7EBF\u5185\u6709\u754C\u6062\u590D\uFF0C\u539F\u56E0\u5FC5\u987B\u6709\u8BC1\u636E\u3002\u4E0D\u8981\u7ED5\u8FC7\u6743\u9650\u9650\u5236\uFF1B\u5BA1\u6279\u6216\u6743\u9650\u62D2\u7EDD\u540E\u5982\u65E0\u83B7\u51C6\u7684\u66FF\u4EE3\u8DEF\u5F84\uFF0C\u5E94\u8FD4\u56DE blocked\u3002
|
|
136906
137014
|
</scheduled_run_context>`;
|
|
136907
137015
|
}
|
|
136908
137016
|
|
|
@@ -137365,7 +137473,7 @@ function migrateScheduledTasks(database, reviewedPrompts) {
|
|
|
137365
137473
|
}).immediate();
|
|
137366
137474
|
}
|
|
137367
137475
|
function checksum(sql) {
|
|
137368
|
-
return (0,
|
|
137476
|
+
return (0, import_node_crypto118.createHash)("sha256").update(sql).digest("hex");
|
|
137369
137477
|
}
|
|
137370
137478
|
function assertLegacySchema(database) {
|
|
137371
137479
|
const tables2 = database.prepare(
|
|
@@ -137479,12 +137587,12 @@ var ScheduledTaskMigration = class {
|
|
|
137479
137587
|
database.pragma("busy_timeout = 5000");
|
|
137480
137588
|
const preview = database.transaction(() => this.readPreview(database))();
|
|
137481
137589
|
this.assertApplicable(database, preview, input2);
|
|
137482
|
-
const backupPath = import_node_path131.default.join(import_node_path131.default.dirname(this.databasePath), "migration-backups", `${(0,
|
|
137590
|
+
const backupPath = import_node_path131.default.join(import_node_path131.default.dirname(this.databasePath), "migration-backups", `${(0, import_node_crypto119.randomUUID)()}.sqlite`);
|
|
137483
137591
|
(0, import_node_fs51.mkdirSync)(import_node_path131.default.dirname(backupPath), { recursive: true, mode: 448 });
|
|
137484
137592
|
await database.backup(backupPath);
|
|
137485
137593
|
(0, import_node_fs51.chmodSync)(backupPath, 384);
|
|
137486
137594
|
const receipt = {
|
|
137487
|
-
migrationId: (0,
|
|
137595
|
+
migrationId: (0, import_node_crypto119.randomUUID)(),
|
|
137488
137596
|
sourceVersion: preview.schemaVersion,
|
|
137489
137597
|
targetVersion: SCHEDULED_TASK_SCHEMA_VERSION,
|
|
137490
137598
|
changedTaskIds: preview.tasks.map((task) => task.id),
|
|
@@ -137585,7 +137693,7 @@ var ScheduledTaskMigration = class {
|
|
|
137585
137693
|
}
|
|
137586
137694
|
};
|
|
137587
137695
|
function digest7(value) {
|
|
137588
|
-
return (0,
|
|
137696
|
+
return (0, import_node_crypto119.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
137589
137697
|
}
|
|
137590
137698
|
function failure2(code, message2) {
|
|
137591
137699
|
return new ScheduledTaskError(code, 409, message2);
|
|
@@ -138228,12 +138336,12 @@ function continuationPrompt2(run2) {
|
|
|
138228
138336
|
}
|
|
138229
138337
|
|
|
138230
138338
|
// backend/src/scheduled-tasks/runtime.ts
|
|
138231
|
-
var
|
|
138339
|
+
var import_node_crypto121 = require("node:crypto");
|
|
138232
138340
|
|
|
138233
138341
|
// backend/src/scheduled-tasks/run-record.ts
|
|
138234
|
-
var
|
|
138342
|
+
var import_node_crypto120 = require("node:crypto");
|
|
138235
138343
|
function createScheduledRunRecord(task, trigger, scheduledFor, context) {
|
|
138236
|
-
const id7 = (0,
|
|
138344
|
+
const id7 = (0, import_node_crypto120.randomUUID)();
|
|
138237
138345
|
return {
|
|
138238
138346
|
id: id7,
|
|
138239
138347
|
revision: 1,
|
|
@@ -138275,14 +138383,15 @@ function createScheduledRunRecord(task, trigger, scheduledFor, context) {
|
|
|
138275
138383
|
var TICK_MS = 5e3;
|
|
138276
138384
|
var LATE_WINDOW_MS = 6e4;
|
|
138277
138385
|
var ScheduledTaskRuntime = class {
|
|
138278
|
-
constructor(store, terminalSessionManager, providers, enabled, limits) {
|
|
138386
|
+
constructor(store, terminalSessionManager, providers, enabled, limits, terminalProvider) {
|
|
138279
138387
|
this.store = store;
|
|
138280
138388
|
this.terminalSessionManager = terminalSessionManager;
|
|
138281
138389
|
this.providers = providers;
|
|
138282
138390
|
this.enabled = enabled;
|
|
138283
138391
|
this.limits = limits;
|
|
138392
|
+
this.terminalProvider = terminalProvider;
|
|
138284
138393
|
}
|
|
138285
|
-
ownerId = `scheduled:${process.pid}:${(0,
|
|
138394
|
+
ownerId = `scheduled:${process.pid}:${(0, import_node_crypto121.randomUUID)()}`;
|
|
138286
138395
|
active = /* @__PURE__ */ new Map();
|
|
138287
138396
|
executions = /* @__PURE__ */ new Map();
|
|
138288
138397
|
timer = null;
|
|
@@ -138457,8 +138566,9 @@ var ScheduledTaskRuntime = class {
|
|
|
138457
138566
|
const executionStarted = Date.now();
|
|
138458
138567
|
try {
|
|
138459
138568
|
const cwd = await validateExecutionContext(initial, this.terminalSessionManager, !initial.threadRef);
|
|
138460
|
-
|
|
138569
|
+
let provider3 = this.providers.get(initial.snapshot.provider);
|
|
138461
138570
|
if (!provider3) throw new Error("provider_unavailable");
|
|
138571
|
+
if (initial.snapshot.provider === "codex" && initial.snapshot.executionPolicy === "full-access" && !initial.snapshot.origin && this.terminalProvider) provider3 = this.terminalProvider;
|
|
138462
138572
|
const budget = initial.executionBudget ?? this.limits;
|
|
138463
138573
|
const remainingMs = budget.timeoutMs - (initial.continuation?.activeMs ?? 0);
|
|
138464
138574
|
const remainingBytes = budget.maxOutputBytes - Number(initial.outputCursor ?? 0);
|
|
@@ -138469,6 +138579,8 @@ var ScheduledTaskRuntime = class {
|
|
|
138469
138579
|
const previous = !resuming && initial.trigger === "scheduled" && !initial.snapshot.origin && initial.snapshot.schedule.kind !== "once" ? await this.store.previousFinishedRun(initial.id) : null;
|
|
138470
138580
|
const result = await provider3.run({
|
|
138471
138581
|
runId: initial.id,
|
|
138582
|
+
source: { type: "scheduled-task", taskId: initial.taskId, runId: initial.id },
|
|
138583
|
+
name: initial.snapshot.name,
|
|
138472
138584
|
projectId: initial.executionContext.kind === "project" ? initial.executionContext.projectId : void 0,
|
|
138473
138585
|
prompt: resuming ? continuationPrompt2(initial) : previousBlockerPrompt(initial, previous),
|
|
138474
138586
|
...resuming ? { resumeThreadId: initial.threadRef.threadId } : {},
|
|
@@ -138485,6 +138597,9 @@ var ScheduledTaskRuntime = class {
|
|
|
138485
138597
|
onOutput: (text5) => this.store.appendOutput(initial.id, text5, budget.maxOutputBytes),
|
|
138486
138598
|
onThread: async (threadId) => {
|
|
138487
138599
|
await this.store.setRunThread(initial.id, this.ownerId, threadId);
|
|
138600
|
+
},
|
|
138601
|
+
onTerminalRetained: async (binding) => {
|
|
138602
|
+
await this.store.putBinding(initial.id, binding);
|
|
138488
138603
|
}
|
|
138489
138604
|
});
|
|
138490
138605
|
if (resuming && result.threadId !== initial.threadRef.threadId)
|
|
@@ -138502,6 +138617,15 @@ var ScheduledTaskRuntime = class {
|
|
|
138502
138617
|
}
|
|
138503
138618
|
});
|
|
138504
138619
|
} catch (error2) {
|
|
138620
|
+
if (error2 instanceof Error && error2.message === "provider_stop_unconfirmed") {
|
|
138621
|
+
await this.store.requestRunStop(initial.id, (/* @__PURE__ */ new Date()).toISOString());
|
|
138622
|
+
logger.warn("scheduled-tasks.execution.stop-unconfirmed", {
|
|
138623
|
+
component: "scheduled-tasks",
|
|
138624
|
+
runId: initial.id,
|
|
138625
|
+
error: error2
|
|
138626
|
+
});
|
|
138627
|
+
return;
|
|
138628
|
+
}
|
|
138505
138629
|
const code = controller.signal.aborted ? "cancelled" : error2 instanceof Error ? "code" in error2 ? String(error2.code) : error2.message : "provider_failed";
|
|
138506
138630
|
await this.store.finishExecution(initial.id, this.ownerId, {
|
|
138507
138631
|
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -138533,6 +138657,12 @@ function providerErrorMessage(code) {
|
|
|
138533
138657
|
return "The provider did not return a persistent thread identity";
|
|
138534
138658
|
case "provider_completion_missing":
|
|
138535
138659
|
return "The provider exited without a confirmed completion event";
|
|
138660
|
+
case "provider_terminal_taken_over":
|
|
138661
|
+
return "\u7528\u6237\u5DF2\u63A5\u7BA1\u6267\u884C\u7EC8\u7AEF\uFF0C\u5DF2\u505C\u6B62\u81EA\u52A8\u7BA1\u7406\u5E76\u4FDD\u7559\u7EC8\u7AEF\u3002";
|
|
138662
|
+
case "provider_terminal_changed":
|
|
138663
|
+
return "\u6267\u884C\u7EC8\u7AEF\u6216\u5BF9\u8BDD\u5DF2\u53D8\u5316\uFF0C\u65E0\u6CD5\u786E\u8BA4\u672C\u6B21\u4EFB\u52A1\u7ED3\u679C\u3002";
|
|
138664
|
+
case "provider_history_unavailable":
|
|
138665
|
+
return "\u65E0\u6CD5\u8BFB\u53D6\u6267\u884C\u7EC8\u7AEF\u7684\u539F\u751F\u5BF9\u8BDD\u8BB0\u5F55\uFF0C\u672A\u786E\u8BA4\u4EFB\u52A1\u6210\u529F\u3002";
|
|
138536
138666
|
case "provider_result_invalid":
|
|
138537
138667
|
return "Agent \u672A\u8FD4\u56DE\u6709\u6548\u7684\u4EFB\u52A1\u7ED3\u679C\uFF0C\u65E0\u6CD5\u786E\u8BA4\u6210\u529F\u3002\u8BF7\u67E5\u770B\u8F93\u51FA\u6216\u6253\u5F00\u5BF9\u8BDD\u3002";
|
|
138538
138668
|
case "provider_output_persist_failed":
|
|
@@ -138610,10 +138740,10 @@ function scheduleError(error2) {
|
|
|
138610
138740
|
}
|
|
138611
138741
|
|
|
138612
138742
|
// backend/src/scheduled-tasks/service.ts
|
|
138613
|
-
var
|
|
138743
|
+
var import_node_crypto123 = require("node:crypto");
|
|
138614
138744
|
|
|
138615
138745
|
// backend/src/scheduled-tasks/quick-input-run.ts
|
|
138616
|
-
var
|
|
138746
|
+
var import_node_crypto122 = require("node:crypto");
|
|
138617
138747
|
async function startQuickInputRun(args) {
|
|
138618
138748
|
const {
|
|
138619
138749
|
quickInputId,
|
|
@@ -138622,7 +138752,7 @@ async function startQuickInputRun(args) {
|
|
|
138622
138752
|
idempotencyKey,
|
|
138623
138753
|
store
|
|
138624
138754
|
} = args;
|
|
138625
|
-
const requestHash = (0,
|
|
138755
|
+
const requestHash = (0, import_node_crypto122.createHash)("sha256").update(JSON.stringify({ quickInputId, projectId, expectedInputUpdatedAt })).digest("hex");
|
|
138626
138756
|
try {
|
|
138627
138757
|
const existing = await store.findQuickInputRun(
|
|
138628
138758
|
quickInputId,
|
|
@@ -138714,7 +138844,7 @@ async function startQuickInputRun(args) {
|
|
|
138714
138844
|
);
|
|
138715
138845
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
138716
138846
|
const task = {
|
|
138717
|
-
id: (0,
|
|
138847
|
+
id: (0, import_node_crypto122.randomUUID)(),
|
|
138718
138848
|
revision: 1,
|
|
138719
138849
|
name: input2.title.trim() || "\u521B\u5EFA github pr",
|
|
138720
138850
|
provider: "codex",
|
|
@@ -138797,7 +138927,7 @@ var ScheduledTaskService = class {
|
|
|
138797
138927
|
const { store, nextRunAt, now: now2 } = this.prepareCreate(input2);
|
|
138798
138928
|
const task = {
|
|
138799
138929
|
...normalizeConfig(input2),
|
|
138800
|
-
id: (0,
|
|
138930
|
+
id: (0, import_node_crypto123.randomUUID)(),
|
|
138801
138931
|
revision: 1,
|
|
138802
138932
|
enabled: input2.enabled,
|
|
138803
138933
|
nextRunAt,
|
|
@@ -139181,7 +139311,7 @@ ${task.prompt}`.toLocaleLowerCase().includes(query))
|
|
|
139181
139311
|
}
|
|
139182
139312
|
};
|
|
139183
139313
|
function hash6(value) {
|
|
139184
|
-
return (0,
|
|
139314
|
+
return (0, import_node_crypto123.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
139185
139315
|
}
|
|
139186
139316
|
|
|
139187
139317
|
// backend/src/scheduled-tasks/storage/store.ts
|
|
@@ -139820,6 +139950,268 @@ function response(projectId, binding) {
|
|
|
139820
139950
|
};
|
|
139821
139951
|
}
|
|
139822
139952
|
|
|
139953
|
+
// backend/src/scheduled-tasks/providers/codex-terminal.ts
|
|
139954
|
+
var import_node_crypto124 = require("node:crypto");
|
|
139955
|
+
var import_promises87 = require("node:timers/promises");
|
|
139956
|
+
|
|
139957
|
+
// backend/src/scheduled-tasks/providers/terminal-processes.ts
|
|
139958
|
+
var import_node_child_process43 = require("node:child_process");
|
|
139959
|
+
var import_promises86 = require("node:timers/promises");
|
|
139960
|
+
var import_node_util23 = require("node:util");
|
|
139961
|
+
var exec8 = (0, import_node_util23.promisify)(import_node_child_process43.execFile);
|
|
139962
|
+
async function processes() {
|
|
139963
|
+
const { stdout } = await exec8("ps", ["-axo", "pid=,ppid=,uid=,lstart="], {
|
|
139964
|
+
timeout: 3e3,
|
|
139965
|
+
maxBuffer: 4 * 1024 * 1024
|
|
139966
|
+
});
|
|
139967
|
+
return stdout.split("\n").flatMap((line) => {
|
|
139968
|
+
const match = line.match(/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.+?)\s*$/);
|
|
139969
|
+
return match && Number(match[3]) === process.getuid?.() ? [{ pid: Number(match[1]), parent: Number(match[2]), identity: `${match[3]}:${match[4]}` }] : [];
|
|
139970
|
+
});
|
|
139971
|
+
}
|
|
139972
|
+
async function terminalChildren(panePid) {
|
|
139973
|
+
const rows = await processes();
|
|
139974
|
+
if (!rows.some((row) => row.pid === panePid)) throw new Error("provider_stop_unconfirmed");
|
|
139975
|
+
const owned = /* @__PURE__ */ new Set([panePid]);
|
|
139976
|
+
for (let pass = 0; pass < rows.length; pass++) {
|
|
139977
|
+
const before = owned.size;
|
|
139978
|
+
for (const row of rows) if (owned.has(row.parent)) owned.add(row.pid);
|
|
139979
|
+
if (owned.size === before) break;
|
|
139980
|
+
}
|
|
139981
|
+
return rows.filter((row) => row.pid !== panePid && owned.has(row.pid));
|
|
139982
|
+
}
|
|
139983
|
+
async function stopTerminalChildren(children) {
|
|
139984
|
+
const expected = new Map(children.map((child) => [child.pid, child.identity]));
|
|
139985
|
+
const live = async () => (await processes()).filter((row) => expected.get(row.pid) === row.identity);
|
|
139986
|
+
const signal = (rows, value) => {
|
|
139987
|
+
for (const row of rows) {
|
|
139988
|
+
try {
|
|
139989
|
+
process.kill(row.pid, value);
|
|
139990
|
+
} catch (error2) {
|
|
139991
|
+
if (error2.code !== "ESRCH") throw error2;
|
|
139992
|
+
}
|
|
139993
|
+
}
|
|
139994
|
+
};
|
|
139995
|
+
signal(await live(), "SIGTERM");
|
|
139996
|
+
const deadline = Date.now() + 3e3;
|
|
139997
|
+
while (Date.now() < deadline) {
|
|
139998
|
+
if (!(await live()).length) return;
|
|
139999
|
+
await (0, import_promises86.setTimeout)(100);
|
|
140000
|
+
}
|
|
140001
|
+
signal(await live(), "SIGKILL");
|
|
140002
|
+
const forceDeadline = Date.now() + 1e3;
|
|
140003
|
+
while (Date.now() < forceDeadline) {
|
|
140004
|
+
if (!(await live()).length) return;
|
|
140005
|
+
await (0, import_promises86.setTimeout)(100);
|
|
140006
|
+
}
|
|
140007
|
+
throw new Error("provider_stop_unconfirmed");
|
|
140008
|
+
}
|
|
140009
|
+
|
|
140010
|
+
// backend/src/scheduled-tasks/providers/codex-terminal.ts
|
|
140011
|
+
var CodexTerminalScheduledTaskProvider = class {
|
|
140012
|
+
constructor(manager, options, history = new AppServerHistoryGateway()) {
|
|
140013
|
+
this.manager = manager;
|
|
140014
|
+
this.options = options;
|
|
140015
|
+
this.history = history;
|
|
140016
|
+
}
|
|
140017
|
+
provider = "codex";
|
|
140018
|
+
async run(request2) {
|
|
140019
|
+
const signal = AbortSignal.any([request2.signal, AbortSignal.timeout(request2.maxWallTimeMs)]);
|
|
140020
|
+
const checkCancelled = () => {
|
|
140021
|
+
if (signal.aborted) throw new Error(request2.signal.aborted ? "provider_cancelled" : "provider_timeout");
|
|
140022
|
+
};
|
|
140023
|
+
checkCancelled();
|
|
140024
|
+
if (request2.executionPolicy !== "full-access" || !request2.source || !this.options.tmuxService)
|
|
140025
|
+
throw new Error("execution_policy_unavailable");
|
|
140026
|
+
if (request2.resumeThreadId)
|
|
140027
|
+
await checkpointCodexResume(request2.resumeThreadId, request2.workingDirectory);
|
|
140028
|
+
checkCancelled();
|
|
140029
|
+
const session = await createTerminalSession(this.manager, {
|
|
140030
|
+
...request2.projectId ? { projectId: request2.projectId } : {},
|
|
140031
|
+
cwd: request2.workingDirectory,
|
|
140032
|
+
runtimePreference: "tmux"
|
|
140033
|
+
}, { ...this.options, strictDefaultPanel: true, activate: true }, request2.source);
|
|
140034
|
+
let takenOver = false;
|
|
140035
|
+
let unwatch = () => {
|
|
140036
|
+
};
|
|
140037
|
+
let panelId;
|
|
140038
|
+
let operationId;
|
|
140039
|
+
let threadId = "";
|
|
140040
|
+
let result;
|
|
140041
|
+
let failure3;
|
|
140042
|
+
let failed = false;
|
|
140043
|
+
let stopUnconfirmed = false;
|
|
140044
|
+
try {
|
|
140045
|
+
const panel = this.manager.listPanels(session.id)[0];
|
|
140046
|
+
if (!panel || session.runtimeKind !== "tmux") throw new Error("provider_terminal_changed");
|
|
140047
|
+
panelId = panel.id;
|
|
140048
|
+
const target2 = buildPaneTarget(session, this.options.tmuxService, panel);
|
|
140049
|
+
await this.manager.updateSessionAlias(session.id, `\u5B9A\u65F6\u4EFB\u52A1 \xB7 ${request2.name ?? request2.runId}`);
|
|
140050
|
+
unwatch = observeTerminalInput(session, () => {
|
|
140051
|
+
takenOver = true;
|
|
140052
|
+
});
|
|
140053
|
+
const assertOwned = () => {
|
|
140054
|
+
checkCancelled();
|
|
140055
|
+
if (takenOver) throw new Error("provider_terminal_taken_over");
|
|
140056
|
+
if (this.manager.getSession(session.id)?.status !== "running" || this.manager.getPanel(panel.id)?.tmuxPaneId !== panel.tmuxPaneId)
|
|
140057
|
+
throw new Error("provider_terminal_changed");
|
|
140058
|
+
if (operationId && !this.manager.matchesPanelAgentOperationGeneration(session.id, panel.id, operationId, "codex")) {
|
|
140059
|
+
takenOver = true;
|
|
140060
|
+
throw new Error("provider_terminal_changed");
|
|
140061
|
+
}
|
|
140062
|
+
const current = resolveConversationTarget(this.manager, session.id, panel.id).target;
|
|
140063
|
+
if (threadId && current && (current.threadId !== threadId || current.provider !== "codex")) {
|
|
140064
|
+
takenOver = true;
|
|
140065
|
+
throw new Error("provider_thread_mismatch");
|
|
140066
|
+
}
|
|
140067
|
+
};
|
|
140068
|
+
const marker = `RW_SCHEDULED_ATTEMPT_${(0, import_node_crypto124.randomUUID)()}`;
|
|
140069
|
+
const prompt = scheduledPrompt(`${marker}
|
|
140070
|
+
|
|
140071
|
+
${request2.prompt}`, request2.runId, true);
|
|
140072
|
+
const prepared = await prepareTerminalAgent(this.manager, session, this.options, {
|
|
140073
|
+
agent: "codex",
|
|
140074
|
+
command: settingText("agents.codex.binary")?.trim() || "codex",
|
|
140075
|
+
panelId: panel.id,
|
|
140076
|
+
cwd: request2.workingDirectory,
|
|
140077
|
+
prompt,
|
|
140078
|
+
...request2.resumeThreadId ? { resumeThreadId: request2.resumeThreadId } : {},
|
|
140079
|
+
args: [...codexScheduledArgs(request2), "-c", 'tui.resume_cwd="current"']
|
|
140080
|
+
}, {
|
|
140081
|
+
supervisorInput: true,
|
|
140082
|
+
stageResumeCommand: true,
|
|
140083
|
+
validateLaunchTarget: async () => {
|
|
140084
|
+
assertOwned();
|
|
140085
|
+
await request2.onSpawn(await this.options.tmuxService.readPaneProcessId(target2));
|
|
140086
|
+
assertOwned();
|
|
140087
|
+
},
|
|
140088
|
+
validateSupervisorTarget: assertOwned
|
|
140089
|
+
});
|
|
140090
|
+
operationId = prepared.operationId;
|
|
140091
|
+
let unavailableSince = null;
|
|
140092
|
+
let unsettledSince = null;
|
|
140093
|
+
let outputBytes = 0;
|
|
140094
|
+
const output = /* @__PURE__ */ new Map();
|
|
140095
|
+
while (true) {
|
|
140096
|
+
assertOwned();
|
|
140097
|
+
const identity2 = resolveConversationTarget(this.manager, session.id, panel.id).target;
|
|
140098
|
+
if (identity2) {
|
|
140099
|
+
if (identity2.provider !== "codex" || threadId && identity2.threadId !== threadId || request2.resumeThreadId && identity2.threadId !== request2.resumeThreadId) {
|
|
140100
|
+
takenOver = true;
|
|
140101
|
+
throw new Error("provider_thread_mismatch");
|
|
140102
|
+
}
|
|
140103
|
+
if (!threadId) {
|
|
140104
|
+
threadId = identity2.threadId;
|
|
140105
|
+
await request2.onThread(threadId);
|
|
140106
|
+
}
|
|
140107
|
+
const response2 = await this.history.getThreadDetail(threadId).catch(() => null);
|
|
140108
|
+
assertOwned();
|
|
140109
|
+
const detail2 = response2?.availability === "available" && response2.detail && "threadId" in response2.detail && response2.detail.provider === "codex" && response2.detail.threadId === threadId ? response2.detail : null;
|
|
140110
|
+
if (!detail2) {
|
|
140111
|
+
unavailableSince ??= Date.now();
|
|
140112
|
+
if (Date.now() - unavailableSince >= 3e4) throw new Error("provider_history_unavailable");
|
|
140113
|
+
} else {
|
|
140114
|
+
unavailableSince = null;
|
|
140115
|
+
const turns = detail2.turns.filter((turn2) => turn2.messages.some((message2) => message2.role === "user" && message2.text.includes(marker)));
|
|
140116
|
+
if (turns.length > 1) throw new Error("provider_thread_mismatch");
|
|
140117
|
+
const turn = turns[0];
|
|
140118
|
+
if (turn) {
|
|
140119
|
+
for (const message2 of turn.messages.filter((message3) => message3.role === "assistant")) {
|
|
140120
|
+
const previous = output.get(message2.id) ?? "";
|
|
140121
|
+
if (previous === message2.text) continue;
|
|
140122
|
+
const text5 = `${message2.text.startsWith(previous) ? message2.text.slice(previous.length) : message2.text}
|
|
140123
|
+
`;
|
|
140124
|
+
outputBytes += Buffer.byteLength(text5);
|
|
140125
|
+
if (outputBytes > request2.maxOutputBytes || !await request2.onOutput(text5))
|
|
140126
|
+
throw new Error("provider_output_limit_exceeded");
|
|
140127
|
+
output.set(message2.id, message2.text);
|
|
140128
|
+
}
|
|
140129
|
+
if (this.manager.getPanel(panel.id)?.terminalState?.state === "agent_idle" && turn.status !== "inProgress" && turn.itemsView === "full") {
|
|
140130
|
+
if (turn.status === "completed") {
|
|
140131
|
+
const final = turn.messages.filter((message2) => message2.role === "assistant" && message2.phase !== "commentary").at(-1);
|
|
140132
|
+
if (!final) throw new Error("provider_result_invalid");
|
|
140133
|
+
result = { provider: this.provider, threadId, ...parseScheduledResult(final.text) };
|
|
140134
|
+
break;
|
|
140135
|
+
}
|
|
140136
|
+
unsettledSince ??= Date.now();
|
|
140137
|
+
if (Date.now() - unsettledSince >= 1e4) throw new Error("provider_completion_missing");
|
|
140138
|
+
} else {
|
|
140139
|
+
unsettledSince = null;
|
|
140140
|
+
}
|
|
140141
|
+
}
|
|
140142
|
+
}
|
|
140143
|
+
}
|
|
140144
|
+
const pane = (await this.options.tmuxService.listPanes(target2)).find((item) => item.paneId === target2.paneId);
|
|
140145
|
+
if (!pane || pane.agentPrepareExit?.startsWith(`exit:${prepared.operationId}:`))
|
|
140146
|
+
throw new Error("provider_completion_missing");
|
|
140147
|
+
await (0, import_promises87.setTimeout)(1e3, void 0, { signal }).catch(() => {
|
|
140148
|
+
checkCancelled();
|
|
140149
|
+
});
|
|
140150
|
+
}
|
|
140151
|
+
} catch (error2) {
|
|
140152
|
+
failed = true;
|
|
140153
|
+
failure3 = error2;
|
|
140154
|
+
} finally {
|
|
140155
|
+
try {
|
|
140156
|
+
if (!takenOver && !result && panelId && operationId) {
|
|
140157
|
+
try {
|
|
140158
|
+
takenOver = !await this.interrupt(session.id, panelId, operationId, threadId, () => takenOver);
|
|
140159
|
+
} catch {
|
|
140160
|
+
stopUnconfirmed = true;
|
|
140161
|
+
}
|
|
140162
|
+
}
|
|
140163
|
+
if ((takenOver || stopUnconfirmed) && panelId) {
|
|
140164
|
+
await request2.onTerminalRetained?.({
|
|
140165
|
+
terminalSessionId: session.id,
|
|
140166
|
+
panelId,
|
|
140167
|
+
attachmentState: stopUnconfirmed ? "failed" : "ready",
|
|
140168
|
+
...stopUnconfirmed ? { error: "provider_stop_unconfirmed" } : {}
|
|
140169
|
+
});
|
|
140170
|
+
} else {
|
|
140171
|
+
const deleted = await deleteTerminalSession(session.id, { ...this.options, terminalSessionManager: this.manager });
|
|
140172
|
+
if (deleted) this.options.terminalEventService?.record({
|
|
140173
|
+
kind: "terminal_session_deleted",
|
|
140174
|
+
terminalSessionId: session.id,
|
|
140175
|
+
projectId: session.projectId,
|
|
140176
|
+
payload: { terminalSessionId: session.id, projectId: session.projectId }
|
|
140177
|
+
});
|
|
140178
|
+
if (deleted) recordTerminalSessionDeleted(this.options.activity, session);
|
|
140179
|
+
}
|
|
140180
|
+
} finally {
|
|
140181
|
+
unwatch();
|
|
140182
|
+
}
|
|
140183
|
+
}
|
|
140184
|
+
if (stopUnconfirmed) throw new Error("provider_stop_unconfirmed");
|
|
140185
|
+
if (failed) throw failure3;
|
|
140186
|
+
return result;
|
|
140187
|
+
}
|
|
140188
|
+
async interrupt(sessionId, panelId, operationId, threadId, takenOver) {
|
|
140189
|
+
const session = this.manager.getSession(sessionId);
|
|
140190
|
+
const panel = this.manager.getPanel(panelId);
|
|
140191
|
+
if (!session || !panel || !this.options.tmuxService) return true;
|
|
140192
|
+
const owned = () => {
|
|
140193
|
+
const current = resolveConversationTarget(this.manager, sessionId, panelId).target;
|
|
140194
|
+
return !takenOver() && this.manager.matchesPanelAgentOperationGeneration(sessionId, panelId, operationId, "codex") && (!threadId || !current || current.provider === "codex" && current.threadId === threadId);
|
|
140195
|
+
};
|
|
140196
|
+
if (!owned()) return false;
|
|
140197
|
+
const panePid = await this.options.tmuxService.readPaneProcessId(buildPaneTarget(session, this.options.tmuxService, panel));
|
|
140198
|
+
const children = await terminalChildren(panePid);
|
|
140199
|
+
if (!owned()) return false;
|
|
140200
|
+
await sendInputToSession(this.manager, {
|
|
140201
|
+
...this.options,
|
|
140202
|
+
supervisorInput: true,
|
|
140203
|
+
validateSupervisorTarget: () => {
|
|
140204
|
+
if (!owned()) throw new Error("provider_terminal_taken_over");
|
|
140205
|
+
}
|
|
140206
|
+
}, session, "\x1B", "raw", void 0, buildPaneTarget(session, this.options.tmuxService, panel));
|
|
140207
|
+
if (!owned()) return false;
|
|
140208
|
+
const afterInterrupt = await terminalChildren(panePid);
|
|
140209
|
+
if (!owned()) return false;
|
|
140210
|
+
await stopTerminalChildren([...children, ...afterInterrupt]);
|
|
140211
|
+
return !takenOver();
|
|
140212
|
+
}
|
|
140213
|
+
};
|
|
140214
|
+
|
|
139823
140215
|
// backend/src/scheduled-tasks/bootstrap.ts
|
|
139824
140216
|
var DEFAULT_TIMEOUT_MS2 = 2 * 60 * 6e4;
|
|
139825
140217
|
var DEFAULT_MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
@@ -139879,7 +140271,8 @@ async function createScheduledTaskSubsystem(params) {
|
|
|
139879
140271
|
params.terminalSessionManager,
|
|
139880
140272
|
providerProbe.adapters,
|
|
139881
140273
|
enabled,
|
|
139882
|
-
{ maxConcurrentRuns, timeoutMs, maxOutputBytes }
|
|
140274
|
+
{ maxConcurrentRuns, timeoutMs, maxOutputBytes },
|
|
140275
|
+
new CodexTerminalScheduledTaskProvider(params.terminalSessionManager, params.terminalOptions)
|
|
139883
140276
|
);
|
|
139884
140277
|
await runtime.initialize();
|
|
139885
140278
|
const service = new ScheduledTaskService(
|
|
@@ -139946,7 +140339,7 @@ async function createScheduledTasks(resources, input2) {
|
|
|
139946
140339
|
}
|
|
139947
140340
|
|
|
139948
140341
|
// backend/src/device-monitor/scheduled-task-alerts.ts
|
|
139949
|
-
var
|
|
140342
|
+
var import_node_crypto125 = require("node:crypto");
|
|
139950
140343
|
var INTERVAL_MS2 = 5e3;
|
|
139951
140344
|
var DELIVERY_WINDOW_MS2 = 3e5;
|
|
139952
140345
|
var ScheduledTaskAlerts = class {
|
|
@@ -140075,7 +140468,7 @@ var ScheduledTaskAlerts = class {
|
|
|
140075
140468
|
}
|
|
140076
140469
|
};
|
|
140077
140470
|
function deliveryId(run2, recipient) {
|
|
140078
|
-
return (0,
|
|
140471
|
+
return (0, import_node_crypto125.createHash)("sha256").update(run2.resultRevision ? `${run2.id}:${run2.resultRevision}:${recipient}` : `${run2.id}:${recipient}`).digest("hex");
|
|
140079
140472
|
}
|
|
140080
140473
|
function deliveryPlans(data, runs, recipients) {
|
|
140081
140474
|
const deliveries = data.taskDeliveries ?? {};
|
|
@@ -140130,11 +140523,11 @@ function createDelivery(id7, run2, subscriptionId) {
|
|
|
140130
140523
|
}
|
|
140131
140524
|
|
|
140132
140525
|
// backend/src/bootstrap/tmux-paths.ts
|
|
140133
|
-
var
|
|
140526
|
+
var import_node_crypto126 = require("node:crypto");
|
|
140134
140527
|
var import_node_os26 = __toESM(require("node:os"), 1);
|
|
140135
140528
|
var import_node_path136 = __toESM(require("node:path"), 1);
|
|
140136
140529
|
function profileId(browserProfileDir) {
|
|
140137
|
-
return (0,
|
|
140530
|
+
return (0, import_node_crypto126.createHash)("sha256").update(browserProfileDir).digest("hex").slice(0, 12);
|
|
140138
140531
|
}
|
|
140139
140532
|
function resolvePersistentTmuxSocketPath(browserProfileDir) {
|
|
140140
140533
|
return import_node_path136.default.join(
|