replicas-engine 0.1.1685 → 0.1.1688
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-ZAKD2UML.js → asp-host-ZQHJIZ66.js} +6 -5
- package/dist/src/{chunk-MTCBDF6Q.js → chunk-2FQOMURD.js} +2 -2
- package/dist/src/chunk-7PMLZC3V.js +48 -0
- package/dist/src/chunk-7ZDAVYTV.js +18 -0
- package/dist/src/{chunk-3JU53Q52.js → chunk-EKP2WDE7.js} +8 -8
- package/dist/src/chunk-ID3TOAOH.js +35 -0
- package/dist/src/{chunk-HFLANP5M.js → chunk-JRVPCYO2.js} +1 -1
- package/dist/src/{chunk-N2E6OIK5.js → chunk-NFRBKHVR.js} +80 -26
- package/dist/src/{chunk-OBCGNFJD.js → chunk-OWOVJSPF.js} +1 -1
- package/dist/src/{chunk-PD4L7TVG.js → chunk-PSCQSFAO.js} +13 -49
- package/dist/src/{chunk-BB6K3H62.js → chunk-QQ46DGF7.js} +3 -3
- package/dist/src/{chunk-TS5VL625.js → chunk-RECB5M3N.js} +5 -16
- package/dist/src/codemode-mcp.js +338 -0
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +5 -4
- package/dist/src/index.js +146 -149
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +3 -1
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
listCodexModelsForDetails,
|
|
9
9
|
restartCodexAspHost,
|
|
10
10
|
restartCodexAspHostIfRunning
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-PSCQSFAO.js";
|
|
12
|
+
import "./chunk-7PMLZC3V.js";
|
|
13
|
+
import "./chunk-EKP2WDE7.js";
|
|
14
|
+
import "./chunk-QQ46DGF7.js";
|
|
15
|
+
import "./chunk-OWOVJSPF.js";
|
|
15
16
|
import "./chunk-UZSNFLDQ.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-NFRBKHVR.js";
|
|
17
18
|
import "./chunk-VEQXQN22.js";
|
|
18
19
|
export {
|
|
19
20
|
CODEX_ULTRAFAST_SERVICE_TIER,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
runGitCommand
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EKP2WDE7.js";
|
|
9
9
|
import {
|
|
10
10
|
COMMAND_PROTECTION_MAX_MESSAGE_FILE_BYTES,
|
|
11
11
|
COMMAND_PROTECTION_REPO_GIT_ARGS,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
parseCommandProtectionRequest,
|
|
19
19
|
toCommandProtectionRepoState,
|
|
20
20
|
withRetry
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-NFRBKHVR.js";
|
|
22
22
|
|
|
23
23
|
// src/services/command-protection-service.ts
|
|
24
24
|
import { readFile, stat } from "fs/promises";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
SUBAGENT_MCP_TOOL_NAMES
|
|
6
|
+
} from "./chunk-NFRBKHVR.js";
|
|
7
|
+
|
|
8
|
+
// src/managers/subagent-mcp-config.ts
|
|
9
|
+
import { existsSync } from "fs";
|
|
10
|
+
import { dirname, join } from "path";
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
var SUBAGENT_MCP_TOOL_TIMEOUT_MS = 24 * 60 * 60 * 1e3 + 6e4;
|
|
14
|
+
function engineScriptProcess(script, args) {
|
|
15
|
+
const directory = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const builtEntry = join(directory, `${script}.js`);
|
|
17
|
+
const sourceEntry = join(directory, "..", `${script}.ts`);
|
|
18
|
+
const entry = existsSync(builtEntry) ? builtEntry : sourceEntry;
|
|
19
|
+
return {
|
|
20
|
+
command: process.execPath,
|
|
21
|
+
args: [
|
|
22
|
+
...entry.endsWith(".ts") ? ["--import", createRequire(import.meta.url).resolve("tsx/esm")] : [],
|
|
23
|
+
entry,
|
|
24
|
+
...args
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function subagentMcpProcessConfig(parentChatId) {
|
|
29
|
+
return engineScriptProcess("subagent-mcp", ["--parent", parentChatId]);
|
|
30
|
+
}
|
|
31
|
+
function subagentCodexMcpConfig(parentChatId) {
|
|
32
|
+
return {
|
|
33
|
+
...subagentMcpProcessConfig(parentChatId),
|
|
34
|
+
env_vars: ["REPLICAS_ENGINE_PORT", "REPLICAS_ENGINE_SECRET"],
|
|
35
|
+
enabled_tools: [...SUBAGENT_MCP_TOOL_NAMES],
|
|
36
|
+
required: true,
|
|
37
|
+
default_tools_approval_mode: "approve",
|
|
38
|
+
startup_timeout_sec: 10,
|
|
39
|
+
tool_timeout_sec: Math.ceil(SUBAGENT_MCP_TOOL_TIMEOUT_MS / 1e3)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
SUBAGENT_MCP_TOOL_TIMEOUT_MS,
|
|
45
|
+
engineScriptProcess,
|
|
46
|
+
subagentMcpProcessConfig,
|
|
47
|
+
subagentCodexMcpConfig
|
|
48
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
|
|
5
|
+
// src/managers/agent-auth-paths.ts
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
var OPENCODE_AUTH_PATH = join(homedir(), ".local", "share", "opencode", "auth.json");
|
|
9
|
+
var PI_AUTH_PATH = join(homedir(), ".pi", "agent", "auth.json");
|
|
10
|
+
var PI_MCP_CONFIG_PATH = join(homedir(), ".pi", "agent", "mcp.json");
|
|
11
|
+
var MUSE_AUTH_PATH = join(homedir(), ".config", "muse", "auth.json");
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
OPENCODE_AUTH_PATH,
|
|
15
|
+
PI_AUTH_PATH,
|
|
16
|
+
PI_MCP_CONFIG_PATH,
|
|
17
|
+
MUSE_AUTH_PATH
|
|
18
|
+
};
|
|
@@ -4,9 +4,9 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
SUBPROCESS_MAX_BUFFER,
|
|
6
6
|
execFileAsync
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OWOVJSPF.js";
|
|
8
8
|
import {
|
|
9
|
-
isRecord
|
|
9
|
+
isRecord
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
11
11
|
import {
|
|
12
12
|
ENGINE_PORT,
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
createErrorResult,
|
|
16
16
|
createSuccessResult,
|
|
17
17
|
fallbackPlanResponseSchema,
|
|
18
|
-
isRecord,
|
|
18
|
+
isRecord as isRecord2,
|
|
19
19
|
isValidAgentProvider,
|
|
20
20
|
parsePosixEnv,
|
|
21
21
|
provisionedDeviceSchema,
|
|
22
22
|
readReplicasRuntimeEnv,
|
|
23
23
|
serializePosixEnvFile
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-NFRBKHVR.js";
|
|
25
25
|
|
|
26
26
|
// src/runtime-env-loader.ts
|
|
27
27
|
import { readFileSync } from "fs";
|
|
@@ -116,7 +116,7 @@ function parseAgentCredentialSnapshots(value) {
|
|
|
116
116
|
if (!value) return {};
|
|
117
117
|
try {
|
|
118
118
|
const parsed = JSON.parse(value);
|
|
119
|
-
if (!
|
|
119
|
+
if (!isRecord(parsed)) return {};
|
|
120
120
|
const snapshots = {};
|
|
121
121
|
for (const [provider, snapshot] of Object.entries(parsed)) {
|
|
122
122
|
if (!isValidAgentProvider(provider)) continue;
|
|
@@ -312,10 +312,10 @@ var MonolithService = class {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
getSubagentMcpConfig() {
|
|
315
|
-
return this.getJson("/v1/engine/subagent-mcp", (body) =>
|
|
315
|
+
return this.getJson("/v1/engine/subagent-mcp", (body) => isRecord2(body) && typeof body.enabled === "boolean" && Array.isArray(body.providers) && body.providers.every((provider) => typeof provider === "string" && isValidAgentProvider(provider)) ? { enabled: body.enabled, providers: body.providers } : null, AbortSignal.timeout(1e4));
|
|
316
316
|
}
|
|
317
317
|
getAutoCompactConfig(provider) {
|
|
318
|
-
return this.getJson(`/v1/engine/auto-compact?provider=${provider}`, (body) =>
|
|
318
|
+
return this.getJson(`/v1/engine/auto-compact?provider=${provider}`, (body) => isRecord2(body) && (body.tokens === null || typeof body.tokens === "number") ? { tokens: body.tokens } : null, AbortSignal.timeout(1e4));
|
|
319
319
|
}
|
|
320
320
|
async generateChatName(request) {
|
|
321
321
|
const response = await monolithRequest("/v1/engine/chat-name", { body: request, signal: AbortSignal.timeout(3e4) });
|
|
@@ -324,7 +324,7 @@ var MonolithService = class {
|
|
|
324
324
|
return body.name;
|
|
325
325
|
}
|
|
326
326
|
getOpenRouterModels() {
|
|
327
|
-
return this.getJson("/v1/engine/openrouter-models", (body) =>
|
|
327
|
+
return this.getJson("/v1/engine/openrouter-models", (body) => isRecord2(body) && Array.isArray(body.models) && body.models.every((model) => typeof model === "string") ? body.models : null);
|
|
328
328
|
}
|
|
329
329
|
/** `unsupported` means an older monolith; `unavailable` means this one could not be read. */
|
|
330
330
|
async getFallbackPlan(params) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
PI_MCP_CONFIG_PATH
|
|
6
|
+
} from "./chunk-7ZDAVYTV.js";
|
|
7
|
+
import {
|
|
8
|
+
engineScriptProcess
|
|
9
|
+
} from "./chunk-7PMLZC3V.js";
|
|
10
|
+
import {
|
|
11
|
+
isRecord
|
|
12
|
+
} from "./chunk-UZSNFLDQ.js";
|
|
13
|
+
|
|
14
|
+
// src/managers/managed-mcp-servers.ts
|
|
15
|
+
import { readFile } from "fs/promises";
|
|
16
|
+
async function getManagedPiMcpServers(path = PI_MCP_CONFIG_PATH) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(await readFile(path, "utf8"));
|
|
19
|
+
if (!isRecord(parsed) || !isRecord(parsed.mcpServers)) return {};
|
|
20
|
+
return Object.fromEntries(Object.entries(parsed.mcpServers).filter(
|
|
21
|
+
(entry) => isRecord(entry[1]) && (typeof entry[1].command === "string" || typeof entry[1].url === "string")
|
|
22
|
+
));
|
|
23
|
+
} catch {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function managedMcpServerProcess(entry) {
|
|
28
|
+
if (entry.command) return { command: entry.command, args: entry.args ?? [], env: entry.env };
|
|
29
|
+
return { ...engineScriptProcess("mcp-http-bridge", []), env: { REPLICAS_MCP_URL: entry.url ?? "", REPLICAS_MCP_HEADERS: JSON.stringify(entry.headers ?? {}) } };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
getManagedPiMcpServers,
|
|
34
|
+
managedMcpServerProcess
|
|
35
|
+
};
|
|
@@ -11067,6 +11067,9 @@ function getEventStreamId(event) {
|
|
|
11067
11067
|
var CODEX_QUOTA_STATUS_EVENT_TYPE = "codex-quota-status";
|
|
11068
11068
|
var CHAT_INTERRUPTED_EVENT_TYPE = "replicas-interrupted";
|
|
11069
11069
|
var CHAT_MESSAGE_REJECTED_EVENT_TYPE = "replicas-message-rejected";
|
|
11070
|
+
var REJECTED_MESSAGE_ID_PAYLOAD_KEY = "rejectedMessageId";
|
|
11071
|
+
var REJECTED_CODE_PAYLOAD_KEY = "rejectedCode";
|
|
11072
|
+
var REFUSED_COPY_MESSAGE_ID_PREFIX = "refused-copy-";
|
|
11070
11073
|
var CHAT_TURN_LOST_EVENT_TYPE = "replicas-turn-lost";
|
|
11071
11074
|
var CHAT_TURN_LOST_MESSAGE = "The workspace restarted and cut this turn off. It wasn't retried.";
|
|
11072
11075
|
var CHAT_GOAL_EVENT_TYPE = "chat-goal";
|
|
@@ -11255,6 +11258,8 @@ var sendChatMessageRequestSchema = z9.object({
|
|
|
11255
11258
|
type: z9.string().min(1).optional(),
|
|
11256
11259
|
merge: z9.boolean().optional(),
|
|
11257
11260
|
idempotencyKey: z9.string().min(1).max(128).optional(),
|
|
11261
|
+
// The workspace's stop count as this send read it when it arrived: set by the monolith alone. Lower than the number of the engine's last Stop of the chat, the send is older than that Stop.
|
|
11262
|
+
stopsSeen: z9.number().int().nonnegative().optional(),
|
|
11258
11263
|
automationId: z9.string().optional(),
|
|
11259
11264
|
environmentId: z9.string().min(1).optional(),
|
|
11260
11265
|
senderUserId: z9.string().optional(),
|
|
@@ -11462,7 +11467,11 @@ var sendChatMessageResponseSchema = z9.object({
|
|
|
11462
11467
|
chatId: z9.string().optional(),
|
|
11463
11468
|
steered: z9.boolean().optional()
|
|
11464
11469
|
});
|
|
11465
|
-
var interruptChatRequestSchema = z9.object({
|
|
11470
|
+
var interruptChatRequestSchema = z9.object({
|
|
11471
|
+
stoppedAt: z9.string().datetime().optional(),
|
|
11472
|
+
// The workspace's stop count once this Stop was noted: set by the monolith alone. A send that saw a lower count is older than this Stop.
|
|
11473
|
+
stopNumber: z9.number().int().positive().optional()
|
|
11474
|
+
});
|
|
11466
11475
|
var respondToolInputRequestSchema = z9.object({
|
|
11467
11476
|
requestId: z9.string().min(1),
|
|
11468
11477
|
selectionId: z9.string().min(1),
|
|
@@ -12186,6 +12195,7 @@ var execRequestSchema = z15.object({
|
|
|
12186
12195
|
idleTtlMs: z15.number().int().positive().max(EXEC_MAX_IDLE_TTL_MS).optional(),
|
|
12187
12196
|
stdin: z15.boolean().optional()
|
|
12188
12197
|
}).refine((body2) => [body2.command, body2.argv, body2.mcpServer].filter((value) => value !== void 0).length === 1, { message: "Pass exactly one of command, argv or mcpServer" });
|
|
12198
|
+
var CODE_MODE_MCP_SERVER = "replicas-codemode";
|
|
12189
12199
|
var execStartedSchema = z15.object({ processId: z15.string(), pid: z15.number() });
|
|
12190
12200
|
var execExitSchema = z15.object({ exitCode: z15.number(), signal: z15.string().nullable(), reason: z15.enum(["exit", "timeout", "killed", "idle"]) });
|
|
12191
12201
|
var execReplySchemas = {
|
|
@@ -12271,6 +12281,28 @@ async function readSseStream(body2, onEvent, shouldContinue = () => true, onChun
|
|
|
12271
12281
|
|
|
12272
12282
|
// ../shared/src/types.ts
|
|
12273
12283
|
var ENGINE_SEND_MESSAGE_FAILED_ERROR = "Failed to send message";
|
|
12284
|
+
var CHAT_MESSAGE_CANCELLED_CODE = "message_cancelled";
|
|
12285
|
+
var CHAT_MESSAGE_HANDED_BACK_CODE = "message_handed_back";
|
|
12286
|
+
var CHAT_MESSAGE_OUTCOME_UNKNOWN_CODE = "message_outcome_unknown";
|
|
12287
|
+
var CHAT_MESSAGE_TAKEN_BACK_CODES = [CHAT_MESSAGE_CANCELLED_CODE, CHAT_MESSAGE_HANDED_BACK_CODE, CHAT_MESSAGE_OUTCOME_UNKNOWN_CODE];
|
|
12288
|
+
var CHAT_MESSAGE_TAKEN_BACK_DETAILS = {
|
|
12289
|
+
[CHAT_MESSAGE_CANCELLED_CODE]: "It was cancelled before it ran. Send it again as a new message.",
|
|
12290
|
+
[CHAT_MESSAGE_HANDED_BACK_CODE]: "It was handed back when Stop was pressed. Send it again as a new message.",
|
|
12291
|
+
[CHAT_MESSAGE_OUTCOME_UNKNOWN_CODE]: "It may still have reached the agent. Check the chat before sending it again."
|
|
12292
|
+
};
|
|
12293
|
+
var CHAT_MESSAGE_NOT_ACCEPTED_MAY_HAVE_RUN_CODE = "message_not_accepted_may_have_run";
|
|
12294
|
+
var CHAT_MESSAGE_CHAT_NOT_FOUND_CODE = "chat_not_found";
|
|
12295
|
+
var CHAT_MESSAGE_WORKSPACE_REFUSED_CODE = "workspace_refused_message";
|
|
12296
|
+
var CHAT_MESSAGE_NOT_DELIVERED_CODE = "message_not_delivered";
|
|
12297
|
+
var CHAT_MESSAGE_NOT_SUPPORTED_BY_WORKSPACE_CODE = "not_supported_by_workspace";
|
|
12298
|
+
var CHAT_MESSAGE_REFUSED_ROW_CODES = [
|
|
12299
|
+
...CHAT_MESSAGE_TAKEN_BACK_CODES,
|
|
12300
|
+
CHAT_MESSAGE_NOT_ACCEPTED_MAY_HAVE_RUN_CODE,
|
|
12301
|
+
CHAT_MESSAGE_CHAT_NOT_FOUND_CODE,
|
|
12302
|
+
CHAT_MESSAGE_WORKSPACE_REFUSED_CODE,
|
|
12303
|
+
CHAT_MESSAGE_NOT_DELIVERED_CODE,
|
|
12304
|
+
CHAT_MESSAGE_NOT_SUPPORTED_BY_WORKSPACE_CODE
|
|
12305
|
+
];
|
|
12274
12306
|
|
|
12275
12307
|
// ../shared/src/routes/workspaces.ts
|
|
12276
12308
|
import { z as z17 } from "zod";
|
|
@@ -16784,6 +16816,23 @@ function threadHandoffText(content) {
|
|
|
16784
16816
|
return envelope.meta.trigger === "auto" ? "" : envelope.replyText;
|
|
16785
16817
|
}
|
|
16786
16818
|
|
|
16819
|
+
// ../shared/src/user-message-matching.ts
|
|
16820
|
+
var parsedTimestamps = /* @__PURE__ */ new Map();
|
|
16821
|
+
function parseTimestampMs(timestamp2) {
|
|
16822
|
+
if (typeof timestamp2 === "number") return Number.isFinite(timestamp2) ? timestamp2 : 0;
|
|
16823
|
+
let value = parsedTimestamps.get(timestamp2);
|
|
16824
|
+
if (value === void 0) {
|
|
16825
|
+
const parsed = Date.parse(timestamp2);
|
|
16826
|
+
value = Number.isFinite(parsed) ? parsed : 0;
|
|
16827
|
+
if (parsedTimestamps.size >= 5e4) parsedTimestamps.clear();
|
|
16828
|
+
parsedTimestamps.set(timestamp2, value);
|
|
16829
|
+
}
|
|
16830
|
+
return value;
|
|
16831
|
+
}
|
|
16832
|
+
function areUserMessagesWithinMatchWindow(a, b) {
|
|
16833
|
+
return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
|
|
16834
|
+
}
|
|
16835
|
+
|
|
16787
16836
|
// ../shared/src/display-message/chat-thread.ts
|
|
16788
16837
|
function describeHarnessSwitch(message2) {
|
|
16789
16838
|
if (message2.trigger === "switch") return `Switched from ${getProviderDisplayName(message2.fromProvider, "long")} to ${getProviderDisplayName(message2.toProvider, "long")}`;
|
|
@@ -17765,23 +17814,6 @@ var managerTicketThreadSchema = z32.array(z32.object({
|
|
|
17765
17814
|
var LINEAR_ISSUE_SUMMARIES_MAX = 50;
|
|
17766
17815
|
var linearIssueSummariesRequestSchema = z32.object({ identifiers: z32.array(linearIdentifier).min(1).max(LINEAR_ISSUE_SUMMARIES_MAX) });
|
|
17767
17816
|
|
|
17768
|
-
// ../shared/src/user-message-matching.ts
|
|
17769
|
-
var parsedTimestamps = /* @__PURE__ */ new Map();
|
|
17770
|
-
function parseTimestampMs(timestamp2) {
|
|
17771
|
-
if (typeof timestamp2 === "number") return Number.isFinite(timestamp2) ? timestamp2 : 0;
|
|
17772
|
-
let value = parsedTimestamps.get(timestamp2);
|
|
17773
|
-
if (value === void 0) {
|
|
17774
|
-
const parsed = Date.parse(timestamp2);
|
|
17775
|
-
value = Number.isFinite(parsed) ? parsed : 0;
|
|
17776
|
-
if (parsedTimestamps.size >= 5e4) parsedTimestamps.clear();
|
|
17777
|
-
parsedTimestamps.set(timestamp2, value);
|
|
17778
|
-
}
|
|
17779
|
-
return value;
|
|
17780
|
-
}
|
|
17781
|
-
function areUserMessagesWithinMatchWindow(a, b) {
|
|
17782
|
-
return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
|
|
17783
|
-
}
|
|
17784
|
-
|
|
17785
17817
|
// ../shared/src/display-message/turns.ts
|
|
17786
17818
|
function isCompaction(message2) {
|
|
17787
17819
|
return message2.type === "reasoning" && message2.content === COMPACTION_CONTENT;
|
|
@@ -19952,8 +19984,10 @@ function parseReplicasEvents(events) {
|
|
|
19952
19984
|
messages.push({
|
|
19953
19985
|
id: typeof messageId === "string" ? messageId : `replicas-user-${String(payload.seq)}`,
|
|
19954
19986
|
type: "user",
|
|
19955
|
-
content:
|
|
19987
|
+
content: extractToolResultText(message2.content),
|
|
19956
19988
|
...images.length ? { images } : {},
|
|
19989
|
+
// Replicas history lists no senders, and only the sender is offered Send again. Sent messages stay without one: a subagent's assignment carries its owner's id.
|
|
19990
|
+
...event.type === `${HARNESS_EVENT_TYPE_PREFIX}cancelled_message` ? { cancelled: true, ...typeof payload.userId === "string" ? { senderUserId: payload.userId } : {} } : {},
|
|
19957
19991
|
timestamp: timestamp2
|
|
19958
19992
|
});
|
|
19959
19993
|
return;
|
|
@@ -20652,6 +20686,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
20652
20686
|
|
|
20653
20687
|
// ../shared/src/display-message/parsers/index.ts
|
|
20654
20688
|
var INTERRUPTION_DEDUP_WINDOW_MS = 15e3;
|
|
20689
|
+
var STOP_CLOCK_SKEW_MS = 5e3;
|
|
20655
20690
|
function parseAgentEvents(events, agentType) {
|
|
20656
20691
|
return withoutReplacedMessages(excludeQueuedAcceptedEvents(events, []), (segment) => parseProviderEvents(segment, agentType));
|
|
20657
20692
|
}
|
|
@@ -20716,12 +20751,18 @@ function applyInterruptions(messages, events) {
|
|
|
20716
20751
|
const result = [...messages];
|
|
20717
20752
|
for (const event of events) {
|
|
20718
20753
|
if (event.type !== CHAT_INTERRUPTED_EVENT_TYPE) continue;
|
|
20719
|
-
|
|
20754
|
+
const interruption = {
|
|
20720
20755
|
id: `interruption-${event.timestamp}`,
|
|
20721
20756
|
type: "interruption",
|
|
20722
20757
|
timestamp: event.timestamp,
|
|
20723
20758
|
...event.payload.steered === true ? { steered: true } : {}
|
|
20724
|
-
}
|
|
20759
|
+
};
|
|
20760
|
+
insertDisplayMessageByTimestamp(result, interruption);
|
|
20761
|
+
const at = result.indexOf(interruption);
|
|
20762
|
+
const stoppedMs = parseTimestampMs(event.timestamp);
|
|
20763
|
+
let to = at;
|
|
20764
|
+
for (let previous = result[to - 1]; previous?.type === "user" && previous.cancelled && stoppedMs - parseTimestampMs(previous.timestamp) <= STOP_CLOCK_SKEW_MS; previous = result[to - 1]) to--;
|
|
20765
|
+
if (to < at) result.splice(to, 0, ...result.splice(at, 1));
|
|
20725
20766
|
}
|
|
20726
20767
|
let lastUserMs = null;
|
|
20727
20768
|
let lastInterruption = null;
|
|
@@ -20763,6 +20804,8 @@ function applyEngineNotices(messages, events) {
|
|
|
20763
20804
|
id: `message-rejected-${event.timestamp}-${index}`,
|
|
20764
20805
|
type: "error",
|
|
20765
20806
|
message: typeof event.payload.message === "string" ? event.payload.message : "Message was rejected",
|
|
20807
|
+
rejectedMessageId: typeof event.payload[REJECTED_MESSAGE_ID_PAYLOAD_KEY] === "string" ? event.payload[REJECTED_MESSAGE_ID_PAYLOAD_KEY] : void 0,
|
|
20808
|
+
rejectedCode: CHAT_MESSAGE_REFUSED_ROW_CODES.find((code) => code === event.payload[REJECTED_CODE_PAYLOAD_KEY]),
|
|
20766
20809
|
timestamp: event.timestamp
|
|
20767
20810
|
});
|
|
20768
20811
|
return;
|
|
@@ -20817,12 +20860,12 @@ function filterDisplayMessages(messages, provider2) {
|
|
|
20817
20860
|
strippedUserContents.set(msg.content, stripped);
|
|
20818
20861
|
}
|
|
20819
20862
|
const { content, files, walkthroughs, appshots, annotations } = stripped;
|
|
20820
|
-
if (INTERRUPTED_MESSAGE_REGEX.test(content)) {
|
|
20863
|
+
if (!msg.cancelled && INTERRUPTED_MESSAGE_REGEX.test(content)) {
|
|
20821
20864
|
return [{ id: msg.id, type: "interruption", timestamp: msg.timestamp }];
|
|
20822
20865
|
}
|
|
20823
20866
|
const cleaned = withoutAttachmentPlaceholder(content, Boolean(msg.images?.length || files.length));
|
|
20824
20867
|
if (cleaned.length === 0 && !msg.images?.length && files.length === 0 && walkthroughs.length === 0 && appshots.length === 0 && annotations.length === 0) return [];
|
|
20825
|
-
const origin = parseMessageOrigin(msg.content);
|
|
20868
|
+
const origin = msg.cancelled ? null : parseMessageOrigin(msg.content);
|
|
20826
20869
|
if (cleaned === msg.content && !origin && files.length === 0 && walkthroughs.length === 0 && appshots.length === 0 && annotations.length === 0) return [msg];
|
|
20827
20870
|
return [{
|
|
20828
20871
|
...msg,
|
|
@@ -20904,7 +20947,7 @@ function getUserMessageId(event) {
|
|
|
20904
20947
|
}
|
|
20905
20948
|
function getReplacedMessageId(event) {
|
|
20906
20949
|
const messageId = event.payload[REPLACED_MESSAGE_ID_PAYLOAD_KEY];
|
|
20907
|
-
return typeof messageId === "string" ? messageId : null;
|
|
20950
|
+
return typeof messageId === "string" && !messageId.startsWith(REFUSED_COPY_MESSAGE_ID_PREFIX) && !messageId.startsWith(`user-${REFUSED_COPY_MESSAGE_ID_PREFIX}`) ? messageId : null;
|
|
20908
20951
|
}
|
|
20909
20952
|
function getRemovedMessageIds(event) {
|
|
20910
20953
|
if (event.type !== QUEUED_MESSAGE_REMOVED_EVENT_TYPE) return [];
|
|
@@ -21601,7 +21644,7 @@ async function withRetry(label, fn, options) {
|
|
|
21601
21644
|
}
|
|
21602
21645
|
|
|
21603
21646
|
// ../shared/src/tensorlake.ts
|
|
21604
|
-
var TENSORLAKE_IMAGE_NAME = "replicas-sandbox-2026-11-20-
|
|
21647
|
+
var TENSORLAKE_IMAGE_NAME = "replicas-sandbox-2026-11-20-v38";
|
|
21605
21648
|
var TENSORLAKE_DISK_MB = 100 * 1024;
|
|
21606
21649
|
|
|
21607
21650
|
// ../shared/src/egress.ts
|
|
@@ -22341,6 +22384,15 @@ function hasChatStarted(chat) {
|
|
|
22341
22384
|
return chat.processing || Boolean(chat.awaitingInput) || Boolean(chat.goal) || Boolean(chat.lastMessageText) || chat.updatedAt > chat.createdAt;
|
|
22342
22385
|
}
|
|
22343
22386
|
|
|
22387
|
+
// ../shared/src/mcp-tool-search.ts
|
|
22388
|
+
function rankToolsByQuery(tools, query, text4) {
|
|
22389
|
+
const terms = query.toLowerCase().split(/[\s_-]+/).filter(Boolean);
|
|
22390
|
+
return tools.map((tool) => {
|
|
22391
|
+
const { name, description: description2 } = text4(tool);
|
|
22392
|
+
return { tool, score: terms.reduce((sum, term) => sum + (name.toLowerCase().includes(term) ? 3 : 0) + (description2.toLowerCase().includes(term) ? 1 : 0), 0) };
|
|
22393
|
+
}).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score).map(({ tool }) => tool);
|
|
22394
|
+
}
|
|
22395
|
+
|
|
22344
22396
|
// ../shared/src/engine/exec-client.ts
|
|
22345
22397
|
var RECONNECT_GIVE_UP_MS = 2 * 6e4;
|
|
22346
22398
|
var encoder3 = new TextEncoder();
|
|
@@ -24125,6 +24177,7 @@ export {
|
|
|
24125
24177
|
formatChatForkHandoffMessage,
|
|
24126
24178
|
formatChatForkUpdateMessage,
|
|
24127
24179
|
threadHandoffText,
|
|
24180
|
+
areUserMessagesWithinMatchWindow,
|
|
24128
24181
|
INTERRUPTED_MESSAGE_REGEX,
|
|
24129
24182
|
isToolInputQuestion,
|
|
24130
24183
|
fileContentDiff,
|
|
@@ -24134,7 +24187,6 @@ export {
|
|
|
24134
24187
|
LEARNED_SKILLS_MANIFEST_PATH,
|
|
24135
24188
|
LEARNED_SKILL_DIR_PREFIX,
|
|
24136
24189
|
learnedSkillsManifestSchema,
|
|
24137
|
-
areUserMessagesWithinMatchWindow,
|
|
24138
24190
|
toolInputAnswer,
|
|
24139
24191
|
lastPlainStepLabel,
|
|
24140
24192
|
currentStepLabel,
|
|
@@ -24217,6 +24269,8 @@ export {
|
|
|
24217
24269
|
decodeExecFrame,
|
|
24218
24270
|
EXEC_ERROR_CODES,
|
|
24219
24271
|
execRequestSchema,
|
|
24272
|
+
CODE_MODE_MCP_SERVER,
|
|
24273
|
+
rankToolsByQuery,
|
|
24220
24274
|
CODEX_AUTH_ENV_KEYS,
|
|
24221
24275
|
codexAuthEnvFromResponse,
|
|
24222
24276
|
CODEX_AUTH_ENV_KEYS_BY_METHOD,
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NFRBKHVR.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/exec.ts
|
|
9
9
|
import { exec, execFile } from "child_process";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module';
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
subagentCodexMcpConfig
|
|
6
|
+
} from "./chunk-7PMLZC3V.js";
|
|
4
7
|
import {
|
|
5
8
|
ENGINE_ENV,
|
|
6
9
|
UNQUOTED_PATHS_CONFIG,
|
|
@@ -12,15 +15,15 @@ import {
|
|
|
12
15
|
resolveDiffBase,
|
|
13
16
|
runGitCommand,
|
|
14
17
|
setAgentCredentialSnapshot
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EKP2WDE7.js";
|
|
16
19
|
import {
|
|
17
20
|
AppServerProcess,
|
|
18
21
|
buildCodexAgentEnv
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QQ46DGF7.js";
|
|
20
23
|
import {
|
|
21
24
|
SUBPROCESS_MAX_BUFFER,
|
|
22
25
|
execFileAsync
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-OWOVJSPF.js";
|
|
24
27
|
import {
|
|
25
28
|
isRecord
|
|
26
29
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -37,7 +40,6 @@ import {
|
|
|
37
40
|
MANAGER_INSTRUCTIONS_TAG,
|
|
38
41
|
SHRUNK_IMAGE_QUALITY,
|
|
39
42
|
SUBAGENT_MCP_SERVER_NAME,
|
|
40
|
-
SUBAGENT_MCP_TOOL_NAMES,
|
|
41
43
|
buildCodeHostPrUrl,
|
|
42
44
|
buildGitCredentialHelperScript,
|
|
43
45
|
buildOutputPreview,
|
|
@@ -61,7 +63,7 @@ import {
|
|
|
61
63
|
shrunkImageSize,
|
|
62
64
|
splitManagerInstructions,
|
|
63
65
|
withTimeout
|
|
64
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-NFRBKHVR.js";
|
|
65
67
|
|
|
66
68
|
// src/managers/codex-token-manager.ts
|
|
67
69
|
import { promises as fs } from "fs";
|
|
@@ -461,7 +463,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
461
463
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
462
464
|
await this.applyCredentialsResponse(data);
|
|
463
465
|
setAgentCredentialSnapshot("codex", data);
|
|
464
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
466
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ZQHJIZ66.js");
|
|
465
467
|
await restartCodexAspHostIfRunning2();
|
|
466
468
|
});
|
|
467
469
|
await this.start(true);
|
|
@@ -483,7 +485,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
483
485
|
const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
|
|
484
486
|
await this.applyCredentialsResponse(data);
|
|
485
487
|
if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
|
|
486
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
488
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ZQHJIZ66.js");
|
|
487
489
|
await restartCodexAspHostIfRunning2();
|
|
488
490
|
}
|
|
489
491
|
setAgentCredentialSnapshot("codex", data);
|
|
@@ -596,7 +598,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
596
598
|
var codexTokenManager = new CodexTokenManager();
|
|
597
599
|
|
|
598
600
|
// src/managers/codex-asp/mappers.ts
|
|
599
|
-
import { existsSync as
|
|
601
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
600
602
|
|
|
601
603
|
// src/git/service.ts
|
|
602
604
|
import { readdir, readFile as readFile3, realpath, stat } from "fs/promises";
|
|
@@ -1589,41 +1591,6 @@ var CodexQuotaStatusTracker = class {
|
|
|
1589
1591
|
}
|
|
1590
1592
|
};
|
|
1591
1593
|
|
|
1592
|
-
// src/managers/subagent-mcp-config.ts
|
|
1593
|
-
import { existsSync as existsSync2 } from "fs";
|
|
1594
|
-
import { dirname as dirname2, join as join6 } from "path";
|
|
1595
|
-
import { fileURLToPath } from "url";
|
|
1596
|
-
import { createRequire as createRequire2 } from "module";
|
|
1597
|
-
var SUBAGENT_MCP_TOOL_TIMEOUT_MS = 24 * 60 * 60 * 1e3 + 6e4;
|
|
1598
|
-
function engineScriptProcess(script, args) {
|
|
1599
|
-
const directory = dirname2(fileURLToPath(import.meta.url));
|
|
1600
|
-
const builtEntry = join6(directory, `${script}.js`);
|
|
1601
|
-
const sourceEntry = join6(directory, "..", `${script}.ts`);
|
|
1602
|
-
const entry = existsSync2(builtEntry) ? builtEntry : sourceEntry;
|
|
1603
|
-
return {
|
|
1604
|
-
command: process.execPath,
|
|
1605
|
-
args: [
|
|
1606
|
-
...entry.endsWith(".ts") ? ["--import", createRequire2(import.meta.url).resolve("tsx/esm")] : [],
|
|
1607
|
-
entry,
|
|
1608
|
-
...args
|
|
1609
|
-
]
|
|
1610
|
-
};
|
|
1611
|
-
}
|
|
1612
|
-
function subagentMcpProcessConfig(parentChatId) {
|
|
1613
|
-
return engineScriptProcess("subagent-mcp", ["--parent", parentChatId]);
|
|
1614
|
-
}
|
|
1615
|
-
function subagentCodexMcpConfig(parentChatId) {
|
|
1616
|
-
return {
|
|
1617
|
-
...subagentMcpProcessConfig(parentChatId),
|
|
1618
|
-
env_vars: ["REPLICAS_ENGINE_PORT", "REPLICAS_ENGINE_SECRET"],
|
|
1619
|
-
enabled_tools: [...SUBAGENT_MCP_TOOL_NAMES],
|
|
1620
|
-
required: true,
|
|
1621
|
-
default_tools_approval_mode: "approve",
|
|
1622
|
-
startup_timeout_sec: 10,
|
|
1623
|
-
tool_timeout_sec: Math.ceil(SUBAGENT_MCP_TOOL_TIMEOUT_MS / 1e3)
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
1594
|
// src/managers/codex-asp/mappers.ts
|
|
1628
1595
|
var localImageCache = /* @__PURE__ */ new Map();
|
|
1629
1596
|
var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
|
|
@@ -1752,7 +1719,7 @@ function transcriptItemsForTurn(turn) {
|
|
|
1752
1719
|
function userImageForLocalPath(path2) {
|
|
1753
1720
|
const cached = localImageCache.get(path2);
|
|
1754
1721
|
if (cached) return cached;
|
|
1755
|
-
if (!
|
|
1722
|
+
if (!existsSync2(path2)) return null;
|
|
1756
1723
|
const image = {
|
|
1757
1724
|
type: "image",
|
|
1758
1725
|
mediaType: inferMediaType(path2),
|
|
@@ -2099,9 +2066,9 @@ async function buildTurnStartParams(threadId, request, serviceTier, unreadReques
|
|
|
2099
2066
|
// src/managers/codex-asp/openai-compatible-model-catalog.ts
|
|
2100
2067
|
import { writeFile as writeFile3 } from "fs/promises";
|
|
2101
2068
|
import { tmpdir } from "os";
|
|
2102
|
-
import { join as
|
|
2069
|
+
import { join as join6 } from "path";
|
|
2103
2070
|
var CATALOG_TTL_MS = 6e4;
|
|
2104
|
-
var CODEX_MODEL_CATALOG_PATH =
|
|
2071
|
+
var CODEX_MODEL_CATALOG_PATH = join6(tmpdir(), "replicas-openai-compatible-model-catalog.json");
|
|
2105
2072
|
var cachedCatalog = null;
|
|
2106
2073
|
async function writeCodexModelCatalog(modelsUrl) {
|
|
2107
2074
|
const ollama = ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "ollama" ? readOllamaAuthEnv("codex", process.env) : null;
|
|
@@ -2314,9 +2281,6 @@ export {
|
|
|
2314
2281
|
normalizeImages,
|
|
2315
2282
|
removeTempImageFiles,
|
|
2316
2283
|
CodexQuotaStatusTracker,
|
|
2317
|
-
SUBAGENT_MCP_TOOL_TIMEOUT_MS,
|
|
2318
|
-
engineScriptProcess,
|
|
2319
|
-
subagentMcpProcessConfig,
|
|
2320
2284
|
DEFAULT_MODEL,
|
|
2321
2285
|
THREAD_START_METHOD,
|
|
2322
2286
|
THREAD_RESUME_METHOD,
|
|
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
execFileAsync
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OWOVJSPF.js";
|
|
7
7
|
import {
|
|
8
8
|
isVersionBelow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NFRBKHVR.js";
|
|
10
10
|
|
|
11
11
|
// src/utils/codex-agent-env.ts
|
|
12
12
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -242,7 +242,7 @@ function getCodexModelProvider(method) {
|
|
|
242
242
|
if (method === "foundry") return "azure";
|
|
243
243
|
return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
|
|
244
244
|
}
|
|
245
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
245
|
+
var ENGINE_PACKAGE_VERSION = "0.1.1688";
|
|
246
246
|
var INITIALIZE_METHOD = "initialize";
|
|
247
247
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
248
248
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|