replicas-engine 0.1.1024 → 0.1.1025
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-RAWMASFX.js → asp-host-HCKPHEGE.js} +5 -5
- package/dist/src/{chunk-5HPD4VG2.js → chunk-4O34RLV4.js} +6 -6
- package/dist/src/{chunk-E5K35DUL.js → chunk-6QJUSUYT.js} +1 -1
- package/dist/src/{chunk-KXADRVAB.js → chunk-A6ZTEZQC.js} +3 -3
- package/dist/src/{chunk-C2C4ZTHR.js → chunk-ABTNJPOU.js} +3 -3
- package/dist/src/{chunk-B4XY2JDA.js → chunk-C5YKZO4K.js} +1 -1
- package/dist/src/{chunk-HHYJ2FOD.js → chunk-MH345B4U.js} +572 -541
- package/dist/src/{chunk-HW2ZEEFV.js → chunk-TGJ5XL4O.js} +1 -1
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +3 -3
- package/dist/src/index.js +7 -7
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -58,11 +58,11 @@ var CODEX_REASONING_EFFORT_BY_THINKING_LEVEL = {
|
|
|
58
58
|
ultra: "ultra",
|
|
59
59
|
ultracode: "xhigh"
|
|
60
60
|
};
|
|
61
|
-
function codexReasoningEffortForThinkingLevel(
|
|
62
|
-
return
|
|
61
|
+
function codexReasoningEffortForThinkingLevel(thinkingLevel2) {
|
|
62
|
+
return thinkingLevel2 ? CODEX_REASONING_EFFORT_BY_THINKING_LEVEL[thinkingLevel2] : void 0;
|
|
63
63
|
}
|
|
64
|
-
function getProviderDisplayName(
|
|
65
|
-
switch (
|
|
64
|
+
function getProviderDisplayName(provider2, variant = "short") {
|
|
65
|
+
switch (provider2) {
|
|
66
66
|
case "codex":
|
|
67
67
|
return "Codex";
|
|
68
68
|
case "cursor":
|
|
@@ -141,10 +141,10 @@ var OPENCODE_GO_BASE_URL = "https://opencode.ai/zen/go/v1";
|
|
|
141
141
|
var DEFAULT_OPENCODE_GO_MODEL = "glm-5.3";
|
|
142
142
|
async function fetchOpenCodeGoCatalog(fallbackModelIds = [DEFAULT_OPENCODE_GO_MODEL]) {
|
|
143
143
|
try {
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
144
|
+
const provider2 = (await fetchModelsDevCatalog())[OPENCODE_GO_PROVIDER];
|
|
145
|
+
if (!provider2) throw new Error("OpenCode Go model catalog is unavailable");
|
|
146
146
|
const models = Object.fromEntries(
|
|
147
|
-
Object.entries(
|
|
147
|
+
Object.entries(provider2.models).filter(([, definition]) => definition.status !== "deprecated" && definition.status !== "alpha").map(([id, definition]) => [id, {
|
|
148
148
|
id: definition.id ?? id,
|
|
149
149
|
name: definition.name,
|
|
150
150
|
api: definition.provider?.npm === "@ai-sdk/anthropic" ? "anthropic-messages" : definition.provider?.npm === "@ai-sdk/openai" ? "openai-responses" : void 0,
|
|
@@ -234,34 +234,34 @@ var FALLBACK_AGENT_MODEL = {
|
|
|
234
234
|
opencode: DEFAULT_OPENCODE_MODEL,
|
|
235
235
|
pi: DEFAULT_PI_MODEL
|
|
236
236
|
};
|
|
237
|
-
function getDefaultAgentModel(
|
|
238
|
-
const catalogDefault = overrides?.defaultModels?.[
|
|
237
|
+
function getDefaultAgentModel(provider2, overrides) {
|
|
238
|
+
const catalogDefault = overrides?.defaultModels?.[provider2];
|
|
239
239
|
if (catalogDefault === null) return "";
|
|
240
|
-
const options = getAgentModelOptions(
|
|
240
|
+
const options = getAgentModelOptions(provider2, overrides);
|
|
241
241
|
if (catalogDefault && options.includes(catalogDefault)) return catalogDefault;
|
|
242
|
-
const fallback = FALLBACK_AGENT_MODEL[
|
|
242
|
+
const fallback = FALLBACK_AGENT_MODEL[provider2];
|
|
243
243
|
return options.includes(fallback) ? fallback : options[0] ?? "";
|
|
244
244
|
}
|
|
245
|
-
function normalizeClaudeModel(
|
|
246
|
-
if (
|
|
245
|
+
function normalizeClaudeModel(model2) {
|
|
246
|
+
if (model2 === "opus" || model2 === CLAUDE_OPUS_1M_MODEL || model2 === LEGACY_CLAUDE_OPUS_1M_MODEL) {
|
|
247
247
|
return DEFAULT_CLAUDE_MODEL;
|
|
248
248
|
}
|
|
249
|
-
if (
|
|
249
|
+
if (model2 === "fable") {
|
|
250
250
|
return CLAUDE_FABLE_5_1_MODEL;
|
|
251
251
|
}
|
|
252
|
-
if (
|
|
252
|
+
if (model2 === "sonnet") {
|
|
253
253
|
return CLAUDE_SONNET_5_MODEL;
|
|
254
254
|
}
|
|
255
|
-
if (
|
|
255
|
+
if (model2 === "haiku") {
|
|
256
256
|
return CLAUDE_HAIKU_4_5_MODEL;
|
|
257
257
|
}
|
|
258
|
-
return
|
|
258
|
+
return model2;
|
|
259
259
|
}
|
|
260
|
-
function toClaudeCodeModel(
|
|
260
|
+
function toClaudeCodeModel(model2, bedrock) {
|
|
261
261
|
if (!bedrock) {
|
|
262
|
-
return
|
|
262
|
+
return model2;
|
|
263
263
|
}
|
|
264
|
-
switch (normalizeClaudeModel(
|
|
264
|
+
switch (normalizeClaudeModel(model2)) {
|
|
265
265
|
case CLAUDE_FABLE_5_1_MODEL:
|
|
266
266
|
return CLAUDE_FABLE_5_1_BEDROCK_MODEL;
|
|
267
267
|
case CLAUDE_FABLE_5_MODEL:
|
|
@@ -281,7 +281,7 @@ function toClaudeCodeModel(model, bedrock) {
|
|
|
281
281
|
case CLAUDE_HAIKU_4_5_MODEL:
|
|
282
282
|
return "haiku";
|
|
283
283
|
default:
|
|
284
|
-
return
|
|
284
|
+
return model2;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
var CLAUDE_MODEL_CONTEXT_WINDOWS = {
|
|
@@ -309,14 +309,14 @@ var CLAUDE_MODEL_CONTEXT_WINDOWS = {
|
|
|
309
309
|
"claude-haiku-4-5-20251001": 2e5,
|
|
310
310
|
"claude-haiku-4-5@20251001": 2e5
|
|
311
311
|
};
|
|
312
|
-
function getClaudeModelContextWindow(
|
|
313
|
-
if (!
|
|
314
|
-
const normalized = normalizeClaudeModel(
|
|
315
|
-
return CLAUDE_MODEL_CONTEXT_WINDOWS[normalized] ?? CLAUDE_MODEL_CONTEXT_WINDOWS[
|
|
312
|
+
function getClaudeModelContextWindow(model2) {
|
|
313
|
+
if (!model2) return null;
|
|
314
|
+
const normalized = normalizeClaudeModel(model2) ?? model2;
|
|
315
|
+
return CLAUDE_MODEL_CONTEXT_WINDOWS[normalized] ?? CLAUDE_MODEL_CONTEXT_WINDOWS[model2] ?? null;
|
|
316
316
|
}
|
|
317
|
-
function canUseClaudeFastMode(
|
|
318
|
-
const normalized = normalizeClaudeModel(
|
|
319
|
-
return normalized === CLAUDE_OPUS_5_5_MODEL || normalized === CLAUDE_OPUS_5_MODEL || normalized === CLAUDE_OPUS_4_8_MODEL ||
|
|
317
|
+
function canUseClaudeFastMode(model2) {
|
|
318
|
+
const normalized = normalizeClaudeModel(model2);
|
|
319
|
+
return normalized === CLAUDE_OPUS_5_5_MODEL || normalized === CLAUDE_OPUS_5_MODEL || normalized === CLAUDE_OPUS_4_8_MODEL || model2 === "claude-opus-4-7";
|
|
320
320
|
}
|
|
321
321
|
var CLAUDE_MODEL_MIN_SANDBOX_IMAGE = {
|
|
322
322
|
[CLAUDE_FABLE_5_1_MODEL]: "replicas-sandbox-2026-09-01-v6",
|
|
@@ -410,18 +410,18 @@ var HIDDEN_BY_DEFAULT_MODELS = /* @__PURE__ */ new Set([
|
|
|
410
410
|
"grok-4.3",
|
|
411
411
|
"kimi-k2.5"
|
|
412
412
|
]);
|
|
413
|
-
var withoutHiddenByDefault = (models) => models.filter((
|
|
413
|
+
var withoutHiddenByDefault = (models) => models.filter((model2) => !HIDDEN_BY_DEFAULT_MODELS.has(model2));
|
|
414
414
|
var DEFAULT_STATIC_AGENT_MODELS = {
|
|
415
415
|
claude: withoutHiddenByDefault(AGENT_MODELS.claude),
|
|
416
416
|
codex: withoutHiddenByDefault(AGENT_MODELS.codex)
|
|
417
417
|
};
|
|
418
418
|
var DEFAULT_CURSOR_MODELS = withoutHiddenByDefault(AGENT_MODELS.cursor);
|
|
419
|
-
function getAgentModelOptions(
|
|
420
|
-
const override = overrides?.[
|
|
419
|
+
function getAgentModelOptions(provider2, overrides) {
|
|
420
|
+
const override = overrides?.[provider2];
|
|
421
421
|
if (override?.length) return override;
|
|
422
|
-
if (
|
|
423
|
-
if (
|
|
424
|
-
return AGENT_MODELS[
|
|
422
|
+
if (provider2 === "claude" || provider2 === "codex") return DEFAULT_STATIC_AGENT_MODELS[provider2];
|
|
423
|
+
if (provider2 === "cursor") return DEFAULT_CURSOR_MODELS;
|
|
424
|
+
return AGENT_MODELS[provider2] ?? [];
|
|
425
425
|
}
|
|
426
426
|
var SANDBOX_IMAGE_MODEL_FALLBACKS = {
|
|
427
427
|
[CLAUDE_OPUS_5_5_MODEL]: CLAUDE_OPUS_5_MODEL,
|
|
@@ -629,14 +629,14 @@ var CONTEXT_WINDOW_KEYS = /* @__PURE__ */ new Set([
|
|
|
629
629
|
"maxContextLength"
|
|
630
630
|
]);
|
|
631
631
|
var MAX_CATALOG_PAGES = 20;
|
|
632
|
-
function getModelContextWindow(
|
|
633
|
-
const directValues = Object.entries(
|
|
632
|
+
function getModelContextWindow(model2) {
|
|
633
|
+
const directValues = Object.entries(model2).flatMap(([key, value]) => {
|
|
634
634
|
const contextWindow = CONTEXT_WINDOW_KEYS.has(key) ? positiveInteger(value) : null;
|
|
635
635
|
return contextWindow === null ? [] : [contextWindow];
|
|
636
636
|
});
|
|
637
637
|
if (directValues.length > 0) return Math.max(...directValues);
|
|
638
638
|
const values = [];
|
|
639
|
-
const pending = Object.entries(
|
|
639
|
+
const pending = Object.entries(model2).filter(([key]) => !CONTEXT_WINDOW_KEYS.has(key)).map(([, value]) => value);
|
|
640
640
|
for (let inspected = 0; pending.length > 0 && inspected < 1e3; inspected += 1) {
|
|
641
641
|
const current = pending.pop();
|
|
642
642
|
if (Array.isArray(current)) {
|
|
@@ -695,7 +695,7 @@ async function listOpenAICompatibleModels(credential) {
|
|
|
695
695
|
});
|
|
696
696
|
if (!response.ok) throw new Error(`Models request failed with status ${response.status}`);
|
|
697
697
|
const payload = await response.json();
|
|
698
|
-
for (const
|
|
698
|
+
for (const model2 of parseOpenAICompatibleModels(payload)) models.set(model2.id, model2);
|
|
699
699
|
if (!isRecord(payload) || payload.has_more !== true) break;
|
|
700
700
|
if (page === MAX_CATALOG_PAGES - 1) throw new Error(`The models endpoint exceeded ${MAX_CATALOG_PAGES} pages`);
|
|
701
701
|
if (typeof payload.next_cursor !== "string" || !payload.next_cursor) {
|
|
@@ -732,17 +732,17 @@ function readOllamaAuthEnv(agent, env) {
|
|
|
732
732
|
var DEFAULT_OLLAMA_MODEL = "gpt-oss:20b";
|
|
733
733
|
var catalogs = /* @__PURE__ */ new Map();
|
|
734
734
|
function getDefaultOllamaModel(models) {
|
|
735
|
-
return models.find((
|
|
735
|
+
return models.find((model2) => model2.id === DEFAULT_OLLAMA_MODEL && model2.capabilities?.includes("tools") && (model2.contextWindow ?? 0) >= 64e3)?.id ?? null;
|
|
736
736
|
}
|
|
737
|
-
function parseOllamaModelDetails(
|
|
738
|
-
if (!isRecord(payload)) return
|
|
737
|
+
function parseOllamaModelDetails(model2, payload) {
|
|
738
|
+
if (!isRecord(payload)) return model2;
|
|
739
739
|
const capabilities = Array.isArray(payload.capabilities) ? payload.capabilities.filter((value) => typeof value === "string") : void 0;
|
|
740
740
|
const info = isRecord(payload.model_info) ? payload.model_info : {};
|
|
741
741
|
const context = Object.entries(info).find(([key]) => key.endsWith(".context_length"))?.[1];
|
|
742
742
|
const configured = typeof payload.parameters === "string" ? /(?:^|\n)\s*num_ctx\s+(\d+)/.exec(payload.parameters)?.[1] : void 0;
|
|
743
743
|
const contextWindow = configured ? Number(configured) : context;
|
|
744
744
|
return {
|
|
745
|
-
...
|
|
745
|
+
...model2,
|
|
746
746
|
...capabilities ? { capabilities } : {},
|
|
747
747
|
...typeof contextWindow === "number" && Number.isSafeInteger(contextWindow) && contextWindow > 0 ? { contextWindow } : {}
|
|
748
748
|
};
|
|
@@ -769,18 +769,18 @@ async function loadOllamaModels(credential) {
|
|
|
769
769
|
detailed.push(...models.slice(offset));
|
|
770
770
|
break;
|
|
771
771
|
}
|
|
772
|
-
detailed.push(...await Promise.all(models.slice(offset, offset + 10).map(async (
|
|
772
|
+
detailed.push(...await Promise.all(models.slice(offset, offset + 10).map(async (model2) => {
|
|
773
773
|
try {
|
|
774
774
|
const response = await fetch(url, {
|
|
775
775
|
method: "POST",
|
|
776
776
|
redirect: "error",
|
|
777
777
|
signal,
|
|
778
778
|
headers: { Authorization: `Bearer ${credential.apiKey}`, "Content-Type": "application/json" },
|
|
779
|
-
body: JSON.stringify({ model:
|
|
779
|
+
body: JSON.stringify({ model: model2.id })
|
|
780
780
|
});
|
|
781
|
-
return response.ok ? parseOllamaModelDetails(
|
|
781
|
+
return response.ok ? parseOllamaModelDetails(model2, await response.json()) : model2;
|
|
782
782
|
} catch {
|
|
783
|
-
return
|
|
783
|
+
return model2;
|
|
784
784
|
}
|
|
785
785
|
})));
|
|
786
786
|
}
|
|
@@ -1101,14 +1101,14 @@ var AUTH_RETRY_STATUS_EVENT_TYPE = "auth-retry-status";
|
|
|
1101
1101
|
var CURSOR_CONNECTION_STATUS_EVENT_TYPE = "cursor-connection-status";
|
|
1102
1102
|
var AUTH_FALLBACK_EVENT_TYPE = "auth-fallback";
|
|
1103
1103
|
function coerceAuthFallbackPayload(payload) {
|
|
1104
|
-
const { provider, reason, exhaustedMethod, exhaustedScope, candidateMethod, candidateScope, status, detail } = payload;
|
|
1104
|
+
const { provider: provider2, reason, exhaustedMethod, exhaustedScope, candidateMethod, candidateScope, status, detail } = payload;
|
|
1105
1105
|
const exhaustedAccount = credentialAccountSchema.safeParse(payload.exhaustedAccount).data;
|
|
1106
1106
|
const candidateAccount = credentialAccountSchema.safeParse(payload.candidateAccount).data;
|
|
1107
|
-
if (typeof
|
|
1107
|
+
if (typeof provider2 !== "string" || !isValidAgentProvider(provider2) || reason !== "rate_limit" && reason !== "out_of_credits" || !isAuthMethod(exhaustedMethod) || !isAuthMethod(candidateMethod) || !isCredentialScope(candidateScope) || status !== "switched" && status !== "failed") {
|
|
1108
1108
|
return null;
|
|
1109
1109
|
}
|
|
1110
1110
|
return {
|
|
1111
|
-
provider,
|
|
1111
|
+
provider: provider2,
|
|
1112
1112
|
reason,
|
|
1113
1113
|
exhaustedMethod,
|
|
1114
1114
|
...isCredentialScope(exhaustedScope) ? { exhaustedScope } : {},
|
|
@@ -1279,14 +1279,14 @@ function imageContentToUserMessageImages(images) {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
return userImages.length > 0 ? userImages : void 0;
|
|
1281
1281
|
}
|
|
1282
|
-
function createAcceptedUserMessageEvent(
|
|
1282
|
+
function createAcceptedUserMessageEvent(message2, messageId, timestamp, images) {
|
|
1283
1283
|
const eventImages = imageContentToUserMessageImages(images);
|
|
1284
1284
|
return {
|
|
1285
1285
|
timestamp,
|
|
1286
1286
|
type: "event_msg",
|
|
1287
1287
|
payload: {
|
|
1288
1288
|
type: "user_message",
|
|
1289
|
-
message,
|
|
1289
|
+
message: message2,
|
|
1290
1290
|
source: ACCEPTED_USER_MESSAGE_SOURCE,
|
|
1291
1291
|
[USER_MESSAGE_ID_PAYLOAD_KEY]: messageId,
|
|
1292
1292
|
...eventImages ? { images: eventImages } : {}
|
|
@@ -1492,6 +1492,62 @@ function paginateChatHistory(full, params) {
|
|
|
1492
1492
|
};
|
|
1493
1493
|
}
|
|
1494
1494
|
|
|
1495
|
+
// ../shared/src/subagent-mcp.ts
|
|
1496
|
+
var SUBAGENT_MCP_SERVER_NAME = "subagents";
|
|
1497
|
+
var SUBAGENT_MCP_TOOLS = {
|
|
1498
|
+
getProviders: "get_providers",
|
|
1499
|
+
spawnAgent: "spawn_agent",
|
|
1500
|
+
getAgent: "get_agent",
|
|
1501
|
+
waitAgent: "wait_agent",
|
|
1502
|
+
messageAgent: "message_agent",
|
|
1503
|
+
deleteAgent: "delete_agent"
|
|
1504
|
+
};
|
|
1505
|
+
var SUBAGENT_MCP_TOOL_NAMES = Object.values(SUBAGENT_MCP_TOOLS);
|
|
1506
|
+
|
|
1507
|
+
// ../shared/src/workspace-identity.ts
|
|
1508
|
+
import { z as z4 } from "zod";
|
|
1509
|
+
var WORKSPACE_IDENTITY_AUDIENCE = "replicas:workspace";
|
|
1510
|
+
var AWS_SOURCE_IDENTITY_CLAIM = "https://aws.amazon.com/source_identity";
|
|
1511
|
+
var WORKSPACE_TOKEN_TTL_SECONDS = 15 * 60;
|
|
1512
|
+
var IDENTITY_PROXY_PORT = 17323;
|
|
1513
|
+
var IDENTITY_TOKEN_PATH = "/token";
|
|
1514
|
+
var workspaceAudienceSchema = z4.string().min(1).max(255).regex(/^[\x21-\x7e]+$/, "Audience must be a single printable token without spaces");
|
|
1515
|
+
var workspaceTokenRequestSchema = z4.object({
|
|
1516
|
+
audience: workspaceAudienceSchema.optional(),
|
|
1517
|
+
aws_source_identity: z4.boolean().optional()
|
|
1518
|
+
});
|
|
1519
|
+
var workspaceTokenClaimsSchema = z4.object({
|
|
1520
|
+
iss: z4.string(),
|
|
1521
|
+
sub: z4.string(),
|
|
1522
|
+
aud: z4.string(),
|
|
1523
|
+
iat: z4.number().int(),
|
|
1524
|
+
nbf: z4.number().int(),
|
|
1525
|
+
exp: z4.number().int(),
|
|
1526
|
+
jti: z4.string(),
|
|
1527
|
+
organization_id: z4.string().uuid(),
|
|
1528
|
+
workspace_id: z4.string().uuid(),
|
|
1529
|
+
environment_id: z4.string().uuid(),
|
|
1530
|
+
creator_id: z4.string().uuid().nullable(),
|
|
1531
|
+
creator_email: z4.string().nullable().default(null),
|
|
1532
|
+
[AWS_SOURCE_IDENTITY_CLAIM]: z4.string().uuid().optional()
|
|
1533
|
+
}).passthrough();
|
|
1534
|
+
var workspaceTokenResponseSchema = z4.object({
|
|
1535
|
+
issuer: z4.string(),
|
|
1536
|
+
audience: z4.string(),
|
|
1537
|
+
token: z4.string(),
|
|
1538
|
+
expires_at: z4.string()
|
|
1539
|
+
});
|
|
1540
|
+
var legacyWorkspaceTokenBundleSchema = z4.object({
|
|
1541
|
+
version: z4.literal(1),
|
|
1542
|
+
issuer: z4.string(),
|
|
1543
|
+
default_audience: z4.string(),
|
|
1544
|
+
tokens: z4.record(z4.string(), z4.object({ token: z4.string(), expires_at: z4.string() }))
|
|
1545
|
+
});
|
|
1546
|
+
var mcpWorkloadAuthSchema = z4.strictObject({
|
|
1547
|
+
type: z4.literal("workspace_identity"),
|
|
1548
|
+
audience: workspaceAudienceSchema
|
|
1549
|
+
});
|
|
1550
|
+
|
|
1495
1551
|
// ../shared/src/runtime-env.ts
|
|
1496
1552
|
var REPLICAS_RUNTIME_ENV_ALIASES = {
|
|
1497
1553
|
monolithUrl: ["REPLICAS_MONOLITH_URL", "MONOLITH_URL"],
|
|
@@ -1694,80 +1750,24 @@ function gitIdentityConfigCommands(identity, scope = "global") {
|
|
|
1694
1750
|
];
|
|
1695
1751
|
}
|
|
1696
1752
|
|
|
1697
|
-
// ../shared/src/subagent-mcp.ts
|
|
1698
|
-
var SUBAGENT_MCP_SERVER_NAME = "subagents";
|
|
1699
|
-
var SUBAGENT_MCP_TOOLS = {
|
|
1700
|
-
getProviders: "get_providers",
|
|
1701
|
-
spawnAgent: "spawn_agent",
|
|
1702
|
-
getAgent: "get_agent",
|
|
1703
|
-
waitAgent: "wait_agent",
|
|
1704
|
-
messageAgent: "message_agent",
|
|
1705
|
-
deleteAgent: "delete_agent"
|
|
1706
|
-
};
|
|
1707
|
-
var SUBAGENT_MCP_TOOL_NAMES = Object.values(SUBAGENT_MCP_TOOLS);
|
|
1708
|
-
|
|
1709
1753
|
// ../shared/src/headless-agent.ts
|
|
1710
|
-
import { z as
|
|
1711
|
-
var headlessAgentRequestSchema =
|
|
1712
|
-
mode:
|
|
1713
|
-
agent:
|
|
1754
|
+
import { z as z5 } from "zod";
|
|
1755
|
+
var headlessAgentRequestSchema = z5.object({
|
|
1756
|
+
mode: z5.literal("structured"),
|
|
1757
|
+
agent: z5.custom(
|
|
1714
1758
|
(value) => typeof value === "string" && isValidAgentProvider(value)
|
|
1715
1759
|
),
|
|
1716
|
-
model:
|
|
1717
|
-
prompt:
|
|
1718
|
-
workingDirectory:
|
|
1719
|
-
timeoutSeconds:
|
|
1720
|
-
codexOauthTokens:
|
|
1721
|
-
outputSchema:
|
|
1760
|
+
model: z5.string().min(1),
|
|
1761
|
+
prompt: z5.string(),
|
|
1762
|
+
workingDirectory: z5.string().min(1),
|
|
1763
|
+
timeoutSeconds: z5.number().int().min(1).max(1800).default(300),
|
|
1764
|
+
codexOauthTokens: z5.object({ accessToken: z5.string(), accountId: z5.string() }).optional(),
|
|
1765
|
+
outputSchema: z5.record(z5.string(), z5.json())
|
|
1722
1766
|
});
|
|
1723
1767
|
|
|
1724
1768
|
// ../shared/src/engine/environment.ts
|
|
1725
1769
|
var DESKTOP_STREAM_PORT = 6080;
|
|
1726
1770
|
|
|
1727
|
-
// ../shared/src/workspace-identity.ts
|
|
1728
|
-
import { z as z5 } from "zod";
|
|
1729
|
-
var WORKSPACE_IDENTITY_AUDIENCE = "replicas:workspace";
|
|
1730
|
-
var AWS_SOURCE_IDENTITY_CLAIM = "https://aws.amazon.com/source_identity";
|
|
1731
|
-
var WORKSPACE_TOKEN_TTL_SECONDS = 15 * 60;
|
|
1732
|
-
var IDENTITY_PROXY_PORT = 17323;
|
|
1733
|
-
var IDENTITY_TOKEN_PATH = "/token";
|
|
1734
|
-
var workspaceAudienceSchema = z5.string().min(1).max(255).regex(/^[\x21-\x7e]+$/, "Audience must be a single printable token without spaces");
|
|
1735
|
-
var workspaceTokenRequestSchema = z5.object({
|
|
1736
|
-
audience: workspaceAudienceSchema.optional(),
|
|
1737
|
-
aws_source_identity: z5.boolean().optional()
|
|
1738
|
-
});
|
|
1739
|
-
var workspaceTokenClaimsSchema = z5.object({
|
|
1740
|
-
iss: z5.string(),
|
|
1741
|
-
sub: z5.string(),
|
|
1742
|
-
aud: z5.string(),
|
|
1743
|
-
iat: z5.number().int(),
|
|
1744
|
-
nbf: z5.number().int(),
|
|
1745
|
-
exp: z5.number().int(),
|
|
1746
|
-
jti: z5.string(),
|
|
1747
|
-
organization_id: z5.string().uuid(),
|
|
1748
|
-
workspace_id: z5.string().uuid(),
|
|
1749
|
-
environment_id: z5.string().uuid(),
|
|
1750
|
-
creator_id: z5.string().uuid().nullable(),
|
|
1751
|
-
creator_email: z5.string().nullable().default(null),
|
|
1752
|
-
[AWS_SOURCE_IDENTITY_CLAIM]: z5.string().uuid().optional()
|
|
1753
|
-
}).passthrough();
|
|
1754
|
-
var workspaceTokenResponseSchema = z5.object({
|
|
1755
|
-
issuer: z5.string(),
|
|
1756
|
-
audience: z5.string(),
|
|
1757
|
-
token: z5.string(),
|
|
1758
|
-
expires_at: z5.string()
|
|
1759
|
-
});
|
|
1760
|
-
var legacyWorkspaceTokenBundleSchema = z5.object({
|
|
1761
|
-
version: z5.literal(1),
|
|
1762
|
-
issuer: z5.string(),
|
|
1763
|
-
default_audience: z5.string(),
|
|
1764
|
-
tokens: z5.record(z5.string(), z5.object({ token: z5.string(), expires_at: z5.string() }))
|
|
1765
|
-
});
|
|
1766
|
-
var mcpWorkloadAuthSchema = z5.strictObject({
|
|
1767
|
-
type: z5.literal("workspace_identity"),
|
|
1768
|
-
audience: workspaceAudienceSchema
|
|
1769
|
-
});
|
|
1770
|
-
|
|
1771
1771
|
// ../shared/src/sse.ts
|
|
1772
1772
|
function parseSseChunk(chunk) {
|
|
1773
1773
|
let data = "";
|
|
@@ -1828,10 +1828,10 @@ async function raceWithTimeout(promise, ms) {
|
|
|
1828
1828
|
});
|
|
1829
1829
|
}
|
|
1830
1830
|
}
|
|
1831
|
-
async function withTimeout(promise, ms,
|
|
1831
|
+
async function withTimeout(promise, ms, message2) {
|
|
1832
1832
|
const result = await raceWithTimeout(promise, ms);
|
|
1833
1833
|
if (result === TIMEOUT) {
|
|
1834
|
-
throw new Error(
|
|
1834
|
+
throw new Error(message2);
|
|
1835
1835
|
}
|
|
1836
1836
|
return result;
|
|
1837
1837
|
}
|
|
@@ -1863,9 +1863,9 @@ function detectAgentQuotaLimit(text2) {
|
|
|
1863
1863
|
}
|
|
1864
1864
|
|
|
1865
1865
|
// ../shared/src/auth-fallback.ts
|
|
1866
|
-
function describeCredential(
|
|
1866
|
+
function describeCredential(provider2, credential) {
|
|
1867
1867
|
const { ownerName, email, ordinal } = credential.account ?? {};
|
|
1868
|
-
const label = `${getCredentialMethodLabel(
|
|
1868
|
+
const label = `${getCredentialMethodLabel(provider2, credential.method)}${ordinal ? ` #${ordinal}` : ""}`;
|
|
1869
1869
|
const owner = credential.scope === CREDENTIAL_SCOPE.USER ? ownerName ? `${ownerName}'s personal ${label}` : `your ${label}` : credential.scope === CREDENTIAL_SCOPE.ORG ? `the organization's ${label}` : `the ${label}`;
|
|
1870
1870
|
return email ? `${owner} (${email})` : owner;
|
|
1871
1871
|
}
|
|
@@ -1894,12 +1894,12 @@ var workspaceCredentialProviderSchema = z6.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
|
|
|
1894
1894
|
var workspaceCredentialSelectionSchema = agentCredentialSnapshotSchema.omit({ revision: true, account: true, credentialId: true });
|
|
1895
1895
|
var createWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend({
|
|
1896
1896
|
provider: z6.enum(VALID_AGENT_PROVIDERS)
|
|
1897
|
-
}).refine(({ provider, method }) => agentCredentialMethods(
|
|
1897
|
+
}).refine(({ provider: provider2, method }) => agentCredentialMethods(provider2).includes(method), {
|
|
1898
1898
|
message: "This inference provider is not supported by this agent"
|
|
1899
1899
|
});
|
|
1900
1900
|
var switchWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend({
|
|
1901
1901
|
provider: workspaceCredentialProviderSchema
|
|
1902
|
-
}).refine(({ provider, method }) => agentCredentialMethods(
|
|
1902
|
+
}).refine(({ provider: provider2, method }) => agentCredentialMethods(provider2).includes(method), {
|
|
1903
1903
|
message: "This authentication method is not supported by this agent"
|
|
1904
1904
|
});
|
|
1905
1905
|
|
|
@@ -1961,8 +1961,8 @@ var forkChatRequestSchema = z8.object({
|
|
|
1961
1961
|
function describeQuotaLimit(reason) {
|
|
1962
1962
|
return reason === "out_of_credits" ? "ran out of credits" : "hit its usage limit";
|
|
1963
1963
|
}
|
|
1964
|
-
function describeChatForkReason(reason,
|
|
1965
|
-
return reason ? `${getProviderDisplayName(
|
|
1964
|
+
function describeChatForkReason(reason, provider2) {
|
|
1965
|
+
return reason ? `${getProviderDisplayName(provider2)} ${describeQuotaLimit(reason)}` : null;
|
|
1966
1966
|
}
|
|
1967
1967
|
var AGENT_QUOTA_EXHAUSTED_EVENT_TYPE = "agent-quota-exhausted";
|
|
1968
1968
|
var agentQuotaExhaustedPayloadSchema = z8.object({
|
|
@@ -1971,8 +1971,8 @@ var agentQuotaExhaustedPayloadSchema = z8.object({
|
|
|
1971
1971
|
detail: z8.string().optional(),
|
|
1972
1972
|
forkTo: fallbackHarnessStepSchema.optional()
|
|
1973
1973
|
});
|
|
1974
|
-
function defaultForkChatTitle(source,
|
|
1975
|
-
return isDefaultChat(source) ? `Forked from ${source.title}` : `${source.title} (${getProviderDisplayName(
|
|
1974
|
+
function defaultForkChatTitle(source, provider2) {
|
|
1975
|
+
return isDefaultChat(source) ? `Forked from ${source.title}` : `${source.title} (${getProviderDisplayName(provider2)})`;
|
|
1976
1976
|
}
|
|
1977
1977
|
|
|
1978
1978
|
// ../shared/src/credential-pool.ts
|
|
@@ -2394,13 +2394,13 @@ function stringifyDisplayValue(value) {
|
|
|
2394
2394
|
return String(value);
|
|
2395
2395
|
}
|
|
2396
2396
|
}
|
|
2397
|
-
function upsertDisplayMessage(messages,
|
|
2398
|
-
const index = messages.findIndex((candidate) => candidate.id ===
|
|
2399
|
-
if (index === -1) messages.push(
|
|
2400
|
-
else messages[index] =
|
|
2401
|
-
return
|
|
2397
|
+
function upsertDisplayMessage(messages, message2) {
|
|
2398
|
+
const index = messages.findIndex((candidate) => candidate.id === message2.id);
|
|
2399
|
+
if (index === -1) messages.push(message2);
|
|
2400
|
+
else messages[index] = message2;
|
|
2401
|
+
return message2;
|
|
2402
2402
|
}
|
|
2403
|
-
function applyToolInputEvent(event, messages,
|
|
2403
|
+
function applyToolInputEvent(event, messages, provider2, state, questionFilter) {
|
|
2404
2404
|
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))) {
|
|
2405
2405
|
const previous = state.resolutions.get(event.payload.toolUseId);
|
|
2406
2406
|
const resolved = previous && (!previous.requestId || previous.requestId === event.payload.requestId) ? previous : void 0;
|
|
@@ -2413,8 +2413,8 @@ function applyToolInputEvent(event, messages, provider, state, questionFilter) {
|
|
|
2413
2413
|
...resolved?.selectionSummary ? { selectionSummary: resolved.selectionSummary } : {}
|
|
2414
2414
|
};
|
|
2415
2415
|
state.requests.set(event.payload.toolUseId, inputRequest);
|
|
2416
|
-
const
|
|
2417
|
-
if (
|
|
2416
|
+
const message2 = messages.find((candidate) => candidate.type === "tool_call" && candidate.id === `${provider2}-tool-${event.payload.toolUseId}`);
|
|
2417
|
+
if (message2) message2.inputRequest = inputRequest;
|
|
2418
2418
|
return true;
|
|
2419
2419
|
}
|
|
2420
2420
|
if (event.type === "replicas-tool-input-resolved" && typeof event.payload.toolUseId === "string" && typeof event.payload.selectionId === "string") {
|
|
@@ -2473,32 +2473,32 @@ function skillNameFromToolCall(tool, input) {
|
|
|
2473
2473
|
if (typeof tool !== "string" || !["read", "read_file", "readfile"].includes(tool.toLowerCase())) return null;
|
|
2474
2474
|
return parseSkillFilePath(input);
|
|
2475
2475
|
}
|
|
2476
|
-
function createCallDisplayMessage(
|
|
2477
|
-
if (
|
|
2478
|
-
const skillName =
|
|
2479
|
-
if (skillName === null) return { ...
|
|
2476
|
+
function createCallDisplayMessage(message2) {
|
|
2477
|
+
if (message2.inputRequest) return { ...message2, type: "tool_call" };
|
|
2478
|
+
const skillName = message2.server.toLowerCase() === "skills" ? message2.tool : skillNameFromToolCall(message2.tool, message2.input);
|
|
2479
|
+
if (skillName === null) return { ...message2, type: "tool_call" };
|
|
2480
2480
|
return {
|
|
2481
|
-
id:
|
|
2481
|
+
id: message2.id,
|
|
2482
2482
|
type: "skill",
|
|
2483
2483
|
skillName,
|
|
2484
|
-
status:
|
|
2485
|
-
timestamp:
|
|
2484
|
+
status: message2.status,
|
|
2485
|
+
timestamp: message2.timestamp
|
|
2486
2486
|
};
|
|
2487
2487
|
}
|
|
2488
|
-
function insertDisplayMessageByTimestamp(messages,
|
|
2489
|
-
const messageMs = parseTimestampMs(
|
|
2488
|
+
function insertDisplayMessageByTimestamp(messages, message2) {
|
|
2489
|
+
const messageMs = parseTimestampMs(message2.timestamp);
|
|
2490
2490
|
let index = messages.length;
|
|
2491
2491
|
while (index > 0 && parseTimestampMs(messages[index - 1].timestamp) > messageMs) index--;
|
|
2492
|
-
messages.splice(index, 0,
|
|
2492
|
+
messages.splice(index, 0, message2);
|
|
2493
2493
|
}
|
|
2494
2494
|
|
|
2495
2495
|
// ../shared/src/display-message/format.ts
|
|
2496
|
-
function planItemsFromMessage(
|
|
2497
|
-
if (
|
|
2498
|
-
return
|
|
2496
|
+
function planItemsFromMessage(message2) {
|
|
2497
|
+
if (message2.type === "todo_list") {
|
|
2498
|
+
return message2.items.map((item) => ({ text: item.text, status: todoItemStatus(item) }));
|
|
2499
2499
|
}
|
|
2500
|
-
if (
|
|
2501
|
-
const input = typeof
|
|
2500
|
+
if (message2.type !== "tool_call" || message2.tool !== "TodoWrite" && message2.tool !== "write_todos") return null;
|
|
2501
|
+
const input = typeof message2.input === "object" ? message2.input : null;
|
|
2502
2502
|
const todos = Array.isArray(input?.todos) ? input.todos : null;
|
|
2503
2503
|
if (!todos) return null;
|
|
2504
2504
|
return todos.flatMap((todo) => {
|
|
@@ -2512,34 +2512,34 @@ function planItemsFromMessage(message) {
|
|
|
2512
2512
|
function todoItemStatus(item) {
|
|
2513
2513
|
return item.itemStatus ?? (item.completed ? "completed" : "pending");
|
|
2514
2514
|
}
|
|
2515
|
-
function getDisplayMessageActivity(
|
|
2516
|
-
if (
|
|
2517
|
-
if (
|
|
2518
|
-
if (
|
|
2519
|
-
const operations =
|
|
2515
|
+
function getDisplayMessageActivity(message2) {
|
|
2516
|
+
if (message2.type === "user" || message2.type === "agent" || message2.type === "reasoning") return null;
|
|
2517
|
+
if (message2.type === "command") return { kind: "command", title: "Command", summary: message2.command, content: message2.output ?? "" };
|
|
2518
|
+
if (message2.type === "patch") {
|
|
2519
|
+
const operations = message2.operations.map((operation) => `${operation.action.toUpperCase()} ${operation.path}${operation.moveTo ? ` \u2192 ${operation.moveTo}` : ""}${operation.diff ? `
|
|
2520
2520
|
${operation.diff}` : ""}`).join("\n\n");
|
|
2521
|
-
return { kind: "file", title: "Apply patch", summary:
|
|
2521
|
+
return { kind: "file", title: "Apply patch", summary: message2.operations.map((operation) => operation.path).join(", "), content: [operations, message2.output].filter(Boolean).join("\n\n") };
|
|
2522
2522
|
}
|
|
2523
|
-
if (
|
|
2524
|
-
if (
|
|
2525
|
-
if (
|
|
2526
|
-
if (
|
|
2527
|
-
const items = planItemsFromMessage(
|
|
2523
|
+
if (message2.type === "file_change") return { kind: "file", title: "File changes", summary: message2.changes.map((change) => change.path).join(", "), content: message2.changes.map((change) => `${change.kind.toUpperCase()} ${change.path}`).join("\n") };
|
|
2524
|
+
if (message2.type === "tool_call") return { kind: "tool", title: `Tool \xB7 ${message2.tool}`, summary: message2.server, content: [stringifyDisplayValue(message2.input), message2.output].filter(Boolean).join("\n\n") };
|
|
2525
|
+
if (message2.type === "web_search") return { kind: "search", title: "Web search", summary: message2.query, content: "" };
|
|
2526
|
+
if (message2.type === "todo_list") {
|
|
2527
|
+
const items = planItemsFromMessage(message2) ?? [];
|
|
2528
2528
|
return { kind: "plan", title: "Plan", summary: `${items.filter((item) => item.status === "completed").length}/${items.length}`, content: "", items };
|
|
2529
2529
|
}
|
|
2530
|
-
if (
|
|
2531
|
-
if (
|
|
2532
|
-
if (
|
|
2533
|
-
if (
|
|
2534
|
-
const rateLimited =
|
|
2535
|
-
return { kind: "error", title: rateLimited ? "Codex rate limit" : "Codex credits", summary: "", content: rateLimited ? `Codex hit a rate limit${
|
|
2530
|
+
if (message2.type === "subagent") return { kind: "task", title: "Subagent", summary: message2.description, content: [message2.prompt, message2.model ? `Model: ${message2.model}` : "", message2.receiverThreadIds?.length ? `Threads: ${message2.receiverThreadIds.join(", ")}` : "", message2.output].filter(Boolean).join("\n\n") };
|
|
2531
|
+
if (message2.type === "background_task") return { kind: "task", title: message2.description ?? message2.summary ?? "Background task", summary: message2.taskType ?? "", content: [message2.prompt, message2.outputFile, message2.error].filter(Boolean).join("\n\n") };
|
|
2532
|
+
if (message2.type === "skill") return { kind: "tool", title: `Skill \xB7 ${message2.skillName}`, summary: message2.args ?? "", content: "" };
|
|
2533
|
+
if (message2.type === "quota_status") {
|
|
2534
|
+
const rateLimited = message2.state === "rate_limited";
|
|
2535
|
+
return { kind: "error", title: rateLimited ? "Codex rate limit" : "Codex credits", summary: "", content: rateLimited ? `Codex hit a rate limit${message2.rateLimitResetType ? ` (${message2.rateLimitResetType})` : ""} \u2014 try again after reset.` : "Codex is out of credits \u2014 top up your OpenAI account to resume." };
|
|
2536
2536
|
}
|
|
2537
|
-
if (
|
|
2538
|
-
const { headline, outcomeClause } = describeAuthFallback(
|
|
2539
|
-
return { kind: "error", title: "Credential fallback", summary: headline, content: [`The workspace ${outcomeClause}.`,
|
|
2537
|
+
if (message2.type === "auth_fallback") {
|
|
2538
|
+
const { headline, outcomeClause } = describeAuthFallback(message2);
|
|
2539
|
+
return { kind: "error", title: "Credential fallback", summary: headline, content: [`The workspace ${outcomeClause}.`, message2.detail].filter(Boolean).join("\n\n") };
|
|
2540
2540
|
}
|
|
2541
|
-
if (
|
|
2542
|
-
return { kind: "error", title: "Agent error", summary: "", content:
|
|
2541
|
+
if (message2.type === "interruption") return { kind: "error", title: "Agent stopped", summary: "", content: "" };
|
|
2542
|
+
return { kind: "error", title: "Agent error", summary: "", content: message2.message };
|
|
2543
2543
|
}
|
|
2544
2544
|
function fileContentDiff(path, content, action) {
|
|
2545
2545
|
const lines = content.replace(/\n$/, "").split("\n");
|
|
@@ -2672,16 +2672,16 @@ function decodePathSegments(segments) {
|
|
|
2672
2672
|
}
|
|
2673
2673
|
});
|
|
2674
2674
|
}
|
|
2675
|
-
function buildCodeHostPrUrl(repoUrl,
|
|
2675
|
+
function buildCodeHostPrUrl(repoUrl, provider2, prNumber) {
|
|
2676
2676
|
const normalizedRepoUrl = repoUrl.replace(/\.git$/, "");
|
|
2677
|
-
if (
|
|
2677
|
+
if (provider2 === "gitlab") {
|
|
2678
2678
|
return `${normalizedRepoUrl}/-/merge_requests/${prNumber}`;
|
|
2679
2679
|
}
|
|
2680
2680
|
return `${normalizedRepoUrl}/pull/${prNumber}`;
|
|
2681
2681
|
}
|
|
2682
2682
|
|
|
2683
2683
|
// ../shared/src/replicas-mcp.ts
|
|
2684
|
-
import { z as
|
|
2684
|
+
import { z as z14 } from "zod";
|
|
2685
2685
|
|
|
2686
2686
|
// ../shared/src/automations/trigger-schemas.ts
|
|
2687
2687
|
import { z as z10 } from "zod";
|
|
@@ -2711,32 +2711,22 @@ var automationTriggerSchema = z10.discriminatedUnion("type", [
|
|
|
2711
2711
|
z10.object({ type: z10.literal("custom"), config: z10.object({}) })
|
|
2712
2712
|
]);
|
|
2713
2713
|
|
|
2714
|
-
// ../shared/src/
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
spawnSubagent: "spawn_subagent",
|
|
2726
|
-
messageSubagent: "message_subagent",
|
|
2727
|
-
listSubagents: "list_subagents",
|
|
2728
|
-
readSubagent: "read_subagent",
|
|
2729
|
-
archiveSubagent: "archive_subagent"
|
|
2730
|
-
};
|
|
2731
|
-
var automationToolInputSchema = z11.object({
|
|
2732
|
-
name: z11.string().describe("Short automation name."),
|
|
2733
|
-
prompt: z11.string().describe("Prompt each automation run starts with."),
|
|
2734
|
-
environment_id: z11.string().describe(`Environment id from \`${REPLICAS_MCP_TOOLS.listEnvironments}\`.`),
|
|
2735
|
-
triggers: z11.array(automationTriggerSchema).min(1).describe(
|
|
2736
|
-
'One or more triggers. Cron: `{ "type": "cron", "config": { "schedule": "0 9 * * 1", "timezone": "America/New_York" } }`. GitHub: `{ "type": "github", "config": { "event": "pull_request.opened", "repository_ids": ["<repository uuid>"] } }`.'
|
|
2737
|
-
),
|
|
2738
|
-
description: z11.string().optional().describe("One-line summary shown in the dashboard.")
|
|
2714
|
+
// ../shared/src/routes/environment.ts
|
|
2715
|
+
import { z as z11 } from "zod";
|
|
2716
|
+
var ENVIRONMENT_MCP_TRANSPORTS = ["stdio", "http", "sse"];
|
|
2717
|
+
var stringMap = z11.record(z11.string(), z11.string());
|
|
2718
|
+
var createEnvironmentMcpRequestSchema = z11.object({
|
|
2719
|
+
name: z11.string(),
|
|
2720
|
+
transport: z11.enum(ENVIRONMENT_MCP_TRANSPORTS),
|
|
2721
|
+
config: z11.union([
|
|
2722
|
+
z11.object({ command: z11.string().min(1), args: z11.array(z11.string()).optional(), env: stringMap.optional() }),
|
|
2723
|
+
z11.object({ url: z11.url(), headers: stringMap.optional(), auth: mcpWorkloadAuthSchema.optional() })
|
|
2724
|
+
]).describe("stdio: `{ command, args, env }`. http/sse: `{ url, headers }`.")
|
|
2739
2725
|
});
|
|
2726
|
+
var updateEnvironmentMcpRequestSchema = createEnvironmentMcpRequestSchema.partial();
|
|
2727
|
+
|
|
2728
|
+
// ../shared/src/routes/workspaces.ts
|
|
2729
|
+
import { z as z13 } from "zod";
|
|
2740
2730
|
|
|
2741
2731
|
// ../shared/src/default-skills/replicas-agent/abilities/computer.ts
|
|
2742
2732
|
var SECTION = `### Computer use (Linux desktop control)
|
|
@@ -4883,6 +4873,100 @@ var REPLICAS_AGENT_ABILITIES = Object.keys(
|
|
|
4883
4873
|
REPLICAS_AGENT_ABILITY_REGISTRY
|
|
4884
4874
|
);
|
|
4885
4875
|
|
|
4876
|
+
// ../shared/src/routes/workspaces.ts
|
|
4877
|
+
var WORKSPACE_STATUSES = ["active", "sleeping", "archived", "preparing", "error"];
|
|
4878
|
+
var STALE_PREPARING_MS = 10 * 6e4;
|
|
4879
|
+
var VALID_LIFECYCLE_POLICIES = ["default", "archive_when_done", "sleep_when_done", "delete_after_inactivity"];
|
|
4880
|
+
var WORKSPACE_STATUS_FILTERS = WORKSPACE_STATUSES.map((status) => status === "error" ? "failed" : status);
|
|
4881
|
+
var WORKSPACE_SORT_CHOICES = [
|
|
4882
|
+
["manual", "Custom"],
|
|
4883
|
+
["activity", "Last activity"],
|
|
4884
|
+
["created", "Created date"]
|
|
4885
|
+
];
|
|
4886
|
+
var WORKSPACE_SORT_OPTIONS = WORKSPACE_SORT_CHOICES.map(([option]) => option);
|
|
4887
|
+
var WORKSPACE_SORT_LABELS = Object.fromEntries(WORKSPACE_SORT_CHOICES);
|
|
4888
|
+
var WORKSPACE_SIDEBAR_ORGANIZATION_CHOICES = [
|
|
4889
|
+
["chronological", "Chronological"],
|
|
4890
|
+
["environments", "Environments"],
|
|
4891
|
+
["recent", "Recent environments"]
|
|
4892
|
+
];
|
|
4893
|
+
var WORKSPACE_SIDEBAR_ORGANIZATIONS = WORKSPACE_SIDEBAR_ORGANIZATION_CHOICES.map(([organization]) => organization);
|
|
4894
|
+
var WORKSPACE_SIDEBAR_ORGANIZATION_LABELS = Object.fromEntries(WORKSPACE_SIDEBAR_ORGANIZATION_CHOICES);
|
|
4895
|
+
var DEFAULT_STATUS_FILTERS = [...WORKSPACE_STATUS_FILTERS];
|
|
4896
|
+
var DEFAULT_WORKSPACE_FILTERS = {
|
|
4897
|
+
statuses: [...DEFAULT_STATUS_FILTERS],
|
|
4898
|
+
ownerIds: [],
|
|
4899
|
+
activity: "any"
|
|
4900
|
+
};
|
|
4901
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
4902
|
+
var workspaceExecRequestSchema = z13.object({
|
|
4903
|
+
command: z13.string().regex(/\S/, "command is required"),
|
|
4904
|
+
timeout_seconds: z13.number().int().min(1).max(50).optional().describe("Default: 30")
|
|
4905
|
+
});
|
|
4906
|
+
var terminalRtcCandidateSchema = z13.object({ type: z13.literal("rtc-candidate"), candidate: z13.string(), mid: z13.string() });
|
|
4907
|
+
var terminalSocketServerMessageSchema = z13.discriminatedUnion("type", [
|
|
4908
|
+
z13.object({ type: z13.literal("output"), data: z13.string() }),
|
|
4909
|
+
z13.object({ type: z13.literal("rtc-answer"), sdp: z13.string() }),
|
|
4910
|
+
terminalRtcCandidateSchema,
|
|
4911
|
+
z13.object({ type: z13.literal("rtc-switch") })
|
|
4912
|
+
]);
|
|
4913
|
+
var TERMINAL_RTC_ICE_SERVER = "stun:stun.l.google.com:19302";
|
|
4914
|
+
|
|
4915
|
+
// ../shared/src/replicas-mcp.ts
|
|
4916
|
+
var REPLICAS_MCP_TOOLS = {
|
|
4917
|
+
listEnvironments: "list_environments",
|
|
4918
|
+
createAutomation: "create_automation",
|
|
4919
|
+
spawn: "spawn_workspace",
|
|
4920
|
+
relay: "relay_to_workspace",
|
|
4921
|
+
linearStart: "start_linear_session",
|
|
4922
|
+
linearSessionIntent: "register_linear_session_intent",
|
|
4923
|
+
listChannelSettings: "list_channel_settings",
|
|
4924
|
+
saveChannelPreset: "save_channel_preset",
|
|
4925
|
+
updateChannelSettings: "update_channel_settings",
|
|
4926
|
+
spawnSubagent: "spawn_subagent",
|
|
4927
|
+
messageSubagent: "message_subagent",
|
|
4928
|
+
listSubagents: "list_subagents",
|
|
4929
|
+
readSubagent: "read_subagent",
|
|
4930
|
+
archiveSubagent: "archive_subagent"
|
|
4931
|
+
};
|
|
4932
|
+
var automationToolInputSchema = z14.object({
|
|
4933
|
+
name: z14.string().describe("Short automation name."),
|
|
4934
|
+
prompt: z14.string().describe("Prompt each automation run starts with."),
|
|
4935
|
+
environment_id: z14.string().describe(`Environment id from \`${REPLICAS_MCP_TOOLS.listEnvironments}\`.`),
|
|
4936
|
+
triggers: z14.array(automationTriggerSchema).min(1).describe(
|
|
4937
|
+
'One or more triggers. Cron: `{ "type": "cron", "config": { "schedule": "0 9 * * 1", "timezone": "America/New_York" } }`. GitHub: `{ "type": "github", "config": { "event": "pull_request.opened", "repository_ids": ["<repository uuid>"] } }`.'
|
|
4938
|
+
),
|
|
4939
|
+
description: z14.string().optional().describe("One-line summary shown in the dashboard."),
|
|
4940
|
+
plan_mode: z14.boolean().optional(),
|
|
4941
|
+
goal_mode: z14.boolean().optional(),
|
|
4942
|
+
fast_mode: z14.boolean().optional()
|
|
4943
|
+
});
|
|
4944
|
+
var automationCreateToolInputSchema = automationToolInputSchema.extend({
|
|
4945
|
+
scope: z14.enum(["org", "user"]).optional().describe("`org` (default) or `user` for a personal automation, which needs a personal API key.")
|
|
4946
|
+
});
|
|
4947
|
+
var automationUpdateToolInputSchema = automationToolInputSchema.partial().extend({
|
|
4948
|
+
automation_id: z14.string().describe("Automation ID"),
|
|
4949
|
+
enabled: z14.boolean().optional(),
|
|
4950
|
+
agent_provider: z14.enum(AGENT).nullable().optional(),
|
|
4951
|
+
model: z14.string().nullable().optional(),
|
|
4952
|
+
thinking_level: z14.enum(VALID_THINKING_LEVELS).nullable().optional(),
|
|
4953
|
+
workspace_lifecycle_policy: z14.enum(VALID_LIFECYCLE_POLICIES).optional(),
|
|
4954
|
+
workspace_size: z14.enum(WORKSPACE_SIZES).optional()
|
|
4955
|
+
});
|
|
4956
|
+
var chatPath = { id: z14.string().describe("Workspace ID"), chat_id: z14.string().describe("Chat ID") };
|
|
4957
|
+
var { provider, model, thinkingLevel, title, message } = forkChatRequestSchema.shape;
|
|
4958
|
+
var createChatToolInputSchema = z14.object({ id: chatPath.id, provider, title: createChatRequestSchema.shape.title });
|
|
4959
|
+
var forkChatToolInputSchema = z14.object({ ...chatPath, provider, model, thinkingLevel, title, message });
|
|
4960
|
+
var renameChatToolInputSchema = z14.object({ ...chatPath, ...updateChatDisplayNameRequestSchema.shape });
|
|
4961
|
+
var runCommandToolInputSchema = z14.object({ id: chatPath.id, ...workspaceExecRequestSchema.shape });
|
|
4962
|
+
var environmentMcpPath = { environment_id: z14.string().describe("Environment ID") };
|
|
4963
|
+
var createEnvironmentMcpToolInputSchema = z14.object({ ...environmentMcpPath, ...createEnvironmentMcpRequestSchema.shape });
|
|
4964
|
+
var updateEnvironmentMcpToolInputSchema = z14.object({
|
|
4965
|
+
...environmentMcpPath,
|
|
4966
|
+
mcp_id: z14.string().describe("MCP ID"),
|
|
4967
|
+
...updateEnvironmentMcpRequestSchema.shape
|
|
4968
|
+
});
|
|
4969
|
+
|
|
4886
4970
|
// ../shared/src/routes/preferences.ts
|
|
4887
4971
|
var EMPTY_AGENT_DEFAULT_SETTINGS = {
|
|
4888
4972
|
agent_provider: null,
|
|
@@ -5029,8 +5113,8 @@ function messagesForCodexTurn(turn) {
|
|
|
5029
5113
|
coalesced.splice(responseIndex, 0, ...coalesced.splice(reasoningIndex, 1));
|
|
5030
5114
|
}
|
|
5031
5115
|
const messages = coalesced.flatMap((item) => {
|
|
5032
|
-
const
|
|
5033
|
-
return [...
|
|
5116
|
+
const message2 = messageForItem(item);
|
|
5117
|
+
return [...message2 ? [message2] : [], ...skillMessagesForItem(item)];
|
|
5034
5118
|
});
|
|
5035
5119
|
if (turn.error) {
|
|
5036
5120
|
messages.push({
|
|
@@ -5307,11 +5391,11 @@ function parseCodexEvents(events) {
|
|
|
5307
5391
|
return;
|
|
5308
5392
|
}
|
|
5309
5393
|
if (event.type === "event_msg" && event.payload?.type === "user_message") {
|
|
5310
|
-
const
|
|
5394
|
+
const message2 = getPayloadString(event, "message");
|
|
5311
5395
|
messages.push({
|
|
5312
5396
|
id: displayId(event, eventIndex, "user"),
|
|
5313
5397
|
type: "user",
|
|
5314
|
-
content:
|
|
5398
|
+
content: message2 ?? "",
|
|
5315
5399
|
images: userMessageImages(event.payload.images),
|
|
5316
5400
|
timestamp: event.timestamp
|
|
5317
5401
|
});
|
|
@@ -5447,34 +5531,34 @@ function parseCodexEvents(events) {
|
|
|
5447
5531
|
}
|
|
5448
5532
|
});
|
|
5449
5533
|
const recordedPrompts = /* @__PURE__ */ new Map();
|
|
5450
|
-
messages.forEach((
|
|
5451
|
-
if (
|
|
5452
|
-
const prompts = recordedPrompts.get(
|
|
5453
|
-
prompts.push({ message, index, timestampMs: parseTimestampMs(
|
|
5454
|
-
recordedPrompts.set(
|
|
5534
|
+
messages.forEach((message2, index) => {
|
|
5535
|
+
if (message2.type !== "user") return;
|
|
5536
|
+
const prompts = recordedPrompts.get(message2.content) ?? [];
|
|
5537
|
+
prompts.push({ message: message2, index, timestampMs: parseTimestampMs(message2.timestamp) });
|
|
5538
|
+
recordedPrompts.set(message2.content, prompts);
|
|
5455
5539
|
});
|
|
5456
5540
|
const claimedPrompts = /* @__PURE__ */ new Set();
|
|
5457
5541
|
for (const { index, turnId } of turnInsertions.reverse()) {
|
|
5458
5542
|
const turn = turns.get(turnId);
|
|
5459
5543
|
if (!turn) continue;
|
|
5460
5544
|
const kept = [];
|
|
5461
|
-
for (const
|
|
5462
|
-
if (
|
|
5463
|
-
kept.push(
|
|
5545
|
+
for (const message2 of messagesForCodexTurn(turn)) {
|
|
5546
|
+
if (message2.type !== "user") {
|
|
5547
|
+
kept.push(message2);
|
|
5464
5548
|
continue;
|
|
5465
5549
|
}
|
|
5466
|
-
const prompts = recordedPrompts.get(
|
|
5467
|
-
const recorded = prompts && takeRecordedPrompt(prompts,
|
|
5550
|
+
const prompts = recordedPrompts.get(message2.content);
|
|
5551
|
+
const recorded = prompts && takeRecordedPrompt(prompts, message2, index);
|
|
5468
5552
|
if (!recorded) {
|
|
5469
|
-
kept.push(
|
|
5553
|
+
kept.push(message2);
|
|
5470
5554
|
continue;
|
|
5471
5555
|
}
|
|
5472
5556
|
claimedPrompts.add(recorded);
|
|
5473
|
-
kept.push({ ...recorded, images: recorded.images ??
|
|
5557
|
+
kept.push({ ...recorded, images: recorded.images ?? message2.images });
|
|
5474
5558
|
}
|
|
5475
5559
|
messages.splice(index, 0, ...kept);
|
|
5476
5560
|
}
|
|
5477
|
-
return messages.filter((
|
|
5561
|
+
return messages.filter((message2) => !claimedPrompts.has(message2));
|
|
5478
5562
|
}
|
|
5479
5563
|
|
|
5480
5564
|
// ../shared/src/display-message/parsers/cursor-parser.ts
|
|
@@ -5490,24 +5574,24 @@ function cursorRunId(event) {
|
|
|
5490
5574
|
return typeof runId === "string" ? runId : "unknown-run";
|
|
5491
5575
|
}
|
|
5492
5576
|
function getCursorAssistantText(event) {
|
|
5493
|
-
const
|
|
5494
|
-
return getTextContent(
|
|
5577
|
+
const message2 = isRecord(event.payload.message) ? event.payload.message : null;
|
|
5578
|
+
return getTextContent(message2?.content);
|
|
5495
5579
|
}
|
|
5496
5580
|
function getCursorThinkingText(event) {
|
|
5497
5581
|
const text2 = event.payload.text;
|
|
5498
5582
|
if (typeof text2 === "string") return text2;
|
|
5499
|
-
const
|
|
5500
|
-
return typeof
|
|
5583
|
+
const message2 = isRecord(event.payload.message) ? event.payload.message : null;
|
|
5584
|
+
return typeof message2?.text === "string" ? message2.text : "";
|
|
5501
5585
|
}
|
|
5502
5586
|
function isTerminalStatus(status) {
|
|
5503
5587
|
return status === "FINISHED" || status === "ERROR" || status === "CANCELLED" || status === "EXPIRED";
|
|
5504
5588
|
}
|
|
5505
5589
|
function finalizeOpenCalls(messages, callIndexes, status) {
|
|
5506
5590
|
for (const index of callIndexes.values()) {
|
|
5507
|
-
const
|
|
5508
|
-
if ((
|
|
5591
|
+
const message2 = messages[index];
|
|
5592
|
+
if ((message2?.type === "tool_call" || message2?.type === "skill") && message2.status === "in_progress") {
|
|
5509
5593
|
messages[index] = {
|
|
5510
|
-
...
|
|
5594
|
+
...message2,
|
|
5511
5595
|
status
|
|
5512
5596
|
};
|
|
5513
5597
|
}
|
|
@@ -5522,10 +5606,10 @@ function parseCursorEvents(events) {
|
|
|
5522
5606
|
let activeThinking = null;
|
|
5523
5607
|
const finalizeActiveThinking = (status) => {
|
|
5524
5608
|
if (!activeThinking) return;
|
|
5525
|
-
const
|
|
5526
|
-
if (
|
|
5609
|
+
const message2 = messages[activeThinking.index];
|
|
5610
|
+
if (message2?.type === "reasoning") {
|
|
5527
5611
|
messages[activeThinking.index] = {
|
|
5528
|
-
...
|
|
5612
|
+
...message2,
|
|
5529
5613
|
status
|
|
5530
5614
|
};
|
|
5531
5615
|
}
|
|
@@ -5534,12 +5618,12 @@ function parseCursorEvents(events) {
|
|
|
5534
5618
|
if (event.type === "event_msg" && event.payload.type === "user_message") {
|
|
5535
5619
|
activeAssistant = null;
|
|
5536
5620
|
activeThinking = null;
|
|
5537
|
-
const
|
|
5538
|
-
if (typeof
|
|
5621
|
+
const message2 = event.payload.message;
|
|
5622
|
+
if (typeof message2 === "string" && message2.trim()) {
|
|
5539
5623
|
messages.push({
|
|
5540
5624
|
id: getUserMessageId(event) ?? `cursor-user-${event.timestamp}-${messages.length}`,
|
|
5541
5625
|
type: "user",
|
|
5542
|
-
content:
|
|
5626
|
+
content: message2,
|
|
5543
5627
|
timestamp: event.timestamp
|
|
5544
5628
|
});
|
|
5545
5629
|
}
|
|
@@ -5562,11 +5646,11 @@ function parseCursorEvents(events) {
|
|
|
5562
5646
|
}) - 1
|
|
5563
5647
|
};
|
|
5564
5648
|
}
|
|
5565
|
-
const
|
|
5566
|
-
if (
|
|
5649
|
+
const message2 = messages[activeAssistant.index];
|
|
5650
|
+
if (message2?.type === "agent") {
|
|
5567
5651
|
messages[activeAssistant.index] = {
|
|
5568
|
-
...
|
|
5569
|
-
content: `${
|
|
5652
|
+
...message2,
|
|
5653
|
+
content: `${message2.content}${text2}`
|
|
5570
5654
|
};
|
|
5571
5655
|
}
|
|
5572
5656
|
}
|
|
@@ -5590,11 +5674,11 @@ function parseCursorEvents(events) {
|
|
|
5590
5674
|
}) - 1
|
|
5591
5675
|
};
|
|
5592
5676
|
}
|
|
5593
|
-
const
|
|
5594
|
-
if (
|
|
5677
|
+
const message2 = messages[activeThinking.index];
|
|
5678
|
+
if (message2?.type === "reasoning") {
|
|
5595
5679
|
messages[activeThinking.index] = {
|
|
5596
|
-
...
|
|
5597
|
-
content: `${
|
|
5680
|
+
...message2,
|
|
5681
|
+
content: `${message2.content}${text2}`,
|
|
5598
5682
|
status: "in_progress"
|
|
5599
5683
|
};
|
|
5600
5684
|
}
|
|
@@ -5653,11 +5737,11 @@ function parseCursorEvents(events) {
|
|
|
5653
5737
|
finalizeOpenCalls(messages, callIndexes, "failed");
|
|
5654
5738
|
activeAssistant = null;
|
|
5655
5739
|
activeThinking = null;
|
|
5656
|
-
const
|
|
5740
|
+
const message2 = typeof event.payload.message === "string" ? event.payload.message : "Cursor run failed";
|
|
5657
5741
|
messages.push({
|
|
5658
5742
|
id: `cursor-error-${event.timestamp}-${messages.length}`,
|
|
5659
5743
|
type: "error",
|
|
5660
|
-
message,
|
|
5744
|
+
message: message2,
|
|
5661
5745
|
timestamp: event.timestamp
|
|
5662
5746
|
});
|
|
5663
5747
|
}
|
|
@@ -5739,16 +5823,16 @@ var TRANSIENT_HTTP_STATUSES = [408, 429, 500, 502, 503, 504, 529];
|
|
|
5739
5823
|
var SERVER_ERROR_TEXT_PATTERN = /internal ?server ?error|server ?error|service unavailable|bad gateway|gateway timeout|overloaded|too many requests/i;
|
|
5740
5824
|
var INFERENCE_ERROR_DETAIL_MAX = 600;
|
|
5741
5825
|
var INFERENCE_ERROR_RETRY_HINT = "This is usually temporary \u2014 retry the message.";
|
|
5742
|
-
function formatInferenceError(
|
|
5826
|
+
function formatInferenceError(message2, context = {}) {
|
|
5743
5827
|
const label = context.provider ? INFERENCE_PROVIDER_LABELS[context.provider] ?? context.provider : null;
|
|
5744
5828
|
const source = label ? `${label}${context.model ? ` (${context.model})` : ""} request failed${typeof context.status === "number" ? ` with HTTP ${context.status}` : ""}` : null;
|
|
5745
|
-
let body = source ?
|
|
5829
|
+
let body = source ? message2 ? `${source}: ${message2}` : `${source}.` : message2;
|
|
5746
5830
|
const detail = context.detail?.trim();
|
|
5747
5831
|
if (detail && !body.includes(detail)) {
|
|
5748
5832
|
body = `${body}
|
|
5749
5833
|
${detail.length > INFERENCE_ERROR_DETAIL_MAX ? `${detail.slice(0, INFERENCE_ERROR_DETAIL_MAX)}\u2026` : detail}`;
|
|
5750
5834
|
}
|
|
5751
|
-
const sniffText = `${
|
|
5835
|
+
const sniffText = `${message2}
|
|
5752
5836
|
${detail ?? ""}`;
|
|
5753
5837
|
const transient = context.retryable ?? (typeof context.status === "number" ? TRANSIENT_HTTP_STATUSES.includes(context.status) || context.status >= 500 : isTransientErrorText(sniffText, { httpStatuses: TRANSIENT_HTTP_STATUSES, includeRateLimit: true }) || SERVER_ERROR_TEXT_PATTERN.test(sniffText));
|
|
5754
5838
|
return transient ? `${body}
|
|
@@ -5768,9 +5852,9 @@ function toolStatus(status) {
|
|
|
5768
5852
|
function assistantError(info) {
|
|
5769
5853
|
if (!isRecord(info) || !isRecord(info.error)) return null;
|
|
5770
5854
|
const data = isRecord(info.error.data) ? info.error.data : null;
|
|
5771
|
-
const
|
|
5772
|
-
if (info.error.name === "MessageAbortedError") return
|
|
5773
|
-
return formatInferenceError(
|
|
5855
|
+
const message2 = typeof data?.message === "string" ? data.message : typeof info.error.message === "string" ? info.error.message : stringifyDisplayValue(info.error) ?? "Opencode run failed";
|
|
5856
|
+
if (info.error.name === "MessageAbortedError") return message2;
|
|
5857
|
+
return formatInferenceError(message2, {
|
|
5774
5858
|
...typeof info.providerID === "string" ? { provider: info.providerID } : {},
|
|
5775
5859
|
...typeof info.modelID === "string" ? { model: info.modelID } : {},
|
|
5776
5860
|
...typeof data?.statusCode === "number" ? { status: data.statusCode } : {},
|
|
@@ -5782,13 +5866,13 @@ function parseOpencodeEvents(events) {
|
|
|
5782
5866
|
const messages = [];
|
|
5783
5867
|
for (const event of events) {
|
|
5784
5868
|
if (event.type === "event_msg" && event.payload.type === "user_message") {
|
|
5785
|
-
const
|
|
5786
|
-
if (typeof
|
|
5869
|
+
const message2 = event.payload.message;
|
|
5870
|
+
if (typeof message2 === "string" && message2.trim()) {
|
|
5787
5871
|
const messageId = event.payload[USER_MESSAGE_ID_PAYLOAD_KEY];
|
|
5788
5872
|
messages.push({
|
|
5789
5873
|
id: typeof messageId === "string" ? messageId : `opencode-user-${event.timestamp}`,
|
|
5790
5874
|
type: "user",
|
|
5791
|
-
content:
|
|
5875
|
+
content: message2,
|
|
5792
5876
|
timestamp: event.timestamp
|
|
5793
5877
|
});
|
|
5794
5878
|
}
|
|
@@ -5807,11 +5891,11 @@ function parseOpencodeEvents(events) {
|
|
|
5807
5891
|
continue;
|
|
5808
5892
|
}
|
|
5809
5893
|
if (event.type === "opencode-error") {
|
|
5810
|
-
const
|
|
5894
|
+
const message2 = typeof event.payload.message === "string" ? event.payload.message : "Opencode run failed";
|
|
5811
5895
|
messages.push({
|
|
5812
5896
|
id: `opencode-${event.type}-${event.timestamp}`,
|
|
5813
5897
|
type: "error",
|
|
5814
|
-
message: formatInferenceError(
|
|
5898
|
+
message: formatInferenceError(message2, {
|
|
5815
5899
|
...typeof event.payload.status === "number" ? { status: event.payload.status } : {}
|
|
5816
5900
|
}),
|
|
5817
5901
|
timestamp: event.timestamp
|
|
@@ -5993,7 +6077,7 @@ function parseMuseEvents(events) {
|
|
|
5993
6077
|
} catch {
|
|
5994
6078
|
}
|
|
5995
6079
|
}
|
|
5996
|
-
const
|
|
6080
|
+
const message2 = createCallDisplayMessage({
|
|
5997
6081
|
id: `muse-tool-${item.itemId}`,
|
|
5998
6082
|
server: "muse",
|
|
5999
6083
|
tool: typeof item.tool === "string" ? item.tool : "tool",
|
|
@@ -6003,7 +6087,7 @@ function parseMuseEvents(events) {
|
|
|
6003
6087
|
status: item.status === "failed" || item.status === "rejected" ? "failed" : terminal ? "completed" : "in_progress",
|
|
6004
6088
|
timestamp: typeof item.recordedAt === "string" ? item.recordedAt : event.timestamp
|
|
6005
6089
|
});
|
|
6006
|
-
upsertDisplayMessage(messages,
|
|
6090
|
+
upsertDisplayMessage(messages, message2);
|
|
6007
6091
|
}
|
|
6008
6092
|
}
|
|
6009
6093
|
return messages;
|
|
@@ -6018,8 +6102,8 @@ function toolStatus2(value) {
|
|
|
6018
6102
|
}
|
|
6019
6103
|
function assistantErrorMessage(value) {
|
|
6020
6104
|
if (!isRecord(value) || value.role !== "assistant" || value.stopReason !== "error") return null;
|
|
6021
|
-
const
|
|
6022
|
-
return formatInferenceError(
|
|
6105
|
+
const message2 = typeof value.errorMessage === "string" && value.errorMessage ? value.errorMessage : "Pi run failed";
|
|
6106
|
+
return formatInferenceError(message2, {
|
|
6023
6107
|
...typeof value.provider === "string" ? { provider: value.provider } : {},
|
|
6024
6108
|
...typeof value.model === "string" ? { model: value.model } : {}
|
|
6025
6109
|
});
|
|
@@ -6066,8 +6150,8 @@ function parsePiEvents(events) {
|
|
|
6066
6150
|
continue;
|
|
6067
6151
|
}
|
|
6068
6152
|
if (event.type === "pi-message_start") {
|
|
6069
|
-
const
|
|
6070
|
-
activeMessageId = typeof
|
|
6153
|
+
const message2 = isRecord(event.payload.message) ? event.payload.message : null;
|
|
6154
|
+
activeMessageId = typeof message2?.id === "string" ? message2.id : `assistant-${event.timestamp}`;
|
|
6071
6155
|
continue;
|
|
6072
6156
|
}
|
|
6073
6157
|
if (event.type === "pi-tool_execution_start" || event.type === "pi-tool_execution_update" || event.type === "pi-tool_execution_end") {
|
|
@@ -6266,8 +6350,8 @@ function fileOrCommandMessage(toolName, toolUseId, input, timestamp) {
|
|
|
6266
6350
|
};
|
|
6267
6351
|
}
|
|
6268
6352
|
function createSubagentMessage(messageIndex, timestamp, fields) {
|
|
6269
|
-
const { id = `subagent-${timestamp}-${messageIndex}`, ...
|
|
6270
|
-
return { id, type: "subagent", ...
|
|
6353
|
+
const { id = `subagent-${timestamp}-${messageIndex}`, ...message2 } = fields;
|
|
6354
|
+
return { id, type: "subagent", ...message2, timestamp };
|
|
6271
6355
|
}
|
|
6272
6356
|
function collectNestedEvents(events, toolUseId) {
|
|
6273
6357
|
return events.filter((e) => e.payload.parent_tool_use_id === toolUseId).map(({ timestamp, type, payload }) => ({ timestamp, type, payload }));
|
|
@@ -6324,12 +6408,12 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6324
6408
|
const supersededUserMessageIndexes = /* @__PURE__ */ new Set();
|
|
6325
6409
|
const findMatchingUserMessageIndex = (indexes, content, timestamp, messageId) => {
|
|
6326
6410
|
if (typeof messageId === "string") {
|
|
6327
|
-
const byId = messages.findIndex((
|
|
6411
|
+
const byId = messages.findIndex((message2, index) => message2.type === "user" && message2.id === messageId && !supersededUserMessageIndexes.has(index));
|
|
6328
6412
|
if (byId !== -1) return byId;
|
|
6329
6413
|
}
|
|
6330
6414
|
return [...indexes].find((index) => {
|
|
6331
|
-
const
|
|
6332
|
-
return
|
|
6415
|
+
const message2 = messages[index];
|
|
6416
|
+
return message2?.type === "user" && areUserMessagesWithinMatchWindow(message2, { content, timestamp });
|
|
6333
6417
|
});
|
|
6334
6418
|
};
|
|
6335
6419
|
const taskAccumulator = new TaskAccumulator();
|
|
@@ -6346,7 +6430,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6346
6430
|
const messageId = event.payload[USER_MESSAGE_ID_PAYLOAD_KEY];
|
|
6347
6431
|
const canonicalIndex = findMatchingUserMessageIndex(canonicalUserMessageIndexes, content, event.timestamp, messageId);
|
|
6348
6432
|
const canonical = canonicalIndex === void 0 ? void 0 : messages[canonicalIndex];
|
|
6349
|
-
const
|
|
6433
|
+
const message2 = {
|
|
6350
6434
|
id: typeof messageId === "string" ? messageId : `user-${event.timestamp}`,
|
|
6351
6435
|
type: "user",
|
|
6352
6436
|
content,
|
|
@@ -6354,9 +6438,9 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6354
6438
|
timestamp: event.timestamp
|
|
6355
6439
|
};
|
|
6356
6440
|
if (canonicalIndex === void 0) {
|
|
6357
|
-
acceptedUserMessageIndexes.add(messages.push(
|
|
6441
|
+
acceptedUserMessageIndexes.add(messages.push(message2) - 1);
|
|
6358
6442
|
} else {
|
|
6359
|
-
messages[canonicalIndex] =
|
|
6443
|
+
messages[canonicalIndex] = message2;
|
|
6360
6444
|
canonicalUserMessageIndexes.delete(canonicalIndex);
|
|
6361
6445
|
}
|
|
6362
6446
|
}
|
|
@@ -6428,7 +6512,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6428
6512
|
stampedId
|
|
6429
6513
|
);
|
|
6430
6514
|
const accepted = acceptedIndex === void 0 ? void 0 : messages[acceptedIndex];
|
|
6431
|
-
const
|
|
6515
|
+
const message2 = {
|
|
6432
6516
|
id: accepted?.id ?? (typeof stampedId === "string" ? stampedId : `user-${event.timestamp}`),
|
|
6433
6517
|
type: "user",
|
|
6434
6518
|
content: textContent || (images.length > 0 ? `[${images.length} image${images.length > 1 ? "s" : ""} attached]` : ""),
|
|
@@ -6436,13 +6520,13 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6436
6520
|
timestamp: event.timestamp
|
|
6437
6521
|
};
|
|
6438
6522
|
if (acceptedIndex === void 0) {
|
|
6439
|
-
canonicalUserMessageIndexes.add(messages.push(
|
|
6523
|
+
canonicalUserMessageIndexes.add(messages.push(message2) - 1);
|
|
6440
6524
|
} else if (acceptedUserMessageIndexes.has(acceptedIndex)) {
|
|
6441
6525
|
supersededUserMessageIndexes.add(acceptedIndex);
|
|
6442
6526
|
acceptedUserMessageIndexes.delete(acceptedIndex);
|
|
6443
|
-
canonicalUserMessageIndexes.add(messages.push(
|
|
6527
|
+
canonicalUserMessageIndexes.add(messages.push(message2) - 1);
|
|
6444
6528
|
} else {
|
|
6445
|
-
messages[acceptedIndex] =
|
|
6529
|
+
messages[acceptedIndex] = message2;
|
|
6446
6530
|
}
|
|
6447
6531
|
}
|
|
6448
6532
|
}
|
|
@@ -6666,9 +6750,9 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6666
6750
|
if (!Array.isArray(payload.options) && !Array.isArray(payload.questions)) return;
|
|
6667
6751
|
const toolInfo = toolCallMap.get(payload.toolUseId);
|
|
6668
6752
|
if (!toolInfo) return;
|
|
6669
|
-
const
|
|
6670
|
-
if (!
|
|
6671
|
-
|
|
6753
|
+
const message2 = messages[toolInfo.messageIndex];
|
|
6754
|
+
if (!message2 || message2.type !== "tool_call") return;
|
|
6755
|
+
message2.inputRequest = {
|
|
6672
6756
|
requestId: payload.requestId,
|
|
6673
6757
|
status: "pending",
|
|
6674
6758
|
options: payload.options,
|
|
@@ -6680,10 +6764,10 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6680
6764
|
if (!payload.toolUseId || !payload.selectionId) return;
|
|
6681
6765
|
const toolInfo = toolCallMap.get(payload.toolUseId);
|
|
6682
6766
|
if (!toolInfo) return;
|
|
6683
|
-
const
|
|
6684
|
-
if (!
|
|
6685
|
-
|
|
6686
|
-
...
|
|
6767
|
+
const message2 = messages[toolInfo.messageIndex];
|
|
6768
|
+
if (!message2 || message2.type !== "tool_call" || !message2.inputRequest) return;
|
|
6769
|
+
message2.inputRequest = {
|
|
6770
|
+
...message2.inputRequest,
|
|
6687
6771
|
status: payload.selectionId === "aborted" ? "aborted" : "resolved",
|
|
6688
6772
|
selectionId: payload.selectionId,
|
|
6689
6773
|
selectionSummary: payload.selectionSummary
|
|
@@ -6705,39 +6789,39 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
6705
6789
|
if (toolInfo.toolName === "TaskCreate" && !isError) {
|
|
6706
6790
|
taskAccumulator.processContentBlock(toolResult);
|
|
6707
6791
|
}
|
|
6708
|
-
const
|
|
6709
|
-
if (!
|
|
6710
|
-
if (
|
|
6711
|
-
|
|
6712
|
-
|
|
6792
|
+
const message2 = messages[toolInfo.messageIndex];
|
|
6793
|
+
if (!message2) return;
|
|
6794
|
+
if (message2.type === "command") {
|
|
6795
|
+
message2.output = resultContent;
|
|
6796
|
+
message2.status = status;
|
|
6713
6797
|
const exitCodeMatch = resultContent.match(/exit code:?\s*(\d+)/i);
|
|
6714
6798
|
if (exitCodeMatch) {
|
|
6715
|
-
|
|
6799
|
+
message2.exitCode = parseInt(exitCodeMatch[1], 10);
|
|
6716
6800
|
} else {
|
|
6717
|
-
|
|
6801
|
+
message2.exitCode = isError ? 1 : 0;
|
|
6718
6802
|
}
|
|
6719
|
-
} else if (
|
|
6720
|
-
|
|
6721
|
-
} else if (
|
|
6722
|
-
|
|
6723
|
-
} else if (
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
} else if (
|
|
6727
|
-
|
|
6728
|
-
} else if (
|
|
6729
|
-
|
|
6730
|
-
|
|
6803
|
+
} else if (message2.type === "patch") {
|
|
6804
|
+
message2.status = status;
|
|
6805
|
+
} else if (message2.type === "web_search") {
|
|
6806
|
+
message2.status = status;
|
|
6807
|
+
} else if (message2.type === "tool_call") {
|
|
6808
|
+
message2.output = resultContent;
|
|
6809
|
+
message2.status = status;
|
|
6810
|
+
} else if (message2.type === "skill") {
|
|
6811
|
+
message2.status = status;
|
|
6812
|
+
} else if (message2.type === "subagent") {
|
|
6813
|
+
message2.output = resultContent;
|
|
6814
|
+
message2.status = status;
|
|
6731
6815
|
}
|
|
6732
6816
|
});
|
|
6733
|
-
for (const
|
|
6734
|
-
if (
|
|
6735
|
-
const toolInfo = toolCallMap.get(
|
|
6817
|
+
for (const message2 of messages) {
|
|
6818
|
+
if (message2.type === "background_task" && message2.toolUseId) {
|
|
6819
|
+
const toolInfo = toolCallMap.get(message2.toolUseId);
|
|
6736
6820
|
const toolMessage = toolInfo ? messages[toolInfo.messageIndex] : void 0;
|
|
6737
|
-
if (toolMessage?.type === "command")
|
|
6821
|
+
if (toolMessage?.type === "command") message2.command = toolMessage.command;
|
|
6738
6822
|
if (toolMessage?.type === "subagent") {
|
|
6739
|
-
|
|
6740
|
-
|
|
6823
|
+
message2.prompt ??= toolMessage.prompt;
|
|
6824
|
+
message2.subagentType ??= toolMessage.subagentType;
|
|
6741
6825
|
}
|
|
6742
6826
|
}
|
|
6743
6827
|
}
|
|
@@ -6789,9 +6873,9 @@ function parseDisplayMessages(events, agentType, options = {}) {
|
|
|
6789
6873
|
events = excludeQueuedAcceptedEvents(events, []);
|
|
6790
6874
|
const parsedEvents = agentType === "claude" ? parseClaudeEvents(events, options.parentToolUseId) : parseAgentEvents(events, agentType);
|
|
6791
6875
|
const reconciledEvents = [];
|
|
6792
|
-
for (const
|
|
6793
|
-
if (
|
|
6794
|
-
else reconciledEvents.push(
|
|
6876
|
+
for (const message2 of parsedEvents) {
|
|
6877
|
+
if (message2.type === "user") upsertDisplayMessage(reconciledEvents, message2);
|
|
6878
|
+
else reconciledEvents.push(message2);
|
|
6795
6879
|
}
|
|
6796
6880
|
if (options.filter === false) return reconciledEvents;
|
|
6797
6881
|
return applyAuthFallbackNotices(
|
|
@@ -6853,17 +6937,17 @@ function applyAuthFallbackNotices(messages, events) {
|
|
|
6853
6937
|
for (const notice of notices) insertDisplayMessageByTimestamp(result, notice);
|
|
6854
6938
|
return result;
|
|
6855
6939
|
}
|
|
6856
|
-
function isCodexInitializationPrompt(
|
|
6857
|
-
return
|
|
6940
|
+
function isCodexInitializationPrompt(message2) {
|
|
6941
|
+
return message2.type === "user" && removeReplicasInstructions(message2.content).trim() === "Hello";
|
|
6858
6942
|
}
|
|
6859
6943
|
function isAgentBackendEvent(value) {
|
|
6860
6944
|
if (!value || typeof value !== "object") return false;
|
|
6861
6945
|
const candidate = value;
|
|
6862
6946
|
return typeof candidate.timestamp === "string" && typeof candidate.type === "string" && typeof candidate.payload === "object" && candidate.payload !== null;
|
|
6863
6947
|
}
|
|
6864
|
-
function filterDisplayMessages(messages,
|
|
6948
|
+
function filterDisplayMessages(messages, provider2) {
|
|
6865
6949
|
let result = messages;
|
|
6866
|
-
if (
|
|
6950
|
+
if (provider2 === "codex") {
|
|
6867
6951
|
const userMessages = result.map((msg, index) => ({ msg, index })).filter(({ msg }) => msg.type === "user");
|
|
6868
6952
|
if (userMessages.length >= 2 && isCodexInitializationPrompt(userMessages[0].msg)) {
|
|
6869
6953
|
result = result.slice(userMessages[1].index);
|
|
@@ -6894,24 +6978,24 @@ function attachSendersToMessages(messages, senders) {
|
|
|
6894
6978
|
const sendersByMessageId = new Map(senders.flatMap((sender) => sender.messageId ? [[sender.messageId, sender], [`user-${sender.messageId}`, sender]] : []));
|
|
6895
6979
|
const legacySenders = senders.filter((sender) => !sender.messageId);
|
|
6896
6980
|
const userIndices = [];
|
|
6897
|
-
const attachSender = (
|
|
6898
|
-
...
|
|
6981
|
+
const attachSender = (message2, sender) => message2.type === "user" ? {
|
|
6982
|
+
...message2,
|
|
6899
6983
|
senderUserId: sender.senderUserId,
|
|
6900
6984
|
senderEmail: sender.senderEmail,
|
|
6901
6985
|
...sender.senderDisplayName ? { senderDisplayName: sender.senderDisplayName } : {},
|
|
6902
6986
|
...sender.senderAvatarUrl ? { senderAvatarUrl: sender.senderAvatarUrl } : {}
|
|
6903
|
-
} :
|
|
6904
|
-
const next = messages.map((
|
|
6905
|
-
const sender =
|
|
6906
|
-
return sender ? attachSender(
|
|
6987
|
+
} : message2;
|
|
6988
|
+
const next = messages.map((message2) => {
|
|
6989
|
+
const sender = message2.type === "user" ? sendersByMessageId.get(message2.id) : void 0;
|
|
6990
|
+
return sender ? attachSender(message2, sender) : message2;
|
|
6907
6991
|
});
|
|
6908
|
-
messages.forEach((
|
|
6909
|
-
if (
|
|
6992
|
+
messages.forEach((message2, index) => {
|
|
6993
|
+
if (message2.type === "user" && !sendersByMessageId.has(message2.id)) {
|
|
6910
6994
|
userIndices.push(index);
|
|
6911
6995
|
}
|
|
6912
6996
|
});
|
|
6913
6997
|
const timestampSenders = senders.filter((sender) => sender.messageId && !messages.some(
|
|
6914
|
-
(
|
|
6998
|
+
(message2) => message2.type === "user" && sendersByMessageId.get(message2.id) === sender
|
|
6915
6999
|
));
|
|
6916
7000
|
for (const sender of timestampSenders) {
|
|
6917
7001
|
const senderTime = parseTimestampMs(sender.recordedAt);
|
|
@@ -6935,9 +7019,9 @@ function attachSendersToMessages(messages, senders) {
|
|
|
6935
7019
|
}
|
|
6936
7020
|
|
|
6937
7021
|
// ../shared/src/display-message/final-response.ts
|
|
6938
|
-
function extractFinalResponse(history,
|
|
6939
|
-
const
|
|
6940
|
-
return
|
|
7022
|
+
function extractFinalResponse(history, provider2) {
|
|
7023
|
+
const message2 = parseAgentEvents(history.events ?? [], provider2).findLast((candidate) => candidate.type === "agent");
|
|
7024
|
+
return message2?.type === "agent" && message2.content ? message2.content : null;
|
|
6941
7025
|
}
|
|
6942
7026
|
|
|
6943
7027
|
// ../shared/src/agent-event-utils.ts
|
|
@@ -6960,7 +7044,7 @@ function getUserMessageItemId(event) {
|
|
|
6960
7044
|
return typeof itemId === "string" ? itemId : null;
|
|
6961
7045
|
}
|
|
6962
7046
|
function excludeQueuedAcceptedEvents(events, queue, removedMessageIds = []) {
|
|
6963
|
-
const queuedMessageIds = /* @__PURE__ */ new Set([...queue.map((
|
|
7047
|
+
const queuedMessageIds = /* @__PURE__ */ new Set([...queue.map((message2) => message2.id), ...removedMessageIds]);
|
|
6964
7048
|
for (const event of events) {
|
|
6965
7049
|
for (const messageId of getRemovedMessageIds(event)) queuedMessageIds.add(messageId);
|
|
6966
7050
|
}
|
|
@@ -7058,25 +7142,25 @@ function redactSecrets(value) {
|
|
|
7058
7142
|
}
|
|
7059
7143
|
|
|
7060
7144
|
// ../shared/src/transcript-canonicalize.ts
|
|
7061
|
-
function canonicalizeChatTranscriptBlocks(content,
|
|
7145
|
+
function canonicalizeChatTranscriptBlocks(content, provider2, senders) {
|
|
7062
7146
|
const messages = attachSendersToMessages(
|
|
7063
|
-
parseDisplayMessages(parseCodexHistoryEvents(content),
|
|
7147
|
+
parseDisplayMessages(parseCodexHistoryEvents(content), provider2),
|
|
7064
7148
|
senders
|
|
7065
7149
|
);
|
|
7066
|
-
return messages.flatMap((
|
|
7150
|
+
return messages.flatMap((message2) => {
|
|
7067
7151
|
let block = null;
|
|
7068
|
-
if (
|
|
7069
|
-
block = `## User${
|
|
7070
|
-
${
|
|
7071
|
-
} else if (
|
|
7152
|
+
if (message2.type === "user") {
|
|
7153
|
+
block = `## User${message2.senderEmail ? ` (${message2.senderEmail})` : ""}
|
|
7154
|
+
${message2.content}`;
|
|
7155
|
+
} else if (message2.type === "agent") {
|
|
7072
7156
|
block = `## Agent
|
|
7073
|
-
${
|
|
7074
|
-
} else if (
|
|
7157
|
+
${message2.content}`;
|
|
7158
|
+
} else if (message2.type === "reasoning") {
|
|
7075
7159
|
block = `## Agent reasoning (unverified)
|
|
7076
|
-
Timestamp: ${
|
|
7077
|
-
${
|
|
7160
|
+
Timestamp: ${message2.sourceTimestamp ?? message2.timestamp}
|
|
7161
|
+
${message2.content}`;
|
|
7078
7162
|
} else {
|
|
7079
|
-
const activity = getDisplayMessageActivity(
|
|
7163
|
+
const activity = getDisplayMessageActivity(message2);
|
|
7080
7164
|
if (activity) {
|
|
7081
7165
|
const details = [];
|
|
7082
7166
|
if (activity.summary) details.push(`Summary: ${activity.summary}`);
|
|
@@ -7086,7 +7170,7 @@ ${activity.items.map((item) => `- [${item.status}] ${item.text}`).join("\n")}`);
|
|
|
7086
7170
|
}
|
|
7087
7171
|
if (activity.content) details.push(`Details:
|
|
7088
7172
|
${activity.content}`);
|
|
7089
|
-
if (
|
|
7173
|
+
if (message2.type === "command" && message2.exitCode != null) details.push(`Exit: ${message2.exitCode}`);
|
|
7090
7174
|
block = `## Activity
|
|
7091
7175
|
${activity.title}${details.length > 0 ? `
|
|
7092
7176
|
${details.join("\n")}` : ""}`;
|
|
@@ -7144,7 +7228,7 @@ ${CLOSE_MARKER}
|
|
|
7144
7228
|
|
|
7145
7229
|
${instruction}`;
|
|
7146
7230
|
}
|
|
7147
|
-
function formatSideChatUpdateMessage(source, turns,
|
|
7231
|
+
function formatSideChatUpdateMessage(source, turns, message2) {
|
|
7148
7232
|
const meta = { sourceProvider: source.provider, sourceTitle: source.title, trigger: "side" };
|
|
7149
7233
|
return `${OPEN_MARKER}${JSON.stringify(meta)}${OPEN_MARKER_END}
|
|
7150
7234
|
# Main chat update
|
|
@@ -7154,7 +7238,7 @@ The main chat "${source.title}" has new turns since your last reply:
|
|
|
7154
7238
|
${turns}
|
|
7155
7239
|
${CLOSE_MARKER}
|
|
7156
7240
|
|
|
7157
|
-
${
|
|
7241
|
+
${message2}`;
|
|
7158
7242
|
}
|
|
7159
7243
|
|
|
7160
7244
|
// ../shared/src/transcript-condense.ts
|
|
@@ -7333,27 +7417,27 @@ function buildCodexTokenUsageContextUsagePayload(usage) {
|
|
|
7333
7417
|
updatedAt: usage.updatedAt
|
|
7334
7418
|
};
|
|
7335
7419
|
}
|
|
7336
|
-
function resolveClaudeContextWindow(
|
|
7337
|
-
if (
|
|
7420
|
+
function resolveClaudeContextWindow(provider2, model2, reportedMaxTokens) {
|
|
7421
|
+
if (provider2 !== "claude") {
|
|
7338
7422
|
return { maxTokens: reportedMaxTokens, usedKnownWindow: false };
|
|
7339
7423
|
}
|
|
7340
|
-
const knownWindow = getClaudeModelContextWindow(
|
|
7424
|
+
const knownWindow = getClaudeModelContextWindow(model2);
|
|
7341
7425
|
return {
|
|
7342
7426
|
maxTokens: knownWindow ?? reportedMaxTokens,
|
|
7343
7427
|
usedKnownWindow: knownWindow !== null
|
|
7344
7428
|
};
|
|
7345
7429
|
}
|
|
7346
7430
|
function coerceContextUsagePayload(payload, timestamp) {
|
|
7347
|
-
const
|
|
7348
|
-
if (typeof
|
|
7431
|
+
const provider2 = payload.provider;
|
|
7432
|
+
if (typeof provider2 !== "string" || !isValidAgentProvider(provider2)) return null;
|
|
7349
7433
|
const rawTotalTokens = numberOrNull(payload.totalTokens);
|
|
7350
7434
|
const percentageValue = numberOrNull(payload.percentage);
|
|
7351
7435
|
if (rawTotalTokens === null || percentageValue === null) {
|
|
7352
7436
|
return null;
|
|
7353
7437
|
}
|
|
7354
|
-
const
|
|
7438
|
+
const model2 = typeof payload.model === "string" ? payload.model : null;
|
|
7355
7439
|
const reportedMaxTokens = numberOrNull(payload.maxTokens);
|
|
7356
|
-
const { maxTokens, usedKnownWindow } = resolveClaudeContextWindow(
|
|
7440
|
+
const { maxTokens, usedKnownWindow } = resolveClaudeContextWindow(provider2, model2, reportedMaxTokens);
|
|
7357
7441
|
const rawMaxTokens = usedKnownWindow ? maxTokens : numberOrNull(payload.rawMaxTokens);
|
|
7358
7442
|
const totalTokens = clampTokensToWindow(rawTotalTokens, maxTokens);
|
|
7359
7443
|
const source = payload.source === "codex_token_count" || payload.source === "claude_usage" || payload.source === "provider_usage" ? payload.source : "claude_context";
|
|
@@ -7373,9 +7457,9 @@ function coerceContextUsagePayload(payload, timestamp) {
|
|
|
7373
7457
|
const compactsAutomatically = typeof payload.compactsAutomatically === "boolean" ? payload.compactsAutomatically : void 0;
|
|
7374
7458
|
const autoCompactThreshold = normalizeAutoCompactThreshold(payload.autoCompactThreshold, maxTokens);
|
|
7375
7459
|
return {
|
|
7376
|
-
provider,
|
|
7460
|
+
provider: provider2,
|
|
7377
7461
|
source,
|
|
7378
|
-
...
|
|
7462
|
+
...model2 ? { model: model2 } : {},
|
|
7379
7463
|
totalTokens,
|
|
7380
7464
|
maxTokens,
|
|
7381
7465
|
rawMaxTokens,
|
|
@@ -7406,18 +7490,18 @@ function codexTokenCountToContextUsage(event) {
|
|
|
7406
7490
|
updatedAt: event.timestamp
|
|
7407
7491
|
});
|
|
7408
7492
|
}
|
|
7409
|
-
function extractLatestContextUsage(events,
|
|
7493
|
+
function extractLatestContextUsage(events, provider2) {
|
|
7410
7494
|
if (!events || events.length === 0) return null;
|
|
7411
7495
|
let latest = null;
|
|
7412
7496
|
for (const event of events) {
|
|
7413
7497
|
if (event.type === CONTEXT_USAGE_EVENT_TYPE) {
|
|
7414
7498
|
const usage = coerceContextUsagePayload(event.payload, event.timestamp);
|
|
7415
|
-
if (usage && usage.provider ===
|
|
7499
|
+
if (usage && usage.provider === provider2) {
|
|
7416
7500
|
latest = usage;
|
|
7417
7501
|
}
|
|
7418
7502
|
continue;
|
|
7419
7503
|
}
|
|
7420
|
-
if (
|
|
7504
|
+
if (provider2 === "codex") {
|
|
7421
7505
|
const usage = codexTokenCountToContextUsage(event);
|
|
7422
7506
|
if (usage) {
|
|
7423
7507
|
latest = usage;
|
|
@@ -7530,7 +7614,7 @@ function normalizeSlashCommandName(name) {
|
|
|
7530
7614
|
if (!command || /\s/.test(command)) return null;
|
|
7531
7615
|
return `/${command}`;
|
|
7532
7616
|
}
|
|
7533
|
-
function createProviderSlashCommand(
|
|
7617
|
+
function createProviderSlashCommand(provider2, name, description, argumentHint) {
|
|
7534
7618
|
const command = normalizeSlashCommandName(name);
|
|
7535
7619
|
if (!command) return null;
|
|
7536
7620
|
const trimmedDescription = description?.trim();
|
|
@@ -7539,7 +7623,7 @@ function createProviderSlashCommand(provider, name, description, argumentHint) {
|
|
|
7539
7623
|
command,
|
|
7540
7624
|
description: trimmedDescription || `Run ${command}.`,
|
|
7541
7625
|
...trimmedArgumentHint ? { argumentHint: trimmedArgumentHint } : {},
|
|
7542
|
-
providers: [
|
|
7626
|
+
providers: [provider2]
|
|
7543
7627
|
};
|
|
7544
7628
|
}
|
|
7545
7629
|
var SIDE_CHAT_COMMANDS = ["/btw", "/side"];
|
|
@@ -7596,8 +7680,8 @@ function mergeSlashCommands(...commandGroups) {
|
|
|
7596
7680
|
}
|
|
7597
7681
|
return commands;
|
|
7598
7682
|
}
|
|
7599
|
-
function getSlashCommandsForProvider(
|
|
7600
|
-
return commands.filter((command) => command.providers.includes(
|
|
7683
|
+
function getSlashCommandsForProvider(provider2, commands = SLASH_COMMANDS) {
|
|
7684
|
+
return commands.filter((command) => command.providers.includes(provider2));
|
|
7601
7685
|
}
|
|
7602
7686
|
var MAX_CODEX_GOAL_OBJECTIVE_CHARS = 4e3;
|
|
7603
7687
|
function classifyGoalValue(value) {
|
|
@@ -7606,20 +7690,20 @@ function classifyGoalValue(value) {
|
|
|
7606
7690
|
if (/^resume$/i.test(value)) return { type: "resume" };
|
|
7607
7691
|
return { type: "set", objective: value };
|
|
7608
7692
|
}
|
|
7609
|
-
function parseGoalCommand(
|
|
7610
|
-
const match =
|
|
7693
|
+
function parseGoalCommand(message2) {
|
|
7694
|
+
const match = message2.trim().match(/^\/goal(?:\s+([\s\S]*))?$/i);
|
|
7611
7695
|
const value = match?.[1]?.trim();
|
|
7612
7696
|
if (!value) return null;
|
|
7613
7697
|
return classifyGoalValue(value);
|
|
7614
7698
|
}
|
|
7615
|
-
function getGoalCommand(
|
|
7616
|
-
if (!goalMode) return parseGoalCommand(
|
|
7617
|
-
const value =
|
|
7699
|
+
function getGoalCommand(message2, goalMode) {
|
|
7700
|
+
if (!goalMode) return parseGoalCommand(message2);
|
|
7701
|
+
const value = message2.trim();
|
|
7618
7702
|
if (!value) return null;
|
|
7619
7703
|
return classifyGoalValue(value);
|
|
7620
7704
|
}
|
|
7621
|
-
function getGoalCommandObjectiveValidationError(
|
|
7622
|
-
const command = getGoalCommand(
|
|
7705
|
+
function getGoalCommandObjectiveValidationError(message2, goalMode) {
|
|
7706
|
+
const command = getGoalCommand(message2, goalMode);
|
|
7623
7707
|
if (command?.type !== "set") return null;
|
|
7624
7708
|
const length = command.objective.length;
|
|
7625
7709
|
if (length <= MAX_CODEX_GOAL_OBJECTIVE_CHARS) return null;
|
|
@@ -7997,7 +8081,7 @@ var CLAUDE_AUTH_ENV_KEYS_BY_METHOD = {
|
|
|
7997
8081
|
};
|
|
7998
8082
|
|
|
7999
8083
|
// ../shared/src/routes/command-protection.ts
|
|
8000
|
-
import { z as
|
|
8084
|
+
import { z as z15 } from "zod";
|
|
8001
8085
|
|
|
8002
8086
|
// ../shared/src/git-invocations.ts
|
|
8003
8087
|
var COMMIT_VALUE_OPTIONS = /* @__PURE__ */ new Set(["message", "file", "trailer", "reuse-message", "reedit-message", "fixup", "squash", "template", "author", "date", "cleanup", "pathspec-from-file"]);
|
|
@@ -8088,27 +8172,27 @@ function findCheckoutTarget(args) {
|
|
|
8088
8172
|
}
|
|
8089
8173
|
|
|
8090
8174
|
// ../shared/src/routes/command-protection.ts
|
|
8091
|
-
var commandProtectionRepoStateSchema =
|
|
8092
|
-
branch:
|
|
8093
|
-
defaultBranch:
|
|
8094
|
-
pushBranch:
|
|
8095
|
-
pushConfig:
|
|
8096
|
-
headMessage:
|
|
8097
|
-
mergeInProgress:
|
|
8175
|
+
var commandProtectionRepoStateSchema = z15.object({
|
|
8176
|
+
branch: z15.string().nullable(),
|
|
8177
|
+
defaultBranch: z15.string().nullable(),
|
|
8178
|
+
pushBranch: z15.string().nullable(),
|
|
8179
|
+
pushConfig: z15.string().nullable(),
|
|
8180
|
+
headMessage: z15.string().nullable(),
|
|
8181
|
+
mergeInProgress: z15.boolean().optional()
|
|
8098
8182
|
});
|
|
8099
|
-
var commandProtectionEvaluateRequestSchema =
|
|
8100
|
-
provider:
|
|
8101
|
-
source:
|
|
8102
|
-
toolName:
|
|
8103
|
-
toolInput:
|
|
8104
|
-
command:
|
|
8105
|
-
cwd:
|
|
8106
|
-
toolUseId:
|
|
8183
|
+
var commandProtectionEvaluateRequestSchema = z15.object({
|
|
8184
|
+
provider: z15.enum(["claude", "codex", "cursor", "opencode", "pi"]),
|
|
8185
|
+
source: z15.enum(["claude_pre_tool_use", "codex_approval_request", "cursor_pre_tool_use", "opencode_pre_tool_use", "pi_tool_call"]),
|
|
8186
|
+
toolName: z15.string(),
|
|
8187
|
+
toolInput: z15.unknown(),
|
|
8188
|
+
command: z15.string().nullish(),
|
|
8189
|
+
cwd: z15.string().nullish(),
|
|
8190
|
+
toolUseId: z15.string().nullish(),
|
|
8107
8191
|
// Read by the engine before the command runs, keyed by absolute path, so the
|
|
8108
8192
|
// policy can see branches and commit messages the command text only references.
|
|
8109
|
-
gitContext:
|
|
8110
|
-
repos:
|
|
8111
|
-
messageFiles:
|
|
8193
|
+
gitContext: z15.object({
|
|
8194
|
+
repos: z15.record(z15.string(), commandProtectionRepoStateSchema),
|
|
8195
|
+
messageFiles: z15.record(z15.string(), z15.string())
|
|
8112
8196
|
}).optional()
|
|
8113
8197
|
});
|
|
8114
8198
|
var COMMAND_PROTECTION_COMMAND_KEYS = ["command", "cmd", "script", "query", "endpoint", "path", "url", "mutation"];
|
|
@@ -8305,89 +8389,89 @@ function shouldRefreshPullRequests(toolName, toolInput) {
|
|
|
8305
8389
|
}
|
|
8306
8390
|
|
|
8307
8391
|
// ../shared/src/routes/linear.ts
|
|
8308
|
-
import { z as
|
|
8309
|
-
var linearSessionMetadataSchema =
|
|
8310
|
-
via_mothership:
|
|
8311
|
-
issue_id:
|
|
8312
|
-
issue_identifier:
|
|
8313
|
-
issue_title:
|
|
8314
|
-
issue_description:
|
|
8315
|
-
issue_url:
|
|
8316
|
-
comment_id:
|
|
8317
|
-
comment_body:
|
|
8318
|
-
triggered_by_id:
|
|
8319
|
-
triggered_by_name:
|
|
8320
|
-
triggered_by_email:
|
|
8321
|
-
linear_workspace_id:
|
|
8322
|
-
creator_id:
|
|
8323
|
-
creator_name:
|
|
8324
|
-
creator_email:
|
|
8325
|
-
assignee_id:
|
|
8326
|
-
assignee_name:
|
|
8327
|
-
assignee_email:
|
|
8328
|
-
issue_state:
|
|
8329
|
-
parent_issue:
|
|
8330
|
-
id:
|
|
8331
|
-
identifier:
|
|
8332
|
-
title:
|
|
8333
|
-
description:
|
|
8392
|
+
import { z as z16 } from "zod";
|
|
8393
|
+
var linearSessionMetadataSchema = z16.object({
|
|
8394
|
+
via_mothership: z16.boolean().optional(),
|
|
8395
|
+
issue_id: z16.string(),
|
|
8396
|
+
issue_identifier: z16.string(),
|
|
8397
|
+
issue_title: z16.string(),
|
|
8398
|
+
issue_description: z16.string(),
|
|
8399
|
+
issue_url: z16.string(),
|
|
8400
|
+
comment_id: z16.string(),
|
|
8401
|
+
comment_body: z16.string(),
|
|
8402
|
+
triggered_by_id: z16.string().optional(),
|
|
8403
|
+
triggered_by_name: z16.string().optional(),
|
|
8404
|
+
triggered_by_email: z16.string().optional(),
|
|
8405
|
+
linear_workspace_id: z16.string().optional(),
|
|
8406
|
+
creator_id: z16.string().optional(),
|
|
8407
|
+
creator_name: z16.string().optional(),
|
|
8408
|
+
creator_email: z16.string().optional(),
|
|
8409
|
+
assignee_id: z16.string().optional(),
|
|
8410
|
+
assignee_name: z16.string().optional(),
|
|
8411
|
+
assignee_email: z16.string().optional(),
|
|
8412
|
+
issue_state: z16.string().optional(),
|
|
8413
|
+
parent_issue: z16.object({
|
|
8414
|
+
id: z16.string(),
|
|
8415
|
+
identifier: z16.string(),
|
|
8416
|
+
title: z16.string(),
|
|
8417
|
+
description: z16.string().nullable()
|
|
8334
8418
|
}).optional(),
|
|
8335
|
-
workspace:
|
|
8336
|
-
id:
|
|
8337
|
-
coding_agent:
|
|
8338
|
-
task_description:
|
|
8339
|
-
created_at:
|
|
8419
|
+
workspace: z16.object({
|
|
8420
|
+
id: z16.string(),
|
|
8421
|
+
coding_agent: z16.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
|
|
8422
|
+
task_description: z16.string(),
|
|
8423
|
+
created_at: z16.string()
|
|
8340
8424
|
}).optional()
|
|
8341
8425
|
});
|
|
8342
8426
|
|
|
8343
8427
|
// ../shared/src/routes/mothership.ts
|
|
8344
|
-
import { z as
|
|
8428
|
+
import { z as z17 } from "zod";
|
|
8345
8429
|
var MOTHERSHIP_LINEAR_ACTIONS = ["ask", "start"];
|
|
8346
|
-
var mothershipLinearSessionIntentRequestSchema =
|
|
8347
|
-
comment_id:
|
|
8348
|
-
action:
|
|
8430
|
+
var mothershipLinearSessionIntentRequestSchema = z17.object({
|
|
8431
|
+
comment_id: z17.string().trim().min(1).describe("Id of the Linear comment the session will be created on."),
|
|
8432
|
+
action: z17.enum(MOTHERSHIP_LINEAR_ACTIONS).describe("`ask` when the comment is a clarifying question, `start` when it is the complete task prompt.")
|
|
8349
8433
|
});
|
|
8350
|
-
var mothershipLinearStartRequestSchema =
|
|
8351
|
-
issue_id:
|
|
8352
|
-
agent_session_id:
|
|
8353
|
-
prompt:
|
|
8434
|
+
var mothershipLinearStartRequestSchema = z17.object({
|
|
8435
|
+
issue_id: z17.string().describe("Linear issue id from the envelope's `issue_id`."),
|
|
8436
|
+
agent_session_id: z17.string().describe("Existing Linear agent session id from the envelope's `agent_session_id`."),
|
|
8437
|
+
prompt: z17.string().trim().min(1).describe("Complete task prompt for the coding workspace.")
|
|
8354
8438
|
});
|
|
8355
|
-
var slackChannelIdSchema =
|
|
8356
|
-
var slackThreadTsSchema =
|
|
8357
|
-
var mothershipSlackSpawnRequestSchema =
|
|
8439
|
+
var slackChannelIdSchema = z17.string().describe("Slack channel id from the envelope's `channel_id`.");
|
|
8440
|
+
var slackThreadTsSchema = z17.string().describe("Slack thread timestamp from the envelope's `thread_ts`.");
|
|
8441
|
+
var mothershipSlackSpawnRequestSchema = z17.object({
|
|
8358
8442
|
channel_id: slackChannelIdSchema,
|
|
8359
8443
|
thread_ts: slackThreadTsSchema,
|
|
8360
|
-
message_ts:
|
|
8361
|
-
user_id:
|
|
8362
|
-
prompt:
|
|
8363
|
-
environment_id:
|
|
8444
|
+
message_ts: z17.string().describe("Timestamp of the Slack message that asked for the work (the envelope's `message_ts`). The server verifies this message and its author."),
|
|
8445
|
+
user_id: z17.string().describe("Slack user id of that message's author (the envelope's `user_id`). The workspace is attributed to them."),
|
|
8446
|
+
prompt: z17.string().describe("Complete task for the new workspace, written so it stands on its own."),
|
|
8447
|
+
environment_id: z17.string().optional().describe(`Environment id from \`${REPLICAS_MCP_TOOLS.listEnvironments}\`. Pass it only when clearly confident it fits; omit it to let routing choose. If routing cannot choose, the call fails and nothing is posted, so pick one or ask the person.`)
|
|
8364
8448
|
});
|
|
8365
|
-
var mothershipSlackRelayRequestSchema =
|
|
8449
|
+
var mothershipSlackRelayRequestSchema = z17.object({
|
|
8366
8450
|
channel_id: slackChannelIdSchema,
|
|
8367
8451
|
thread_ts: slackThreadTsSchema,
|
|
8368
|
-
message:
|
|
8369
|
-
user_id:
|
|
8370
|
-
queue:
|
|
8452
|
+
message: z17.string().describe("The follow-up to deliver, combining every fresh message that belongs to this update."),
|
|
8453
|
+
user_id: z17.string().optional().describe("Slack user id of the follow-up's author (the envelope's `user_id`), so it is attributed to them. Defaults to the thread's original requester."),
|
|
8454
|
+
queue: z17.boolean().optional().describe("Set true only when the person explicitly asked for this to happen after the current task finishes. Delivers behind the active turn instead of interrupting it.")
|
|
8371
8455
|
});
|
|
8372
|
-
var mothershipSlackConfirmationSchema =
|
|
8373
|
-
confirmation_channel_id:
|
|
8374
|
-
confirmation_thread_ts:
|
|
8375
|
-
confirmation_message_ts:
|
|
8376
|
-
confirmation_user_id:
|
|
8456
|
+
var mothershipSlackConfirmationSchema = z17.object({
|
|
8457
|
+
confirmation_channel_id: z17.string().describe("`channel_id` from the envelope of the Slack message that asked for or accepted this."),
|
|
8458
|
+
confirmation_thread_ts: z17.string().describe("`thread_ts` from that message's envelope."),
|
|
8459
|
+
confirmation_message_ts: z17.string().describe("`message_ts` from that message's envelope."),
|
|
8460
|
+
confirmation_user_id: z17.string().describe("`user_id` from that message's envelope.")
|
|
8377
8461
|
});
|
|
8378
8462
|
var mothershipAutomationToolInputSchema = automationToolInputSchema.extend(mothershipSlackConfirmationSchema.shape);
|
|
8379
8463
|
var mothershipSaveChannelPresetToolInputSchema = mothershipSlackConfirmationSchema.extend({
|
|
8380
|
-
preset_id:
|
|
8381
|
-
name:
|
|
8382
|
-
description:
|
|
8383
|
-
icon:
|
|
8384
|
-
instructions:
|
|
8464
|
+
preset_id: z17.string().optional().describe(`Id of the preset to update, from \`${REPLICAS_MCP_TOOLS.listChannelSettings}\`. Omit to create a new preset.`),
|
|
8465
|
+
name: z17.string().trim().min(1).max(MOTHERSHIP_PRESET_NAME_MAX_LENGTH).optional().describe("Preset name. Required when creating."),
|
|
8466
|
+
description: z17.string().optional().describe("One-line summary shown in settings."),
|
|
8467
|
+
icon: z17.enum(MOTHERSHIP_PRESET_ICONS).optional(),
|
|
8468
|
+
instructions: z17.string().optional().describe("Complete preset instructions; replaces the existing text. Required when creating.")
|
|
8385
8469
|
});
|
|
8386
8470
|
var mothershipUpdateChannelSettingsToolInputSchema = mothershipSlackConfirmationSchema.extend({
|
|
8387
|
-
source:
|
|
8388
|
-
external_id:
|
|
8389
|
-
preset_id:
|
|
8390
|
-
instructions:
|
|
8471
|
+
source: z17.enum(MOTHERSHIP_SOURCE_TYPES).optional().describe("Defaults to `slack`."),
|
|
8472
|
+
external_id: z17.string().describe(`Slack channel id or Linear team id of an already monitored source, from \`${REPLICAS_MCP_TOOLS.listChannelSettings}\`.`),
|
|
8473
|
+
preset_id: z17.string().nullable().optional().describe("Preset to assign; `null` removes the preset. Omit to keep it."),
|
|
8474
|
+
instructions: z17.string().nullable().optional().describe("Complete channel-specific instructions, applied after the preset; replaces the existing text. `null` clears them. Omit to keep them.")
|
|
8391
8475
|
});
|
|
8392
8476
|
|
|
8393
8477
|
// ../shared/src/routes/plugin-catalog.ts
|
|
@@ -8711,85 +8795,46 @@ var workspaceLastViewedAtClientStateKey = orgUserClientStateKey(WORKSPACE_LAST_V
|
|
|
8711
8795
|
var workspaceAttentionDoneClientStateKey = orgUserClientStateKey(WORKSPACE_ATTENTION_DONE_CLIENT_STATE_KEY_PREFIX);
|
|
8712
8796
|
var workspaceStagesClientStateKey = orgUserClientStateKey(WORKSPACE_STAGES_CLIENT_STATE_KEY_PREFIX);
|
|
8713
8797
|
|
|
8714
|
-
// ../shared/src/routes/workspaces.ts
|
|
8715
|
-
import { z as z16 } from "zod";
|
|
8716
|
-
var WORKSPACE_STATUSES = ["active", "sleeping", "archived", "preparing", "error"];
|
|
8717
|
-
var STALE_PREPARING_MS = 10 * 6e4;
|
|
8718
|
-
var WORKSPACE_STATUS_FILTERS = WORKSPACE_STATUSES.map((status) => status === "error" ? "failed" : status);
|
|
8719
|
-
var WORKSPACE_SORT_CHOICES = [
|
|
8720
|
-
["manual", "Custom"],
|
|
8721
|
-
["activity", "Last activity"],
|
|
8722
|
-
["created", "Created date"]
|
|
8723
|
-
];
|
|
8724
|
-
var WORKSPACE_SORT_OPTIONS = WORKSPACE_SORT_CHOICES.map(([option]) => option);
|
|
8725
|
-
var WORKSPACE_SORT_LABELS = Object.fromEntries(WORKSPACE_SORT_CHOICES);
|
|
8726
|
-
var WORKSPACE_SIDEBAR_ORGANIZATION_CHOICES = [
|
|
8727
|
-
["chronological", "Chronological"],
|
|
8728
|
-
["environments", "Environments"],
|
|
8729
|
-
["recent", "Recent environments"]
|
|
8730
|
-
];
|
|
8731
|
-
var WORKSPACE_SIDEBAR_ORGANIZATIONS = WORKSPACE_SIDEBAR_ORGANIZATION_CHOICES.map(([organization]) => organization);
|
|
8732
|
-
var WORKSPACE_SIDEBAR_ORGANIZATION_LABELS = Object.fromEntries(WORKSPACE_SIDEBAR_ORGANIZATION_CHOICES);
|
|
8733
|
-
var DEFAULT_STATUS_FILTERS = [...WORKSPACE_STATUS_FILTERS];
|
|
8734
|
-
var DEFAULT_WORKSPACE_FILTERS = {
|
|
8735
|
-
statuses: [...DEFAULT_STATUS_FILTERS],
|
|
8736
|
-
ownerIds: [],
|
|
8737
|
-
activity: "any"
|
|
8738
|
-
};
|
|
8739
|
-
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
8740
|
-
var workspaceExecRequestSchema = z16.object({
|
|
8741
|
-
command: z16.string().regex(/\S/, "command is required"),
|
|
8742
|
-
timeout_seconds: z16.number().int().min(1).max(50).optional().describe("Default: 30")
|
|
8743
|
-
});
|
|
8744
|
-
var terminalRtcCandidateSchema = z16.object({ type: z16.literal("rtc-candidate"), candidate: z16.string(), mid: z16.string() });
|
|
8745
|
-
var terminalSocketServerMessageSchema = z16.discriminatedUnion("type", [
|
|
8746
|
-
z16.object({ type: z16.literal("output"), data: z16.string() }),
|
|
8747
|
-
z16.object({ type: z16.literal("rtc-answer"), sdp: z16.string() }),
|
|
8748
|
-
terminalRtcCandidateSchema,
|
|
8749
|
-
z16.object({ type: z16.literal("rtc-switch") })
|
|
8750
|
-
]);
|
|
8751
|
-
var TERMINAL_RTC_ICE_SERVER = "stun:stun.l.google.com:19302";
|
|
8752
|
-
|
|
8753
8798
|
// ../shared/src/routes/workspace-events.ts
|
|
8754
|
-
import { z as
|
|
8755
|
-
var workspaceChangedEventSchema =
|
|
8756
|
-
|
|
8757
|
-
type:
|
|
8758
|
-
workspaceId:
|
|
8759
|
-
completion:
|
|
8760
|
-
workspaceName:
|
|
8761
|
-
completedAt:
|
|
8762
|
-
processing:
|
|
8799
|
+
import { z as z18 } from "zod";
|
|
8800
|
+
var workspaceChangedEventSchema = z18.discriminatedUnion("type", [
|
|
8801
|
+
z18.object({
|
|
8802
|
+
type: z18.literal("workspace.changed"),
|
|
8803
|
+
workspaceId: z18.string(),
|
|
8804
|
+
completion: z18.object({
|
|
8805
|
+
workspaceName: z18.string(),
|
|
8806
|
+
completedAt: z18.string(),
|
|
8807
|
+
processing: z18.boolean().optional()
|
|
8763
8808
|
}).optional(),
|
|
8764
|
-
ts:
|
|
8809
|
+
ts: z18.string()
|
|
8765
8810
|
}),
|
|
8766
|
-
|
|
8767
|
-
type:
|
|
8768
|
-
workspaceId:
|
|
8769
|
-
chatId:
|
|
8770
|
-
ts:
|
|
8811
|
+
z18.object({
|
|
8812
|
+
type: z18.literal("workspace.chat.changed"),
|
|
8813
|
+
workspaceId: z18.string(),
|
|
8814
|
+
chatId: z18.string(),
|
|
8815
|
+
ts: z18.string()
|
|
8771
8816
|
}),
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
type:
|
|
8775
|
-
workspaceId:
|
|
8776
|
-
ts:
|
|
8817
|
+
z18.object({ type: z18.literal("presence.changed"), ts: z18.string() }),
|
|
8818
|
+
z18.object({
|
|
8819
|
+
type: z18.literal("mobile-testing.changed"),
|
|
8820
|
+
workspaceId: z18.string(),
|
|
8821
|
+
ts: z18.string()
|
|
8777
8822
|
})
|
|
8778
8823
|
]);
|
|
8779
8824
|
|
|
8780
8825
|
// ../shared/src/routes/presence.ts
|
|
8781
|
-
import { z as
|
|
8782
|
-
var presenceStatusSchema =
|
|
8783
|
-
var presenceLocationSchema =
|
|
8784
|
-
workspaceId:
|
|
8826
|
+
import { z as z19 } from "zod";
|
|
8827
|
+
var presenceStatusSchema = z19.enum(["online", "typing"]);
|
|
8828
|
+
var presenceLocationSchema = z19.object({
|
|
8829
|
+
workspaceId: z19.string().optional()
|
|
8785
8830
|
});
|
|
8786
|
-
var presenceEntrySchema =
|
|
8787
|
-
userId:
|
|
8831
|
+
var presenceEntrySchema = z19.object({
|
|
8832
|
+
userId: z19.string(),
|
|
8788
8833
|
status: presenceStatusSchema,
|
|
8789
8834
|
location: presenceLocationSchema,
|
|
8790
|
-
ts:
|
|
8835
|
+
ts: z19.string()
|
|
8791
8836
|
});
|
|
8792
|
-
var updatePresenceRequestSchema =
|
|
8837
|
+
var updatePresenceRequestSchema = z19.object({
|
|
8793
8838
|
status: presenceStatusSchema,
|
|
8794
8839
|
location: presenceLocationSchema.optional()
|
|
8795
8840
|
});
|
|
@@ -8864,20 +8909,6 @@ function scoreRepoFileMatch(query, filePath) {
|
|
|
8864
8909
|
var WEBHOOK_PROVIDERS = ["linear", "github", "gitlab", "slack", "e2b", "stripe", "sentry"];
|
|
8865
8910
|
var WEBHOOK_PROVIDER_SET = new Set(WEBHOOK_PROVIDERS);
|
|
8866
8911
|
|
|
8867
|
-
// ../shared/src/routes/environment.ts
|
|
8868
|
-
import { z as z19 } from "zod";
|
|
8869
|
-
var ENVIRONMENT_MCP_TRANSPORTS = ["stdio", "http", "sse"];
|
|
8870
|
-
var stringMap = z19.record(z19.string(), z19.string());
|
|
8871
|
-
var createEnvironmentMcpRequestSchema = z19.object({
|
|
8872
|
-
name: z19.string(),
|
|
8873
|
-
transport: z19.enum(ENVIRONMENT_MCP_TRANSPORTS),
|
|
8874
|
-
config: z19.union([
|
|
8875
|
-
z19.object({ command: z19.string().min(1), args: z19.array(z19.string()).optional(), env: stringMap.optional() }),
|
|
8876
|
-
z19.object({ url: z19.url(), headers: stringMap.optional(), auth: mcpWorkloadAuthSchema.optional() })
|
|
8877
|
-
]).describe("stdio: `{ command, args, env }`. http/sse: `{ url, headers }`.")
|
|
8878
|
-
});
|
|
8879
|
-
var updateEnvironmentMcpRequestSchema = createEnvironmentMcpRequestSchema.partial();
|
|
8880
|
-
|
|
8881
8912
|
// ../shared/src/workspace-sidebar-state.ts
|
|
8882
8913
|
var FIRST_BOOT_GRACE_MS = 15 * 6e4;
|
|
8883
8914
|
var SLOW_ENGINE_GRACE_MS = 10 * 6e4;
|
|
@@ -9023,12 +9054,12 @@ function normalizeChatTranscriptMetadata(value) {
|
|
|
9023
9054
|
if (!isRecord(value)) return {};
|
|
9024
9055
|
const metadata = {};
|
|
9025
9056
|
const {
|
|
9026
|
-
provider,
|
|
9057
|
+
provider: provider2,
|
|
9027
9058
|
credential,
|
|
9028
9059
|
credentialSource,
|
|
9029
9060
|
environmentAuthMethod,
|
|
9030
|
-
model,
|
|
9031
|
-
title,
|
|
9061
|
+
model: model2,
|
|
9062
|
+
title: title2,
|
|
9032
9063
|
displayName,
|
|
9033
9064
|
createdAt,
|
|
9034
9065
|
updatedAt,
|
|
@@ -9042,14 +9073,14 @@ function normalizeChatTranscriptMetadata(value) {
|
|
|
9042
9073
|
sha256,
|
|
9043
9074
|
fork
|
|
9044
9075
|
} = value;
|
|
9045
|
-
if (typeof
|
|
9076
|
+
if (typeof provider2 === "string" && isValidAgentProvider(provider2)) metadata.provider = provider2;
|
|
9046
9077
|
const parsedCredential = agentCredentialSnapshotSchema.safeParse(credential);
|
|
9047
9078
|
if (parsedCredential.success) metadata.credential = parsedCredential.data;
|
|
9048
9079
|
if (credentialSource === "stored" || credentialSource === "environment") metadata.credentialSource = credentialSource;
|
|
9049
9080
|
const authMethod = Object.values(CREDENTIAL_METHOD).find((method) => method === environmentAuthMethod);
|
|
9050
9081
|
if (authMethod) metadata.environmentAuthMethod = authMethod;
|
|
9051
|
-
if (typeof
|
|
9052
|
-
if (typeof
|
|
9082
|
+
if (typeof model2 === "string") metadata.model = model2;
|
|
9083
|
+
if (typeof title2 === "string") metadata.title = title2;
|
|
9053
9084
|
if (typeof displayName === "string") metadata.displayName = displayName;
|
|
9054
9085
|
if (typeof createdAt === "string") metadata.createdAt = createdAt;
|
|
9055
9086
|
if (typeof updatedAt === "string") metadata.updatedAt = updatedAt;
|
|
@@ -9255,9 +9286,21 @@ export {
|
|
|
9255
9286
|
decodePathSegments,
|
|
9256
9287
|
buildCodeHostPrUrl,
|
|
9257
9288
|
createUuidFromHex,
|
|
9289
|
+
SUBAGENT_MCP_SERVER_NAME,
|
|
9290
|
+
SUBAGENT_MCP_TOOLS,
|
|
9291
|
+
SUBAGENT_MCP_TOOL_NAMES,
|
|
9292
|
+
WORKSPACE_IDENTITY_AUDIENCE,
|
|
9293
|
+
AWS_SOURCE_IDENTITY_CLAIM,
|
|
9294
|
+
IDENTITY_PROXY_PORT,
|
|
9295
|
+
IDENTITY_TOKEN_PATH,
|
|
9296
|
+
workspaceAudienceSchema,
|
|
9297
|
+
workspaceTokenRequestSchema,
|
|
9298
|
+
workspaceTokenResponseSchema,
|
|
9299
|
+
legacyWorkspaceTokenBundleSchema,
|
|
9258
9300
|
SANDBOX_SKILL_DIRS,
|
|
9259
9301
|
HISTORY_ROOT,
|
|
9260
9302
|
HISTORY_INDEX_FILENAME,
|
|
9303
|
+
TERMINAL_RTC_ICE_SERVER,
|
|
9261
9304
|
REPLICAS_INSTRUCTIONS_TAG,
|
|
9262
9305
|
wrapInTag,
|
|
9263
9306
|
extractErrorText,
|
|
@@ -9322,9 +9365,6 @@ export {
|
|
|
9322
9365
|
resolveWarmHookConfig,
|
|
9323
9366
|
REPLICAS_CONFIG_FILENAMES,
|
|
9324
9367
|
parseReplicasConfigString,
|
|
9325
|
-
SUBAGENT_MCP_SERVER_NAME,
|
|
9326
|
-
SUBAGENT_MCP_TOOLS,
|
|
9327
|
-
SUBAGENT_MCP_TOOL_NAMES,
|
|
9328
9368
|
headlessAgentRequestSchema,
|
|
9329
9369
|
isClaudeAuthErrorText,
|
|
9330
9370
|
isCodexAuthError,
|
|
@@ -9344,18 +9384,9 @@ export {
|
|
|
9344
9384
|
findGitCommitSignals,
|
|
9345
9385
|
findCommandProtectionGitLookups,
|
|
9346
9386
|
shouldRefreshPullRequests,
|
|
9347
|
-
TERMINAL_RTC_ICE_SERVER,
|
|
9348
9387
|
MAX_REPO_FILE_CONTENT_BYTES,
|
|
9349
9388
|
searchRepoFileIndex,
|
|
9350
9389
|
isExcludedRepoFilePath,
|
|
9351
|
-
WORKSPACE_IDENTITY_AUDIENCE,
|
|
9352
|
-
AWS_SOURCE_IDENTITY_CLAIM,
|
|
9353
|
-
IDENTITY_PROXY_PORT,
|
|
9354
|
-
IDENTITY_TOKEN_PATH,
|
|
9355
|
-
workspaceAudienceSchema,
|
|
9356
|
-
workspaceTokenRequestSchema,
|
|
9357
|
-
workspaceTokenResponseSchema,
|
|
9358
|
-
legacyWorkspaceTokenBundleSchema,
|
|
9359
9390
|
readJsonlPage,
|
|
9360
9391
|
normalizeChatTranscriptMetadata,
|
|
9361
9392
|
parseChatTranscriptArtifact,
|