replicas-engine 0.1.844 → 0.1.846
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-HL2CZF2K.js → asp-host-Y326VRVF.js} +4 -4
- package/dist/src/{chunk-ZKC3JWMQ.js → chunk-HEH6SVCF.js} +1 -1
- package/dist/src/{chunk-IGBQE3LN.js → chunk-LZSQ7376.js} +1 -1
- package/dist/src/{chunk-QVQFSVLT.js → chunk-MQMKKDOH.js} +62 -32
- package/dist/src/{chunk-MSLCZZPV.js → chunk-RLO6MC7U.js} +2 -2
- package/dist/src/{chunk-ORW4ECBB.js → chunk-T32XK5XV.js} +2 -2
- package/dist/src/{chunk-DCCU6AJL.js → chunk-ZFOQMUTU.js} +4 -4
- 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 +119 -60
- 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-ZFOQMUTU.js";
|
|
9
|
+
import "./chunk-HEH6SVCF.js";
|
|
10
|
+
import "./chunk-RLO6MC7U.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-MQMKKDOH.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-MQMKKDOH.js";
|
|
7
7
|
|
|
8
8
|
// src/services/post-tool-pr-notifier.ts
|
|
9
9
|
async function notifyPostToolUse(toolName, toolInput) {
|
|
@@ -1549,6 +1549,15 @@ var headlessFilesystemAgentResultSchema = z4.object({
|
|
|
1549
1549
|
// ../shared/src/engine/environment.ts
|
|
1550
1550
|
var DESKTOP_STREAM_PORT = 6080;
|
|
1551
1551
|
|
|
1552
|
+
// ../shared/src/json.ts
|
|
1553
|
+
function safeJsonParse(str, fallback) {
|
|
1554
|
+
try {
|
|
1555
|
+
return JSON.parse(str);
|
|
1556
|
+
} catch {
|
|
1557
|
+
return fallback;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1552
1561
|
// ../shared/src/async.ts
|
|
1553
1562
|
var TIMEOUT = /* @__PURE__ */ Symbol("timeout");
|
|
1554
1563
|
async function raceWithTimeout(promise, ms) {
|
|
@@ -1717,6 +1726,21 @@ function coerceBackgroundTaskPayload(payload) {
|
|
|
1717
1726
|
toolUses: optionalNumber(payload.usage.tool_uses),
|
|
1718
1727
|
durationMs: optionalNumber(payload.usage.duration_ms)
|
|
1719
1728
|
} : void 0;
|
|
1729
|
+
const workflowAgents = Array.isArray(payload.workflow_progress) ? payload.workflow_progress.flatMap((entry) => {
|
|
1730
|
+
if (!isRecord(entry) || entry.type !== "workflow_agent") return [];
|
|
1731
|
+
const agentId = optionalString(entry.agentId);
|
|
1732
|
+
const label = optionalString(entry.label);
|
|
1733
|
+
if (!agentId || !label) return [];
|
|
1734
|
+
return [{
|
|
1735
|
+
agentId,
|
|
1736
|
+
label,
|
|
1737
|
+
model: optionalString(entry.model),
|
|
1738
|
+
state: optionalString(entry.state),
|
|
1739
|
+
promptPreview: optionalString(entry.promptPreview),
|
|
1740
|
+
lastToolSummary: optionalString(entry.lastToolSummary),
|
|
1741
|
+
resultPreview: optionalString(entry.resultPreview)
|
|
1742
|
+
}];
|
|
1743
|
+
}) : void 0;
|
|
1720
1744
|
return {
|
|
1721
1745
|
subtype,
|
|
1722
1746
|
taskId,
|
|
@@ -1733,6 +1757,7 @@ function coerceBackgroundTaskPayload(payload) {
|
|
|
1733
1757
|
lastToolName: optionalString(payload.last_tool_name),
|
|
1734
1758
|
usage,
|
|
1735
1759
|
ambient: optionalBoolean(payload.ambient),
|
|
1760
|
+
workflowAgents,
|
|
1736
1761
|
patch
|
|
1737
1762
|
};
|
|
1738
1763
|
}
|
|
@@ -1755,15 +1780,6 @@ function normalizeBackgroundTaskStatus(status) {
|
|
|
1755
1780
|
// ../shared/src/display-message/constants.ts
|
|
1756
1781
|
var USER_MESSAGE_MATCH_GRACE_PERIOD_MS = 3e4;
|
|
1757
1782
|
|
|
1758
|
-
// ../shared/src/json.ts
|
|
1759
|
-
function safeJsonParse(str, fallback) {
|
|
1760
|
-
try {
|
|
1761
|
-
return JSON.parse(str);
|
|
1762
|
-
} catch {
|
|
1763
|
-
return fallback;
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
1783
|
// ../shared/src/display-message/parsers/utils.ts
|
|
1768
1784
|
var INTERRUPTED_MESSAGE_REGEX = /^\[Request interrupted by user.*\]$/;
|
|
1769
1785
|
function userMessageImages(value) {
|
|
@@ -1784,6 +1800,7 @@ function upsertDisplayMessage(messages, message) {
|
|
|
1784
1800
|
const index = messages.findIndex((candidate) => candidate.id === message.id);
|
|
1785
1801
|
if (index === -1) messages.push(message);
|
|
1786
1802
|
else messages[index] = message;
|
|
1803
|
+
return message;
|
|
1787
1804
|
}
|
|
1788
1805
|
function applyToolInputEvent(event, messages, provider, state, questionFilter) {
|
|
1789
1806
|
if (event.type === "replicas-tool-input-request" && typeof event.payload.toolUseId === "string" && typeof event.payload.requestId === "string" && (Array.isArray(event.payload.options) || Array.isArray(event.payload.questions))) {
|
|
@@ -4974,6 +4991,13 @@ function areUserMessagesWithinMatchWindow(a, b) {
|
|
|
4974
4991
|
|
|
4975
4992
|
// ../shared/src/display-message/parsers/claude-parser.ts
|
|
4976
4993
|
var ABORTED_TERMINAL_REASONS = /* @__PURE__ */ new Set(["aborted_streaming", "aborted_tools"]);
|
|
4994
|
+
function createSubagentMessage(messageIndex, timestamp, fields) {
|
|
4995
|
+
const { id = `subagent-${timestamp}-${messageIndex}`, ...message } = fields;
|
|
4996
|
+
return { id, type: "subagent", ...message, timestamp };
|
|
4997
|
+
}
|
|
4998
|
+
function collectNestedEvents(events, toolUseId) {
|
|
4999
|
+
return events.filter((e) => e.payload.parent_tool_use_id === toolUseId).map(({ timestamp, type, payload }) => ({ timestamp, type, payload }));
|
|
5000
|
+
}
|
|
4977
5001
|
function coerceClaudeResultPayload(payload) {
|
|
4978
5002
|
return {
|
|
4979
5003
|
is_error: typeof payload.is_error === "boolean" ? payload.is_error : void 0,
|
|
@@ -5000,6 +5024,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
5000
5024
|
});
|
|
5001
5025
|
const toolCallMap = /* @__PURE__ */ new Map();
|
|
5002
5026
|
const taskMessageMap = /* @__PURE__ */ new Map();
|
|
5027
|
+
const workflowAgentMessageMap = /* @__PURE__ */ new Map();
|
|
5003
5028
|
const ambientTaskIds = /* @__PURE__ */ new Set();
|
|
5004
5029
|
const partialIndexes = /* @__PURE__ */ new Map();
|
|
5005
5030
|
const completedStreamIds = /* @__PURE__ */ new Set();
|
|
@@ -5195,23 +5220,16 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
5195
5220
|
});
|
|
5196
5221
|
if (toolName === "Task" || toolName === "Agent") {
|
|
5197
5222
|
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
5198
|
-
const nestedEvents = events
|
|
5199
|
-
|
|
5200
|
-
type: e.type,
|
|
5201
|
-
payload: e.payload
|
|
5202
|
-
}));
|
|
5203
|
-
messages.push({
|
|
5204
|
-
id: `subagent-${event.timestamp}-${messages.length}`,
|
|
5205
|
-
type: "subagent",
|
|
5223
|
+
const nestedEvents = collectNestedEvents(events, toolUseId);
|
|
5224
|
+
messages.push(createSubagentMessage(messages.length, event.timestamp, {
|
|
5206
5225
|
toolUseId,
|
|
5207
5226
|
description: inputObj.description || "Subagent Task",
|
|
5208
5227
|
prompt: inputObj.prompt || "",
|
|
5209
5228
|
subagentType: inputObj.subagent_type || "general",
|
|
5210
5229
|
model: inputObj.model,
|
|
5211
5230
|
status: "in_progress",
|
|
5212
|
-
nestedEvents
|
|
5213
|
-
|
|
5214
|
-
});
|
|
5231
|
+
nestedEvents
|
|
5232
|
+
}));
|
|
5215
5233
|
} else if (toolName === "Bash" || toolName === "bash" || toolName === "shell") {
|
|
5216
5234
|
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
5217
5235
|
const command = inputObj.command || "";
|
|
@@ -5300,9 +5318,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
5300
5318
|
const prompt = typeof inputObj.prompt === "string" ? inputObj.prompt : "";
|
|
5301
5319
|
const model = typeof inputObj.model === "string" ? inputObj.model : void 0;
|
|
5302
5320
|
const title = typeof inputObj.title === "string" ? inputObj.title : void 0;
|
|
5303
|
-
messages.push({
|
|
5304
|
-
id: `subagent-${event.timestamp}-${messages.length}`,
|
|
5305
|
-
type: "subagent",
|
|
5321
|
+
messages.push(createSubagentMessage(messages.length, event.timestamp, {
|
|
5306
5322
|
toolUseId,
|
|
5307
5323
|
description: title || `Relay subagent (${provider})`,
|
|
5308
5324
|
prompt,
|
|
@@ -5311,9 +5327,8 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
5311
5327
|
thinkingLevel: isValidThinkingLevel(inputObj.thinking_level) ? inputObj.thinking_level : void 0,
|
|
5312
5328
|
status: "in_progress",
|
|
5313
5329
|
nestedEvents: [],
|
|
5314
|
-
isChatBased: true
|
|
5315
|
-
|
|
5316
|
-
});
|
|
5330
|
+
isChatBased: true
|
|
5331
|
+
}));
|
|
5317
5332
|
} else if (toolName === "mcp__relay-subagent-tools__message_agent") {
|
|
5318
5333
|
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
5319
5334
|
messages.push({
|
|
@@ -5369,6 +5384,25 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
5369
5384
|
const payload = coerceBackgroundTaskPayload(event.payload);
|
|
5370
5385
|
if (payload?.ambient) ambientTaskIds.add(payload.taskId);
|
|
5371
5386
|
if (payload && !ambientTaskIds.has(payload.taskId)) {
|
|
5387
|
+
for (const workflowAgent of payload.workflowAgents ?? []) {
|
|
5388
|
+
const existingWorkflowAgent = workflowAgentMessageMap.get(workflowAgent.agentId);
|
|
5389
|
+
const nextWorkflowAgent = createSubagentMessage(
|
|
5390
|
+
messages.length,
|
|
5391
|
+
existingWorkflowAgent?.timestamp ?? event.timestamp,
|
|
5392
|
+
{
|
|
5393
|
+
id: existingWorkflowAgent?.id,
|
|
5394
|
+
toolUseId: workflowAgent.agentId,
|
|
5395
|
+
description: workflowAgent.label,
|
|
5396
|
+
prompt: workflowAgent.promptPreview ?? existingWorkflowAgent?.prompt ?? "",
|
|
5397
|
+
subagentType: "general",
|
|
5398
|
+
model: workflowAgent.model ?? existingWorkflowAgent?.model,
|
|
5399
|
+
status: workflowAgent.state === "done" ? "completed" : workflowAgent.state === "error" ? "failed" : "in_progress",
|
|
5400
|
+
output: workflowAgent.resultPreview ?? workflowAgent.lastToolSummary ?? existingWorkflowAgent?.output,
|
|
5401
|
+
nestedEvents: existingWorkflowAgent?.nestedEvents ?? collectNestedEvents(events, workflowAgent.agentId)
|
|
5402
|
+
}
|
|
5403
|
+
);
|
|
5404
|
+
workflowAgentMessageMap.set(workflowAgent.agentId, upsertDisplayMessage(messages, nextWorkflowAgent));
|
|
5405
|
+
}
|
|
5372
5406
|
const existing = taskMessageMap.get(payload.taskId);
|
|
5373
5407
|
const nextStatus = payload.subtype === "task_notification" ? normalizeBackgroundTaskStatus(payload.status) : payload.subtype === "task_updated" && payload.patch?.status !== void 0 ? normalizeBackgroundTaskStatus(payload.patch?.status) : existing?.status ?? "in_progress";
|
|
5374
5408
|
const nextMessage = {
|
|
@@ -5390,12 +5424,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
5390
5424
|
isBackgrounded: payload.isBackgrounded ?? payload.patch?.isBackgrounded ?? existing?.isBackgrounded,
|
|
5391
5425
|
timestamp: existing?.timestamp ?? event.timestamp
|
|
5392
5426
|
};
|
|
5393
|
-
|
|
5394
|
-
Object.assign(existing, nextMessage);
|
|
5395
|
-
} else {
|
|
5396
|
-
taskMessageMap.set(payload.taskId, nextMessage);
|
|
5397
|
-
messages.push(nextMessage);
|
|
5398
|
-
}
|
|
5427
|
+
taskMessageMap.set(payload.taskId, upsertDisplayMessage(messages, nextMessage));
|
|
5399
5428
|
}
|
|
5400
5429
|
}
|
|
5401
5430
|
});
|
|
@@ -7784,6 +7813,7 @@ function isSkillRegistryManifest(value) {
|
|
|
7784
7813
|
export {
|
|
7785
7814
|
isRecord,
|
|
7786
7815
|
isNonEmptyString,
|
|
7816
|
+
safeJsonParse,
|
|
7787
7817
|
TIMEOUT,
|
|
7788
7818
|
raceWithTimeout,
|
|
7789
7819
|
withTimeout,
|
|
@@ -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-MQMKKDOH.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.846";
|
|
245
245
|
var INITIALIZE_METHOD = "initialize";
|
|
246
246
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
247
247
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -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-HEH6SVCF.js";
|
|
7
7
|
import {
|
|
8
8
|
extractCommandProtectionCommandText,
|
|
9
9
|
findGitCommitSignals,
|
|
10
10
|
findPrMergeSignals
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MQMKKDOH.js";
|
|
12
12
|
|
|
13
13
|
// src/services/command-protection-service.ts
|
|
14
14
|
var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
setAgentCredentialSnapshot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HEH6SVCF.js";
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
11
|
SUBPROCESS_MAX_BUFFER,
|
|
12
12
|
buildCodexAgentEnv,
|
|
13
13
|
execFileAsync
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-RLO6MC7U.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-MQMKKDOH.js";
|
|
27
27
|
|
|
28
28
|
// src/managers/codex-token-manager.ts
|
|
29
29
|
import { promises as fs } from "fs";
|
|
@@ -238,7 +238,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
238
238
|
const data = await response.json();
|
|
239
239
|
await this.applyCredentialsResponse(data);
|
|
240
240
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
241
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
241
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-Y326VRVF.js");
|
|
242
242
|
await restartCodexAspHostIfRunning2();
|
|
243
243
|
}
|
|
244
244
|
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-T32XK5XV.js";
|
|
7
|
+
import "./chunk-HEH6SVCF.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-MQMKKDOH.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-T32XK5XV.js";
|
|
7
7
|
import {
|
|
8
8
|
notifyPostToolUse
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-LZSQ7376.js";
|
|
10
|
+
import "./chunk-HEH6SVCF.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-MQMKKDOH.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-RLO6MC7U.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
getMemoryOutputSafetyViolation,
|
|
15
15
|
headlessAgentRequestSchema
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-MQMKKDOH.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-T32XK5XV.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -131,20 +131,20 @@ import {
|
|
|
131
131
|
recordCredentialFallback,
|
|
132
132
|
recordExhaustedCredential,
|
|
133
133
|
restartCodexAspHost
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-ZFOQMUTU.js";
|
|
135
135
|
import {
|
|
136
136
|
ENGINE_ENV,
|
|
137
137
|
IS_WARMING_MODE,
|
|
138
138
|
monolithRequest,
|
|
139
139
|
monolithService,
|
|
140
140
|
setAgentCredentialSnapshot
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-HEH6SVCF.js";
|
|
142
142
|
import {
|
|
143
143
|
AspClient,
|
|
144
144
|
SUBPROCESS_MAX_BUFFER,
|
|
145
145
|
execAsync,
|
|
146
146
|
execFileAsync
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-RLO6MC7U.js";
|
|
148
148
|
import {
|
|
149
149
|
isRecord as isRecord2
|
|
150
150
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -344,6 +344,7 @@ import {
|
|
|
344
344
|
readJsonlPage,
|
|
345
345
|
renumberCodexAspTranscriptItems,
|
|
346
346
|
resolveWarmHookConfig,
|
|
347
|
+
safeJsonParse,
|
|
347
348
|
sanitizeCanvasFilename,
|
|
348
349
|
searchRepoFileIndex,
|
|
349
350
|
sendChatMessageRequestSchema,
|
|
@@ -354,7 +355,7 @@ import {
|
|
|
354
355
|
spawnRelaySubagentRequestSchema,
|
|
355
356
|
stripAgentDiagnosticErrors,
|
|
356
357
|
withTimeout
|
|
357
|
-
} from "./chunk-
|
|
358
|
+
} from "./chunk-MQMKKDOH.js";
|
|
358
359
|
import {
|
|
359
360
|
__commonJS,
|
|
360
361
|
__export,
|
|
@@ -10692,7 +10693,7 @@ async function registerDesktopPreview() {
|
|
|
10692
10693
|
}
|
|
10693
10694
|
|
|
10694
10695
|
// src/services/chat/chat-service.ts
|
|
10695
|
-
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir21, readFile as
|
|
10696
|
+
import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir21, readFile as readFile23, rename as rename4, rm as rm4 } from "fs/promises";
|
|
10696
10697
|
import { join as join36 } from "path";
|
|
10697
10698
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
10698
10699
|
|
|
@@ -10871,7 +10872,7 @@ import {
|
|
|
10871
10872
|
} from "@anthropic-ai/claude-agent-sdk";
|
|
10872
10873
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
10873
10874
|
import { dirname as dirname4, join as join16 } from "path";
|
|
10874
|
-
import { mkdir as mkdir10 } from "fs/promises";
|
|
10875
|
+
import { mkdir as mkdir10, readdir as readdir4, readFile as readFile11 } from "fs/promises";
|
|
10875
10876
|
import { homedir as homedir11 } from "os";
|
|
10876
10877
|
|
|
10877
10878
|
// src/utils/linear-converter.ts
|
|
@@ -12848,6 +12849,11 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
12848
12849
|
backgroundWatchdogTimer = null;
|
|
12849
12850
|
backgroundRecoveryAttempted = false;
|
|
12850
12851
|
backgroundWatchdogTriggered = false;
|
|
12852
|
+
// Ultracode workflow child agents never reach the SDK stream (forwardSubagentText
|
|
12853
|
+
// covers only Task subagents); their conversations exist solely as
|
|
12854
|
+
// agent-<agentId>.jsonl files in the run's transcript directory, keyed by task id.
|
|
12855
|
+
workflowTranscripts = /* @__PURE__ */ new Map();
|
|
12856
|
+
ambientTaskIds = /* @__PURE__ */ new Set();
|
|
12851
12857
|
// Set when background tasks outlive a turn; cleared once their completion
|
|
12852
12858
|
// has been reported through onTurnComplete.
|
|
12853
12859
|
pendingBackgroundCompletion = false;
|
|
@@ -13078,6 +13084,35 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13078
13084
|
};
|
|
13079
13085
|
};
|
|
13080
13086
|
}
|
|
13087
|
+
async forwardWorkflowAgentTranscripts(taskId) {
|
|
13088
|
+
const workflow = this.workflowTranscripts.get(taskId);
|
|
13089
|
+
if (!workflow || this.ambientTaskIds.has(taskId)) return;
|
|
13090
|
+
for (const file of await readdir4(workflow.dir).catch(() => [])) {
|
|
13091
|
+
const agentId = /^agent-(.+)\.jsonl$/.exec(file)?.[1];
|
|
13092
|
+
if (!agentId) continue;
|
|
13093
|
+
const offset = workflow.offsets.get(file) ?? 0;
|
|
13094
|
+
const buffer = await readFile11(join16(workflow.dir, file)).catch(() => Buffer.alloc(0));
|
|
13095
|
+
const end = buffer.lastIndexOf(10);
|
|
13096
|
+
if (end < offset) continue;
|
|
13097
|
+
workflow.offsets.set(file, end + 1);
|
|
13098
|
+
for (const line of buffer.toString("utf8", offset, end).split("\n").filter(Boolean)) {
|
|
13099
|
+
const entry = safeJsonParse(line, null);
|
|
13100
|
+
if (!entry || entry.type !== "user" && entry.type !== "assistant" || typeof entry.message !== "object" || !entry.message) continue;
|
|
13101
|
+
const event = {
|
|
13102
|
+
timestamp: typeof entry.timestamp === "string" ? entry.timestamp : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13103
|
+
type: `claude-${entry.type}`,
|
|
13104
|
+
payload: {
|
|
13105
|
+
type: entry.type,
|
|
13106
|
+
message: entry.message,
|
|
13107
|
+
parent_tool_use_id: agentId,
|
|
13108
|
+
session_id: typeof entry.sessionId === "string" ? entry.sessionId : this.sessionId ?? ""
|
|
13109
|
+
}
|
|
13110
|
+
};
|
|
13111
|
+
this.historyFile.append(event);
|
|
13112
|
+
this.onEvent(event);
|
|
13113
|
+
}
|
|
13114
|
+
}
|
|
13115
|
+
}
|
|
13081
13116
|
async processMessageInternal(request) {
|
|
13082
13117
|
let lastError;
|
|
13083
13118
|
let authRetryExhausted = false;
|
|
@@ -13436,6 +13471,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13436
13471
|
...ultracode ? { enableWorkflows: true, ultracode: true } : {}
|
|
13437
13472
|
},
|
|
13438
13473
|
includePartialMessages: true,
|
|
13474
|
+
forwardSubagentText: true,
|
|
13439
13475
|
...supportsClaudeThinkingDisplay(resolvedModel) ? { thinking: { type: "adaptive", display: "summarized" } } : {},
|
|
13440
13476
|
...effort ? { effort } : {},
|
|
13441
13477
|
canUseTool: this.buildCanUseTool(),
|
|
@@ -13455,6 +13491,16 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13455
13491
|
return {};
|
|
13456
13492
|
}],
|
|
13457
13493
|
timeout: 30
|
|
13494
|
+
}, {
|
|
13495
|
+
matcher: "Workflow",
|
|
13496
|
+
hooks: [async (input) => {
|
|
13497
|
+
const response2 = input.hook_event_name === "PostToolUse" ? input.tool_response : void 0;
|
|
13498
|
+
if (isRecord(response2) && typeof response2.taskId === "string" && typeof response2.transcriptDir === "string") {
|
|
13499
|
+
this.workflowTranscripts.set(response2.taskId, { dir: response2.transcriptDir, offsets: /* @__PURE__ */ new Map() });
|
|
13500
|
+
}
|
|
13501
|
+
return {};
|
|
13502
|
+
}],
|
|
13503
|
+
timeout: 30
|
|
13458
13504
|
}]
|
|
13459
13505
|
}
|
|
13460
13506
|
}
|
|
@@ -13597,6 +13643,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13597
13643
|
this.clearBackgroundWatchdog();
|
|
13598
13644
|
this.backgroundRecoveryAttempted = false;
|
|
13599
13645
|
this.backgroundWatchdogTriggered = false;
|
|
13646
|
+
this.workflowTranscripts.clear();
|
|
13647
|
+
this.ambientTaskIds.clear();
|
|
13600
13648
|
this.pendingBackgroundCompletion = false;
|
|
13601
13649
|
for (const timer of this.partialMessageFlushTimers.values()) {
|
|
13602
13650
|
clearTimeout(timer);
|
|
@@ -13996,6 +14044,12 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13996
14044
|
this.slashCommandsDiscoveredAt = Date.now();
|
|
13997
14045
|
}
|
|
13998
14046
|
this.trackNativeCompaction(message);
|
|
14047
|
+
if (message.type === "system" && message.subtype === "task_started" && message.ambient) {
|
|
14048
|
+
this.ambientTaskIds.add(message.task_id);
|
|
14049
|
+
}
|
|
14050
|
+
if (message.type === "system" && (message.subtype === "task_progress" || message.subtype === "task_updated" || message.subtype === "task_notification")) {
|
|
14051
|
+
await this.forwardWorkflowAgentTranscripts(message.task_id);
|
|
14052
|
+
}
|
|
13999
14053
|
await this.recordEvent(message);
|
|
14000
14054
|
}
|
|
14001
14055
|
// Claude Code intercepts /compact and auto-compaction inside the SDK process; we just observe the status messages to mirror state to the UI.
|
|
@@ -14011,10 +14065,15 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14011
14065
|
}
|
|
14012
14066
|
async recordEvent(event, replicasMessageId) {
|
|
14013
14067
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
14068
|
+
const restampAmbient = event.type === "system" && "task_id" in event && this.ambientTaskIds.has(event.task_id);
|
|
14014
14069
|
const jsonEvent = {
|
|
14015
14070
|
timestamp,
|
|
14016
14071
|
type: `claude-${event.type}`,
|
|
14017
|
-
payload:
|
|
14072
|
+
payload: {
|
|
14073
|
+
...event,
|
|
14074
|
+
...restampAmbient ? { ambient: true } : {},
|
|
14075
|
+
...replicasMessageId ? { [USER_MESSAGE_ID_PAYLOAD_KEY]: replicasMessageId } : {}
|
|
14076
|
+
}
|
|
14018
14077
|
};
|
|
14019
14078
|
this.historyFile.append(jsonEvent);
|
|
14020
14079
|
this.onEvent(jsonEvent);
|
|
@@ -14022,7 +14081,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14022
14081
|
};
|
|
14023
14082
|
|
|
14024
14083
|
// src/managers/codex-asp/codex-asp-manager.ts
|
|
14025
|
-
import { readdir as
|
|
14084
|
+
import { readdir as readdir5 } from "fs/promises";
|
|
14026
14085
|
import { join as join18 } from "path";
|
|
14027
14086
|
|
|
14028
14087
|
// src/utils/codex-quota.ts
|
|
@@ -14799,7 +14858,7 @@ function formatBlockedCommandReason(reason) {
|
|
|
14799
14858
|
async function readCodexAspThreadHistory(threadId) {
|
|
14800
14859
|
let entries;
|
|
14801
14860
|
try {
|
|
14802
|
-
entries = await
|
|
14861
|
+
entries = await readdir5(CODEX_HISTORY_DIR, { withFileTypes: true });
|
|
14803
14862
|
} catch (error) {
|
|
14804
14863
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
14805
14864
|
entries = [];
|
|
@@ -16219,14 +16278,14 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
16219
16278
|
};
|
|
16220
16279
|
|
|
16221
16280
|
// src/managers/cursor-manager.ts
|
|
16222
|
-
import { mkdir as mkdir12, readFile as
|
|
16281
|
+
import { mkdir as mkdir12, readFile as readFile13, readdir as readdir6 } from "fs/promises";
|
|
16223
16282
|
import { basename as basename2, dirname as dirname6, extname, join as join20 } from "path";
|
|
16224
16283
|
import { parse as parseYaml } from "yaml";
|
|
16225
16284
|
import { Agent as CursorAgent2 } from "@cursor/sdk";
|
|
16226
16285
|
|
|
16227
16286
|
// src/services/native-command-protection-hooks.ts
|
|
16228
16287
|
import { existsSync as existsSync8 } from "fs";
|
|
16229
|
-
import { mkdir as mkdir11, readFile as
|
|
16288
|
+
import { mkdir as mkdir11, readFile as readFile12, writeFile as writeFile6 } from "fs/promises";
|
|
16230
16289
|
import { basename, dirname as dirname5, join as join19 } from "path";
|
|
16231
16290
|
import { fileURLToPath } from "url";
|
|
16232
16291
|
var moduleDirectory = dirname5(fileURLToPath(import.meta.url));
|
|
@@ -16260,7 +16319,7 @@ async function ensureCursorCommandProtectionHook() {
|
|
|
16260
16319
|
const path7 = join19(ENGINE_ENV.HOME_DIR, ".cursor", "hooks.json");
|
|
16261
16320
|
let config = {};
|
|
16262
16321
|
try {
|
|
16263
|
-
const parsed = JSON.parse(await
|
|
16322
|
+
const parsed = JSON.parse(await readFile12(path7, "utf8"));
|
|
16264
16323
|
if (!isRecord2(parsed)) throw new Error("Invalid Cursor hooks configuration.");
|
|
16265
16324
|
config = parsed;
|
|
16266
16325
|
} catch (error) {
|
|
@@ -16285,7 +16344,7 @@ async function ensureGeminiCommandProtectionHook() {
|
|
|
16285
16344
|
const path7 = join19(ENGINE_ENV.HOME_DIR, ".gemini", "settings.json");
|
|
16286
16345
|
let config = {};
|
|
16287
16346
|
try {
|
|
16288
|
-
const parsed = JSON.parse(await
|
|
16347
|
+
const parsed = JSON.parse(await readFile12(path7, "utf8"));
|
|
16289
16348
|
if (!isRecord2(parsed)) throw new Error("Invalid Gemini hooks configuration.");
|
|
16290
16349
|
config = parsed;
|
|
16291
16350
|
} catch (error) {
|
|
@@ -16315,7 +16374,7 @@ async function ensureKimiCommandProtectionHook() {
|
|
|
16315
16374
|
const end = "# End Replicas command protection hook";
|
|
16316
16375
|
let config = "";
|
|
16317
16376
|
try {
|
|
16318
|
-
config = await
|
|
16377
|
+
config = await readFile12(path7, "utf8");
|
|
16319
16378
|
} catch (error) {
|
|
16320
16379
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
16321
16380
|
}
|
|
@@ -16409,7 +16468,7 @@ function extractCursorCommandDescription(content) {
|
|
|
16409
16468
|
async function listCursorCommandsInDirectory(directory) {
|
|
16410
16469
|
let entries;
|
|
16411
16470
|
try {
|
|
16412
|
-
entries = await
|
|
16471
|
+
entries = await readdir6(directory, { withFileTypes: true });
|
|
16413
16472
|
} catch (error) {
|
|
16414
16473
|
if (isRecord2(error) && error.code === "ENOENT") return [];
|
|
16415
16474
|
console.warn("[CursorManager] Failed to read slash command directory:", error);
|
|
@@ -16419,7 +16478,7 @@ async function listCursorCommandsInDirectory(directory) {
|
|
|
16419
16478
|
const name = basename2(entry.name, ".md");
|
|
16420
16479
|
let description;
|
|
16421
16480
|
try {
|
|
16422
|
-
description = extractCursorCommandDescription(await
|
|
16481
|
+
description = extractCursorCommandDescription(await readFile13(join20(directory, entry.name), "utf8"));
|
|
16423
16482
|
} catch (error) {
|
|
16424
16483
|
console.warn("[CursorManager] Failed to read slash command file:", error);
|
|
16425
16484
|
}
|
|
@@ -16800,7 +16859,7 @@ import { createRequire } from "module";
|
|
|
16800
16859
|
import { basename as basename3, dirname as dirname7, join as join21 } from "path";
|
|
16801
16860
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16802
16861
|
import { existsSync as existsSync9 } from "fs";
|
|
16803
|
-
import { mkdir as mkdir13, readFile as
|
|
16862
|
+
import { mkdir as mkdir13, readFile as readFile14, rename as rename2, writeFile as writeFile7 } from "fs/promises";
|
|
16804
16863
|
import { z as z2 } from "zod";
|
|
16805
16864
|
import WebSocket from "ws";
|
|
16806
16865
|
import { AbstractApiClient } from "@deepseek-ai/dsh-host-apiproxy/client";
|
|
@@ -17049,7 +17108,7 @@ var DeepseekManager = class extends CodingAgentManager {
|
|
|
17049
17108
|
if (!DSH_PATCH || !DSH_COMMAND_PROTECTION_PLUGIN) throw new Error("DeepSeek Harness configuration is missing from the engine package.");
|
|
17050
17109
|
const runtimePatch = join21(this.deepseekHome, "replicas.cordis.patch.yml");
|
|
17051
17110
|
await mkdir13(dirname7(runtimePatch), { recursive: true });
|
|
17052
|
-
await writeFile7(runtimePatch, (await
|
|
17111
|
+
await writeFile7(runtimePatch, (await readFile14(DSH_PATCH, "utf8")).replace(
|
|
17053
17112
|
"__REPLICAS_DSH_COMMAND_PROTECTION_PLUGIN__",
|
|
17054
17113
|
JSON.stringify(DSH_COMMAND_PROTECTION_PLUGIN)
|
|
17055
17114
|
));
|
|
@@ -17299,13 +17358,13 @@ ${request.message}` : request.message;
|
|
|
17299
17358
|
};
|
|
17300
17359
|
|
|
17301
17360
|
// src/managers/fx-manager.ts
|
|
17302
|
-
import { readFile as
|
|
17361
|
+
import { readFile as readFile16 } from "fs/promises";
|
|
17303
17362
|
import { spawn as spawn5 } from "child_process";
|
|
17304
17363
|
|
|
17305
17364
|
// src/managers/acp-manager.ts
|
|
17306
17365
|
import { spawn as spawn4 } from "child_process";
|
|
17307
17366
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
17308
|
-
import { mkdir as mkdir14, readFile as
|
|
17367
|
+
import { mkdir as mkdir14, readFile as readFile15, writeFile as writeFile8 } from "fs/promises";
|
|
17309
17368
|
import { dirname as dirname8 } from "path";
|
|
17310
17369
|
import { Writable } from "stream";
|
|
17311
17370
|
import {
|
|
@@ -17377,7 +17436,7 @@ var AcpManager = class extends CodingAgentManager {
|
|
|
17377
17436
|
});
|
|
17378
17437
|
const app2 = client({ name: "Replicas" }).onNotification(methods.client.session.update, ({ params }) => this.recordUpdate(params)).onRequest(methods.client.fs.readTextFile, async ({ params }) => {
|
|
17379
17438
|
this.assertSession(params.sessionId);
|
|
17380
|
-
const content = await
|
|
17439
|
+
const content = await readFile15(params.path, "utf8");
|
|
17381
17440
|
if (params.line === void 0 && params.limit === void 0) return { content };
|
|
17382
17441
|
const start = Math.max(0, (params.line ?? 1) - 1);
|
|
17383
17442
|
const end = params.limit === null || params.limit === void 0 ? void 0 : start + params.limit;
|
|
@@ -17764,7 +17823,7 @@ ${request.message}` : request.message
|
|
|
17764
17823
|
|
|
17765
17824
|
// src/managers/fx-manager.ts
|
|
17766
17825
|
async function ensureResolvableDnsConfig() {
|
|
17767
|
-
const contents = await
|
|
17826
|
+
const contents = await readFile16("/etc/resolv.conf");
|
|
17768
17827
|
if (contents.length === 0 || contents.at(-1) === 10) return;
|
|
17769
17828
|
await new Promise((resolve7, reject) => {
|
|
17770
17829
|
const child = spawn5("sudo", ["tee", "-a", "/etc/resolv.conf"], { stdio: ["pipe", "ignore", "pipe"] });
|
|
@@ -18373,7 +18432,7 @@ ${pending}
|
|
|
18373
18432
|
|
|
18374
18433
|
// src/managers/opencode-manager.ts
|
|
18375
18434
|
import { existsSync as existsSync10 } from "fs";
|
|
18376
|
-
import { copyFile, mkdir as mkdir16, readFile as
|
|
18435
|
+
import { copyFile, mkdir as mkdir16, readFile as readFile17, rm as rm2 } from "fs/promises";
|
|
18377
18436
|
import { delimiter, dirname as dirname10, join as join22 } from "path";
|
|
18378
18437
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
18379
18438
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
@@ -18427,7 +18486,7 @@ var opencodeAuthSchema = z3.record(z3.string(), z3.object({
|
|
|
18427
18486
|
async function hasOpencodeCredentials(provider) {
|
|
18428
18487
|
if (!existsSync10(OPENCODE_AUTH_PATH)) return false;
|
|
18429
18488
|
try {
|
|
18430
|
-
const auth2 = opencodeAuthSchema.safeParse(JSON.parse(await
|
|
18489
|
+
const auth2 = opencodeAuthSchema.safeParse(JSON.parse(await readFile17(OPENCODE_AUTH_PATH, "utf8")));
|
|
18431
18490
|
return auth2.success && auth2.data[provider]?.type === "api" && Boolean(auth2.data[provider]?.key);
|
|
18432
18491
|
} catch {
|
|
18433
18492
|
return false;
|
|
@@ -18532,7 +18591,7 @@ function isOpencodeMcpEntry(value) {
|
|
|
18532
18591
|
async function readProvisionedOpencodeMcpConfig() {
|
|
18533
18592
|
let raw;
|
|
18534
18593
|
try {
|
|
18535
|
-
raw = await
|
|
18594
|
+
raw = await readFile17(OPENCODE_CONFIG_PATH, "utf8");
|
|
18536
18595
|
} catch (error) {
|
|
18537
18596
|
if (isRecord2(error) && error.code === "ENOENT") return void 0;
|
|
18538
18597
|
console.error("[OpencodeManager] Failed to read Opencode config:", error);
|
|
@@ -19038,7 +19097,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
19038
19097
|
};
|
|
19039
19098
|
|
|
19040
19099
|
// src/managers/pi-manager.ts
|
|
19041
|
-
import { mkdir as mkdir18, readFile as
|
|
19100
|
+
import { mkdir as mkdir18, readFile as readFile18 } from "fs/promises";
|
|
19042
19101
|
import { dirname as dirname18, join as join29 } from "path";
|
|
19043
19102
|
import {
|
|
19044
19103
|
createAgentSession,
|
|
@@ -59520,7 +59579,7 @@ var pi_mcp_adapter_default = createMcpAdapter();
|
|
|
59520
59579
|
// src/managers/pi-manager.ts
|
|
59521
59580
|
async function getManagedPiMcpServers() {
|
|
59522
59581
|
try {
|
|
59523
|
-
const parsed = JSON.parse(await
|
|
59582
|
+
const parsed = JSON.parse(await readFile18(PI_MCP_CONFIG_PATH, "utf8"));
|
|
59524
59583
|
if (!isRecord2(parsed) || !isRecord2(parsed.mcpServers)) return {};
|
|
59525
59584
|
return Object.fromEntries(Object.entries(parsed.mcpServers).filter(
|
|
59526
59585
|
(entry) => isRecord2(entry[1]) && (typeof entry[1].command === "string" || typeof entry[1].url === "string")
|
|
@@ -59900,8 +59959,8 @@ async function uploadAnalytics(endpoint, body) {
|
|
|
59900
59959
|
import {
|
|
59901
59960
|
appendFile as appendFile4,
|
|
59902
59961
|
mkdir as mkdir19,
|
|
59903
|
-
readFile as
|
|
59904
|
-
readdir as
|
|
59962
|
+
readFile as readFile19,
|
|
59963
|
+
readdir as readdir7,
|
|
59905
59964
|
rename as rename3,
|
|
59906
59965
|
unlink as unlink3
|
|
59907
59966
|
} from "fs/promises";
|
|
@@ -59996,7 +60055,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
59996
60055
|
).catch(() => {
|
|
59997
60056
|
});
|
|
59998
60057
|
}
|
|
59999
|
-
const entries = await
|
|
60058
|
+
const entries = await readdir7(ENGINE_DIR2).catch(() => []);
|
|
60000
60059
|
let flushed = 0;
|
|
60001
60060
|
let failed = 0;
|
|
60002
60061
|
for (const entry of entries) {
|
|
@@ -60038,7 +60097,7 @@ var AnalyticsRecordBuffer = class {
|
|
|
60038
60097
|
return { flushed, failed };
|
|
60039
60098
|
}
|
|
60040
60099
|
async uploadSegment(filePath) {
|
|
60041
|
-
const records = this.parseRecords(await
|
|
60100
|
+
const records = this.parseRecords(await readFile19(filePath, "utf-8"));
|
|
60042
60101
|
if (records.length > 0) await this.options.upload(records);
|
|
60043
60102
|
await rename3(filePath, `${filePath}${UPLOADED_SUFFIX}`).catch(() => {
|
|
60044
60103
|
});
|
|
@@ -60877,7 +60936,7 @@ var KeepAliveService = class _KeepAliveService {
|
|
|
60877
60936
|
var keepAliveService = new KeepAliveService();
|
|
60878
60937
|
|
|
60879
60938
|
// src/services/canvas-service.ts
|
|
60880
|
-
import { readdir as
|
|
60939
|
+
import { readdir as readdir8, readFile as readFile21, stat as stat4 } from "fs/promises";
|
|
60881
60940
|
import { homedir as homedir13 } from "os";
|
|
60882
60941
|
import { join as join31 } from "path";
|
|
60883
60942
|
|
|
@@ -60905,9 +60964,9 @@ function fileRevision(content) {
|
|
|
60905
60964
|
}
|
|
60906
60965
|
|
|
60907
60966
|
// src/utils/revisioned-text-file.ts
|
|
60908
|
-
import { readFile as
|
|
60967
|
+
import { readFile as readFile20 } from "fs/promises";
|
|
60909
60968
|
async function writeRevisionedTextFile(filePath, content, expectedRevision) {
|
|
60910
|
-
const current = await
|
|
60969
|
+
const current = await readFile20(filePath, "utf8");
|
|
60911
60970
|
const revision = fileRevision(current);
|
|
60912
60971
|
if (revision !== expectedRevision) {
|
|
60913
60972
|
return {
|
|
@@ -60947,7 +61006,7 @@ var CanvasService = class {
|
|
|
60947
61006
|
if (!current) continue;
|
|
60948
61007
|
let entries;
|
|
60949
61008
|
try {
|
|
60950
|
-
entries = await
|
|
61009
|
+
entries = await readdir8(current.directory, { withFileTypes: true });
|
|
60951
61010
|
} catch {
|
|
60952
61011
|
continue;
|
|
60953
61012
|
}
|
|
@@ -61000,7 +61059,7 @@ var CanvasService = class {
|
|
|
61000
61059
|
};
|
|
61001
61060
|
}
|
|
61002
61061
|
try {
|
|
61003
|
-
const bytes = await
|
|
61062
|
+
const bytes = await readFile21(filePath);
|
|
61004
61063
|
return { filename: safe, kind, sizeBytes, mimeType, updatedAt, bytes };
|
|
61005
61064
|
} catch {
|
|
61006
61065
|
continue;
|
|
@@ -61162,7 +61221,7 @@ async function reconcileCanvasItems(filenames) {
|
|
|
61162
61221
|
// src/services/upload-chat-transcripts.ts
|
|
61163
61222
|
import { createReadStream } from "fs";
|
|
61164
61223
|
import { createHash as createHash8 } from "crypto";
|
|
61165
|
-
import { readFile as
|
|
61224
|
+
import { readFile as readFile22, readdir as readdir9, stat as stat5 } from "fs/promises";
|
|
61166
61225
|
import { basename as basename4, join as join33 } from "path";
|
|
61167
61226
|
|
|
61168
61227
|
// src/services/chat/chat-senders.ts
|
|
@@ -61202,7 +61261,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
61202
61261
|
for (const dir of HISTORY_DIRS) {
|
|
61203
61262
|
let entries;
|
|
61204
61263
|
try {
|
|
61205
|
-
entries = await
|
|
61264
|
+
entries = await readdir9(dir);
|
|
61206
61265
|
} catch {
|
|
61207
61266
|
continue;
|
|
61208
61267
|
}
|
|
@@ -61228,7 +61287,7 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map(), ca
|
|
|
61228
61287
|
async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
61229
61288
|
const { size } = await stat5(filePath);
|
|
61230
61289
|
if (size === 0) return null;
|
|
61231
|
-
const historyPages = createChatTranscriptPages(await
|
|
61290
|
+
const historyPages = createChatTranscriptPages(await readFile22(filePath));
|
|
61232
61291
|
const metadata = chat ? {
|
|
61233
61292
|
provider: chat.provider,
|
|
61234
61293
|
...chat.relayBaseProvider ? { relayBaseProvider: chat.relayBaseProvider } : {},
|
|
@@ -61249,7 +61308,7 @@ async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
61249
61308
|
}
|
|
61250
61309
|
try {
|
|
61251
61310
|
metadata.senders = parseChatMessageSendersJsonl(
|
|
61252
|
-
await
|
|
61311
|
+
await readFile22(chatMessageSendersFilePath(chatId), "utf-8")
|
|
61253
61312
|
);
|
|
61254
61313
|
} catch (error) {
|
|
61255
61314
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
@@ -61300,7 +61359,7 @@ async function uploadChatTranscript(chatId, filePath, chat, capture) {
|
|
|
61300
61359
|
|
|
61301
61360
|
// src/services/upload-engine-logs.ts
|
|
61302
61361
|
import { createReadStream as createReadStream2 } from "fs";
|
|
61303
|
-
import { readdir as
|
|
61362
|
+
import { readdir as readdir10, stat as stat6 } from "fs/promises";
|
|
61304
61363
|
import { join as join34 } from "path";
|
|
61305
61364
|
var MAX_ENGINE_LOG_FLUSH_SESSIONS = 10;
|
|
61306
61365
|
var MAX_ENGINE_LOG_FLUSH_BYTES = 5 * 1024 * 1024;
|
|
@@ -61311,7 +61370,7 @@ async function flushAllEngineLogs() {
|
|
|
61311
61370
|
let failed = 0;
|
|
61312
61371
|
const deadline = Date.now() + ENGINE_LOG_FLUSH_TIMEOUT_MS;
|
|
61313
61372
|
await runBeforeDeadline((signal) => engineLogger.flush(signal), deadline);
|
|
61314
|
-
const files = await runBeforeDeadline(() =>
|
|
61373
|
+
const files = await runBeforeDeadline(() => readdir10(LOG_DIR), deadline).catch(() => []);
|
|
61315
61374
|
const currentFilename = engineLogger.sessionId ? `${engineLogger.sessionId}.log` : null;
|
|
61316
61375
|
const filenames = files.filter((filename) => {
|
|
61317
61376
|
if (!filename.endsWith(".log")) return false;
|
|
@@ -61962,7 +62021,7 @@ var ChatService = class {
|
|
|
61962
62021
|
}
|
|
61963
62022
|
}
|
|
61964
62023
|
async readSenders(chatId) {
|
|
61965
|
-
return
|
|
62024
|
+
return readFile23(chatMessageSendersFilePath(chatId), "utf-8").then(parseChatMessageSendersJsonl).catch((error) => {
|
|
61966
62025
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return [];
|
|
61967
62026
|
console.error("[ChatService] Failed to read sender records:", error);
|
|
61968
62027
|
return [];
|
|
@@ -62750,7 +62809,7 @@ var ChatService = class {
|
|
|
62750
62809
|
}
|
|
62751
62810
|
async loadChats() {
|
|
62752
62811
|
try {
|
|
62753
|
-
const content = await
|
|
62812
|
+
const content = await readFile23(CHATS_FILE, "utf-8");
|
|
62754
62813
|
return parsePersistedChatsContent(content);
|
|
62755
62814
|
} catch (error) {
|
|
62756
62815
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
@@ -62765,7 +62824,7 @@ var ChatService = class {
|
|
|
62765
62824
|
console.error("[ChatService] Failed to quarantine corrupt chats file:", renameError);
|
|
62766
62825
|
}
|
|
62767
62826
|
try {
|
|
62768
|
-
const backupContent = await
|
|
62827
|
+
const backupContent = await readFile23(CHATS_BACKUP_FILE, "utf-8");
|
|
62769
62828
|
return parsePersistedChatsContent(backupContent);
|
|
62770
62829
|
} catch (backupError) {
|
|
62771
62830
|
if (backupError && typeof backupError === "object" && "code" in backupError && backupError.code === "ENOENT") {
|
|
@@ -62855,7 +62914,7 @@ var ChatService = class {
|
|
|
62855
62914
|
|
|
62856
62915
|
// src/services/repo-file-service.ts
|
|
62857
62916
|
import { execFile as execFile7 } from "child_process";
|
|
62858
|
-
import { readFile as
|
|
62917
|
+
import { readFile as readFile24 } from "fs/promises";
|
|
62859
62918
|
import { extname as extname3 } from "path";
|
|
62860
62919
|
|
|
62861
62920
|
// src/services/language-server-service.ts
|
|
@@ -63152,7 +63211,7 @@ var RepoFileService = class {
|
|
|
63152
63211
|
sizeBytes,
|
|
63153
63212
|
binary: true,
|
|
63154
63213
|
tooLarge: false,
|
|
63155
|
-
base64: (await
|
|
63214
|
+
base64: (await readFile24(fullPath)).toString("base64"),
|
|
63156
63215
|
mimeType
|
|
63157
63216
|
};
|
|
63158
63217
|
}
|
|
@@ -63177,7 +63236,7 @@ var RepoFileService = class {
|
|
|
63177
63236
|
tooLarge: true
|
|
63178
63237
|
};
|
|
63179
63238
|
}
|
|
63180
|
-
const content = await
|
|
63239
|
+
const content = await readFile24(fullPath, "utf-8");
|
|
63181
63240
|
return {
|
|
63182
63241
|
repoName,
|
|
63183
63242
|
path: filePath,
|
|
@@ -63209,7 +63268,7 @@ var RepoFileService = class {
|
|
|
63209
63268
|
async inspectSymbol(repoName, filePath, line, character, action) {
|
|
63210
63269
|
const resolved = await this.resolveFile(repoName, filePath);
|
|
63211
63270
|
if (!resolved || line < 1 || character < 0 || isBinaryExtension(filePath)) return null;
|
|
63212
|
-
const content = await
|
|
63271
|
+
const content = await readFile24(resolved.fullPath, "utf8");
|
|
63213
63272
|
const sourceLine = content.split("\n")[line - 1];
|
|
63214
63273
|
if (sourceLine === void 0) return null;
|
|
63215
63274
|
const symbolMatch = Array.from(sourceLine.matchAll(/[\p{L}_$][\p{L}\p{N}_$]*/gu)).find((match) => character >= match.index && character <= match.index + match[0].length);
|
|
@@ -63322,17 +63381,17 @@ var RepoFileService = class {
|
|
|
63322
63381
|
// src/v1-routes.ts
|
|
63323
63382
|
import { Hono } from "hono";
|
|
63324
63383
|
import { z as z6 } from "zod";
|
|
63325
|
-
import { readdir as
|
|
63384
|
+
import { readdir as readdir12, stat as stat7, readFile as readFile27 } from "fs/promises";
|
|
63326
63385
|
import { join as join40, resolve as resolve5 } from "path";
|
|
63327
63386
|
|
|
63328
63387
|
// src/services/warm-hooks-service.ts
|
|
63329
63388
|
import { spawn as spawn10 } from "child_process";
|
|
63330
|
-
import { readFile as
|
|
63389
|
+
import { readFile as readFile26 } from "fs/promises";
|
|
63331
63390
|
import { existsSync as existsSync18 } from "fs";
|
|
63332
63391
|
import { join as join39 } from "path";
|
|
63333
63392
|
|
|
63334
63393
|
// src/services/warm-hook-logs-service.ts
|
|
63335
|
-
import { mkdir as mkdir22, readFile as
|
|
63394
|
+
import { mkdir as mkdir22, readFile as readFile25, writeFile as writeFile12, readdir as readdir11, appendFile as appendFile6, unlink as unlink4 } from "fs/promises";
|
|
63336
63395
|
import { homedir as homedir14 } from "os";
|
|
63337
63396
|
import { join as join38 } from "path";
|
|
63338
63397
|
var LOGS_DIR2 = join38(homedir14(), ".replicas", "warm-hook-logs");
|
|
@@ -63379,7 +63438,7 @@ var WarmHookLogsService = class {
|
|
|
63379
63438
|
async getAllLogs() {
|
|
63380
63439
|
let files;
|
|
63381
63440
|
try {
|
|
63382
|
-
files = await
|
|
63441
|
+
files = await readdir11(LOGS_DIR2);
|
|
63383
63442
|
} catch (err) {
|
|
63384
63443
|
if (err.code === "ENOENT") {
|
|
63385
63444
|
return [];
|
|
@@ -63392,7 +63451,7 @@ var WarmHookLogsService = class {
|
|
|
63392
63451
|
continue;
|
|
63393
63452
|
}
|
|
63394
63453
|
try {
|
|
63395
|
-
const raw = await
|
|
63454
|
+
const raw = await readFile25(join38(LOGS_DIR2, file), "utf-8");
|
|
63396
63455
|
const stored = JSON.parse(raw);
|
|
63397
63456
|
logs.push(withPreview2(stored));
|
|
63398
63457
|
} catch {
|
|
@@ -63421,7 +63480,7 @@ var WarmHookLogsService = class {
|
|
|
63421
63480
|
}
|
|
63422
63481
|
async getCurrentRunLog() {
|
|
63423
63482
|
try {
|
|
63424
|
-
return await
|
|
63483
|
+
return await readFile25(CURRENT_RUN_LOG, "utf-8");
|
|
63425
63484
|
} catch (err) {
|
|
63426
63485
|
if (err.code === "ENOENT") return null;
|
|
63427
63486
|
throw err;
|
|
@@ -63430,7 +63489,7 @@ var WarmHookLogsService = class {
|
|
|
63430
63489
|
async getFullOutput(hookType, hookName) {
|
|
63431
63490
|
const filename = hookType === "global" ? GLOBAL_FILENAME : hookType === "environment" ? ENVIRONMENT_HOOK_LOG_FILENAME : repoHookLogFilename(hookName);
|
|
63432
63491
|
try {
|
|
63433
|
-
const raw = await
|
|
63492
|
+
const raw = await readFile25(join38(LOGS_DIR2, filename), "utf-8");
|
|
63434
63493
|
const stored = JSON.parse(raw);
|
|
63435
63494
|
if (stored.hookType !== hookType || stored.hookName !== hookName) {
|
|
63436
63495
|
return null;
|
|
@@ -63454,7 +63513,7 @@ async function readRepoWarmHook(repoPath) {
|
|
|
63454
63513
|
continue;
|
|
63455
63514
|
}
|
|
63456
63515
|
try {
|
|
63457
|
-
const raw = await
|
|
63516
|
+
const raw = await readFile26(configPath, "utf-8");
|
|
63458
63517
|
const config = parseReplicasConfigString(raw, filename);
|
|
63459
63518
|
if (!config.warmHook) {
|
|
63460
63519
|
return null;
|
|
@@ -64766,7 +64825,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64766
64825
|
});
|
|
64767
64826
|
app2.get("/logs", async (c) => {
|
|
64768
64827
|
try {
|
|
64769
|
-
const files = await
|
|
64828
|
+
const files = await readdir12(LOG_DIR).catch(() => []);
|
|
64770
64829
|
const logFiles = files.filter((f) => f.endsWith(".log"));
|
|
64771
64830
|
const sessions = await Promise.all(
|
|
64772
64831
|
logFiles.map(async (filename) => {
|
|
@@ -64805,7 +64864,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
64805
64864
|
}
|
|
64806
64865
|
let content;
|
|
64807
64866
|
try {
|
|
64808
|
-
content = await
|
|
64867
|
+
content = await readFile27(filePath, "utf-8");
|
|
64809
64868
|
} catch {
|
|
64810
64869
|
return c.json(jsonError("Log session not found"), 404);
|
|
64811
64870
|
}
|
|
@@ -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-LZSQ7376.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-MQMKKDOH.js";
|
|
11
11
|
import "./chunk-VEQXQN22.js";
|
|
12
12
|
|
|
13
13
|
// src/post-tool-pr-hook.ts
|
package/dist/src/relay-mcp.js
CHANGED