replicas-engine 0.1.932 → 0.1.934
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/{asp-host-XZDD3MM3.js → asp-host-3MLXO4VA.js} +5 -4
- package/dist/src/{chunk-QZYXFGI7.js → chunk-3LWSEH3N.js} +707 -198
- package/dist/src/{chunk-KTWH5E6W.js → chunk-CXSJSSFY.js} +1 -1
- package/dist/src/chunk-E4MPACC3.js +19 -0
- package/dist/src/{chunk-PTWY4MDP.js → chunk-ET2HBN72.js} +8 -6
- package/dist/src/{chunk-SRGTHBJU.js → chunk-F3EHVMWY.js} +5 -13
- package/dist/src/{chunk-LPVZD5CN.js → chunk-KQOMWVOJ.js} +1 -1
- package/dist/src/chunk-T3YADB2L.js +191 -0
- package/dist/src/command-protection-hook.js +5 -4
- package/dist/src/headless-agent.js +3 -2
- package/dist/src/index.js +383 -416
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
- package/dist/src/chunk-HSG6K3WN.js +0 -75
package/dist/src/index.js
CHANGED
|
@@ -26,8 +26,13 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
evaluateCommandProtection,
|
|
28
28
|
extractToolCommand,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
getCurrentBranch,
|
|
30
|
+
getOriginDefaultBranch,
|
|
31
|
+
readRepoHeadBranches,
|
|
32
|
+
reportCommandProtectionBlock,
|
|
33
|
+
resolveDiffBase,
|
|
34
|
+
runGitCommand
|
|
35
|
+
} from "./chunk-T3YADB2L.js";
|
|
31
36
|
import {
|
|
32
37
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
33
38
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -52,7 +57,7 @@ import {
|
|
|
52
57
|
} from "./chunk-FLDA7BX3.js";
|
|
53
58
|
import {
|
|
54
59
|
publishedPullRequestUrls
|
|
55
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-KQOMWVOJ.js";
|
|
56
61
|
import {
|
|
57
62
|
RELAY_MCP_TOOLS,
|
|
58
63
|
RELAY_MCP_TOOL_NAMES,
|
|
@@ -74,7 +79,7 @@ import {
|
|
|
74
79
|
refreshDelayMs,
|
|
75
80
|
restartCodexAspHost,
|
|
76
81
|
routineRefreshExclusions
|
|
77
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-ET2HBN72.js";
|
|
78
83
|
import {
|
|
79
84
|
ENGINE_ENV,
|
|
80
85
|
monolithRequest,
|
|
@@ -82,14 +87,16 @@ import {
|
|
|
82
87
|
readRuntimeEnvFile,
|
|
83
88
|
reloadEngineEnv,
|
|
84
89
|
setAgentCredentialSnapshot
|
|
85
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-CXSJSSFY.js";
|
|
86
91
|
import {
|
|
87
92
|
AspClient,
|
|
93
|
+
getCodexModelProvider
|
|
94
|
+
} from "./chunk-F3EHVMWY.js";
|
|
95
|
+
import {
|
|
88
96
|
SUBPROCESS_MAX_BUFFER,
|
|
89
97
|
execAsync,
|
|
90
|
-
execFileAsync
|
|
91
|
-
|
|
92
|
-
} from "./chunk-SRGTHBJU.js";
|
|
98
|
+
execFileAsync
|
|
99
|
+
} from "./chunk-E4MPACC3.js";
|
|
93
100
|
import {
|
|
94
101
|
isRecord as isRecord2
|
|
95
102
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -105,6 +112,7 @@ import {
|
|
|
105
112
|
ASTER_PROVIDER,
|
|
106
113
|
AUTH_FALLBACK_EVENT_TYPE,
|
|
107
114
|
AUTH_RETRY_STATUS_EVENT_TYPE,
|
|
115
|
+
CHAT_FORK_EXCERPT_OMITTED_NOTICE,
|
|
108
116
|
CHAT_GOAL_EVENT_TYPE,
|
|
109
117
|
CHAT_INTERRUPTED_EVENT_TYPE,
|
|
110
118
|
CLAUDE_AUTH_ENV_KEYS,
|
|
@@ -230,6 +238,7 @@ import {
|
|
|
230
238
|
fetchOpenCodeGoCatalog,
|
|
231
239
|
forkChatRequestSchema,
|
|
232
240
|
formatChatForkHandoffMessage,
|
|
241
|
+
formatSideChatUpdateMessage,
|
|
233
242
|
getChatExecutionProvider,
|
|
234
243
|
getChatHistoryPageSenders,
|
|
235
244
|
getClaudeModelContextWindow,
|
|
@@ -317,7 +326,7 @@ import {
|
|
|
317
326
|
workspaceCredentialProviderSchema,
|
|
318
327
|
workspaceTokenRequestSchema,
|
|
319
328
|
workspaceTokenResponseSchema
|
|
320
|
-
} from "./chunk-
|
|
329
|
+
} from "./chunk-3LWSEH3N.js";
|
|
321
330
|
import {
|
|
322
331
|
cloneMcpConfig,
|
|
323
332
|
ensureCompatibilityImports,
|
|
@@ -518,7 +527,7 @@ var require_lib = __commonJS({
|
|
|
518
527
|
"../node_modules/.bun/which@5.0.0/node_modules/which/lib/index.js"(exports, module) {
|
|
519
528
|
"use strict";
|
|
520
529
|
var { isexe, sync: isexeSync } = require_index_min();
|
|
521
|
-
var { join:
|
|
530
|
+
var { join: join39, delimiter: delimiter3, sep: sep2, posix } = __require("path");
|
|
522
531
|
var isWindows = process.platform === "win32";
|
|
523
532
|
var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
|
|
524
533
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -547,7 +556,7 @@ var require_lib = __commonJS({
|
|
|
547
556
|
var getPathPart = (raw, cmd) => {
|
|
548
557
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
549
558
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
550
|
-
return prefix +
|
|
559
|
+
return prefix + join39(pathPart, cmd);
|
|
551
560
|
};
|
|
552
561
|
var which = async (cmd, opt = {}) => {
|
|
553
562
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -3826,7 +3835,7 @@ var require_compile2 = __commonJS({
|
|
|
3826
3835
|
const schOrFunc = root.refs[ref];
|
|
3827
3836
|
if (schOrFunc)
|
|
3828
3837
|
return schOrFunc;
|
|
3829
|
-
let _sch =
|
|
3838
|
+
let _sch = resolve7.call(this, root, ref);
|
|
3830
3839
|
if (_sch === void 0) {
|
|
3831
3840
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
3832
3841
|
const { schemaId } = this.opts;
|
|
@@ -3853,7 +3862,7 @@ var require_compile2 = __commonJS({
|
|
|
3853
3862
|
function sameSchemaEnv(s1, s2) {
|
|
3854
3863
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3855
3864
|
}
|
|
3856
|
-
function
|
|
3865
|
+
function resolve7(root, ref) {
|
|
3857
3866
|
let sch;
|
|
3858
3867
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3859
3868
|
ref = sch;
|
|
@@ -4484,7 +4493,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
4484
4493
|
}
|
|
4485
4494
|
return uri;
|
|
4486
4495
|
}
|
|
4487
|
-
function
|
|
4496
|
+
function resolve7(baseURI, relativeURI, options) {
|
|
4488
4497
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
4489
4498
|
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
4490
4499
|
schemelessOptions.skipEscape = true;
|
|
@@ -4742,7 +4751,7 @@ var require_fast_uri2 = __commonJS({
|
|
|
4742
4751
|
var fastUri = {
|
|
4743
4752
|
SCHEMES,
|
|
4744
4753
|
normalize,
|
|
4745
|
-
resolve:
|
|
4754
|
+
resolve: resolve7,
|
|
4746
4755
|
resolveComponent,
|
|
4747
4756
|
equal,
|
|
4748
4757
|
serialize,
|
|
@@ -8639,7 +8648,7 @@ function removeCredentialFileLines(filePath, shouldRemove) {
|
|
|
8639
8648
|
// src/git/service.ts
|
|
8640
8649
|
import { readdir, readFile as readFile3, stat } from "fs/promises";
|
|
8641
8650
|
import { spawn } from "child_process";
|
|
8642
|
-
import { join as
|
|
8651
|
+
import { join as join3 } from "path";
|
|
8643
8652
|
|
|
8644
8653
|
// src/utils/state.ts
|
|
8645
8654
|
import { readFile as readFile2, mkdir as mkdir2 } from "fs/promises";
|
|
@@ -8747,74 +8756,6 @@ async function saveRepoState(repoName, state, fallbackState) {
|
|
|
8747
8756
|
return updated.repos[repoName];
|
|
8748
8757
|
}
|
|
8749
8758
|
|
|
8750
|
-
// src/git/commands.ts
|
|
8751
|
-
import { readdirSync, readFileSync, statSync } from "fs";
|
|
8752
|
-
import { join as join3, resolve } from "path";
|
|
8753
|
-
async function runGitCommand(args, cwd, options = {}) {
|
|
8754
|
-
const { stdout } = await execFileAsync("git", args, {
|
|
8755
|
-
cwd,
|
|
8756
|
-
encoding: "utf-8",
|
|
8757
|
-
maxBuffer: options.maxBuffer ?? SUBPROCESS_MAX_BUFFER
|
|
8758
|
-
});
|
|
8759
|
-
return stdout.trim();
|
|
8760
|
-
}
|
|
8761
|
-
function readRepoHeadBranches(repoPath) {
|
|
8762
|
-
const branches = /* @__PURE__ */ new Set();
|
|
8763
|
-
try {
|
|
8764
|
-
let gitDir = join3(repoPath, ".git");
|
|
8765
|
-
if (statSync(gitDir).isFile()) {
|
|
8766
|
-
const target = readFileSync(gitDir, "utf8").trim().match(/^gitdir: (.+)$/)?.[1];
|
|
8767
|
-
if (!target) return branches;
|
|
8768
|
-
gitDir = resolve(repoPath, target);
|
|
8769
|
-
}
|
|
8770
|
-
let commonDir = gitDir;
|
|
8771
|
-
try {
|
|
8772
|
-
commonDir = resolve(gitDir, readFileSync(join3(gitDir, "commondir"), "utf8").trim());
|
|
8773
|
-
} catch {
|
|
8774
|
-
}
|
|
8775
|
-
const headDirs = /* @__PURE__ */ new Set([gitDir, commonDir]);
|
|
8776
|
-
try {
|
|
8777
|
-
for (const entry of readdirSync(join3(commonDir, "worktrees"))) {
|
|
8778
|
-
headDirs.add(join3(commonDir, "worktrees", entry));
|
|
8779
|
-
}
|
|
8780
|
-
} catch {
|
|
8781
|
-
}
|
|
8782
|
-
for (const dir of headDirs) {
|
|
8783
|
-
try {
|
|
8784
|
-
const branch = readFileSync(join3(dir, "HEAD"), "utf8").trim().match(/^ref:\s+refs\/heads\/(.+)$/)?.[1];
|
|
8785
|
-
if (branch) branches.add(branch);
|
|
8786
|
-
} catch {
|
|
8787
|
-
}
|
|
8788
|
-
}
|
|
8789
|
-
} catch {
|
|
8790
|
-
}
|
|
8791
|
-
return branches;
|
|
8792
|
-
}
|
|
8793
|
-
async function branchExists(branchName, cwd) {
|
|
8794
|
-
try {
|
|
8795
|
-
await runGitCommand(["rev-parse", "--verify", branchName], cwd);
|
|
8796
|
-
return true;
|
|
8797
|
-
} catch {
|
|
8798
|
-
return false;
|
|
8799
|
-
}
|
|
8800
|
-
}
|
|
8801
|
-
async function getCurrentBranch(cwd) {
|
|
8802
|
-
try {
|
|
8803
|
-
return await runGitCommand(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
8804
|
-
} catch (error) {
|
|
8805
|
-
console.error("Error getting current branch:", error);
|
|
8806
|
-
return null;
|
|
8807
|
-
}
|
|
8808
|
-
}
|
|
8809
|
-
async function resolveDiffBase(repoPath, defaultBranch) {
|
|
8810
|
-
const baseBranch = `origin/${defaultBranch}`;
|
|
8811
|
-
try {
|
|
8812
|
-
return await runGitCommand(["merge-base", baseBranch, "HEAD"], repoPath);
|
|
8813
|
-
} catch {
|
|
8814
|
-
}
|
|
8815
|
-
return await branchExists(baseBranch, repoPath) ? baseBranch : "HEAD";
|
|
8816
|
-
}
|
|
8817
|
-
|
|
8818
8759
|
// src/git/service.ts
|
|
8819
8760
|
var FULL_DIFF_MAX_BUFFER = 50 * 1024 * 1024;
|
|
8820
8761
|
var MAX_DIFF_FILE_BYTES = 1024 * 1024;
|
|
@@ -8849,13 +8790,13 @@ var GitService = class {
|
|
|
8849
8790
|
const repos = [];
|
|
8850
8791
|
let complete2 = true;
|
|
8851
8792
|
for (const entry of entries) {
|
|
8852
|
-
const fullPath =
|
|
8793
|
+
const fullPath = join3(root, entry);
|
|
8853
8794
|
try {
|
|
8854
8795
|
const entryStat = await stat(fullPath);
|
|
8855
8796
|
if (!entryStat.isDirectory()) {
|
|
8856
8797
|
continue;
|
|
8857
8798
|
}
|
|
8858
|
-
const hasGit = Boolean(await this.safeStat(
|
|
8799
|
+
const hasGit = Boolean(await this.safeStat(join3(fullPath, ".git")));
|
|
8859
8800
|
if (!hasGit) {
|
|
8860
8801
|
continue;
|
|
8861
8802
|
}
|
|
@@ -9009,7 +8950,7 @@ var GitService = class {
|
|
|
9009
8950
|
for (let i = 0; i < paths.length; i += UNTRACKED_STAT_CONCURRENCY) {
|
|
9010
8951
|
const batch = await Promise.all(paths.slice(i, i + UNTRACKED_STAT_CONCURRENCY).map(async (path7) => {
|
|
9011
8952
|
try {
|
|
9012
|
-
return { path: path7, size: (await stat(
|
|
8953
|
+
return { path: path7, size: (await stat(join3(repoPath, path7))).size };
|
|
9013
8954
|
} catch {
|
|
9014
8955
|
return null;
|
|
9015
8956
|
}
|
|
@@ -9051,7 +8992,7 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
|
|
|
9051
8992
|
}
|
|
9052
8993
|
}
|
|
9053
8994
|
readUntrackedDiff(repoPath, paths) {
|
|
9054
|
-
return new Promise((
|
|
8995
|
+
return new Promise((resolve7) => {
|
|
9055
8996
|
const child = spawn("git", ["diff", "--", ...paths], {
|
|
9056
8997
|
cwd: repoPath,
|
|
9057
8998
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -9072,12 +9013,12 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
|
|
|
9072
9013
|
});
|
|
9073
9014
|
child.stderr.on("data", () => {
|
|
9074
9015
|
});
|
|
9075
|
-
child.on("error", () =>
|
|
9016
|
+
child.on("error", () => resolve7(""));
|
|
9076
9017
|
child.on("close", (code) => {
|
|
9077
9018
|
if (code === 0 || code === 1 || truncated) {
|
|
9078
|
-
|
|
9019
|
+
resolve7(Buffer.concat(chunks).toString("utf-8"));
|
|
9079
9020
|
} else {
|
|
9080
|
-
|
|
9021
|
+
resolve7("");
|
|
9081
9022
|
}
|
|
9082
9023
|
});
|
|
9083
9024
|
});
|
|
@@ -9089,7 +9030,7 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
|
|
|
9089
9030
|
for (const { path: path7, tooLarge } of files) {
|
|
9090
9031
|
if (tooLarge) continue;
|
|
9091
9032
|
try {
|
|
9092
|
-
const contents = await readFile3(
|
|
9033
|
+
const contents = await readFile3(join3(repoPath, path7));
|
|
9093
9034
|
if (contents.length === 0 || contents.includes(0)) {
|
|
9094
9035
|
continue;
|
|
9095
9036
|
}
|
|
@@ -9277,7 +9218,7 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
|
|
|
9277
9218
|
}
|
|
9278
9219
|
async getGitLabAccessToken(host) {
|
|
9279
9220
|
try {
|
|
9280
|
-
const credentials = await readFile3(
|
|
9221
|
+
const credentials = await readFile3(join3(ENGINE_ENV.HOME_DIR, ".git-credentials"), "utf-8");
|
|
9281
9222
|
for (const line of credentials.split("\n")) {
|
|
9282
9223
|
const trimmed = line.trim();
|
|
9283
9224
|
if (!trimmed) continue;
|
|
@@ -9298,22 +9239,13 @@ Binary files /dev/null and ${quote(`b/${path7}`)} differ
|
|
|
9298
9239
|
if (cached) {
|
|
9299
9240
|
return cached;
|
|
9300
9241
|
}
|
|
9301
|
-
const fromSymbolicRef = await
|
|
9242
|
+
const fromSymbolicRef = await getOriginDefaultBranch(repoPath);
|
|
9302
9243
|
if (fromSymbolicRef) {
|
|
9303
9244
|
this.defaultBranchCache.set(repoPath, fromSymbolicRef);
|
|
9304
9245
|
return fromSymbolicRef;
|
|
9305
9246
|
}
|
|
9306
9247
|
return "main";
|
|
9307
9248
|
}
|
|
9308
|
-
async resolveDefaultBranchFromSymbolicRef(repoPath) {
|
|
9309
|
-
try {
|
|
9310
|
-
const output = await runGitCommand(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], repoPath);
|
|
9311
|
-
const match = output.match(/^origin\/(.+)$/);
|
|
9312
|
-
return match ? match[1] : null;
|
|
9313
|
-
} catch {
|
|
9314
|
-
return null;
|
|
9315
|
-
}
|
|
9316
|
-
}
|
|
9317
9249
|
async refreshRepoMetadata(repo, currentBranch, startHooksCompleted, persistedState, observedBranches, includeDiffs = false) {
|
|
9318
9250
|
const notFound = { status: "not_found" };
|
|
9319
9251
|
const prResult = currentBranch === repo.defaultBranch ? notFound : await this.getPullRequestUrl(repo.name, repo.path, currentBranch, persistedState);
|
|
@@ -9741,7 +9673,7 @@ function resolveIdentityRoute(requestUrl) {
|
|
|
9741
9673
|
return { target, audience: decode(encodedAudience) };
|
|
9742
9674
|
}
|
|
9743
9675
|
function readJsonBody(request) {
|
|
9744
|
-
return new Promise((
|
|
9676
|
+
return new Promise((resolve7) => {
|
|
9745
9677
|
const chunks = [];
|
|
9746
9678
|
let size = 0;
|
|
9747
9679
|
request.on("data", (chunk) => {
|
|
@@ -9749,15 +9681,15 @@ function readJsonBody(request) {
|
|
|
9749
9681
|
if (size <= MAX_TOKEN_REQUEST_BYTES) chunks.push(chunk);
|
|
9750
9682
|
});
|
|
9751
9683
|
request.on("end", () => {
|
|
9752
|
-
if (size > MAX_TOKEN_REQUEST_BYTES) return
|
|
9684
|
+
if (size > MAX_TOKEN_REQUEST_BYTES) return resolve7(null);
|
|
9753
9685
|
const text = Buffer.concat(chunks).toString("utf8").trim();
|
|
9754
9686
|
try {
|
|
9755
|
-
|
|
9687
|
+
resolve7(text ? JSON.parse(text) : {});
|
|
9756
9688
|
} catch {
|
|
9757
|
-
|
|
9689
|
+
resolve7(null);
|
|
9758
9690
|
}
|
|
9759
9691
|
});
|
|
9760
|
-
request.on("error", () =>
|
|
9692
|
+
request.on("error", () => resolve7(null));
|
|
9761
9693
|
});
|
|
9762
9694
|
}
|
|
9763
9695
|
function createIdentityProxy(tokens) {
|
|
@@ -9812,7 +9744,7 @@ function createIdentityProxy(tokens) {
|
|
|
9812
9744
|
}
|
|
9813
9745
|
|
|
9814
9746
|
// src/lifecycle.ts
|
|
9815
|
-
import { readFileSync
|
|
9747
|
+
import { readFileSync, rmSync, writeFileSync } from "fs";
|
|
9816
9748
|
var CLAIM_FILE = "/tmp/replicas-engine.claim";
|
|
9817
9749
|
var EngineLifecycle = class {
|
|
9818
9750
|
state = "parked";
|
|
@@ -9825,7 +9757,7 @@ var EngineLifecycle = class {
|
|
|
9825
9757
|
/** The workspace an earlier run of this engine activated for and never slept. */
|
|
9826
9758
|
get claimedWorkspaceId() {
|
|
9827
9759
|
try {
|
|
9828
|
-
return
|
|
9760
|
+
return readFileSync(CLAIM_FILE, "utf-8").trim() || null;
|
|
9829
9761
|
} catch {
|
|
9830
9762
|
return null;
|
|
9831
9763
|
}
|
|
@@ -9845,11 +9777,11 @@ var EngineLifecycle = class {
|
|
|
9845
9777
|
}
|
|
9846
9778
|
waitForActive(timeoutMs) {
|
|
9847
9779
|
if (this.active) return Promise.resolve();
|
|
9848
|
-
return new Promise((
|
|
9849
|
-
const timer = setTimeout(
|
|
9780
|
+
return new Promise((resolve7) => {
|
|
9781
|
+
const timer = setTimeout(resolve7, timeoutMs);
|
|
9850
9782
|
this.activeWaiters.push(() => {
|
|
9851
9783
|
clearTimeout(timer);
|
|
9852
|
-
|
|
9784
|
+
resolve7();
|
|
9853
9785
|
});
|
|
9854
9786
|
});
|
|
9855
9787
|
}
|
|
@@ -9865,7 +9797,7 @@ var lifecycle = new EngineLifecycle();
|
|
|
9865
9797
|
// src/utils/logger.ts
|
|
9866
9798
|
import { mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
|
|
9867
9799
|
import { homedir as homedir2 } from "os";
|
|
9868
|
-
import { join as
|
|
9800
|
+
import { join as join4 } from "path";
|
|
9869
9801
|
import { format } from "util";
|
|
9870
9802
|
import { randomBytes } from "crypto";
|
|
9871
9803
|
|
|
@@ -9900,9 +9832,9 @@ var StreamWriter = class {
|
|
|
9900
9832
|
return true;
|
|
9901
9833
|
}
|
|
9902
9834
|
flush(signal) {
|
|
9903
|
-
return new Promise((
|
|
9835
|
+
return new Promise((resolve7, reject) => {
|
|
9904
9836
|
if (!this.stream) {
|
|
9905
|
-
|
|
9837
|
+
resolve7();
|
|
9906
9838
|
return;
|
|
9907
9839
|
}
|
|
9908
9840
|
if (this.flushTimer) {
|
|
@@ -9919,7 +9851,7 @@ var StreamWriter = class {
|
|
|
9919
9851
|
s.write("", (error) => {
|
|
9920
9852
|
signal?.removeEventListener("abort", onAbort);
|
|
9921
9853
|
if (error) reject(error);
|
|
9922
|
-
else
|
|
9854
|
+
else resolve7();
|
|
9923
9855
|
});
|
|
9924
9856
|
});
|
|
9925
9857
|
}
|
|
@@ -9940,7 +9872,7 @@ var StreamWriter = class {
|
|
|
9940
9872
|
};
|
|
9941
9873
|
|
|
9942
9874
|
// src/utils/logger.ts
|
|
9943
|
-
var LOG_DIR =
|
|
9875
|
+
var LOG_DIR = join4(homedir2(), ".replicas", "logs");
|
|
9944
9876
|
var EngineLogger = class {
|
|
9945
9877
|
_sessionId = null;
|
|
9946
9878
|
patched = false;
|
|
@@ -9951,7 +9883,7 @@ var EngineLogger = class {
|
|
|
9951
9883
|
async initialize() {
|
|
9952
9884
|
await mkdir3(LOG_DIR, { recursive: true });
|
|
9953
9885
|
this._sessionId = this.createSessionId();
|
|
9954
|
-
const logPath =
|
|
9886
|
+
const logPath = join4(LOG_DIR, `${this._sessionId}.log`);
|
|
9955
9887
|
await writeFile2(logPath, `=== Replicas Engine Session ${this._sessionId} ===
|
|
9956
9888
|
`, "utf-8");
|
|
9957
9889
|
this.writer.open(logPath);
|
|
@@ -9998,7 +9930,7 @@ var engineLogger = new EngineLogger();
|
|
|
9998
9930
|
// src/services/replicas-config-service.ts
|
|
9999
9931
|
import { readFile as readFile7, appendFile, writeFile as writeFile4, mkdir as mkdir6 } from "fs/promises";
|
|
10000
9932
|
import { existsSync as existsSync4 } from "fs";
|
|
10001
|
-
import { join as
|
|
9933
|
+
import { join as join9 } from "path";
|
|
10002
9934
|
import { homedir as homedir7 } from "os";
|
|
10003
9935
|
import { spawn as spawn2 } from "child_process";
|
|
10004
9936
|
|
|
@@ -10006,20 +9938,20 @@ import { spawn as spawn2 } from "child_process";
|
|
|
10006
9938
|
import { mkdir as mkdir4, readFile as readFile5 } from "fs/promises";
|
|
10007
9939
|
import { existsSync as existsSync3 } from "fs";
|
|
10008
9940
|
import { homedir as homedir5 } from "os";
|
|
10009
|
-
import { join as
|
|
9941
|
+
import { join as join7 } from "path";
|
|
10010
9942
|
|
|
10011
9943
|
// src/managers/agent-auth-detection.ts
|
|
10012
9944
|
import { existsSync as existsSync2 } from "fs";
|
|
10013
9945
|
import { homedir as homedir4 } from "os";
|
|
10014
|
-
import { join as
|
|
9946
|
+
import { join as join6 } from "path";
|
|
10015
9947
|
|
|
10016
9948
|
// src/managers/agent-auth-paths.ts
|
|
10017
9949
|
import { homedir as homedir3 } from "os";
|
|
10018
|
-
import { join as
|
|
10019
|
-
var OPENCODE_AUTH_PATH =
|
|
10020
|
-
var PI_AUTH_PATH =
|
|
10021
|
-
var PI_MCP_CONFIG_PATH =
|
|
10022
|
-
var MUSE_AUTH_PATH =
|
|
9950
|
+
import { join as join5 } from "path";
|
|
9951
|
+
var OPENCODE_AUTH_PATH = join5(homedir3(), ".local", "share", "opencode", "auth.json");
|
|
9952
|
+
var PI_AUTH_PATH = join5(homedir3(), ".pi", "agent", "auth.json");
|
|
9953
|
+
var PI_MCP_CONFIG_PATH = join5(homedir3(), ".pi", "agent", "mcp.json");
|
|
9954
|
+
var MUSE_AUTH_PATH = join5(homedir3(), ".config", "muse", "auth.json");
|
|
10023
9955
|
|
|
10024
9956
|
// src/managers/codex-auth.ts
|
|
10025
9957
|
function detectCodexAuthMethod() {
|
|
@@ -10027,7 +9959,7 @@ function detectCodexAuthMethod() {
|
|
|
10027
9959
|
}
|
|
10028
9960
|
|
|
10029
9961
|
// src/managers/agent-auth-detection.ts
|
|
10030
|
-
var CLAUDE_CREDENTIALS_PATH =
|
|
9962
|
+
var CLAUDE_CREDENTIALS_PATH = join6(homedir4(), ".claude", ".credentials.json");
|
|
10031
9963
|
function detectClaudeAuthMethod() {
|
|
10032
9964
|
if (ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "ollama") return "ollama";
|
|
10033
9965
|
if (existsSync2(CLAUDE_CREDENTIALS_PATH)) {
|
|
@@ -10093,10 +10025,10 @@ async function getPiProviderCredentials() {
|
|
|
10093
10025
|
}
|
|
10094
10026
|
|
|
10095
10027
|
// src/services/environment-details-service.ts
|
|
10096
|
-
var REPLICAS_DIR =
|
|
10097
|
-
var DETAILS_FILE =
|
|
10098
|
-
var GH_HOSTS_PATH =
|
|
10099
|
-
var GIT_CREDENTIALS_PATH =
|
|
10028
|
+
var REPLICAS_DIR = join7(homedir5(), ".replicas");
|
|
10029
|
+
var DETAILS_FILE = join7(REPLICAS_DIR, "environment-details.json");
|
|
10030
|
+
var GH_HOSTS_PATH = join7(homedir5(), ".config", "gh", "hosts.yml");
|
|
10031
|
+
var GIT_CREDENTIALS_PATH = join7(homedir5(), ".git-credentials");
|
|
10100
10032
|
async function detectGitIdentityConfigured() {
|
|
10101
10033
|
try {
|
|
10102
10034
|
const { stdout } = await execFileAsync("git", ["config", "--global", "user.name"]);
|
|
@@ -10194,6 +10126,7 @@ var EnvironmentDetailsService = class {
|
|
|
10194
10126
|
details.supportsChatForking = true;
|
|
10195
10127
|
details.supportsChatForkMessage = true;
|
|
10196
10128
|
details.supportsDeferredChatForking = true;
|
|
10129
|
+
details.supportsSideChats = true;
|
|
10197
10130
|
details.supportsCredentialSwitching = true;
|
|
10198
10131
|
details.supportsChatCredentials = true;
|
|
10199
10132
|
details.agentCredentials = { ...ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS };
|
|
@@ -10286,7 +10219,7 @@ var environmentDetailsService = new EnvironmentDetailsService();
|
|
|
10286
10219
|
// src/services/start-hook-logs-service.ts
|
|
10287
10220
|
import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile3, readdir as readdir2 } from "fs/promises";
|
|
10288
10221
|
import { homedir as homedir6 } from "os";
|
|
10289
|
-
import { join as
|
|
10222
|
+
import { join as join8 } from "path";
|
|
10290
10223
|
|
|
10291
10224
|
// src/services/hook-log-files.ts
|
|
10292
10225
|
import { createHash } from "crypto";
|
|
@@ -10298,7 +10231,7 @@ function repoHookLogFilename(repoName) {
|
|
|
10298
10231
|
}
|
|
10299
10232
|
|
|
10300
10233
|
// src/services/start-hook-logs-service.ts
|
|
10301
|
-
var LOGS_DIR =
|
|
10234
|
+
var LOGS_DIR = join8(homedir6(), ".replicas", "start-hook-logs");
|
|
10302
10235
|
function withPreview(stored) {
|
|
10303
10236
|
const preview = buildHookOutputPreview(stored.output);
|
|
10304
10237
|
return { ...stored, ...preview };
|
|
@@ -10336,7 +10269,7 @@ var StartHookLogsService = class {
|
|
|
10336
10269
|
await this.ensureDir();
|
|
10337
10270
|
const log = { hookType, hookName, repoName: hookName, ...entry };
|
|
10338
10271
|
const filename = hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
10339
|
-
await writeFile3(
|
|
10272
|
+
await writeFile3(join8(LOGS_DIR, filename), `${JSON.stringify(log, null, 2)}
|
|
10340
10273
|
`, "utf-8");
|
|
10341
10274
|
}
|
|
10342
10275
|
async saveEnvironmentLog(entry) {
|
|
@@ -10361,7 +10294,7 @@ var StartHookLogsService = class {
|
|
|
10361
10294
|
continue;
|
|
10362
10295
|
}
|
|
10363
10296
|
try {
|
|
10364
|
-
const raw = await readFile6(
|
|
10297
|
+
const raw = await readFile6(join8(LOGS_DIR, file), "utf-8");
|
|
10365
10298
|
const stored = normalizeStored(JSON.parse(raw));
|
|
10366
10299
|
if (stored) {
|
|
10367
10300
|
logs.push(withPreview(stored));
|
|
@@ -10380,7 +10313,7 @@ var StartHookLogsService = class {
|
|
|
10380
10313
|
async getFullOutput(hookType, hookName) {
|
|
10381
10314
|
const filename = hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
10382
10315
|
try {
|
|
10383
|
-
const raw = await readFile6(
|
|
10316
|
+
const raw = await readFile6(join8(LOGS_DIR, filename), "utf-8");
|
|
10384
10317
|
const stored = normalizeStored(JSON.parse(raw));
|
|
10385
10318
|
if (!stored || stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
10386
10319
|
return null;
|
|
@@ -10397,7 +10330,7 @@ var StartHookLogsService = class {
|
|
|
10397
10330
|
var startHookLogsService = new StartHookLogsService();
|
|
10398
10331
|
|
|
10399
10332
|
// src/services/replicas-config-service.ts
|
|
10400
|
-
var START_HOOKS_LOG =
|
|
10333
|
+
var START_HOOKS_LOG = join9(homedir7(), ".replicas", "startHooks.log");
|
|
10401
10334
|
var START_HOOKS_RUNNING_PROMPT = `IMPORTANT - Start Hooks Running:
|
|
10402
10335
|
Start hooks are shell commands/scripts set by repository owners that run on workspace startup.
|
|
10403
10336
|
These hooks are currently executing in the background. You can:
|
|
@@ -10408,7 +10341,7 @@ The start hooks may install dependencies, build projects, or perform other setup
|
|
|
10408
10341
|
If your task depends on setup being complete, check the log file before proceeding.`;
|
|
10409
10342
|
async function readReplicasConfigFromDir(dirPath) {
|
|
10410
10343
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
10411
|
-
const configPath =
|
|
10344
|
+
const configPath = join9(dirPath, filename);
|
|
10412
10345
|
if (!existsSync4(configPath)) {
|
|
10413
10346
|
continue;
|
|
10414
10347
|
}
|
|
@@ -10457,7 +10390,7 @@ var ReplicasConfigService = class {
|
|
|
10457
10390
|
});
|
|
10458
10391
|
if (signal("SIGTERM").length === 0) return;
|
|
10459
10392
|
const deadline = Date.now() + 5e3;
|
|
10460
|
-
while (signal(0).length > 0 && Date.now() < deadline) await new Promise((
|
|
10393
|
+
while (signal(0).length > 0 && Date.now() < deadline) await new Promise((resolve7) => setTimeout(resolve7, 25));
|
|
10461
10394
|
signal("SIGKILL");
|
|
10462
10395
|
}
|
|
10463
10396
|
/**
|
|
@@ -10497,7 +10430,7 @@ var ReplicasConfigService = class {
|
|
|
10497
10430
|
const logLine = `[${timestamp}] ${message}
|
|
10498
10431
|
`;
|
|
10499
10432
|
try {
|
|
10500
|
-
await mkdir6(
|
|
10433
|
+
await mkdir6(join9(homedir7(), ".replicas"), { recursive: true });
|
|
10501
10434
|
await appendFile(START_HOOKS_LOG, logLine, "utf-8");
|
|
10502
10435
|
} catch (error) {
|
|
10503
10436
|
console.error("Failed to write to start hooks log:", error);
|
|
@@ -10533,7 +10466,7 @@ var ReplicasConfigService = class {
|
|
|
10533
10466
|
await this.logToFile(`[${params.repoName}] --- Running: ${params.label} ---`);
|
|
10534
10467
|
emit(`$ ${params.label}
|
|
10535
10468
|
`);
|
|
10536
|
-
return new Promise((
|
|
10469
|
+
return new Promise((resolve7) => {
|
|
10537
10470
|
const proc = spawn2("bash", ["-lc", params.command], {
|
|
10538
10471
|
cwd: params.cwd,
|
|
10539
10472
|
env: process.env,
|
|
@@ -10546,7 +10479,7 @@ var ReplicasConfigService = class {
|
|
|
10546
10479
|
const finish = (result) => {
|
|
10547
10480
|
if (settled) return;
|
|
10548
10481
|
settled = true;
|
|
10549
|
-
|
|
10482
|
+
resolve7(result);
|
|
10550
10483
|
};
|
|
10551
10484
|
const timer = setTimeout(() => {
|
|
10552
10485
|
timedOut = true;
|
|
@@ -10635,7 +10568,7 @@ var ReplicasConfigService = class {
|
|
|
10635
10568
|
this.hooksCompleted = false;
|
|
10636
10569
|
this.hooksFailed = false;
|
|
10637
10570
|
try {
|
|
10638
|
-
await mkdir6(
|
|
10571
|
+
await mkdir6(join9(homedir7(), ".replicas"), { recursive: true });
|
|
10639
10572
|
await writeFile4(
|
|
10640
10573
|
START_HOOKS_LOG,
|
|
10641
10574
|
`=== Start Hooks Execution Log ===
|
|
@@ -10832,10 +10765,10 @@ var replicasConfigService = new ReplicasConfigService();
|
|
|
10832
10765
|
// src/services/event-service.ts
|
|
10833
10766
|
import { mkdir as mkdir7 } from "fs/promises";
|
|
10834
10767
|
import { homedir as homedir8 } from "os";
|
|
10835
|
-
import { join as
|
|
10768
|
+
import { join as join10 } from "path";
|
|
10836
10769
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
10837
|
-
var ENGINE_DIR =
|
|
10838
|
-
var EVENTS_FILE =
|
|
10770
|
+
var ENGINE_DIR = join10(homedir8(), ".replicas", "engine");
|
|
10771
|
+
var EVENTS_FILE = join10(ENGINE_DIR, "events.jsonl");
|
|
10839
10772
|
var EventService = class {
|
|
10840
10773
|
subscribers = /* @__PURE__ */ new Map();
|
|
10841
10774
|
writer = new StreamWriter();
|
|
@@ -10870,8 +10803,8 @@ import { mkdir as mkdir8, readFile as readFile8 } from "fs/promises";
|
|
|
10870
10803
|
import { existsSync as existsSync5 } from "fs";
|
|
10871
10804
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
10872
10805
|
import { homedir as homedir9 } from "os";
|
|
10873
|
-
import { dirname as dirname2, join as
|
|
10874
|
-
var PREVIEW_PORTS_FILE =
|
|
10806
|
+
import { dirname as dirname2, join as join11 } from "path";
|
|
10807
|
+
var PREVIEW_PORTS_FILE = join11(homedir9(), ".replicas", "preview-ports.json");
|
|
10875
10808
|
async function readPreviewsFile() {
|
|
10876
10809
|
try {
|
|
10877
10810
|
if (!existsSync5(PREVIEW_PORTS_FILE)) {
|
|
@@ -10986,11 +10919,11 @@ async function registerDesktopPreview(signal) {
|
|
|
10986
10919
|
|
|
10987
10920
|
// src/services/chat/chat-service.ts
|
|
10988
10921
|
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir20, readFile as readFile19, rename as rename4, rm as rm4 } from "fs/promises";
|
|
10989
|
-
import { join as
|
|
10922
|
+
import { join as join34 } from "path";
|
|
10990
10923
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
10991
10924
|
|
|
10992
10925
|
// ../shared/src/workspace-chat.ts
|
|
10993
|
-
var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION =
|
|
10926
|
+
var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION = 8;
|
|
10994
10927
|
var WORKSPACE_CHATS_QUERY_ROOT = `workspace-chats:v${WORKSPACE_CHATS_QUERY_SCHEMA_VERSION}`;
|
|
10995
10928
|
function isAcceptedUserMessage(event) {
|
|
10996
10929
|
return getUserMessage(event) !== null && event.payload.source === ACCEPTED_USER_MESSAGE_SOURCE;
|
|
@@ -11163,7 +11096,7 @@ import {
|
|
|
11163
11096
|
query
|
|
11164
11097
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
11165
11098
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
11166
|
-
import { dirname as dirname4, join as
|
|
11099
|
+
import { dirname as dirname4, join as join15 } from "path";
|
|
11167
11100
|
import { mkdir as mkdir10, readdir as readdir4, readFile as readFile10 } from "fs/promises";
|
|
11168
11101
|
import { homedir as homedir11 } from "os";
|
|
11169
11102
|
|
|
@@ -11551,7 +11484,7 @@ function extractPlanFromCodexAspNotification(notification) {
|
|
|
11551
11484
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
11552
11485
|
import { mkdir as mkdir9, unlink as unlink2, writeFile as writeFile5 } from "fs/promises";
|
|
11553
11486
|
import { homedir as homedir10 } from "os";
|
|
11554
|
-
import { join as
|
|
11487
|
+
import { join as join12 } from "path";
|
|
11555
11488
|
function isImageMediaType(value) {
|
|
11556
11489
|
return IMAGE_MEDIA_TYPES.includes(value);
|
|
11557
11490
|
}
|
|
@@ -11616,14 +11549,14 @@ async function normalizeImages(images) {
|
|
|
11616
11549
|
}
|
|
11617
11550
|
return normalized;
|
|
11618
11551
|
}
|
|
11619
|
-
async function saveNormalizedImagesToTempFiles(images, tempImageDir =
|
|
11552
|
+
async function saveNormalizedImagesToTempFiles(images, tempImageDir = join12(homedir10(), ".replicas", "codex", "temp-images")) {
|
|
11620
11553
|
await mkdir9(tempImageDir, { recursive: true });
|
|
11621
11554
|
const tempPaths = [];
|
|
11622
11555
|
try {
|
|
11623
11556
|
for (const image of images) {
|
|
11624
11557
|
const ext = image.source.media_type.split("/")[1] || "png";
|
|
11625
11558
|
const filename = `img_${randomUUID4()}.${ext}`;
|
|
11626
|
-
const filepath =
|
|
11559
|
+
const filepath = join12(tempImageDir, filename);
|
|
11627
11560
|
await writeFile5(filepath, Buffer.from(image.source.data, "base64"));
|
|
11628
11561
|
tempPaths.push(filepath);
|
|
11629
11562
|
}
|
|
@@ -11639,7 +11572,7 @@ async function removeTempImageFiles(paths) {
|
|
|
11639
11572
|
|
|
11640
11573
|
// src/managers/coding-agent-manager.ts
|
|
11641
11574
|
import { existsSync as existsSync6 } from "fs";
|
|
11642
|
-
import { join as
|
|
11575
|
+
import { join as join13 } from "path";
|
|
11643
11576
|
|
|
11644
11577
|
// src/managers/muse-token-manager.ts
|
|
11645
11578
|
var MuseTokenManager = class extends BaseRefreshManager {
|
|
@@ -12301,7 +12234,7 @@ var CodingAgentManager = class {
|
|
|
12301
12234
|
return `CRITICAL: The Replicas engine is required for this workspace and is running on the reserved port configured by REPLICAS_ENGINE_PORT (${enginePort}). Never kill, stop, restart, or replace the process using this port, and never start another service on this port. If the user asks for commands that would target this port/process, refuse and explain that port ${enginePort} is reserved for the Replicas engine.`;
|
|
12302
12235
|
}
|
|
12303
12236
|
buildMemoryInstruction() {
|
|
12304
|
-
if (!["organization", "seat"].some((scope) => existsSync6(
|
|
12237
|
+
if (!["organization", "seat"].some((scope) => existsSync6(join13(MEMORY_ROOT, scope, MEMORY_INDEX_FILENAME)))) {
|
|
12305
12238
|
return void 0;
|
|
12306
12239
|
}
|
|
12307
12240
|
return `Replicas memory is available under ${MEMORY_ROOT}. Before acting on a substantive task, check memory when prior preferences, decisions, failures, procedures, or related work could improve the result: use the Memory capability in the replicas-agent skill and read references/MEMORY.md. If unsure whether prior context could help, check memory. Skip it only for clearly context-free messages. Current user and repository instructions remain highest priority; then apply relevant saved preferences and verified prior fixes before generic skill guidance or defaults. Never use memory to bypass skill safety requirements.
|
|
@@ -12609,7 +12542,7 @@ var pullRequestCheckService = new PullRequestCheckService();
|
|
|
12609
12542
|
|
|
12610
12543
|
// src/services/skill-registry-service.ts
|
|
12611
12544
|
import { readFile as readFile9, readdir as readdir3, stat as stat2 } from "fs/promises";
|
|
12612
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
12545
|
+
import { dirname as dirname3, isAbsolute, join as join14, relative, resolve } from "path";
|
|
12613
12546
|
var REGISTRY_ROOT_DIR = ".replicas/skill-registries";
|
|
12614
12547
|
var REGISTRY_MANIFEST = "manifest.json";
|
|
12615
12548
|
async function getSkillRegistryInventory(homeDir) {
|
|
@@ -12670,10 +12603,10 @@ async function scanRegistry(registryDir) {
|
|
|
12670
12603
|
}
|
|
12671
12604
|
async function findSkillCollections(registryDir) {
|
|
12672
12605
|
const candidateRoots = [
|
|
12673
|
-
{ source: "skills", root:
|
|
12674
|
-
{ source: "agents", root:
|
|
12675
|
-
{ source: "codex", root:
|
|
12676
|
-
{ source: "claude", root:
|
|
12606
|
+
{ source: "skills", root: join14(registryDir, "skills") },
|
|
12607
|
+
{ source: "agents", root: join14(registryDir, ".agents", "skills") },
|
|
12608
|
+
{ source: "codex", root: join14(registryDir, ".codex", "skills") },
|
|
12609
|
+
{ source: "claude", root: join14(registryDir, ".claude", "skills") }
|
|
12677
12610
|
];
|
|
12678
12611
|
const collections = [];
|
|
12679
12612
|
for (const { source, root } of candidateRoots) {
|
|
@@ -12687,9 +12620,9 @@ async function findSkillCollections(registryDir) {
|
|
|
12687
12620
|
async function findSkillDirsInRoot(root) {
|
|
12688
12621
|
const skillDirs = [];
|
|
12689
12622
|
for (const dirent of await safeReadDir(root)) {
|
|
12690
|
-
const skillDir =
|
|
12623
|
+
const skillDir = join14(root, dirent.name);
|
|
12691
12624
|
if (!await isDirectoryDirent(dirent, skillDir)) continue;
|
|
12692
|
-
if (await fileExists(
|
|
12625
|
+
if (await fileExists(join14(skillDir, "SKILL.md"))) {
|
|
12693
12626
|
skillDirs.push(skillDir);
|
|
12694
12627
|
}
|
|
12695
12628
|
}
|
|
@@ -12699,9 +12632,9 @@ async function findTopLevelSkills(registryDir) {
|
|
|
12699
12632
|
const skills = [];
|
|
12700
12633
|
for (const dirent of await safeReadDir(registryDir)) {
|
|
12701
12634
|
if (dirent.name.startsWith(".") || dirent.name === "skills" || dirent.name === "plugins") continue;
|
|
12702
|
-
const skillDir =
|
|
12635
|
+
const skillDir = join14(registryDir, dirent.name);
|
|
12703
12636
|
if (!await isDirectoryDirent(dirent, skillDir)) continue;
|
|
12704
|
-
if (await fileExists(
|
|
12637
|
+
if (await fileExists(join14(skillDir, "SKILL.md"))) {
|
|
12705
12638
|
skills.push({ source: "root", skillDir });
|
|
12706
12639
|
}
|
|
12707
12640
|
}
|
|
@@ -12712,10 +12645,10 @@ async function findClaudePluginRoots(registryDir) {
|
|
|
12712
12645
|
async function walk(dir) {
|
|
12713
12646
|
for (const dirent of await safeReadDir(dir)) {
|
|
12714
12647
|
if (dirent.name === ".git") continue;
|
|
12715
|
-
const child =
|
|
12648
|
+
const child = join14(dir, dirent.name);
|
|
12716
12649
|
if (!await isDirectoryDirent(dirent, child)) continue;
|
|
12717
12650
|
if (dirent.name === ".claude-plugin") {
|
|
12718
|
-
if (await fileExists(
|
|
12651
|
+
if (await fileExists(join14(child, "plugin.json"))) {
|
|
12719
12652
|
roots.push(dirname3(child));
|
|
12720
12653
|
}
|
|
12721
12654
|
continue;
|
|
@@ -12727,7 +12660,7 @@ async function findClaudePluginRoots(registryDir) {
|
|
|
12727
12660
|
return uniqueStrings(roots);
|
|
12728
12661
|
}
|
|
12729
12662
|
async function hasCodexMarketplace(registryDir) {
|
|
12730
|
-
return await fileExists(
|
|
12663
|
+
return await fileExists(join14(registryDir, ".agents", "plugins", "marketplace.json")) || await fileExists(join14(registryDir, ".codex", "plugins", "marketplace.json"));
|
|
12731
12664
|
}
|
|
12732
12665
|
async function installCodexRegistryPlugins(client, inventory) {
|
|
12733
12666
|
const cwds = inventory.codexMarketplaceCwds;
|
|
@@ -12769,10 +12702,10 @@ async function readManifest(homeDir) {
|
|
|
12769
12702
|
}
|
|
12770
12703
|
}
|
|
12771
12704
|
function getRegistryRoot(homeDir) {
|
|
12772
|
-
return
|
|
12705
|
+
return join14(homeDir, REGISTRY_ROOT_DIR);
|
|
12773
12706
|
}
|
|
12774
12707
|
function getManifestPath(homeDir) {
|
|
12775
|
-
return
|
|
12708
|
+
return join14(getRegistryRoot(homeDir), REGISTRY_MANIFEST);
|
|
12776
12709
|
}
|
|
12777
12710
|
function emptyInventory(registryRoot) {
|
|
12778
12711
|
return {
|
|
@@ -12832,8 +12765,8 @@ async function fileExists(path7) {
|
|
|
12832
12765
|
}
|
|
12833
12766
|
}
|
|
12834
12767
|
function isPathInside(parentPath, childPath) {
|
|
12835
|
-
const parent =
|
|
12836
|
-
const child =
|
|
12768
|
+
const parent = resolve(parentPath);
|
|
12769
|
+
const child = resolve(childPath);
|
|
12837
12770
|
const childRelativePath = relative(parent, child);
|
|
12838
12771
|
return childRelativePath === "" || !childRelativePath.startsWith("..") && !isAbsolute(childRelativePath);
|
|
12839
12772
|
}
|
|
@@ -13101,8 +13034,8 @@ var PromptStream = class {
|
|
|
13101
13034
|
if (this.closed) {
|
|
13102
13035
|
return Promise.resolve({ value: void 0, done: true });
|
|
13103
13036
|
}
|
|
13104
|
-
return new Promise((
|
|
13105
|
-
this.waiters.push(
|
|
13037
|
+
return new Promise((resolve7) => {
|
|
13038
|
+
this.waiters.push(resolve7);
|
|
13106
13039
|
});
|
|
13107
13040
|
}
|
|
13108
13041
|
};
|
|
@@ -13350,7 +13283,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13350
13283
|
this.chatId = options.chatId;
|
|
13351
13284
|
this.onChatCredential = options.onChatCredential ?? (() => {
|
|
13352
13285
|
});
|
|
13353
|
-
this.historyFilePath = options.historyFilePath ??
|
|
13286
|
+
this.historyFilePath = options.historyFilePath ?? join15(homedir11(), ".replicas", "claude", "history.jsonl");
|
|
13354
13287
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
13355
13288
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
13356
13289
|
}
|
|
@@ -13541,14 +13474,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13541
13474
|
const requestId = randomUUID5();
|
|
13542
13475
|
const toolUseId = options.toolUseID;
|
|
13543
13476
|
const { options: requestOptions, questions: requestQuestions } = handler.getRequest(input);
|
|
13544
|
-
const result = await new Promise((
|
|
13477
|
+
const result = await new Promise((resolve7) => {
|
|
13545
13478
|
this.pendingToolInputs.set(requestId, {
|
|
13546
13479
|
requestId,
|
|
13547
13480
|
toolUseId,
|
|
13548
13481
|
toolName,
|
|
13549
13482
|
input,
|
|
13550
13483
|
handler,
|
|
13551
|
-
resolve:
|
|
13484
|
+
resolve: resolve7
|
|
13552
13485
|
});
|
|
13553
13486
|
const onAbort = () => {
|
|
13554
13487
|
const pending = this.pendingToolInputs.get(requestId);
|
|
@@ -13612,7 +13545,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13612
13545
|
const agentId = /^agent-(.+)\.jsonl$/.exec(file)?.[1];
|
|
13613
13546
|
if (!agentId) continue;
|
|
13614
13547
|
const offset = workflow.offsets.get(file) ?? 0;
|
|
13615
|
-
const buffer = await readFile10(
|
|
13548
|
+
const buffer = await readFile10(join15(workflow.dir, file)).catch(() => Buffer.alloc(0));
|
|
13616
13549
|
const end = buffer.lastIndexOf(10);
|
|
13617
13550
|
if (end < offset) continue;
|
|
13618
13551
|
workflow.offsets.set(file, end + 1);
|
|
@@ -13704,7 +13637,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13704
13637
|
error
|
|
13705
13638
|
);
|
|
13706
13639
|
await this.tearDownSession();
|
|
13707
|
-
await new Promise((
|
|
13640
|
+
await new Promise((resolve7) => setTimeout(resolve7, delayMs));
|
|
13708
13641
|
currentRequest = { ...request, message: CLAUDE_MIDTURN_CONTINUE_PROMPT, images: [], goalMode: false };
|
|
13709
13642
|
attempt++;
|
|
13710
13643
|
continue;
|
|
@@ -13717,7 +13650,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13717
13650
|
error
|
|
13718
13651
|
);
|
|
13719
13652
|
await this.tearDownSession();
|
|
13720
|
-
await new Promise((
|
|
13653
|
+
await new Promise((resolve7) => setTimeout(resolve7, delayMs));
|
|
13721
13654
|
attempt++;
|
|
13722
13655
|
continue;
|
|
13723
13656
|
}
|
|
@@ -13872,8 +13805,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13872
13805
|
this.pendingInterrupt = false;
|
|
13873
13806
|
return;
|
|
13874
13807
|
}
|
|
13875
|
-
await new Promise((
|
|
13876
|
-
this.pendingTurn = { resolve:
|
|
13808
|
+
await new Promise((resolve7, reject) => {
|
|
13809
|
+
this.pendingTurn = { resolve: resolve7, reject, sawActivity: false, userMessageUuids: /* @__PURE__ */ new Set([userMessage.uuid]) };
|
|
13877
13810
|
promptStream.push(goalCommand ? { ...userMessage, message: { role: "user", content: `/goal ${goalObjective ?? "clear"}` } } : userMessage);
|
|
13878
13811
|
});
|
|
13879
13812
|
}
|
|
@@ -14663,7 +14596,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14663
14596
|
|
|
14664
14597
|
// src/managers/codex-asp/codex-asp-manager.ts
|
|
14665
14598
|
import { mkdir as mkdir11, writeFile as writeFile6 } from "fs/promises";
|
|
14666
|
-
import { join as
|
|
14599
|
+
import { join as join16 } from "path";
|
|
14667
14600
|
|
|
14668
14601
|
// src/utils/codex-quota.ts
|
|
14669
14602
|
function buildCodexRateLimitsSnapshot(fields) {
|
|
@@ -14727,7 +14660,7 @@ var CodexQuotaStatusTracker = class {
|
|
|
14727
14660
|
};
|
|
14728
14661
|
|
|
14729
14662
|
// src/managers/codex-asp/mappers.ts
|
|
14730
|
-
import { existsSync as existsSync7, readFileSync as
|
|
14663
|
+
import { existsSync as existsSync7, readFileSync as readFileSync2 } from "fs";
|
|
14731
14664
|
var localImageCache = /* @__PURE__ */ new Map();
|
|
14732
14665
|
var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
|
|
14733
14666
|
var THREAD_START_METHOD = "thread/start";
|
|
@@ -14855,7 +14788,7 @@ function userImageForLocalPath(path7) {
|
|
|
14855
14788
|
const image = {
|
|
14856
14789
|
type: "image",
|
|
14857
14790
|
mediaType: inferMediaType(path7),
|
|
14858
|
-
data:
|
|
14791
|
+
data: readFileSync2(path7).toString("base64")
|
|
14859
14792
|
};
|
|
14860
14793
|
if (image.data.length > 0) localImageCache.set(path7, image);
|
|
14861
14794
|
return image;
|
|
@@ -15712,9 +15645,9 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
15712
15645
|
async continueWithNewProvider(host, previous, request, developerInstructions, serviceTier) {
|
|
15713
15646
|
const events = codexTranscriptToEvents(threadToAspTranscript(previous));
|
|
15714
15647
|
const text = canonicalizeChatTranscriptBlocks(events.map((event) => JSON.stringify(event)).join("\n"), "codex", void 0).join("\n\n");
|
|
15715
|
-
const directory =
|
|
15648
|
+
const directory = join16(ENGINE_ENV.HOME_DIR, ".replicas", "codex", "provider-context");
|
|
15716
15649
|
await mkdir11(directory, { recursive: true });
|
|
15717
|
-
const transcriptPath =
|
|
15650
|
+
const transcriptPath = join16(directory, `${previous.id}.md`);
|
|
15718
15651
|
await writeFile6(transcriptPath, text, "utf8");
|
|
15719
15652
|
const response = await host.client.request(
|
|
15720
15653
|
THREAD_START_METHOD,
|
|
@@ -15810,8 +15743,8 @@ ${text.slice(-24e3)}`
|
|
|
15810
15743
|
}
|
|
15811
15744
|
async observeTurn(host, threadId, request, startTurn) {
|
|
15812
15745
|
let resolveCompleted;
|
|
15813
|
-
const completed = new Promise((
|
|
15814
|
-
resolveCompleted =
|
|
15746
|
+
const completed = new Promise((resolve7) => {
|
|
15747
|
+
resolveCompleted = resolve7;
|
|
15815
15748
|
});
|
|
15816
15749
|
let rejectDisposed = () => {
|
|
15817
15750
|
};
|
|
@@ -16341,22 +16274,22 @@ ${text.slice(-24e3)}`
|
|
|
16341
16274
|
|
|
16342
16275
|
// src/managers/cursor-manager.ts
|
|
16343
16276
|
import { mkdir as mkdir13, readFile as readFile12, readdir as readdir5 } from "fs/promises";
|
|
16344
|
-
import { basename as basename2, dirname as dirname6, extname, join as
|
|
16277
|
+
import { basename as basename2, dirname as dirname6, extname, join as join18 } from "path";
|
|
16345
16278
|
import { Agent as CursorAgent2 } from "@cursor/sdk";
|
|
16346
16279
|
|
|
16347
16280
|
// src/services/native-command-protection-hooks.ts
|
|
16348
16281
|
import { existsSync as existsSync8 } from "fs";
|
|
16349
16282
|
import { mkdir as mkdir12, readFile as readFile11, writeFile as writeFile7 } from "fs/promises";
|
|
16350
|
-
import { basename, dirname as dirname5, join as
|
|
16283
|
+
import { basename, dirname as dirname5, join as join17 } from "path";
|
|
16351
16284
|
import { fileURLToPath } from "url";
|
|
16352
16285
|
var moduleDirectory = dirname5(fileURLToPath(import.meta.url));
|
|
16353
16286
|
var hookPath = [
|
|
16354
|
-
|
|
16355
|
-
|
|
16287
|
+
join17(moduleDirectory, "command-protection-hook.js"),
|
|
16288
|
+
join17(moduleDirectory, "..", "command-protection-hook.ts")
|
|
16356
16289
|
].find(existsSync8);
|
|
16357
16290
|
var postToolHookPath = [
|
|
16358
|
-
|
|
16359
|
-
|
|
16291
|
+
join17(moduleDirectory, "post-tool-pr-hook.js"),
|
|
16292
|
+
join17(moduleDirectory, "..", "post-tool-pr-hook.ts")
|
|
16360
16293
|
].find(existsSync8);
|
|
16361
16294
|
function shellCommand(path7, provider) {
|
|
16362
16295
|
if (!path7) throw new Error("Replicas hook executable is missing.");
|
|
@@ -16377,7 +16310,7 @@ function getPostToolPrHookPath() {
|
|
|
16377
16310
|
return postToolHookPath;
|
|
16378
16311
|
}
|
|
16379
16312
|
async function ensureCursorCommandProtectionHook() {
|
|
16380
|
-
const path7 =
|
|
16313
|
+
const path7 = join17(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
16381
16314
|
let config = {};
|
|
16382
16315
|
try {
|
|
16383
16316
|
const parsed = JSON.parse(await readFile11(path7, "utf8"));
|
|
@@ -16476,7 +16409,7 @@ async function listCursorCommandsInDirectory(directory) {
|
|
|
16476
16409
|
const name = basename2(entry.name, ".md");
|
|
16477
16410
|
let description;
|
|
16478
16411
|
try {
|
|
16479
|
-
description = extractCursorCommandDescription(await readFile12(
|
|
16412
|
+
description = extractCursorCommandDescription(await readFile12(join18(directory, entry.name), "utf8"));
|
|
16480
16413
|
} catch (error) {
|
|
16481
16414
|
console.warn("[CursorManager] Failed to read slash command file:", error);
|
|
16482
16415
|
}
|
|
@@ -16498,7 +16431,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
16498
16431
|
slashCommandsRequest = null;
|
|
16499
16432
|
constructor(options) {
|
|
16500
16433
|
super(options);
|
|
16501
|
-
this.historyFilePath = options.historyFilePath ??
|
|
16434
|
+
this.historyFilePath = options.historyFilePath ?? join18(ENGINE_ENV.HOME_DIR, ".replicas", "cursor", "history.jsonl");
|
|
16502
16435
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
16503
16436
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
16504
16437
|
}
|
|
@@ -16573,7 +16506,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
16573
16506
|
this.slashCommandsRequest ??= (async () => {
|
|
16574
16507
|
try {
|
|
16575
16508
|
const repoDirectories = await getAgentAdditionalDirectories();
|
|
16576
|
-
const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) =>
|
|
16509
|
+
const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) => join18(directory, ".cursor", "commands"));
|
|
16577
16510
|
const commands = mergeSlashCommands(
|
|
16578
16511
|
...await Promise.all(commandDirectories.map(listCursorCommandsInDirectory))
|
|
16579
16512
|
);
|
|
@@ -16612,8 +16545,8 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
16612
16545
|
let agent = null;
|
|
16613
16546
|
let sawCursorActivity = false;
|
|
16614
16547
|
let reconnectNoticeTimer = null;
|
|
16615
|
-
const aborted = new Promise((
|
|
16616
|
-
this.abortActiveTurn = () =>
|
|
16548
|
+
const aborted = new Promise((resolve7) => {
|
|
16549
|
+
this.abortActiveTurn = () => resolve7(TURN_ABORTED);
|
|
16617
16550
|
});
|
|
16618
16551
|
const linearSessionId = this.linearSessionId;
|
|
16619
16552
|
const linearForwarder = new LinearEventForwarder(linearSessionId);
|
|
@@ -17148,8 +17081,8 @@ ${typeof pending.subject.command === "string" ? pending.subject.command : JSON.s
|
|
|
17148
17081
|
userMessageRecorded = true;
|
|
17149
17082
|
}
|
|
17150
17083
|
if (/^\/compact$/i.test(request.message.trim())) {
|
|
17151
|
-
const completed2 = new Promise((
|
|
17152
|
-
this.compactionComplete = { resolve:
|
|
17084
|
+
const completed2 = new Promise((resolve7) => {
|
|
17085
|
+
this.compactionComplete = { resolve: resolve7 };
|
|
17153
17086
|
});
|
|
17154
17087
|
const result2 = await this.request("session/compact", {
|
|
17155
17088
|
commandId: uuidV7(),
|
|
@@ -17181,8 +17114,8 @@ ${pending}
|
|
|
17181
17114
|
|
|
17182
17115
|
` : ""}${request.planMode ? "Plan the requested work without modifying files or running mutating commands.\n\n" : ""}${request.message}`;
|
|
17183
17116
|
this.turnError = null;
|
|
17184
|
-
const completed = new Promise((
|
|
17185
|
-
this.turnComplete = { resolve:
|
|
17117
|
+
const completed = new Promise((resolve7) => {
|
|
17118
|
+
this.turnComplete = { resolve: resolve7 };
|
|
17186
17119
|
});
|
|
17187
17120
|
const result = await this.request("turn/start", {
|
|
17188
17121
|
commandId: uuidV7(),
|
|
@@ -17366,7 +17299,7 @@ ${pending}
|
|
|
17366
17299
|
// src/managers/opencode-manager.ts
|
|
17367
17300
|
import { existsSync as existsSync9 } from "fs";
|
|
17368
17301
|
import { copyFile, mkdir as mkdir15, readFile as readFile13, rm as rm2 } from "fs/promises";
|
|
17369
|
-
import { delimiter, dirname as dirname8, join as
|
|
17302
|
+
import { delimiter, dirname as dirname8, join as join19 } from "path";
|
|
17370
17303
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
17371
17304
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
17372
17305
|
import { Agent } from "undici";
|
|
@@ -17395,10 +17328,10 @@ async function getAllowedOpenRouterModels() {
|
|
|
17395
17328
|
|
|
17396
17329
|
// src/managers/opencode-manager.ts
|
|
17397
17330
|
var OPENCODE_SHIM_DIR = dirname8(fileURLToPath2(new URL("../../scripts/opencode", import.meta.url)));
|
|
17398
|
-
var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE =
|
|
17399
|
-
var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH =
|
|
17400
|
-
var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH =
|
|
17401
|
-
var OPENCODE_CONFIG_PATH =
|
|
17331
|
+
var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE = join19(OPENCODE_SHIM_DIR, "opencode-command-protection-plugin.ts");
|
|
17332
|
+
var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH = join19(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.ts");
|
|
17333
|
+
var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH = join19(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.mjs");
|
|
17334
|
+
var OPENCODE_CONFIG_PATH = join19(ENGINE_ENV.HOME_DIR, ".config", "opencode", "opencode.json");
|
|
17402
17335
|
var OPENCODE_FETCH_DISPATCHER = new Agent({ headersTimeout: 0, bodyTimeout: 0 });
|
|
17403
17336
|
var OPENCODE_SERVER_STARTUP_TIMEOUT_MS = 3e4;
|
|
17404
17337
|
var OPENCODE_WORKSPACE_PERMISSION = "allow";
|
|
@@ -17619,7 +17552,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
17619
17552
|
constructor(options) {
|
|
17620
17553
|
super({ ...options, provider: "opencode" });
|
|
17621
17554
|
this.sessionId = options.initialSessionId;
|
|
17622
|
-
this.historyFilePath = options.historyFilePath ??
|
|
17555
|
+
this.historyFilePath = options.historyFilePath ?? join19(ENGINE_ENV.HOME_DIR, ".replicas", "opencode", "history.jsonl");
|
|
17623
17556
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
17624
17557
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
17625
17558
|
}
|
|
@@ -17696,8 +17629,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
17696
17629
|
const previousUpdate = this.clientUpdate;
|
|
17697
17630
|
let finishUpdate = () => {
|
|
17698
17631
|
};
|
|
17699
|
-
this.clientUpdate = new Promise((
|
|
17700
|
-
finishUpdate =
|
|
17632
|
+
this.clientUpdate = new Promise((resolve7) => {
|
|
17633
|
+
finishUpdate = resolve7;
|
|
17701
17634
|
});
|
|
17702
17635
|
await previousUpdate;
|
|
17703
17636
|
try {
|
|
@@ -17771,8 +17704,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
17771
17704
|
this.configuredModels = new Set(providerModels);
|
|
17772
17705
|
const eventController = new AbortController();
|
|
17773
17706
|
this.eventAbortController = eventController;
|
|
17774
|
-
this.eventSubscriptionReady = new Promise((
|
|
17775
|
-
this.resolveEventSubscriptionReady =
|
|
17707
|
+
this.eventSubscriptionReady = new Promise((resolve7) => {
|
|
17708
|
+
this.resolveEventSubscriptionReady = resolve7;
|
|
17776
17709
|
});
|
|
17777
17710
|
this.subscribeToEvents(client, eventController).catch((error) => {
|
|
17778
17711
|
this.resolveEventSubscriptionReady?.();
|
|
@@ -17782,7 +17715,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
17782
17715
|
});
|
|
17783
17716
|
await Promise.race([
|
|
17784
17717
|
this.eventSubscriptionReady,
|
|
17785
|
-
new Promise((
|
|
17718
|
+
new Promise((resolve7) => setTimeout(resolve7, 2e3))
|
|
17786
17719
|
]);
|
|
17787
17720
|
return client;
|
|
17788
17721
|
} finally {
|
|
@@ -18041,7 +17974,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18041
17974
|
|
|
18042
17975
|
// src/managers/pi-manager.ts
|
|
18043
17976
|
import { mkdir as mkdir17, readFile as readFile14 } from "fs/promises";
|
|
18044
|
-
import { dirname as dirname16, join as
|
|
17977
|
+
import { dirname as dirname16, join as join27 } from "path";
|
|
18045
17978
|
import {
|
|
18046
17979
|
createAgentSession,
|
|
18047
17980
|
ModelRegistry,
|
|
@@ -18052,17 +17985,17 @@ import {
|
|
|
18052
17985
|
|
|
18053
17986
|
// src/services/chat/history-paths.ts
|
|
18054
17987
|
import { homedir as homedir12 } from "os";
|
|
18055
|
-
import { join as
|
|
18056
|
-
var ENGINE_DIR2 =
|
|
18057
|
-
var CHATS_FILE =
|
|
18058
|
-
var CLAUDE_HISTORY_DIR =
|
|
18059
|
-
var RELAY_HISTORY_DIR =
|
|
18060
|
-
var CODEX_HISTORY_DIR =
|
|
18061
|
-
var CURSOR_HISTORY_DIR =
|
|
18062
|
-
var OPENCODE_HISTORY_DIR =
|
|
18063
|
-
var PI_HISTORY_DIR =
|
|
18064
|
-
var MUSE_HISTORY_DIR =
|
|
18065
|
-
var FORKS_DIR =
|
|
17988
|
+
import { join as join20 } from "path";
|
|
17989
|
+
var ENGINE_DIR2 = join20(homedir12(), ".replicas", "engine");
|
|
17990
|
+
var CHATS_FILE = join20(ENGINE_DIR2, "chats.json");
|
|
17991
|
+
var CLAUDE_HISTORY_DIR = join20(ENGINE_DIR2, "claude-histories");
|
|
17992
|
+
var RELAY_HISTORY_DIR = join20(ENGINE_DIR2, "relay-histories");
|
|
17993
|
+
var CODEX_HISTORY_DIR = join20(ENGINE_DIR2, "codex-histories");
|
|
17994
|
+
var CURSOR_HISTORY_DIR = join20(ENGINE_DIR2, "cursor-histories");
|
|
17995
|
+
var OPENCODE_HISTORY_DIR = join20(ENGINE_DIR2, "opencode-histories");
|
|
17996
|
+
var PI_HISTORY_DIR = join20(ENGINE_DIR2, "pi-histories");
|
|
17997
|
+
var MUSE_HISTORY_DIR = join20(ENGINE_DIR2, "muse-histories");
|
|
17998
|
+
var FORKS_DIR = join20(ENGINE_DIR2, "forks");
|
|
18066
17999
|
var HISTORY_DIR_BY_PROVIDER = {
|
|
18067
18000
|
claude: CLAUDE_HISTORY_DIR,
|
|
18068
18001
|
relay: RELAY_HISTORY_DIR,
|
|
@@ -27388,14 +27321,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
27388
27321
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
27389
27322
|
}
|
|
27390
27323
|
function sleep(ms, signal) {
|
|
27391
|
-
return new Promise((
|
|
27324
|
+
return new Promise((resolve7, reject) => {
|
|
27392
27325
|
if (signal?.aborted) {
|
|
27393
27326
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
27394
27327
|
return;
|
|
27395
27328
|
}
|
|
27396
27329
|
const timer = setTimeout(() => {
|
|
27397
27330
|
signal?.removeEventListener("abort", onAbort);
|
|
27398
|
-
|
|
27331
|
+
resolve7();
|
|
27399
27332
|
}, ms);
|
|
27400
27333
|
const onAbort = () => {
|
|
27401
27334
|
clearTimeout(timer);
|
|
@@ -28234,7 +28167,7 @@ var Protocol = class {
|
|
|
28234
28167
|
const flowStartedAt = Date.now();
|
|
28235
28168
|
let onAbort;
|
|
28236
28169
|
let cleanupMessageId;
|
|
28237
|
-
return new Promise((
|
|
28170
|
+
return new Promise((resolve7, reject) => {
|
|
28238
28171
|
const earlyReject = (error) => {
|
|
28239
28172
|
reject(error);
|
|
28240
28173
|
};
|
|
@@ -28302,7 +28235,7 @@ var Protocol = class {
|
|
|
28302
28235
|
}
|
|
28303
28236
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
28304
28237
|
if (decoded.kind === "input_required") {
|
|
28305
|
-
if (options?.allowInputRequired === true) return
|
|
28238
|
+
if (options?.allowInputRequired === true) return resolve7(manualInputRequiredValue(decoded));
|
|
28306
28239
|
const flow = {
|
|
28307
28240
|
codec,
|
|
28308
28241
|
request,
|
|
@@ -28314,11 +28247,11 @@ var Protocol = class {
|
|
|
28314
28247
|
params
|
|
28315
28248
|
}, resultSchema, legOptions)
|
|
28316
28249
|
};
|
|
28317
|
-
return
|
|
28250
|
+
return resolve7(this._resolveNonCompleteResult(decoded, flow));
|
|
28318
28251
|
}
|
|
28319
28252
|
const result = decoded.result;
|
|
28320
28253
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
28321
|
-
if (parseResult.success)
|
|
28254
|
+
if (parseResult.success) resolve7(parseResult.data);
|
|
28322
28255
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
|
|
28323
28256
|
}, reject);
|
|
28324
28257
|
});
|
|
@@ -31270,7 +31203,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31270
31203
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
31271
31204
|
const schOrFunc = root.refs[ref];
|
|
31272
31205
|
if (schOrFunc) return schOrFunc;
|
|
31273
|
-
let _sch =
|
|
31206
|
+
let _sch = resolve7.call(this, root, ref);
|
|
31274
31207
|
if (_sch === void 0) {
|
|
31275
31208
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
31276
31209
|
const { schemaId } = this.opts;
|
|
@@ -31296,7 +31229,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
31296
31229
|
function sameSchemaEnv(s1, s2) {
|
|
31297
31230
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
31298
31231
|
}
|
|
31299
|
-
function
|
|
31232
|
+
function resolve7(root, ref) {
|
|
31300
31233
|
let sch;
|
|
31301
31234
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
31302
31235
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -31746,7 +31679,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
31746
31679
|
else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
|
|
31747
31680
|
return uri;
|
|
31748
31681
|
}
|
|
31749
|
-
function
|
|
31682
|
+
function resolve7(baseURI, relativeURI, options) {
|
|
31750
31683
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
31751
31684
|
const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
31752
31685
|
schemelessOptions.skipEscape = true;
|
|
@@ -31920,7 +31853,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
31920
31853
|
const fastUri = {
|
|
31921
31854
|
SCHEMES,
|
|
31922
31855
|
normalize,
|
|
31923
|
-
resolve:
|
|
31856
|
+
resolve: resolve7,
|
|
31924
31857
|
resolveComponent,
|
|
31925
31858
|
equal,
|
|
31926
31859
|
serialize,
|
|
@@ -37733,14 +37666,14 @@ var ProbeWindow = class ProbeWindow2 {
|
|
|
37733
37666
|
*/
|
|
37734
37667
|
async exchange(buildRequest, timeoutMs) {
|
|
37735
37668
|
const id = `server-discover-probe-${++this._probeCounter}`;
|
|
37736
|
-
return new Promise((
|
|
37669
|
+
return new Promise((resolve7) => {
|
|
37737
37670
|
let settled = false;
|
|
37738
37671
|
const settle = (reply) => {
|
|
37739
37672
|
if (settled) return;
|
|
37740
37673
|
settled = true;
|
|
37741
37674
|
clearTimeout(timer);
|
|
37742
37675
|
if (this._pending?.id === id) this._pending = void 0;
|
|
37743
|
-
|
|
37676
|
+
resolve7(reply);
|
|
37744
37677
|
};
|
|
37745
37678
|
const timer = setTimeout(() => settle({ kind: "timeout" }), timeoutMs);
|
|
37746
37679
|
this._pending = {
|
|
@@ -38946,13 +38879,13 @@ var Client = class extends Protocol {
|
|
|
38946
38879
|
let onCallerAbort;
|
|
38947
38880
|
let resolveOpening;
|
|
38948
38881
|
let rejectOpening;
|
|
38949
|
-
const opening = new Promise((
|
|
38950
|
-
resolveOpening =
|
|
38882
|
+
const opening = new Promise((resolve7, reject) => {
|
|
38883
|
+
resolveOpening = resolve7;
|
|
38951
38884
|
rejectOpening = reject;
|
|
38952
38885
|
});
|
|
38953
38886
|
let resolveClosed;
|
|
38954
|
-
const closed = new Promise((
|
|
38955
|
-
resolveClosed =
|
|
38887
|
+
const closed = new Promise((resolve7) => {
|
|
38888
|
+
resolveClosed = resolve7;
|
|
38956
38889
|
});
|
|
38957
38890
|
const settle = (outcome) => {
|
|
38958
38891
|
if (state === "closed") return;
|
|
@@ -39432,7 +39365,7 @@ var SSEClientTransport = class {
|
|
|
39432
39365
|
}
|
|
39433
39366
|
_startOrAuth() {
|
|
39434
39367
|
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
39435
|
-
return new Promise((
|
|
39368
|
+
return new Promise((resolve7, reject) => {
|
|
39436
39369
|
this._eventSource = new EventSource(this._url.href, {
|
|
39437
39370
|
...this._eventSourceInit,
|
|
39438
39371
|
fetch: async (url3, init) => {
|
|
@@ -39464,7 +39397,7 @@ var SSEClientTransport = class {
|
|
|
39464
39397
|
response,
|
|
39465
39398
|
serverUrl: this._url,
|
|
39466
39399
|
fetchFn: this._fetchWithInit
|
|
39467
|
-
}).then(() => this._startOrAuth().then(
|
|
39400
|
+
}).then(() => this._startOrAuth().then(resolve7, reject), (error$2) => {
|
|
39468
39401
|
markAuthSeamEscape(error$2);
|
|
39469
39402
|
this.onerror?.(error$2);
|
|
39470
39403
|
reject(error$2);
|
|
@@ -39493,7 +39426,7 @@ var SSEClientTransport = class {
|
|
|
39493
39426
|
this.close();
|
|
39494
39427
|
return;
|
|
39495
39428
|
}
|
|
39496
|
-
|
|
39429
|
+
resolve7();
|
|
39497
39430
|
});
|
|
39498
39431
|
this._eventSource.onmessage = (event) => {
|
|
39499
39432
|
const messageEvent = event;
|
|
@@ -40169,7 +40102,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
40169
40102
|
};
|
|
40170
40103
|
|
|
40171
40104
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/server-manager.ts
|
|
40172
|
-
import { mkdirSync as mkdirSync2, statSync as
|
|
40105
|
+
import { mkdirSync as mkdirSync2, statSync as statSync2 } from "fs";
|
|
40173
40106
|
import { isDeepStrictEqual } from "util";
|
|
40174
40107
|
|
|
40175
40108
|
// ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/stdio.mjs
|
|
@@ -40225,7 +40158,7 @@ var StdioClientTransport = class {
|
|
|
40225
40158
|
*/
|
|
40226
40159
|
async start() {
|
|
40227
40160
|
if (this._process) throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
40228
|
-
return new Promise((
|
|
40161
|
+
return new Promise((resolve7, reject) => {
|
|
40229
40162
|
this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
|
|
40230
40163
|
env: {
|
|
40231
40164
|
...getDefaultEnvironment(),
|
|
@@ -40245,7 +40178,7 @@ var StdioClientTransport = class {
|
|
|
40245
40178
|
this.onerror?.(error);
|
|
40246
40179
|
});
|
|
40247
40180
|
this._process.on("spawn", () => {
|
|
40248
|
-
|
|
40181
|
+
resolve7();
|
|
40249
40182
|
});
|
|
40250
40183
|
this._process.on("close", (_code) => {
|
|
40251
40184
|
this._process = void 0;
|
|
@@ -40310,7 +40243,7 @@ var StdioClientTransport = class {
|
|
|
40310
40243
|
const proc = this._process;
|
|
40311
40244
|
this._process = void 0;
|
|
40312
40245
|
if (proc && proc.exitCode === null && proc.signalCode === null) {
|
|
40313
|
-
const exited = new Promise((
|
|
40246
|
+
const exited = new Promise((resolve7) => proc.once("exit", () => resolve7()));
|
|
40314
40247
|
try {
|
|
40315
40248
|
proc.stdin?.end();
|
|
40316
40249
|
} catch {
|
|
@@ -40319,7 +40252,7 @@ var StdioClientTransport = class {
|
|
|
40319
40252
|
proc.kill("SIGTERM");
|
|
40320
40253
|
} catch {
|
|
40321
40254
|
}
|
|
40322
|
-
await Promise.race([exited, new Promise((
|
|
40255
|
+
await Promise.race([exited, new Promise((resolve7) => setTimeout(resolve7, 1e3).unref())]);
|
|
40323
40256
|
if (proc.exitCode === null && proc.signalCode === null) try {
|
|
40324
40257
|
proc.kill("SIGKILL");
|
|
40325
40258
|
} catch {
|
|
@@ -40344,22 +40277,22 @@ var StdioClientTransport = class {
|
|
|
40344
40277
|
if (this._process) {
|
|
40345
40278
|
const processToClose = this._process;
|
|
40346
40279
|
this._process = void 0;
|
|
40347
|
-
const closePromise = new Promise((
|
|
40280
|
+
const closePromise = new Promise((resolve7) => {
|
|
40348
40281
|
processToClose.once("close", () => {
|
|
40349
|
-
|
|
40282
|
+
resolve7();
|
|
40350
40283
|
});
|
|
40351
40284
|
});
|
|
40352
40285
|
try {
|
|
40353
40286
|
processToClose.stdin?.end();
|
|
40354
40287
|
} catch {
|
|
40355
40288
|
}
|
|
40356
|
-
await Promise.race([closePromise, new Promise((
|
|
40289
|
+
await Promise.race([closePromise, new Promise((resolve7) => setTimeout(resolve7, 2e3).unref())]);
|
|
40357
40290
|
if (processToClose.exitCode === null) {
|
|
40358
40291
|
try {
|
|
40359
40292
|
processToClose.kill("SIGTERM");
|
|
40360
40293
|
} catch {
|
|
40361
40294
|
}
|
|
40362
|
-
await Promise.race([closePromise, new Promise((
|
|
40295
|
+
await Promise.race([closePromise, new Promise((resolve7) => setTimeout(resolve7, 2e3).unref())]);
|
|
40363
40296
|
}
|
|
40364
40297
|
if (processToClose.exitCode === null) try {
|
|
40365
40298
|
processToClose.kill("SIGKILL");
|
|
@@ -40369,11 +40302,11 @@ var StdioClientTransport = class {
|
|
|
40369
40302
|
this._readBuffer.clear();
|
|
40370
40303
|
}
|
|
40371
40304
|
send(message) {
|
|
40372
|
-
return new Promise((
|
|
40305
|
+
return new Promise((resolve7) => {
|
|
40373
40306
|
if (!this._process?.stdin) throw new SdkError(SdkErrorCode.NotConnected, "Not connected");
|
|
40374
40307
|
const json = serializeMessage(message);
|
|
40375
|
-
if (this._process.stdin.write(json))
|
|
40376
|
-
else this._process.stdin.once("drain",
|
|
40308
|
+
if (this._process.stdin.write(json)) resolve7();
|
|
40309
|
+
else this._process.stdin.once("drain", resolve7);
|
|
40377
40310
|
});
|
|
40378
40311
|
}
|
|
40379
40312
|
};
|
|
@@ -40394,13 +40327,13 @@ var UnixSocketClientTransport = class {
|
|
|
40394
40327
|
if (this.socket) {
|
|
40395
40328
|
throw new Error("UnixSocketClientTransport already started");
|
|
40396
40329
|
}
|
|
40397
|
-
await new Promise((
|
|
40330
|
+
await new Promise((resolve7, reject) => {
|
|
40398
40331
|
const socket = createConnection(this.socketPath);
|
|
40399
40332
|
this.socket = socket;
|
|
40400
40333
|
let connected = false;
|
|
40401
40334
|
socket.once("connect", () => {
|
|
40402
40335
|
connected = true;
|
|
40403
|
-
|
|
40336
|
+
resolve7();
|
|
40404
40337
|
});
|
|
40405
40338
|
socket.on("data", (chunk) => {
|
|
40406
40339
|
try {
|
|
@@ -40432,12 +40365,12 @@ var UnixSocketClientTransport = class {
|
|
|
40432
40365
|
this.socket = void 0;
|
|
40433
40366
|
this.readBuffer.clear();
|
|
40434
40367
|
if (!socket || socket.destroyed) return;
|
|
40435
|
-
await new Promise((
|
|
40368
|
+
await new Promise((resolve7) => {
|
|
40436
40369
|
const timeout = setTimeout(() => socket.destroy(), 2e3);
|
|
40437
40370
|
timeout.unref();
|
|
40438
40371
|
socket.once("close", () => {
|
|
40439
40372
|
clearTimeout(timeout);
|
|
40440
|
-
|
|
40373
|
+
resolve7();
|
|
40441
40374
|
});
|
|
40442
40375
|
socket.end();
|
|
40443
40376
|
});
|
|
@@ -40445,10 +40378,10 @@ var UnixSocketClientTransport = class {
|
|
|
40445
40378
|
async send(message) {
|
|
40446
40379
|
const socket = this.socket;
|
|
40447
40380
|
if (!socket || socket.destroyed) throw new Error("Unix socket is not connected");
|
|
40448
|
-
await new Promise((
|
|
40381
|
+
await new Promise((resolve7, reject) => {
|
|
40449
40382
|
socket.write(serializeMessage(message), (error) => {
|
|
40450
40383
|
if (error) reject(error);
|
|
40451
|
-
else
|
|
40384
|
+
else resolve7();
|
|
40452
40385
|
});
|
|
40453
40386
|
});
|
|
40454
40387
|
}
|
|
@@ -40602,8 +40535,8 @@ async function probeMcpEndpoint(url3) {
|
|
|
40602
40535
|
}
|
|
40603
40536
|
|
|
40604
40537
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
|
|
40605
|
-
import { existsSync as existsSync10, readFileSync as
|
|
40606
|
-
import { join as
|
|
40538
|
+
import { existsSync as existsSync10, readFileSync as readFileSync3, realpathSync, readdirSync, statSync, writeFileSync as writeFileSync2, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
|
|
40539
|
+
import { join as join21, dirname as dirname9, extname as extname2, resolve as resolve2, sep } from "path";
|
|
40607
40540
|
|
|
40608
40541
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
|
|
40609
40542
|
function throwIfAborted(signal) {
|
|
@@ -40613,7 +40546,7 @@ function throwIfAborted(signal) {
|
|
|
40613
40546
|
async function abortable(promise, signal) {
|
|
40614
40547
|
if (!signal) return promise;
|
|
40615
40548
|
throwIfAborted(signal);
|
|
40616
|
-
return await new Promise((
|
|
40549
|
+
return await new Promise((resolve7, reject) => {
|
|
40617
40550
|
let settled = false;
|
|
40618
40551
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
40619
40552
|
const onAbort = () => {
|
|
@@ -40628,7 +40561,7 @@ async function abortable(promise, signal) {
|
|
|
40628
40561
|
if (settled) return;
|
|
40629
40562
|
settled = true;
|
|
40630
40563
|
cleanup();
|
|
40631
|
-
|
|
40564
|
+
resolve7(value);
|
|
40632
40565
|
},
|
|
40633
40566
|
(error) => {
|
|
40634
40567
|
if (settled) return;
|
|
@@ -40760,11 +40693,11 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
40760
40693
|
const { packageName, exactVersion } = parsedSpec;
|
|
40761
40694
|
const packageDir = findCachedPackageDir(cacheDir, packageName, exactVersion);
|
|
40762
40695
|
if (!packageDir) return null;
|
|
40763
|
-
const packageJsonPath =
|
|
40696
|
+
const packageJsonPath = join21(packageDir, "package.json");
|
|
40764
40697
|
if (!existsSync10(packageJsonPath)) return null;
|
|
40765
40698
|
let pkg = null;
|
|
40766
40699
|
try {
|
|
40767
|
-
pkg = JSON.parse(
|
|
40700
|
+
pkg = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
|
|
40768
40701
|
} catch {
|
|
40769
40702
|
return null;
|
|
40770
40703
|
}
|
|
@@ -40794,10 +40727,10 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
40794
40727
|
}
|
|
40795
40728
|
if (!binRel) return null;
|
|
40796
40729
|
const nodeModulesDir = findNodeModulesDir(packageDir);
|
|
40797
|
-
const binLink = chosenBinName ?
|
|
40730
|
+
const binLink = chosenBinName ? join21(nodeModulesDir, ".bin", chosenBinName) : null;
|
|
40798
40731
|
let resolvedBin = binLink && existsSync10(binLink) ? safeRealpath(binLink) : "";
|
|
40799
40732
|
if (!resolvedBin) {
|
|
40800
|
-
resolvedBin =
|
|
40733
|
+
resolvedBin = resolve2(packageDir, binRel);
|
|
40801
40734
|
if (!existsSync10(resolvedBin)) return null;
|
|
40802
40735
|
}
|
|
40803
40736
|
const isJs = detectJsBinary(resolvedBin);
|
|
@@ -40812,7 +40745,7 @@ var FORCE_CACHE_TIMEOUT_MS = 3e4;
|
|
|
40812
40745
|
async function forceNpxCache(packageSpec, signal) {
|
|
40813
40746
|
throwIfAborted(signal);
|
|
40814
40747
|
try {
|
|
40815
|
-
await new Promise((
|
|
40748
|
+
await new Promise((resolve7, reject) => {
|
|
40816
40749
|
const proc = (0, import_cross_spawn2.default)(
|
|
40817
40750
|
"npm",
|
|
40818
40751
|
["exec", "--yes", "--package", packageSpec, "--", "node", "-e", "1"],
|
|
@@ -40831,7 +40764,7 @@ async function forceNpxCache(packageSpec, signal) {
|
|
|
40831
40764
|
proc.on("close", () => {
|
|
40832
40765
|
clearTimeout(timer);
|
|
40833
40766
|
signal?.removeEventListener("abort", abort);
|
|
40834
|
-
|
|
40767
|
+
resolve7();
|
|
40835
40768
|
});
|
|
40836
40769
|
proc.on("error", (err) => {
|
|
40837
40770
|
clearTimeout(timer);
|
|
@@ -40896,21 +40829,21 @@ function defaultBinName(packageName) {
|
|
|
40896
40829
|
return packageName;
|
|
40897
40830
|
}
|
|
40898
40831
|
function findCachedPackageDir(cacheDir, packageName, exactVersion) {
|
|
40899
|
-
const npxDir =
|
|
40832
|
+
const npxDir = join21(cacheDir, "_npx");
|
|
40900
40833
|
if (!existsSync10(npxDir)) return null;
|
|
40901
40834
|
const packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
|
|
40902
|
-
const candidates =
|
|
40903
|
-
const full =
|
|
40835
|
+
const candidates = readdirSync(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
40836
|
+
const full = join21(npxDir, entry.name);
|
|
40904
40837
|
const mtime = safeStatMtime(full);
|
|
40905
40838
|
return { name: entry.name, mtime };
|
|
40906
40839
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
40907
40840
|
for (const entry of candidates) {
|
|
40908
|
-
const pkgDir =
|
|
40909
|
-
const packageJsonPath =
|
|
40841
|
+
const pkgDir = join21(npxDir, entry.name, "node_modules", ...packagePathParts);
|
|
40842
|
+
const packageJsonPath = join21(pkgDir, "package.json");
|
|
40910
40843
|
if (!existsSync10(packageJsonPath)) continue;
|
|
40911
40844
|
if (exactVersion) {
|
|
40912
40845
|
try {
|
|
40913
|
-
const pkg = JSON.parse(
|
|
40846
|
+
const pkg = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
|
|
40914
40847
|
if (pkg.version !== exactVersion) continue;
|
|
40915
40848
|
} catch {
|
|
40916
40849
|
continue;
|
|
@@ -40926,7 +40859,7 @@ function findNodeModulesDir(packageDir) {
|
|
|
40926
40859
|
if (idx >= 0) {
|
|
40927
40860
|
return parts.slice(0, idx + 1).join(sep);
|
|
40928
40861
|
}
|
|
40929
|
-
return
|
|
40862
|
+
return join21(packageDir, "..");
|
|
40930
40863
|
}
|
|
40931
40864
|
function detectJsBinary(binPath) {
|
|
40932
40865
|
const ext = extname2(binPath).toLowerCase();
|
|
@@ -40972,7 +40905,7 @@ function getNpxCachePath() {
|
|
|
40972
40905
|
function readNpxCachePayload(cachePath) {
|
|
40973
40906
|
if (!existsSync10(cachePath)) return null;
|
|
40974
40907
|
try {
|
|
40975
|
-
return JSON.parse(
|
|
40908
|
+
return JSON.parse(readFileSync3(cachePath, "utf-8"));
|
|
40976
40909
|
} catch {
|
|
40977
40910
|
return null;
|
|
40978
40911
|
}
|
|
@@ -41053,7 +40986,7 @@ function safeRealpath(path7) {
|
|
|
41053
40986
|
}
|
|
41054
40987
|
function safeStatMtime(path7) {
|
|
41055
40988
|
try {
|
|
41056
|
-
return
|
|
40989
|
+
return statSync(path7).mtimeMs;
|
|
41057
40990
|
} catch {
|
|
41058
40991
|
return 0;
|
|
41059
40992
|
}
|
|
@@ -41117,8 +41050,8 @@ function createJsonSchemaValidator() {
|
|
|
41117
41050
|
import { spawnSync } from "child_process";
|
|
41118
41051
|
import { createHash as createHash2 } from "crypto";
|
|
41119
41052
|
import { createRequire } from "module";
|
|
41120
|
-
import { readFileSync as
|
|
41121
|
-
import { dirname as dirname10, join as
|
|
41053
|
+
import { readFileSync as readFileSync4, existsSync as existsSync11, rmSync as rmSync2 } from "fs";
|
|
41054
|
+
import { dirname as dirname10, join as join22 } from "path";
|
|
41122
41055
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
41123
41056
|
var require2 = createRequire(import.meta.url);
|
|
41124
41057
|
var AUTH_SECRET_SERVICE = "pi-mcp-adapter.oauth";
|
|
@@ -41274,7 +41207,7 @@ function loadKeyringNativeBindingFallback(keyringRequire, platform3, arch2) {
|
|
|
41274
41207
|
for (const target of targets) {
|
|
41275
41208
|
try {
|
|
41276
41209
|
const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
|
|
41277
|
-
return keyringRequire(
|
|
41210
|
+
return keyringRequire(join22(dirname10(packageJsonPath), target.bindingFile));
|
|
41278
41211
|
} catch (error) {
|
|
41279
41212
|
lastError = error;
|
|
41280
41213
|
}
|
|
@@ -41379,7 +41312,7 @@ function getServerDir(serverName, options) {
|
|
|
41379
41312
|
throw new Error(`Invalid MCP server name: ${JSON.stringify(serverName)}`);
|
|
41380
41313
|
}
|
|
41381
41314
|
const storageKey = getAuthEntryAccount(serverName);
|
|
41382
|
-
return
|
|
41315
|
+
return join22(getAuthBaseDir(options), storageKey);
|
|
41383
41316
|
}
|
|
41384
41317
|
function getAuthEntryAccount(serverName) {
|
|
41385
41318
|
if (typeof serverName !== "string") {
|
|
@@ -41388,7 +41321,7 @@ function getAuthEntryAccount(serverName) {
|
|
|
41388
41321
|
return `sha256-${createHash2("sha256").update(serverName, "utf8").digest("hex")}`;
|
|
41389
41322
|
}
|
|
41390
41323
|
function getAuthEntryFilePath(serverName, options) {
|
|
41391
|
-
return
|
|
41324
|
+
return join22(getServerDir(serverName, options), "tokens.json");
|
|
41392
41325
|
}
|
|
41393
41326
|
function parseJsonPayload(serverName, payload, source) {
|
|
41394
41327
|
try {
|
|
@@ -41538,7 +41471,7 @@ function readChunkedAuthEntry(store, serverName, account, manifest) {
|
|
|
41538
41471
|
function readLegacyAuthEntry(serverName, options) {
|
|
41539
41472
|
const filePath = getAuthEntryFilePath(serverName, options);
|
|
41540
41473
|
if (!existsSync11(filePath)) return void 0;
|
|
41541
|
-
const data =
|
|
41474
|
+
const data = readFileSync4(filePath, "utf-8");
|
|
41542
41475
|
return parseAuthEntryPayload(serverName, data, filePath);
|
|
41543
41476
|
}
|
|
41544
41477
|
function removeLegacyAuthEntry(serverName, options) {
|
|
@@ -42744,14 +42677,14 @@ var baseOpen = async (options) => {
|
|
|
42744
42677
|
}
|
|
42745
42678
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
42746
42679
|
if (options.wait) {
|
|
42747
|
-
return new Promise((
|
|
42680
|
+
return new Promise((resolve7, reject) => {
|
|
42748
42681
|
subprocess.once("error", reject);
|
|
42749
42682
|
subprocess.once("close", (exitCode) => {
|
|
42750
42683
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
42751
42684
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
42752
42685
|
return;
|
|
42753
42686
|
}
|
|
42754
|
-
|
|
42687
|
+
resolve7(subprocess);
|
|
42755
42688
|
});
|
|
42756
42689
|
});
|
|
42757
42690
|
}
|
|
@@ -43079,12 +43012,12 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43079
43012
|
const candidateServer = createServer(handleRequest);
|
|
43080
43013
|
const listenPort = strictPort ? requiredPort : 0;
|
|
43081
43014
|
try {
|
|
43082
|
-
await new Promise((
|
|
43015
|
+
await new Promise((resolve7, reject) => {
|
|
43083
43016
|
candidateServer.once("error", (err) => {
|
|
43084
43017
|
reject(err);
|
|
43085
43018
|
});
|
|
43086
43019
|
candidateServer.listen(listenPort, requestedHost, () => {
|
|
43087
|
-
|
|
43020
|
+
resolve7();
|
|
43088
43021
|
});
|
|
43089
43022
|
});
|
|
43090
43023
|
if (strictPort) {
|
|
@@ -43097,8 +43030,8 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43097
43030
|
setOAuthCallbackPort(address.port);
|
|
43098
43031
|
}
|
|
43099
43032
|
if (previousServer && (needsStrictRebind || needsHostSwitch)) {
|
|
43100
|
-
await new Promise((
|
|
43101
|
-
previousServer.close(() =>
|
|
43033
|
+
await new Promise((resolve7) => {
|
|
43034
|
+
previousServer.close(() => resolve7());
|
|
43102
43035
|
});
|
|
43103
43036
|
}
|
|
43104
43037
|
callbackServerHost = requestedHost;
|
|
@@ -43114,8 +43047,8 @@ async function ensureCallbackServerLocked(options = {}) {
|
|
|
43114
43047
|
reservedAuthStates.delete(reservedState);
|
|
43115
43048
|
}
|
|
43116
43049
|
const nodeError = error;
|
|
43117
|
-
await new Promise((
|
|
43118
|
-
candidateServer.close(() =>
|
|
43050
|
+
await new Promise((resolve7) => {
|
|
43051
|
+
candidateServer.close(() => resolve7());
|
|
43119
43052
|
});
|
|
43120
43053
|
if (strictPort && nodeError.code === "EADDRINUSE") {
|
|
43121
43054
|
throw new Error(
|
|
@@ -43131,14 +43064,14 @@ function releaseCallbackServer(oauthState) {
|
|
|
43131
43064
|
}
|
|
43132
43065
|
function waitForCallback(oauthState) {
|
|
43133
43066
|
reservedAuthStates.delete(oauthState);
|
|
43134
|
-
return new Promise((
|
|
43067
|
+
return new Promise((resolve7, reject) => {
|
|
43135
43068
|
const timeout = setTimeout(() => {
|
|
43136
43069
|
if (pendingAuths.has(oauthState)) {
|
|
43137
43070
|
pendingAuths.delete(oauthState);
|
|
43138
43071
|
reject(new Error("OAuth callback timeout - authorization took too long"));
|
|
43139
43072
|
}
|
|
43140
43073
|
}, CALLBACK_TIMEOUT_MS);
|
|
43141
|
-
pendingAuths.set(oauthState, { resolve:
|
|
43074
|
+
pendingAuths.set(oauthState, { resolve: resolve7, reject, timeout });
|
|
43142
43075
|
});
|
|
43143
43076
|
}
|
|
43144
43077
|
function cancelPendingCallback(oauthState) {
|
|
@@ -43163,9 +43096,9 @@ function stopCallbackServer() {
|
|
|
43163
43096
|
});
|
|
43164
43097
|
}
|
|
43165
43098
|
if (server) {
|
|
43166
|
-
await new Promise((
|
|
43099
|
+
await new Promise((resolve7) => {
|
|
43167
43100
|
server.close(() => {
|
|
43168
|
-
|
|
43101
|
+
resolve7();
|
|
43169
43102
|
});
|
|
43170
43103
|
});
|
|
43171
43104
|
server = void 0;
|
|
@@ -43991,7 +43924,7 @@ async function shutdownOAuth(runtime = legacyRuntime) {
|
|
|
43991
43924
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-bearer-store.ts
|
|
43992
43925
|
import { createHash as createHash3 } from "crypto";
|
|
43993
43926
|
import { createRequire as createRequire2 } from "module";
|
|
43994
|
-
import { dirname as dirname11, join as
|
|
43927
|
+
import { dirname as dirname11, join as join23 } from "path";
|
|
43995
43928
|
var require3 = createRequire2(import.meta.url);
|
|
43996
43929
|
var BEARER_SECRET_SERVICE = "pi-mcp-adapter.bearer";
|
|
43997
43930
|
var TEST_AUTH_STORE_ENV2 = "PI_MCP_ADAPTER_TEST_AUTH_STORE";
|
|
@@ -44093,7 +44026,7 @@ function loadKeyringNativeBindingFallback2(keyringRequire, platform3, arch2) {
|
|
|
44093
44026
|
for (const target of targets) {
|
|
44094
44027
|
try {
|
|
44095
44028
|
const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
|
|
44096
|
-
return keyringRequire(
|
|
44029
|
+
return keyringRequire(join23(dirname11(packageJsonPath), target.bindingFile));
|
|
44097
44030
|
} catch (error) {
|
|
44098
44031
|
lastError = error;
|
|
44099
44032
|
}
|
|
@@ -44707,7 +44640,7 @@ function humanizeName(name) {
|
|
|
44707
44640
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-trace.ts
|
|
44708
44641
|
import { appendFile as appendFile3, mkdir as mkdir16, writeFile as writeFile8 } from "fs/promises";
|
|
44709
44642
|
import { Buffer as Buffer3 } from "buffer";
|
|
44710
|
-
import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as
|
|
44643
|
+
import { dirname as dirname12, isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
|
|
44711
44644
|
var MCP_TRACE_SCHEMA_VERSION = 1;
|
|
44712
44645
|
var DEFAULT_MCP_TRACE_MAX_BYTES = 256 * 1024;
|
|
44713
44646
|
var DEFAULT_MCP_TRACE_MAX_EVENTS = 1e4;
|
|
@@ -44839,7 +44772,7 @@ var McpTraceWriter = class {
|
|
|
44839
44772
|
function createMcpTraceWriter(sessionCwd, settings2 = {}, randomSuffix = Math.random().toString(36).slice(2, 10)) {
|
|
44840
44773
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
44841
44774
|
const configuredPath = settings2.file;
|
|
44842
|
-
const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath :
|
|
44775
|
+
const filePath = configuredPath ? isAbsolute2(configuredPath) ? configuredPath : resolve3(sessionCwd ?? process.cwd(), configuredPath) : resolve3(sessionCwd ?? process.cwd(), ".pi", "mcp-traces", `mcp-${timestamp}-${randomSuffix}.jsonl`);
|
|
44843
44776
|
return new McpTraceWriter({
|
|
44844
44777
|
filePath,
|
|
44845
44778
|
...settings2.maxBytes !== void 0 ? { maxBytes: settings2.maxBytes } : {},
|
|
@@ -45054,7 +44987,7 @@ function resolvedCommand(config) {
|
|
|
45054
44987
|
async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
45055
44988
|
const resolved = resolvedCommand(config);
|
|
45056
44989
|
if (USE_PROCESS_GROUP) assertPosixProcessDiscoveryAvailable();
|
|
45057
|
-
return new Promise((
|
|
44990
|
+
return new Promise((resolve7, reject) => {
|
|
45058
44991
|
let stdout = Buffer.alloc(0);
|
|
45059
44992
|
let settled = false;
|
|
45060
44993
|
const cleanupToken = randomUUID6();
|
|
@@ -45083,7 +45016,7 @@ async function invokeRequestHeadersCommand(config, envelope, signal) {
|
|
|
45083
45016
|
if (descendantTracker) clearInterval(descendantTracker);
|
|
45084
45017
|
signal.removeEventListener("abort", abort);
|
|
45085
45018
|
if (result.status === "error") reject(result.error);
|
|
45086
|
-
else
|
|
45019
|
+
else resolve7(result.headers);
|
|
45087
45020
|
};
|
|
45088
45021
|
const finishAfterKill = (result) => {
|
|
45089
45022
|
try {
|
|
@@ -45705,7 +45638,7 @@ var McpServerManager = class {
|
|
|
45705
45638
|
let args = (definition.args ?? []).map((argument) => interpolateEnvVars(argument));
|
|
45706
45639
|
const cwd = resolveConfigPath(definition.cwd) ?? this.defaultCwd;
|
|
45707
45640
|
if (cwd !== void 0) {
|
|
45708
|
-
const cwdStats =
|
|
45641
|
+
const cwdStats = statSync2(cwd, { throwIfNoEntry: false });
|
|
45709
45642
|
if (!cwdStats) throw new Error(`MCP server "${name}" configured cwd does not exist: "${cwd}"`);
|
|
45710
45643
|
if (!cwdStats.isDirectory()) throw new Error(`MCP server "${name}" configured cwd is not a directory: "${cwd}"`);
|
|
45711
45644
|
}
|
|
@@ -47905,7 +47838,7 @@ function getEffectiveIdleTimeoutMinutes(state, serverName) {
|
|
|
47905
47838
|
}
|
|
47906
47839
|
|
|
47907
47840
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/onboarding-state.ts
|
|
47908
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync3, readFileSync as
|
|
47841
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3, renameSync as renameSync2 } from "fs";
|
|
47909
47842
|
import { dirname as dirname13 } from "path";
|
|
47910
47843
|
var DEFAULT_STATE2 = {
|
|
47911
47844
|
version: 1,
|
|
@@ -47919,7 +47852,7 @@ function loadOnboardingState() {
|
|
|
47919
47852
|
const path7 = getOnboardingStatePath();
|
|
47920
47853
|
if (!existsSync13(path7)) return { ...DEFAULT_STATE2 };
|
|
47921
47854
|
try {
|
|
47922
|
-
const raw = JSON.parse(
|
|
47855
|
+
const raw = JSON.parse(readFileSync5(path7, "utf-8"));
|
|
47923
47856
|
if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE2 };
|
|
47924
47857
|
return {
|
|
47925
47858
|
version: 1,
|
|
@@ -48375,12 +48308,12 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
|
|
|
48375
48308
|
markSetupCompleted(discovery.fingerprint);
|
|
48376
48309
|
}
|
|
48377
48310
|
};
|
|
48378
|
-
return new Promise((
|
|
48311
|
+
return new Promise((resolve7) => {
|
|
48379
48312
|
ctx.ui.custom(
|
|
48380
48313
|
(tui, _theme, keybindings, done) => {
|
|
48381
48314
|
return createMcpSetupPanel(discovery, callbacks, { mode, onboardingState, keybindings }, tui, () => {
|
|
48382
48315
|
done(void 0);
|
|
48383
|
-
|
|
48316
|
+
resolve7({ configChanged });
|
|
48384
48317
|
});
|
|
48385
48318
|
},
|
|
48386
48319
|
{ overlay: true, overlayOptions: { anchor: "center", width: 92 } }
|
|
@@ -48462,7 +48395,7 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
|
|
|
48462
48395
|
const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
|
|
48463
48396
|
const { createMcpPanel } = await import("./mcp-panel-2XMW56WJ.js");
|
|
48464
48397
|
let configChanged = false;
|
|
48465
|
-
await new Promise((
|
|
48398
|
+
await new Promise((resolve7) => {
|
|
48466
48399
|
ctx.ui.custom(
|
|
48467
48400
|
(tui, _theme, keybindings, done) => {
|
|
48468
48401
|
return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, (result) => {
|
|
@@ -48485,13 +48418,13 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
|
|
|
48485
48418
|
ctx.ui.notify("Direct tools updated for this session.", "info");
|
|
48486
48419
|
}
|
|
48487
48420
|
done(void 0);
|
|
48488
|
-
|
|
48421
|
+
resolve7();
|
|
48489
48422
|
})().catch((error) => {
|
|
48490
48423
|
const message = error instanceof Error ? error.message : String(error);
|
|
48491
48424
|
ctx.ui.notify(`Direct tools updated, but live refresh failed: ${message}`, "error");
|
|
48492
48425
|
configChanged = true;
|
|
48493
48426
|
done(void 0);
|
|
48494
|
-
|
|
48427
|
+
resolve7();
|
|
48495
48428
|
});
|
|
48496
48429
|
}, { noticeLines, keybindings });
|
|
48497
48430
|
},
|
|
@@ -48533,12 +48466,12 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
|
|
|
48533
48466
|
let overlayHandle;
|
|
48534
48467
|
const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
|
|
48535
48468
|
const { createMcpPanel } = await import("./mcp-panel-2XMW56WJ.js");
|
|
48536
|
-
await new Promise((
|
|
48469
|
+
await new Promise((resolve7) => {
|
|
48537
48470
|
ctx.ui.custom(
|
|
48538
48471
|
(tui, _theme, keybindings, done) => {
|
|
48539
48472
|
return createMcpPanel(config, cache2, provenanceMap, callbacks, tui, () => {
|
|
48540
48473
|
done(void 0);
|
|
48541
|
-
|
|
48474
|
+
resolve7();
|
|
48542
48475
|
}, {
|
|
48543
48476
|
authOnly: true,
|
|
48544
48477
|
keybindings,
|
|
@@ -48560,7 +48493,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
|
|
|
48560
48493
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-registrar.ts
|
|
48561
48494
|
import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
48562
48495
|
import { tmpdir } from "os";
|
|
48563
|
-
import { join as
|
|
48496
|
+
import { join as join24 } from "path";
|
|
48564
48497
|
var MAX_BINARY_RESOURCE_BYTES = 10 * 1024 * 1024;
|
|
48565
48498
|
var MAX_SESSION_RESOURCE_BYTES = 100 * 1024 * 1024;
|
|
48566
48499
|
var MAX_SESSION_RESOURCE_FILES = 1e4;
|
|
@@ -48667,11 +48600,11 @@ function materializeBinaryResource(resource, scope) {
|
|
|
48667
48600
|
return omitBinaryResource(resource, "session resource limit reached");
|
|
48668
48601
|
}
|
|
48669
48602
|
try {
|
|
48670
|
-
session.directory ??= mkdtempSync(
|
|
48603
|
+
session.directory ??= mkdtempSync(join24(tmpdir(), "pi-mcp-resource-"));
|
|
48671
48604
|
} catch {
|
|
48672
48605
|
return omitBinaryResource(resource, "could not be saved");
|
|
48673
48606
|
}
|
|
48674
|
-
const filePath =
|
|
48607
|
+
const filePath = join24(session.directory, `resource-${++session.sequence}.bin`);
|
|
48675
48608
|
session.bytes += decodedBytes;
|
|
48676
48609
|
session.files += 1;
|
|
48677
48610
|
try {
|
|
@@ -48764,7 +48697,7 @@ function stringifyStructuredContent(value) {
|
|
|
48764
48697
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
48765
48698
|
import { mkdtemp, rm as rm3, writeFile as writeFile9 } from "fs/promises";
|
|
48766
48699
|
import { tmpdir as tmpdir2 } from "os";
|
|
48767
|
-
import { dirname as dirname14, join as
|
|
48700
|
+
import { dirname as dirname14, join as join25 } from "path";
|
|
48768
48701
|
var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
48769
48702
|
var DEFAULT_MCP_OUTPUT_MAX_LINES = 2e3;
|
|
48770
48703
|
var DEFAULT_MCP_DETAILS_MAX_BYTES = 16 * 1024;
|
|
@@ -49072,8 +49005,8 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
49072
49005
|
}
|
|
49073
49006
|
async function saveArtifact(kind, text) {
|
|
49074
49007
|
try {
|
|
49075
|
-
const dir = await mkdtemp(
|
|
49076
|
-
const path7 =
|
|
49008
|
+
const dir = await mkdtemp(join25(tmpdir2(), "pi-mcp-output-"));
|
|
49009
|
+
const path7 = join25(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
|
|
49077
49010
|
await writeFile9(path7, text, { encoding: "utf8", mode: 384 });
|
|
49078
49011
|
return { path: path7 };
|
|
49079
49012
|
} catch (error) {
|
|
@@ -50485,7 +50418,7 @@ data: ${JSON.stringify(payload)}
|
|
|
50485
50418
|
markCompleted("stale");
|
|
50486
50419
|
}, WATCHDOG_INTERVAL_MS);
|
|
50487
50420
|
watchdog.unref();
|
|
50488
|
-
return new Promise((
|
|
50421
|
+
return new Promise((resolve7, reject) => {
|
|
50489
50422
|
const candidates = resolvePortCandidates(options.port);
|
|
50490
50423
|
let candidateIndex = 0;
|
|
50491
50424
|
const startSandboxProxy = (parentOrigin) => {
|
|
@@ -50622,7 +50555,7 @@ data: ${JSON.stringify(payload)}
|
|
|
50622
50555
|
getSessionMessages: () => ({ ...sessionMessages }),
|
|
50623
50556
|
getStreamSummary: () => streamSummary ? { ...streamSummary, phases: [...streamSummary.phases] } : void 0
|
|
50624
50557
|
};
|
|
50625
|
-
|
|
50558
|
+
resolve7(handle);
|
|
50626
50559
|
}).catch((error) => {
|
|
50627
50560
|
log.error("Failed to start sandbox proxy", error instanceof Error ? error : void 0);
|
|
50628
50561
|
closeListeners();
|
|
@@ -50647,7 +50580,7 @@ async function parseBody(req, res) {
|
|
|
50647
50580
|
}
|
|
50648
50581
|
}
|
|
50649
50582
|
function readBody(req) {
|
|
50650
|
-
return new Promise((
|
|
50583
|
+
return new Promise((resolve7, reject) => {
|
|
50651
50584
|
let size = 0;
|
|
50652
50585
|
const chunks = [];
|
|
50653
50586
|
req.on("data", (chunk) => {
|
|
@@ -50661,7 +50594,7 @@ function readBody(req) {
|
|
|
50661
50594
|
});
|
|
50662
50595
|
req.on("end", () => {
|
|
50663
50596
|
try {
|
|
50664
|
-
|
|
50597
|
+
resolve7(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
|
|
50665
50598
|
} catch (error) {
|
|
50666
50599
|
reject(error);
|
|
50667
50600
|
}
|
|
@@ -50720,7 +50653,7 @@ function sendText(res, status, text) {
|
|
|
50720
50653
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/glimpse-ui.ts
|
|
50721
50654
|
import { existsSync as existsSync14 } from "fs";
|
|
50722
50655
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
50723
|
-
import { join as
|
|
50656
|
+
import { join as join26, dirname as dirname15 } from "path";
|
|
50724
50657
|
import { platform as platform2 } from "os";
|
|
50725
50658
|
import { createRequire as createRequire3 } from "module";
|
|
50726
50659
|
var glimpseAvailable = null;
|
|
@@ -50742,20 +50675,20 @@ function getGlimpseBinaryPath() {
|
|
|
50742
50675
|
try {
|
|
50743
50676
|
const require6 = createRequire3(import.meta.url);
|
|
50744
50677
|
const glimpseuiPath = require6.resolve("glimpseui");
|
|
50745
|
-
const binaryPath =
|
|
50678
|
+
const binaryPath = join26(dirname15(glimpseuiPath), "glimpse");
|
|
50746
50679
|
if (existsSync14(binaryPath)) return binaryPath;
|
|
50747
50680
|
} catch {
|
|
50748
50681
|
}
|
|
50749
50682
|
try {
|
|
50750
50683
|
const globalRoot = execFileSync2("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
|
|
50751
|
-
const binaryPath =
|
|
50684
|
+
const binaryPath = join26(globalRoot, "glimpseui", "src", "glimpse");
|
|
50752
50685
|
if (existsSync14(binaryPath)) return binaryPath;
|
|
50753
50686
|
} catch {
|
|
50754
50687
|
}
|
|
50755
50688
|
return null;
|
|
50756
50689
|
}
|
|
50757
50690
|
async function openGlimpseWindow(html, options) {
|
|
50758
|
-
const modulePath = resolvedBinaryPath ?
|
|
50691
|
+
const modulePath = resolvedBinaryPath ? join26(dirname15(resolvedBinaryPath), "glimpse.mjs") : "glimpseui";
|
|
50759
50692
|
const glimpse = await import(modulePath);
|
|
50760
50693
|
let active = true;
|
|
50761
50694
|
const win = glimpse.open(html, {
|
|
@@ -50842,22 +50775,22 @@ function isRemoteSession() {
|
|
|
50842
50775
|
return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
|
|
50843
50776
|
}
|
|
50844
50777
|
function hasActiveRemoteLogin() {
|
|
50845
|
-
return new Promise((
|
|
50778
|
+
return new Promise((resolve7) => {
|
|
50846
50779
|
execFile6("who", { encoding: "utf8", timeout: 2e3 }, (error, out) => {
|
|
50847
50780
|
if (error) {
|
|
50848
|
-
|
|
50781
|
+
resolve7(false);
|
|
50849
50782
|
return;
|
|
50850
50783
|
}
|
|
50851
|
-
|
|
50784
|
+
resolve7(/\(.+\)\s*$/m.test(out));
|
|
50852
50785
|
});
|
|
50853
50786
|
});
|
|
50854
50787
|
}
|
|
50855
50788
|
function probeMoshiGateway() {
|
|
50856
|
-
return new Promise((
|
|
50789
|
+
return new Promise((resolve7) => {
|
|
50857
50790
|
const socket = net.connect({ host: "127.0.0.1", port: 24543 });
|
|
50858
50791
|
const done = (ok) => {
|
|
50859
50792
|
socket.destroy();
|
|
50860
|
-
|
|
50793
|
+
resolve7(ok);
|
|
50861
50794
|
};
|
|
50862
50795
|
socket.setTimeout(300);
|
|
50863
50796
|
socket.once("connect", () => done(true));
|
|
@@ -57277,7 +57210,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57277
57210
|
trackUnmanagedFds: false
|
|
57278
57211
|
});
|
|
57279
57212
|
const activeWorker = worker;
|
|
57280
|
-
const execution = new Promise((
|
|
57213
|
+
const execution = new Promise((resolve7, reject) => {
|
|
57281
57214
|
let completed = false;
|
|
57282
57215
|
activeWorker.on("message", (value) => {
|
|
57283
57216
|
const message = parseWorkerMessage(value);
|
|
@@ -57289,7 +57222,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
|
|
|
57289
57222
|
if (message.type === "done") {
|
|
57290
57223
|
completed = true;
|
|
57291
57224
|
if ("returnBlock" in message) output.push(toContentBlock(message.returnBlock));
|
|
57292
|
-
|
|
57225
|
+
resolve7();
|
|
57293
57226
|
return;
|
|
57294
57227
|
}
|
|
57295
57228
|
if (message.type === "error") {
|
|
@@ -57568,8 +57501,8 @@ async function awaitWithTimeout(promise, timeoutMs) {
|
|
|
57568
57501
|
try {
|
|
57569
57502
|
return await Promise.race([
|
|
57570
57503
|
promise,
|
|
57571
|
-
new Promise((
|
|
57572
|
-
timer = setTimeout(() =>
|
|
57504
|
+
new Promise((resolve7) => {
|
|
57505
|
+
timer = setTimeout(() => resolve7(INIT_WAIT_TIMED_OUT), timeoutMs);
|
|
57573
57506
|
timer.unref?.();
|
|
57574
57507
|
})
|
|
57575
57508
|
]);
|
|
@@ -58667,7 +58600,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
58667
58600
|
modelRuntime = null;
|
|
58668
58601
|
constructor(options) {
|
|
58669
58602
|
super(options);
|
|
58670
|
-
this.historyFilePath = options.historyFilePath ??
|
|
58603
|
+
this.historyFilePath = options.historyFilePath ?? join27(PI_HISTORY_DIR, `${Date.now()}.jsonl`);
|
|
58671
58604
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
58672
58605
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
58673
58606
|
}
|
|
@@ -58825,9 +58758,9 @@ var PiManager = class extends CodingAgentManager {
|
|
|
58825
58758
|
}
|
|
58826
58759
|
const resourceLoader = new DefaultResourceLoader({
|
|
58827
58760
|
cwd: this.workingDirectory,
|
|
58828
|
-
agentDir:
|
|
58761
|
+
agentDir: join27(ENGINE_ENV.HOME_DIR, ".pi", "agent"),
|
|
58829
58762
|
extensionFactories,
|
|
58830
|
-
appendSystemPrompt: [this.buildCombinedInstructions() ?? ""]
|
|
58763
|
+
appendSystemPrompt: [this.buildCombinedInstructions(request.customInstructions) ?? ""]
|
|
58831
58764
|
});
|
|
58832
58765
|
await resourceLoader.reload();
|
|
58833
58766
|
const result = await createAgentSession({
|
|
@@ -58947,8 +58880,8 @@ import {
|
|
|
58947
58880
|
rename as rename3,
|
|
58948
58881
|
unlink as unlink3
|
|
58949
58882
|
} from "fs/promises";
|
|
58950
|
-
import { existsSync as existsSync15, readFileSync as
|
|
58951
|
-
import { join as
|
|
58883
|
+
import { existsSync as existsSync15, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "fs";
|
|
58884
|
+
import { join as join28 } from "path";
|
|
58952
58885
|
var MAX_FAILED_RECORDS = 500;
|
|
58953
58886
|
var FLUSH_DEBOUNCE_MS = 15e3;
|
|
58954
58887
|
var MAX_UPLOADED_SEGMENTS = 50;
|
|
@@ -58960,7 +58893,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
58960
58893
|
options.storageName,
|
|
58961
58894
|
...options.legacyStorageNames ?? []
|
|
58962
58895
|
];
|
|
58963
|
-
this.liveFile =
|
|
58896
|
+
this.liveFile = join28(ENGINE_DIR2, `${options.storageName}.jsonl`);
|
|
58964
58897
|
this.segmentFilePatterns = this.storageNames.map(
|
|
58965
58898
|
(storageName) => new RegExp(`^${storageName}\\.(\\d+)\\.jsonl$`)
|
|
58966
58899
|
);
|
|
@@ -58996,9 +58929,9 @@ var AnalyticsRecordBuffer = class {
|
|
|
58996
58929
|
}
|
|
58997
58930
|
readStoredRecords() {
|
|
58998
58931
|
if (!existsSync15(ENGINE_DIR2)) return [];
|
|
58999
|
-
return
|
|
58932
|
+
return readdirSync2(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
|
|
59000
58933
|
(storageName) => entry.name === `${storageName}.jsonl` || entry.name.startsWith(`${storageName}.`) && (entry.name.endsWith(".jsonl") || entry.name.endsWith(`.jsonl${UPLOADED_SUFFIX}`))
|
|
59001
|
-
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(
|
|
58934
|
+
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync6(join28(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
|
|
59002
58935
|
const recordId = this.options.getRecordId?.(record3);
|
|
59003
58936
|
if (recordId) this.recordIds.add(recordId);
|
|
59004
58937
|
return record3;
|
|
@@ -59033,8 +58966,8 @@ var AnalyticsRecordBuffer = class {
|
|
|
59033
58966
|
}
|
|
59034
58967
|
for (const storageName of this.storageNames) {
|
|
59035
58968
|
await rename3(
|
|
59036
|
-
|
|
59037
|
-
|
|
58969
|
+
join28(ENGINE_DIR2, `${storageName}.jsonl`),
|
|
58970
|
+
join28(ENGINE_DIR2, `${storageName}.${Date.now()}.jsonl`)
|
|
59038
58971
|
).catch(() => {
|
|
59039
58972
|
});
|
|
59040
58973
|
}
|
|
@@ -59044,7 +58977,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59044
58977
|
for (const entry of entries) {
|
|
59045
58978
|
if (!this.segmentFilePatterns.some((pattern) => pattern.test(entry))) continue;
|
|
59046
58979
|
try {
|
|
59047
|
-
await this.uploadSegment(
|
|
58980
|
+
await this.uploadSegment(join28(ENGINE_DIR2, entry));
|
|
59048
58981
|
flushed++;
|
|
59049
58982
|
} catch (error) {
|
|
59050
58983
|
failed++;
|
|
@@ -59073,7 +59006,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59073
59006
|
(storageName) => entry.startsWith(`${storageName}.`)
|
|
59074
59007
|
) && entry.endsWith(UPLOADED_SUFFIX)).sort();
|
|
59075
59008
|
for (const entry of uploaded.slice(0, -MAX_UPLOADED_SEGMENTS)) {
|
|
59076
|
-
await unlink3(
|
|
59009
|
+
await unlink3(join28(ENGINE_DIR2, entry)).catch(() => {
|
|
59077
59010
|
});
|
|
59078
59011
|
}
|
|
59079
59012
|
}
|
|
@@ -59868,15 +59801,15 @@ var keepAliveService = new KeepAliveService();
|
|
|
59868
59801
|
// src/services/canvas-service.ts
|
|
59869
59802
|
import { readdir as readdir7, readFile as readFile17, stat as stat4 } from "fs/promises";
|
|
59870
59803
|
import { homedir as homedir13 } from "os";
|
|
59871
|
-
import { join as
|
|
59804
|
+
import { join as join29 } from "path";
|
|
59872
59805
|
|
|
59873
59806
|
// src/utils/contained-file.ts
|
|
59874
59807
|
import { realpath, stat as stat3 } from "fs/promises";
|
|
59875
|
-
import { resolve as
|
|
59808
|
+
import { resolve as resolve4 } from "path";
|
|
59876
59809
|
async function resolveContainedFile(root, relativePath) {
|
|
59877
59810
|
try {
|
|
59878
59811
|
const [fullPath, resolvedRoot] = await Promise.all([
|
|
59879
|
-
realpath(
|
|
59812
|
+
realpath(resolve4(root, relativePath)),
|
|
59880
59813
|
realpath(root)
|
|
59881
59814
|
]);
|
|
59882
59815
|
const fileStat = await stat3(fullPath);
|
|
@@ -59910,15 +59843,15 @@ async function writeRevisionedTextFile(filePath, content, expectedRevision) {
|
|
|
59910
59843
|
|
|
59911
59844
|
// src/services/canvas-service.ts
|
|
59912
59845
|
var GLOBAL_CANVAS_DIRECTORIES = [
|
|
59913
|
-
|
|
59914
|
-
|
|
59915
|
-
|
|
59846
|
+
join29(homedir13(), ".claude", "plans"),
|
|
59847
|
+
join29(process.env.XDG_DATA_HOME ?? join29(homedir13(), ".local", "share"), "opencode", "plans"),
|
|
59848
|
+
join29(homedir13(), ".replicas", "canvas")
|
|
59916
59849
|
];
|
|
59917
59850
|
async function canvasDirectories() {
|
|
59918
59851
|
const repositories = await gitService.listRepositories().catch(() => []);
|
|
59919
59852
|
return [
|
|
59920
59853
|
...GLOBAL_CANVAS_DIRECTORIES,
|
|
59921
|
-
...repositories.map((repository) =>
|
|
59854
|
+
...repositories.map((repository) => join29(repository.path, ".opencode", "plans"))
|
|
59922
59855
|
];
|
|
59923
59856
|
}
|
|
59924
59857
|
var CanvasService = class {
|
|
@@ -59943,7 +59876,7 @@ var CanvasService = class {
|
|
|
59943
59876
|
for (const entry of entries) {
|
|
59944
59877
|
if (entry.name.startsWith(".")) continue;
|
|
59945
59878
|
const filename = current.relativePath ? `${current.relativePath}/${entry.name}` : entry.name;
|
|
59946
|
-
const filePath =
|
|
59879
|
+
const filePath = join29(current.directory, entry.name);
|
|
59947
59880
|
if (entry.isDirectory()) {
|
|
59948
59881
|
pending.push({ directory: filePath, relativePath: filename });
|
|
59949
59882
|
continue;
|
|
@@ -59968,7 +59901,7 @@ var CanvasService = class {
|
|
|
59968
59901
|
if (!safe) return null;
|
|
59969
59902
|
const { kind, mimeType } = classifyCanvasFilename(safe);
|
|
59970
59903
|
for (const directory of await this.directories()) {
|
|
59971
|
-
const filePath =
|
|
59904
|
+
const filePath = join29(directory, safe);
|
|
59972
59905
|
let sizeBytes = 0;
|
|
59973
59906
|
let updatedAt = "";
|
|
59974
59907
|
try {
|
|
@@ -60045,7 +59978,7 @@ function isReconcileCanvasItemsResponse(value) {
|
|
|
60045
59978
|
}
|
|
60046
59979
|
async function withCanvasUploadSlot(operation) {
|
|
60047
59980
|
if (activeCanvasUploads >= MAX_CONCURRENT_CANVAS_UPLOADS) {
|
|
60048
|
-
await new Promise((
|
|
59981
|
+
await new Promise((resolve7) => pendingCanvasUploads.push(resolve7));
|
|
60049
59982
|
} else {
|
|
60050
59983
|
activeCanvasUploads++;
|
|
60051
59984
|
}
|
|
@@ -60152,13 +60085,13 @@ async function reconcileCanvasItems(filenames) {
|
|
|
60152
60085
|
import { createReadStream as createReadStream2 } from "fs";
|
|
60153
60086
|
import { createHash as createHash7 } from "crypto";
|
|
60154
60087
|
import { readFile as readFile18, readdir as readdir8, stat as stat5 } from "fs/promises";
|
|
60155
|
-
import { basename as basename3, join as
|
|
60088
|
+
import { basename as basename3, join as join31 } from "path";
|
|
60156
60089
|
|
|
60157
60090
|
// src/services/chat/chat-senders.ts
|
|
60158
|
-
import { join as
|
|
60159
|
-
var CHAT_SENDERS_DIR =
|
|
60091
|
+
import { join as join30 } from "path";
|
|
60092
|
+
var CHAT_SENDERS_DIR = join30(ENGINE_DIR2, "chat-senders");
|
|
60160
60093
|
function chatMessageSendersFilePath(chatId) {
|
|
60161
|
-
return
|
|
60094
|
+
return join30(CHAT_SENDERS_DIR, `${chatId}.jsonl`);
|
|
60162
60095
|
}
|
|
60163
60096
|
function parseChatMessageSendersJsonl(content) {
|
|
60164
60097
|
return content.split("\n").flatMap((line) => {
|
|
@@ -60201,7 +60134,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
60201
60134
|
const chat = chatsById.get(chatId);
|
|
60202
60135
|
if (!shouldFlushChatTranscript(dir, chat, chatsById)) continue;
|
|
60203
60136
|
tasks.push(
|
|
60204
|
-
uploadChatTranscript(chatId,
|
|
60137
|
+
uploadChatTranscript(chatId, join31(dir, entry), chat, capture).then((artifact) => {
|
|
60205
60138
|
flushed++;
|
|
60206
60139
|
if (artifact && capture) revisions.push(artifact);
|
|
60207
60140
|
}).catch((err) => {
|
|
@@ -60289,7 +60222,7 @@ async function uploadChatTranscriptNow(chatId, filePath, chat, capture) {
|
|
|
60289
60222
|
// src/services/upload-engine-logs.ts
|
|
60290
60223
|
import { createReadStream as createReadStream3 } from "fs";
|
|
60291
60224
|
import { readdir as readdir9, stat as stat6 } from "fs/promises";
|
|
60292
|
-
import { join as
|
|
60225
|
+
import { join as join32 } from "path";
|
|
60293
60226
|
var MAX_ENGINE_LOG_FLUSH_SESSIONS = 10;
|
|
60294
60227
|
var MAX_ENGINE_LOG_FLUSH_BYTES = 5 * 1024 * 1024;
|
|
60295
60228
|
var ENGINE_LOG_FLUSH_TIMEOUT_MS = 2e4;
|
|
@@ -60318,7 +60251,7 @@ async function flushAllEngineLogs() {
|
|
|
60318
60251
|
const candidates = (await Promise.all(filenames.slice(0, MAX_ENGINE_LOG_FLUSH_SESSIONS).map(async (filename) => {
|
|
60319
60252
|
try {
|
|
60320
60253
|
const sessionId = filename.slice(0, -".log".length);
|
|
60321
|
-
const filePath =
|
|
60254
|
+
const filePath = join32(LOG_DIR, filename);
|
|
60322
60255
|
const fileStat = await runBeforeDeadline(() => stat6(filePath), deadline);
|
|
60323
60256
|
if (!fileStat.isFile()) {
|
|
60324
60257
|
skipped++;
|
|
@@ -60383,13 +60316,13 @@ function runBeforeDeadline(operation, deadline) {
|
|
|
60383
60316
|
const timeoutMs = deadline - Date.now();
|
|
60384
60317
|
if (timeoutMs <= 0) return Promise.reject(new DOMException("engine log flush deadline exceeded", "TimeoutError"));
|
|
60385
60318
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
60386
|
-
return new Promise((
|
|
60319
|
+
return new Promise((resolve7, reject) => {
|
|
60387
60320
|
const onAbort = () => reject(signal.reason);
|
|
60388
60321
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
60389
60322
|
operation(signal).then(
|
|
60390
60323
|
(value) => {
|
|
60391
60324
|
signal.removeEventListener("abort", onAbort);
|
|
60392
|
-
|
|
60325
|
+
resolve7(value);
|
|
60393
60326
|
},
|
|
60394
60327
|
(error) => {
|
|
60395
60328
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -60414,8 +60347,9 @@ async function uploadEngineLog(input, timeoutMs) {
|
|
|
60414
60347
|
}
|
|
60415
60348
|
|
|
60416
60349
|
// src/services/chat/fork-handoff.ts
|
|
60350
|
+
import { createHash as createHash8 } from "crypto";
|
|
60417
60351
|
import { mkdir as mkdir19, open as open3, writeFile as writeFile10 } from "fs/promises";
|
|
60418
|
-
import { join as
|
|
60352
|
+
import { join as join33 } from "path";
|
|
60419
60353
|
var EXCERPT_MAX_CHARS = 24e3;
|
|
60420
60354
|
var MAX_SANITIZED_SOURCE_BYTES = 32 * 1024 * 1024;
|
|
60421
60355
|
function unansweredRequest(blocks) {
|
|
@@ -60449,8 +60383,21 @@ function tailBlocks(blocks, maxChars) {
|
|
|
60449
60383
|
const excerpt = start < blocks.length ? blocks.slice(start).join("\n\n") : `\u2026${blocks.at(-1)?.slice(-maxChars) ?? ""}`;
|
|
60450
60384
|
return { excerpt, truncated: start > 0 };
|
|
60451
60385
|
}
|
|
60386
|
+
function hashTranscriptBlocks(blocks) {
|
|
60387
|
+
return blocks.map((block) => createHash8("sha1").update(block).digest("base64"));
|
|
60388
|
+
}
|
|
60389
|
+
function unseenTurnsExcerpt(seenHashes, blocks) {
|
|
60390
|
+
const hashes = hashTranscriptBlocks(blocks);
|
|
60391
|
+
let common = 0;
|
|
60392
|
+
while (common < seenHashes.length && common < blocks.length && seenHashes[common] === hashes[common]) common++;
|
|
60393
|
+
if (common === blocks.length) return null;
|
|
60394
|
+
const { excerpt, truncated } = tailBlocks(blocks.slice(common), EXCERPT_MAX_CHARS);
|
|
60395
|
+
return truncated ? `${CHAT_FORK_EXCERPT_OMITTED_NOTICE}
|
|
60396
|
+
|
|
60397
|
+
${excerpt}` : excerpt;
|
|
60398
|
+
}
|
|
60452
60399
|
async function buildForkHandoff(input) {
|
|
60453
|
-
const rawHistoryPath =
|
|
60400
|
+
const rawHistoryPath = join33(HISTORY_DIR_BY_PROVIDER[input.sourceProvider], `${input.sourceChatId}.jsonl`);
|
|
60454
60401
|
const { content, truncated: sourceTruncated } = await readHistoryTail(rawHistoryPath, MAX_SANITIZED_SOURCE_BYTES);
|
|
60455
60402
|
let blocks = canonicalizeChatTranscriptBlocks(content, input.executionProvider, input.senders);
|
|
60456
60403
|
if (input.turnLimit !== void 0) {
|
|
@@ -60458,9 +60405,9 @@ async function buildForkHandoff(input) {
|
|
|
60458
60405
|
const start = blocks.findLastIndex((block) => block.startsWith("## User") && ++turns === input.turnLimit);
|
|
60459
60406
|
blocks = blocks.slice(Math.max(0, start));
|
|
60460
60407
|
}
|
|
60461
|
-
const forkDir =
|
|
60408
|
+
const forkDir = join33(FORKS_DIR, input.targetChatId);
|
|
60462
60409
|
await mkdir19(forkDir, { recursive: true });
|
|
60463
|
-
const transcriptPath =
|
|
60410
|
+
const transcriptPath = join33(forkDir, "source-transcript.md");
|
|
60464
60411
|
const header = sourceTruncated ? `_This file was generated from only the most recent ${MAX_SANITIZED_SOURCE_BYTES / 1024 / 1024} MB of the source chat.${input.turnLimit === void 0 ? ` The complete raw event log is at ${rawHistoryPath}; grep it for anything earlier.` : ""}_
|
|
60465
60412
|
|
|
60466
60413
|
` : "";
|
|
@@ -60471,6 +60418,7 @@ async function buildForkHandoff(input) {
|
|
|
60471
60418
|
excerpt,
|
|
60472
60419
|
excerptTruncated: truncated,
|
|
60473
60420
|
sourceTruncated,
|
|
60421
|
+
blocks,
|
|
60474
60422
|
resumeRequest: unansweredRequest(blocks),
|
|
60475
60423
|
transcriptPath,
|
|
60476
60424
|
rawHistoryPath: input.turnLimit === void 0 ? rawHistoryPath : void 0
|
|
@@ -60610,6 +60558,7 @@ var ChatService = class {
|
|
|
60610
60558
|
agentChatActivityTrackerService;
|
|
60611
60559
|
agentTokenUsageTracker;
|
|
60612
60560
|
chats = /* @__PURE__ */ new Map();
|
|
60561
|
+
sideChatSeenBlocks = /* @__PURE__ */ new Map();
|
|
60613
60562
|
persistPromise = null;
|
|
60614
60563
|
persistQueued = false;
|
|
60615
60564
|
async initialize() {
|
|
@@ -60704,6 +60653,13 @@ var ChatService = class {
|
|
|
60704
60653
|
throw new ChatNotFoundError(parentChatId);
|
|
60705
60654
|
}
|
|
60706
60655
|
const source = request.forkSourceChatId ? this.requireChat(request.forkSourceChatId) : void 0;
|
|
60656
|
+
if (request.sideChat) {
|
|
60657
|
+
for (const previous of this.chats.values()) {
|
|
60658
|
+
if (previous.persisted.parentChatId === parentChatId && previous.persisted.fork?.trigger === "side" && !previous.persisted.deletedAt) {
|
|
60659
|
+
await this.deleteChat(previous.persisted.id);
|
|
60660
|
+
}
|
|
60661
|
+
}
|
|
60662
|
+
}
|
|
60707
60663
|
const persisted = {
|
|
60708
60664
|
id: request.id ?? randomUUID11(),
|
|
60709
60665
|
provider: request.provider,
|
|
@@ -60718,7 +60674,7 @@ var ChatService = class {
|
|
|
60718
60674
|
displayName: request.title?.trim() || void 0,
|
|
60719
60675
|
model: getChatExecutionProvider(source.persisted) === (relayBaseProvider ?? request.provider) ? source.persisted.model : void 0,
|
|
60720
60676
|
pendingForkHandoff: true,
|
|
60721
|
-
fork: createForkInfo(source.persisted, "manual", now)
|
|
60677
|
+
fork: createForkInfo(source.persisted, request.sideChat ? "side" : "manual", now)
|
|
60722
60678
|
} : {}
|
|
60723
60679
|
};
|
|
60724
60680
|
const runtime = this.createRuntimeChat(persisted);
|
|
@@ -60818,8 +60774,8 @@ var ChatService = class {
|
|
|
60818
60774
|
if (result.status === "completed") return result;
|
|
60819
60775
|
const remainingMs = timeoutMs === null ? null : timeoutMs - (Date.now() - startedAt);
|
|
60820
60776
|
if (remainingMs !== null && remainingMs <= 0) return { ...result, timedOut: true };
|
|
60821
|
-
await new Promise((
|
|
60822
|
-
|
|
60777
|
+
await new Promise((resolve7) => setTimeout(
|
|
60778
|
+
resolve7,
|
|
60823
60779
|
remainingMs === null ? RELAY_SUBAGENT_POLL_INTERVAL_MS : Math.min(RELAY_SUBAGENT_POLL_INTERVAL_MS, remainingMs)
|
|
60824
60780
|
));
|
|
60825
60781
|
}
|
|
@@ -60838,10 +60794,12 @@ var ChatService = class {
|
|
|
60838
60794
|
const previousAcceptance = chat.lastSendAcceptance;
|
|
60839
60795
|
const accepting = (async () => {
|
|
60840
60796
|
chat.acceptingMessages += 1;
|
|
60797
|
+
let seenBeforeSend;
|
|
60841
60798
|
try {
|
|
60842
60799
|
await previousAcceptance?.catch(() => {
|
|
60843
60800
|
});
|
|
60844
|
-
|
|
60801
|
+
seenBeforeSend = this.sideChatSeenBlocks.get(chatId);
|
|
60802
|
+
if (chat.persisted.fork && (chat.persisted.pendingForkHandoff || chat.persisted.fork.trigger === "side")) {
|
|
60845
60803
|
request = {
|
|
60846
60804
|
...request,
|
|
60847
60805
|
message: await this.createForkHandoffMessage(chatId, {
|
|
@@ -60863,6 +60821,10 @@ var ChatService = class {
|
|
|
60863
60821
|
result
|
|
60864
60822
|
)
|
|
60865
60823
|
);
|
|
60824
|
+
} catch (error) {
|
|
60825
|
+
if (seenBeforeSend) this.sideChatSeenBlocks.set(chatId, seenBeforeSend);
|
|
60826
|
+
else this.sideChatSeenBlocks.delete(chatId);
|
|
60827
|
+
throw error;
|
|
60866
60828
|
} finally {
|
|
60867
60829
|
chat.acceptingMessages -= 1;
|
|
60868
60830
|
}
|
|
@@ -61229,14 +61191,14 @@ var ChatService = class {
|
|
|
61229
61191
|
return descendants;
|
|
61230
61192
|
}
|
|
61231
61193
|
async deleteHistoryFile(persisted) {
|
|
61232
|
-
const historyPath =
|
|
61194
|
+
const historyPath = join34(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
61233
61195
|
await Promise.all([
|
|
61234
61196
|
historyPath,
|
|
61235
61197
|
`${historyPath}.pages.jsonl`,
|
|
61236
61198
|
`${historyPath}.pages.index.json`
|
|
61237
61199
|
].map((path7) => rm4(path7, { force: true })));
|
|
61238
61200
|
await rm4(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
61239
|
-
await rm4(
|
|
61201
|
+
await rm4(join34(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
61240
61202
|
}
|
|
61241
61203
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
61242
61204
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
@@ -61273,7 +61235,12 @@ var ChatService = class {
|
|
|
61273
61235
|
senders: await this.readSenders(options.source.chatId),
|
|
61274
61236
|
turnLimit: options.turnLimit
|
|
61275
61237
|
});
|
|
61276
|
-
return formatChatForkHandoffMessage({ ...handoff, ...options });
|
|
61238
|
+
if (options.trigger !== "side") return formatChatForkHandoffMessage({ ...handoff, ...options });
|
|
61239
|
+
const seen = this.sideChatSeenBlocks.get(targetChatId);
|
|
61240
|
+
this.sideChatSeenBlocks.set(targetChatId, hashTranscriptBlocks(handoff.blocks));
|
|
61241
|
+
if (!seen) return formatChatForkHandoffMessage({ ...handoff, ...options });
|
|
61242
|
+
const unseen = unseenTurnsExcerpt(seen, handoff.blocks);
|
|
61243
|
+
return unseen ? formatSideChatUpdateMessage(options.source, unseen, options.message ?? "") : options.message ?? "";
|
|
61277
61244
|
}
|
|
61278
61245
|
async runFork(targetId, request, errorNotificationTargets) {
|
|
61279
61246
|
const target = this.chats.get(targetId);
|
|
@@ -61333,7 +61300,7 @@ var ChatService = class {
|
|
|
61333
61300
|
}
|
|
61334
61301
|
async autoForkAfterQuota(chat, exhaustion) {
|
|
61335
61302
|
const target = exhaustion.forkTo;
|
|
61336
|
-
if (!target || chat.persisted.deletedAt) return false;
|
|
61303
|
+
if (!target || chat.persisted.deletedAt || chat.persisted.fork?.trigger === "side") return false;
|
|
61337
61304
|
const alreadyForked = [...this.chats.values()].some((other) => other.persisted.fork?.trigger === "auto" && other.persisted.fork.source.chatId === chat.persisted.id && !other.persisted.deletedAt);
|
|
61338
61305
|
if (alreadyForked) return false;
|
|
61339
61306
|
const last = chat.lastSendRequest;
|
|
@@ -61432,7 +61399,7 @@ var ChatService = class {
|
|
|
61432
61399
|
const chatId = chat.persisted.id;
|
|
61433
61400
|
uploadChatTranscript(
|
|
61434
61401
|
chatId,
|
|
61435
|
-
|
|
61402
|
+
join34(HISTORY_DIR_BY_PROVIDER[chat.persisted.provider], `${chatId}.jsonl`),
|
|
61436
61403
|
this.toTranscriptSource(chat)
|
|
61437
61404
|
).catch((err) => {
|
|
61438
61405
|
console.error("[ChatService] Failed to upload chat transcript:", { chatId, err });
|
|
@@ -61535,7 +61502,7 @@ var ChatService = class {
|
|
|
61535
61502
|
}
|
|
61536
61503
|
const baseProvider = getChatExecutionProvider(persisted);
|
|
61537
61504
|
const additionalInstructions = persisted.provider === "relay" ? buildRelayInstructions(this.workingDirectory) : void 0;
|
|
61538
|
-
const historyFilePath =
|
|
61505
|
+
const historyFilePath = join34(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
61539
61506
|
const managerOptions = {
|
|
61540
61507
|
provider: baseProvider,
|
|
61541
61508
|
workingDirectory: this.workingDirectory,
|
|
@@ -61947,9 +61914,9 @@ import { extname as extname3 } from "path";
|
|
|
61947
61914
|
|
|
61948
61915
|
// src/services/language-server-service.ts
|
|
61949
61916
|
import { spawn as spawn6 } from "child_process";
|
|
61950
|
-
import { existsSync as existsSync16, readFileSync as
|
|
61917
|
+
import { existsSync as existsSync16, readFileSync as readFileSync7 } from "fs";
|
|
61951
61918
|
import { createRequire as createRequire5 } from "module";
|
|
61952
|
-
import { delimiter as delimiter2, dirname as dirname17, join as
|
|
61919
|
+
import { delimiter as delimiter2, dirname as dirname17, join as join35, relative as relative2 } from "path";
|
|
61953
61920
|
import { setTimeout as setTimeout3 } from "timers/promises";
|
|
61954
61921
|
import { fileURLToPath as fileURLToPath5, pathToFileURL } from "url";
|
|
61955
61922
|
import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node.js";
|
|
@@ -61987,7 +61954,7 @@ var LANGUAGE_SERVERS = {
|
|
|
61987
61954
|
};
|
|
61988
61955
|
function packageBin(packageName, binName) {
|
|
61989
61956
|
const packageJsonPath = require5.resolve(`${packageName}/package.json`);
|
|
61990
|
-
const packageJson = JSON.parse(
|
|
61957
|
+
const packageJson = JSON.parse(readFileSync7(packageJsonPath, "utf8"));
|
|
61991
61958
|
const bin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin[binName];
|
|
61992
61959
|
if (!bin) throw new Error(`Missing ${binName} binary`);
|
|
61993
61960
|
return `${dirname17(packageJsonPath)}/${bin}`;
|
|
@@ -62068,7 +62035,7 @@ var LanguageServerService = class {
|
|
|
62068
62035
|
if (config.package && config.bin) command = process.execPath;
|
|
62069
62036
|
else if (config.command) {
|
|
62070
62037
|
const commandName = config.command;
|
|
62071
|
-
command = process.env.PATH?.split(delimiter2).map((directory) =>
|
|
62038
|
+
command = process.env.PATH?.split(delimiter2).map((directory) => join35(directory, commandName)).find(existsSync16);
|
|
62072
62039
|
}
|
|
62073
62040
|
const args = config.package && config.bin ? [packageBin(config.package, config.bin), ...config.args] : config.args;
|
|
62074
62041
|
if (!command) return null;
|
|
@@ -62091,7 +62058,7 @@ var LanguageServerService = class {
|
|
|
62091
62058
|
const absolutePath = fileURLToPath5(uri);
|
|
62092
62059
|
const path7 = relative2(repoPath, absolutePath);
|
|
62093
62060
|
if (path7.startsWith("..")) return [];
|
|
62094
|
-
const preview =
|
|
62061
|
+
const preview = readFileSync7(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
|
|
62095
62062
|
return [{ repoName, path: path7, line: range.start.line + 1, character: range.start.character, endCharacter: range.end.character, preview }];
|
|
62096
62063
|
});
|
|
62097
62064
|
return { symbol: "", detail: null, documentation: null, locations, provider: "language-server" };
|
|
@@ -62144,7 +62111,7 @@ function isBinaryExtension(filePath) {
|
|
|
62144
62111
|
return classifyCanvasFilename(filePath).kind === "image" || binaryExts.has(ext);
|
|
62145
62112
|
}
|
|
62146
62113
|
function execGitAsync(args, cwd, timeoutMs) {
|
|
62147
|
-
return new Promise((
|
|
62114
|
+
return new Promise((resolve7, reject) => {
|
|
62148
62115
|
const child = execFile7("git", args, {
|
|
62149
62116
|
cwd,
|
|
62150
62117
|
encoding: "utf-8",
|
|
@@ -62154,7 +62121,7 @@ function execGitAsync(args, cwd, timeoutMs) {
|
|
|
62154
62121
|
if (error) {
|
|
62155
62122
|
reject(error);
|
|
62156
62123
|
} else {
|
|
62157
|
-
|
|
62124
|
+
resolve7(stdout);
|
|
62158
62125
|
}
|
|
62159
62126
|
});
|
|
62160
62127
|
child.stdin?.end();
|
|
@@ -62410,20 +62377,20 @@ var RepoFileService = class {
|
|
|
62410
62377
|
import { Hono } from "hono";
|
|
62411
62378
|
import { z as z4 } from "zod";
|
|
62412
62379
|
import { readdir as readdir11, stat as stat7, readFile as readFile23 } from "fs/promises";
|
|
62413
|
-
import { join as
|
|
62380
|
+
import { join as join38, resolve as resolve5 } from "path";
|
|
62414
62381
|
|
|
62415
62382
|
// src/services/warm-hooks-service.ts
|
|
62416
62383
|
import { spawn as spawn7 } from "child_process";
|
|
62417
62384
|
import { readFile as readFile22 } from "fs/promises";
|
|
62418
62385
|
import { existsSync as existsSync17 } from "fs";
|
|
62419
|
-
import { join as
|
|
62386
|
+
import { join as join37 } from "path";
|
|
62420
62387
|
|
|
62421
62388
|
// src/services/warm-hook-logs-service.ts
|
|
62422
62389
|
import { mkdir as mkdir21, readFile as readFile21, writeFile as writeFile11, readdir as readdir10, appendFile as appendFile6, unlink as unlink4 } from "fs/promises";
|
|
62423
62390
|
import { homedir as homedir14 } from "os";
|
|
62424
|
-
import { join as
|
|
62425
|
-
var LOGS_DIR2 =
|
|
62426
|
-
var CURRENT_RUN_LOG =
|
|
62391
|
+
import { join as join36 } from "path";
|
|
62392
|
+
var LOGS_DIR2 = join36(homedir14(), ".replicas", "warm-hook-logs");
|
|
62393
|
+
var CURRENT_RUN_LOG = join36(LOGS_DIR2, "current-run.log");
|
|
62427
62394
|
var GLOBAL_FILENAME = "global.json";
|
|
62428
62395
|
function withPreview2(stored) {
|
|
62429
62396
|
const preview = buildHookOutputPreview(stored.output);
|
|
@@ -62440,7 +62407,7 @@ var WarmHookLogsService = class {
|
|
|
62440
62407
|
hookName: "organization",
|
|
62441
62408
|
...entry
|
|
62442
62409
|
};
|
|
62443
|
-
await writeFile11(
|
|
62410
|
+
await writeFile11(join36(LOGS_DIR2, GLOBAL_FILENAME), `${JSON.stringify(log, null, 2)}
|
|
62444
62411
|
`, "utf-8");
|
|
62445
62412
|
}
|
|
62446
62413
|
async saveEnvironmentHookLog(entry) {
|
|
@@ -62450,7 +62417,7 @@ var WarmHookLogsService = class {
|
|
|
62450
62417
|
hookName: "environment",
|
|
62451
62418
|
...entry
|
|
62452
62419
|
};
|
|
62453
|
-
await writeFile11(
|
|
62420
|
+
await writeFile11(join36(LOGS_DIR2, ENVIRONMENT_HOOK_LOG_FILENAME), `${JSON.stringify(log, null, 2)}
|
|
62454
62421
|
`, "utf-8");
|
|
62455
62422
|
}
|
|
62456
62423
|
async saveRepoHookLog(repoName, entry) {
|
|
@@ -62460,7 +62427,7 @@ var WarmHookLogsService = class {
|
|
|
62460
62427
|
hookName: repoName,
|
|
62461
62428
|
...entry
|
|
62462
62429
|
};
|
|
62463
|
-
await writeFile11(
|
|
62430
|
+
await writeFile11(join36(LOGS_DIR2, repoHookLogFilename(repoName)), `${JSON.stringify(log, null, 2)}
|
|
62464
62431
|
`, "utf-8");
|
|
62465
62432
|
}
|
|
62466
62433
|
async getAllLogs() {
|
|
@@ -62479,7 +62446,7 @@ var WarmHookLogsService = class {
|
|
|
62479
62446
|
continue;
|
|
62480
62447
|
}
|
|
62481
62448
|
try {
|
|
62482
|
-
const raw = await readFile21(
|
|
62449
|
+
const raw = await readFile21(join36(LOGS_DIR2, file), "utf-8");
|
|
62483
62450
|
const stored = JSON.parse(raw);
|
|
62484
62451
|
logs.push(withPreview2(stored));
|
|
62485
62452
|
} catch {
|
|
@@ -62517,7 +62484,7 @@ var WarmHookLogsService = class {
|
|
|
62517
62484
|
async getFullOutput(hookType, hookName) {
|
|
62518
62485
|
const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
62519
62486
|
try {
|
|
62520
|
-
const raw = await readFile21(
|
|
62487
|
+
const raw = await readFile21(join36(LOGS_DIR2, filename), "utf-8");
|
|
62521
62488
|
const stored = JSON.parse(raw);
|
|
62522
62489
|
if (stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
62523
62490
|
return null;
|
|
@@ -62536,7 +62503,7 @@ var warmHookLogsService = new WarmHookLogsService();
|
|
|
62536
62503
|
// src/services/warm-hooks-service.ts
|
|
62537
62504
|
async function readRepoWarmHook(repoPath) {
|
|
62538
62505
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
62539
|
-
const configPath =
|
|
62506
|
+
const configPath = join37(repoPath, filename);
|
|
62540
62507
|
if (!existsSync17(configPath)) {
|
|
62541
62508
|
continue;
|
|
62542
62509
|
}
|
|
@@ -62587,7 +62554,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
62587
62554
|
let bufferExceeded = false;
|
|
62588
62555
|
params.onChunk(`$ ${params.label}
|
|
62589
62556
|
`);
|
|
62590
|
-
return new Promise((
|
|
62557
|
+
return new Promise((resolve7) => {
|
|
62591
62558
|
const proc = spawn7("bash", ["-lc", params.content], {
|
|
62592
62559
|
cwd: params.cwd,
|
|
62593
62560
|
env: process.env,
|
|
@@ -62620,7 +62587,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
62620
62587
|
proc.on("close", (code) => {
|
|
62621
62588
|
clearTimeout(timer);
|
|
62622
62589
|
const output = [`$ ${params.label}`, ...outputParts].join("");
|
|
62623
|
-
|
|
62590
|
+
resolve7({
|
|
62624
62591
|
exitCode: bufferExceeded ? 1 : code ?? 1,
|
|
62625
62592
|
output,
|
|
62626
62593
|
timedOut: killed && !bufferExceeded
|
|
@@ -62630,7 +62597,7 @@ async function executeHookScriptStreaming(params) {
|
|
|
62630
62597
|
clearTimeout(timer);
|
|
62631
62598
|
const output = [`$ ${params.label}
|
|
62632
62599
|
`, ...outputParts, err.message].join("");
|
|
62633
|
-
|
|
62600
|
+
resolve7({
|
|
62634
62601
|
exitCode: 1,
|
|
62635
62602
|
output,
|
|
62636
62603
|
timedOut: false
|
|
@@ -63896,7 +63863,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
63896
63863
|
const logFiles = files.filter((f) => f.endsWith(".log"));
|
|
63897
63864
|
const sessions = await Promise.all(
|
|
63898
63865
|
logFiles.map(async (filename) => {
|
|
63899
|
-
const filePath =
|
|
63866
|
+
const filePath = join38(LOG_DIR, filename);
|
|
63900
63867
|
const fileStat = await stat7(filePath);
|
|
63901
63868
|
const sessionId = filename.replace(/\.log$/, "");
|
|
63902
63869
|
return {
|
|
@@ -63925,8 +63892,8 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
63925
63892
|
if (!isValidEngineLogSessionId(sessionId)) {
|
|
63926
63893
|
return c.json(jsonError("Invalid session ID"), 400);
|
|
63927
63894
|
}
|
|
63928
|
-
const filePath =
|
|
63929
|
-
if (!filePath.startsWith(
|
|
63895
|
+
const filePath = resolve5(LOG_DIR, `${sessionId}.log`);
|
|
63896
|
+
if (!filePath.startsWith(resolve5(LOG_DIR))) {
|
|
63930
63897
|
return c.json(jsonError("Invalid session ID"), 400);
|
|
63931
63898
|
}
|
|
63932
63899
|
let content;
|
|
@@ -64007,12 +63974,12 @@ var heartbeatService = new HeartbeatService();
|
|
|
64007
63974
|
|
|
64008
63975
|
// src/services/workspace-sdk-service.ts
|
|
64009
63976
|
import { cp, mkdir as mkdir22 } from "fs/promises";
|
|
64010
|
-
import { dirname as dirname18, resolve as
|
|
63977
|
+
import { dirname as dirname18, resolve as resolve6 } from "path";
|
|
64011
63978
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
64012
63979
|
async function installWorkspaceSdk() {
|
|
64013
|
-
const source =
|
|
63980
|
+
const source = resolve6(dirname18(fileURLToPath6(import.meta.url)), "../../workspace-sdk");
|
|
64014
63981
|
const targets = [
|
|
64015
|
-
|
|
63982
|
+
resolve6(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
|
|
64016
63983
|
"/tmp/node_modules/@replicas/sdk"
|
|
64017
63984
|
];
|
|
64018
63985
|
await Promise.all(targets.map(async (target) => {
|
|
@@ -64066,11 +64033,11 @@ async function checkActiveSSHSessions() {
|
|
|
64066
64033
|
}
|
|
64067
64034
|
}
|
|
64068
64035
|
function checkDesktopReady() {
|
|
64069
|
-
return new Promise((
|
|
64036
|
+
return new Promise((resolve7) => {
|
|
64070
64037
|
const socket = connect({ host: "127.0.0.1", port: DESKTOP_STREAM_PORT });
|
|
64071
64038
|
const done = (ready) => {
|
|
64072
64039
|
socket.destroy();
|
|
64073
|
-
|
|
64040
|
+
resolve7(ready);
|
|
64074
64041
|
};
|
|
64075
64042
|
socket.once("connect", () => done(true));
|
|
64076
64043
|
socket.once("error", () => done(false));
|