replicas-engine 0.1.815 → 0.1.816
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-LHDELXWM.js → asp-host-GPNVHNDJ.js} +2 -2
- package/dist/src/chunk-JA23HN6S.js +46 -0
- package/dist/src/{chunk-WRUZSBSF.js → chunk-QIDTIQQU.js} +2 -2
- package/dist/src/{chunk-UUQYVSQY.js → chunk-T7RJYRCH.js} +1 -1
- package/dist/src/headless-agent.js +1 -1
- package/dist/src/index.js +223 -250
- package/dist/src/relay-mcp.js +4 -1
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -114,6 +114,13 @@ import {
|
|
|
114
114
|
putPresignedFile,
|
|
115
115
|
recoverCompletedTurn
|
|
116
116
|
} from "./chunk-FLDA7BX3.js";
|
|
117
|
+
import {
|
|
118
|
+
RELAY_MCP_SERVER_NAME,
|
|
119
|
+
RELAY_MCP_TOOL_NAMES,
|
|
120
|
+
RELAY_MCP_TOOL_TIMEOUT_MS,
|
|
121
|
+
relayCodexMcpConfig,
|
|
122
|
+
relayMcpProcessConfig
|
|
123
|
+
} from "./chunk-JA23HN6S.js";
|
|
117
124
|
import {
|
|
118
125
|
BaseRefreshManager,
|
|
119
126
|
CodexAspAuthMethodChangedError,
|
|
@@ -124,7 +131,7 @@ import {
|
|
|
124
131
|
recordCredentialFallback,
|
|
125
132
|
recordExhaustedCredential,
|
|
126
133
|
restartCodexAspHost
|
|
127
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-QIDTIQQU.js";
|
|
128
135
|
import {
|
|
129
136
|
ENGINE_ENV,
|
|
130
137
|
IS_WARMING_MODE,
|
|
@@ -137,7 +144,7 @@ import {
|
|
|
137
144
|
SUBPROCESS_MAX_BUFFER,
|
|
138
145
|
execAsync,
|
|
139
146
|
execFileAsync
|
|
140
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-T7RJYRCH.js";
|
|
141
148
|
import {
|
|
142
149
|
isRecord as isRecord2
|
|
143
150
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -8535,7 +8542,7 @@ var require_dist2 = __commonJS({
|
|
|
8535
8542
|
// src/index.ts
|
|
8536
8543
|
import { serve } from "@hono/node-server";
|
|
8537
8544
|
import { Hono as Hono2 } from "hono";
|
|
8538
|
-
import { existsSync as
|
|
8545
|
+
import { existsSync as existsSync20 } from "fs";
|
|
8539
8546
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
8540
8547
|
import { connect } from "net";
|
|
8541
8548
|
|
|
@@ -10679,7 +10686,7 @@ async function registerDesktopPreview() {
|
|
|
10679
10686
|
|
|
10680
10687
|
// src/services/chat/chat-service.ts
|
|
10681
10688
|
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir21, readFile as readFile22, rename as rename4, rm as rm4 } from "fs/promises";
|
|
10682
|
-
import { join as
|
|
10689
|
+
import { join as join36 } from "path";
|
|
10683
10690
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
10684
10691
|
|
|
10685
10692
|
// ../shared/src/workspace-chat.ts
|
|
@@ -10856,7 +10863,7 @@ import {
|
|
|
10856
10863
|
query
|
|
10857
10864
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
10858
10865
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
10859
|
-
import { dirname as
|
|
10866
|
+
import { dirname as dirname4, join as join16 } from "path";
|
|
10860
10867
|
import { mkdir as mkdir10 } from "fs/promises";
|
|
10861
10868
|
import { homedir as homedir11 } from "os";
|
|
10862
10869
|
|
|
@@ -12581,40 +12588,6 @@ var ClaudeBackgroundTasks = class {
|
|
|
12581
12588
|
}
|
|
12582
12589
|
};
|
|
12583
12590
|
|
|
12584
|
-
// src/managers/relay-mcp-config.ts
|
|
12585
|
-
import { existsSync as existsSync7 } from "fs";
|
|
12586
|
-
import { dirname as dirname4, join as join16 } from "path";
|
|
12587
|
-
import { fileURLToPath } from "url";
|
|
12588
|
-
import { createRequire } from "module";
|
|
12589
|
-
var RELAY_MCP_TOOL_NAMES = ["get_providers", "spawn_agent", "message_agent", "delete_agent"];
|
|
12590
|
-
var RELAY_MCP_TOOL_TIMEOUT_MS = 24 * 60 * 60 * 1e3 + 6e4;
|
|
12591
|
-
function relayMcpProcessConfig(parentChatId) {
|
|
12592
|
-
const directory = dirname4(fileURLToPath(import.meta.url));
|
|
12593
|
-
const builtEntry = join16(directory, "relay-mcp.js");
|
|
12594
|
-
const sourceEntry = join16(directory, "..", "relay-mcp.ts");
|
|
12595
|
-
const entry = existsSync7(builtEntry) ? builtEntry : sourceEntry;
|
|
12596
|
-
return {
|
|
12597
|
-
command: process.execPath,
|
|
12598
|
-
args: [
|
|
12599
|
-
...entry.endsWith(".ts") ? ["--import", createRequire(import.meta.url).resolve("tsx/esm")] : [],
|
|
12600
|
-
entry,
|
|
12601
|
-
"--parent",
|
|
12602
|
-
parentChatId
|
|
12603
|
-
]
|
|
12604
|
-
};
|
|
12605
|
-
}
|
|
12606
|
-
function relayCodexMcpConfig(parentChatId) {
|
|
12607
|
-
return {
|
|
12608
|
-
...relayMcpProcessConfig(parentChatId),
|
|
12609
|
-
env_vars: ["REPLICAS_ENGINE_PORT", "REPLICAS_ENGINE_SECRET"],
|
|
12610
|
-
enabled_tools: [...RELAY_MCP_TOOL_NAMES],
|
|
12611
|
-
required: true,
|
|
12612
|
-
default_tools_approval_mode: "approve",
|
|
12613
|
-
startup_timeout_sec: 10,
|
|
12614
|
-
tool_timeout_sec: Math.ceil(RELAY_MCP_TOOL_TIMEOUT_MS / 1e3)
|
|
12615
|
-
};
|
|
12616
|
-
}
|
|
12617
|
-
|
|
12618
12591
|
// src/managers/claude-manager.ts
|
|
12619
12592
|
var PromptStream = class {
|
|
12620
12593
|
queue = [];
|
|
@@ -12878,7 +12851,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
12878
12851
|
authRetrying = false;
|
|
12879
12852
|
constructor(options) {
|
|
12880
12853
|
super({ ...options, provider: AGENT.CLAUDE });
|
|
12881
|
-
this.historyFilePath = options.historyFilePath ??
|
|
12854
|
+
this.historyFilePath = options.historyFilePath ?? join16(homedir11(), ".replicas", "claude", "history.jsonl");
|
|
12882
12855
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
12883
12856
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
12884
12857
|
}
|
|
@@ -13422,7 +13395,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13422
13395
|
const interactiveAllowed = enableInteractiveTools && resolvedPermissionMode === "plan";
|
|
13423
13396
|
const allowedTools = [
|
|
13424
13397
|
...ALWAYS_ALLOWED_TOOLS.filter((tool) => !this.isRelay || tool !== "Agent"),
|
|
13425
|
-
...this.isRelay ? RELAY_MCP_TOOL_NAMES.map((tool) => `
|
|
13398
|
+
...this.isRelay ? RELAY_MCP_TOOL_NAMES.map((tool) => `mcp__${RELAY_MCP_SERVER_NAME}__${tool}`) : [],
|
|
13426
13399
|
...interactiveAllowed ? INTERACTIVE_TOOL_NAMES : []
|
|
13427
13400
|
];
|
|
13428
13401
|
const disallowedTools = [
|
|
@@ -13443,7 +13416,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13443
13416
|
...disallowedTools.length > 0 ? { disallowedTools } : {},
|
|
13444
13417
|
settingSources: ["user", "project", "local"],
|
|
13445
13418
|
systemPrompt,
|
|
13446
|
-
...this.relayParentChatId ? { mcpServers: {
|
|
13419
|
+
...this.relayParentChatId ? { mcpServers: { [RELAY_MCP_SERVER_NAME]: { type: "stdio", alwaysLoad: true, ...relayMcpProcessConfig(this.relayParentChatId) } } } : {},
|
|
13447
13420
|
...shared.plugins.length > 0 ? { plugins: shared.plugins } : {},
|
|
13448
13421
|
...shared.enableAllSkills ? { skills: "all" } : {},
|
|
13449
13422
|
env: shared.env,
|
|
@@ -13991,7 +13964,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13991
13964
|
}
|
|
13992
13965
|
}
|
|
13993
13966
|
async initialize() {
|
|
13994
|
-
await mkdir10(
|
|
13967
|
+
await mkdir10(dirname4(this.historyFilePath), { recursive: true });
|
|
13995
13968
|
if (this.initialSessionId) {
|
|
13996
13969
|
this.sessionId = this.initialSessionId;
|
|
13997
13970
|
console.log(`[ClaudeManager] Restored session ID from persisted state: ${this.sessionId}`);
|
|
@@ -14040,7 +14013,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14040
14013
|
|
|
14041
14014
|
// src/managers/codex-asp/codex-asp-manager.ts
|
|
14042
14015
|
import { readdir as readdir4 } from "fs/promises";
|
|
14043
|
-
import { join as
|
|
14016
|
+
import { join as join18 } from "path";
|
|
14044
14017
|
|
|
14045
14018
|
// src/utils/codex-quota.ts
|
|
14046
14019
|
function buildCodexRateLimitsSnapshot(fields) {
|
|
@@ -14104,7 +14077,7 @@ var CodexQuotaStatusTracker = class {
|
|
|
14104
14077
|
};
|
|
14105
14078
|
|
|
14106
14079
|
// src/managers/codex-asp/mappers.ts
|
|
14107
|
-
import { existsSync as
|
|
14080
|
+
import { existsSync as existsSync7, readFileSync as readFileSync3 } from "fs";
|
|
14108
14081
|
var localImageCache = /* @__PURE__ */ new Map();
|
|
14109
14082
|
var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
|
|
14110
14083
|
var THREAD_START_METHOD = "thread/start";
|
|
@@ -14228,7 +14201,7 @@ function transcriptItemsForTurn(turn) {
|
|
|
14228
14201
|
function userImageForLocalPath(path7) {
|
|
14229
14202
|
const cached = localImageCache.get(path7);
|
|
14230
14203
|
if (cached) return cached;
|
|
14231
|
-
if (!
|
|
14204
|
+
if (!existsSync7(path7)) return null;
|
|
14232
14205
|
const image = {
|
|
14233
14206
|
type: "image",
|
|
14234
14207
|
mediaType: inferMediaType(path7),
|
|
@@ -14607,7 +14580,7 @@ async function buildThreadStartParams(workingDirectory, request, developerInstru
|
|
|
14607
14580
|
model_reasoning_summary: "auto",
|
|
14608
14581
|
...relayParentChatId ? {
|
|
14609
14582
|
features: { multi_agent: false },
|
|
14610
|
-
|
|
14583
|
+
[`mcp_servers.${RELAY_MCP_SERVER_NAME}`]: relayCodexMcpConfig(relayParentChatId)
|
|
14611
14584
|
} : {}
|
|
14612
14585
|
},
|
|
14613
14586
|
experimentalRawEvents: false
|
|
@@ -14629,7 +14602,7 @@ async function buildThreadResumeParams(workingDirectory, threadId, request, deve
|
|
|
14629
14602
|
model_reasoning_summary: "auto",
|
|
14630
14603
|
...relayParentChatId ? {
|
|
14631
14604
|
features: { multi_agent: false },
|
|
14632
|
-
|
|
14605
|
+
[`mcp_servers.${RELAY_MCP_SERVER_NAME}`]: relayCodexMcpConfig(relayParentChatId)
|
|
14633
14606
|
} : {}
|
|
14634
14607
|
},
|
|
14635
14608
|
excludeTurns: false
|
|
@@ -14738,20 +14711,20 @@ var TranscriptUpdateCoalescer = class {
|
|
|
14738
14711
|
|
|
14739
14712
|
// src/services/chat/history-paths.ts
|
|
14740
14713
|
import { homedir as homedir12 } from "os";
|
|
14741
|
-
import { join as
|
|
14742
|
-
var ENGINE_DIR2 =
|
|
14743
|
-
var CHATS_FILE =
|
|
14744
|
-
var CLAUDE_HISTORY_DIR =
|
|
14745
|
-
var RELAY_HISTORY_DIR =
|
|
14746
|
-
var CODEX_HISTORY_DIR =
|
|
14747
|
-
var CURSOR_HISTORY_DIR =
|
|
14748
|
-
var OPENCODE_HISTORY_DIR =
|
|
14749
|
-
var PI_HISTORY_DIR =
|
|
14750
|
-
var DEEPSEEK_HISTORY_DIR =
|
|
14751
|
-
var FX_HISTORY_DIR =
|
|
14752
|
-
var KIMI_HISTORY_DIR =
|
|
14753
|
-
var MUSE_HISTORY_DIR =
|
|
14754
|
-
var FORKS_DIR =
|
|
14714
|
+
import { join as join17 } from "path";
|
|
14715
|
+
var ENGINE_DIR2 = join17(homedir12(), ".replicas", "engine");
|
|
14716
|
+
var CHATS_FILE = join17(ENGINE_DIR2, "chats.json");
|
|
14717
|
+
var CLAUDE_HISTORY_DIR = join17(ENGINE_DIR2, "claude-histories");
|
|
14718
|
+
var RELAY_HISTORY_DIR = join17(ENGINE_DIR2, "relay-histories");
|
|
14719
|
+
var CODEX_HISTORY_DIR = join17(ENGINE_DIR2, "codex-histories");
|
|
14720
|
+
var CURSOR_HISTORY_DIR = join17(ENGINE_DIR2, "cursor-histories");
|
|
14721
|
+
var OPENCODE_HISTORY_DIR = join17(ENGINE_DIR2, "opencode-histories");
|
|
14722
|
+
var PI_HISTORY_DIR = join17(ENGINE_DIR2, "pi-histories");
|
|
14723
|
+
var DEEPSEEK_HISTORY_DIR = join17(ENGINE_DIR2, "deepseek-histories");
|
|
14724
|
+
var FX_HISTORY_DIR = join17(ENGINE_DIR2, "fx-histories");
|
|
14725
|
+
var KIMI_HISTORY_DIR = join17(ENGINE_DIR2, "kimi-histories");
|
|
14726
|
+
var MUSE_HISTORY_DIR = join17(ENGINE_DIR2, "muse-histories");
|
|
14727
|
+
var FORKS_DIR = join17(ENGINE_DIR2, "forks");
|
|
14755
14728
|
var HISTORY_DIR_BY_PROVIDER = {
|
|
14756
14729
|
claude: CLAUDE_HISTORY_DIR,
|
|
14757
14730
|
relay: RELAY_HISTORY_DIR,
|
|
@@ -14824,7 +14797,7 @@ async function readCodexAspThreadHistory(threadId) {
|
|
|
14824
14797
|
}
|
|
14825
14798
|
for (const entry of entries) {
|
|
14826
14799
|
if (!entry.isFile() || !entry.name.endsWith(".jsonl") || entry.name.endsWith(".pages.jsonl")) continue;
|
|
14827
|
-
const history = await new CodexHistoryFile(
|
|
14800
|
+
const history = await new CodexHistoryFile(join18(CODEX_HISTORY_DIR, entry.name)).load();
|
|
14828
14801
|
const transcript = history.transcriptsByThreadId.get(threadId);
|
|
14829
14802
|
if (transcript) {
|
|
14830
14803
|
return {
|
|
@@ -16230,24 +16203,24 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
16230
16203
|
|
|
16231
16204
|
// src/managers/cursor-manager.ts
|
|
16232
16205
|
import { mkdir as mkdir12, readFile as readFile12, readdir as readdir5 } from "fs/promises";
|
|
16233
|
-
import { basename as basename2, dirname as
|
|
16206
|
+
import { basename as basename2, dirname as dirname6, extname, join as join20 } from "path";
|
|
16234
16207
|
import { parse as parseYaml } from "yaml";
|
|
16235
16208
|
import { Agent as CursorAgent2 } from "@cursor/sdk";
|
|
16236
16209
|
|
|
16237
16210
|
// src/services/native-command-protection-hooks.ts
|
|
16238
|
-
import { existsSync as
|
|
16211
|
+
import { existsSync as existsSync8 } from "fs";
|
|
16239
16212
|
import { mkdir as mkdir11, readFile as readFile11, writeFile as writeFile6 } from "fs/promises";
|
|
16240
|
-
import { basename, dirname as
|
|
16241
|
-
import { fileURLToPath
|
|
16242
|
-
var moduleDirectory =
|
|
16213
|
+
import { basename, dirname as dirname5, join as join19 } from "path";
|
|
16214
|
+
import { fileURLToPath } from "url";
|
|
16215
|
+
var moduleDirectory = dirname5(fileURLToPath(import.meta.url));
|
|
16243
16216
|
var hookPath = [
|
|
16244
|
-
|
|
16245
|
-
|
|
16246
|
-
].find(
|
|
16217
|
+
join19(moduleDirectory, "command-protection-hook.js"),
|
|
16218
|
+
join19(moduleDirectory, "..", "command-protection-hook.ts")
|
|
16219
|
+
].find(existsSync8);
|
|
16247
16220
|
var postToolHookPath = [
|
|
16248
|
-
|
|
16249
|
-
|
|
16250
|
-
].find(
|
|
16221
|
+
join19(moduleDirectory, "post-tool-pr-hook.js"),
|
|
16222
|
+
join19(moduleDirectory, "..", "post-tool-pr-hook.ts")
|
|
16223
|
+
].find(existsSync8);
|
|
16251
16224
|
function shellCommand(path7, provider) {
|
|
16252
16225
|
if (!path7) throw new Error("Replicas hook executable is missing.");
|
|
16253
16226
|
const args = [
|
|
@@ -16267,7 +16240,7 @@ function getPostToolPrHookPath() {
|
|
|
16267
16240
|
return postToolHookPath;
|
|
16268
16241
|
}
|
|
16269
16242
|
async function ensureCursorCommandProtectionHook() {
|
|
16270
|
-
const path7 =
|
|
16243
|
+
const path7 = join19(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
16271
16244
|
let config = {};
|
|
16272
16245
|
try {
|
|
16273
16246
|
const parsed = JSON.parse(await readFile11(path7, "utf8"));
|
|
@@ -16287,12 +16260,12 @@ async function ensureCursorCommandProtectionHook() {
|
|
|
16287
16260
|
...existingPost.filter((entry) => !isRecord2(entry) || typeof entry.command !== "string" || !entry.command.includes("post-tool-pr-hook")),
|
|
16288
16261
|
{ command: shellCommand(postToolHookPath) }
|
|
16289
16262
|
];
|
|
16290
|
-
await mkdir11(
|
|
16263
|
+
await mkdir11(dirname5(path7), { recursive: true });
|
|
16291
16264
|
await writeFile6(path7, `${JSON.stringify({ ...config, version: 1, hooks }, null, 2)}
|
|
16292
16265
|
`, "utf8");
|
|
16293
16266
|
}
|
|
16294
16267
|
async function ensureKimiCommandProtectionHook() {
|
|
16295
|
-
const path7 =
|
|
16268
|
+
const path7 = join19(ENGINE_ENV.HOME_DIR, ".kimi-code", "config.toml");
|
|
16296
16269
|
const start = "# Replicas command protection hook";
|
|
16297
16270
|
const end = "# End Replicas command protection hook";
|
|
16298
16271
|
let config = "";
|
|
@@ -16316,7 +16289,7 @@ ${end}`;
|
|
|
16316
16289
|
const markerEnd = config.indexOf(end, markerStart + start.length);
|
|
16317
16290
|
config = markerStart >= 0 && markerEnd >= 0 ? `${config.slice(0, markerStart)}${block}${config.slice(markerEnd + end.length)}` : `${config.trimEnd()}${config.trim() ? "\n\n" : ""}${block}
|
|
16318
16291
|
`;
|
|
16319
|
-
await mkdir11(
|
|
16292
|
+
await mkdir11(dirname5(path7), { recursive: true });
|
|
16320
16293
|
await writeFile6(path7, config, "utf8");
|
|
16321
16294
|
}
|
|
16322
16295
|
|
|
@@ -16401,7 +16374,7 @@ async function listCursorCommandsInDirectory(directory) {
|
|
|
16401
16374
|
const name = basename2(entry.name, ".md");
|
|
16402
16375
|
let description;
|
|
16403
16376
|
try {
|
|
16404
|
-
description = extractCursorCommandDescription(await readFile12(
|
|
16377
|
+
description = extractCursorCommandDescription(await readFile12(join20(directory, entry.name), "utf8"));
|
|
16405
16378
|
} catch (error) {
|
|
16406
16379
|
console.warn("[CursorManager] Failed to read slash command file:", error);
|
|
16407
16380
|
}
|
|
@@ -16423,12 +16396,12 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
16423
16396
|
slashCommandsRequest = null;
|
|
16424
16397
|
constructor(options) {
|
|
16425
16398
|
super(options);
|
|
16426
|
-
this.historyFilePath = options.historyFilePath ??
|
|
16399
|
+
this.historyFilePath = options.historyFilePath ?? join20(ENGINE_ENV.HOME_DIR, ".replicas", "cursor", "history.jsonl");
|
|
16427
16400
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
16428
16401
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
16429
16402
|
}
|
|
16430
16403
|
async initialize() {
|
|
16431
|
-
await mkdir12(
|
|
16404
|
+
await mkdir12(dirname6(this.historyFilePath), { recursive: true });
|
|
16432
16405
|
await ensureCursorCommandProtectionHook();
|
|
16433
16406
|
}
|
|
16434
16407
|
getHistorySink() {
|
|
@@ -16498,7 +16471,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
16498
16471
|
this.slashCommandsRequest ??= (async () => {
|
|
16499
16472
|
try {
|
|
16500
16473
|
const repoDirectories = await getAgentAdditionalDirectories();
|
|
16501
|
-
const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) =>
|
|
16474
|
+
const commandDirectories = [this.workingDirectory, ...repoDirectories, ENGINE_ENV.HOME_DIR].map((directory) => join20(directory, ".cursor", "commands"));
|
|
16502
16475
|
const commands = mergeSlashCommands(
|
|
16503
16476
|
...await Promise.all(commandDirectories.map(listCursorCommandsInDirectory))
|
|
16504
16477
|
);
|
|
@@ -16778,10 +16751,10 @@ ${instructions}
|
|
|
16778
16751
|
// src/managers/deepseek-manager.ts
|
|
16779
16752
|
import { spawn as spawn3 } from "child_process";
|
|
16780
16753
|
import { createHash as createHash2, randomUUID as randomUUID6 } from "crypto";
|
|
16781
|
-
import { createRequire
|
|
16782
|
-
import { basename as basename3, dirname as
|
|
16783
|
-
import { fileURLToPath as
|
|
16784
|
-
import { existsSync as
|
|
16754
|
+
import { createRequire } from "module";
|
|
16755
|
+
import { basename as basename3, dirname as dirname7, join as join21 } from "path";
|
|
16756
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16757
|
+
import { existsSync as existsSync9 } from "fs";
|
|
16785
16758
|
import { mkdir as mkdir13, readFile as readFile13, rename as rename2, writeFile as writeFile7 } from "fs/promises";
|
|
16786
16759
|
import { z as z2 } from "zod";
|
|
16787
16760
|
import WebSocket from "ws";
|
|
@@ -16793,18 +16766,18 @@ var questionSelectionSchema = z2.record(z2.string(), z2.object({
|
|
|
16793
16766
|
options: z2.array(z2.string()).optional(),
|
|
16794
16767
|
custom: z2.string().optional()
|
|
16795
16768
|
}));
|
|
16796
|
-
var require2 =
|
|
16797
|
-
var DSH_BIN =
|
|
16798
|
-
var MANAGER_DIR =
|
|
16769
|
+
var require2 = createRequire(import.meta.url);
|
|
16770
|
+
var DSH_BIN = join21(dirname7(require2.resolve("@deepseek-ai/dsh/package.json")), "lib", "bin.js");
|
|
16771
|
+
var MANAGER_DIR = dirname7(fileURLToPath2(import.meta.url));
|
|
16799
16772
|
var DSH_PATCH = [
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
].find(
|
|
16773
|
+
join21(MANAGER_DIR, "..", "..", "scripts", "deepseek", "replicas.cordis.patch.yml"),
|
|
16774
|
+
join21(MANAGER_DIR, "..", "..", "..", "scripts", "deepseek", "replicas.cordis.patch.yml")
|
|
16775
|
+
].find(existsSync9) ?? "";
|
|
16803
16776
|
var DSH_COMMAND_PROTECTION_PLUGIN = [
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
].find(
|
|
16807
|
-
var DEEPSEEK_HOME =
|
|
16777
|
+
join21(MANAGER_DIR, "deepseek-command-protection-plugin.js"),
|
|
16778
|
+
join21(MANAGER_DIR, "..", "deepseek-command-protection-plugin.ts")
|
|
16779
|
+
].find(existsSync9) ?? "";
|
|
16780
|
+
var DEEPSEEK_HOME = join21(ENGINE_ENV.HOME_DIR, ".replicas", "deepseek");
|
|
16808
16781
|
function relayPresetContent(content, instructions, mcp) {
|
|
16809
16782
|
const personaMarker = " text: >-\n";
|
|
16810
16783
|
const personaStart = content.indexOf(personaMarker);
|
|
@@ -16821,10 +16794,10 @@ ${indentedInstructions}${content.slice(personaEnd)}`.replace(delegationMarker, `
|
|
|
16821
16794
|
if (!mcp) return relayContent;
|
|
16822
16795
|
return `${relayContent}
|
|
16823
16796
|
|
|
16824
|
-
- id:
|
|
16797
|
+
- id: subagent-relay-mcp
|
|
16825
16798
|
name: '@deepseek-ai/dsh-mcp-client'
|
|
16826
16799
|
config:
|
|
16827
|
-
serverName:
|
|
16800
|
+
serverName: ${RELAY_MCP_SERVER_NAME}
|
|
16828
16801
|
transport: stdio
|
|
16829
16802
|
command: ${JSON.stringify(mcp.command)}
|
|
16830
16803
|
args: ${JSON.stringify(mcp.args)}
|
|
@@ -16949,13 +16922,13 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
16949
16922
|
constructor(options) {
|
|
16950
16923
|
super(options);
|
|
16951
16924
|
this.sessionId = options.initialSessionId ? sessionIdSchema.parse(options.initialSessionId) : null;
|
|
16952
|
-
this.historyFilePath = options.historyFilePath ??
|
|
16953
|
-
this.deepseekHome = this.isRelay ?
|
|
16925
|
+
this.historyFilePath = options.historyFilePath ?? join21(ENGINE_ENV.HOME_DIR, ".replicas", "deepseek", "history.jsonl");
|
|
16926
|
+
this.deepseekHome = this.isRelay ? join21(ENGINE_ENV.HOME_DIR, ".replicas", "deepseek-relay", basename3(this.historyFilePath, ".jsonl")) : DEEPSEEK_HOME;
|
|
16954
16927
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
16955
16928
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
16956
16929
|
}
|
|
16957
16930
|
async initialize() {
|
|
16958
|
-
await mkdir13(
|
|
16931
|
+
await mkdir13(dirname7(this.historyFilePath), { recursive: true });
|
|
16959
16932
|
}
|
|
16960
16933
|
getHistorySink() {
|
|
16961
16934
|
return this.historyFile;
|
|
@@ -17029,8 +17002,8 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
17029
17002
|
async ensureClient() {
|
|
17030
17003
|
if (this.client) return this.client;
|
|
17031
17004
|
if (!DSH_PATCH || !DSH_COMMAND_PROTECTION_PLUGIN) throw new Error("DeepSeek Harness configuration is missing from the engine package.");
|
|
17032
|
-
const runtimePatch =
|
|
17033
|
-
await mkdir13(
|
|
17005
|
+
const runtimePatch = join21(this.deepseekHome, "replicas.cordis.patch.yml");
|
|
17006
|
+
await mkdir13(dirname7(runtimePatch), { recursive: true });
|
|
17034
17007
|
await writeFile7(runtimePatch, (await readFile13(DSH_PATCH, "utf8")).replace(
|
|
17035
17008
|
"__REPLICAS_DSH_COMMAND_PROTECTION_PLUGIN__",
|
|
17036
17009
|
JSON.stringify(DSH_COMMAND_PROTECTION_PLUGIN)
|
|
@@ -17104,10 +17077,10 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
17104
17077
|
if (!roster.some((preset) => preset.id === agentPreset)) {
|
|
17105
17078
|
const stage = `relay-stage-${randomUUID6().replaceAll("-", "")}`;
|
|
17106
17079
|
unwrap(await client2.agentPresets.copy({ from: "standard", agentPreset: stage, name: "Relay" }));
|
|
17107
|
-
const stageDirectory =
|
|
17080
|
+
const stageDirectory = join21(this.deepseekHome, ".agent-presets", stage);
|
|
17108
17081
|
try {
|
|
17109
|
-
await writeFile7(
|
|
17110
|
-
await rename2(stageDirectory,
|
|
17082
|
+
await writeFile7(join21(stageDirectory, "agent.cordis.yml"), content, "utf8");
|
|
17083
|
+
await rename2(stageDirectory, join21(this.deepseekHome, ".agent-presets", agentPreset));
|
|
17111
17084
|
} catch (error) {
|
|
17112
17085
|
unwrap(await client2.agentPresets.remove({ agentPreset: stage }));
|
|
17113
17086
|
if (!unwrap(await client2.agentPresets.list({})).presets.some((preset) => preset.id === agentPreset)) throw error;
|
|
@@ -17288,7 +17261,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
17288
17261
|
import { spawn as spawn4 } from "child_process";
|
|
17289
17262
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
17290
17263
|
import { mkdir as mkdir14, readFile as readFile14, writeFile as writeFile8 } from "fs/promises";
|
|
17291
|
-
import { dirname as
|
|
17264
|
+
import { dirname as dirname8 } from "path";
|
|
17292
17265
|
import { Writable } from "stream";
|
|
17293
17266
|
import {
|
|
17294
17267
|
PROTOCOL_VERSION,
|
|
@@ -17328,7 +17301,7 @@ var AcpManager = class extends CodingAgentManager {
|
|
|
17328
17301
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
17329
17302
|
}
|
|
17330
17303
|
async initialize() {
|
|
17331
|
-
await mkdir14(
|
|
17304
|
+
await mkdir14(dirname8(this.historyFilePath), { recursive: true });
|
|
17332
17305
|
await this.acp.prepare?.();
|
|
17333
17306
|
}
|
|
17334
17307
|
getHistorySink() {
|
|
@@ -17823,7 +17796,7 @@ var KimiManager = class extends AcpManager {
|
|
|
17823
17796
|
import { spawn as spawn6 } from "child_process";
|
|
17824
17797
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
17825
17798
|
import { mkdir as mkdir15 } from "fs/promises";
|
|
17826
|
-
import { dirname as
|
|
17799
|
+
import { dirname as dirname9 } from "path";
|
|
17827
17800
|
var MuseQuotaError = class extends Error {
|
|
17828
17801
|
};
|
|
17829
17802
|
function uuidV7() {
|
|
@@ -17864,7 +17837,7 @@ var MuseManager = class extends CodingAgentManager {
|
|
|
17864
17837
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
17865
17838
|
}
|
|
17866
17839
|
async initialize() {
|
|
17867
|
-
await mkdir15(
|
|
17840
|
+
await mkdir15(dirname9(this.historyFilePath), { recursive: true });
|
|
17868
17841
|
}
|
|
17869
17842
|
getHistorySink() {
|
|
17870
17843
|
return this.historyFile;
|
|
@@ -18333,11 +18306,11 @@ ${pending}
|
|
|
18333
18306
|
};
|
|
18334
18307
|
|
|
18335
18308
|
// src/managers/opencode-manager.ts
|
|
18336
|
-
import { existsSync as
|
|
18309
|
+
import { existsSync as existsSync10 } from "fs";
|
|
18337
18310
|
import { copyFile, mkdir as mkdir16, readFile as readFile16, rm as rm2 } from "fs/promises";
|
|
18338
|
-
import { delimiter, dirname as
|
|
18311
|
+
import { delimiter, dirname as dirname10, join as join22 } from "path";
|
|
18339
18312
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18340
|
-
import { fileURLToPath as
|
|
18313
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
18341
18314
|
import { Agent } from "undici";
|
|
18342
18315
|
import { z as z3 } from "zod";
|
|
18343
18316
|
import {
|
|
@@ -18363,11 +18336,11 @@ async function getAllowedOpenRouterModels() {
|
|
|
18363
18336
|
}
|
|
18364
18337
|
|
|
18365
18338
|
// src/managers/opencode-manager.ts
|
|
18366
|
-
var OPENCODE_SHIM_DIR =
|
|
18367
|
-
var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE =
|
|
18368
|
-
var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH =
|
|
18369
|
-
var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH =
|
|
18370
|
-
var OPENCODE_CONFIG_PATH =
|
|
18339
|
+
var OPENCODE_SHIM_DIR = dirname10(fileURLToPath3(new URL("../../scripts/opencode", import.meta.url)));
|
|
18340
|
+
var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE = join22(OPENCODE_SHIM_DIR, "opencode-command-protection-plugin.ts");
|
|
18341
|
+
var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH = join22(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.ts");
|
|
18342
|
+
var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH = join22(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.mjs");
|
|
18343
|
+
var OPENCODE_CONFIG_PATH = join22(ENGINE_ENV.HOME_DIR, ".config", "opencode", "opencode.json");
|
|
18371
18344
|
var OPENCODE_FETCH_DISPATCHER = new Agent({ headersTimeout: 0, bodyTimeout: 0 });
|
|
18372
18345
|
var OPENCODE_SERVER_STARTUP_TIMEOUT_MS = 3e4;
|
|
18373
18346
|
var OPENCODE_WORKSPACE_PERMISSION = "allow";
|
|
@@ -18386,7 +18359,7 @@ var opencodeAuthSchema = z3.record(z3.string(), z3.object({
|
|
|
18386
18359
|
key: z3.string().optional()
|
|
18387
18360
|
}));
|
|
18388
18361
|
async function hasOpencodeCredentials(provider) {
|
|
18389
|
-
if (!
|
|
18362
|
+
if (!existsSync10(OPENCODE_AUTH_PATH)) return false;
|
|
18390
18363
|
try {
|
|
18391
18364
|
const auth2 = opencodeAuthSchema.safeParse(JSON.parse(await readFile16(OPENCODE_AUTH_PATH, "utf8")));
|
|
18392
18365
|
return auth2.success && auth2.data[provider]?.type === "api" && Boolean(auth2.data[provider]?.key);
|
|
@@ -18579,12 +18552,12 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18579
18552
|
constructor(options) {
|
|
18580
18553
|
super({ ...options, provider: "opencode" });
|
|
18581
18554
|
this.sessionId = options.initialSessionId;
|
|
18582
|
-
this.historyFilePath = options.historyFilePath ??
|
|
18555
|
+
this.historyFilePath = options.historyFilePath ?? join22(ENGINE_ENV.HOME_DIR, ".replicas", "opencode", "history.jsonl");
|
|
18583
18556
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
18584
18557
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
18585
18558
|
}
|
|
18586
18559
|
async initialize() {
|
|
18587
|
-
await mkdir16(
|
|
18560
|
+
await mkdir16(dirname10(this.historyFilePath), { recursive: true });
|
|
18588
18561
|
}
|
|
18589
18562
|
getHistorySink() {
|
|
18590
18563
|
return this.historyFile;
|
|
@@ -18681,10 +18654,10 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18681
18654
|
if (!await hasOpencodeCredentials(providerId)) {
|
|
18682
18655
|
throw new Error("OpenCode Go, Aster, or OpenRouter credentials are not configured for Opencode in this workspace.");
|
|
18683
18656
|
}
|
|
18684
|
-
if (!
|
|
18657
|
+
if (!existsSync10(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE)) {
|
|
18685
18658
|
throw new Error("Opencode command protection plugin is missing from the engine package.");
|
|
18686
18659
|
}
|
|
18687
|
-
await mkdir16(
|
|
18660
|
+
await mkdir16(dirname10(OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH), { recursive: true });
|
|
18688
18661
|
await copyFile(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE, OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH);
|
|
18689
18662
|
await rm2(OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH, { force: true });
|
|
18690
18663
|
process.env.REPLICAS_COMMAND_PROTECTION_HOOK_PATH = getCommandProtectionHookPath();
|
|
@@ -18705,7 +18678,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18705
18678
|
const relay = relayMcpProcessConfig(this.relayParentChatId);
|
|
18706
18679
|
config.mcp = {
|
|
18707
18680
|
...config.mcp,
|
|
18708
|
-
|
|
18681
|
+
[RELAY_MCP_SERVER_NAME]: {
|
|
18709
18682
|
type: "local",
|
|
18710
18683
|
command: [relay.command, ...relay.args],
|
|
18711
18684
|
enabled: true,
|
|
@@ -19000,7 +18973,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
19000
18973
|
|
|
19001
18974
|
// src/managers/pi-manager.ts
|
|
19002
18975
|
import { mkdir as mkdir18, readFile as readFile17 } from "fs/promises";
|
|
19003
|
-
import { dirname as
|
|
18976
|
+
import { dirname as dirname18, join as join29 } from "path";
|
|
19004
18977
|
import {
|
|
19005
18978
|
createAgentSession,
|
|
19006
18979
|
ModelRegistry,
|
|
@@ -23598,7 +23571,7 @@ __export(typebox_exports, {
|
|
|
23598
23571
|
});
|
|
23599
23572
|
|
|
23600
23573
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/init.ts
|
|
23601
|
-
import { existsSync as
|
|
23574
|
+
import { existsSync as existsSync13 } from "fs";
|
|
23602
23575
|
|
|
23603
23576
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/errors.ts
|
|
23604
23577
|
var McpUiError = class extends Error {
|
|
@@ -41538,8 +41511,8 @@ async function probeMcpEndpoint(url3) {
|
|
|
41538
41511
|
}
|
|
41539
41512
|
|
|
41540
41513
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
|
|
41541
|
-
import { existsSync as
|
|
41542
|
-
import { join as
|
|
41514
|
+
import { existsSync as existsSync11, readFileSync as readFileSync4, realpathSync, readdirSync, statSync, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
|
|
41515
|
+
import { join as join23, dirname as dirname11, extname as extname2, resolve as resolve2, sep } from "path";
|
|
41543
41516
|
|
|
41544
41517
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
|
|
41545
41518
|
function throwIfAborted(signal) {
|
|
@@ -41589,7 +41562,7 @@ async function resolveNpxBinary(command, args, signal) {
|
|
|
41589
41562
|
const cacheKey = JSON.stringify([command, parsed.packageSpec, parsed.binName ?? ""]);
|
|
41590
41563
|
const cache2 = loadCache();
|
|
41591
41564
|
const cached = cache2?.entries?.[cacheKey];
|
|
41592
|
-
if (cached && Date.now() - cached.resolvedAt < CACHE_TTL_MS &&
|
|
41565
|
+
if (cached && Date.now() - cached.resolvedAt < CACHE_TTL_MS && existsSync11(cached.resolvedBin) && (!packageSpec?.exactVersion || cached.packageVersion === packageSpec.exactVersion)) {
|
|
41593
41566
|
return { binPath: cached.resolvedBin, extraArgs: parsed.extraArgs, isJs: cached.isJs };
|
|
41594
41567
|
}
|
|
41595
41568
|
const resolved = resolveFromNpmCache(parsed.packageSpec, parsed.binName);
|
|
@@ -41696,8 +41669,8 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
41696
41669
|
const { packageName, exactVersion } = parsedSpec;
|
|
41697
41670
|
const packageDir = findCachedPackageDir(cacheDir, packageName, exactVersion);
|
|
41698
41671
|
if (!packageDir) return null;
|
|
41699
|
-
const packageJsonPath =
|
|
41700
|
-
if (!
|
|
41672
|
+
const packageJsonPath = join23(packageDir, "package.json");
|
|
41673
|
+
if (!existsSync11(packageJsonPath)) return null;
|
|
41701
41674
|
let pkg = null;
|
|
41702
41675
|
try {
|
|
41703
41676
|
pkg = JSON.parse(readFileSync4(packageJsonPath, "utf-8"));
|
|
@@ -41730,11 +41703,11 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
41730
41703
|
}
|
|
41731
41704
|
if (!binRel) return null;
|
|
41732
41705
|
const nodeModulesDir = findNodeModulesDir(packageDir);
|
|
41733
|
-
const binLink = chosenBinName ?
|
|
41734
|
-
let resolvedBin = binLink &&
|
|
41706
|
+
const binLink = chosenBinName ? join23(nodeModulesDir, ".bin", chosenBinName) : null;
|
|
41707
|
+
let resolvedBin = binLink && existsSync11(binLink) ? safeRealpath(binLink) : "";
|
|
41735
41708
|
if (!resolvedBin) {
|
|
41736
41709
|
resolvedBin = resolve2(packageDir, binRel);
|
|
41737
|
-
if (!
|
|
41710
|
+
if (!existsSync11(resolvedBin)) return null;
|
|
41738
41711
|
}
|
|
41739
41712
|
const isJs = detectJsBinary(resolvedBin);
|
|
41740
41713
|
return {
|
|
@@ -41832,18 +41805,18 @@ function defaultBinName(packageName) {
|
|
|
41832
41805
|
return packageName;
|
|
41833
41806
|
}
|
|
41834
41807
|
function findCachedPackageDir(cacheDir, packageName, exactVersion) {
|
|
41835
|
-
const npxDir =
|
|
41836
|
-
if (!
|
|
41808
|
+
const npxDir = join23(cacheDir, "_npx");
|
|
41809
|
+
if (!existsSync11(npxDir)) return null;
|
|
41837
41810
|
const packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
|
|
41838
41811
|
const candidates = readdirSync(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
41839
|
-
const full =
|
|
41812
|
+
const full = join23(npxDir, entry.name);
|
|
41840
41813
|
const mtime = safeStatMtime(full);
|
|
41841
41814
|
return { name: entry.name, mtime };
|
|
41842
41815
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
41843
41816
|
for (const entry of candidates) {
|
|
41844
|
-
const pkgDir =
|
|
41845
|
-
const packageJsonPath =
|
|
41846
|
-
if (!
|
|
41817
|
+
const pkgDir = join23(npxDir, entry.name, "node_modules", ...packagePathParts);
|
|
41818
|
+
const packageJsonPath = join23(pkgDir, "package.json");
|
|
41819
|
+
if (!existsSync11(packageJsonPath)) continue;
|
|
41847
41820
|
if (exactVersion) {
|
|
41848
41821
|
try {
|
|
41849
41822
|
const pkg = JSON.parse(readFileSync4(packageJsonPath, "utf-8"));
|
|
@@ -41862,7 +41835,7 @@ function findNodeModulesDir(packageDir) {
|
|
|
41862
41835
|
if (idx >= 0) {
|
|
41863
41836
|
return parts.slice(0, idx + 1).join(sep);
|
|
41864
41837
|
}
|
|
41865
|
-
return
|
|
41838
|
+
return join23(packageDir, "..");
|
|
41866
41839
|
}
|
|
41867
41840
|
function detectJsBinary(binPath) {
|
|
41868
41841
|
const ext = extname2(binPath).toLowerCase();
|
|
@@ -41906,7 +41879,7 @@ function getNpxCachePath() {
|
|
|
41906
41879
|
return getAgentPath("mcp-npx-cache.json");
|
|
41907
41880
|
}
|
|
41908
41881
|
function readNpxCachePayload(cachePath) {
|
|
41909
|
-
if (!
|
|
41882
|
+
if (!existsSync11(cachePath)) return null;
|
|
41910
41883
|
try {
|
|
41911
41884
|
return JSON.parse(readFileSync4(cachePath, "utf-8"));
|
|
41912
41885
|
} catch {
|
|
@@ -41967,7 +41940,7 @@ function loadCache() {
|
|
|
41967
41940
|
function saveCacheEntry(key, entry) {
|
|
41968
41941
|
try {
|
|
41969
41942
|
const cachePath = getNpxCachePath();
|
|
41970
|
-
const dir =
|
|
41943
|
+
const dir = dirname11(cachePath);
|
|
41971
41944
|
mkdirSync(dir, { recursive: true });
|
|
41972
41945
|
const existing = toNpxCache(readNpxCachePayload(cachePath));
|
|
41973
41946
|
const entries = createCacheEntries();
|
|
@@ -42052,11 +42025,11 @@ function createJsonSchemaValidator() {
|
|
|
42052
42025
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-auth.ts
|
|
42053
42026
|
import { spawnSync } from "child_process";
|
|
42054
42027
|
import { createHash as createHash3 } from "crypto";
|
|
42055
|
-
import { createRequire as
|
|
42056
|
-
import { readFileSync as readFileSync5, existsSync as
|
|
42057
|
-
import { dirname as
|
|
42058
|
-
import { fileURLToPath as
|
|
42059
|
-
var require3 =
|
|
42028
|
+
import { createRequire as createRequire2 } from "module";
|
|
42029
|
+
import { readFileSync as readFileSync5, existsSync as existsSync12, rmSync } from "fs";
|
|
42030
|
+
import { dirname as dirname12, join as join24 } from "path";
|
|
42031
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
42032
|
+
var require3 = createRequire2(import.meta.url);
|
|
42060
42033
|
var AUTH_SECRET_SERVICE = "pi-mcp-adapter.oauth";
|
|
42061
42034
|
var TEST_AUTH_STORE_ENV = "PI_MCP_ADAPTER_TEST_AUTH_STORE";
|
|
42062
42035
|
var AUTH_SECRET_CHUNK_SIZE = 1e3;
|
|
@@ -42210,7 +42183,7 @@ function loadKeyringNativeBindingFallback(keyringRequire, platform3, arch2) {
|
|
|
42210
42183
|
for (const target of targets) {
|
|
42211
42184
|
try {
|
|
42212
42185
|
const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
|
|
42213
|
-
return keyringRequire(
|
|
42186
|
+
return keyringRequire(join24(dirname12(packageJsonPath), target.bindingFile));
|
|
42214
42187
|
} catch (error) {
|
|
42215
42188
|
lastError = error;
|
|
42216
42189
|
}
|
|
@@ -42255,7 +42228,7 @@ function shouldAttemptLinuxKeyringRecovery(error) {
|
|
|
42255
42228
|
function runLinuxKeyringRecoveryOperation(operation, account, payload) {
|
|
42256
42229
|
const keyctl = process.env[KEYRING_RECOVERY_KEYCTL_ENV]?.trim() || "keyctl";
|
|
42257
42230
|
const node = process.env[KEYRING_RECOVERY_NODE_ENV]?.trim() || "node";
|
|
42258
|
-
const helper = process.env[KEYRING_RECOVERY_HELPER_ENV]?.trim() ||
|
|
42231
|
+
const helper = process.env[KEYRING_RECOVERY_HELPER_ENV]?.trim() || fileURLToPath4(new URL("./mcp-keyring-helper.cjs", import.meta.url));
|
|
42259
42232
|
const request = JSON.stringify({ operation, service: AUTH_SECRET_SERVICE, account, payload });
|
|
42260
42233
|
const result = spawnSync(keyctl, ["session", "-", node, helper], {
|
|
42261
42234
|
input: `${request}
|
|
@@ -42315,7 +42288,7 @@ function getServerDir(serverName, options) {
|
|
|
42315
42288
|
throw new Error(`Invalid MCP server name: ${JSON.stringify(serverName)}`);
|
|
42316
42289
|
}
|
|
42317
42290
|
const storageKey = getAuthEntryAccount(serverName);
|
|
42318
|
-
return
|
|
42291
|
+
return join24(getAuthBaseDir(options), storageKey);
|
|
42319
42292
|
}
|
|
42320
42293
|
function getAuthEntryAccount(serverName) {
|
|
42321
42294
|
if (typeof serverName !== "string") {
|
|
@@ -42324,7 +42297,7 @@ function getAuthEntryAccount(serverName) {
|
|
|
42324
42297
|
return `sha256-${createHash3("sha256").update(serverName, "utf8").digest("hex")}`;
|
|
42325
42298
|
}
|
|
42326
42299
|
function getAuthEntryFilePath(serverName, options) {
|
|
42327
|
-
return
|
|
42300
|
+
return join24(getServerDir(serverName, options), "tokens.json");
|
|
42328
42301
|
}
|
|
42329
42302
|
function parseJsonPayload(serverName, payload, source) {
|
|
42330
42303
|
try {
|
|
@@ -42473,13 +42446,13 @@ function readChunkedAuthEntry(store, serverName, account, manifest) {
|
|
|
42473
42446
|
}
|
|
42474
42447
|
function readLegacyAuthEntry(serverName, options) {
|
|
42475
42448
|
const filePath = getAuthEntryFilePath(serverName, options);
|
|
42476
|
-
if (!
|
|
42449
|
+
if (!existsSync12(filePath)) return void 0;
|
|
42477
42450
|
const data = readFileSync5(filePath, "utf-8");
|
|
42478
42451
|
return parseAuthEntryPayload(serverName, data, filePath);
|
|
42479
42452
|
}
|
|
42480
42453
|
function removeLegacyAuthEntry(serverName, options) {
|
|
42481
42454
|
const filePath = getAuthEntryFilePath(serverName, options);
|
|
42482
|
-
if (!
|
|
42455
|
+
if (!existsSync12(filePath)) return;
|
|
42483
42456
|
try {
|
|
42484
42457
|
rmSync(filePath, { force: true });
|
|
42485
42458
|
} catch (error) {
|
|
@@ -43249,7 +43222,7 @@ var McpOAuthProvider = class {
|
|
|
43249
43222
|
import process9 from "process";
|
|
43250
43223
|
import { Buffer as Buffer2 } from "buffer";
|
|
43251
43224
|
import path5 from "path";
|
|
43252
|
-
import { fileURLToPath as
|
|
43225
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
43253
43226
|
import { promisify as promisify5 } from "util";
|
|
43254
43227
|
import childProcess from "child_process";
|
|
43255
43228
|
import fs6, { constants as fsConstants2 } from "fs/promises";
|
|
@@ -43506,7 +43479,7 @@ async function defaultBrowser2() {
|
|
|
43506
43479
|
|
|
43507
43480
|
// ../node_modules/.bun/open@10.2.0/node_modules/open/index.js
|
|
43508
43481
|
var execFile5 = promisify5(childProcess.execFile);
|
|
43509
|
-
var __dirname = path5.dirname(
|
|
43482
|
+
var __dirname = path5.dirname(fileURLToPath5(import.meta.url));
|
|
43510
43483
|
var localXdgOpenPath = path5.join(__dirname, "xdg-open");
|
|
43511
43484
|
var { platform, arch } = process9;
|
|
43512
43485
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
@@ -44926,9 +44899,9 @@ async function shutdownOAuth(runtime = legacyRuntime) {
|
|
|
44926
44899
|
|
|
44927
44900
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-bearer-store.ts
|
|
44928
44901
|
import { createHash as createHash4 } from "crypto";
|
|
44929
|
-
import { createRequire as
|
|
44930
|
-
import { dirname as
|
|
44931
|
-
var require4 =
|
|
44902
|
+
import { createRequire as createRequire3 } from "module";
|
|
44903
|
+
import { dirname as dirname13, join as join25 } from "path";
|
|
44904
|
+
var require4 = createRequire3(import.meta.url);
|
|
44932
44905
|
var BEARER_SECRET_SERVICE = "pi-mcp-adapter.bearer";
|
|
44933
44906
|
var TEST_AUTH_STORE_ENV2 = "PI_MCP_ADAPTER_TEST_AUTH_STORE";
|
|
44934
44907
|
var BEARER_SECRET_VALUE_LIMIT = 1280;
|
|
@@ -45029,7 +45002,7 @@ function loadKeyringNativeBindingFallback2(keyringRequire, platform3, arch2) {
|
|
|
45029
45002
|
for (const target of targets) {
|
|
45030
45003
|
try {
|
|
45031
45004
|
const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
|
|
45032
|
-
return keyringRequire(
|
|
45005
|
+
return keyringRequire(join25(dirname13(packageJsonPath), target.bindingFile));
|
|
45033
45006
|
} catch (error) {
|
|
45034
45007
|
lastError = error;
|
|
45035
45008
|
}
|
|
@@ -45643,7 +45616,7 @@ function humanizeName(name) {
|
|
|
45643
45616
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-trace.ts
|
|
45644
45617
|
import { appendFile as appendFile3, mkdir as mkdir17, writeFile as writeFile9 } from "fs/promises";
|
|
45645
45618
|
import { Buffer as Buffer3 } from "buffer";
|
|
45646
|
-
import { dirname as
|
|
45619
|
+
import { dirname as dirname14, isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
|
|
45647
45620
|
var MCP_TRACE_SCHEMA_VERSION = 1;
|
|
45648
45621
|
var DEFAULT_MCP_TRACE_MAX_BYTES = 256 * 1024;
|
|
45649
45622
|
var DEFAULT_MCP_TRACE_MAX_EVENTS = 1e4;
|
|
@@ -45716,7 +45689,7 @@ var McpTraceWriter = class {
|
|
|
45716
45689
|
await mkdir17(path7, { recursive: true });
|
|
45717
45690
|
return void 0;
|
|
45718
45691
|
});
|
|
45719
|
-
this.fileReady = this.makeDirectory(
|
|
45692
|
+
this.fileReady = this.makeDirectory(dirname14(this.options.filePath), { recursive: true }).then(() => this.resetFile(this.options.filePath, "", { encoding: "utf8" })).catch(() => {
|
|
45720
45693
|
this.initializationFailed = true;
|
|
45721
45694
|
this.disabled = true;
|
|
45722
45695
|
});
|
|
@@ -48450,7 +48423,7 @@ async function initializeMcp(pi, ctx, owner = createMcpRuntimeOwner(), options =
|
|
|
48450
48423
|
const idleSetting = typeof config.settings?.idleTimeout === "number" ? config.settings.idleTimeout : 10;
|
|
48451
48424
|
lifecycle.setGlobalIdleTimeout(idleSetting);
|
|
48452
48425
|
const cachePath = getMetadataCachePath();
|
|
48453
|
-
const cacheFileExists =
|
|
48426
|
+
const cacheFileExists = existsSync13(cachePath);
|
|
48454
48427
|
let cache2 = loadMetadataCache();
|
|
48455
48428
|
let bootstrapAll = false;
|
|
48456
48429
|
if (!cacheFileExists) {
|
|
@@ -48841,8 +48814,8 @@ function getEffectiveIdleTimeoutMinutes(state, serverName) {
|
|
|
48841
48814
|
}
|
|
48842
48815
|
|
|
48843
48816
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/onboarding-state.ts
|
|
48844
|
-
import { existsSync as
|
|
48845
|
-
import { dirname as
|
|
48817
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync2, renameSync as renameSync2 } from "fs";
|
|
48818
|
+
import { dirname as dirname15 } from "path";
|
|
48846
48819
|
var DEFAULT_STATE2 = {
|
|
48847
48820
|
version: 1,
|
|
48848
48821
|
sharedConfigHintShown: false,
|
|
@@ -48853,7 +48826,7 @@ function getOnboardingStatePath() {
|
|
|
48853
48826
|
}
|
|
48854
48827
|
function loadOnboardingState() {
|
|
48855
48828
|
const path7 = getOnboardingStatePath();
|
|
48856
|
-
if (!
|
|
48829
|
+
if (!existsSync14(path7)) return { ...DEFAULT_STATE2 };
|
|
48857
48830
|
try {
|
|
48858
48831
|
const raw = JSON.parse(readFileSync6(path7, "utf-8"));
|
|
48859
48832
|
if (!raw || typeof raw !== "object") return { ...DEFAULT_STATE2 };
|
|
@@ -48869,7 +48842,7 @@ function loadOnboardingState() {
|
|
|
48869
48842
|
}
|
|
48870
48843
|
function saveOnboardingState(state) {
|
|
48871
48844
|
const path7 = getOnboardingStatePath();
|
|
48872
|
-
mkdirSync3(
|
|
48845
|
+
mkdirSync3(dirname15(path7), { recursive: true });
|
|
48873
48846
|
const tmpPath = `${path7}.${process.pid}.tmp`;
|
|
48874
48847
|
writeFileSync2(tmpPath, `${JSON.stringify(state, null, 2)}
|
|
48875
48848
|
`, "utf-8");
|
|
@@ -49496,7 +49469,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
|
|
|
49496
49469
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-registrar.ts
|
|
49497
49470
|
import { mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
49498
49471
|
import { tmpdir } from "os";
|
|
49499
|
-
import { join as
|
|
49472
|
+
import { join as join26 } from "path";
|
|
49500
49473
|
var MAX_BINARY_RESOURCE_BYTES = 10 * 1024 * 1024;
|
|
49501
49474
|
var MAX_SESSION_RESOURCE_BYTES = 100 * 1024 * 1024;
|
|
49502
49475
|
var MAX_SESSION_RESOURCE_FILES = 1e4;
|
|
@@ -49603,11 +49576,11 @@ function materializeBinaryResource(resource, scope) {
|
|
|
49603
49576
|
return omitBinaryResource(resource, "session resource limit reached");
|
|
49604
49577
|
}
|
|
49605
49578
|
try {
|
|
49606
|
-
session.directory ??= mkdtempSync(
|
|
49579
|
+
session.directory ??= mkdtempSync(join26(tmpdir(), "pi-mcp-resource-"));
|
|
49607
49580
|
} catch {
|
|
49608
49581
|
return omitBinaryResource(resource, "could not be saved");
|
|
49609
49582
|
}
|
|
49610
|
-
const filePath =
|
|
49583
|
+
const filePath = join26(session.directory, `resource-${++session.sequence}.bin`);
|
|
49611
49584
|
session.bytes += decodedBytes;
|
|
49612
49585
|
session.files += 1;
|
|
49613
49586
|
try {
|
|
@@ -49700,7 +49673,7 @@ function stringifyStructuredContent(value) {
|
|
|
49700
49673
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
49701
49674
|
import { mkdtemp, rm as rm3, writeFile as writeFile10 } from "fs/promises";
|
|
49702
49675
|
import { tmpdir as tmpdir2 } from "os";
|
|
49703
|
-
import { dirname as
|
|
49676
|
+
import { dirname as dirname16, join as join27 } from "path";
|
|
49704
49677
|
var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
49705
49678
|
var DEFAULT_MCP_OUTPUT_MAX_LINES = 2e3;
|
|
49706
49679
|
var DEFAULT_MCP_DETAILS_MAX_BYTES = 16 * 1024;
|
|
@@ -50008,8 +49981,8 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
50008
49981
|
}
|
|
50009
49982
|
async function saveArtifact(kind, text) {
|
|
50010
49983
|
try {
|
|
50011
|
-
const dir = await mkdtemp(
|
|
50012
|
-
const path7 =
|
|
49984
|
+
const dir = await mkdtemp(join27(tmpdir2(), "pi-mcp-output-"));
|
|
49985
|
+
const path7 = join27(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
|
|
50013
49986
|
await writeFile10(path7, text, { encoding: "utf8", mode: 384 });
|
|
50014
49987
|
return { path: path7 };
|
|
50015
49988
|
} catch (error) {
|
|
@@ -50018,7 +49991,7 @@ async function saveArtifact(kind, text) {
|
|
|
50018
49991
|
}
|
|
50019
49992
|
async function discardArtifact(path7) {
|
|
50020
49993
|
try {
|
|
50021
|
-
await rm3(
|
|
49994
|
+
await rm3(dirname16(path7), { recursive: true, force: true });
|
|
50022
49995
|
} catch {
|
|
50023
49996
|
}
|
|
50024
49997
|
}
|
|
@@ -51654,11 +51627,11 @@ function sendText(res, status, text) {
|
|
|
51654
51627
|
}
|
|
51655
51628
|
|
|
51656
51629
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/glimpse-ui.ts
|
|
51657
|
-
import { existsSync as
|
|
51630
|
+
import { existsSync as existsSync15 } from "fs";
|
|
51658
51631
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
51659
|
-
import { join as
|
|
51632
|
+
import { join as join28, dirname as dirname17 } from "path";
|
|
51660
51633
|
import { platform as platform2 } from "os";
|
|
51661
|
-
import { createRequire as
|
|
51634
|
+
import { createRequire as createRequire4 } from "module";
|
|
51662
51635
|
var glimpseAvailable = null;
|
|
51663
51636
|
var resolvedBinaryPath = null;
|
|
51664
51637
|
function isGlimpseAvailable() {
|
|
@@ -51672,26 +51645,26 @@ function isGlimpseAvailable() {
|
|
|
51672
51645
|
return glimpseAvailable;
|
|
51673
51646
|
}
|
|
51674
51647
|
function getGlimpseBinaryPath() {
|
|
51675
|
-
if (process.env.GLIMPSE_BINARY &&
|
|
51648
|
+
if (process.env.GLIMPSE_BINARY && existsSync15(process.env.GLIMPSE_BINARY)) {
|
|
51676
51649
|
return process.env.GLIMPSE_BINARY;
|
|
51677
51650
|
}
|
|
51678
51651
|
try {
|
|
51679
|
-
const require7 =
|
|
51652
|
+
const require7 = createRequire4(import.meta.url);
|
|
51680
51653
|
const glimpseuiPath = require7.resolve("glimpseui");
|
|
51681
|
-
const binaryPath =
|
|
51682
|
-
if (
|
|
51654
|
+
const binaryPath = join28(dirname17(glimpseuiPath), "glimpse");
|
|
51655
|
+
if (existsSync15(binaryPath)) return binaryPath;
|
|
51683
51656
|
} catch {
|
|
51684
51657
|
}
|
|
51685
51658
|
try {
|
|
51686
51659
|
const globalRoot = execFileSync2("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
|
|
51687
|
-
const binaryPath =
|
|
51688
|
-
if (
|
|
51660
|
+
const binaryPath = join28(globalRoot, "glimpseui", "src", "glimpse");
|
|
51661
|
+
if (existsSync15(binaryPath)) return binaryPath;
|
|
51689
51662
|
} catch {
|
|
51690
51663
|
}
|
|
51691
51664
|
return null;
|
|
51692
51665
|
}
|
|
51693
51666
|
async function openGlimpseWindow(html, options) {
|
|
51694
|
-
const modulePath = resolvedBinaryPath ?
|
|
51667
|
+
const modulePath = resolvedBinaryPath ? join28(dirname17(resolvedBinaryPath), "glimpse.mjs") : "glimpseui";
|
|
51695
51668
|
const glimpse = await import(modulePath);
|
|
51696
51669
|
let active = true;
|
|
51697
51670
|
const win = glimpse.open(html, {
|
|
@@ -56087,7 +56060,7 @@ function buildCommandDescription(metadata) {
|
|
|
56087
56060
|
}
|
|
56088
56061
|
|
|
56089
56062
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/proxy-modes.ts
|
|
56090
|
-
import { createRequire as
|
|
56063
|
+
import { createRequire as createRequire5 } from "module";
|
|
56091
56064
|
|
|
56092
56065
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ts-shape.ts
|
|
56093
56066
|
var UNSUPPORTED_KEYWORDS = ["if", "then", "else", "allOf", "not", "patternProperties", "additionalProperties"];
|
|
@@ -56407,7 +56380,7 @@ function rankSuggestions(state, name, limit) {
|
|
|
56407
56380
|
}
|
|
56408
56381
|
|
|
56409
56382
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/proxy-modes.ts
|
|
56410
|
-
var require5 =
|
|
56383
|
+
var require5 = createRequire5(import.meta.url);
|
|
56411
56384
|
var MAX_REGEX_SEARCH_QUERY_LENGTH = 256;
|
|
56412
56385
|
var INSTRUCTIONS_PREVIEW_LENGTH = 300;
|
|
56413
56386
|
var REGEX_SAFETY_CHECK_PARAMS = {
|
|
@@ -59603,12 +59576,12 @@ var PiManager = class extends CodingAgentManager {
|
|
|
59603
59576
|
modelRuntime = null;
|
|
59604
59577
|
constructor(options) {
|
|
59605
59578
|
super(options);
|
|
59606
|
-
this.historyFilePath = options.historyFilePath ??
|
|
59579
|
+
this.historyFilePath = options.historyFilePath ?? join29(PI_HISTORY_DIR, `${Date.now()}.jsonl`);
|
|
59607
59580
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
59608
59581
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
59609
59582
|
}
|
|
59610
59583
|
async initialize() {
|
|
59611
|
-
await mkdir18(
|
|
59584
|
+
await mkdir18(dirname18(this.historyFilePath), { recursive: true });
|
|
59612
59585
|
}
|
|
59613
59586
|
getHistorySink() {
|
|
59614
59587
|
return this.historyFile;
|
|
@@ -59715,7 +59688,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
59715
59688
|
const sessionManager = this.initialSessionId ? SessionManager.open(this.initialSessionId, PI_HISTORY_DIR, this.workingDirectory) : SessionManager.create(this.workingDirectory, PI_HISTORY_DIR);
|
|
59716
59689
|
const mcpServers = await getManagedPiMcpServers();
|
|
59717
59690
|
if (this.relayParentChatId) {
|
|
59718
|
-
mcpServers[
|
|
59691
|
+
mcpServers[RELAY_MCP_SERVER_NAME] = {
|
|
59719
59692
|
...relayMcpProcessConfig(this.relayParentChatId),
|
|
59720
59693
|
lifecycle: "lazy",
|
|
59721
59694
|
idleTimeout: 1,
|
|
@@ -59739,7 +59712,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
59739
59712
|
}
|
|
59740
59713
|
const resourceLoader = new DefaultResourceLoader({
|
|
59741
59714
|
cwd: this.workingDirectory,
|
|
59742
|
-
agentDir:
|
|
59715
|
+
agentDir: join29(ENGINE_ENV.HOME_DIR, ".pi", "agent"),
|
|
59743
59716
|
extensionFactories,
|
|
59744
59717
|
appendSystemPrompt: [this.buildCombinedInstructions() ?? ""]
|
|
59745
59718
|
});
|
|
@@ -59816,7 +59789,7 @@ Go straight to the point. Lead with outcomes and decisions, keep updates concise
|
|
|
59816
59789
|
|
|
59817
59790
|
Your primary constraint is context. Work directly when the task is small, tightly coupled to context you already hold, or cheaper to complete than explain. Delegate independent work that would consume substantial context, including broad investigation, multi-file implementation, iterative debugging, test-and-fix loops, and unbiased review or verification. Do not delegate trivial work or work whose full context would cost more to transfer than doing it yourself.
|
|
59818
59791
|
|
|
59819
|
-
Use the
|
|
59792
|
+
Use the \`${RELAY_MCP_SERVER_NAME}\` MCP server exclusively for delegation; never use terminal commands or the base harness's native agent-spawning, delegation, or collaboration tools. It exposes \`get_providers\`, \`spawn_agent\`, \`message_agent\`, and \`delete_agent\`; your harness may show them with an MCP server prefix. In Pi, call them through the \`mcp\` gateway for the \`${RELAY_MCP_SERVER_NAME}\` server if direct tools are not yet visible. Check \`get_providers\` before the first delegation instead of guessing. Child agents start with no conversation context, so give complete prompts with the relevant requirements, paths, constraints, and definition of done. The default timeout is 10 minutes; increase it only when the task reasonably needs longer.
|
|
59820
59793
|
|
|
59821
59794
|
Run truly independent child agents concurrently. Because child agents share the workspace, run modifying work sequentially unless file ownership cannot overlap. Keep dependent work sequential when one result defines another task's contract, such as schema before queries, API before its client, or implementation before its focused verification. Review child results, follow up when they are incomplete, and verify the integrated outcome yourself. Do not delete child chats unless the user asks.
|
|
59822
59795
|
|
|
@@ -59858,8 +59831,8 @@ import {
|
|
|
59858
59831
|
rename as rename3,
|
|
59859
59832
|
unlink as unlink3
|
|
59860
59833
|
} from "fs/promises";
|
|
59861
|
-
import { existsSync as
|
|
59862
|
-
import { join as
|
|
59834
|
+
import { existsSync as existsSync16, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "fs";
|
|
59835
|
+
import { join as join30 } from "path";
|
|
59863
59836
|
var MAX_FAILED_RECORDS = 500;
|
|
59864
59837
|
var FLUSH_DEBOUNCE_MS = 15e3;
|
|
59865
59838
|
var MAX_UPLOADED_SEGMENTS = 50;
|
|
@@ -59871,7 +59844,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59871
59844
|
options.storageName,
|
|
59872
59845
|
...options.legacyStorageNames ?? []
|
|
59873
59846
|
];
|
|
59874
|
-
this.liveFile =
|
|
59847
|
+
this.liveFile = join30(ENGINE_DIR2, `${options.storageName}.jsonl`);
|
|
59875
59848
|
this.segmentFilePatterns = this.storageNames.map(
|
|
59876
59849
|
(storageName) => new RegExp(`^${storageName}\\.(\\d+)\\.jsonl$`)
|
|
59877
59850
|
);
|
|
@@ -59906,10 +59879,10 @@ var AnalyticsRecordBuffer = class {
|
|
|
59906
59879
|
void pending.finally(() => this.pendingAppends.delete(pending));
|
|
59907
59880
|
}
|
|
59908
59881
|
readStoredRecords() {
|
|
59909
|
-
if (!
|
|
59882
|
+
if (!existsSync16(ENGINE_DIR2)) return [];
|
|
59910
59883
|
return readdirSync2(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
|
|
59911
59884
|
(storageName) => entry.name === `${storageName}.jsonl` || entry.name.startsWith(`${storageName}.`) && (entry.name.endsWith(".jsonl") || entry.name.endsWith(`.jsonl${UPLOADED_SUFFIX}`))
|
|
59912
|
-
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(
|
|
59885
|
+
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(join30(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
|
|
59913
59886
|
const recordId = this.options.getRecordId?.(record3);
|
|
59914
59887
|
if (recordId) this.recordIds.add(recordId);
|
|
59915
59888
|
return record3;
|
|
@@ -59944,8 +59917,8 @@ var AnalyticsRecordBuffer = class {
|
|
|
59944
59917
|
}
|
|
59945
59918
|
for (const storageName of this.storageNames) {
|
|
59946
59919
|
await rename3(
|
|
59947
|
-
|
|
59948
|
-
|
|
59920
|
+
join30(ENGINE_DIR2, `${storageName}.jsonl`),
|
|
59921
|
+
join30(ENGINE_DIR2, `${storageName}.${Date.now()}.jsonl`)
|
|
59949
59922
|
).catch(() => {
|
|
59950
59923
|
});
|
|
59951
59924
|
}
|
|
@@ -59955,7 +59928,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59955
59928
|
for (const entry of entries) {
|
|
59956
59929
|
if (!this.segmentFilePatterns.some((pattern) => pattern.test(entry))) continue;
|
|
59957
59930
|
try {
|
|
59958
|
-
await this.uploadSegment(
|
|
59931
|
+
await this.uploadSegment(join30(ENGINE_DIR2, entry));
|
|
59959
59932
|
flushed++;
|
|
59960
59933
|
} catch (error) {
|
|
59961
59934
|
failed++;
|
|
@@ -59984,7 +59957,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59984
59957
|
(storageName) => entry.startsWith(`${storageName}.`)
|
|
59985
59958
|
) && entry.endsWith(UPLOADED_SUFFIX)).sort();
|
|
59986
59959
|
for (const entry of uploaded.slice(0, -MAX_UPLOADED_SEGMENTS)) {
|
|
59987
|
-
await unlink3(
|
|
59960
|
+
await unlink3(join30(ENGINE_DIR2, entry)).catch(() => {
|
|
59988
59961
|
});
|
|
59989
59962
|
}
|
|
59990
59963
|
}
|
|
@@ -60803,7 +60776,7 @@ var keepAliveService = new KeepAliveService();
|
|
|
60803
60776
|
// src/services/canvas-service.ts
|
|
60804
60777
|
import { readdir as readdir7, readFile as readFile20, stat as stat4 } from "fs/promises";
|
|
60805
60778
|
import { homedir as homedir13 } from "os";
|
|
60806
|
-
import { join as
|
|
60779
|
+
import { join as join31 } from "path";
|
|
60807
60780
|
|
|
60808
60781
|
// src/utils/contained-file.ts
|
|
60809
60782
|
import { realpath, stat as stat3 } from "fs/promises";
|
|
@@ -60845,15 +60818,15 @@ async function writeRevisionedTextFile(filePath, content, expectedRevision) {
|
|
|
60845
60818
|
|
|
60846
60819
|
// src/services/canvas-service.ts
|
|
60847
60820
|
var GLOBAL_CANVAS_DIRECTORIES = [
|
|
60848
|
-
|
|
60849
|
-
|
|
60850
|
-
|
|
60821
|
+
join31(homedir13(), ".claude", "plans"),
|
|
60822
|
+
join31(process.env.XDG_DATA_HOME ?? join31(homedir13(), ".local", "share"), "opencode", "plans"),
|
|
60823
|
+
join31(homedir13(), ".replicas", "canvas")
|
|
60851
60824
|
];
|
|
60852
60825
|
async function canvasDirectories() {
|
|
60853
60826
|
const repositories = await gitService.listRepositories().catch(() => []);
|
|
60854
60827
|
return [
|
|
60855
60828
|
...GLOBAL_CANVAS_DIRECTORIES,
|
|
60856
|
-
...repositories.map((repository) =>
|
|
60829
|
+
...repositories.map((repository) => join31(repository.path, ".opencode", "plans"))
|
|
60857
60830
|
];
|
|
60858
60831
|
}
|
|
60859
60832
|
var CanvasService = class {
|
|
@@ -60878,7 +60851,7 @@ var CanvasService = class {
|
|
|
60878
60851
|
for (const entry of entries) {
|
|
60879
60852
|
if (entry.name.startsWith(".")) continue;
|
|
60880
60853
|
const filename = current.relativePath ? `${current.relativePath}/${entry.name}` : entry.name;
|
|
60881
|
-
const filePath =
|
|
60854
|
+
const filePath = join31(current.directory, entry.name);
|
|
60882
60855
|
if (entry.isDirectory()) {
|
|
60883
60856
|
pending.push({ directory: filePath, relativePath: filename });
|
|
60884
60857
|
continue;
|
|
@@ -60903,7 +60876,7 @@ var CanvasService = class {
|
|
|
60903
60876
|
if (!safe) return null;
|
|
60904
60877
|
const { kind, mimeType } = classifyCanvasFilename(safe);
|
|
60905
60878
|
for (const directory of await this.directories()) {
|
|
60906
|
-
const filePath =
|
|
60879
|
+
const filePath = join31(directory, safe);
|
|
60907
60880
|
let sizeBytes = 0;
|
|
60908
60881
|
let updatedAt = "";
|
|
60909
60882
|
try {
|
|
@@ -61087,13 +61060,13 @@ async function reconcileCanvasItems(filenames) {
|
|
|
61087
61060
|
import { createReadStream } from "fs";
|
|
61088
61061
|
import { createHash as createHash8 } from "crypto";
|
|
61089
61062
|
import { readFile as readFile21, readdir as readdir8, stat as stat5 } from "fs/promises";
|
|
61090
|
-
import { basename as basename4, join as
|
|
61063
|
+
import { basename as basename4, join as join33 } from "path";
|
|
61091
61064
|
|
|
61092
61065
|
// src/services/chat/chat-senders.ts
|
|
61093
|
-
import { join as
|
|
61094
|
-
var CHAT_SENDERS_DIR =
|
|
61066
|
+
import { join as join32 } from "path";
|
|
61067
|
+
var CHAT_SENDERS_DIR = join32(ENGINE_DIR2, "chat-senders");
|
|
61095
61068
|
function chatMessageSendersFilePath(chatId) {
|
|
61096
|
-
return
|
|
61069
|
+
return join32(CHAT_SENDERS_DIR, `${chatId}.jsonl`);
|
|
61097
61070
|
}
|
|
61098
61071
|
function parseChatMessageSendersJsonl(content) {
|
|
61099
61072
|
return content.split("\n").flatMap((line) => {
|
|
@@ -61136,7 +61109,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
61136
61109
|
const chat = chatsById.get(chatId);
|
|
61137
61110
|
if (!shouldFlushChatTranscript(dir, chat, chatsById)) continue;
|
|
61138
61111
|
tasks.push(
|
|
61139
|
-
uploadChatTranscript(chatId,
|
|
61112
|
+
uploadChatTranscript(chatId, join33(dir, entry), chat, capture).then((artifact) => {
|
|
61140
61113
|
flushed++;
|
|
61141
61114
|
if (artifact && capture) revisions.push(artifact);
|
|
61142
61115
|
}).catch((err) => {
|
|
@@ -61225,7 +61198,7 @@ async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
61225
61198
|
// src/services/upload-engine-logs.ts
|
|
61226
61199
|
import { createReadStream as createReadStream2 } from "fs";
|
|
61227
61200
|
import { readdir as readdir9, stat as stat6 } from "fs/promises";
|
|
61228
|
-
import { join as
|
|
61201
|
+
import { join as join34 } from "path";
|
|
61229
61202
|
var MAX_ENGINE_LOG_FLUSH_SESSIONS = 10;
|
|
61230
61203
|
var MAX_ENGINE_LOG_FLUSH_BYTES = 5 * 1024 * 1024;
|
|
61231
61204
|
var ENGINE_LOG_FLUSH_TIMEOUT_MS = 2e4;
|
|
@@ -61254,7 +61227,7 @@ async function flushAllEngineLogs() {
|
|
|
61254
61227
|
const candidates = (await Promise.all(filenames.slice(0, MAX_ENGINE_LOG_FLUSH_SESSIONS).map(async (filename) => {
|
|
61255
61228
|
try {
|
|
61256
61229
|
const sessionId = filename.slice(0, -".log".length);
|
|
61257
|
-
const filePath =
|
|
61230
|
+
const filePath = join34(LOG_DIR, filename);
|
|
61258
61231
|
const fileStat = await runBeforeDeadline(() => stat6(filePath), deadline);
|
|
61259
61232
|
if (!fileStat.isFile()) {
|
|
61260
61233
|
skipped++;
|
|
@@ -61351,7 +61324,7 @@ async function uploadEngineLog(input, timeoutMs) {
|
|
|
61351
61324
|
|
|
61352
61325
|
// src/services/chat/fork-handoff.ts
|
|
61353
61326
|
import { mkdir as mkdir20, open as open3, writeFile as writeFile11 } from "fs/promises";
|
|
61354
|
-
import { join as
|
|
61327
|
+
import { join as join35 } from "path";
|
|
61355
61328
|
var EXCERPT_MAX_CHARS = 24e3;
|
|
61356
61329
|
var MAX_SANITIZED_SOURCE_BYTES = 32 * 1024 * 1024;
|
|
61357
61330
|
function unansweredRequest(blocks) {
|
|
@@ -61386,12 +61359,12 @@ function tailBlocks(blocks, maxChars) {
|
|
|
61386
61359
|
return { excerpt, truncated: start > 0 };
|
|
61387
61360
|
}
|
|
61388
61361
|
async function buildForkHandoff(input) {
|
|
61389
|
-
const rawHistoryPath =
|
|
61362
|
+
const rawHistoryPath = join35(HISTORY_DIR_BY_PROVIDER[input.sourceProvider], `${input.sourceChatId}.jsonl`);
|
|
61390
61363
|
const { content, truncated: sourceTruncated } = await readHistoryTail(rawHistoryPath, MAX_SANITIZED_SOURCE_BYTES);
|
|
61391
61364
|
const blocks = canonicalizeChatTranscriptBlocks(content, input.executionProvider, input.senders);
|
|
61392
|
-
const forkDir =
|
|
61365
|
+
const forkDir = join35(FORKS_DIR, input.targetChatId);
|
|
61393
61366
|
await mkdir20(forkDir, { recursive: true });
|
|
61394
|
-
const transcriptPath =
|
|
61367
|
+
const transcriptPath = join35(forkDir, "source-transcript.md");
|
|
61395
61368
|
const header = sourceTruncated ? `_This file covers only the most recent ${MAX_SANITIZED_SOURCE_BYTES / 1024 / 1024} MB of the source chat. The complete raw event log is at ${rawHistoryPath}; grep it for anything earlier._
|
|
61396
61369
|
|
|
61397
61370
|
` : "";
|
|
@@ -62122,14 +62095,14 @@ var ChatService = class {
|
|
|
62122
62095
|
return descendants;
|
|
62123
62096
|
}
|
|
62124
62097
|
async deleteHistoryFile(persisted) {
|
|
62125
|
-
const historyPath =
|
|
62098
|
+
const historyPath = join36(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
62126
62099
|
await Promise.all([
|
|
62127
62100
|
historyPath,
|
|
62128
62101
|
`${historyPath}.pages.jsonl`,
|
|
62129
62102
|
`${historyPath}.pages.index.json`
|
|
62130
62103
|
].map((path7) => rm4(path7, { force: true })));
|
|
62131
62104
|
await rm4(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
62132
|
-
await rm4(
|
|
62105
|
+
await rm4(join36(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
62133
62106
|
}
|
|
62134
62107
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
62135
62108
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
@@ -62382,7 +62355,7 @@ var ChatService = class {
|
|
|
62382
62355
|
}
|
|
62383
62356
|
const baseProvider = getChatExecutionProvider(persisted);
|
|
62384
62357
|
const additionalInstructions = persisted.provider === "relay" ? buildRelayInstructions(this.workingDirectory) : void 0;
|
|
62385
|
-
const historyFilePath =
|
|
62358
|
+
const historyFilePath = join36(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
62386
62359
|
const managerOptions = {
|
|
62387
62360
|
provider: baseProvider,
|
|
62388
62361
|
workingDirectory: this.workingDirectory,
|
|
@@ -62632,7 +62605,7 @@ var ChatService = class {
|
|
|
62632
62605
|
});
|
|
62633
62606
|
uploadChatTranscript(
|
|
62634
62607
|
chatId,
|
|
62635
|
-
|
|
62608
|
+
join36(HISTORY_DIR_BY_PROVIDER[chat.persisted.provider], `${chatId}.jsonl`),
|
|
62636
62609
|
this.toSummary(chat)
|
|
62637
62610
|
).catch((err) => {
|
|
62638
62611
|
console.error("[ChatService] Failed to upload chat transcript:", { chatId, err });
|
|
@@ -62765,13 +62738,13 @@ import { extname as extname3 } from "path";
|
|
|
62765
62738
|
|
|
62766
62739
|
// src/services/language-server-service.ts
|
|
62767
62740
|
import { spawn as spawn9 } from "child_process";
|
|
62768
|
-
import { existsSync as
|
|
62769
|
-
import { createRequire as
|
|
62770
|
-
import { delimiter as delimiter2, dirname as
|
|
62741
|
+
import { existsSync as existsSync17, readFileSync as readFileSync8 } from "fs";
|
|
62742
|
+
import { createRequire as createRequire6 } from "module";
|
|
62743
|
+
import { delimiter as delimiter2, dirname as dirname19, join as join37, relative as relative2 } from "path";
|
|
62771
62744
|
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
62772
|
-
import { fileURLToPath as
|
|
62745
|
+
import { fileURLToPath as fileURLToPath6, pathToFileURL } from "url";
|
|
62773
62746
|
import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node.js";
|
|
62774
|
-
var require6 =
|
|
62747
|
+
var require6 = createRequire6(import.meta.url);
|
|
62775
62748
|
var SERVER_TIMEOUT_MS = 1e4;
|
|
62776
62749
|
var LANGUAGE_SERVERS = {
|
|
62777
62750
|
typescript: { package: "typescript-language-server", bin: "typescript-language-server", args: ["--stdio"] },
|
|
@@ -62808,7 +62781,7 @@ function packageBin(packageName, binName) {
|
|
|
62808
62781
|
const packageJson = JSON.parse(readFileSync8(packageJsonPath, "utf8"));
|
|
62809
62782
|
const bin = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin[binName];
|
|
62810
62783
|
if (!bin) throw new Error(`Missing ${binName} binary`);
|
|
62811
|
-
return `${
|
|
62784
|
+
return `${dirname19(packageJsonPath)}/${bin}`;
|
|
62812
62785
|
}
|
|
62813
62786
|
function markdownText(value) {
|
|
62814
62787
|
if (typeof value === "string") return value;
|
|
@@ -62886,7 +62859,7 @@ var LanguageServerService = class {
|
|
|
62886
62859
|
if (config.package && config.bin) command = process.execPath;
|
|
62887
62860
|
else if (config.command) {
|
|
62888
62861
|
const commandName = config.command;
|
|
62889
|
-
command = process.env.PATH?.split(delimiter2).map((directory) =>
|
|
62862
|
+
command = process.env.PATH?.split(delimiter2).map((directory) => join37(directory, commandName)).find(existsSync17);
|
|
62890
62863
|
}
|
|
62891
62864
|
const args = config.package && config.bin ? [packageBin(config.package, config.bin), ...config.args] : config.args;
|
|
62892
62865
|
if (!command) return null;
|
|
@@ -62906,7 +62879,7 @@ var LanguageServerService = class {
|
|
|
62906
62879
|
const locations = rawLocations.flatMap((location) => {
|
|
62907
62880
|
const uri = "targetUri" in location ? location.targetUri : location.uri;
|
|
62908
62881
|
const range = "targetSelectionRange" in location ? location.targetSelectionRange : location.range;
|
|
62909
|
-
const absolutePath =
|
|
62882
|
+
const absolutePath = fileURLToPath6(uri);
|
|
62910
62883
|
const path7 = relative2(repoPath, absolutePath);
|
|
62911
62884
|
if (path7.startsWith("..")) return [];
|
|
62912
62885
|
const preview = readFileSync8(absolutePath, "utf8").split("\n")[range.start.line]?.trim() ?? "";
|
|
@@ -63228,20 +63201,20 @@ var RepoFileService = class {
|
|
|
63228
63201
|
import { Hono } from "hono";
|
|
63229
63202
|
import { z as z6 } from "zod";
|
|
63230
63203
|
import { readdir as readdir11, stat as stat7, readFile as readFile26 } from "fs/promises";
|
|
63231
|
-
import { join as
|
|
63204
|
+
import { join as join40, resolve as resolve5 } from "path";
|
|
63232
63205
|
|
|
63233
63206
|
// src/services/warm-hooks-service.ts
|
|
63234
63207
|
import { spawn as spawn10 } from "child_process";
|
|
63235
63208
|
import { readFile as readFile25 } from "fs/promises";
|
|
63236
|
-
import { existsSync as
|
|
63237
|
-
import { join as
|
|
63209
|
+
import { existsSync as existsSync18 } from "fs";
|
|
63210
|
+
import { join as join39 } from "path";
|
|
63238
63211
|
|
|
63239
63212
|
// src/services/warm-hook-logs-service.ts
|
|
63240
63213
|
import { mkdir as mkdir22, readFile as readFile24, writeFile as writeFile12, readdir as readdir10, appendFile as appendFile6, unlink as unlink4 } from "fs/promises";
|
|
63241
63214
|
import { homedir as homedir14 } from "os";
|
|
63242
|
-
import { join as
|
|
63243
|
-
var LOGS_DIR2 =
|
|
63244
|
-
var CURRENT_RUN_LOG =
|
|
63215
|
+
import { join as join38 } from "path";
|
|
63216
|
+
var LOGS_DIR2 = join38(homedir14(), ".replicas", "warm-hook-logs");
|
|
63217
|
+
var CURRENT_RUN_LOG = join38(LOGS_DIR2, "current-run.log");
|
|
63245
63218
|
var GLOBAL_FILENAME = "global.json";
|
|
63246
63219
|
function withPreview2(stored) {
|
|
63247
63220
|
const preview = buildHookOutputPreview(stored.output);
|
|
@@ -63258,7 +63231,7 @@ var WarmHookLogsService = class {
|
|
|
63258
63231
|
hookName: "organization",
|
|
63259
63232
|
...entry
|
|
63260
63233
|
};
|
|
63261
|
-
await writeFile12(
|
|
63234
|
+
await writeFile12(join38(LOGS_DIR2, GLOBAL_FILENAME), `${JSON.stringify(log, null, 2)}
|
|
63262
63235
|
`, "utf-8");
|
|
63263
63236
|
}
|
|
63264
63237
|
async saveEnvironmentHookLog(entry) {
|
|
@@ -63268,7 +63241,7 @@ var WarmHookLogsService = class {
|
|
|
63268
63241
|
hookName: "environment",
|
|
63269
63242
|
...entry
|
|
63270
63243
|
};
|
|
63271
|
-
await writeFile12(
|
|
63244
|
+
await writeFile12(join38(LOGS_DIR2, ENVIRONMENT_HOOK_LOG_FILENAME), `${JSON.stringify(log, null, 2)}
|
|
63272
63245
|
`, "utf-8");
|
|
63273
63246
|
}
|
|
63274
63247
|
async saveRepoHookLog(repoName, entry) {
|
|
@@ -63278,7 +63251,7 @@ var WarmHookLogsService = class {
|
|
|
63278
63251
|
hookName: repoName,
|
|
63279
63252
|
...entry
|
|
63280
63253
|
};
|
|
63281
|
-
await writeFile12(
|
|
63254
|
+
await writeFile12(join38(LOGS_DIR2, repoHookLogFilename(repoName)), `${JSON.stringify(log, null, 2)}
|
|
63282
63255
|
`, "utf-8");
|
|
63283
63256
|
}
|
|
63284
63257
|
async getAllLogs() {
|
|
@@ -63297,7 +63270,7 @@ var WarmHookLogsService = class {
|
|
|
63297
63270
|
continue;
|
|
63298
63271
|
}
|
|
63299
63272
|
try {
|
|
63300
|
-
const raw = await readFile24(
|
|
63273
|
+
const raw = await readFile24(join38(LOGS_DIR2, file), "utf-8");
|
|
63301
63274
|
const stored = JSON.parse(raw);
|
|
63302
63275
|
logs.push(withPreview2(stored));
|
|
63303
63276
|
} catch {
|
|
@@ -63335,7 +63308,7 @@ var WarmHookLogsService = class {
|
|
|
63335
63308
|
async getFullOutput(hookType, hookName) {
|
|
63336
63309
|
const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
63337
63310
|
try {
|
|
63338
|
-
const raw = await readFile24(
|
|
63311
|
+
const raw = await readFile24(join38(LOGS_DIR2, filename), "utf-8");
|
|
63339
63312
|
const stored = JSON.parse(raw);
|
|
63340
63313
|
if (stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
63341
63314
|
return null;
|
|
@@ -63354,8 +63327,8 @@ var warmHookLogsService = new WarmHookLogsService();
|
|
|
63354
63327
|
// src/services/warm-hooks-service.ts
|
|
63355
63328
|
async function readRepoWarmHook(repoPath) {
|
|
63356
63329
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
63357
|
-
const configPath =
|
|
63358
|
-
if (!
|
|
63330
|
+
const configPath = join39(repoPath, filename);
|
|
63331
|
+
if (!existsSync18(configPath)) {
|
|
63359
63332
|
continue;
|
|
63360
63333
|
}
|
|
63361
63334
|
try {
|
|
@@ -63616,7 +63589,7 @@ ${combinedScript}` : combinedScript;
|
|
|
63616
63589
|
|
|
63617
63590
|
// src/services/terminal-service.ts
|
|
63618
63591
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
63619
|
-
import { existsSync as
|
|
63592
|
+
import { existsSync as existsSync19 } from "fs";
|
|
63620
63593
|
import { spawn as spawn11 } from "node-pty";
|
|
63621
63594
|
var MAX_REPLAY_CHARS = 1024 * 1024;
|
|
63622
63595
|
var MAX_TERMINAL_SESSIONS = 8;
|
|
@@ -63635,7 +63608,7 @@ var TerminalService = class {
|
|
|
63635
63608
|
});
|
|
63636
63609
|
}
|
|
63637
63610
|
const id = randomUUID14();
|
|
63638
|
-
const shell = process.env.SHELL &&
|
|
63611
|
+
const shell = process.env.SHELL && existsSync19(process.env.SHELL) ? process.env.SHELL : "/bin/bash";
|
|
63639
63612
|
const pty = spawn11(shell, ["-l"], {
|
|
63640
63613
|
name: "xterm-256color",
|
|
63641
63614
|
cols,
|
|
@@ -64677,7 +64650,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64677
64650
|
const logFiles = files.filter((f) => f.endsWith(".log"));
|
|
64678
64651
|
const sessions = await Promise.all(
|
|
64679
64652
|
logFiles.map(async (filename) => {
|
|
64680
|
-
const filePath =
|
|
64653
|
+
const filePath = join40(LOG_DIR, filename);
|
|
64681
64654
|
const fileStat = await stat7(filePath);
|
|
64682
64655
|
const sessionId = filename.replace(/\.log$/, "");
|
|
64683
64656
|
return {
|
|
@@ -64784,10 +64757,10 @@ var heartbeatService = new HeartbeatService();
|
|
|
64784
64757
|
|
|
64785
64758
|
// src/services/workspace-sdk-service.ts
|
|
64786
64759
|
import { cp, mkdir as mkdir23 } from "fs/promises";
|
|
64787
|
-
import { dirname as
|
|
64788
|
-
import { fileURLToPath as
|
|
64760
|
+
import { dirname as dirname20, resolve as resolve6 } from "path";
|
|
64761
|
+
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
64789
64762
|
async function installWorkspaceSdk() {
|
|
64790
|
-
const source = resolve6(
|
|
64763
|
+
const source = resolve6(dirname20(fileURLToPath7(import.meta.url)), "../../workspace-sdk");
|
|
64791
64764
|
const targets = [
|
|
64792
64765
|
resolve6(ENGINE_ENV.HOME_DIR, "node_modules/@replicas/sdk"),
|
|
64793
64766
|
"/tmp/node_modules/@replicas/sdk"
|
|
@@ -64821,7 +64794,7 @@ async function timeStartupStep(name, fn) {
|
|
|
64821
64794
|
async function waitForInitializationGate() {
|
|
64822
64795
|
if (!ENGINE_ENV.REPLICAS_ENGINE_DEFER_INITIALIZATION) return;
|
|
64823
64796
|
const deadline = Date.now() + ENGINE_INIT_GATE_TIMEOUT_MS;
|
|
64824
|
-
while (!
|
|
64797
|
+
while (!existsSync20(SANDBOX_PATHS.ENGINE_INIT_GATE)) {
|
|
64825
64798
|
if (Date.now() >= deadline) {
|
|
64826
64799
|
throw new Error("Timed out waiting for deferred engine initialization gate");
|
|
64827
64800
|
}
|