replicas-engine 0.1.861 → 0.1.863
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-ILUBLDEI.js → asp-host-CM65PFT7.js} +4 -4
- package/dist/src/{chunk-6W3WWFMF.js → chunk-6B2CUGV3.js} +1 -1
- package/dist/src/{chunk-4AQH6PWH.js → chunk-747EKU2K.js} +18 -0
- package/dist/src/{chunk-AN25X54K.js → chunk-A3GYC2GM.js} +2 -2
- package/dist/src/{chunk-66QA65ND.js → chunk-DN6EFXHX.js} +1 -1
- package/dist/src/{chunk-VSP7P7GW.js → chunk-F5XX27N5.js} +2 -2
- package/dist/src/{chunk-5V24YBKM.js → chunk-QJPJ6RY5.js} +5 -5
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +4 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +167 -132
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
getCodexAspHost,
|
|
6
6
|
restartCodexAspHost,
|
|
7
7
|
restartCodexAspHostIfRunning
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-QJPJ6RY5.js";
|
|
9
|
+
import "./chunk-DN6EFXHX.js";
|
|
10
|
+
import "./chunk-F5XX27N5.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-747EKU2K.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
export {
|
|
15
15
|
getCodexAspHost,
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
shouldRefreshPullRequests
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-747EKU2K.js";
|
|
7
7
|
|
|
8
8
|
// src/services/post-tool-pr-notifier.ts
|
|
9
9
|
async function notifyPostToolUse(toolName, toolInput) {
|
|
@@ -7871,6 +7871,23 @@ function parseChatTranscriptArtifact(value) {
|
|
|
7871
7871
|
};
|
|
7872
7872
|
}
|
|
7873
7873
|
|
|
7874
|
+
// ../shared/src/frontmatter.ts
|
|
7875
|
+
import { parse as parseYaml2 } from "yaml";
|
|
7876
|
+
function parseFrontmatter(content) {
|
|
7877
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
7878
|
+
if (!match) return {};
|
|
7879
|
+
try {
|
|
7880
|
+
const parsed = parseYaml2(match[1]);
|
|
7881
|
+
if (typeof parsed !== "object" || parsed === null) return {};
|
|
7882
|
+
return {
|
|
7883
|
+
..."name" in parsed && typeof parsed.name === "string" ? { name: parsed.name.trim() } : {},
|
|
7884
|
+
..."description" in parsed && typeof parsed.description === "string" ? { description: parsed.description.trim() } : {}
|
|
7885
|
+
};
|
|
7886
|
+
} catch {
|
|
7887
|
+
return {};
|
|
7888
|
+
}
|
|
7889
|
+
}
|
|
7890
|
+
|
|
7874
7891
|
// ../shared/src/skill-registry.ts
|
|
7875
7892
|
var SKILL_REGISTRY_MANIFEST_VERSION = 1;
|
|
7876
7893
|
function isSkillRegistryManifest(value) {
|
|
@@ -8106,5 +8123,6 @@ export {
|
|
|
8106
8123
|
createChatTranscriptPages,
|
|
8107
8124
|
parseChatTranscriptArtifact,
|
|
8108
8125
|
readSseStream,
|
|
8126
|
+
parseFrontmatter,
|
|
8109
8127
|
isSkillRegistryManifest
|
|
8110
8128
|
};
|
|
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
monolithRequest
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DN6EFXHX.js";
|
|
7
7
|
import {
|
|
8
8
|
extractCommandProtectionCommandText,
|
|
9
9
|
findGitCommitSignals,
|
|
10
10
|
findPrMergeSignals
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-747EKU2K.js";
|
|
12
12
|
|
|
13
13
|
// src/services/command-protection-service.ts
|
|
14
14
|
var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
6
6
|
isVersionBelow
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-747EKU2K.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/codex-agent-env.ts
|
|
10
10
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -241,7 +241,7 @@ var DEFAULT_CODEX_ARGS = [
|
|
|
241
241
|
var MIN_CODEX_CLI_VERSION = "0.153.3";
|
|
242
242
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
243
243
|
var codexCliVersionEnsured = null;
|
|
244
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
244
|
+
var ENGINE_PACKAGE_VERSION = "0.1.863";
|
|
245
245
|
var INITIALIZE_METHOD = "initialize";
|
|
246
246
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
247
247
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
setAgentCredentialSnapshot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-DN6EFXHX.js";
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
11
|
SUBPROCESS_MAX_BUFFER,
|
|
12
12
|
buildCodexAgentEnv,
|
|
13
13
|
execFileAsync
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-F5XX27N5.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
17
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
createSuccessResult,
|
|
24
24
|
listOpenAICompatibleModels,
|
|
25
25
|
resolveOpenAICompatibleModelsUrl
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-747EKU2K.js";
|
|
27
27
|
|
|
28
28
|
// src/managers/codex-token-manager.ts
|
|
29
29
|
import { promises as fs } from "fs";
|
|
@@ -244,7 +244,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
244
244
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
245
245
|
await this.applyCredentialsResponse(data);
|
|
246
246
|
if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
|
|
247
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
247
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-CM65PFT7.js");
|
|
248
248
|
await restartCodexAspHostIfRunning2();
|
|
249
249
|
});
|
|
250
250
|
await this.start(true);
|
|
@@ -264,7 +264,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
264
264
|
await this.applyCredentialUpdate(generation, async () => {
|
|
265
265
|
await this.applyCredentialsResponse(data);
|
|
266
266
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
267
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
267
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-CM65PFT7.js");
|
|
268
268
|
await restartCodexAspHostIfRunning2();
|
|
269
269
|
}
|
|
270
270
|
if (data.scope) {
|
|
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-A3GYC2GM.js";
|
|
7
|
+
import "./chunk-DN6EFXHX.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-747EKU2K.js";
|
|
12
12
|
import "./chunk-VEQXQN22.js";
|
|
13
13
|
|
|
14
14
|
// src/command-protection-hook.ts
|
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-A3GYC2GM.js";
|
|
7
7
|
import {
|
|
8
8
|
notifyPostToolUse
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-6B2CUGV3.js";
|
|
10
|
+
import "./chunk-DN6EFXHX.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-747EKU2K.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/deepseek-command-protection-plugin.ts
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
AppServerProcess,
|
|
10
10
|
buildCodexAgentEnv
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-F5XX27N5.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
getMemoryOutputSafetyViolation,
|
|
15
15
|
headlessAgentRequestSchema
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-747EKU2K.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
|
|
19
19
|
// src/headless-agent.ts
|
package/dist/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
evaluateCommandProtection,
|
|
92
92
|
extractToolCommand,
|
|
93
93
|
reportCommandProtectionBlock
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-A3GYC2GM.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -132,20 +132,20 @@ import {
|
|
|
132
132
|
recordCredentialFallback,
|
|
133
133
|
recordExhaustedCredential,
|
|
134
134
|
restartCodexAspHost
|
|
135
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-QJPJ6RY5.js";
|
|
136
136
|
import {
|
|
137
137
|
ENGINE_ENV,
|
|
138
138
|
IS_WARMING_MODE,
|
|
139
139
|
monolithRequest,
|
|
140
140
|
monolithService,
|
|
141
141
|
setAgentCredentialSnapshot
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-DN6EFXHX.js";
|
|
143
143
|
import {
|
|
144
144
|
AspClient,
|
|
145
145
|
SUBPROCESS_MAX_BUFFER,
|
|
146
146
|
execAsync,
|
|
147
147
|
execFileAsync
|
|
148
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-F5XX27N5.js";
|
|
149
149
|
import {
|
|
150
150
|
isRecord as isRecord2
|
|
151
151
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -334,6 +334,7 @@ import {
|
|
|
334
334
|
parseChatHistoryCursor,
|
|
335
335
|
parseChatTranscriptArtifact,
|
|
336
336
|
parseDisplayMessages,
|
|
337
|
+
parseFrontmatter,
|
|
337
338
|
parseGitRemote,
|
|
338
339
|
parseLatestCodexAspTranscriptTurn,
|
|
339
340
|
parseMcpToolName,
|
|
@@ -356,7 +357,7 @@ import {
|
|
|
356
357
|
waitRelaySubagentRequestSchema,
|
|
357
358
|
withTimeout,
|
|
358
359
|
workspaceCredentialProviderSchema
|
|
359
|
-
} from "./chunk-
|
|
360
|
+
} from "./chunk-747EKU2K.js";
|
|
360
361
|
import {
|
|
361
362
|
__commonJS,
|
|
362
363
|
__export,
|
|
@@ -10699,8 +10700,8 @@ async function registerDesktopPreview() {
|
|
|
10699
10700
|
}
|
|
10700
10701
|
|
|
10701
10702
|
// src/services/chat/chat-service.ts
|
|
10702
|
-
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir21, readFile as
|
|
10703
|
-
import { join as
|
|
10703
|
+
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir21, readFile as readFile24, rename as rename4, rm as rm4 } from "fs/promises";
|
|
10704
|
+
import { join as join37 } from "path";
|
|
10704
10705
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
10705
10706
|
|
|
10706
10707
|
// ../shared/src/workspace-chat.ts
|
|
@@ -16275,7 +16276,6 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
16275
16276
|
// src/managers/cursor-manager.ts
|
|
16276
16277
|
import { mkdir as mkdir12, readFile as readFile13, readdir as readdir6 } from "fs/promises";
|
|
16277
16278
|
import { basename as basename2, dirname as dirname6, extname, join as join20 } from "path";
|
|
16278
|
-
import { parse as parseYaml } from "yaml";
|
|
16279
16279
|
import { Agent as CursorAgent2 } from "@cursor/sdk";
|
|
16280
16280
|
|
|
16281
16281
|
// src/services/native-command-protection-hooks.ts
|
|
@@ -16451,14 +16451,7 @@ function finiteNumber(value) {
|
|
|
16451
16451
|
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
16452
16452
|
}
|
|
16453
16453
|
function extractCursorCommandDescription(content) {
|
|
16454
|
-
|
|
16455
|
-
if (!match) return void 0;
|
|
16456
|
-
try {
|
|
16457
|
-
const parsed = parseYaml(match[1]);
|
|
16458
|
-
if (isRecord2(parsed) && typeof parsed.description === "string") return parsed.description;
|
|
16459
|
-
} catch {
|
|
16460
|
-
}
|
|
16461
|
-
return void 0;
|
|
16454
|
+
return parseFrontmatter(content).description;
|
|
16462
16455
|
}
|
|
16463
16456
|
async function listCursorCommandsInDirectory(directory) {
|
|
16464
16457
|
let entries;
|
|
@@ -17353,13 +17346,13 @@ ${request.message}` : request.message;
|
|
|
17353
17346
|
};
|
|
17354
17347
|
|
|
17355
17348
|
// src/managers/fx-manager.ts
|
|
17356
|
-
import { readFile as
|
|
17349
|
+
import { readFile as readFile17 } from "fs/promises";
|
|
17357
17350
|
import { spawn as spawn5 } from "child_process";
|
|
17358
17351
|
|
|
17359
17352
|
// src/managers/acp-manager.ts
|
|
17360
17353
|
import { spawn as spawn4 } from "child_process";
|
|
17361
17354
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
17362
|
-
import { mkdir as mkdir14, readFile as
|
|
17355
|
+
import { mkdir as mkdir14, readFile as readFile16, writeFile as writeFile8 } from "fs/promises";
|
|
17363
17356
|
import { dirname as dirname8 } from "path";
|
|
17364
17357
|
import { Writable } from "stream";
|
|
17365
17358
|
import {
|
|
@@ -17368,6 +17361,47 @@ import {
|
|
|
17368
17361
|
methods,
|
|
17369
17362
|
ndJsonStream
|
|
17370
17363
|
} from "@agentclientprotocol/sdk";
|
|
17364
|
+
|
|
17365
|
+
// src/services/installed-skill-service.ts
|
|
17366
|
+
import { readFile as readFile15, readdir as readdir7 } from "fs/promises";
|
|
17367
|
+
import { join as join22 } from "path";
|
|
17368
|
+
var installedSkillsByHome = /* @__PURE__ */ new Map();
|
|
17369
|
+
function isNotFoundError2(error) {
|
|
17370
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
17371
|
+
}
|
|
17372
|
+
async function loadInstalledSkills(homeDir) {
|
|
17373
|
+
const skillsDir = join22(homeDir, ".agents/skills");
|
|
17374
|
+
let entries;
|
|
17375
|
+
try {
|
|
17376
|
+
entries = await readdir7(skillsDir, { withFileTypes: true });
|
|
17377
|
+
} catch (error) {
|
|
17378
|
+
if (!isNotFoundError2(error)) console.warn("[InstalledSkills] Failed to list installed skills:", error);
|
|
17379
|
+
return [];
|
|
17380
|
+
}
|
|
17381
|
+
const skills = await Promise.all(entries.filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map(async (entry) => {
|
|
17382
|
+
try {
|
|
17383
|
+
const metadata = parseFrontmatter(await readFile15(join22(skillsDir, entry.name, "SKILL.md"), "utf8"));
|
|
17384
|
+
return metadata.name && metadata.description ? metadata : null;
|
|
17385
|
+
} catch (error) {
|
|
17386
|
+
if (!isNotFoundError2(error)) console.warn(`[InstalledSkills] Failed to read ${entry.name}:`, error);
|
|
17387
|
+
return null;
|
|
17388
|
+
}
|
|
17389
|
+
}));
|
|
17390
|
+
return skills.filter((skill) => skill !== null);
|
|
17391
|
+
}
|
|
17392
|
+
async function getInstalledSkillsAsSlashCommands(homeDir, provider) {
|
|
17393
|
+
let installedSkills = installedSkillsByHome.get(homeDir);
|
|
17394
|
+
if (!installedSkills) {
|
|
17395
|
+
installedSkills = loadInstalledSkills(homeDir);
|
|
17396
|
+
installedSkillsByHome.set(homeDir, installedSkills);
|
|
17397
|
+
}
|
|
17398
|
+
return (await installedSkills).flatMap(({ name, description }) => {
|
|
17399
|
+
const command = createProviderSlashCommand(provider, name, description);
|
|
17400
|
+
return command ? [command] : [];
|
|
17401
|
+
});
|
|
17402
|
+
}
|
|
17403
|
+
|
|
17404
|
+
// src/managers/acp-manager.ts
|
|
17371
17405
|
function selectOptions(option) {
|
|
17372
17406
|
if (option.type !== "select") return [];
|
|
17373
17407
|
return option.options.flatMap((entry) => "group" in entry ? entry.options : [entry]);
|
|
@@ -17431,7 +17465,7 @@ var AcpManager = class extends CodingAgentManager {
|
|
|
17431
17465
|
});
|
|
17432
17466
|
const app2 = client({ name: "Replicas" }).onNotification(methods.client.session.update, ({ params }) => this.recordUpdate(params)).onRequest(methods.client.fs.readTextFile, async ({ params }) => {
|
|
17433
17467
|
this.assertSession(params.sessionId);
|
|
17434
|
-
const content = await
|
|
17468
|
+
const content = await readFile16(params.path, "utf8");
|
|
17435
17469
|
if (params.line === void 0 && params.limit === void 0) return { content };
|
|
17436
17470
|
const start = Math.max(0, (params.line ?? 1) - 1);
|
|
17437
17471
|
const end = params.limit === null || params.limit === void 0 ? void 0 : start + params.limit;
|
|
@@ -17796,7 +17830,8 @@ ${request.message}` : request.message
|
|
|
17796
17830
|
}
|
|
17797
17831
|
async listSlashCommands() {
|
|
17798
17832
|
await this.initialized;
|
|
17799
|
-
|
|
17833
|
+
const localSkills = await getInstalledSkillsAsSlashCommands(ENGINE_ENV.HOME_DIR, this.acp.provider);
|
|
17834
|
+
return mergeSlashCommands(this.slashCommands, localSkills);
|
|
17800
17835
|
}
|
|
17801
17836
|
dispose() {
|
|
17802
17837
|
for (const terminal of this.terminals.values()) {
|
|
@@ -17821,7 +17856,7 @@ ${request.message}` : request.message
|
|
|
17821
17856
|
|
|
17822
17857
|
// src/managers/fx-manager.ts
|
|
17823
17858
|
async function ensureResolvableDnsConfig() {
|
|
17824
|
-
const contents = await
|
|
17859
|
+
const contents = await readFile17("/etc/resolv.conf");
|
|
17825
17860
|
if (contents.length === 0 || contents.at(-1) === 10) return;
|
|
17826
17861
|
await new Promise((resolve7, reject) => {
|
|
17827
17862
|
const child = spawn5("sudo", ["tee", "-a", "/etc/resolv.conf"], { stdio: ["pipe", "ignore", "pipe"] });
|
|
@@ -18431,8 +18466,8 @@ ${pending}
|
|
|
18431
18466
|
|
|
18432
18467
|
// src/managers/opencode-manager.ts
|
|
18433
18468
|
import { existsSync as existsSync10 } from "fs";
|
|
18434
|
-
import { copyFile, mkdir as mkdir16, readFile as
|
|
18435
|
-
import { delimiter, dirname as dirname10, join as
|
|
18469
|
+
import { copyFile, mkdir as mkdir16, readFile as readFile18, rm as rm2 } from "fs/promises";
|
|
18470
|
+
import { delimiter, dirname as dirname10, join as join23 } from "path";
|
|
18436
18471
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18437
18472
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
18438
18473
|
import { Agent } from "undici";
|
|
@@ -18461,10 +18496,10 @@ async function getAllowedOpenRouterModels() {
|
|
|
18461
18496
|
|
|
18462
18497
|
// src/managers/opencode-manager.ts
|
|
18463
18498
|
var OPENCODE_SHIM_DIR = dirname10(fileURLToPath3(new URL("../../scripts/opencode", import.meta.url)));
|
|
18464
|
-
var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE =
|
|
18465
|
-
var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH =
|
|
18466
|
-
var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH =
|
|
18467
|
-
var OPENCODE_CONFIG_PATH =
|
|
18499
|
+
var OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE = join23(OPENCODE_SHIM_DIR, "opencode-command-protection-plugin.ts");
|
|
18500
|
+
var OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH = join23(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.ts");
|
|
18501
|
+
var OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH = join23(ENGINE_ENV.HOME_DIR, ".config", "opencode", "plugins", "replicas-command-protection.mjs");
|
|
18502
|
+
var OPENCODE_CONFIG_PATH = join23(ENGINE_ENV.HOME_DIR, ".config", "opencode", "opencode.json");
|
|
18468
18503
|
var OPENCODE_FETCH_DISPATCHER = new Agent({ headersTimeout: 0, bodyTimeout: 0 });
|
|
18469
18504
|
var OPENCODE_SERVER_STARTUP_TIMEOUT_MS = 3e4;
|
|
18470
18505
|
var OPENCODE_WORKSPACE_PERMISSION = "allow";
|
|
@@ -18485,7 +18520,7 @@ var opencodeAuthSchema = z3.record(z3.string(), z3.object({
|
|
|
18485
18520
|
async function hasOpencodeCredentials(provider) {
|
|
18486
18521
|
if (!existsSync10(OPENCODE_AUTH_PATH)) return false;
|
|
18487
18522
|
try {
|
|
18488
|
-
const auth2 = opencodeAuthSchema.safeParse(JSON.parse(await
|
|
18523
|
+
const auth2 = opencodeAuthSchema.safeParse(JSON.parse(await readFile18(OPENCODE_AUTH_PATH, "utf8")));
|
|
18489
18524
|
return auth2.success && auth2.data[provider]?.type === "api" && Boolean(auth2.data[provider]?.key);
|
|
18490
18525
|
} catch {
|
|
18491
18526
|
return false;
|
|
@@ -18590,7 +18625,7 @@ function isOpencodeMcpEntry(value) {
|
|
|
18590
18625
|
async function readProvisionedOpencodeMcpConfig() {
|
|
18591
18626
|
let raw;
|
|
18592
18627
|
try {
|
|
18593
|
-
raw = await
|
|
18628
|
+
raw = await readFile18(OPENCODE_CONFIG_PATH, "utf8");
|
|
18594
18629
|
} catch (error) {
|
|
18595
18630
|
if (isRecord2(error) && error.code === "ENOENT") return void 0;
|
|
18596
18631
|
console.error("[OpencodeManager] Failed to read Opencode config:", error);
|
|
@@ -18676,7 +18711,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
18676
18711
|
constructor(options) {
|
|
18677
18712
|
super({ ...options, provider: "opencode" });
|
|
18678
18713
|
this.sessionId = options.initialSessionId;
|
|
18679
|
-
this.historyFilePath = options.historyFilePath ??
|
|
18714
|
+
this.historyFilePath = options.historyFilePath ?? join23(ENGINE_ENV.HOME_DIR, ".replicas", "opencode", "history.jsonl");
|
|
18680
18715
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
18681
18716
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
18682
18717
|
}
|
|
@@ -19096,8 +19131,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
19096
19131
|
};
|
|
19097
19132
|
|
|
19098
19133
|
// src/managers/pi-manager.ts
|
|
19099
|
-
import { mkdir as mkdir18, readFile as
|
|
19100
|
-
import { dirname as dirname18, join as
|
|
19134
|
+
import { mkdir as mkdir18, readFile as readFile19 } from "fs/promises";
|
|
19135
|
+
import { dirname as dirname18, join as join30 } from "path";
|
|
19101
19136
|
import {
|
|
19102
19137
|
createAgentSession,
|
|
19103
19138
|
ModelRegistry,
|
|
@@ -41636,7 +41671,7 @@ async function probeMcpEndpoint(url3) {
|
|
|
41636
41671
|
|
|
41637
41672
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
|
|
41638
41673
|
import { existsSync as existsSync11, readFileSync as readFileSync4, realpathSync, readdirSync, statSync, writeFileSync, renameSync, mkdirSync, openSync, readSync, closeSync, unlinkSync } from "fs";
|
|
41639
|
-
import { join as
|
|
41674
|
+
import { join as join24, dirname as dirname11, extname as extname2, resolve as resolve2, sep } from "path";
|
|
41640
41675
|
|
|
41641
41676
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
|
|
41642
41677
|
function throwIfAborted(signal) {
|
|
@@ -41793,7 +41828,7 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
41793
41828
|
const { packageName, exactVersion } = parsedSpec;
|
|
41794
41829
|
const packageDir = findCachedPackageDir(cacheDir, packageName, exactVersion);
|
|
41795
41830
|
if (!packageDir) return null;
|
|
41796
|
-
const packageJsonPath =
|
|
41831
|
+
const packageJsonPath = join24(packageDir, "package.json");
|
|
41797
41832
|
if (!existsSync11(packageJsonPath)) return null;
|
|
41798
41833
|
let pkg = null;
|
|
41799
41834
|
try {
|
|
@@ -41827,7 +41862,7 @@ function resolveFromNpmCache(packageSpec, binName) {
|
|
|
41827
41862
|
}
|
|
41828
41863
|
if (!binRel) return null;
|
|
41829
41864
|
const nodeModulesDir = findNodeModulesDir(packageDir);
|
|
41830
|
-
const binLink = chosenBinName ?
|
|
41865
|
+
const binLink = chosenBinName ? join24(nodeModulesDir, ".bin", chosenBinName) : null;
|
|
41831
41866
|
let resolvedBin = binLink && existsSync11(binLink) ? safeRealpath(binLink) : "";
|
|
41832
41867
|
if (!resolvedBin) {
|
|
41833
41868
|
resolvedBin = resolve2(packageDir, binRel);
|
|
@@ -41929,17 +41964,17 @@ function defaultBinName(packageName) {
|
|
|
41929
41964
|
return packageName;
|
|
41930
41965
|
}
|
|
41931
41966
|
function findCachedPackageDir(cacheDir, packageName, exactVersion) {
|
|
41932
|
-
const npxDir =
|
|
41967
|
+
const npxDir = join24(cacheDir, "_npx");
|
|
41933
41968
|
if (!existsSync11(npxDir)) return null;
|
|
41934
41969
|
const packagePathParts = packageName.startsWith("@") ? packageName.split("/") : [packageName];
|
|
41935
41970
|
const candidates = readdirSync(npxDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
41936
|
-
const full =
|
|
41971
|
+
const full = join24(npxDir, entry.name);
|
|
41937
41972
|
const mtime = safeStatMtime(full);
|
|
41938
41973
|
return { name: entry.name, mtime };
|
|
41939
41974
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
41940
41975
|
for (const entry of candidates) {
|
|
41941
|
-
const pkgDir =
|
|
41942
|
-
const packageJsonPath =
|
|
41976
|
+
const pkgDir = join24(npxDir, entry.name, "node_modules", ...packagePathParts);
|
|
41977
|
+
const packageJsonPath = join24(pkgDir, "package.json");
|
|
41943
41978
|
if (!existsSync11(packageJsonPath)) continue;
|
|
41944
41979
|
if (exactVersion) {
|
|
41945
41980
|
try {
|
|
@@ -41959,7 +41994,7 @@ function findNodeModulesDir(packageDir) {
|
|
|
41959
41994
|
if (idx >= 0) {
|
|
41960
41995
|
return parts.slice(0, idx + 1).join(sep);
|
|
41961
41996
|
}
|
|
41962
|
-
return
|
|
41997
|
+
return join24(packageDir, "..");
|
|
41963
41998
|
}
|
|
41964
41999
|
function detectJsBinary(binPath) {
|
|
41965
42000
|
const ext = extname2(binPath).toLowerCase();
|
|
@@ -42151,7 +42186,7 @@ import { spawnSync } from "child_process";
|
|
|
42151
42186
|
import { createHash as createHash3 } from "crypto";
|
|
42152
42187
|
import { createRequire as createRequire2 } from "module";
|
|
42153
42188
|
import { readFileSync as readFileSync5, existsSync as existsSync12, rmSync } from "fs";
|
|
42154
|
-
import { dirname as dirname12, join as
|
|
42189
|
+
import { dirname as dirname12, join as join25 } from "path";
|
|
42155
42190
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
42156
42191
|
var require3 = createRequire2(import.meta.url);
|
|
42157
42192
|
var AUTH_SECRET_SERVICE = "pi-mcp-adapter.oauth";
|
|
@@ -42307,7 +42342,7 @@ function loadKeyringNativeBindingFallback(keyringRequire, platform3, arch2) {
|
|
|
42307
42342
|
for (const target of targets) {
|
|
42308
42343
|
try {
|
|
42309
42344
|
const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
|
|
42310
|
-
return keyringRequire(
|
|
42345
|
+
return keyringRequire(join25(dirname12(packageJsonPath), target.bindingFile));
|
|
42311
42346
|
} catch (error) {
|
|
42312
42347
|
lastError = error;
|
|
42313
42348
|
}
|
|
@@ -42412,7 +42447,7 @@ function getServerDir(serverName, options) {
|
|
|
42412
42447
|
throw new Error(`Invalid MCP server name: ${JSON.stringify(serverName)}`);
|
|
42413
42448
|
}
|
|
42414
42449
|
const storageKey = getAuthEntryAccount(serverName);
|
|
42415
|
-
return
|
|
42450
|
+
return join25(getAuthBaseDir(options), storageKey);
|
|
42416
42451
|
}
|
|
42417
42452
|
function getAuthEntryAccount(serverName) {
|
|
42418
42453
|
if (typeof serverName !== "string") {
|
|
@@ -42421,7 +42456,7 @@ function getAuthEntryAccount(serverName) {
|
|
|
42421
42456
|
return `sha256-${createHash3("sha256").update(serverName, "utf8").digest("hex")}`;
|
|
42422
42457
|
}
|
|
42423
42458
|
function getAuthEntryFilePath(serverName, options) {
|
|
42424
|
-
return
|
|
42459
|
+
return join25(getServerDir(serverName, options), "tokens.json");
|
|
42425
42460
|
}
|
|
42426
42461
|
function parseJsonPayload(serverName, payload, source) {
|
|
42427
42462
|
try {
|
|
@@ -45024,7 +45059,7 @@ async function shutdownOAuth(runtime = legacyRuntime) {
|
|
|
45024
45059
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-bearer-store.ts
|
|
45025
45060
|
import { createHash as createHash4 } from "crypto";
|
|
45026
45061
|
import { createRequire as createRequire3 } from "module";
|
|
45027
|
-
import { dirname as dirname13, join as
|
|
45062
|
+
import { dirname as dirname13, join as join26 } from "path";
|
|
45028
45063
|
var require4 = createRequire3(import.meta.url);
|
|
45029
45064
|
var BEARER_SECRET_SERVICE = "pi-mcp-adapter.bearer";
|
|
45030
45065
|
var TEST_AUTH_STORE_ENV2 = "PI_MCP_ADAPTER_TEST_AUTH_STORE";
|
|
@@ -45126,7 +45161,7 @@ function loadKeyringNativeBindingFallback2(keyringRequire, platform3, arch2) {
|
|
|
45126
45161
|
for (const target of targets) {
|
|
45127
45162
|
try {
|
|
45128
45163
|
const packageJsonPath = keyringRequire.resolve(`${target.packageName}/package.json`);
|
|
45129
|
-
return keyringRequire(
|
|
45164
|
+
return keyringRequire(join26(dirname13(packageJsonPath), target.bindingFile));
|
|
45130
45165
|
} catch (error) {
|
|
45131
45166
|
lastError = error;
|
|
45132
45167
|
}
|
|
@@ -49593,7 +49628,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
|
|
|
49593
49628
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-registrar.ts
|
|
49594
49629
|
import { mkdtempSync, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
49595
49630
|
import { tmpdir } from "os";
|
|
49596
|
-
import { join as
|
|
49631
|
+
import { join as join27 } from "path";
|
|
49597
49632
|
var MAX_BINARY_RESOURCE_BYTES = 10 * 1024 * 1024;
|
|
49598
49633
|
var MAX_SESSION_RESOURCE_BYTES = 100 * 1024 * 1024;
|
|
49599
49634
|
var MAX_SESSION_RESOURCE_FILES = 1e4;
|
|
@@ -49700,11 +49735,11 @@ function materializeBinaryResource(resource, scope) {
|
|
|
49700
49735
|
return omitBinaryResource(resource, "session resource limit reached");
|
|
49701
49736
|
}
|
|
49702
49737
|
try {
|
|
49703
|
-
session.directory ??= mkdtempSync(
|
|
49738
|
+
session.directory ??= mkdtempSync(join27(tmpdir(), "pi-mcp-resource-"));
|
|
49704
49739
|
} catch {
|
|
49705
49740
|
return omitBinaryResource(resource, "could not be saved");
|
|
49706
49741
|
}
|
|
49707
|
-
const filePath =
|
|
49742
|
+
const filePath = join27(session.directory, `resource-${++session.sequence}.bin`);
|
|
49708
49743
|
session.bytes += decodedBytes;
|
|
49709
49744
|
session.files += 1;
|
|
49710
49745
|
try {
|
|
@@ -49797,7 +49832,7 @@ function stringifyStructuredContent(value) {
|
|
|
49797
49832
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
49798
49833
|
import { mkdtemp, rm as rm3, writeFile as writeFile10 } from "fs/promises";
|
|
49799
49834
|
import { tmpdir as tmpdir2 } from "os";
|
|
49800
|
-
import { dirname as dirname16, join as
|
|
49835
|
+
import { dirname as dirname16, join as join28 } from "path";
|
|
49801
49836
|
var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
49802
49837
|
var DEFAULT_MCP_OUTPUT_MAX_LINES = 2e3;
|
|
49803
49838
|
var DEFAULT_MCP_DETAILS_MAX_BYTES = 16 * 1024;
|
|
@@ -50105,8 +50140,8 @@ function serializedObjectEntryBytes(key, value, hasPrevious) {
|
|
|
50105
50140
|
}
|
|
50106
50141
|
async function saveArtifact(kind, text) {
|
|
50107
50142
|
try {
|
|
50108
|
-
const dir = await mkdtemp(
|
|
50109
|
-
const path7 =
|
|
50143
|
+
const dir = await mkdtemp(join28(tmpdir2(), "pi-mcp-output-"));
|
|
50144
|
+
const path7 = join28(dir, `${kind}-${randomBytes4(4).toString("hex")}.txt`);
|
|
50110
50145
|
await writeFile10(path7, text, { encoding: "utf8", mode: 384 });
|
|
50111
50146
|
return { path: path7 };
|
|
50112
50147
|
} catch (error) {
|
|
@@ -51753,7 +51788,7 @@ function sendText(res, status, text) {
|
|
|
51753
51788
|
// ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/glimpse-ui.ts
|
|
51754
51789
|
import { existsSync as existsSync15 } from "fs";
|
|
51755
51790
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
51756
|
-
import { join as
|
|
51791
|
+
import { join as join29, dirname as dirname17 } from "path";
|
|
51757
51792
|
import { platform as platform2 } from "os";
|
|
51758
51793
|
import { createRequire as createRequire4 } from "module";
|
|
51759
51794
|
var glimpseAvailable = null;
|
|
@@ -51775,20 +51810,20 @@ function getGlimpseBinaryPath() {
|
|
|
51775
51810
|
try {
|
|
51776
51811
|
const require7 = createRequire4(import.meta.url);
|
|
51777
51812
|
const glimpseuiPath = require7.resolve("glimpseui");
|
|
51778
|
-
const binaryPath =
|
|
51813
|
+
const binaryPath = join29(dirname17(glimpseuiPath), "glimpse");
|
|
51779
51814
|
if (existsSync15(binaryPath)) return binaryPath;
|
|
51780
51815
|
} catch {
|
|
51781
51816
|
}
|
|
51782
51817
|
try {
|
|
51783
51818
|
const globalRoot = execFileSync2("npm", ["root", "-g"], { encoding: "utf-8" }).trim();
|
|
51784
|
-
const binaryPath =
|
|
51819
|
+
const binaryPath = join29(globalRoot, "glimpseui", "src", "glimpse");
|
|
51785
51820
|
if (existsSync15(binaryPath)) return binaryPath;
|
|
51786
51821
|
} catch {
|
|
51787
51822
|
}
|
|
51788
51823
|
return null;
|
|
51789
51824
|
}
|
|
51790
51825
|
async function openGlimpseWindow(html, options) {
|
|
51791
|
-
const modulePath = resolvedBinaryPath ?
|
|
51826
|
+
const modulePath = resolvedBinaryPath ? join29(dirname17(resolvedBinaryPath), "glimpse.mjs") : "glimpseui";
|
|
51792
51827
|
const glimpse = await import(modulePath);
|
|
51793
51828
|
let active = true;
|
|
51794
51829
|
const win = glimpse.open(html, {
|
|
@@ -59578,7 +59613,7 @@ var pi_mcp_adapter_default = createMcpAdapter();
|
|
|
59578
59613
|
// src/managers/pi-manager.ts
|
|
59579
59614
|
async function getManagedPiMcpServers() {
|
|
59580
59615
|
try {
|
|
59581
|
-
const parsed = JSON.parse(await
|
|
59616
|
+
const parsed = JSON.parse(await readFile19(PI_MCP_CONFIG_PATH, "utf8"));
|
|
59582
59617
|
if (!isRecord2(parsed) || !isRecord2(parsed.mcpServers)) return {};
|
|
59583
59618
|
return Object.fromEntries(Object.entries(parsed.mcpServers).filter(
|
|
59584
59619
|
(entry) => isRecord2(entry[1]) && (typeof entry[1].command === "string" || typeof entry[1].url === "string")
|
|
@@ -59700,7 +59735,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
59700
59735
|
modelRuntime = null;
|
|
59701
59736
|
constructor(options) {
|
|
59702
59737
|
super(options);
|
|
59703
|
-
this.historyFilePath = options.historyFilePath ??
|
|
59738
|
+
this.historyFilePath = options.historyFilePath ?? join30(PI_HISTORY_DIR, `${Date.now()}.jsonl`);
|
|
59704
59739
|
this.historyFile = new CodexHistoryFile(this.historyFilePath);
|
|
59705
59740
|
this.initializeManager(this.processMessageInternal.bind(this));
|
|
59706
59741
|
}
|
|
@@ -59836,7 +59871,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
59836
59871
|
}
|
|
59837
59872
|
const resourceLoader = new DefaultResourceLoader({
|
|
59838
59873
|
cwd: this.workingDirectory,
|
|
59839
|
-
agentDir:
|
|
59874
|
+
agentDir: join30(ENGINE_ENV.HOME_DIR, ".pi", "agent"),
|
|
59840
59875
|
extensionFactories,
|
|
59841
59876
|
appendSystemPrompt: [this.buildCombinedInstructions() ?? ""]
|
|
59842
59877
|
});
|
|
@@ -59958,13 +59993,13 @@ async function uploadAnalytics(endpoint, body) {
|
|
|
59958
59993
|
import {
|
|
59959
59994
|
appendFile as appendFile4,
|
|
59960
59995
|
mkdir as mkdir19,
|
|
59961
|
-
readFile as
|
|
59962
|
-
readdir as
|
|
59996
|
+
readFile as readFile20,
|
|
59997
|
+
readdir as readdir8,
|
|
59963
59998
|
rename as rename3,
|
|
59964
59999
|
unlink as unlink3
|
|
59965
60000
|
} from "fs/promises";
|
|
59966
60001
|
import { existsSync as existsSync16, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "fs";
|
|
59967
|
-
import { join as
|
|
60002
|
+
import { join as join31 } from "path";
|
|
59968
60003
|
var MAX_FAILED_RECORDS = 500;
|
|
59969
60004
|
var FLUSH_DEBOUNCE_MS = 15e3;
|
|
59970
60005
|
var MAX_UPLOADED_SEGMENTS = 50;
|
|
@@ -59976,7 +60011,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59976
60011
|
options.storageName,
|
|
59977
60012
|
...options.legacyStorageNames ?? []
|
|
59978
60013
|
];
|
|
59979
|
-
this.liveFile =
|
|
60014
|
+
this.liveFile = join31(ENGINE_DIR2, `${options.storageName}.jsonl`);
|
|
59980
60015
|
this.segmentFilePatterns = this.storageNames.map(
|
|
59981
60016
|
(storageName) => new RegExp(`^${storageName}\\.(\\d+)\\.jsonl$`)
|
|
59982
60017
|
);
|
|
@@ -60014,7 +60049,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
60014
60049
|
if (!existsSync16(ENGINE_DIR2)) return [];
|
|
60015
60050
|
return readdirSync2(ENGINE_DIR2, { withFileTypes: true }).filter((entry) => entry.isFile() && this.storageNames.some(
|
|
60016
60051
|
(storageName) => entry.name === `${storageName}.jsonl` || entry.name.startsWith(`${storageName}.`) && (entry.name.endsWith(".jsonl") || entry.name.endsWith(`.jsonl${UPLOADED_SUFFIX}`))
|
|
60017
|
-
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(
|
|
60052
|
+
)).map(({ name }) => name).sort().flatMap((name) => this.parseRecords(readFileSync7(join31(ENGINE_DIR2, name), "utf-8"))).map((record3) => {
|
|
60018
60053
|
const recordId = this.options.getRecordId?.(record3);
|
|
60019
60054
|
if (recordId) this.recordIds.add(recordId);
|
|
60020
60055
|
return record3;
|
|
@@ -60049,18 +60084,18 @@ var AnalyticsRecordBuffer = class {
|
|
|
60049
60084
|
}
|
|
60050
60085
|
for (const storageName of this.storageNames) {
|
|
60051
60086
|
await rename3(
|
|
60052
|
-
|
|
60053
|
-
|
|
60087
|
+
join31(ENGINE_DIR2, `${storageName}.jsonl`),
|
|
60088
|
+
join31(ENGINE_DIR2, `${storageName}.${Date.now()}.jsonl`)
|
|
60054
60089
|
).catch(() => {
|
|
60055
60090
|
});
|
|
60056
60091
|
}
|
|
60057
|
-
const entries = await
|
|
60092
|
+
const entries = await readdir8(ENGINE_DIR2).catch(() => []);
|
|
60058
60093
|
let flushed = 0;
|
|
60059
60094
|
let failed = 0;
|
|
60060
60095
|
for (const entry of entries) {
|
|
60061
60096
|
if (!this.segmentFilePatterns.some((pattern) => pattern.test(entry))) continue;
|
|
60062
60097
|
try {
|
|
60063
|
-
await this.uploadSegment(
|
|
60098
|
+
await this.uploadSegment(join31(ENGINE_DIR2, entry));
|
|
60064
60099
|
flushed++;
|
|
60065
60100
|
} catch (error) {
|
|
60066
60101
|
failed++;
|
|
@@ -60089,14 +60124,14 @@ var AnalyticsRecordBuffer = class {
|
|
|
60089
60124
|
(storageName) => entry.startsWith(`${storageName}.`)
|
|
60090
60125
|
) && entry.endsWith(UPLOADED_SUFFIX)).sort();
|
|
60091
60126
|
for (const entry of uploaded.slice(0, -MAX_UPLOADED_SEGMENTS)) {
|
|
60092
|
-
await unlink3(
|
|
60127
|
+
await unlink3(join31(ENGINE_DIR2, entry)).catch(() => {
|
|
60093
60128
|
});
|
|
60094
60129
|
}
|
|
60095
60130
|
}
|
|
60096
60131
|
return { flushed, failed };
|
|
60097
60132
|
}
|
|
60098
60133
|
async uploadSegment(filePath) {
|
|
60099
|
-
const records = this.parseRecords(await
|
|
60134
|
+
const records = this.parseRecords(await readFile20(filePath, "utf-8"));
|
|
60100
60135
|
if (records.length > 0) await this.options.upload(records);
|
|
60101
60136
|
await rename3(filePath, `${filePath}${UPLOADED_SUFFIX}`).catch(() => {
|
|
60102
60137
|
});
|
|
@@ -60938,9 +60973,9 @@ var KeepAliveService = class _KeepAliveService {
|
|
|
60938
60973
|
var keepAliveService = new KeepAliveService();
|
|
60939
60974
|
|
|
60940
60975
|
// src/services/canvas-service.ts
|
|
60941
|
-
import { readdir as
|
|
60976
|
+
import { readdir as readdir9, readFile as readFile22, stat as stat4 } from "fs/promises";
|
|
60942
60977
|
import { homedir as homedir13 } from "os";
|
|
60943
|
-
import { join as
|
|
60978
|
+
import { join as join32 } from "path";
|
|
60944
60979
|
|
|
60945
60980
|
// src/utils/contained-file.ts
|
|
60946
60981
|
import { realpath, stat as stat3 } from "fs/promises";
|
|
@@ -60966,9 +61001,9 @@ function fileRevision(content) {
|
|
|
60966
61001
|
}
|
|
60967
61002
|
|
|
60968
61003
|
// src/utils/revisioned-text-file.ts
|
|
60969
|
-
import { readFile as
|
|
61004
|
+
import { readFile as readFile21 } from "fs/promises";
|
|
60970
61005
|
async function writeRevisionedTextFile(filePath, content, expectedRevision) {
|
|
60971
|
-
const current = await
|
|
61006
|
+
const current = await readFile21(filePath, "utf8");
|
|
60972
61007
|
const revision = fileRevision(current);
|
|
60973
61008
|
if (revision !== expectedRevision) {
|
|
60974
61009
|
return {
|
|
@@ -60982,15 +61017,15 @@ async function writeRevisionedTextFile(filePath, content, expectedRevision) {
|
|
|
60982
61017
|
|
|
60983
61018
|
// src/services/canvas-service.ts
|
|
60984
61019
|
var GLOBAL_CANVAS_DIRECTORIES = [
|
|
60985
|
-
|
|
60986
|
-
|
|
60987
|
-
|
|
61020
|
+
join32(homedir13(), ".claude", "plans"),
|
|
61021
|
+
join32(process.env.XDG_DATA_HOME ?? join32(homedir13(), ".local", "share"), "opencode", "plans"),
|
|
61022
|
+
join32(homedir13(), ".replicas", "canvas")
|
|
60988
61023
|
];
|
|
60989
61024
|
async function canvasDirectories() {
|
|
60990
61025
|
const repositories = await gitService.listRepositories().catch(() => []);
|
|
60991
61026
|
return [
|
|
60992
61027
|
...GLOBAL_CANVAS_DIRECTORIES,
|
|
60993
|
-
...repositories.map((repository) =>
|
|
61028
|
+
...repositories.map((repository) => join32(repository.path, ".opencode", "plans"))
|
|
60994
61029
|
];
|
|
60995
61030
|
}
|
|
60996
61031
|
var CanvasService = class {
|
|
@@ -61008,14 +61043,14 @@ var CanvasService = class {
|
|
|
61008
61043
|
if (!current) continue;
|
|
61009
61044
|
let entries;
|
|
61010
61045
|
try {
|
|
61011
|
-
entries = await
|
|
61046
|
+
entries = await readdir9(current.directory, { withFileTypes: true });
|
|
61012
61047
|
} catch {
|
|
61013
61048
|
continue;
|
|
61014
61049
|
}
|
|
61015
61050
|
for (const entry of entries) {
|
|
61016
61051
|
if (entry.name.startsWith(".")) continue;
|
|
61017
61052
|
const filename = current.relativePath ? `${current.relativePath}/${entry.name}` : entry.name;
|
|
61018
|
-
const filePath =
|
|
61053
|
+
const filePath = join32(current.directory, entry.name);
|
|
61019
61054
|
if (entry.isDirectory()) {
|
|
61020
61055
|
pending.push({ directory: filePath, relativePath: filename });
|
|
61021
61056
|
continue;
|
|
@@ -61040,7 +61075,7 @@ var CanvasService = class {
|
|
|
61040
61075
|
if (!safe) return null;
|
|
61041
61076
|
const { kind, mimeType } = classifyCanvasFilename(safe);
|
|
61042
61077
|
for (const directory of await this.directories()) {
|
|
61043
|
-
const filePath =
|
|
61078
|
+
const filePath = join32(directory, safe);
|
|
61044
61079
|
let sizeBytes = 0;
|
|
61045
61080
|
let updatedAt = "";
|
|
61046
61081
|
try {
|
|
@@ -61061,7 +61096,7 @@ var CanvasService = class {
|
|
|
61061
61096
|
};
|
|
61062
61097
|
}
|
|
61063
61098
|
try {
|
|
61064
|
-
const bytes = await
|
|
61099
|
+
const bytes = await readFile22(filePath);
|
|
61065
61100
|
return { filename: safe, kind, sizeBytes, mimeType, updatedAt, bytes };
|
|
61066
61101
|
} catch {
|
|
61067
61102
|
continue;
|
|
@@ -61223,14 +61258,14 @@ async function reconcileCanvasItems(filenames) {
|
|
|
61223
61258
|
// src/services/upload-chat-transcripts.ts
|
|
61224
61259
|
import { createReadStream } from "fs";
|
|
61225
61260
|
import { createHash as createHash8 } from "crypto";
|
|
61226
|
-
import { readFile as
|
|
61227
|
-
import { basename as basename4, join as
|
|
61261
|
+
import { readFile as readFile23, readdir as readdir10, stat as stat5 } from "fs/promises";
|
|
61262
|
+
import { basename as basename4, join as join34 } from "path";
|
|
61228
61263
|
|
|
61229
61264
|
// src/services/chat/chat-senders.ts
|
|
61230
|
-
import { join as
|
|
61231
|
-
var CHAT_SENDERS_DIR =
|
|
61265
|
+
import { join as join33 } from "path";
|
|
61266
|
+
var CHAT_SENDERS_DIR = join33(ENGINE_DIR2, "chat-senders");
|
|
61232
61267
|
function chatMessageSendersFilePath(chatId) {
|
|
61233
|
-
return
|
|
61268
|
+
return join33(CHAT_SENDERS_DIR, `${chatId}.jsonl`);
|
|
61234
61269
|
}
|
|
61235
61270
|
function parseChatMessageSendersJsonl(content) {
|
|
61236
61271
|
return content.split("\n").flatMap((line) => {
|
|
@@ -61263,7 +61298,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
61263
61298
|
for (const dir of HISTORY_DIRS) {
|
|
61264
61299
|
let entries;
|
|
61265
61300
|
try {
|
|
61266
|
-
entries = await
|
|
61301
|
+
entries = await readdir10(dir);
|
|
61267
61302
|
} catch {
|
|
61268
61303
|
continue;
|
|
61269
61304
|
}
|
|
@@ -61273,7 +61308,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
61273
61308
|
const chat = chatsById.get(chatId);
|
|
61274
61309
|
if (!shouldFlushChatTranscript(dir, chat, chatsById)) continue;
|
|
61275
61310
|
tasks.push(
|
|
61276
|
-
uploadChatTranscript(chatId,
|
|
61311
|
+
uploadChatTranscript(chatId, join34(dir, entry), chat, capture).then((artifact) => {
|
|
61277
61312
|
flushed++;
|
|
61278
61313
|
if (artifact && capture) revisions.push(artifact);
|
|
61279
61314
|
}).catch((err) => {
|
|
@@ -61289,7 +61324,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
61289
61324
|
async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
61290
61325
|
const { size } = await stat5(filePath);
|
|
61291
61326
|
if (size === 0) return null;
|
|
61292
|
-
const historyPages = createChatTranscriptPages(await
|
|
61327
|
+
const historyPages = createChatTranscriptPages(await readFile23(filePath));
|
|
61293
61328
|
const metadata = chat ? {
|
|
61294
61329
|
provider: chat.provider,
|
|
61295
61330
|
...chat.relayBaseProvider ? { relayBaseProvider: chat.relayBaseProvider } : {},
|
|
@@ -61310,7 +61345,7 @@ async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
61310
61345
|
}
|
|
61311
61346
|
try {
|
|
61312
61347
|
metadata.senders = parseChatMessageSendersJsonl(
|
|
61313
|
-
await
|
|
61348
|
+
await readFile23(chatMessageSendersFilePath(chatId), "utf-8")
|
|
61314
61349
|
);
|
|
61315
61350
|
} catch (error) {
|
|
61316
61351
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
@@ -61361,8 +61396,8 @@ async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
61361
61396
|
|
|
61362
61397
|
// src/services/upload-engine-logs.ts
|
|
61363
61398
|
import { createReadStream as createReadStream2 } from "fs";
|
|
61364
|
-
import { readdir as
|
|
61365
|
-
import { join as
|
|
61399
|
+
import { readdir as readdir11, stat as stat6 } from "fs/promises";
|
|
61400
|
+
import { join as join35 } from "path";
|
|
61366
61401
|
var MAX_ENGINE_LOG_FLUSH_SESSIONS = 10;
|
|
61367
61402
|
var MAX_ENGINE_LOG_FLUSH_BYTES = 5 * 1024 * 1024;
|
|
61368
61403
|
var ENGINE_LOG_FLUSH_TIMEOUT_MS = 2e4;
|
|
@@ -61372,7 +61407,7 @@ async function flushAllEngineLogs() {
|
|
|
61372
61407
|
let failed = 0;
|
|
61373
61408
|
const deadline = Date.now() + ENGINE_LOG_FLUSH_TIMEOUT_MS;
|
|
61374
61409
|
await runBeforeDeadline((signal) => engineLogger.flush(signal), deadline);
|
|
61375
|
-
const files = await runBeforeDeadline(() =>
|
|
61410
|
+
const files = await runBeforeDeadline(() => readdir11(LOG_DIR), deadline).catch(() => []);
|
|
61376
61411
|
const currentFilename = engineLogger.sessionId ? `${engineLogger.sessionId}.log` : null;
|
|
61377
61412
|
const filenames = files.filter((filename) => {
|
|
61378
61413
|
if (!filename.endsWith(".log")) return false;
|
|
@@ -61391,7 +61426,7 @@ async function flushAllEngineLogs() {
|
|
|
61391
61426
|
const candidates = (await Promise.all(filenames.slice(0, MAX_ENGINE_LOG_FLUSH_SESSIONS).map(async (filename) => {
|
|
61392
61427
|
try {
|
|
61393
61428
|
const sessionId = filename.slice(0, -".log".length);
|
|
61394
|
-
const filePath =
|
|
61429
|
+
const filePath = join35(LOG_DIR, filename);
|
|
61395
61430
|
const fileStat = await runBeforeDeadline(() => stat6(filePath), deadline);
|
|
61396
61431
|
if (!fileStat.isFile()) {
|
|
61397
61432
|
skipped++;
|
|
@@ -61488,7 +61523,7 @@ async function uploadEngineLog(input, timeoutMs) {
|
|
|
61488
61523
|
|
|
61489
61524
|
// src/services/chat/fork-handoff.ts
|
|
61490
61525
|
import { mkdir as mkdir20, open as open3, writeFile as writeFile11 } from "fs/promises";
|
|
61491
|
-
import { join as
|
|
61526
|
+
import { join as join36 } from "path";
|
|
61492
61527
|
var EXCERPT_MAX_CHARS = 24e3;
|
|
61493
61528
|
var MAX_SANITIZED_SOURCE_BYTES = 32 * 1024 * 1024;
|
|
61494
61529
|
function unansweredRequest(blocks) {
|
|
@@ -61523,7 +61558,7 @@ function tailBlocks(blocks, maxChars) {
|
|
|
61523
61558
|
return { excerpt, truncated: start > 0 };
|
|
61524
61559
|
}
|
|
61525
61560
|
async function buildForkHandoff(input) {
|
|
61526
|
-
const rawHistoryPath =
|
|
61561
|
+
const rawHistoryPath = join36(HISTORY_DIR_BY_PROVIDER[input.sourceProvider], `${input.sourceChatId}.jsonl`);
|
|
61527
61562
|
const { content, truncated: sourceTruncated } = await readHistoryTail(rawHistoryPath, MAX_SANITIZED_SOURCE_BYTES);
|
|
61528
61563
|
let blocks = canonicalizeChatTranscriptBlocks(content, input.executionProvider, input.senders);
|
|
61529
61564
|
if (input.turnLimit !== void 0) {
|
|
@@ -61531,9 +61566,9 @@ async function buildForkHandoff(input) {
|
|
|
61531
61566
|
const start = blocks.findLastIndex((block) => block.startsWith("## User") && ++turns === input.turnLimit);
|
|
61532
61567
|
blocks = blocks.slice(Math.max(0, start));
|
|
61533
61568
|
}
|
|
61534
|
-
const forkDir =
|
|
61569
|
+
const forkDir = join36(FORKS_DIR, input.targetChatId);
|
|
61535
61570
|
await mkdir20(forkDir, { recursive: true });
|
|
61536
|
-
const transcriptPath =
|
|
61571
|
+
const transcriptPath = join36(forkDir, "source-transcript.md");
|
|
61537
61572
|
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.` : ""}_
|
|
61538
61573
|
|
|
61539
61574
|
` : "";
|
|
@@ -62030,7 +62065,7 @@ var ChatService = class {
|
|
|
62030
62065
|
}
|
|
62031
62066
|
}
|
|
62032
62067
|
async readSenders(chatId) {
|
|
62033
|
-
return
|
|
62068
|
+
return readFile24(chatMessageSendersFilePath(chatId), "utf-8").then(parseChatMessageSendersJsonl).catch((error) => {
|
|
62034
62069
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return [];
|
|
62035
62070
|
console.error("[ChatService] Failed to read sender records:", error);
|
|
62036
62071
|
return [];
|
|
@@ -62283,14 +62318,14 @@ var ChatService = class {
|
|
|
62283
62318
|
return descendants;
|
|
62284
62319
|
}
|
|
62285
62320
|
async deleteHistoryFile(persisted) {
|
|
62286
|
-
const historyPath =
|
|
62321
|
+
const historyPath = join37(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
62287
62322
|
await Promise.all([
|
|
62288
62323
|
historyPath,
|
|
62289
62324
|
`${historyPath}.pages.jsonl`,
|
|
62290
62325
|
`${historyPath}.pages.index.json`
|
|
62291
62326
|
].map((path7) => rm4(path7, { force: true })));
|
|
62292
62327
|
await rm4(chatMessageSendersFilePath(persisted.id), { force: true });
|
|
62293
|
-
await rm4(
|
|
62328
|
+
await rm4(join37(FORKS_DIR, persisted.id), { recursive: true, force: true });
|
|
62294
62329
|
}
|
|
62295
62330
|
/** Resolves once the target chat exists; the handoff and its first turn run in the background. */
|
|
62296
62331
|
async forkChat(sourceChatId, request, trigger = "manual", reason) {
|
|
@@ -62538,7 +62573,7 @@ var ChatService = class {
|
|
|
62538
62573
|
}
|
|
62539
62574
|
const baseProvider = getChatExecutionProvider(persisted);
|
|
62540
62575
|
const additionalInstructions = persisted.provider === "relay" ? buildRelayInstructions(this.workingDirectory) : void 0;
|
|
62541
|
-
const historyFilePath =
|
|
62576
|
+
const historyFilePath = join37(HISTORY_DIR_BY_PROVIDER[persisted.provider], `${persisted.id}.jsonl`);
|
|
62542
62577
|
const managerOptions = {
|
|
62543
62578
|
provider: baseProvider,
|
|
62544
62579
|
workingDirectory: this.workingDirectory,
|
|
@@ -62787,7 +62822,7 @@ var ChatService = class {
|
|
|
62787
62822
|
this.publishTurnCompleted(chat, completedAt, processing);
|
|
62788
62823
|
uploadChatTranscript(
|
|
62789
62824
|
chatId,
|
|
62790
|
-
|
|
62825
|
+
join37(HISTORY_DIR_BY_PROVIDER[chat.persisted.provider], `${chatId}.jsonl`),
|
|
62791
62826
|
this.toSummary(chat)
|
|
62792
62827
|
).catch((err) => {
|
|
62793
62828
|
console.error("[ChatService] Failed to upload chat transcript:", { chatId, err });
|
|
@@ -62835,7 +62870,7 @@ var ChatService = class {
|
|
|
62835
62870
|
}
|
|
62836
62871
|
async loadChats() {
|
|
62837
62872
|
try {
|
|
62838
|
-
const content = await
|
|
62873
|
+
const content = await readFile24(CHATS_FILE, "utf-8");
|
|
62839
62874
|
return parsePersistedChatsContent(content);
|
|
62840
62875
|
} catch (error) {
|
|
62841
62876
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
@@ -62850,7 +62885,7 @@ var ChatService = class {
|
|
|
62850
62885
|
console.error("[ChatService] Failed to quarantine corrupt chats file:", renameError);
|
|
62851
62886
|
}
|
|
62852
62887
|
try {
|
|
62853
|
-
const backupContent = await
|
|
62888
|
+
const backupContent = await readFile24(CHATS_BACKUP_FILE, "utf-8");
|
|
62854
62889
|
return parsePersistedChatsContent(backupContent);
|
|
62855
62890
|
} catch (backupError) {
|
|
62856
62891
|
if (backupError && typeof backupError === "object" && "code" in backupError && backupError.code === "ENOENT") {
|
|
@@ -62945,14 +62980,14 @@ var ChatService = class {
|
|
|
62945
62980
|
|
|
62946
62981
|
// src/services/repo-file-service.ts
|
|
62947
62982
|
import { execFile as execFile7 } from "child_process";
|
|
62948
|
-
import { readFile as
|
|
62983
|
+
import { readFile as readFile25 } from "fs/promises";
|
|
62949
62984
|
import { extname as extname3 } from "path";
|
|
62950
62985
|
|
|
62951
62986
|
// src/services/language-server-service.ts
|
|
62952
62987
|
import { spawn as spawn9 } from "child_process";
|
|
62953
62988
|
import { existsSync as existsSync17, readFileSync as readFileSync8 } from "fs";
|
|
62954
62989
|
import { createRequire as createRequire6 } from "module";
|
|
62955
|
-
import { delimiter as delimiter2, dirname as dirname19, join as
|
|
62990
|
+
import { delimiter as delimiter2, dirname as dirname19, join as join38, relative as relative2 } from "path";
|
|
62956
62991
|
import { setTimeout as setTimeout2 } from "timers/promises";
|
|
62957
62992
|
import { fileURLToPath as fileURLToPath6, pathToFileURL } from "url";
|
|
62958
62993
|
import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node.js";
|
|
@@ -63071,7 +63106,7 @@ var LanguageServerService = class {
|
|
|
63071
63106
|
if (config.package && config.bin) command = process.execPath;
|
|
63072
63107
|
else if (config.command) {
|
|
63073
63108
|
const commandName = config.command;
|
|
63074
|
-
command = process.env.PATH?.split(delimiter2).map((directory) =>
|
|
63109
|
+
command = process.env.PATH?.split(delimiter2).map((directory) => join38(directory, commandName)).find(existsSync17);
|
|
63075
63110
|
}
|
|
63076
63111
|
const args = config.package && config.bin ? [packageBin(config.package, config.bin), ...config.args] : config.args;
|
|
63077
63112
|
if (!command) return null;
|
|
@@ -63242,7 +63277,7 @@ var RepoFileService = class {
|
|
|
63242
63277
|
sizeBytes,
|
|
63243
63278
|
binary: true,
|
|
63244
63279
|
tooLarge: false,
|
|
63245
|
-
base64: (await
|
|
63280
|
+
base64: (await readFile25(fullPath)).toString("base64"),
|
|
63246
63281
|
mimeType
|
|
63247
63282
|
};
|
|
63248
63283
|
}
|
|
@@ -63267,7 +63302,7 @@ var RepoFileService = class {
|
|
|
63267
63302
|
tooLarge: true
|
|
63268
63303
|
};
|
|
63269
63304
|
}
|
|
63270
|
-
const content = await
|
|
63305
|
+
const content = await readFile25(fullPath, "utf-8");
|
|
63271
63306
|
return {
|
|
63272
63307
|
repoName,
|
|
63273
63308
|
path: filePath,
|
|
@@ -63299,7 +63334,7 @@ var RepoFileService = class {
|
|
|
63299
63334
|
async inspectSymbol(repoName, filePath, line, character, action) {
|
|
63300
63335
|
const resolved = await this.resolveFile(repoName, filePath);
|
|
63301
63336
|
if (!resolved || line < 1 || character < 0 || isBinaryExtension(filePath)) return null;
|
|
63302
|
-
const content = await
|
|
63337
|
+
const content = await readFile25(resolved.fullPath, "utf8");
|
|
63303
63338
|
const sourceLine = content.split("\n")[line - 1];
|
|
63304
63339
|
if (sourceLine === void 0) return null;
|
|
63305
63340
|
const symbolMatch = Array.from(sourceLine.matchAll(/[\p{L}_$][\p{L}\p{N}_$]*/gu)).find((match) => character >= match.index && character <= match.index + match[0].length);
|
|
@@ -63412,21 +63447,21 @@ var RepoFileService = class {
|
|
|
63412
63447
|
// src/v1-routes.ts
|
|
63413
63448
|
import { Hono } from "hono";
|
|
63414
63449
|
import { z as z6 } from "zod";
|
|
63415
|
-
import { readdir as
|
|
63416
|
-
import { join as
|
|
63450
|
+
import { readdir as readdir13, stat as stat7, readFile as readFile28 } from "fs/promises";
|
|
63451
|
+
import { join as join41, resolve as resolve5 } from "path";
|
|
63417
63452
|
|
|
63418
63453
|
// src/services/warm-hooks-service.ts
|
|
63419
63454
|
import { spawn as spawn10 } from "child_process";
|
|
63420
|
-
import { readFile as
|
|
63455
|
+
import { readFile as readFile27 } from "fs/promises";
|
|
63421
63456
|
import { existsSync as existsSync18 } from "fs";
|
|
63422
|
-
import { join as
|
|
63457
|
+
import { join as join40 } from "path";
|
|
63423
63458
|
|
|
63424
63459
|
// src/services/warm-hook-logs-service.ts
|
|
63425
|
-
import { mkdir as mkdir22, readFile as
|
|
63460
|
+
import { mkdir as mkdir22, readFile as readFile26, writeFile as writeFile12, readdir as readdir12, appendFile as appendFile6, unlink as unlink4 } from "fs/promises";
|
|
63426
63461
|
import { homedir as homedir14 } from "os";
|
|
63427
|
-
import { join as
|
|
63428
|
-
var LOGS_DIR2 =
|
|
63429
|
-
var CURRENT_RUN_LOG =
|
|
63462
|
+
import { join as join39 } from "path";
|
|
63463
|
+
var LOGS_DIR2 = join39(homedir14(), ".replicas", "warm-hook-logs");
|
|
63464
|
+
var CURRENT_RUN_LOG = join39(LOGS_DIR2, "current-run.log");
|
|
63430
63465
|
var GLOBAL_FILENAME = "global.json";
|
|
63431
63466
|
function withPreview2(stored) {
|
|
63432
63467
|
const preview = buildHookOutputPreview(stored.output);
|
|
@@ -63443,7 +63478,7 @@ var WarmHookLogsService = class {
|
|
|
63443
63478
|
hookName: "organization",
|
|
63444
63479
|
...entry
|
|
63445
63480
|
};
|
|
63446
|
-
await writeFile12(
|
|
63481
|
+
await writeFile12(join39(LOGS_DIR2, GLOBAL_FILENAME), `${JSON.stringify(log, null, 2)}
|
|
63447
63482
|
`, "utf-8");
|
|
63448
63483
|
}
|
|
63449
63484
|
async saveEnvironmentHookLog(entry) {
|
|
@@ -63453,7 +63488,7 @@ var WarmHookLogsService = class {
|
|
|
63453
63488
|
hookName: "environment",
|
|
63454
63489
|
...entry
|
|
63455
63490
|
};
|
|
63456
|
-
await writeFile12(
|
|
63491
|
+
await writeFile12(join39(LOGS_DIR2, ENVIRONMENT_HOOK_LOG_FILENAME), `${JSON.stringify(log, null, 2)}
|
|
63457
63492
|
`, "utf-8");
|
|
63458
63493
|
}
|
|
63459
63494
|
async saveRepoHookLog(repoName, entry) {
|
|
@@ -63463,13 +63498,13 @@ var WarmHookLogsService = class {
|
|
|
63463
63498
|
hookName: repoName,
|
|
63464
63499
|
...entry
|
|
63465
63500
|
};
|
|
63466
|
-
await writeFile12(
|
|
63501
|
+
await writeFile12(join39(LOGS_DIR2, repoHookLogFilename(repoName)), `${JSON.stringify(log, null, 2)}
|
|
63467
63502
|
`, "utf-8");
|
|
63468
63503
|
}
|
|
63469
63504
|
async getAllLogs() {
|
|
63470
63505
|
let files;
|
|
63471
63506
|
try {
|
|
63472
|
-
files = await
|
|
63507
|
+
files = await readdir12(LOGS_DIR2);
|
|
63473
63508
|
} catch (err) {
|
|
63474
63509
|
if (err.code === "ENOENT") {
|
|
63475
63510
|
return [];
|
|
@@ -63482,7 +63517,7 @@ var WarmHookLogsService = class {
|
|
|
63482
63517
|
continue;
|
|
63483
63518
|
}
|
|
63484
63519
|
try {
|
|
63485
|
-
const raw = await
|
|
63520
|
+
const raw = await readFile26(join39(LOGS_DIR2, file), "utf-8");
|
|
63486
63521
|
const stored = JSON.parse(raw);
|
|
63487
63522
|
logs.push(withPreview2(stored));
|
|
63488
63523
|
} catch {
|
|
@@ -63511,7 +63546,7 @@ var WarmHookLogsService = class {
|
|
|
63511
63546
|
}
|
|
63512
63547
|
async getCurrentRunLog() {
|
|
63513
63548
|
try {
|
|
63514
|
-
return await
|
|
63549
|
+
return await readFile26(CURRENT_RUN_LOG, "utf-8");
|
|
63515
63550
|
} catch (err) {
|
|
63516
63551
|
if (err.code === "ENOENT") return null;
|
|
63517
63552
|
throw err;
|
|
@@ -63520,7 +63555,7 @@ var WarmHookLogsService = class {
|
|
|
63520
63555
|
async getFullOutput(hookType, hookName) {
|
|
63521
63556
|
const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
63522
63557
|
try {
|
|
63523
|
-
const raw = await
|
|
63558
|
+
const raw = await readFile26(join39(LOGS_DIR2, filename), "utf-8");
|
|
63524
63559
|
const stored = JSON.parse(raw);
|
|
63525
63560
|
if (stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
63526
63561
|
return null;
|
|
@@ -63539,12 +63574,12 @@ var warmHookLogsService = new WarmHookLogsService();
|
|
|
63539
63574
|
// src/services/warm-hooks-service.ts
|
|
63540
63575
|
async function readRepoWarmHook(repoPath) {
|
|
63541
63576
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
63542
|
-
const configPath =
|
|
63577
|
+
const configPath = join40(repoPath, filename);
|
|
63543
63578
|
if (!existsSync18(configPath)) {
|
|
63544
63579
|
continue;
|
|
63545
63580
|
}
|
|
63546
63581
|
try {
|
|
63547
|
-
const raw = await
|
|
63582
|
+
const raw = await readFile27(configPath, "utf-8");
|
|
63548
63583
|
const config = parseReplicasConfigString(raw, filename);
|
|
63549
63584
|
if (!config.warmHook) {
|
|
63550
63585
|
return null;
|
|
@@ -64869,11 +64904,11 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64869
64904
|
});
|
|
64870
64905
|
app2.get("/logs", async (c) => {
|
|
64871
64906
|
try {
|
|
64872
|
-
const files = await
|
|
64907
|
+
const files = await readdir13(LOG_DIR).catch(() => []);
|
|
64873
64908
|
const logFiles = files.filter((f) => f.endsWith(".log"));
|
|
64874
64909
|
const sessions = await Promise.all(
|
|
64875
64910
|
logFiles.map(async (filename) => {
|
|
64876
|
-
const filePath =
|
|
64911
|
+
const filePath = join41(LOG_DIR, filename);
|
|
64877
64912
|
const fileStat = await stat7(filePath);
|
|
64878
64913
|
const sessionId = filename.replace(/\.log$/, "");
|
|
64879
64914
|
return {
|
|
@@ -64908,7 +64943,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64908
64943
|
}
|
|
64909
64944
|
let content;
|
|
64910
64945
|
try {
|
|
64911
|
-
content = await
|
|
64946
|
+
content = await readFile28(filePath, "utf-8");
|
|
64912
64947
|
} catch {
|
|
64913
64948
|
return c.json(jsonError("Log session not found"), 404);
|
|
64914
64949
|
}
|
|
@@ -3,11 +3,11 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
notifyPostToolUse
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6B2CUGV3.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-747EKU2K.js";
|
|
11
11
|
import "./chunk-VEQXQN22.js";
|
|
12
12
|
|
|
13
13
|
// src/post-tool-pr-hook.ts
|
package/dist/src/relay-mcp.js
CHANGED