replicas-engine 0.1.453 → 0.1.455
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/index.js +158 -100
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -163,6 +163,21 @@ function detectLanguageByPath(filePath) {
|
|
|
163
163
|
return EXT_TO_LANGUAGE[ext] ?? null;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// ../shared/src/credentials/opencode-go.ts
|
|
167
|
+
import { z } from "zod";
|
|
168
|
+
var OPENCODE_GO_PROVIDER = "opencode-go";
|
|
169
|
+
var opencodeGoModelsDevSchema = z.object({
|
|
170
|
+
"opencode-go": z.object({
|
|
171
|
+
models: z.record(z.string(), z.object({
|
|
172
|
+
id: z.string().optional(),
|
|
173
|
+
name: z.string(),
|
|
174
|
+
description: z.string().optional(),
|
|
175
|
+
status: z.enum(["alpha", "beta", "deprecated"]).optional()
|
|
176
|
+
}))
|
|
177
|
+
}).optional()
|
|
178
|
+
});
|
|
179
|
+
var OPENCODE_GO_CATALOG_CACHE_MS = 5 * 6e4;
|
|
180
|
+
|
|
166
181
|
// ../shared/src/engine/types.ts
|
|
167
182
|
var DEFAULT_CHAT_TITLES = {
|
|
168
183
|
claude: "Claude Code",
|
|
@@ -528,7 +543,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
528
543
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
529
544
|
|
|
530
545
|
// ../shared/src/e2b.ts
|
|
531
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-19-
|
|
546
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-19-v7";
|
|
532
547
|
|
|
533
548
|
// ../shared/src/runtime-env.ts
|
|
534
549
|
function shellQuotePosix(value) {
|
|
@@ -5873,7 +5888,7 @@ async function registerDesktopPreview() {
|
|
|
5873
5888
|
}
|
|
5874
5889
|
|
|
5875
5890
|
// src/services/chat/chat-service.ts
|
|
5876
|
-
import { existsSync as
|
|
5891
|
+
import { existsSync as existsSync8 } from "fs";
|
|
5877
5892
|
import { appendFile as appendFile3, copyFile, mkdir as mkdir14, readFile as readFile14, rename as rename2, rm as rm2 } from "fs/promises";
|
|
5878
5893
|
import { homedir as homedir15 } from "os";
|
|
5879
5894
|
import { join as join22 } from "path";
|
|
@@ -8589,7 +8604,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
|
8589
8604
|
var MIN_CODEX_CLI_VERSION = "0.144.0";
|
|
8590
8605
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
8591
8606
|
var codexCliVersionEnsured = null;
|
|
8592
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
8607
|
+
var ENGINE_PACKAGE_VERSION = "0.1.455";
|
|
8593
8608
|
var INITIALIZE_METHOD = "initialize";
|
|
8594
8609
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
8595
8610
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -11083,17 +11098,20 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
11083
11098
|
};
|
|
11084
11099
|
|
|
11085
11100
|
// src/managers/opencode-manager.ts
|
|
11101
|
+
import { existsSync as existsSync7 } from "fs";
|
|
11086
11102
|
import { mkdir as mkdir12, readFile as readFile11 } from "fs/promises";
|
|
11087
11103
|
import { delimiter, dirname as dirname6, join as join18 } from "path";
|
|
11088
11104
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
11089
11105
|
import { fileURLToPath } from "url";
|
|
11090
11106
|
import { Agent } from "undici";
|
|
11107
|
+
import { z as z2 } from "zod";
|
|
11091
11108
|
import {
|
|
11092
11109
|
createOpencodeClient,
|
|
11093
11110
|
createOpencodeServer
|
|
11094
11111
|
} from "@opencode-ai/sdk/v2";
|
|
11095
11112
|
var OPENCODE_SHIM_DIR = dirname6(fileURLToPath(new URL("../../scripts/opencode", import.meta.url)));
|
|
11096
11113
|
var OPENCODE_CONFIG_PATH = join18(ENGINE_ENV.HOME_DIR, ".config", "opencode", "opencode.json");
|
|
11114
|
+
var OPENCODE_AUTH_PATH2 = join18(ENGINE_ENV.HOME_DIR, ".local", "share", "opencode", "auth.json");
|
|
11097
11115
|
var OPENCODE_FETCH_DISPATCHER = new Agent({ headersTimeout: 0, bodyTimeout: 0 });
|
|
11098
11116
|
var OPENCODE_SERVER_STARTUP_TIMEOUT_MS = 3e4;
|
|
11099
11117
|
var OPENCODE_WORKSPACE_PERMISSION = {
|
|
@@ -11121,30 +11139,56 @@ var OPENCODE_VARIANT_CANDIDATES_BY_THINKING_LEVEL = {
|
|
|
11121
11139
|
xhigh: ["xhigh", "high"],
|
|
11122
11140
|
max: ["max", "xhigh", "high"]
|
|
11123
11141
|
};
|
|
11142
|
+
var opencodeAuthSchema = z2.record(z2.string(), z2.object({
|
|
11143
|
+
type: z2.string().optional(),
|
|
11144
|
+
key: z2.string().optional()
|
|
11145
|
+
}));
|
|
11146
|
+
async function hasOpenCodeGoCredentials() {
|
|
11147
|
+
if (!existsSync7(OPENCODE_AUTH_PATH2)) return false;
|
|
11148
|
+
try {
|
|
11149
|
+
const auth = opencodeAuthSchema.safeParse(JSON.parse(await readFile11(OPENCODE_AUTH_PATH2, "utf8")));
|
|
11150
|
+
return auth.success && auth.data[OPENCODE_GO_PROVIDER]?.type === "api" && Boolean(auth.data[OPENCODE_GO_PROVIDER]?.key);
|
|
11151
|
+
} catch {
|
|
11152
|
+
return false;
|
|
11153
|
+
}
|
|
11154
|
+
}
|
|
11155
|
+
function getOpenCodeGoModel(model) {
|
|
11156
|
+
return model.replace(/^[^/]+\//, "");
|
|
11157
|
+
}
|
|
11124
11158
|
async function opencodeConfig(model) {
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11159
|
+
let config;
|
|
11160
|
+
if (await hasOpenCodeGoCredentials()) {
|
|
11161
|
+
config = {
|
|
11162
|
+
enabled_providers: [OPENCODE_GO_PROVIDER],
|
|
11163
|
+
model: `${OPENCODE_GO_PROVIDER}/${model}`,
|
|
11164
|
+
permission: OPENCODE_WORKSPACE_PERMISSION,
|
|
11165
|
+
share: "disabled"
|
|
11166
|
+
};
|
|
11167
|
+
} else {
|
|
11168
|
+
const models = getConfiguredOpencodeModels(model);
|
|
11169
|
+
config = {
|
|
11170
|
+
enabled_providers: ["openrouter"],
|
|
11171
|
+
model: `openrouter/${model}`,
|
|
11172
|
+
provider: {
|
|
11173
|
+
openrouter: {
|
|
11174
|
+
models: Object.fromEntries(models.map((candidate) => [candidate, {}])),
|
|
11175
|
+
options: {
|
|
11176
|
+
apiKey: "{env:OPENROUTER_API_KEY}"
|
|
11177
|
+
}
|
|
11135
11178
|
}
|
|
11136
|
-
}
|
|
11137
|
-
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
}
|
|
11179
|
+
},
|
|
11180
|
+
permission: OPENCODE_WORKSPACE_PERMISSION,
|
|
11181
|
+
share: "disabled"
|
|
11182
|
+
};
|
|
11183
|
+
}
|
|
11184
|
+
const mcp = await readProvisionedOpencodeMcpConfig();
|
|
11141
11185
|
if (mcp && Object.keys(mcp).length > 0) {
|
|
11142
11186
|
config.mcp = mcp;
|
|
11143
11187
|
}
|
|
11144
11188
|
return config;
|
|
11145
11189
|
}
|
|
11146
11190
|
function getConfiguredOpencodeModels(model) {
|
|
11147
|
-
return [.../* @__PURE__ */ new Set([model, ...
|
|
11191
|
+
return [.../* @__PURE__ */ new Set([model, ...OPENROUTER_MODELS])];
|
|
11148
11192
|
}
|
|
11149
11193
|
function opencodeCommandToSlashCommand(command) {
|
|
11150
11194
|
return createProviderSlashCommand("opencode", command.name, command.description);
|
|
@@ -11274,6 +11318,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11274
11318
|
historyFile;
|
|
11275
11319
|
activeAbortController = null;
|
|
11276
11320
|
configuredModels = /* @__PURE__ */ new Set();
|
|
11321
|
+
providerId = "openrouter";
|
|
11277
11322
|
eventAbortController = null;
|
|
11278
11323
|
eventSubscriptionReady = Promise.resolve();
|
|
11279
11324
|
resolveEventSubscriptionReady = null;
|
|
@@ -11361,9 +11406,21 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11361
11406
|
return this.slashCommandsRequest;
|
|
11362
11407
|
}
|
|
11363
11408
|
async ensureClient(model) {
|
|
11364
|
-
|
|
11365
|
-
if (
|
|
11366
|
-
|
|
11409
|
+
const providerId = await hasOpenCodeGoCredentials() ? OPENCODE_GO_PROVIDER : "openrouter";
|
|
11410
|
+
if (this.client && this.providerId !== providerId) {
|
|
11411
|
+
this.eventAbortController?.abort();
|
|
11412
|
+
this.server?.close();
|
|
11413
|
+
this.client = null;
|
|
11414
|
+
this.server = null;
|
|
11415
|
+
this.configuredModels.clear();
|
|
11416
|
+
}
|
|
11417
|
+
this.providerId = providerId;
|
|
11418
|
+
const configuredModel = providerId === OPENCODE_GO_PROVIDER ? getOpenCodeGoModel(model) : model;
|
|
11419
|
+
if (this.client && (providerId === OPENCODE_GO_PROVIDER || this.configuredModels.has(configuredModel))) {
|
|
11420
|
+
return this.client;
|
|
11421
|
+
}
|
|
11422
|
+
if (!ENGINE_ENV.OPENROUTER_API_KEY && this.providerId !== OPENCODE_GO_PROVIDER) {
|
|
11423
|
+
throw new Error("OpenCode Go or OpenRouter credentials are not configured for Opencode in this workspace.");
|
|
11367
11424
|
}
|
|
11368
11425
|
this.eventAbortController?.abort();
|
|
11369
11426
|
this.server?.close();
|
|
@@ -11376,7 +11433,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11376
11433
|
const server = await createOpencodeServer({
|
|
11377
11434
|
port: 0,
|
|
11378
11435
|
timeout: OPENCODE_SERVER_STARTUP_TIMEOUT_MS,
|
|
11379
|
-
config: await opencodeConfig(
|
|
11436
|
+
config: await opencodeConfig(configuredModel)
|
|
11380
11437
|
});
|
|
11381
11438
|
const client = createOpencodeClient({
|
|
11382
11439
|
baseUrl: server.url,
|
|
@@ -11387,7 +11444,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11387
11444
|
});
|
|
11388
11445
|
this.client = client;
|
|
11389
11446
|
this.server = server;
|
|
11390
|
-
this.configuredModels = new Set(getConfiguredOpencodeModels(model));
|
|
11447
|
+
this.configuredModels = this.providerId === OPENCODE_GO_PROVIDER ? /* @__PURE__ */ new Set() : new Set(getConfiguredOpencodeModels(model));
|
|
11391
11448
|
const eventController = new AbortController();
|
|
11392
11449
|
this.eventAbortController = eventController;
|
|
11393
11450
|
this.eventSubscriptionReady = new Promise((resolve4) => {
|
|
@@ -11420,7 +11477,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11420
11477
|
const result = await client.session.create({
|
|
11421
11478
|
directory: this.workingDirectory,
|
|
11422
11479
|
agent,
|
|
11423
|
-
model: { providerID:
|
|
11480
|
+
model: { providerID: this.providerId, id: model, ...variant ? { variant } : {} }
|
|
11424
11481
|
}, { throwOnError: true });
|
|
11425
11482
|
const session = result.data;
|
|
11426
11483
|
this.sessionId = session.id;
|
|
@@ -11436,7 +11493,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11436
11493
|
{ throwOnError: true }
|
|
11437
11494
|
);
|
|
11438
11495
|
for (const candidate of result.data.data) {
|
|
11439
|
-
if (candidate.providerID ===
|
|
11496
|
+
if (candidate.providerID === this.providerId) {
|
|
11440
11497
|
this.modelVariants.set(candidate.id, new Set(candidate.variants.map((variant) => variant.id)));
|
|
11441
11498
|
}
|
|
11442
11499
|
}
|
|
@@ -11460,9 +11517,10 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11460
11517
|
this.forwardedLinearPartKeys.clear();
|
|
11461
11518
|
try {
|
|
11462
11519
|
const client = await this.ensureClient(model);
|
|
11520
|
+
const providerModel = this.providerId === OPENCODE_GO_PROVIDER ? getOpenCodeGoModel(model) : model;
|
|
11463
11521
|
const agent = request.planMode ? "plan" : "build";
|
|
11464
|
-
const variant = await this.getThinkingVariant(client,
|
|
11465
|
-
const sessionId = await this.ensureSession(client,
|
|
11522
|
+
const variant = await this.getThinkingVariant(client, providerModel, request.thinkingLevel);
|
|
11523
|
+
const sessionId = await this.ensureSession(client, providerModel, agent, variant);
|
|
11466
11524
|
const system = this.buildCombinedInstructions(request.customInstructions);
|
|
11467
11525
|
this.recordHistoryEvent("event_msg", {
|
|
11468
11526
|
type: "user_message",
|
|
@@ -11472,7 +11530,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
11472
11530
|
sessionID: sessionId,
|
|
11473
11531
|
directory: this.workingDirectory,
|
|
11474
11532
|
agent,
|
|
11475
|
-
model: { providerID:
|
|
11533
|
+
model: { providerID: this.providerId, modelID: providerModel },
|
|
11476
11534
|
...variant ? { variant } : {},
|
|
11477
11535
|
...system ? { system } : {},
|
|
11478
11536
|
parts: [{ type: "text", text: request.message }]
|
|
@@ -11924,7 +11982,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
11924
11982
|
|
|
11925
11983
|
// src/managers/relay-tools.ts
|
|
11926
11984
|
import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk";
|
|
11927
|
-
import { z } from "zod";
|
|
11985
|
+
import { z as z3 } from "zod";
|
|
11928
11986
|
|
|
11929
11987
|
// src/managers/relay-providers.ts
|
|
11930
11988
|
function getAvailableRelayProviders(availability) {
|
|
@@ -12036,7 +12094,7 @@ function buildSpawnAgentTool(parentChatId, availability = {}) {
|
|
|
12036
12094
|
const cursorAvailable = availability.cursorAvailable ?? false;
|
|
12037
12095
|
const opencodeAvailable = availability.opencodeAvailable ?? false;
|
|
12038
12096
|
const availableProviders = getAvailableRelayProviders(availability);
|
|
12039
|
-
const providerEnum =
|
|
12097
|
+
const providerEnum = z3.enum(availableProviders);
|
|
12040
12098
|
const codeProviders = getAvailableCodeProviders(availability);
|
|
12041
12099
|
const providerDesc = codeProviders.length > 0 ? `Which agent to use. Prefer ${codeProviders.join(" or ")} for code writing, claude for exploration/analysis, relay for complex multi-step orchestration.` : "Which agent to use. Use claude for code writing, exploration, and analysis. Use relay for complex multi-step orchestration.";
|
|
12042
12100
|
const useCases = codeProviders.length > 0 ? `- Complex code writing tasks (use provider '${codeProviders.join("' or '")}' with a capable model)
|
|
@@ -12055,18 +12113,18 @@ The tool blocks until the subagent completes and returns its final response.
|
|
|
12055
12113
|
You will also receive the chatId so you can send follow-up messages or clean up the chat.`,
|
|
12056
12114
|
{
|
|
12057
12115
|
provider: providerEnum.describe(providerDesc),
|
|
12058
|
-
prompt:
|
|
12059
|
-
model:
|
|
12116
|
+
prompt: z3.string().describe("The full prompt/instructions for the subagent. Be detailed - it has no context from your conversation."),
|
|
12117
|
+
model: z3.string().optional().describe([
|
|
12060
12118
|
`Model override. Claude: ${AGENT_MODELS.claude.join(", ")} (opus is the default; sonnet is faster).`,
|
|
12061
12119
|
codexAvailable ? `Codex: ${AGENT_MODELS.codex.join(", ")}.` : null,
|
|
12062
12120
|
cursorAvailable ? `Cursor: ${AGENT_MODELS.cursor.join(", ")}.` : null,
|
|
12063
12121
|
opencodeAvailable ? `Opencode: ${AGENT_MODELS.opencode.join(", ")}.` : null
|
|
12064
12122
|
].filter(Boolean).join(" ")),
|
|
12065
|
-
thinking_level:
|
|
12123
|
+
thinking_level: z3.enum(VALID_THINKING_LEVELS).optional().describe(
|
|
12066
12124
|
"Controls how much thinking/reasoning the subagent applies. low = light thinking, medium = moderate, high = deep reasoning, xhigh = extended effort, max = maximum effort. Defaults: Claude = high, Codex = medium, Cursor = medium, Opencode = medium."
|
|
12067
12125
|
),
|
|
12068
|
-
title:
|
|
12069
|
-
timeout_minutes:
|
|
12126
|
+
title: z3.string().optional().describe("Optional title for the subagent chat (for identification)."),
|
|
12127
|
+
timeout_minutes: z3.number().positive().optional().describe("Timeout in minutes for the subagent to complete (default: 10). Set higher for large tasks to avoid losing work.")
|
|
12070
12128
|
},
|
|
12071
12129
|
async (args) => {
|
|
12072
12130
|
try {
|
|
@@ -12127,13 +12185,13 @@ var messageAgentTool = tool(
|
|
|
12127
12185
|
|
|
12128
12186
|
The tool blocks until the subagent completes and returns its response.`,
|
|
12129
12187
|
{
|
|
12130
|
-
chatId:
|
|
12131
|
-
message:
|
|
12132
|
-
model:
|
|
12133
|
-
thinking_level:
|
|
12188
|
+
chatId: z3.string().describe("The chat ID of the subagent (returned by spawn_agent)."),
|
|
12189
|
+
message: z3.string().describe("The follow-up message to send."),
|
|
12190
|
+
model: z3.string().optional().describe("Optional model override for this message."),
|
|
12191
|
+
thinking_level: z3.enum(VALID_THINKING_LEVELS).optional().describe(
|
|
12134
12192
|
"Controls how much thinking/reasoning the subagent applies. low = light thinking, medium = moderate, high = deep reasoning, xhigh = extended effort, max = maximum effort. Defaults: Claude = high, Codex = medium, Cursor = medium, Opencode = medium."
|
|
12135
12193
|
),
|
|
12136
|
-
timeout_minutes:
|
|
12194
|
+
timeout_minutes: z3.number().positive().optional().describe("Timeout in minutes for the subagent to complete (default: 10). Set higher for large tasks to avoid losing work.")
|
|
12137
12195
|
},
|
|
12138
12196
|
async (args) => {
|
|
12139
12197
|
try {
|
|
@@ -12171,7 +12229,7 @@ var deleteAgentTool = tool(
|
|
|
12171
12229
|
"delete_agent",
|
|
12172
12230
|
`Delete a subagent chat to free resources. Use this after a subagent has completed its work and you no longer need to send it follow-up messages.`,
|
|
12173
12231
|
{
|
|
12174
|
-
chatId:
|
|
12232
|
+
chatId: z3.string().describe("The chat ID of the subagent to delete.")
|
|
12175
12233
|
},
|
|
12176
12234
|
async (args) => {
|
|
12177
12235
|
try {
|
|
@@ -12849,17 +12907,17 @@ async function flushRepoState() {
|
|
|
12849
12907
|
// src/services/chat/chat-service.ts
|
|
12850
12908
|
var CHAT_SENDERS_DIR = join22(ENGINE_DIR2, "chat-senders");
|
|
12851
12909
|
var CODEX_AUTH_PATH2 = join22(homedir15(), ".codex", "auth.json");
|
|
12852
|
-
var
|
|
12910
|
+
var OPENCODE_AUTH_PATH3 = join22(homedir15(), ".local", "share", "opencode", "auth.json");
|
|
12853
12911
|
var CHATS_BACKUP_FILE = `${CHATS_FILE}.bak`;
|
|
12854
12912
|
function isChatMessageSender(value) {
|
|
12855
12913
|
if (!isRecord4(value)) return false;
|
|
12856
12914
|
return typeof value.senderUserId === "string" && typeof value.senderEmail === "string" && typeof value.recordedAt === "string";
|
|
12857
12915
|
}
|
|
12858
12916
|
function isCodexAvailable() {
|
|
12859
|
-
return
|
|
12917
|
+
return existsSync8(CODEX_AUTH_PATH2) || Boolean(ENGINE_ENV.OPENAI_API_KEY);
|
|
12860
12918
|
}
|
|
12861
12919
|
function isOpencodeAvailable() {
|
|
12862
|
-
return
|
|
12920
|
+
return existsSync8(OPENCODE_AUTH_PATH3) || Boolean(ENGINE_ENV.OPENROUTER_API_KEY);
|
|
12863
12921
|
}
|
|
12864
12922
|
function isPiAvailable() {
|
|
12865
12923
|
return Boolean(ENGINE_ENV.OPENROUTER_API_KEY);
|
|
@@ -13945,14 +14003,14 @@ var RepoFileService = class {
|
|
|
13945
14003
|
|
|
13946
14004
|
// src/v1-routes.ts
|
|
13947
14005
|
import { Hono } from "hono";
|
|
13948
|
-
import { z as
|
|
14006
|
+
import { z as z4 } from "zod";
|
|
13949
14007
|
import { readdir as readdir9, stat as stat5, readFile as readFile18 } from "fs/promises";
|
|
13950
14008
|
import { join as join26, resolve as resolve3 } from "path";
|
|
13951
14009
|
|
|
13952
14010
|
// src/services/warm-hooks-service.ts
|
|
13953
14011
|
import { spawn as spawn4 } from "child_process";
|
|
13954
14012
|
import { readFile as readFile17 } from "fs/promises";
|
|
13955
|
-
import { existsSync as
|
|
14013
|
+
import { existsSync as existsSync9 } from "fs";
|
|
13956
14014
|
import { join as join25 } from "path";
|
|
13957
14015
|
|
|
13958
14016
|
// src/services/warm-hook-logs-service.ts
|
|
@@ -14074,7 +14132,7 @@ var warmHookLogsService = new WarmHookLogsService();
|
|
|
14074
14132
|
async function readRepoWarmHook(repoPath) {
|
|
14075
14133
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
14076
14134
|
const configPath = join25(repoPath, filename);
|
|
14077
|
-
if (!
|
|
14135
|
+
if (!existsSync9(configPath)) {
|
|
14078
14136
|
continue;
|
|
14079
14137
|
}
|
|
14080
14138
|
try {
|
|
@@ -14335,7 +14393,7 @@ ${combinedScript}` : combinedScript;
|
|
|
14335
14393
|
|
|
14336
14394
|
// src/services/terminal-service.ts
|
|
14337
14395
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
14338
|
-
import { existsSync as
|
|
14396
|
+
import { existsSync as existsSync10 } from "fs";
|
|
14339
14397
|
import { spawn as spawn5 } from "node-pty";
|
|
14340
14398
|
var MAX_REPLAY_CHARS = 1024 * 1024;
|
|
14341
14399
|
var MAX_TERMINAL_SESSIONS = 8;
|
|
@@ -14354,7 +14412,7 @@ var TerminalService = class {
|
|
|
14354
14412
|
});
|
|
14355
14413
|
}
|
|
14356
14414
|
const id = randomUUID6();
|
|
14357
|
-
const shell = process.env.SHELL &&
|
|
14415
|
+
const shell = process.env.SHELL && existsSync10(process.env.SHELL) ? process.env.SHELL : "/bin/bash";
|
|
14358
14416
|
const pty = spawn5(shell, ["-l"], {
|
|
14359
14417
|
name: "xterm-256color",
|
|
14360
14418
|
cols,
|
|
@@ -14453,67 +14511,67 @@ var TerminalService = class {
|
|
|
14453
14511
|
var terminalService = new TerminalService();
|
|
14454
14512
|
|
|
14455
14513
|
// src/v1-routes.ts
|
|
14456
|
-
var setWorkspaceNameSchema =
|
|
14457
|
-
name:
|
|
14514
|
+
var setWorkspaceNameSchema = z4.object({
|
|
14515
|
+
name: z4.string().min(1).max(48)
|
|
14458
14516
|
});
|
|
14459
|
-
var createChatSchema =
|
|
14460
|
-
provider:
|
|
14461
|
-
title:
|
|
14462
|
-
parentChatId:
|
|
14463
|
-
clientRequestId:
|
|
14517
|
+
var createChatSchema = z4.object({
|
|
14518
|
+
provider: z4.enum(["claude", "codex", "cursor", "opencode", "pi", "relay"]),
|
|
14519
|
+
title: z4.string().min(1).optional(),
|
|
14520
|
+
parentChatId: z4.string().uuid().optional(),
|
|
14521
|
+
clientRequestId: z4.string().min(1).max(128).optional()
|
|
14464
14522
|
});
|
|
14465
|
-
var imageMediaTypeSchema =
|
|
14466
|
-
var createPreviewSchema =
|
|
14467
|
-
port:
|
|
14468
|
-
publicUrl:
|
|
14523
|
+
var imageMediaTypeSchema = z4.enum(IMAGE_MEDIA_TYPES);
|
|
14524
|
+
var createPreviewSchema = z4.object({
|
|
14525
|
+
port: z4.number().int().min(1).max(65535),
|
|
14526
|
+
publicUrl: z4.string().min(1)
|
|
14469
14527
|
});
|
|
14470
|
-
var terminalSizeSchema =
|
|
14471
|
-
cols:
|
|
14472
|
-
rows:
|
|
14528
|
+
var terminalSizeSchema = z4.object({
|
|
14529
|
+
cols: z4.number().int().min(2).max(500),
|
|
14530
|
+
rows: z4.number().int().min(1).max(200)
|
|
14473
14531
|
});
|
|
14474
|
-
var writeTerminalSessionSchema =
|
|
14475
|
-
data:
|
|
14476
|
-
generation:
|
|
14477
|
-
sequence:
|
|
14532
|
+
var writeTerminalSessionSchema = z4.object({
|
|
14533
|
+
data: z4.string().max(64 * 1024),
|
|
14534
|
+
generation: z4.number().int().nonnegative(),
|
|
14535
|
+
sequence: z4.number().int().nonnegative()
|
|
14478
14536
|
});
|
|
14479
|
-
var sendMessageSchema =
|
|
14480
|
-
message:
|
|
14481
|
-
model:
|
|
14482
|
-
customInstructions:
|
|
14483
|
-
planMode:
|
|
14484
|
-
images:
|
|
14485
|
-
type:
|
|
14486
|
-
source:
|
|
14487
|
-
|
|
14488
|
-
type:
|
|
14537
|
+
var sendMessageSchema = z4.object({
|
|
14538
|
+
message: z4.string().min(1),
|
|
14539
|
+
model: z4.string().optional(),
|
|
14540
|
+
customInstructions: z4.string().optional(),
|
|
14541
|
+
planMode: z4.boolean().optional(),
|
|
14542
|
+
images: z4.array(z4.object({
|
|
14543
|
+
type: z4.literal("image"),
|
|
14544
|
+
source: z4.union([
|
|
14545
|
+
z4.object({
|
|
14546
|
+
type: z4.literal("base64"),
|
|
14489
14547
|
media_type: imageMediaTypeSchema,
|
|
14490
|
-
data:
|
|
14548
|
+
data: z4.string().min(1)
|
|
14491
14549
|
}),
|
|
14492
|
-
|
|
14493
|
-
type:
|
|
14494
|
-
url:
|
|
14550
|
+
z4.object({
|
|
14551
|
+
type: z4.literal("url"),
|
|
14552
|
+
url: z4.string().url()
|
|
14495
14553
|
})
|
|
14496
14554
|
])
|
|
14497
14555
|
})).optional(),
|
|
14498
|
-
thinkingLevel:
|
|
14499
|
-
goalMode:
|
|
14500
|
-
fastMode:
|
|
14501
|
-
enableInteractiveTools:
|
|
14502
|
-
type:
|
|
14503
|
-
merge:
|
|
14504
|
-
idempotencyKey:
|
|
14505
|
-
senderUserId:
|
|
14506
|
-
senderEmail:
|
|
14507
|
-
senderDisplayName:
|
|
14508
|
-
senderAvatarUrl:
|
|
14556
|
+
thinkingLevel: z4.enum(VALID_THINKING_LEVELS).optional(),
|
|
14557
|
+
goalMode: z4.boolean().optional(),
|
|
14558
|
+
fastMode: z4.boolean().optional(),
|
|
14559
|
+
enableInteractiveTools: z4.boolean().optional(),
|
|
14560
|
+
type: z4.string().min(1).optional(),
|
|
14561
|
+
merge: z4.boolean().optional(),
|
|
14562
|
+
idempotencyKey: z4.string().min(1).max(128).optional(),
|
|
14563
|
+
senderUserId: z4.string().optional(),
|
|
14564
|
+
senderEmail: z4.string().optional(),
|
|
14565
|
+
senderDisplayName: z4.string().optional(),
|
|
14566
|
+
senderAvatarUrl: z4.string().optional()
|
|
14509
14567
|
});
|
|
14510
|
-
var respondToolInputSchema =
|
|
14511
|
-
requestId:
|
|
14512
|
-
selectionId:
|
|
14568
|
+
var respondToolInputSchema = z4.object({
|
|
14569
|
+
requestId: z4.string().min(1),
|
|
14570
|
+
selectionId: z4.string().min(1)
|
|
14513
14571
|
});
|
|
14514
|
-
var updateGoalSchema =
|
|
14515
|
-
objective:
|
|
14516
|
-
status:
|
|
14572
|
+
var updateGoalSchema = z4.object({
|
|
14573
|
+
objective: z4.string().trim().min(1).max(MAX_CODEX_GOAL_OBJECTIVE_CHARS).optional(),
|
|
14574
|
+
status: z4.enum(["active", "paused"]).optional()
|
|
14517
14575
|
}).refine((body) => body.objective !== void 0 || body.status !== void 0, {
|
|
14518
14576
|
message: "Goal objective or status required"
|
|
14519
14577
|
});
|
|
@@ -14704,7 +14762,7 @@ function createV1Routes(deps) {
|
|
|
14704
14762
|
const result = await deps.chatService.updateGoal(c.req.param("chatId"), body);
|
|
14705
14763
|
return c.json(result);
|
|
14706
14764
|
} catch (error) {
|
|
14707
|
-
if (error instanceof
|
|
14765
|
+
if (error instanceof z4.ZodError) {
|
|
14708
14766
|
return c.json(jsonError(error.issues[0]?.message || "Invalid goal update"), 400);
|
|
14709
14767
|
}
|
|
14710
14768
|
if (error instanceof ChatNotFoundError) {
|